From 1e080b32ebdffedffcf2e7a5a3c002ce7bfe54f1 Mon Sep 17 00:00:00 2001 From: RobbyV2 Date: Wed, 29 Jul 2026 09:27:42 -0400 Subject: phys: match System contact listener and group handler functions --- data/uking_functions.csv | 8 ++++---- .../Physics/System/physLayerContactPointInfo.h | 2 ++ src/KingSystem/Physics/System/physSystem.cpp | 23 ++++++++++++++++++++++ src/KingSystem/Physics/System/physSystem.h | 4 ++-- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/data/uking_functions.csv b/data/uking_functions.csv index 10518633..4109073c 100644 --- a/data/uking_functions.csv +++ b/data/uking_functions.csv @@ -93566,7 +93566,7 @@ Address,Quality,Size,Name 0x0000007101215784,U,000048,_ZN4ksys4phys6System11unlockWorldENS0_16ContactLayerTypeEPKciNS0_16OnlyLockIfNeededE 0x00000071012157b4,U,000464,PhysicsMemSys::__auto0 0x0000007101215984,U,000484,PhysicsMemSys::initGroupFilterXs -0x0000007101215b68,U,000036,_ZN4ksys4phys6System24removeSystemGroupHandlerEPNS0_18SystemGroupHandlerE +0x0000007101215b68,O,000036,_ZN4ksys4phys6System24removeSystemGroupHandlerEPNS0_18SystemGroupHandlerE 0x0000007101215b8c,U,001728,ksys::phys::System::createWorld 0x000000710121624c,U,000220,PhysicsMemSys::__auto1 0x0000007101216328,U,000200,PhysicsMemSys::__auto5 @@ -93594,15 +93594,15 @@ Address,Quality,Size,Name 0x00000071012168fc,O,000008,_ZNK4ksys4phys6System21allocContactPointInfoEPN4sead4HeapEiRKNS2_14SafeStringBaseIcEEiii 0x0000007101216904,O,000008,_ZNK4ksys4phys6System20freeContactPointInfoEPNS0_16ContactPointInfoE 0x000000710121690c,O,000008,_ZNK4ksys4phys6System26allocLayerContactPointInfoEPN4sead4HeapEiiRKNS2_14SafeStringBaseIcEEiii -0x0000007101216914,U,000080,_ZNK4ksys4phys6System25freeLayerContactPointInfoEPNS0_21LayerContactPointInfoE +0x0000007101216914,O,000080,_ZNK4ksys4phys6System25freeLayerContactPointInfoEPNS0_21LayerContactPointInfoE 0x0000007101216964,O,000008,_ZNK4ksys4phys6System24registerContactPointInfoEPNS0_16ContactPointInfoE 0x000000710121696c,U,000008,PhysicsMemSys::x_3 -0x0000007101216974,U,000048,_ZN4ksys4phys6System29registerContactPointLayerPairEPNS0_21LayerContactPointInfoENS0_12ContactLayerES4_b +0x0000007101216974,O,000048,_ZN4ksys4phys6System29registerContactPointLayerPairEPNS0_21LayerContactPointInfoENS0_12ContactLayerES4_b 0x00000071012169a4,O,000008,_ZNK4ksys4phys6System18allocCollisionInfoEPN4sead4HeapERKNS2_14SafeStringBaseIcEE 0x00000071012169ac,O,000008,_ZNK4ksys4phys6System17freeCollisionInfoEPNS0_13CollisionInfoE 0x00000071012169b4,O,000012,_ZN4ksys4phys6System34makeContactLayerCollisionInfoGroupEPN4sead4HeapENS0_12ContactLayerEiRKNS2_14SafeStringBaseIcEE 0x00000071012169c0,O,000008,_ZN4ksys4phys6System34freeContactLayerCollisionInfoGroupEPNS0_30ContactLayerCollisionInfoGroupE -0x00000071012169c8,U,000088,_ZN4ksys4phys6System14trackLayerPairENS0_12ContactLayerES2_ +0x00000071012169c8,O,000088,_ZN4ksys4phys6System14trackLayerPairENS0_12ContactLayerES2_ 0x0000007101216a20,U,000136,_ZN4ksys4phys6System32removeRigidBodyFromContactSystemEPNS0_9RigidBodyE 0x0000007101216aa8,U,000008, 0x0000007101216ab0,U,000008, diff --git a/src/KingSystem/Physics/System/physLayerContactPointInfo.h b/src/KingSystem/Physics/System/physLayerContactPointInfo.h index 377adb07..2080cfb0 100644 --- a/src/KingSystem/Physics/System/physLayerContactPointInfo.h +++ b/src/KingSystem/Physics/System/physLayerContactPointInfo.h @@ -84,6 +84,8 @@ public: bool registerLayerPair(ContactLayer layer1, ContactLayer layer2, bool enabled = true); bool isPairUnknown(ContactLayer layer1, ContactLayer layer2) const; + ContactLayerType getLayerType() const { return mLayerType; } + ContactCallback* getCallback() const { return mCallback; } void setCallback(ContactCallback* callback) { mCallback = callback; } diff --git a/src/KingSystem/Physics/System/physSystem.cpp b/src/KingSystem/Physics/System/physSystem.cpp index e9a1ffb5..ef55e1f1 100644 --- a/src/KingSystem/Physics/System/physSystem.cpp +++ b/src/KingSystem/Physics/System/physSystem.cpp @@ -6,10 +6,12 @@ #include "KingSystem/Physics/RigidBody/physRigidBodyResource.h" #include "KingSystem/Physics/StaticCompound/physStaticCompound.h" #include "KingSystem/Physics/SupportBone/physSupportBoneResource.h" +#include "KingSystem/Physics/System/physContactListener.h" #include "KingSystem/Physics/System/physContactMgr.h" #include "KingSystem/Physics/System/physContactPointInfo.h" #include "KingSystem/Physics/System/physEntityGroupFilter.h" #include "KingSystem/Physics/System/physGroupFilter.h" +#include "KingSystem/Physics/System/physLayerContactPointInfo.h" #include "KingSystem/Physics/System/physMaterialTable.h" #include "KingSystem/Physics/System/physRayCastRequestMgr.h" #include "KingSystem/Physics/System/physSensorGroupFilter.h" @@ -53,6 +55,10 @@ void System::initSystemData(sead::Heap* heap) { mContactMgr); } +void System::removeSystemGroupHandler(SystemGroupHandler* handler) { + mGroupFilters[static_cast(handler->getLayerType())]->removeSystemGroupHandler(handler); +} + ContactPointInfo* System::allocContactPointInfo(sead::Heap* heap, int num, const sead::SafeString& name, int a, int b, int c) const { @@ -100,10 +106,27 @@ LayerContactPointInfo* System::allocLayerContactPointInfo(sead::Heap* heap, int return mContactMgr->makeLayerContactPointInfo(heap, num, num2, name, a, b, c); } +void System::freeLayerContactPointInfo(LayerContactPointInfo* info) const { + mContactListeners[static_cast(info->getLayerType())]->removeLayerPairsForContactPointInfo( + info); + mContactMgr->freeContactPointInfo(info); +} + void System::registerContactPointInfo(ContactPointInfo* info) const { mContactMgr->registerContactPointInfo(info); } +void System::registerContactPointLayerPair(LayerContactPointInfo* info, ContactLayer layer1, + ContactLayer layer2, bool enabled) { + mContactListeners[static_cast(info->getLayerType())]->addLayerPairForContactPointInfo( + info, layer1, layer2, enabled); +} + +ContactLayerCollisionInfo* System::trackLayerPair(ContactLayer layer_a, ContactLayer layer_b) { + return mContactListeners[static_cast(getContactLayerType(layer_a))]->trackLayerPair( + layer_a, layer_b); +} + RagdollControllerKeyList* System::getRagdollCtrlKeyList() const { if (!mSystemData) return nullptr; diff --git a/src/KingSystem/Physics/System/physSystem.h b/src/KingSystem/Physics/System/physSystem.h index 1bd55360..67559001 100644 --- a/src/KingSystem/Physics/System/physSystem.h +++ b/src/KingSystem/Physics/System/physSystem.h @@ -14,6 +14,7 @@ namespace ksys::phys { class CollisionInfo; class ContactLayerCollisionInfo; class ContactLayerCollisionInfoGroup; +class ContactListener; class ContactMgr; class ContactPointInfo; class GroupFilter; @@ -151,8 +152,7 @@ private: GroupFilter* mEntityGroupFilter{}; GroupFilter* mSensorGroupFilter{}; sead::FixedPtrArray mGroupFilters; - // FIXME: type - sead::FixedPtrArray _128; + sead::FixedPtrArray mContactListeners; ContactMgr* mContactMgr; void* _150; StaticCompoundMgr* mStaticCompoundMgr; -- cgit v1.2.3