From e37f768a8d0b8b706a319c8246753d86c8890f23 Mon Sep 17 00:00:00 2001 From: fallenoak Date: Sat, 3 Jan 2026 20:35:42 -0600 Subject: [PATCH] feat(model): add CM2Model::FreeExternalResources --- src/model/CM2Model.cpp | 23 +++++++++++++++++++++-- src/model/CM2Model.hpp | 1 + 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/model/CM2Model.cpp b/src/model/CM2Model.cpp index 0e28a07..6f081f8 100644 --- a/src/model/CM2Model.cpp +++ b/src/model/CM2Model.cpp @@ -95,8 +95,7 @@ CM2Model::~CM2Model() { this->DetachFromScene(); if (this->m_shared) { - // TODO - + this->FreeExternalResources(); this->FreeInternalResources(); this->m_shared->Release(); @@ -1023,6 +1022,26 @@ void CM2Model::FindKey(M2ModelBoneSeq* sequence, const M2TrackBase& track, uint3 } } +void CM2Model::FreeExternalResources() { + if (!this->m_loaded) { + return; + } + + // TODO + + if (this->m_textures) { + for (int32_t i = 0; i < this->m_shared->m_data->textures.Count(); i++) { + auto texture = this->m_textures[i]; + + if (texture) { + HandleClose(texture); + } + } + } + + // TODO +} + void CM2Model::FreeInternalResources() { if (!this->m_internalResources) { return; diff --git a/src/model/CM2Model.hpp b/src/model/CM2Model.hpp index e4ca9c2..821b498 100644 --- a/src/model/CM2Model.hpp +++ b/src/model/CM2Model.hpp @@ -165,6 +165,7 @@ class CM2Model { void DetachFromParent(); void DetachFromScene(); void FindKey(M2ModelBoneSeq* sequence, const M2TrackBase& track, uint32_t& currentKey, uint32_t& nextKey, float& ratio); + void FreeExternalResources(); void FreeInternalResources(); C44Matrix GetAttachmentWorldTransform(uint32_t id); CAaBox& GetBoundingBox(CAaBox& bounds);