summaryrefslogtreecommitdiff
path: root/src/KingSystem
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2022-03-01 20:07:55 +0100
committerLéo Lam <leo@leolam.fr>2022-03-01 20:10:56 +0100
commit220cb534689303a2ef4df51a41b6142cfe9b7ee2 (patch)
tree30e3bf33c071976a21f81d7c0a7a71fd98c3725c /src/KingSystem
parent35cc8dd9ee6ed41dffc71da40f0981d1d002b6d0 (diff)
ksys/phys: Add ContactLayerCollisionInfo
Diffstat (limited to 'src/KingSystem')
-rw-r--r--src/KingSystem/Physics/CMakeLists.txt2
-rw-r--r--src/KingSystem/Physics/System/physContactLayerCollisionInfo.cpp12
-rw-r--r--src/KingSystem/Physics/System/physContactLayerCollisionInfo.h26
-rw-r--r--src/KingSystem/Physics/System/physContactListener.cpp19
-rw-r--r--src/KingSystem/Physics/System/physContactListener.h14
-rw-r--r--src/KingSystem/Physics/System/physContactMgr.h6
6 files changed, 55 insertions, 24 deletions
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 <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
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 <math/seadMathCalcCommon.h>
#include <prim/seadMemUtil.h>
#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<sead::Buffer<sead::FixedObjArray<Unk1, 8>>> _20;
- sead::Buffer<sead::Buffer<ContactUnk1*>> _30;
+ sead::Buffer<sead::Buffer<ContactLayerCollisionInfo*>> 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,