Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions data/uking_functions.csv
Original file line number Diff line number Diff line change
Expand Up @@ -93611,13 +93611,13 @@ Address,Quality,Size,Name
0x0000007101216ac8,O,000032,_ZNK4ksys4phys6System14getGroupFilterENS0_16ContactLayerTypeE
0x0000007101216ae8,O,000012,_ZN4ksys4phys6System19allocRayCastRequestEPNS0_18SystemGroupHandlerENS0_9GroundHitE
0x0000007101216af4,U,000276,
0x0000007101216c08,U,000080,PhysicsMemSys::isHavokMainHeapOom
0x0000007101216c08,O,000080,_ZNK4ksys4phys6System18isHavokMainHeapOomEv
0x0000007101216c58,U,000008,PhysicsMemSys::setRigidBodyDividedMeshShapeMgr
0x0000007101216c60,U,000020,phys::System::setEntityContactListenerField90
0x0000007101216c74,U,000016,_ZNK4ksys4phys6System31getEntityContactListenerField90Ev
0x0000007101216c84,O,000032,_ZNK4ksys4phys6System21getRagdollCtrlKeyListEv
0x0000007101216ca4,U,000072,_ZNK4ksys4phys6System17isActorSystemIdleEv
0x0000007101216cec,U,000148,_ZNK4ksys4phys6System18getPhysicsTempHeapENS0_11LowPriorityE
0x0000007101216cec,O,000148,_ZNK4ksys4phys6System18getPhysicsTempHeapENS0_11LowPriorityE
0x0000007101216d80,U,000112,
0x0000007101216df0,U,000152,PhysicsMemSys::__auto9
0x0000007101216e88,U,000076,
Expand Down
21 changes: 21 additions & 0 deletions src/KingSystem/Physics/System/physSystem.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "KingSystem/Physics/System/physSystem.h"
#include <heap/seadHeap.h>
#include <thread/seadThread.h>
#include "KingSystem/Physics/Cloth/physClothResource.h"
#include "KingSystem/Physics/Ragdoll/physRagdollControllerKeyList.h"
#include "KingSystem/Physics/Ragdoll/physRagdollResource.h"
Expand All @@ -14,6 +16,7 @@
#include "KingSystem/Physics/System/physRayCastRequestMgr.h"
#include "KingSystem/Physics/System/physSensorGroupFilter.h"
#include "KingSystem/Physics/System/physSystemData.h"
#include "KingSystem/Physics/physHavokMemoryAllocator.h"
#include "KingSystem/Resource/resEntryFactory.h"
#include "KingSystem/Resource/resSystem.h"

Expand Down Expand Up @@ -110,4 +113,22 @@ RagdollControllerKeyList* System::getRagdollCtrlKeyList() const {
return mSystemData->getRagdollCtrlKeyList();
}

bool System::isHavokMainHeapOom() const {
return static_cast<f32>(mHavokAllocator->getHeapFreeSize()) /
static_cast<f32>(mHavokAllocator->getHeapSize()) <
0.05f;
}

sead::Heap* System::getPhysicsTempHeap(LowPriority low_priority) const {
if (low_priority != LowPriority::No ||
sead::ThreadMgr::instance()->getCurrentThread()->getPriority() >
sead::Thread::cDefaultPriority)
return mPhysicsTempLowHeap;

if (mPhysicsTempDefaultHeap->getMaxAllocatableSize(8) <= 0x2800)
mPhysicsTempDefaultHeap->dump();

return mPhysicsTempDefaultHeap;
}

} // namespace ksys::phys
7 changes: 5 additions & 2 deletions src/KingSystem/Physics/System/physSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class ContactLayerCollisionInfoGroup;
class ContactMgr;
class ContactPointInfo;
class GroupFilter;
class HavokMemoryAllocator;
class LayerContactPointInfo;
class MaterialTable;
class RayCastForRequest;
Expand Down Expand Up @@ -132,7 +133,8 @@ class System {
// 0x000000710121684c
void decrementWorldUnkCounter(ContactLayerType layer_type);

// 0x0000007101216cec
bool isHavokMainHeapOom() const;

sead::Heap* getPhysicsTempHeap(LowPriority low_priority) const;

private:
Expand All @@ -144,7 +146,8 @@ class System {
float _6c = 1.0;
float _70 = 1.0 / 30.0;
float mTimeFactor{};
u8 _78[0xa8 - 0x78];
HavokMemoryAllocator* mHavokAllocator{};
u8 _80[0xa8 - 0x80];
sead::CriticalSection mCS;
void* _e8{};
void* _f0{};
Expand Down