ksys/phys: Add MemSystem::initSystemData

This commit is contained in:
Léo Lam
2022-01-07 01:30:35 +01:00
parent 53c5d03420
commit b4bbaf141f
7 changed files with 133 additions and 53 deletions
+2
View File
@@ -84,6 +84,8 @@ target_sources(uking PRIVATE
System/physRigidContactPoints.h
System/physRigidContactPointsEx.cpp
System/physRigidContactPointsEx.h
System/physSensorGroupFilter.cpp
System/physSensorGroupFilter.h
System/physShapeParam.cpp
System/physShapeParam.h
System/physSystemData.cpp
@@ -1,11 +1,53 @@
#include "KingSystem/Physics/System/physMemSystem.h"
#include "KingSystem/Physics/Cloth/physClothResource.h"
#include "KingSystem/Physics/Ragdoll/physRagdollControllerKeyList.h"
#include "KingSystem/Physics/Ragdoll/physRagdollResource.h"
#include "KingSystem/Physics/RigidBody/TeraMesh/physTeraMeshRigidBodyResource.h"
#include "KingSystem/Physics/RigidBody/physRigidBodyResource.h"
#include "KingSystem/Physics/StaticCompound/physStaticCompound.h"
#include "KingSystem/Physics/SupportBone/physSupportBoneResource.h"
#include "KingSystem/Physics/System/physContactMgr.h"
#include "KingSystem/Physics/System/physEntityGroupFilter.h"
#include "KingSystem/Physics/System/physMaterialTable.h"
#include "KingSystem/Physics/System/physRigidContactPoints.h"
#include "KingSystem/Physics/System/physSensorGroupFilter.h"
#include "KingSystem/Physics/System/physSystemData.h"
#include "KingSystem/Resource/resEntryFactory.h"
#include "KingSystem/Resource/resSystem.h"
namespace ksys::phys {
SEAD_SINGLETON_DISPOSER_IMPL(MemSystem)
void MemSystem::initSystemData(sead::Heap* heap) {
res::registerEntryFactory(new (heap) res::EntryFactory<RigidBodyResource>(1.0, 0x400), "hkrb");
res::registerEntryFactory(new (heap) res::EntryFactory<RagdollResource>(1.0, 0x400), "hkrg");
res::registerEntryFactory(new (heap) res::EntryFactory<SupportBoneResource>(1.0, 0x100000),
"bphyssb");
res::registerEntryFactory(new (heap) res::EntryFactory<ClothResource>(2.0, 0x2800), "hkcl");
res::registerEntryFactory(new (heap) res::EntryFactory<StaticCompound>(1.3, 0x40000), "hksc");
res::registerEntryFactory(new (heap) res::EntryFactory<TeraMeshRigidBodyResource>(1.0, 0x800),
"hktmrb");
res::registerEntryFactory(new (heap) res::EntryFactory<RagdollControllerKeyList>(1.0, 0x4000),
"brgcon");
mEntityGroupFilter = EntityGroupFilter::make(ContactLayer::EntityObject,
ContactLayer::EntityMeshVisualizer, heap);
mSensorGroupFilter = SensorGroupFilter::make(ContactLayer::SensorCustomReceiver, heap);
mGroupFilters.pushBack(mEntityGroupFilter);
mGroupFilters.pushBack(mSensorGroupFilter);
mContactMgr = new (heap) ContactMgr;
if (mContactMgr)
mContactMgr->init(heap);
mMaterialTable = new (heap) MaterialTable;
mSystemData = new (heap) SystemData;
mSystemData->load(mPhysicsSystemHeap, mEntityGroupFilter, mSensorGroupFilter, mMaterialTable,
mContactMgr);
}
RigidContactPoints* MemSystem::allocContactPoints(sead::Heap* heap, int num,
const sead::SafeString& name, int a, int b,
int c) const {
+22 -2
View File
@@ -1,7 +1,9 @@
#pragma once
#include <basis/seadTypes.h>
#include <container/seadPtrArray.h>
#include <heap/seadDisposer.h>
#include <thread/seadCriticalSection.h>
#include "KingSystem/Physics/System/physDefines.h"
#include "KingSystem/Utils/Types.h"
@@ -38,6 +40,8 @@ public:
SystemData* getSystemData() const { return mSystemData; }
MaterialTable* getMaterialTable() const { return mMaterialTable; }
void initSystemData(sead::Heap* heap);
RigidContactPoints* allocContactPoints(sead::Heap* heap, int num, const sead::SafeString& name,
int a, int b, int c) const;
void freeContactPoints(RigidContactPoints* points) const;
@@ -52,7 +56,15 @@ public:
void removeSystemGroupHandler(SystemGroupHandler* handler);
private:
u8 _28[0x148 - 0x28];
u8 _28[0xa8 - 0x28];
sead::CriticalSection mCS;
void* _e8{};
void* _f0{};
GroupFilter* mEntityGroupFilter{};
GroupFilter* mSensorGroupFilter{};
sead::FixedPtrArray<GroupFilter, 2> mGroupFilters;
// FIXME: type
sead::FixedPtrArray<void*, 2> _128;
ContactMgr* mContactMgr;
void* _150;
void* _158;
@@ -61,7 +73,15 @@ private:
void* mRigidBodyDividedMeshShapeMgr;
SystemData* mSystemData;
MaterialTable* mMaterialTable;
u8 _188[0x480 - 0x188];
void* _188{};
void* _190{};
void* _198{};
void* _1a0{};
sead::Heap* mPhysicsSystemHeap{};
sead::Heap* mDebugHeap{};
sead::Heap* mPhysicsTempDefaultHeap{};
sead::Heap* mPhysicsTempLowHeap{};
u8 _1c8[0x480 - 0x1c8];
};
KSYS_CHECK_SIZE_NX150(MemSystem, 0x480);
@@ -0,0 +1 @@
#include "KingSystem/Physics/System/physSensorGroupFilter.h"
@@ -0,0 +1,14 @@
#pragma once
#include "KingSystem/Physics/System/physGroupFilter.h"
namespace ksys::phys {
// FIXME
class SensorGroupFilter : public GroupFilter {
SEAD_RTTI_OVERRIDE(SensorGroupFilter, GroupFilter)
public:
static SensorGroupFilter* make(ContactLayer::ValueType last, sead::Heap* heap);
};
} // namespace ksys::phys
+2 -1
View File
@@ -32,7 +32,8 @@ template <typename T>
class EntryFactory : public EntryFactoryBase {
SEAD_RTTI_OVERRIDE(EntryFactory<T>, EntryFactoryBase)
public:
using EntryFactoryBase::EntryFactoryBase;
explicit EntryFactory(f32 size_multiplier = 1.0, u32 size_constant = 0)
: EntryFactoryBase(size_multiplier, size_constant) {}
u32 getResourceSize() const override { return sizeof(T); }
u32 getLoadDataAlignment() const override { return T::cLoadDataAlignment; }