ksys/phys: Implement ContactMgr contact point pool functions

This commit is contained in:
Léo Lam 2022-01-04 18:51:27 +01:00
parent 8cf2def97c
commit 3f33ba5d59
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
4 changed files with 27 additions and 10 deletions

View File

@ -83723,8 +83723,8 @@ Address,Quality,Size,Name
0x0000007100fb2230,U,000180,
0x0000007100fb22e4,U,000036,
0x0000007100fb2308,U,000212,
0x0000007100fb23dc,U,000152,
0x0000007100fb2474,U,000116,
0x0000007100fb23dc,O,000152,_ZN4ksys4phys10ContactMgr20initContactPointPoolEPN4sead4HeapENS0_13IsIndoorStageE
0x0000007100fb2474,O,000116,_ZN4ksys4phys10ContactMgr20freeContactPointPoolEv
0x0000007100fb24e8,O,000316,_ZN4ksys4phys10ContactMgr20loadContactInfoTableEPN4sead4HeapEN3agl3utl19ResParameterArchiveENS0_16ContactLayerTypeE
0x0000007100fb2624,O,000688,_ZN4ksys4phys10ContactMgr22doLoadContactInfoTableEN3agl3utl19ResParameterArchiveENS0_16ContactLayerTypeEb
0x0000007100fb28d4,O,000136,_ZN4ksys4phys10ContactMgr18allocContactPointsEPN4sead4HeapEiRKNS2_14SafeStringBaseIcEEiii

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

View File

@ -18,6 +18,17 @@ ContactMgr::ContactMgr() {
mList5.initOffset(0x48);
}
void ContactMgr::initContactPointPool(sead::Heap* heap, IsIndoorStage indoor) {
int count = 0x1000;
if (indoor == IsIndoorStage::Yes)
count = 0x2000;
mContactPointPool.allocBufferAssert(count, heap);
}
void ContactMgr::freeContactPointPool() {
mContactPointPool.freeBuffer();
}
void ContactMgr::loadContactInfoTable(sead::Heap* heap, agl::utl::ResParameterArchive archive,
ContactLayerType type) {
auto& table = mContactInfoTables[int(type)];

View File

@ -13,6 +13,7 @@
#include <thread/seadAtomic.h>
#include <thread/seadMutex.h>
#include "KingSystem/Physics/System/physDefines.h"
#include "KingSystem/Physics/System/physMaterialMask.h"
#include "KingSystem/Utils/Types.h"
namespace sead {
@ -21,6 +22,7 @@ class Heap;
namespace ksys::phys {
enum class IsIndoorStage;
class IRigidContactPoints;
class RigidContactPoints;
class RigidContactPointsEx;
@ -55,12 +57,8 @@ struct ContactPoint {
sead::Vector3f _10;
sead::Vector3f _1c;
float scale;
void* _30;
void* _38;
void* _40;
void* _48;
void* _50;
void* _58;
MaterialMask material_mask1;
MaterialMask material_mask2;
void* _60;
sead::TypedBitFlag<Flag, u8> flags;
};
@ -73,6 +71,9 @@ public:
void init(sead::Heap* heap);
void initContactPointPool(sead::Heap* heap, IsIndoorStage indoor);
void freeContactPointPool();
void loadContactInfoTable(sead::Heap* heap, agl::utl::ResParameterArchive archive,
ContactLayerType type);
@ -89,8 +90,8 @@ private:
void doLoadContactInfoTable(agl::utl::ResParameterArchive archive, ContactLayerType type,
bool skip_params);
// FIXME: type, name
sead::Buffer<void*> mBuffer;
// Used to optimise ContactPoint allocations.
sead::Buffer<ContactPoint> mContactPointPool;
sead::OffsetList<void*> mList0;
int mList0Size = 0;
sead::Atomic<int> _34 = 0;

View File

@ -21,6 +21,11 @@ struct RigidBodyRequestMgr {
void sub_7100FA6C8C(bool, RigidBody*);
};
enum class IsIndoorStage {
No,
Yes,
};
class MemSystem {
SEAD_SINGLETON_DISPOSER(MemSystem)
MemSystem();