I added a new example showcasing various engine features you can enable to optimize how animations are processed. It is present in examples/animations/optimize_animations_test subdirectory of the engine. Enjoy!
Make sure to make a release (not debug) build to experiment with performance. On my system, I can make FPS between 15 and 60 (which is maximum with vsync=on for my system), depending on the configuration of the switches. So there’s a nice spectrum to show how various options improve the speed.
Read the API reference of the linked options for details — what these things do, when do you want to enable them (and when not):
-
OptimizeExtensiveTransformations
andInternalFastTransformUpdate
— both especially useful in case of nested transformation hierarchies when many transformations change every frame. Like typical animations done using skeleton, in Spine or glTF. In the future, I hope to be able to actually remove both these flags, and have their respective optimizations always “on” and universal (always beneficial, never losing any functionality)I have also fixed
OptimizeExtensiveTransformations
along the way of preparing this — it had a long-standing bug that prevented from using it. Now it’s all good. -
TCastleViewport.DynamicBatching
also helps, though it is really a rendering optimization (doesn’t affect how animations are processed). -
TCastleSceneCore.AnimateOnlyWhenVisible
does pretty much does what it says :), it only optimizes animations if you look away from them. The invisible animations are not updated, saving time. You can experiment with this by looking away (press right mouse button to activate mouse look in the example). -
TCastleSceneCore.AnimateSkipTicks
is a “brutal” optimization — if you set it to something > 0 then animation just doesn’t update every frame. In this example you can toggle it between 0 (don’t skip) and 1 (skip every other frame). You can experiment with setting it to something even larger, like 2, for even more performance but sacrificing quality.
Start the discussion at Castle Game Engine Forum