Merge pull request #43 from MonsterDruide1/RagdollControllerKeyList

ksys/phys: Add RagdollControllerKeyList-Resource
This commit is contained in:
Léo Lam 2021-07-09 13:24:49 +02:00 committed by GitHub
commit 754523a246
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 118 additions and 14 deletions

View File

@ -95289,20 +95289,20 @@
0x00000071012ab97c,sub_71012AB97C,344, 0x00000071012ab97c,sub_71012AB97C,344,
0x00000071012abad4,sub_71012ABAD4,8, 0x00000071012abad4,sub_71012ABAD4,8,
0x00000071012abadc,sub_71012ABADC,284, 0x00000071012abadc,sub_71012ABADC,284,
0x00000071012abbf8,sub_71012ABBF8,928, 0x00000071012abbf8,sub_71012ABBF8,928,_ZN4ksys4phys24RagdollControllerKeyList20RagdollControllerKeyC1Ev
0x00000071012abf98,sub_71012ABF98,64, 0x00000071012abf98,sub_71012ABF98,64,_ZN4ksys4phys24RagdollControllerKeyListC1Ev
0x00000071012abfd8,sub_71012ABFD8,212, 0x00000071012abfd8,sub_71012ABFD8,212,_ZN4ksys4phys24RagdollControllerKeyListD1Ev
0x00000071012ac0ac,sub_71012AC0AC,212, 0x00000071012ac0ac,sub_71012AC0AC,212,_ZThn32_N4ksys4phys24RagdollControllerKeyListD1Ev
0x00000071012ac180,sub_71012AC180,220, 0x00000071012ac180,sub_71012AC180,220,_ZN4ksys4phys24RagdollControllerKeyListD0Ev
0x00000071012ac25c,sub_71012AC25C,220, 0x00000071012ac25c,sub_71012AC25C,220,_ZThn32_N4ksys4phys24RagdollControllerKeyListD0Ev
0x00000071012ac338,sub_71012AC338,340, 0x00000071012ac338,sub_71012AC338,340,_ZN4ksys4phys24RagdollControllerKeyList21getControllerKeyByKeyERKN4sead14SafeStringBaseIcEE
0x00000071012ac48c,sub_71012AC48C,400, 0x00000071012ac48c,sub_71012AC48C,400,_ZN4ksys4phys24RagdollControllerKeyList6parse_EPhmPN4sead4HeapE
0x00000071012ac61c,sub_71012AC61C,8, 0x00000071012ac61c,sub_71012AC61C,8,_ZNK4ksys4phys24RagdollControllerKeyList27checkDerivedRuntimeTypeInfoEPKN4sead15RuntimeTypeInfo9InterfaceE
0x00000071012ac624,sub_71012AC624,92, 0x00000071012ac624,sub_71012AC624,92,_ZNK4ksys4phys24RagdollControllerKeyList18getRuntimeTypeInfoEv
0x00000071012ac680,sub_71012AC680,8, 0x00000071012ac680,sub_71012AC680,8,_ZNK4ksys4phys24RagdollControllerKeyList10needsParseEv
0x00000071012ac688,sub_71012AC688,84, 0x00000071012ac688,sub_71012AC688,84,_ZN4ksys4phys24RagdollControllerKeyList20RagdollControllerKeyD2Ev
0x00000071012ac6dc,j__ZdlPv_1288,4, 0x00000071012ac6dc,j__ZdlPv_1288,4,_ZN4ksys4phys24RagdollControllerKeyList20RagdollControllerKeyD0Ev
0x00000071012ac6e0,sub_71012AC6E0,372, 0x00000071012ac6e0,sub_71012AC6E0,372,_ZN4ksys4phys24RagdollControllerKeyList33checkDerivedRuntimeTypeInfoStaticEPKN4sead15RuntimeTypeInfo9InterfaceE
0x00000071012ac854,sub_71012AC854,40, 0x00000071012ac854,sub_71012AC854,40,
0x00000071012ac87c,sub_71012AC87C,68, 0x00000071012ac87c,sub_71012AC87C,68,
0x00000071012ac8c0,sub_71012AC8C0,76, 0x00000071012ac8c0,sub_71012AC8C0,76,

Can't render this file because it is too large.

View File

@ -21,6 +21,8 @@ target_sources(uking PRIVATE
System/physDefines.h System/physDefines.h
System/physParamSet.cpp System/physParamSet.cpp
System/physParamSet.h System/physParamSet.h
System/physRagdollControllerKeyList.h
System/physRagdollControllerKeyList.cpp
System/physShapeParam.cpp System/physShapeParam.cpp
System/physShapeParam.h System/physShapeParam.h
) )

View File

@ -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

View File

@ -0,0 +1,46 @@
#pragma once
#include <agl/Utils/aglParameter.h>
#include <agl/Utils/aglParameterObj.h>
#include <container/seadBuffer.h>
#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<sead::SafeString> key;
agl::utl::Parameter<float> hierarchy_gain;
agl::utl::Parameter<float> velocity_damping;
agl::utl::Parameter<float> acceleration_gain;
agl::utl::Parameter<float> velocity_gain;
agl::utl::Parameter<float> position_gain;
agl::utl::Parameter<float> position_max_linear_velocity;
agl::utl::Parameter<float> position_max_angular_velocity;
agl::utl::Parameter<float> snap_gain;
agl::utl::Parameter<float> snap_max_linear_velocity;
agl::utl::Parameter<float> snap_max_angular_velocity;
agl::utl::Parameter<float> snap_max_linear_distance;
agl::utl::Parameter<float> 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<RagdollControllerKey> buffer;
};
} // namespace ksys::phys