diff options
| author | Léo Lam <leo@leolam.fr> | 2022-01-07 01:30:35 +0100 |
|---|---|---|
| committer | Léo Lam <leo@leolam.fr> | 2022-01-07 01:51:13 +0100 |
| commit | b4bbaf141f871352fe4eac1eb1ef9c7522ca8154 (patch) | |
| tree | bc479fde849b250f1d4a52f903e782265fa555d5 /src | |
| parent | 53c5d0342027160ab9c0f7fb2f9fd44d8dd7ac1a (diff) | |
ksys/phys: Add MemSystem::initSystemData
Diffstat (limited to 'src')
| -rw-r--r-- | src/KingSystem/Physics/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/KingSystem/Physics/System/physMemSystem.cpp | 42 | ||||
| -rw-r--r-- | src/KingSystem/Physics/System/physMemSystem.h | 24 | ||||
| -rw-r--r-- | src/KingSystem/Physics/System/physSensorGroupFilter.cpp | 1 | ||||
| -rw-r--r-- | src/KingSystem/Physics/System/physSensorGroupFilter.h | 14 | ||||
| -rw-r--r-- | src/KingSystem/Resource/resEntryFactory.h | 3 |
6 files changed, 83 insertions, 3 deletions
diff --git a/src/KingSystem/Physics/CMakeLists.txt b/src/KingSystem/Physics/CMakeLists.txt index fa1eb647..194fb98b 100644 --- a/src/KingSystem/Physics/CMakeLists.txt +++ b/src/KingSystem/Physics/CMakeLists.txt @@ -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 diff --git a/src/KingSystem/Physics/System/physMemSystem.cpp b/src/KingSystem/Physics/System/physMemSystem.cpp index 834d6e2e..9bf4af62 100644 --- a/src/KingSystem/Physics/System/physMemSystem.cpp +++ b/src/KingSystem/Physics/System/physMemSystem.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 { diff --git a/src/KingSystem/Physics/System/physMemSystem.h b/src/KingSystem/Physics/System/physMemSystem.h index a6a12625..908940f1 100644 --- a/src/KingSystem/Physics/System/physMemSystem.h +++ b/src/KingSystem/Physics/System/physMemSystem.h @@ -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); diff --git a/src/KingSystem/Physics/System/physSensorGroupFilter.cpp b/src/KingSystem/Physics/System/physSensorGroupFilter.cpp new file mode 100644 index 00000000..2ec514d0 --- /dev/null +++ b/src/KingSystem/Physics/System/physSensorGroupFilter.cpp @@ -0,0 +1 @@ +#include "KingSystem/Physics/System/physSensorGroupFilter.h" diff --git a/src/KingSystem/Physics/System/physSensorGroupFilter.h b/src/KingSystem/Physics/System/physSensorGroupFilter.h new file mode 100644 index 00000000..867cbd40 --- /dev/null +++ b/src/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 diff --git a/src/KingSystem/Resource/resEntryFactory.h b/src/KingSystem/Resource/resEntryFactory.h index 1ac243f2..071f70e3 100644 --- a/src/KingSystem/Resource/resEntryFactory.h +++ b/src/KingSystem/Resource/resEntryFactory.h @@ -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; } |
