ksys/phys: Add ContactLayerCollisionInfo

This commit is contained in:
Léo Lam 2022-03-01 20:07:55 +01:00
parent 35cc8dd9ee
commit 220cb53468
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
7 changed files with 58 additions and 27 deletions

View File

@ -84279,9 +84279,9 @@ Address,Quality,Size,Name
0x0000007100fcd7c4,U,000004,phys::UserTag::m4n 0x0000007100fcd7c4,U,000004,phys::UserTag::m4n
0x0000007100fcd7c8,U,000004,phys::UserTag::m5n 0x0000007100fcd7c8,U,000004,phys::UserTag::m5n
0x0000007100fcd7cc,U,000004,phys::UserTag::m7n 0x0000007100fcd7cc,U,000004,phys::UserTag::m7n
0x0000007100fcd7d0,U,000104, 0x0000007100fcd7d0,O,000104,_ZN4ksys4phys25ContactLayerCollisionInfoC1ENS0_12ContactLayerE
0x0000007100fcd838,U,000020, 0x0000007100fcd838,O,000020,_ZN4ksys4phys25ContactLayerCollisionInfoD1Ev
0x0000007100fcd84c,U,000052, 0x0000007100fcd84c,O,000052,_ZN4ksys4phys25ContactLayerCollisionInfoD0Ev
0x0000007100fcd880,U,000064, 0x0000007100fcd880,U,000064,
0x0000007100fcd8c0,U,000004,nullsub_4256 0x0000007100fcd8c0,U,000004,nullsub_4256
0x0000007100fcd8c4,U,000004,j__ZdlPv_1012 0x0000007100fcd8c4,U,000004,j__ZdlPv_1012

Can't render this file because it is too large.

View File

@ -105,6 +105,8 @@ target_sources(uking PRIVATE
System/physConstraint.h System/physConstraint.h
System/physContactInfoParam.cpp System/physContactInfoParam.cpp
System/physContactInfoParam.h System/physContactInfoParam.h
System/physContactLayerCollisionInfo.cpp
System/physContactLayerCollisionInfo.h
System/physContactListener.cpp System/physContactListener.cpp
System/physContactListener.h System/physContactListener.h
System/physContactMgr.cpp System/physContactMgr.cpp

View File

@ -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

View File

@ -0,0 +1,26 @@
#pragma once
#include <container/seadOffsetList.h>
#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<void*> mList;
};
} // namespace ksys::phys

View File

@ -6,6 +6,7 @@
#include <math/seadMathCalcCommon.h> #include <math/seadMathCalcCommon.h>
#include <prim/seadMemUtil.h> #include <prim/seadMemUtil.h>
#include "KingSystem/Physics/RigidBody/physRigidBody.h" #include "KingSystem/Physics/RigidBody/physRigidBody.h"
#include "KingSystem/Physics/System/physContactLayerCollisionInfo.h"
#include "KingSystem/Physics/System/physContactMgr.h" #include "KingSystem/Physics/System/physContactMgr.h"
#include "KingSystem/Physics/System/physSystem.h" #include "KingSystem/Physics/System/physSystem.h"
@ -29,16 +30,16 @@ void ContactListener::init(sead::Heap* heap) {
_20[i].allocBufferAssert(mLayerCount, nullptr); _20[i].allocBufferAssert(mLayerCount, nullptr);
} }
_30.allocBufferAssert(mLayerCount, nullptr); mCollisionInfoPerLayerPair.allocBufferAssert(mLayerCount, nullptr);
for (u32 i = 0; i < mLayerCount; ++i) { for (u32 i = 0; i < mLayerCount; ++i) {
auto& row = _30[i]; auto& row = mCollisionInfoPerLayerPair[i];
row.allocBufferAssert(mLayerCount, nullptr); row.allocBufferAssert(mLayerCount, nullptr);
for (u32 j = 0; j < mLayerCount; ++j) { for (u32 j = 0; j < mLayerCount; ++j) {
if (j >= i) { if (j >= i) {
row[j] = new (heap) ContactUnk1(mLayerBase + i); row[j] = new (heap) ContactLayerCollisionInfo(mLayerBase + i);
} else { } 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 i = int(layer_a - mLayerBase);
const auto j = int(layer_b - mLayerBase); const auto j = int(layer_b - mLayerBase);
ContactUnk1* unk = _30[i][j]; ContactLayerCollisionInfo* info = mCollisionInfoPerLayerPair[i][j];
if (unk->_68) { if (!info->getList().isEmpty()) {
const auto layer_a_ = int(layer_a); const auto layer_a_ = int(layer_a);
const auto layer_unk = unk->_50; const auto tracked_layer = info->getLayer();
const bool body_a_first = layer_a_ == layer_unk; const bool body_a_first = layer_a_ == tracked_layer;
auto* body1 = body_a_first ? body_a : body_b; auto* body1 = body_a_first ? body_a : body_b;
auto* body2 = body_a_first ? body_b : body_a; auto* body2 = body_a_first ? body_b : body_a;
mMgr->x_20(unk, body1, body2); mMgr->x_20(info, body1, body2);
} }
} }

View File

@ -10,20 +10,10 @@
namespace ksys::phys { namespace ksys::phys {
class ContactLayerCollisionInfo;
class ContactMgr; class ContactMgr;
class RigidBody; 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 { class ContactListener : public hkpContactListener, public sead::hostio::Node {
SEAD_RTTI_BASE(ContactListener) SEAD_RTTI_BASE(ContactListener)
public: public:
@ -72,7 +62,7 @@ private:
ContactLayerType mLayerType{}; ContactLayerType mLayerType{};
u32 mLayerBase{}; u32 mLayerBase{};
sead::Buffer<sead::Buffer<sead::FixedObjArray<Unk1, 8>>> _20; sead::Buffer<sead::Buffer<sead::FixedObjArray<Unk1, 8>>> _20;
sead::Buffer<sead::Buffer<ContactUnk1*>> _30; sead::Buffer<sead::Buffer<ContactLayerCollisionInfo*>> mCollisionInfoPerLayerPair;
void* _40{}; void* _40{};
u32 _48{}; u32 _48{};
u32 mLayerCount{}; u32 mLayerCount{};

View File

@ -22,7 +22,7 @@ class Heap;
namespace ksys::phys { namespace ksys::phys {
struct ContactUnk1; class ContactLayerCollisionInfo;
enum class IsIndoorStage; enum class IsIndoorStage;
class ContactPointInfoBase; class ContactPointInfoBase;
class RigidBody; class RigidBody;
@ -91,11 +91,11 @@ public:
// 0x0000007100fb3744 // 0x0000007100fb3744
void x_17(void* unk, RigidBody* body_a, RigidBody* body_b); void x_17(void* unk, RigidBody* body_a, RigidBody* body_b);
// 0x0000007100fb37d4 // 0x0000007100fb37d4
void x_18(ContactUnk1* unk, RigidBody* body_a, RigidBody* body_b); void x_18(ContactLayerCollisionInfo* info, RigidBody* body_a, RigidBody* body_b);
// 0x0000007100fb3854 // 0x0000007100fb3854
void x_19(void* unk, RigidBody* body_a, RigidBody* body_b); void x_19(void* unk, RigidBody* body_a, RigidBody* body_b);
// 0x0000007100fb3938 // 0x0000007100fb3938
void x_20(ContactUnk1* unk, RigidBody* body_a, RigidBody* body_b); void x_20(ContactLayerCollisionInfo* info, RigidBody* body_a, RigidBody* body_b);
private: private:
void doLoadContactInfoTable(agl::utl::ResParameterArchive archive, ContactLayerType type, void doLoadContactInfoTable(agl::utl::ResParameterArchive archive, ContactLayerType type,