- Modificato
[AS3 Starling] Disable Spine Animator Component
I doing some tests between game engines, I've been working on a test in AS3/Starling using the Starling runtime. On a stage of 1920x2160/FrameRate = 60, I've got 3 static graphics (1920 x 1080), a test button, and 2 Spine characters, which I place on the stage. One of the Spine characters I duplicate 288 times and place across the stage.
I've have the std memory/gpu memory low and the draw calls down to 6. However, the FPS is not as good as it could be. I started out between 7 and 15 FPS. With some help of the fine folks over at the Starling forums, I've achieved up to the mid 20's.
An excellent 'WiseOwl' over there mentioned "...in Unity I can disable the spine animator component. That stops the Update (AS3- OnEnterFrame).. I don't know if that's available in the AS3 spine runtime. That helps with the FPS quite a bit.".
My question : is there something similar in the AS3/Starling runtime? If so, where would be a good place to look?
UPDATE : I saw an old post http://esotericsoftware.com/forum/Starling-AS3-Performance-Question-8706 where BadLogic had opened an issue https://github.com/EsotericSoftware/spine-runtimes/issues/918 however BadLogic mentions
Decided against this. It can be easily handled in user code without any downsides.
This seems like my issue above, so may I ask what the user code is to handle this? All advice/help is much appreciated!
That issue is actually only sort of related. It's about only updating the internal MeshBatches when things have changed. This is essentially undecidable without putting in more work than the MeshBatch updates themselves require.
What I referred to as "can be done in user code" boils down to writing a custom class based on this one: spine-runtimes/SkeletonAnimation.as at 3.7
It derrives from SkeletonSprite, which does the heavy lifting. Your custom implementation of SkeletonAnimation
can then decide whether to update the world transform and whether to require a new frame to be rendered based on your game state or visibility checks.
FWIW 288 instances of a skeleton is quite excessive. I assume not all of them are visible on screen?
@badlogic - that's it! I did as suggested: extended the SkeletonAnimation class, added a boolean, and start/stopped the character animation as required. The FPS then went up to acceptable levels on the target machine. ('mistergreen' over on the Starling forums also replied with the same suggestion and an example of some C# code!)
As I mentioned on the Starling forum : Using a machine with a good processor and a GPU, the FPS issues with minimal. However my target machine has neither - so this is a great solution I can work around.
Responding to your "FWIW" - management has requested a possible "100 to 150" characters on the screen animating at one time. It's my habit to always double their requests (because they will eventually do that!). For most of the time, a max of 25 to 50 characters would be the norm - but must plan for worst case.
Again, thank you for your help/advice!