feat(model): implement CM2Shared::Release

This commit is contained in:
fallenoak 2025-10-29 14:52:25 -05:00
parent b370d86f7d
commit 12a7752a57
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
2 changed files with 19 additions and 4 deletions

View File

@ -53,7 +53,9 @@ void CM2Shared::SkinProfileLoadedCallback(void* arg) {
} }
void CM2Shared::AddRef() { void CM2Shared::AddRef() {
// TODO // TODO free list management etc
this->m_refCount++;
} }
int32_t CM2Shared::CallbackWhenLoaded(CM2Model* model) { int32_t CM2Shared::CallbackWhenLoaded(CM2Model* model) {
@ -595,8 +597,20 @@ int32_t CM2Shared::LoadSkinProfile(uint32_t profile) {
return 1; return 1;
} }
void CM2Shared::Release() { uint32_t CM2Shared::Release() {
// TODO STORM_ASSERT(this->m_refCount > 0);
this->m_refCount--;
if (this->m_refCount > 0) {
return this->m_refCount;
}
// TODO free list management etc
delete this;
return 0;
} }
int32_t CM2Shared::SetIndices() { int32_t CM2Shared::SetIndices() {

View File

@ -26,6 +26,7 @@ class CM2Shared {
static void SkinProfileLoadedCallback(void* param); static void SkinProfileLoadedCallback(void* param);
// Member variables // Member variables
uint32_t m_refCount = 1;
CM2Cache* m_cache; CM2Cache* m_cache;
uint32_t m_m2DataLoaded : 1; uint32_t m_m2DataLoaded : 1;
uint32_t m_skinProfileLoaded : 1; uint32_t m_skinProfileLoaded : 1;
@ -73,7 +74,7 @@ class CM2Shared {
int32_t InitializeSkinProfile(); int32_t InitializeSkinProfile();
int32_t Load(SFile* file, int32_t a3, CAaBox* a4); int32_t Load(SFile* file, int32_t a3, CAaBox* a4);
int32_t LoadSkinProfile(uint32_t profile); int32_t LoadSkinProfile(uint32_t profile);
void Release(); uint32_t Release();
int32_t SetIndices(); int32_t SetIndices();
int32_t SetVertices(uint32_t a2); int32_t SetVertices(uint32_t a2);
void SubstituteSimpleShaders(); void SubstituteSimpleShaders();