Release mesh texture references on destruction

This commit is contained in:
Leonardo Zide committed 2026-09-23 11:09:15 -07:00
1 parent 197a3d18e6
commit 3e376ddb84
3 files changed
+10 -12

No files matched your search

+9
View File
@@ -21,7 +21,16 @@ lcMesh::~lcMesh()
free(mVertexData);
free(mIndexData);
for (int LodIdx = 0; LodIdx < LC_NUM_MESH_LODS; LodIdx++)
{
for (int SectionIdx = 0; SectionIdx < mLods[LodIdx].NumSections; SectionIdx++)
{
lcTexture* Texture = mLods[LodIdx].Sections[SectionIdx].Texture;
if (Texture)
Texture->Release();
}
delete[] mLods[LodIdx].Sections;
}
}
void lcMesh::Create(quint16(&NumSections)[LC_NUM_MESH_LODS], int VertexCount, int TexturedVertexCount, int ConditionalVertexCount, int IndexCount)
+1 -1
View File
@@ -38,7 +38,7 @@ struct lcMeshSection
int DrawOffset; // Index-buffer byte offset, or first conditional vertex.
int DrawCount; // Index count, or conditional vertex count.
lcMeshPrimitiveType PrimitiveType;
lcTexture* Texture;
lcTexture* Texture = nullptr;
lcBoundingBox BoundingBox;
float Radius;
};
-11
View File
@@ -167,17 +167,6 @@ void PieceInfo::ReleaseMesh()
{
if (mMesh)
{
for (int LodIdx = 0; LodIdx < LC_NUM_MESH_LODS; LodIdx++)
{
for (int SectionIdx = 0; SectionIdx < mMesh->mLods[LodIdx].NumSections; SectionIdx++)
{
lcMeshSection& Section = mMesh->mLods[LodIdx].Sections[SectionIdx];
if (Section.Texture)
Section.Texture->Release();
}
}
delete mMesh;
mMesh = nullptr;
}