diff --git a/data/uking_functions.csv b/data/uking_functions.csv index f34cbcdd..27dfdad0 100644 --- a/data/uking_functions.csv +++ b/data/uking_functions.csv @@ -73704,9 +73704,9 @@ Address,Quality,Size,Name 0x0000007100d3d40c,U,000144, 0x0000007100d3d49c,U,000100, 0x0000007100d3d500,U,000244, -0x0000007100d3d5f4,U,000016,ActorConstraints::ctor -0x0000007100d3d604,U,000104, -0x0000007100d3d66c,U,000104, +0x0000007100d3d5f4,O,000016,_ZN4ksys3act18PhysicsConstraintsC1Ev +0x0000007100d3d604,O,000104,_ZN4ksys3act18PhysicsConstraintsD1Ev +0x0000007100d3d66c,O,000104,_ZN4ksys3act18PhysicsConstraints8finalizeEv 0x0000007100d3d6d4,U,002256,ActorConstraints::init 0x0000007100d3dfa4,U,000380, 0x0000007100d3e120,U,000332, @@ -82384,7 +82384,7 @@ Address,Quality,Size,Name 0x0000007100f6a5c8,U,000212, 0x0000007100f6a69c,U,000092, 0x0000007100f6a6f8,U,000372, -0x0000007100f6a86c,U,000020, +0x0000007100f6a86c,O,000020,_ZN4ksys4phys10Constraint7destroyEPS1_ 0x0000007100f6a880,U,000012, 0x0000007100f6a88c,U,000160, 0x0000007100f6a92c,U,000168, diff --git a/src/KingSystem/ActorSystem/CMakeLists.txt b/src/KingSystem/ActorSystem/CMakeLists.txt index 5c6a1b47..57acd6df 100644 --- a/src/KingSystem/ActorSystem/CMakeLists.txt +++ b/src/KingSystem/ActorSystem/CMakeLists.txt @@ -107,6 +107,8 @@ target_sources(uking PRIVATE actInstParamPack.cpp actInstParamPack.h actLifeRecoveryInfo.h + actPhysicsConstraints.cpp + actPhysicsConstraints.h actPhysicsUserTag.cpp actPhysicsUserTag.h actPlayerInfo.cpp diff --git a/src/KingSystem/ActorSystem/actPhysicsConstraints.cpp b/src/KingSystem/ActorSystem/actPhysicsConstraints.cpp new file mode 100644 index 00000000..7f96a8ad --- /dev/null +++ b/src/KingSystem/ActorSystem/actPhysicsConstraints.cpp @@ -0,0 +1,24 @@ +#include "KingSystem/ActorSystem/actPhysicsConstraints.h" +#include "KingSystem/Physics/System/physConstraint.h" + +namespace ksys::act { + +PhysicsConstraints::PhysicsConstraints() = default; + +PhysicsConstraints::~PhysicsConstraints() { + finalize(); +} + +void PhysicsConstraints::finalize() { + for (auto*& cs : mConstraints) { + if (cs) { + phys::Constraint::destroy(cs); + cs = nullptr; + } + } + mConstraints.freeBuffer(); + _10 = false; + _11 = false; +} + +} // namespace ksys::act diff --git a/src/KingSystem/ActorSystem/actPhysicsConstraints.h b/src/KingSystem/ActorSystem/actPhysicsConstraints.h new file mode 100644 index 00000000..a093aaec --- /dev/null +++ b/src/KingSystem/ActorSystem/actPhysicsConstraints.h @@ -0,0 +1,30 @@ +#pragma once + +#include +#include "KingSystem/Utils/Types.h" + +namespace ksys::phys { +class Constraint; +} + +namespace ksys::act { + +class Actor; + +class PhysicsConstraints { +public: + PhysicsConstraints(); + ~PhysicsConstraints(); + + bool initialize(Actor* actor, sead::Heap* heap); + void finalize(); + void calc(); + +private: + sead::Buffer mConstraints; + bool _10 = false; + bool _11 = false; +}; +KSYS_CHECK_SIZE_NX150(PhysicsConstraints, 0x18); + +} // namespace ksys::act diff --git a/src/KingSystem/Physics/CMakeLists.txt b/src/KingSystem/Physics/CMakeLists.txt index 48a5745b..b4f8d18b 100644 --- a/src/KingSystem/Physics/CMakeLists.txt +++ b/src/KingSystem/Physics/CMakeLists.txt @@ -18,6 +18,8 @@ target_sources(uking PRIVATE SupportBone/physSupportBoneResourceMainBone.cpp System/physCharacterControllerParam.cpp System/physCharacterControllerParam.h + System/physConstraint.cpp + System/physConstraint.h System/physContactInfoParam.cpp System/physContactInfoParam.h System/physDefines.cpp diff --git a/src/KingSystem/Physics/System/physConstraint.cpp b/src/KingSystem/Physics/System/physConstraint.cpp new file mode 100644 index 00000000..b5752a0e --- /dev/null +++ b/src/KingSystem/Physics/System/physConstraint.cpp @@ -0,0 +1,10 @@ +#include "KingSystem/Physics/System/physConstraint.h" + +namespace ksys::phys { + +void Constraint::destroy(Constraint* instance) { + if (instance) + delete instance; +} + +} // namespace ksys::phys diff --git a/src/KingSystem/Physics/System/physConstraint.h b/src/KingSystem/Physics/System/physConstraint.h new file mode 100644 index 00000000..cfb52638 --- /dev/null +++ b/src/KingSystem/Physics/System/physConstraint.h @@ -0,0 +1,19 @@ +#pragma once + +#include + +namespace ksys::phys { + +class Constraint { + SEAD_RTTI_BASE(Constraint) + +public: + // FIXME: types + Constraint(); + virtual ~Constraint(); + + /// No-op if instance is null. + static void destroy(Constraint* instance); +}; + +} // namespace ksys::phys