Add CStateManager::MemoryAllocatorAllocationFailedCallback and RayStaticIntersection

Former-commit-id: c29af5f67d
This commit is contained in:
Henrique Gemignani Passos Lima 2022-11-17 12:12:03 +02:00
parent f585ef383f
commit c8d4b77885
3 changed files with 26 additions and 2 deletions

View File

@ -9,6 +9,7 @@ public:
static void CollectGarbage();
static void PreInitializeAlloc(uint size) { mPreInitializeAlloc += size; }
static void Initialize(uint);
static void WaitForAllDMAsToComplete();
private:
static uint mPreInitializeAlloc;

View File

@ -132,6 +132,7 @@ public:
void AddObject(CEntity*);
TUniqueId AllocateUniqueId();
const rstl::string& HashInstanceName(CInputStream& in);
bool SwapOutAllPossibleMemory();
void BuildNearList(TEntityList& nearList, const CVector3f& pos, const CVector3f& dir, float mag,
const CMaterialFilter&, const CActor*) const;

View File

@ -17,10 +17,17 @@
#include "MetroidPrime/ScriptObjects/CScriptMazeNode.hpp"
#include "Collision/CCollisionPrimitive.hpp"
#include "Collision/CRayCastResult.hpp"
#include "Kyoto/Basics/RAssertDolphin.hpp"
#include "Kyoto/CARAMManager.hpp"
#include "Kyoto/CARAMToken.hpp"
#include "Kyoto/Graphics/CLight.hpp"
#include "MetaRender/CCubeRenderer.hpp"
extern "C" {
void sub_8036ccfc();
}
CStateManager::CStateManager(const rstl::ncrc_ptr< CScriptMailbox >& mailbox,
const rstl::ncrc_ptr< CMapWorldInfo >& mwInfo,
const rstl::ncrc_ptr< CPlayerState >& playerState,
@ -311,10 +318,25 @@ TUniqueId CStateManager::AllocateUniqueId() {
return TUniqueId(x4_objectIndexArray[ourIndex], ourIndex);
}
CRayCastResult CStateManager::RayStaticIntersection(const CVector3f& pos, const CVector3f& dir,
float length,
const CMaterialFilter& filter) const {
return CGameCollision::RayStaticIntersection(*this, pos, dir, length, filter);
}
void CStateManager::RemoveObject(TUniqueId id) {}
void CStateManager::ClearGraveyard() {}
void CStateManager::RendererDrawCallback(const void*, const void*, int) {}
const bool CStateManager::MemoryAllocatorAllocationFailedCallback(const void* obj, unsigned int) {
return static_cast< CStateManager* >(const_cast< void* >(obj))->SwapOutAllPossibleMemory();
}
const bool CStateManager::MemoryAllocatorAllocationFailedCallback(const void*, unsigned int) {}
bool CStateManager::SwapOutAllPossibleMemory() {
sub_8036ccfc();
CARAMManager::WaitForAllDMAsToComplete();
CARAMToken::UpdateAllDMAs();
return true;
}
void CStateManager::RendererDrawCallback(const void*, const void*, int) {}