From 3be9a6927d21794ca4fbb06f71b09ee6f6f8ca40 Mon Sep 17 00:00:00 2001 From: MonsterDruide1 <5958456@gmail.com> Date: Fri, 9 Jul 2021 12:29:51 +0200 Subject: [PATCH] ksys/phys: Add RagdollControllerKeyList-Resource --- data/uking_functions.csv | 28 +++++----- src/KingSystem/Physics/CMakeLists.txt | 2 + .../System/physRagdollControllerKeyList.cpp | 56 +++++++++++++++++++ .../System/physRagdollControllerKeyList.h | 46 +++++++++++++++ 4 files changed, 118 insertions(+), 14 deletions(-) create mode 100644 src/KingSystem/Physics/System/physRagdollControllerKeyList.cpp create mode 100644 src/KingSystem/Physics/System/physRagdollControllerKeyList.h diff --git a/data/uking_functions.csv b/data/uking_functions.csv index 7c34abf2..75aaa698 100644 --- a/data/uking_functions.csv +++ b/data/uking_functions.csv @@ -95289,20 +95289,20 @@ 0x00000071012ab97c,sub_71012AB97C,344, 0x00000071012abad4,sub_71012ABAD4,8, 0x00000071012abadc,sub_71012ABADC,284, -0x00000071012abbf8,sub_71012ABBF8,928, -0x00000071012abf98,sub_71012ABF98,64, -0x00000071012abfd8,sub_71012ABFD8,212, -0x00000071012ac0ac,sub_71012AC0AC,212, -0x00000071012ac180,sub_71012AC180,220, -0x00000071012ac25c,sub_71012AC25C,220, -0x00000071012ac338,sub_71012AC338,340, -0x00000071012ac48c,sub_71012AC48C,400, -0x00000071012ac61c,sub_71012AC61C,8, -0x00000071012ac624,sub_71012AC624,92, -0x00000071012ac680,sub_71012AC680,8, -0x00000071012ac688,sub_71012AC688,84, -0x00000071012ac6dc,j__ZdlPv_1288,4, -0x00000071012ac6e0,sub_71012AC6E0,372, +0x00000071012abbf8,sub_71012ABBF8,928,_ZN4ksys4phys24RagdollControllerKeyList20RagdollControllerKeyC1Ev +0x00000071012abf98,sub_71012ABF98,64,_ZN4ksys4phys24RagdollControllerKeyListC1Ev +0x00000071012abfd8,sub_71012ABFD8,212,_ZN4ksys4phys24RagdollControllerKeyListD1Ev +0x00000071012ac0ac,sub_71012AC0AC,212,_ZThn32_N4ksys4phys24RagdollControllerKeyListD1Ev +0x00000071012ac180,sub_71012AC180,220,_ZN4ksys4phys24RagdollControllerKeyListD0Ev +0x00000071012ac25c,sub_71012AC25C,220,_ZThn32_N4ksys4phys24RagdollControllerKeyListD0Ev +0x00000071012ac338,sub_71012AC338,340,_ZN4ksys4phys24RagdollControllerKeyList21getControllerKeyByKeyERKN4sead14SafeStringBaseIcEE +0x00000071012ac48c,sub_71012AC48C,400,_ZN4ksys4phys24RagdollControllerKeyList6parse_EPhmPN4sead4HeapE +0x00000071012ac61c,sub_71012AC61C,8,_ZNK4ksys4phys24RagdollControllerKeyList27checkDerivedRuntimeTypeInfoEPKN4sead15RuntimeTypeInfo9InterfaceE +0x00000071012ac624,sub_71012AC624,92,_ZNK4ksys4phys24RagdollControllerKeyList18getRuntimeTypeInfoEv +0x00000071012ac680,sub_71012AC680,8,_ZNK4ksys4phys24RagdollControllerKeyList10needsParseEv +0x00000071012ac688,sub_71012AC688,84,_ZN4ksys4phys24RagdollControllerKeyList20RagdollControllerKeyD2Ev +0x00000071012ac6dc,j__ZdlPv_1288,4,_ZN4ksys4phys24RagdollControllerKeyList20RagdollControllerKeyD0Ev +0x00000071012ac6e0,sub_71012AC6E0,372,_ZN4ksys4phys24RagdollControllerKeyList33checkDerivedRuntimeTypeInfoStaticEPKN4sead15RuntimeTypeInfo9InterfaceE 0x00000071012ac854,sub_71012AC854,40, 0x00000071012ac87c,sub_71012AC87C,68, 0x00000071012ac8c0,sub_71012AC8C0,76, diff --git a/src/KingSystem/Physics/CMakeLists.txt b/src/KingSystem/Physics/CMakeLists.txt index 7504bda4..d41ebf28 100644 --- a/src/KingSystem/Physics/CMakeLists.txt +++ b/src/KingSystem/Physics/CMakeLists.txt @@ -21,6 +21,8 @@ target_sources(uking PRIVATE System/physDefines.h System/physParamSet.cpp System/physParamSet.h + System/physRagdollControllerKeyList.h + System/physRagdollControllerKeyList.cpp System/physShapeParam.cpp System/physShapeParam.h ) diff --git a/src/KingSystem/Physics/System/physRagdollControllerKeyList.cpp b/src/KingSystem/Physics/System/physRagdollControllerKeyList.cpp new file mode 100644 index 00000000..e714cd69 --- /dev/null +++ b/src/KingSystem/Physics/System/physRagdollControllerKeyList.cpp @@ -0,0 +1,56 @@ +#include "KingSystem/Physics/System/physRagdollControllerKeyList.h" + +namespace ksys::phys { + +RagdollControllerKeyList::RagdollControllerKey::RagdollControllerKey() + : key(sead::SafeString::cEmptyString, "key", this), hierarchy_gain(0, "hierarchy_gain", this), + velocity_damping(0, "velocity_damping", this), + acceleration_gain(0, "acceleration_gain", this), velocity_gain(0, "velocity_gain", this), + position_gain(0, "position_gain", this), + position_max_linear_velocity(0, "position_max_linear_velocity", this), + position_max_angular_velocity(0, "position_max_angular_velocity", this), + snap_gain(0, "snap_gain", this), + snap_max_linear_velocity(0, "snap_max_linear_velocity", this), + snap_max_angular_velocity(0, "snap_max_angular_velocity", this), + snap_max_linear_distance(0, "snap_max_linear_distance", this), + snap_max_angular_distance(0, "snap_max_angular_distance", this) {} + +RagdollControllerKeyList::RagdollControllerKeyList() = default; +RagdollControllerKeyList::~RagdollControllerKeyList() { + buffer.freeBuffer(); +} + +RagdollControllerKeyList::RagdollControllerKey* +RagdollControllerKeyList::getControllerKeyByKey(const sead::SafeString& key) { + int buffer_size = buffer.size(); + for (int i = 0; i < buffer_size; i++) { + if (buffer[i].key.ref() == key) { + return &buffer[i]; + } + } + return nullptr; +} + +bool RagdollControllerKeyList::parse_(u8* data, size_t actualFileSize, sead::Heap* heap) { + if (!data) + return false; + + auto archive = agl::utl::ResParameterArchive(data); + auto key_list = agl::utl::getResParameterList(archive.getRootList(), "RagCtrlKeyList"); + if (!key_list) + return false; + + int key_count = key_list.getResParameterObjNum(); + if (key_count == 0) + return false; + + buffer.allocBufferAssert(key_count, heap); + + for (int i = 0; i < key_count; i++) { + buffer[i].applyResParameterObj(key_list.getResParameterObj(i)); + } + + return true; +} + +} // namespace ksys::phys \ No newline at end of file diff --git a/src/KingSystem/Physics/System/physRagdollControllerKeyList.h b/src/KingSystem/Physics/System/physRagdollControllerKeyList.h new file mode 100644 index 00000000..685d0625 --- /dev/null +++ b/src/KingSystem/Physics/System/physRagdollControllerKeyList.h @@ -0,0 +1,46 @@ +#pragma once + +#include +#include +#include + +#include "KingSystem/Resource/resResource.h" + +namespace ksys::phys { + +class RagdollControllerKeyList : public ksys::res::Resource { + SEAD_RTTI_OVERRIDE(RagdollControllerKeyList, ksys::res::Resource) + + struct RagdollControllerKey : public agl::utl::ParameterObj { + RagdollControllerKey(); + + agl::utl::Parameter key; + agl::utl::Parameter hierarchy_gain; + agl::utl::Parameter velocity_damping; + agl::utl::Parameter acceleration_gain; + agl::utl::Parameter velocity_gain; + agl::utl::Parameter position_gain; + agl::utl::Parameter position_max_linear_velocity; + agl::utl::Parameter position_max_angular_velocity; + agl::utl::Parameter snap_gain; + agl::utl::Parameter snap_max_linear_velocity; + agl::utl::Parameter snap_max_angular_velocity; + agl::utl::Parameter snap_max_linear_distance; + agl::utl::Parameter snap_max_angular_distance; + }; + KSYS_CHECK_SIZE_NX150(RagdollControllerKey, 0x1D8); + +public: + RagdollControllerKeyList(); + ~RagdollControllerKeyList(); + + RagdollControllerKey* getControllerKeyByKey(const sead::SafeString& key); + +private: + bool parse_(u8* data, size_t actualFileSize, sead::Heap* heap) override; + bool needsParse() const override { return true; } + + sead::Buffer buffer; +}; + +} // namespace ksys::phys \ No newline at end of file