From 1ee012858c2c1f348e9ede0b26f36ffc0e1fa8b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Tue, 1 Mar 2022 18:52:50 +0100 Subject: [PATCH] ksys: Rename RigidContactPoints to match param files --- data/uking_functions.csv | 50 +++++++++---------- src/KingSystem/Physics/CMakeLists.txt | 8 +-- .../Physics/RigidBody/physRigidBody.cpp | 8 +-- .../Physics/RigidBody/physRigidBody.h | 8 +-- .../RigidBody/physRigidBodyRequestMgr.cpp | 4 +- .../RigidBody/physRigidBodyRequestMgr.h | 6 +-- .../Physics/System/physContactMgr.cpp | 42 ++++++++-------- .../Physics/System/physContactMgr.h | 20 ++++---- .../Physics/System/physContactPointInfo.cpp | 28 +++++++++++ ...ContactPoints.h => physContactPointInfo.h} | 24 +++++---- ...ointsEx.cpp => physContactPointInfoEx.cpp} | 37 +++++++------- ...actPointsEx.h => physContactPointInfoEx.h} | 17 +++---- .../Physics/System/physRigidContactPoints.cpp | 28 ----------- src/KingSystem/Physics/System/physSystem.cpp | 22 ++++---- src/KingSystem/Physics/System/physSystem.h | 24 +++++---- 15 files changed, 163 insertions(+), 163 deletions(-) create mode 100644 src/KingSystem/Physics/System/physContactPointInfo.cpp rename src/KingSystem/Physics/System/{physRigidContactPoints.h => physContactPointInfo.h} (59%) rename src/KingSystem/Physics/System/{physRigidContactPointsEx.cpp => physContactPointInfoEx.cpp} (59%) rename src/KingSystem/Physics/System/{physRigidContactPointsEx.h => physContactPointInfoEx.h} (83%) delete mode 100644 src/KingSystem/Physics/System/physRigidContactPoints.cpp diff --git a/data/uking_functions.csv b/data/uking_functions.csv index 18a8fffe..c45fc44a 100644 --- a/data/uking_functions.csv +++ b/data/uking_functions.csv @@ -82987,7 +82987,7 @@ Address,Quality,Size,Name 0x0000007100f8e110,O,000748,_ZN4ksys4phys9RigidBody4x_10Ev 0x0000007100f8e3fc,U,000816,phys::RigidBody::x_11 0x0000007100f8e72c,U,000136,phys::RigidBody::x_12 -0x0000007100f8e7b4,O,000052,_ZN4ksys4phys9RigidBody16setContactPointsEPNS0_18RigidContactPointsE +0x0000007100f8e7b4,O,000052,_ZN4ksys4phys9RigidBody19setContactPointInfoEPNS0_16ContactPointInfoE 0x0000007100f8e7e8,O,000264,_ZN4ksys4phys9RigidBody26setFixedAndPreserveImpulseEbb 0x0000007100f8e8f0,O,000460,_ZN4ksys4phys9RigidBody6freezeEbbb 0x0000007100f8eabc,O,000384,_ZN4ksys4phys9RigidBody8setFixedEbb @@ -83749,10 +83749,10 @@ Address,Quality,Size,Name 0x0000007100fb2624,O,000688,_ZN4ksys4phys10ContactMgr22doLoadContactInfoTableEN3agl3utl19ResParameterArchiveENS0_16ContactLayerTypeEb 0x0000007100fb28d4,O,000136,_ZN4ksys4phys10ContactMgr18allocContactPointsEPN4sead4HeapEiRKNS2_14SafeStringBaseIcEEiii 0x0000007100fb295c,O,000220,_ZN4ksys4phys10ContactMgr20allocContactPointsExEPN4sead4HeapEiiRKNS2_14SafeStringBaseIcEEiii -0x0000007100fb2a38,O,000100,_ZN4ksys4phys10ContactMgr21registerContactPointsEPNS0_19IRigidContactPointsE +0x0000007100fb2a38,O,000100,_ZN4ksys4phys10ContactMgr24registerContactPointInfoEPNS0_20ContactPointInfoBaseE 0x0000007100fb2a9c,U,000056,phys::ContactInfoTable::allocCollisionInfo 0x0000007100fb2ad4,U,000156,phys::ContactInfoTable::x_2 -0x0000007100fb2b70,O,000148,_ZN4ksys4phys10ContactMgr17freeContactPointsEPNS0_19IRigidContactPointsE +0x0000007100fb2b70,O,000148,_ZN4ksys4phys10ContactMgr20freeContactPointInfoEPNS0_20ContactPointInfoBaseE 0x0000007100fb2c04,U,000144,phys::ContactInfoTable::x_5 0x0000007100fb2c94,U,000216,phys::ContactInfoTable::x_6 0x0000007100fb2d6c,U,000136,phys::ContactInfoTable::x_7 @@ -84106,13 +84106,13 @@ Address,Quality,Size,Name 0x0000007100fc75a8,U,000076, 0x0000007100fc75f4,U,000020, 0x0000007100fc7608,U,000052, -0x0000007100fc763c,O,000064,_ZN4ksys4phys18RigidContactPoints4makeEPN4sead4HeapEiRKNS2_14SafeStringBaseIcEEiii -0x0000007100fc767c,O,000024,_ZN4ksys4phys18RigidContactPoints4freeEPS1_ -0x0000007100fc7694,O,000076,_ZN4ksys4phys18RigidContactPointsC1ERKN4sead14SafeStringBaseIcEEiii -0x0000007100fc76e0,O,000004,_ZN4ksys4phys18RigidContactPointsD1Ev -0x0000007100fc76e4,O,000004,_ZN4ksys4phys18RigidContactPointsD0Ev -0x0000007100fc76e8,O,000092,_ZN4ksys4phys18RigidContactPoints11allocPointsEPN4sead4HeapEi -0x0000007100fc7744,O,000048,_ZN4ksys4phys18RigidContactPoints10freePointsEv +0x0000007100fc763c,O,000064,_ZN4ksys4phys16ContactPointInfo4makeEPN4sead4HeapEiRKNS2_14SafeStringBaseIcEEiii +0x0000007100fc767c,O,000024,_ZN4ksys4phys16ContactPointInfo4freeEPS1_ +0x0000007100fc7694,O,000076,_ZN4ksys4phys16ContactPointInfoC1ERKN4sead14SafeStringBaseIcEEiii +0x0000007100fc76e0,O,000004,_ZN4ksys4phys16ContactPointInfoD1Ev +0x0000007100fc76e4,O,000004,_ZN4ksys4phys16ContactPointInfoD0Ev +0x0000007100fc76e8,O,000092,_ZN4ksys4phys16ContactPointInfo11allocPointsEPN4sead4HeapEi +0x0000007100fc7744,O,000048,_ZN4ksys4phys16ContactPointInfo10freePointsEv 0x0000007100fc7774,U,000084,phys::SomeClass::ctor 0x0000007100fc77c8,U,000044,phys::SomeClass::ctor_0 0x0000007100fc77f4,U,000260,phys::SomeClass::someCalc @@ -84320,18 +84320,18 @@ Address,Quality,Size,Name 0x0000007100fcf854,O,000092,_ZNK4ksys4phys15ContactListener18getRuntimeTypeInfoEv 0x0000007100fcf8b0,O,000004,_ZN4ksys4phys15ContactListener3m11Ev 0x0000007100fcf8b4,O,000008,_ZN4ksys4phys15ContactListener3m15Ev -0x0000007100fcf8bc,O,000072,_ZN4ksys4phys20RigidContactPointsEx4makeEPN4sead4HeapEiiRKNS2_14SafeStringBaseIcEEiii -0x0000007100fcf904,O,000348,_ZN4ksys4phys20RigidContactPointsEx17registerLayerPairENS0_12ContactLayerES2_b -0x0000007100fcfa60,O,000024,_ZN4ksys4phys20RigidContactPointsEx4freeEPS1_ -0x0000007100fcfa78,O,000096,_ZN4ksys4phys20RigidContactPointsExC1ERKN4sead14SafeStringBaseIcEEiii -0x0000007100fcfad8,O,000004,_ZN4ksys4phys20RigidContactPointsExD1Ev -0x0000007100fcfadc,O,000004,_ZN4ksys4phys20RigidContactPointsExD0Ev -0x0000007100fcfae0,O,000300,_ZN4ksys4phys20RigidContactPointsEx11allocPointsEPN4sead4HeapEii -0x0000007100fcfc0c,O,000168,_ZN4ksys4phys20RigidContactPointsEx10freePointsEv -0x0000007100fcfcb4,O,000260,_ZNK4ksys4phys20RigidContactPointsEx8Iterator7getDataEPN4sead7Vector3IfEENS2_4ModeE -0x0000007100fcfdb8,O,000048,_ZNK4ksys4phys20RigidContactPointsEx8Iterator7getDataENS2_4ModeE -0x0000007100fcfde8,O,000068,_ZN4ksys4phys20RigidContactPointsEx8IteratorC1ERKN4sead6BufferIPNS0_12ContactPointEEEi -0x0000007100fcfe2c,O,000028,_ZN4ksys4phys20RigidContactPointsEx11IteratorEndC1ERKN4sead6BufferIPNS0_12ContactPointEEEi +0x0000007100fcf8bc,O,000072,_ZN4ksys4phys18ContactPointInfoEx4makeEPN4sead4HeapEiiRKNS2_14SafeStringBaseIcEEiii +0x0000007100fcf904,O,000348,_ZN4ksys4phys18ContactPointInfoEx17registerLayerPairENS0_12ContactLayerES2_b +0x0000007100fcfa60,O,000024,_ZN4ksys4phys18ContactPointInfoEx4freeEPS1_ +0x0000007100fcfa78,O,000096,_ZN4ksys4phys18ContactPointInfoExC1ERKN4sead14SafeStringBaseIcEEiii +0x0000007100fcfad8,O,000004,_ZN4ksys4phys18ContactPointInfoExD1Ev +0x0000007100fcfadc,O,000004,_ZN4ksys4phys18ContactPointInfoExD0Ev +0x0000007100fcfae0,O,000300,_ZN4ksys4phys18ContactPointInfoEx11allocPointsEPN4sead4HeapEii +0x0000007100fcfc0c,O,000168,_ZN4ksys4phys18ContactPointInfoEx10freePointsEv +0x0000007100fcfcb4,O,000260,_ZNK4ksys4phys18ContactPointInfoEx8Iterator7getDataEPN4sead7Vector3IfEENS2_4ModeE +0x0000007100fcfdb8,O,000048,_ZNK4ksys4phys18ContactPointInfoEx8Iterator7getDataENS2_4ModeE +0x0000007100fcfde8,O,000068,_ZN4ksys4phys18ContactPointInfoEx8IteratorC1ERKN4sead6BufferIPNS0_12ContactPointEEEi +0x0000007100fcfe2c,O,000028,_ZN4ksys4phys18ContactPointInfoEx11IteratorEndC1ERKN4sead6BufferIPNS0_12ContactPointEEEi 0x0000007100fcfe48,U,000112, 0x0000007100fcfeb8,U,000072, 0x0000007100fcff00,U,000692, @@ -93446,11 +93446,11 @@ Address,Quality,Size,Name 0x000000710121686c,U,000040,PhysicsMemSys::addGroupFilterX 0x0000007101216894,U,000052, 0x00000071012168c8,U,000052, -0x00000071012168fc,O,000008,_ZNK4ksys4phys6System18allocContactPointsEPN4sead4HeapEiRKNS2_14SafeStringBaseIcEEiii -0x0000007101216904,O,000008,_ZNK4ksys4phys6System17freeContactPointsEPNS0_18RigidContactPointsE +0x00000071012168fc,O,000008,_ZNK4ksys4phys6System21allocContactPointInfoEPN4sead4HeapEiRKNS2_14SafeStringBaseIcEEiii +0x0000007101216904,O,000008,_ZNK4ksys4phys6System20freeContactPointInfoEPNS0_16ContactPointInfoE 0x000000710121690c,O,000008,_ZNK4ksys4phys6System20allocContactPointsExEPN4sead4HeapEiiRKNS2_14SafeStringBaseIcEEiii 0x0000007101216914,U,000080,PhysicsMemSys::freeContactPoints2 -0x0000007101216964,O,000008,_ZNK4ksys4phys6System21registerContactPointsEPNS0_18RigidContactPointsE +0x0000007101216964,O,000008,_ZNK4ksys4phys6System24registerContactPointInfoEPNS0_16ContactPointInfoE 0x000000710121696c,U,000008,PhysicsMemSys::x_3 0x0000007101216974,U,000048,PhysicsMemSys::x_2 0x00000071012169a4,U,000008,PhysicsMemSys::allocCollisionStuff diff --git a/src/KingSystem/Physics/CMakeLists.txt b/src/KingSystem/Physics/CMakeLists.txt index cdeaec75..ac725dc3 100644 --- a/src/KingSystem/Physics/CMakeLists.txt +++ b/src/KingSystem/Physics/CMakeLists.txt @@ -108,6 +108,10 @@ target_sources(uking PRIVATE System/physContactListener.h System/physContactMgr.cpp System/physContactMgr.h + System/physContactPointInfo.cpp + System/physContactPointInfo.h + System/physContactPointInfoEx.cpp + System/physContactPointInfoEx.h System/physEntityGroupFilter.cpp System/physEntityGroupFilter.h System/physGroupFilter.cpp @@ -118,10 +122,6 @@ target_sources(uking PRIVATE System/physMaterialTable.h System/physParamSet.cpp System/physParamSet.h - System/physRigidContactPoints.cpp - System/physRigidContactPoints.h - System/physRigidContactPointsEx.cpp - System/physRigidContactPointsEx.h System/physSensorGroupFilter.cpp System/physSensorGroupFilter.h System/physSystem.cpp diff --git a/src/KingSystem/Physics/RigidBody/physRigidBody.cpp b/src/KingSystem/Physics/RigidBody/physRigidBody.cpp index 41dbebe0..9ec4ffe2 100644 --- a/src/KingSystem/Physics/RigidBody/physRigidBody.cpp +++ b/src/KingSystem/Physics/RigidBody/physRigidBody.cpp @@ -473,10 +473,10 @@ void RigidBody::x_10() { x_8(nullptr); } -void RigidBody::setContactPoints(RigidContactPoints* points) { - mContactPoints = points; - if (isFlag8Set() && mContactPoints && !mContactPoints->isLinked()) - System::instance()->registerContactPoints(points); +void RigidBody::setContactPointInfo(ContactPointInfo* info) { + mContactPointInfo = info; + if (isFlag8Set() && mContactPointInfo && !mContactPointInfo->isLinked()) + System::instance()->registerContactPointInfo(info); } void RigidBody::freeze(bool should_freeze, bool preserve_velocities, bool preserve_max_impulse) { diff --git a/src/KingSystem/Physics/RigidBody/physRigidBody.h b/src/KingSystem/Physics/RigidBody/physRigidBody.h index f3fb87ba..5cd3cd40 100644 --- a/src/KingSystem/Physics/RigidBody/physRigidBody.h +++ b/src/KingSystem/Physics/RigidBody/physRigidBody.h @@ -28,7 +28,7 @@ class MotionAccessor; struct RigidBodyInstanceParam; class RigidBodyMotionEntity; class RigidBodyMotionSensor; -class RigidContactPoints; +class ContactPointInfo; class SystemGroupHandler; class UserTag; @@ -191,8 +191,8 @@ public: void* get90() const { return _90; } // 0x0000007100f8e72c void x_12_setField90(void* field_90); - RigidContactPoints* getContactPoints() const { return mContactPoints; } - void setContactPoints(RigidContactPoints* points); + ContactPointInfo* getContactPointInfo() const { return mContactPointInfo; } + void setContactPointInfo(ContactPointInfo* info); void freeze(bool should_freeze, bool preserve_velocities, bool preserve_max_impulse); void setFixedAndPreserveImpulse(bool fixed, bool mark_linear_vel_as_dirty); @@ -583,7 +583,7 @@ protected: sead::BitFlag32 mContactMask{}; hkpRigidBody* mHkBody; UserTag* mUserTag = nullptr; - RigidContactPoints* mContactPoints = nullptr; + ContactPointInfo* mContactPointInfo = nullptr; void* _90 = nullptr; u16 _98 = 0; RigidBodyAccessor mRigidBodyAccessor; diff --git a/src/KingSystem/Physics/RigidBody/physRigidBodyRequestMgr.cpp b/src/KingSystem/Physics/RigidBody/physRigidBodyRequestMgr.cpp index 7498f536..fb45b399 100644 --- a/src/KingSystem/Physics/RigidBody/physRigidBodyRequestMgr.cpp +++ b/src/KingSystem/Physics/RigidBody/physRigidBodyRequestMgr.cpp @@ -27,7 +27,7 @@ RigidBodyRequestMgr::~RigidBodyRequestMgr() { mMotionAccessors.freeBuffer(); if (mContactPoints) { - ksys::phys::RigidContactPointsEx::free(mContactPoints); + ksys::phys::ContactPointInfoEx::free(mContactPoints); mContactPoints = nullptr; } } @@ -62,7 +62,7 @@ void RigidBodyRequestMgr::init(sead::Heap* heap) { mNumEntitiesInWorld = 0; mContactPoints = - RigidContactPointsEx::make(heap, 0x1000, 11, "RigidBodyRequestMgr::Water", 0, 0, 0); + ContactPointInfoEx::make(heap, 0x1000, 11, "RigidBodyRequestMgr::Water", 0, 0, 0); mContactPoints->setCallback(&mCallback); mContactPoints->set30(1); diff --git a/src/KingSystem/Physics/RigidBody/physRigidBodyRequestMgr.h b/src/KingSystem/Physics/RigidBody/physRigidBodyRequestMgr.h index 880f7286..fd4d5e09 100644 --- a/src/KingSystem/Physics/RigidBody/physRigidBodyRequestMgr.h +++ b/src/KingSystem/Physics/RigidBody/physRigidBodyRequestMgr.h @@ -9,7 +9,7 @@ #include #include #include -#include "KingSystem/Physics/System/physRigidContactPointsEx.h" +#include "KingSystem/Physics/System/physContactPointInfoEx.h" #include "KingSystem/Physics/physDefines.h" #include "KingSystem/Utils/Container/LockFreeQueue.h" #include "KingSystem/Utils/Types.h" @@ -84,7 +84,7 @@ private: }; KSYS_CHECK_SIZE_NX150(Unk6, 0x48); - struct PointCallback : RigidContactPointsEx::Callback { + struct PointCallback : ContactPointInfoEx::Callback { explicit PointCallback(RigidBodyRequestMgr* mgr_) : mgr(mgr_) {} void invoke(void* arg) override { mgr->someFunction2(arg); } @@ -112,7 +112,7 @@ private: sead::Atomic _130; sead::Buffer _138; u32 mNumEntitiesInWorld{}; - RigidContactPointsEx* mContactPoints{}; + ContactPointInfoEx* mContactPoints{}; sead::SafeArray mCriticalSections; sead::CriticalSection mCS; float _218 = 1.0; diff --git a/src/KingSystem/Physics/System/physContactMgr.cpp b/src/KingSystem/Physics/System/physContactMgr.cpp index 2dab145e..43735edd 100644 --- a/src/KingSystem/Physics/System/physContactMgr.cpp +++ b/src/KingSystem/Physics/System/physContactMgr.cpp @@ -1,15 +1,15 @@ #include "KingSystem/Physics/System/physContactMgr.h" #include +#include "KingSystem/Physics/System/physContactPointInfo.h" +#include "KingSystem/Physics/System/physContactPointInfoEx.h" #include "KingSystem/Physics/System/physEntityGroupFilter.h" #include "KingSystem/Physics/System/physGroupFilter.h" -#include "KingSystem/Physics/System/physRigidContactPoints.h" -#include "KingSystem/Physics/System/physRigidContactPointsEx.h" #include "KingSystem/Physics/System/physSystem.h" namespace ksys::phys { ContactMgr::ContactMgr() { - mRigidContactPoints.initOffset(RigidContactPoints::getListNodeOffset()); + mRigidContactPoints.initOffset(ContactPointInfo::getListNodeOffset()); // FIXME: figure out what these offsets are mList2.initOffset(0x78); mList3.initOffset(0x40); @@ -76,40 +76,40 @@ void ContactMgr::doLoadContactInfoTable(agl::utl::ResParameterArchive archive, table.param_io.applyResParameterArchive(archive); } -RigidContactPoints* ContactMgr::allocContactPoints(sead::Heap* heap, int num, - const sead::SafeString& name, int a, int b, - int c) { - auto* points = new (heap) RigidContactPoints(name, a, b, c); +ContactPointInfo* ContactMgr::allocContactPoints(sead::Heap* heap, int num, + const sead::SafeString& name, int a, int b, + int c) { + auto* points = new (heap) ContactPointInfo(name, a, b, c); points->allocPoints(heap, num); return points; } -RigidContactPointsEx* ContactMgr::allocContactPointsEx(sead::Heap* heap, int num, int num2, - const sead::SafeString& name, int a, int b, - int c) { - auto* points = new (heap) RigidContactPointsEx(name, a, b, c); +ContactPointInfoEx* ContactMgr::allocContactPointsEx(sead::Heap* heap, int num, int num2, + const sead::SafeString& name, int a, int b, + int c) { + auto* points = new (heap) ContactPointInfoEx(name, a, b, c); points->allocPoints(heap, num, num2); - registerContactPoints(points); + registerContactPointInfo(points); return points; } -void ContactMgr::registerContactPoints(IRigidContactPoints* points) { +void ContactMgr::registerContactPointInfo(ContactPointInfoBase* info) { auto lock = sead::makeScopedLock(mMutex1); - if (!points->isLinked()) - mRigidContactPoints.pushBack(points); + if (!info->isLinked()) + mRigidContactPoints.pushBack(info); } -void ContactMgr::freeContactPoints(IRigidContactPoints* points) { - if (!points) +void ContactMgr::freeContactPointInfo(ContactPointInfoBase* info) { + if (!info) return; { auto lock = sead::makeScopedLock(mMutex1); - if (points->isLinked()) - mRigidContactPoints.erase(points); + if (info->isLinked()) + mRigidContactPoints.erase(info); } - points->freePoints(); - delete points; + info->freePoints(); + delete info; } bool ContactMgr::getSensorLayerMask(SensorCollisionMask* mask, diff --git a/src/KingSystem/Physics/System/physContactMgr.h b/src/KingSystem/Physics/System/physContactMgr.h index 5a868033..7c61b4a9 100644 --- a/src/KingSystem/Physics/System/physContactMgr.h +++ b/src/KingSystem/Physics/System/physContactMgr.h @@ -24,10 +24,10 @@ namespace ksys::phys { struct ContactUnk1; enum class IsIndoorStage; -class IRigidContactPoints; +class ContactPointInfoBase; class RigidBody; -class RigidContactPoints; -class RigidContactPointsEx; +class ContactPointInfo; +class ContactPointInfoEx; struct ContactInfoTable { struct Receiver : agl::utl::ParameterObj { @@ -81,12 +81,12 @@ public: bool getSensorLayerMask(SensorCollisionMask* mask, const sead::SafeString& receiver_type) const; - RigidContactPoints* allocContactPoints(sead::Heap* heap, int num, const sead::SafeString& name, - int a, int b, int c); - RigidContactPointsEx* allocContactPointsEx(sead::Heap* heap, int num, int num2, - const sead::SafeString& name, int a, int b, int c); - void registerContactPoints(IRigidContactPoints* points); - void freeContactPoints(IRigidContactPoints* points); + ContactPointInfo* allocContactPoints(sead::Heap* heap, int num, const sead::SafeString& name, + int a, int b, int c); + ContactPointInfoEx* allocContactPointsEx(sead::Heap* heap, int num, int num2, + const sead::SafeString& name, int a, int b, int c); + void registerContactPointInfo(ContactPointInfoBase* info); + void freeContactPointInfo(ContactPointInfoBase* info); // 0x0000007100fb3744 void x_17(void* unk, RigidBody* body_a, RigidBody* body_b); @@ -106,7 +106,7 @@ private: sead::OffsetList mList0; int mList0Size = 0; sead::Atomic _34 = 0; - sead::OffsetList mRigidContactPoints; + sead::OffsetList mRigidContactPoints; sead::OffsetList mList2; sead::OffsetList mList3; sead::OffsetList mList4; diff --git a/src/KingSystem/Physics/System/physContactPointInfo.cpp b/src/KingSystem/Physics/System/physContactPointInfo.cpp new file mode 100644 index 00000000..0553e383 --- /dev/null +++ b/src/KingSystem/Physics/System/physContactPointInfo.cpp @@ -0,0 +1,28 @@ +#include "KingSystem/Physics/System/physContactPointInfo.h" +#include "KingSystem/Physics/System/physSystem.h" + +namespace ksys::phys { + +ContactPointInfo* ContactPointInfo::make(sead::Heap* heap, int num, const sead::SafeString& name, + int a, int b, int c) { + return System::instance()->allocContactPointInfo(heap, num, name, a, b, c); +} + +void ContactPointInfo::free(ContactPointInfo* instance) { + System::instance()->freeContactPointInfo(instance); +} + +ContactPointInfo::ContactPointInfo(const sead::SafeString& name, int a, int b, int c) + : ContactPointInfoBase(name, a, b, c) {} + +ContactPointInfo::~ContactPointInfo() = default; + +void ContactPointInfo::allocPoints(sead::Heap* heap, int num) { + mPoints.allocBufferAssert(num, heap); +} + +void ContactPointInfo::freePoints() { + mPoints.freeBuffer(); +} + +} // namespace ksys::phys diff --git a/src/KingSystem/Physics/System/physRigidContactPoints.h b/src/KingSystem/Physics/System/physContactPointInfo.h similarity index 59% rename from src/KingSystem/Physics/System/physRigidContactPoints.h rename to src/KingSystem/Physics/System/physContactPointInfo.h index 621555d6..282eb90d 100644 --- a/src/KingSystem/Physics/System/physRigidContactPoints.h +++ b/src/KingSystem/Physics/System/physContactPointInfo.h @@ -13,18 +13,20 @@ namespace ksys::phys { -class IRigidContactPoints : public sead::INamable { +class ContactPointInfoBase : public sead::INamable { public: // FIXME: parameter names - IRigidContactPoints(const sead::SafeString& name, int a, int b, int c) + ContactPointInfoBase(const sead::SafeString& name, int a, int b, int c) : sead::INamable(name), _2c(a), _30(b), _34(c) {} - virtual ~IRigidContactPoints() = default; + virtual ~ContactPointInfoBase() = default; virtual void freePoints() = 0; void set30(u32 value) { _30 = value; } bool isLinked() const { return mListNode.isLinked(); } - static constexpr size_t getListNodeOffset() { return offsetof(IRigidContactPoints, mListNode); } + static constexpr size_t getListNodeOffset() { + return offsetof(ContactPointInfoBase, mListNode); + } protected: sead::Atomic _18; @@ -36,14 +38,14 @@ protected: sead::ListNode mListNode{}; }; -class RigidContactPoints : public IRigidContactPoints { +class ContactPointInfo : public ContactPointInfoBase { public: - static RigidContactPoints* make(sead::Heap* heap, int num, const sead::SafeString& name, int a, - int b, int c); - static void free(RigidContactPoints* instance); + static ContactPointInfo* make(sead::Heap* heap, int num, const sead::SafeString& name, int a, + int b, int c); + static void free(ContactPointInfo* instance); - RigidContactPoints(const sead::SafeString& name, int a, int b, int c); - ~RigidContactPoints() override; + ContactPointInfo(const sead::SafeString& name, int a, int b, int c); + ~ContactPointInfo() override; void freePoints() override; virtual void allocPoints(sead::Heap* heap, int num); @@ -51,6 +53,6 @@ private: sead::Buffer mPoints{}; void* _58{}; }; -KSYS_CHECK_SIZE_NX150(RigidContactPoints, 0x60); +KSYS_CHECK_SIZE_NX150(ContactPointInfo, 0x60); } // namespace ksys::phys diff --git a/src/KingSystem/Physics/System/physRigidContactPointsEx.cpp b/src/KingSystem/Physics/System/physContactPointInfoEx.cpp similarity index 59% rename from src/KingSystem/Physics/System/physRigidContactPointsEx.cpp rename to src/KingSystem/Physics/System/physContactPointInfoEx.cpp index ed868ec9..2f1851b4 100644 --- a/src/KingSystem/Physics/System/physRigidContactPointsEx.cpp +++ b/src/KingSystem/Physics/System/physContactPointInfoEx.cpp @@ -1,21 +1,19 @@ -#include "KingSystem/Physics/System/physRigidContactPointsEx.h" +#include "KingSystem/Physics/System/physContactPointInfoEx.h" #include "KingSystem/Physics/System/physContactMgr.h" #include "KingSystem/Physics/System/physSystem.h" namespace ksys::phys { -RigidContactPointsEx* RigidContactPointsEx::make(sead::Heap* heap, int num, int num2, - const sead::SafeString& name, int a, int b, - int c) { +ContactPointInfoEx* ContactPointInfoEx::make(sead::Heap* heap, int num, int num2, + const sead::SafeString& name, int a, int b, int c) { return System::instance()->allocContactPointsEx(heap, num, num2, name, a, b, c); } -void RigidContactPointsEx::free(RigidContactPointsEx* instance) { - System::instance()->freeContactPointsEx(instance); +void ContactPointInfoEx::free(ContactPointInfoEx* instance) { + System::instance()->freeContactPointInfoEx(instance); } -bool RigidContactPointsEx::registerLayerPair(ContactLayer layer1, ContactLayer layer2, - bool enabled) { +bool ContactPointInfoEx::registerLayerPair(ContactLayer layer1, ContactLayer layer2, bool enabled) { if (mLayerType == ContactLayerType::Invalid) mLayerType = getContactLayerType(layer1); @@ -34,7 +32,7 @@ bool RigidContactPointsEx::registerLayerPair(ContactLayer layer1, ContactLayer l return true; } -bool RigidContactPointsEx::isPairUnknown(ContactLayer layer1, ContactLayer layer2) const { +bool ContactPointInfoEx::isPairUnknown(ContactLayer layer1, ContactLayer layer2) const { for (int i = 0; i < mLayerEntries.size(); ++i) { const auto* entry = mLayerEntries[i]; if (int(layer1) == entry->layer1 && int(layer2) == entry->layer2) @@ -45,23 +43,23 @@ bool RigidContactPointsEx::isPairUnknown(ContactLayer layer1, ContactLayer layer return true; } -RigidContactPointsEx::RigidContactPointsEx(const sead::SafeString& name, int a, int b, int c) - : IRigidContactPoints(name, a, b, c) {} +ContactPointInfoEx::ContactPointInfoEx(const sead::SafeString& name, int a, int b, int c) + : ContactPointInfoBase(name, a, b, c) {} -RigidContactPointsEx::~RigidContactPointsEx() = default; +ContactPointInfoEx::~ContactPointInfoEx() = default; -void RigidContactPointsEx::allocPoints(sead::Heap* heap, int num, int num2) { +void ContactPointInfoEx::allocPoints(sead::Heap* heap, int num, int num2) { mPoints.allocBufferAssert(num, heap); mLayerEntries.allocBuffer(num2, heap); } -void RigidContactPointsEx::freePoints() { +void ContactPointInfoEx::freePoints() { mPoints.freeBuffer(); mLayerEntries.freeBuffer(); } -void RigidContactPointsEx::Iterator::getData(sead::Vector3f* out, - RigidContactPointsEx::Iterator::Mode mode) const { +void ContactPointInfoEx::Iterator::getData(sead::Vector3f* out, + ContactPointInfoEx::Iterator::Mode mode) const { const float scale = getPoint()->scale; out->e = getPoint()->_10.e; @@ -89,13 +87,13 @@ void RigidContactPointsEx::Iterator::getData(sead::Vector3f* out, } sead::Vector3f -RigidContactPointsEx::Iterator::getData(RigidContactPointsEx::Iterator::Mode mode) const { +ContactPointInfoEx::Iterator::getData(ContactPointInfoEx::Iterator::Mode mode) const { sead::Vector3f out; getData(&out, mode); return out; } -RigidContactPointsEx::Iterator::Iterator(const RigidContactPointsEx::Points& points, int count) +ContactPointInfoEx::Iterator::Iterator(const ContactPointInfoEx::Points& points, int count) : mPoints(points.getBufferPtr()), mPointsNum(count), mPointsStart(points.getBufferPtr()) { for (int i = 0; i != count; ++i) { if (!mPoints[i]->flags.isOn(ContactPoint::Flag::_1)) @@ -104,8 +102,7 @@ RigidContactPointsEx::Iterator::Iterator(const RigidContactPointsEx::Points& poi } } -RigidContactPointsEx::IteratorEnd::IteratorEnd(const RigidContactPointsEx::Points& points, - int count) +ContactPointInfoEx::IteratorEnd::IteratorEnd(const ContactPointInfoEx::Points& points, int count) : mIdx(count), mPoints(points.getBufferPtr()), mPointsNum(count), mPointsStart(points.getBufferPtr()) {} diff --git a/src/KingSystem/Physics/System/physRigidContactPointsEx.h b/src/KingSystem/Physics/System/physContactPointInfoEx.h similarity index 83% rename from src/KingSystem/Physics/System/physRigidContactPointsEx.h rename to src/KingSystem/Physics/System/physContactPointInfoEx.h index 305171af..42f2b4e5 100644 --- a/src/KingSystem/Physics/System/physRigidContactPointsEx.h +++ b/src/KingSystem/Physics/System/physContactPointInfoEx.h @@ -4,7 +4,7 @@ #include #include #include -#include "KingSystem/Physics/System/physRigidContactPoints.h" +#include "KingSystem/Physics/System/physContactPointInfo.h" #include "KingSystem/Physics/physDefines.h" #include "KingSystem/Utils/Types.h" @@ -12,8 +12,7 @@ namespace ksys::phys { struct ContactPoint; -// FIXME: rename. This should be below SensorGroupFilter and StaticCompound stuff -class RigidContactPointsEx : public IRigidContactPoints { +class ContactPointInfoEx : public ContactPointInfoBase { public: using Points = sead::Buffer; @@ -84,12 +83,12 @@ public: // FIXME: figure out the types using Callback = sead::IDelegate1; - static RigidContactPointsEx* make(sead::Heap* heap, int num, int num2, - const sead::SafeString& name, int a, int b, int c); - static void free(RigidContactPointsEx* instance); + static ContactPointInfoEx* make(sead::Heap* heap, int num, int num2, + const sead::SafeString& name, int a, int b, int c); + static void free(ContactPointInfoEx* instance); - RigidContactPointsEx(const sead::SafeString& name, int a, int b, int c); - ~RigidContactPointsEx() override; + ContactPointInfoEx(const sead::SafeString& name, int a, int b, int c); + ~ContactPointInfoEx() override; void freePoints() override; virtual void allocPoints(sead::Heap* heap, int num, int num2); @@ -113,6 +112,6 @@ private: ContactLayerType mLayerType = ContactLayerType::Invalid; Callback* mCallback = nullptr; }; -KSYS_CHECK_SIZE_NX150(RigidContactPointsEx, 0x88); +KSYS_CHECK_SIZE_NX150(ContactPointInfoEx, 0x88); } // namespace ksys::phys diff --git a/src/KingSystem/Physics/System/physRigidContactPoints.cpp b/src/KingSystem/Physics/System/physRigidContactPoints.cpp deleted file mode 100644 index 5bc63b34..00000000 --- a/src/KingSystem/Physics/System/physRigidContactPoints.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "KingSystem/Physics/System/physRigidContactPoints.h" -#include "KingSystem/Physics/System/physSystem.h" - -namespace ksys::phys { - -RigidContactPoints* RigidContactPoints::make(sead::Heap* heap, int num, - const sead::SafeString& name, int a, int b, int c) { - return System::instance()->allocContactPoints(heap, num, name, a, b, c); -} - -void RigidContactPoints::free(RigidContactPoints* instance) { - System::instance()->freeContactPoints(instance); -} - -RigidContactPoints::RigidContactPoints(const sead::SafeString& name, int a, int b, int c) - : IRigidContactPoints(name, a, b, c) {} - -RigidContactPoints::~RigidContactPoints() = default; - -void RigidContactPoints::allocPoints(sead::Heap* heap, int num) { - mPoints.allocBufferAssert(num, heap); -} - -void RigidContactPoints::freePoints() { - mPoints.freeBuffer(); -} - -} // namespace ksys::phys diff --git a/src/KingSystem/Physics/System/physSystem.cpp b/src/KingSystem/Physics/System/physSystem.cpp index ad87f567..0ef11465 100644 --- a/src/KingSystem/Physics/System/physSystem.cpp +++ b/src/KingSystem/Physics/System/physSystem.cpp @@ -7,9 +7,9 @@ #include "KingSystem/Physics/StaticCompound/physStaticCompound.h" #include "KingSystem/Physics/SupportBone/physSupportBoneResource.h" #include "KingSystem/Physics/System/physContactMgr.h" +#include "KingSystem/Physics/System/physContactPointInfo.h" #include "KingSystem/Physics/System/physEntityGroupFilter.h" #include "KingSystem/Physics/System/physMaterialTable.h" -#include "KingSystem/Physics/System/physRigidContactPoints.h" #include "KingSystem/Physics/System/physSensorGroupFilter.h" #include "KingSystem/Physics/System/physSystemData.h" #include "KingSystem/Resource/resEntryFactory.h" @@ -47,24 +47,24 @@ void System::initSystemData(sead::Heap* heap) { mContactMgr); } -RigidContactPoints* System::allocContactPoints(sead::Heap* heap, int num, - const sead::SafeString& name, int a, int b, - int c) const { +ContactPointInfo* System::allocContactPointInfo(sead::Heap* heap, int num, + const sead::SafeString& name, int a, int b, + int c) const { return mContactMgr->allocContactPoints(heap, num, name, a, b, c); } -void System::freeContactPoints(RigidContactPoints* points) const { - mContactMgr->freeContactPoints(points); +void System::freeContactPointInfo(ContactPointInfo* info) const { + mContactMgr->freeContactPointInfo(info); } -RigidContactPointsEx* System::allocContactPointsEx(sead::Heap* heap, int num, int num2, - const sead::SafeString& name, int a, int b, - int c) const { +ContactPointInfoEx* System::allocContactPointsEx(sead::Heap* heap, int num, int num2, + const sead::SafeString& name, int a, int b, + int c) const { return mContactMgr->allocContactPointsEx(heap, num, num2, name, a, b, c); } -void System::registerContactPoints(RigidContactPoints* points) const { - mContactMgr->registerContactPoints(points); +void System::registerContactPointInfo(ContactPointInfo* info) const { + mContactMgr->registerContactPointInfo(info); } } // namespace ksys::phys diff --git a/src/KingSystem/Physics/System/physSystem.h b/src/KingSystem/Physics/System/physSystem.h index 06dbc551..14b8f365 100644 --- a/src/KingSystem/Physics/System/physSystem.h +++ b/src/KingSystem/Physics/System/physSystem.h @@ -14,8 +14,8 @@ class GroupFilter; class MaterialTable; class RigidBody; class RigidBodyRequestMgr; -class RigidContactPoints; -class RigidContactPointsEx; +class ContactPointInfo; +class ContactPointInfoEx; class SystemData; class SystemGroupHandler; @@ -42,15 +42,17 @@ public: void initSystemData(sead::Heap* heap); - RigidContactPoints* allocContactPoints(sead::Heap* heap, int num, const sead::SafeString& name, - int a, int b, int c) const; - void freeContactPoints(RigidContactPoints* points) const; - RigidContactPointsEx* allocContactPointsEx(sead::Heap* heap, int num, int num2, - const sead::SafeString& name, int a, int b, - int c) const; - void freeContactPointsEx(RigidContactPointsEx* points) const; - void registerContactPoints(RigidContactPoints* points) const; - void registerContactPointLayerPair(RigidContactPointsEx* points, ContactLayer layer1, + ContactPointInfo* allocContactPointInfo(sead::Heap* heap, int num, const sead::SafeString& name, + int a, int b, int c) const; + void freeContactPointInfo(ContactPointInfo* info) const; + + ContactPointInfoEx* allocContactPointsEx(sead::Heap* heap, int num, int num2, + const sead::SafeString& name, int a, int b, + int c) const; + void freeContactPointInfoEx(ContactPointInfoEx* info) const; + + void registerContactPointInfo(ContactPointInfo* info) const; + void registerContactPointLayerPair(ContactPointInfoEx* info, ContactLayer layer1, ContactLayer layer2, bool enabled); // 0x0000007101216a20