perf(gltf): add skinning cache — skip re-skinning when pose is unchanged

This commit is contained in:
NotEvil
2026-04-17 01:45:02 +02:00
parent c0c53f9504
commit 17269f51f8
3 changed files with 237 additions and 0 deletions

View File

@@ -96,6 +96,7 @@ public final class GltfClientSetup {
ProfilerFiller profiler
) {
GltfCache.clearCache();
GltfSkinCache.clearAll();
GltfAnimationApplier.invalidateCache();
GltfMeshRenderer.clearRenderTypeCache();
// Reload context GLB animations from resource packs FIRST,
@@ -120,4 +121,24 @@ public final class GltfClientSetup {
}
}
/**
* FORGE bus event subscribers for entity lifecycle cleanup.
* Removes skin cache entries when entities leave the level, preventing memory leaks.
*/
@Mod.EventBusSubscriber(
modid = "tiedup",
bus = Mod.EventBusSubscriber.Bus.FORGE,
value = Dist.CLIENT
)
public static class ForgeBusEvents {
@SubscribeEvent
public static void onEntityLeaveLevel(
net.minecraftforge.event.entity.EntityLeaveLevelEvent event
) {
if (event.getLevel().isClientSide()) {
GltfSkinCache.removeEntity(event.getEntity().getId());
}
}
}
}