mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 07:40:14 +00:00
Fix composite cache clearing to not delete NPC textures
clearCompositeCache() now only clears the lookup map without deleting GPU textures, preventing NPC and other instance textures from being accidentally destroyed during player equipment changes.
This commit is contained in:
parent
dcd6c488fa
commit
4190cb796f
1 changed files with 3 additions and 16 deletions
|
|
@ -576,22 +576,9 @@ GLuint CharacterRenderer::compositeTextures(const std::vector<std::string>& laye
|
|||
}
|
||||
|
||||
void CharacterRenderer::clearCompositeCache() {
|
||||
// Delete GPU textures that aren't referenced by any model's texture slots
|
||||
for (auto& [key, texId] : compositeCache_) {
|
||||
if (texId && texId != whiteTexture) {
|
||||
// Check if any model still references this texture
|
||||
bool inUse = false;
|
||||
for (const auto& [mid, gm] : models) {
|
||||
for (GLuint tid : gm.textureIds) {
|
||||
if (tid == texId) { inUse = true; break; }
|
||||
}
|
||||
if (inUse) break;
|
||||
}
|
||||
if (!inUse) {
|
||||
glDeleteTextures(1, &texId);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Just clear the lookup map so next compositeWithRegions() creates fresh textures.
|
||||
// Don't delete GPU textures — they may still be referenced by models or instances.
|
||||
// Orphaned textures will be cleaned up when their model/instance is destroyed.
|
||||
compositeCache_.clear();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue