mirror of
https://github.com/whoahq/whoa.git
synced 2026-02-01 16:22:45 +03:00
feat(model): implement CM2Model::Release
This commit is contained in:
parent
fd7b6fda74
commit
e055543167
@ -5,12 +5,13 @@
|
|||||||
#include "model/CM2Shared.hpp"
|
#include "model/CM2Shared.hpp"
|
||||||
#include "model/M2Animate.hpp"
|
#include "model/M2Animate.hpp"
|
||||||
#include "model/M2Data.hpp"
|
#include "model/M2Data.hpp"
|
||||||
|
#include "model/M2Internal.hpp"
|
||||||
#include "model/M2Model.hpp"
|
#include "model/M2Model.hpp"
|
||||||
#include <cmath>
|
|
||||||
#include <new>
|
|
||||||
#include <common/DataMgr.hpp>
|
#include <common/DataMgr.hpp>
|
||||||
#include <common/ObjectAlloc.hpp>
|
#include <common/ObjectAlloc.hpp>
|
||||||
#include <tempest/Math.hpp>
|
#include <tempest/Math.hpp>
|
||||||
|
#include <cmath>
|
||||||
|
#include <new>
|
||||||
|
|
||||||
// Alignment helpers
|
// Alignment helpers
|
||||||
#define ALIGN(addr, type) ((addr + alignof(type) - 1) & ~(alignof(type) - 1))
|
#define ALIGN(addr, type) ((addr + alignof(type) - 1) & ~(alignof(type) - 1))
|
||||||
@ -25,13 +26,11 @@ uint32_t CM2Model::s_skinProfileBoneCountMax[] = { 256, 64, 53, 21 };
|
|||||||
|
|
||||||
CM2Model* CM2Model::AllocModel(uint32_t* heapId) {
|
CM2Model* CM2Model::AllocModel(uint32_t* heapId) {
|
||||||
uint32_t memHandle;
|
uint32_t memHandle;
|
||||||
void* object = nullptr;
|
void* mem = nullptr;
|
||||||
|
|
||||||
if (ObjectAlloc(*heapId, &memHandle, &object, 0)) {
|
if (ObjectAlloc(*heapId, &memHandle, &mem, false)) {
|
||||||
CM2Model* model = new (object) CM2Model();
|
auto model = new (mem) CM2Model();
|
||||||
|
model->m_memHandle = memHandle;
|
||||||
// TODO
|
|
||||||
// model->uint2E8 = memHandle;
|
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
@ -1420,8 +1419,19 @@ void CM2Model::ProcessCallbacksRecursive() {
|
|||||||
this->Release();
|
this->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CM2Model::Release() {
|
uint32_t CM2Model::Release() {
|
||||||
// TODO
|
STORM_ASSERT(this->m_refCount > 0);
|
||||||
|
|
||||||
|
this->m_refCount--;
|
||||||
|
|
||||||
|
if (this->m_refCount > 0) {
|
||||||
|
return this->m_refCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->~CM2Model();
|
||||||
|
ObjectFree(*g_modelPool, this->m_memHandle);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CM2Model::ReplaceTexture(uint32_t textureId, HTEXTURE texture) {
|
void CM2Model::ReplaceTexture(uint32_t textureId, HTEXTURE texture) {
|
||||||
|
|||||||
@ -116,6 +116,7 @@ class CM2Model {
|
|||||||
void* m_lightingArg = nullptr;
|
void* m_lightingArg = nullptr;
|
||||||
M2ModelCamera* m_cameras = nullptr;
|
M2ModelCamera* m_cameras = nullptr;
|
||||||
void* ptr2D0 = nullptr;
|
void* ptr2D0 = nullptr;
|
||||||
|
uint32_t m_memHandle;
|
||||||
|
|
||||||
// Member functions
|
// Member functions
|
||||||
CM2Model()
|
CM2Model()
|
||||||
@ -170,7 +171,7 @@ class CM2Model {
|
|||||||
void LinkToCallbackListTail();
|
void LinkToCallbackListTail();
|
||||||
int32_t ProcessCallbacks();
|
int32_t ProcessCallbacks();
|
||||||
void ProcessCallbacksRecursive();
|
void ProcessCallbacksRecursive();
|
||||||
void Release();
|
uint32_t Release();
|
||||||
void ReplaceTexture(uint32_t textureId, HTEXTURE texture);
|
void ReplaceTexture(uint32_t textureId, HTEXTURE texture);
|
||||||
void SetAnimating(int32_t animating);
|
void SetAnimating(int32_t animating);
|
||||||
void SetBoneSequence(uint32_t boneId, uint32_t sequenceId, uint32_t a4, uint32_t time, float a6, int32_t a7, int32_t a8);
|
void SetBoneSequence(uint32_t boneId, uint32_t sequenceId, uint32_t a4, uint32_t time, float a6, int32_t a7, int32_t a8);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user