diff --git a/data/uking_functions.csv b/data/uking_functions.csv index 6005e7d9..500b185a 100644 --- a/data/uking_functions.csv +++ b/data/uking_functions.csv @@ -84279,9 +84279,9 @@ Address,Quality,Size,Name 0x0000007100fcd7c4,U,000004,phys::UserTag::m4n 0x0000007100fcd7c8,U,000004,phys::UserTag::m5n 0x0000007100fcd7cc,U,000004,phys::UserTag::m7n -0x0000007100fcd7d0,U,000104, -0x0000007100fcd838,U,000020, -0x0000007100fcd84c,U,000052, +0x0000007100fcd7d0,O,000104,_ZN4ksys4phys25ContactLayerCollisionInfoC1ENS0_12ContactLayerE +0x0000007100fcd838,O,000020,_ZN4ksys4phys25ContactLayerCollisionInfoD1Ev +0x0000007100fcd84c,O,000052,_ZN4ksys4phys25ContactLayerCollisionInfoD0Ev 0x0000007100fcd880,U,000064, 0x0000007100fcd8c0,U,000004,nullsub_4256 0x0000007100fcd8c4,U,000004,j__ZdlPv_1012 diff --git a/src/KingSystem/Physics/CMakeLists.txt b/src/KingSystem/Physics/CMakeLists.txt index 479c28be..fcf5219d 100644 --- a/src/KingSystem/Physics/CMakeLists.txt +++ b/src/KingSystem/Physics/CMakeLists.txt @@ -105,6 +105,8 @@ target_sources(uking PRIVATE System/physConstraint.h System/physContactInfoParam.cpp System/physContactInfoParam.h + System/physContactLayerCollisionInfo.cpp + System/physContactLayerCollisionInfo.h System/physContactListener.cpp System/physContactListener.h System/physContactMgr.cpp diff --git a/src/KingSystem/Physics/System/physContactLayerCollisionInfo.cpp b/src/KingSystem/Physics/System/physContactLayerCollisionInfo.cpp new file mode 100644 index 00000000..72d5ffb1 --- /dev/null +++ b/src/KingSystem/Physics/System/physContactLayerCollisionInfo.cpp @@ -0,0 +1,12 @@ +#include "KingSystem/Physics/System/physContactLayerCollisionInfo.h" + +namespace ksys::phys { + +ContactLayerCollisionInfo::ContactLayerCollisionInfo(ContactLayer layer) : mLayer(layer) { + // FIXME: figure out what this is + mList.initOffset(0x10); +} + +ContactLayerCollisionInfo::~ContactLayerCollisionInfo() = default; + +} // namespace ksys::phys diff --git a/src/KingSystem/Physics/System/physContactLayerCollisionInfo.h b/src/KingSystem/Physics/System/physContactLayerCollisionInfo.h new file mode 100644 index 00000000..d2819e85 --- /dev/null +++ b/src/KingSystem/Physics/System/physContactLayerCollisionInfo.h @@ -0,0 +1,26 @@ +#pragma once + +#include +#include "KingSystem/Physics/System/physCollisionInfo.h" +#include "KingSystem/Physics/physDefines.h" + +namespace ksys::phys { + +/// Tracks contact points for a contact layer. +class ContactLayerCollisionInfo : public CollisionInfoBase { +public: + explicit ContactLayerCollisionInfo(ContactLayer layer); + ~ContactLayerCollisionInfo() override; + + ContactLayer getLayer() const { return mLayer; } + + auto& getList() { return mList; } + const auto& getList() const { return mList; } + +private: + ContactLayer mLayer; + // FIXME: type + sead::OffsetList mList; +}; + +} // namespace ksys::phys diff --git a/src/KingSystem/Physics/System/physContactListener.cpp b/src/KingSystem/Physics/System/physContactListener.cpp index 7fbd3c56..d41ec16c 100644 --- a/src/KingSystem/Physics/System/physContactListener.cpp +++ b/src/KingSystem/Physics/System/physContactListener.cpp @@ -6,6 +6,7 @@ #include #include #include "KingSystem/Physics/RigidBody/physRigidBody.h" +#include "KingSystem/Physics/System/physContactLayerCollisionInfo.h" #include "KingSystem/Physics/System/physContactMgr.h" #include "KingSystem/Physics/System/physSystem.h" @@ -29,16 +30,16 @@ void ContactListener::init(sead::Heap* heap) { _20[i].allocBufferAssert(mLayerCount, nullptr); } - _30.allocBufferAssert(mLayerCount, nullptr); + mCollisionInfoPerLayerPair.allocBufferAssert(mLayerCount, nullptr); for (u32 i = 0; i < mLayerCount; ++i) { - auto& row = _30[i]; + auto& row = mCollisionInfoPerLayerPair[i]; row.allocBufferAssert(mLayerCount, nullptr); for (u32 j = 0; j < mLayerCount; ++j) { if (j >= i) { - row[j] = new (heap) ContactUnk1(mLayerBase + i); + row[j] = new (heap) ContactLayerCollisionInfo(mLayerBase + i); } else { - row[j] = _30[j][i]; + row[j] = mCollisionInfoPerLayerPair[j][i]; } } } @@ -106,14 +107,14 @@ void ContactListener::handleCollisionRemoved(const hkpCollisionEvent& event, Rig const auto i = int(layer_a - mLayerBase); const auto j = int(layer_b - mLayerBase); - ContactUnk1* unk = _30[i][j]; - if (unk->_68) { + ContactLayerCollisionInfo* info = mCollisionInfoPerLayerPair[i][j]; + if (!info->getList().isEmpty()) { const auto layer_a_ = int(layer_a); - const auto layer_unk = unk->_50; - const bool body_a_first = layer_a_ == layer_unk; + const auto tracked_layer = info->getLayer(); + const bool body_a_first = layer_a_ == tracked_layer; auto* body1 = body_a_first ? body_a : body_b; auto* body2 = body_a_first ? body_b : body_a; - mMgr->x_20(unk, body1, body2); + mMgr->x_20(info, body1, body2); } } diff --git a/src/KingSystem/Physics/System/physContactListener.h b/src/KingSystem/Physics/System/physContactListener.h index f04aa91b..c64090fd 100644 --- a/src/KingSystem/Physics/System/physContactListener.h +++ b/src/KingSystem/Physics/System/physContactListener.h @@ -10,20 +10,10 @@ namespace ksys::phys { +class ContactLayerCollisionInfo; class ContactMgr; class RigidBody; -struct ContactUnk1 { - ContactUnk1(u32 layer); - virtual ~ContactUnk1(); - - u8 _8[0x50 - 0x8]; - ContactLayer _50; - u8 _54[0x68 - 0x54]; - u32 _68; - u32 _6c; -}; - class ContactListener : public hkpContactListener, public sead::hostio::Node { SEAD_RTTI_BASE(ContactListener) public: @@ -72,7 +62,7 @@ private: ContactLayerType mLayerType{}; u32 mLayerBase{}; sead::Buffer>> _20; - sead::Buffer> _30; + sead::Buffer> mCollisionInfoPerLayerPair; void* _40{}; u32 _48{}; u32 mLayerCount{}; diff --git a/src/KingSystem/Physics/System/physContactMgr.h b/src/KingSystem/Physics/System/physContactMgr.h index 7c61b4a9..04b107dd 100644 --- a/src/KingSystem/Physics/System/physContactMgr.h +++ b/src/KingSystem/Physics/System/physContactMgr.h @@ -22,7 +22,7 @@ class Heap; namespace ksys::phys { -struct ContactUnk1; +class ContactLayerCollisionInfo; enum class IsIndoorStage; class ContactPointInfoBase; class RigidBody; @@ -91,11 +91,11 @@ public: // 0x0000007100fb3744 void x_17(void* unk, RigidBody* body_a, RigidBody* body_b); // 0x0000007100fb37d4 - void x_18(ContactUnk1* unk, RigidBody* body_a, RigidBody* body_b); + void x_18(ContactLayerCollisionInfo* info, RigidBody* body_a, RigidBody* body_b); // 0x0000007100fb3854 void x_19(void* unk, RigidBody* body_a, RigidBody* body_b); // 0x0000007100fb3938 - void x_20(ContactUnk1* unk, RigidBody* body_a, RigidBody* body_b); + void x_20(ContactLayerCollisionInfo* info, RigidBody* body_a, RigidBody* body_b); private: void doLoadContactInfoTable(agl::utl::ResParameterArchive archive, ContactLayerType type,