perf(gltf): add skinning cache — skip re-skinning when pose is unchanged
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user