From 2359ce6fb42c02d07d3919389c7bb89cb51d40af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Tue, 4 Jan 2022 19:24:04 +0100 Subject: [PATCH] ksys/phys: Start adding StaticCompound (very incomplete) --- data/uking_functions.csv | 16 +++--- src/KingSystem/Physics/CMakeLists.txt | 9 ++++ .../StaticCompound/physStaticCompound.cpp | 24 +++++++++ .../StaticCompound/physStaticCompound.h | 53 +++++++++++++++++++ .../physStaticCompoundFieldBodyGroup.cpp | 7 +++ .../physStaticCompoundFieldBodyGroup.h | 42 +++++++++++++++ 6 files changed, 143 insertions(+), 8 deletions(-) create mode 100644 src/KingSystem/Physics/StaticCompound/physStaticCompound.cpp create mode 100644 src/KingSystem/Physics/StaticCompound/physStaticCompound.h create mode 100644 src/KingSystem/Physics/StaticCompound/physStaticCompoundFieldBodyGroup.cpp create mode 100644 src/KingSystem/Physics/StaticCompound/physStaticCompoundFieldBodyGroup.h diff --git a/data/uking_functions.csv b/data/uking_functions.csv index ffbbb214..f3178d8a 100644 --- a/data/uking_functions.csv +++ b/data/uking_functions.csv @@ -84177,7 +84177,7 @@ Address,Quality,Size,Name 0x0000007100fc9b48,U,000092, 0x0000007100fc9ba4,U,000140, 0x0000007100fc9c30,U,000140, -0x0000007100fc9cbc,U,000208,ResourceHksc::ctor +0x0000007100fc9cbc,O,000208,_ZN4ksys4phys14StaticCompoundC1Ev 0x0000007100fc9d8c,U,000352,ResourceHksc::dtor 0x0000007100fc9eec,U,000008, 0x0000007100fc9ef4,U,000036,ResourceHksc::dtorDelete @@ -84197,12 +84197,12 @@ Address,Quality,Size,Name 0x0000007100fcac2c,U,000112, 0x0000007100fcac9c,U,000112, 0x0000007100fcad0c,U,000328, -0x0000007100fcae54,U,000028,ResourceHksc::getFieldBodyGroup -0x0000007100fcae70,U,000084, -0x0000007100fcaec4,U,000008,ResourceHksc::m0 -0x0000007100fcaecc,U,000092,ResourceHksc::m1 -0x0000007100fcaf28,U,000008,ResourceHksc::needsParse -0x0000007100fcaf30,U,000372, +0x0000007100fcae54,O,000028,_ZN4ksys4phys14StaticCompound17getFieldBodyGroupEi +0x0000007100fcae70,O,000084,_ZNK4ksys4phys14StaticCompound17hasFieldBodyGroupEPNS0_14FieldBodyGroupE +0x0000007100fcaec4,O,000008,_ZNK4ksys4phys14StaticCompound27checkDerivedRuntimeTypeInfoEPKN4sead15RuntimeTypeInfo9InterfaceE +0x0000007100fcaecc,O,000092,_ZNK4ksys4phys14StaticCompound18getRuntimeTypeInfoEv +0x0000007100fcaf28,O,000008,_ZNK4ksys4phys14StaticCompound10needsParseEv +0x0000007100fcaf30,O,000372,_ZN4ksys4phys14StaticCompound33checkDerivedRuntimeTypeInfoStaticEPKN4sead15RuntimeTypeInfo9InterfaceE 0x0000007100fcb0a4,U,000004,nullsub_5551 0x0000007100fcb0a8,U,000004,nullsub_5552 0x0000007100fcb0ac,U,000136, @@ -84230,7 +84230,7 @@ Address,Quality,Size,Name 0x0000007100fcbbe4,U,000176, 0x0000007100fcbc94,U,000324, 0x0000007100fcbdd8,U,000104, -0x0000007100fcbe40,U,000168,FieldBodyGroup::ctor +0x0000007100fcbe40,O,000168,_ZN4ksys4phys14FieldBodyGroupC1Ev 0x0000007100fcbee8,U,000288, 0x0000007100fcc008,U,001492,FieldBodyGroup::init 0x0000007100fcc5dc,U,000120, diff --git a/src/KingSystem/Physics/CMakeLists.txt b/src/KingSystem/Physics/CMakeLists.txt index e2fa89d7..c8c96c9f 100644 --- a/src/KingSystem/Physics/CMakeLists.txt +++ b/src/KingSystem/Physics/CMakeLists.txt @@ -1,10 +1,12 @@ target_sources(uking PRIVATE Cloth/physClothParam.cpp Cloth/physClothParam.h + Ragdoll/physRagdollConfig.cpp Ragdoll/physRagdollConfig.h Ragdoll/physRagdollParam.cpp Ragdoll/physRagdollParam.h + RigidBody/physEdgeRigidBodyParam.cpp RigidBody/physEdgeRigidBodyParam.h RigidBody/physMotionAccessor.cpp @@ -27,11 +29,18 @@ target_sources(uking PRIVATE RigidBody/Shape/physSphereShape.h RigidBody/Shape/physWaterCylinderShape.cpp RigidBody/Shape/physWaterCylinderShape.h + + StaticCompound/physStaticCompound.cpp + StaticCompound/physStaticCompound.h + StaticCompound/physStaticCompoundFieldBodyGroup.cpp + StaticCompound/physStaticCompoundFieldBodyGroup.h + SupportBone/physSupportBoneParam.cpp SupportBone/physSupportBoneParam.h SupportBone/physSupportBoneResource.cpp SupportBone/physSupportBoneResource.h SupportBone/physSupportBoneResourceMainBone.cpp + System/physCharacterControllerParam.cpp System/physCharacterControllerParam.h System/physConstraint.cpp diff --git a/src/KingSystem/Physics/StaticCompound/physStaticCompound.cpp b/src/KingSystem/Physics/StaticCompound/physStaticCompound.cpp new file mode 100644 index 00000000..6fb85437 --- /dev/null +++ b/src/KingSystem/Physics/StaticCompound/physStaticCompound.cpp @@ -0,0 +1,24 @@ +#include "KingSystem/Physics/StaticCompound/physStaticCompound.h" +#include "KingSystem/Physics/StaticCompound/physStaticCompoundFieldBodyGroup.h" + +namespace ksys::phys { + +StaticCompound::StaticCompound() = default; + +StaticCompound::~StaticCompound() { + // FIXME +} + +FieldBodyGroup* StaticCompound::getFieldBodyGroup(int idx) { + return &mFieldBodyGroups[idx]; +} + +bool StaticCompound::hasFieldBodyGroup(FieldBodyGroup* group) const { + for (int i = 0, n = mFieldBodyGroups.size(); i < n; ++i) { + if (&mFieldBodyGroups[i] == group) + return true; + } + return false; +} + +} // namespace ksys::phys diff --git a/src/KingSystem/Physics/StaticCompound/physStaticCompound.h b/src/KingSystem/Physics/StaticCompound/physStaticCompound.h new file mode 100644 index 00000000..b65c1b38 --- /dev/null +++ b/src/KingSystem/Physics/StaticCompound/physStaticCompound.h @@ -0,0 +1,53 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include "KingSystem/Resource/resResource.h" +#include "KingSystem/Utils/Types.h" + +namespace ksys::phys { + +class FieldBodyGroup; + +class StaticCompound : public res::Resource, public sead::hostio::Node { + SEAD_RTTI_OVERRIDE(StaticCompound, res::Resource) + +public: + StaticCompound(); + ~StaticCompound() override; + + FieldBodyGroup* getFieldBodyGroup(int idx); + bool hasFieldBodyGroup(FieldBodyGroup* group) const; + + // res::Resource interface + void doCreate_(u8* buffer, u32 buffer_size, sead::Heap* heap) override; + bool needsParse() const override { return true; } + bool finishParsing_() override; + bool m7_() override; + +private: + enum class Flag { + Initialised = 1 << 0, + }; + + sead::TypedBitFlag mFlags; + sead::Heap* mHeap{}; + void* _50{}; + void* mData{}; + int _60{}; + void* _68{}; + int _70{}; + sead::Buffer mFieldBodyGroups; + sead::FixedSafeString<32> mName; + sead::Matrix34f mMtx = sead::Matrix34f::ident; + sead::Buffer _f0{}; + sead::CriticalSection mCS; +}; +KSYS_CHECK_SIZE_NX150(StaticCompound, 0x140); + +} // namespace ksys::phys diff --git a/src/KingSystem/Physics/StaticCompound/physStaticCompoundFieldBodyGroup.cpp b/src/KingSystem/Physics/StaticCompound/physStaticCompoundFieldBodyGroup.cpp new file mode 100644 index 00000000..a0614efc --- /dev/null +++ b/src/KingSystem/Physics/StaticCompound/physStaticCompoundFieldBodyGroup.cpp @@ -0,0 +1,7 @@ +#include "KingSystem/Physics/StaticCompound/physStaticCompoundFieldBodyGroup.h" + +namespace ksys::phys { + +FieldBodyGroup::FieldBodyGroup() = default; + +} // namespace ksys::phys diff --git a/src/KingSystem/Physics/StaticCompound/physStaticCompoundFieldBodyGroup.h b/src/KingSystem/Physics/StaticCompound/physStaticCompoundFieldBodyGroup.h new file mode 100644 index 00000000..00ec7144 --- /dev/null +++ b/src/KingSystem/Physics/StaticCompound/physStaticCompoundFieldBodyGroup.h @@ -0,0 +1,42 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include "KingSystem/Utils/Types.h" + +namespace ksys::phys { + +class RigidBody; +class StaticCompound; + +class FieldBodyGroup { +public: + FieldBodyGroup(); + ~FieldBodyGroup(); + + FieldBodyGroup(const FieldBodyGroup&) = delete; + auto operator=(const FieldBodyGroup&) = delete; + + sead::Atomic _0; + sead::Atomic _4; + sead::Buffer _8; + sead::Buffer _18; + sead::Buffer _28; + sead::Buffer _38; + sead::Matrix34f mMtx0 = sead::Matrix34f::ident; + sead::Matrix34f mMtx1 = sead::Matrix34f::ident; + sead::Matrix34f* mMtxPtr{}; + sead::PtrArray mRigidBodies; + StaticCompound* mStaticCompound{}; + sead::Vector3f _c8 = sead::Vector3f::zero; + sead::Vector3f _d4 = sead::Vector3f::zero; + u32 _e0{}; + sead::Buffer _e8; +}; +KSYS_CHECK_SIZE_NX150(FieldBodyGroup, 0xf8); + +} // namespace ksys::phys