For the Construct 3 Spine plugin, it renders a skeleton instance to a texture and the texture is then used by C3 to display the rendered Spine instance as a Sprite.
One performance enhancement I am looking at implementing is having Spine only rendering to texture when the skeleton instance is still animating. So, for example, if the instance was walking, the render would be continuous through the walk (e.g. looping animation). However if the instance was doing a sit animation, it would stop after the animation is complete, at this point we could stop rendering to texture and just the last render of the animation as a texture until something changes (e.g. new animation applied.)
What is the best way to check that all tracks of animations are complete on an instance (or that all animations have been completed?) We may need to render one last time at this point, but then none after that.
I was initially thinking about using listeners for complete on each active track and checking that complete is done for all active tracks and that none of the tracks are looping. However, I will need to do some boo keeping on which tracks are active, if their animations are changed, if they completed, etc.
Is there a simpler way to know that all animations on all tracks are complete, so I can stop rendering the skeleton to texture? Perhaps using isComplete() along with a check on if looping is enabled?
Thanks in advance for any comment or other suggested directions to look at.
ページ 1 / 1
MikalDev
1 year ago
- MikalDev
- 記事: 70
MikalDev
Thanks Nate, I'll check it out.
---
Hmm, just monitoring tracks to all be null does not seem to give me the data I want. I also want to check the case that an animation has played through to end and is no longer playing. Right now, a track entry is still included (not null), even though the animation is finished and has played through.
I might try going through all the available track entries and if they are not null, I will check if they are looping and isComplete(), if none are looping and all are set to isComplete(), then there is no render needed (I might also check if timescale is 0, if I start using that to pause animations.)
---
Hmm, just monitoring tracks to all be null does not seem to give me the data I want. I also want to check the case that an animation has played through to end and is no longer playing. Right now, a track entry is still included (not null), even though the animation is finished and has played through.
I might try going through all the available track entries and if they are not null, I will check if they are looping and isComplete(), if none are looping and all are set to isComplete(), then there is no render needed (I might also check if timescale is 0, if I start using that to pause animations.)
1 year ago
- MikalDev
- 記事: 70
Nate
An animation is not done playing until it is cleared from its track. That only happens if the user clears the track explicitly (eg with AnimationState
You could assume an animation is no longer needed if non-looping and TrackEntry
---
To be clear, you could cease rendering if: all tracks are null OR (non-looping AND complete)
clearTrack
) or TrackEntry trackEnd
is reached. By default trackEnd
will never be reached, so animations will continue being applied (looping or not). trackEnd
could be set to Animation duration
so a non-looping animation is cleared when it reaches the animation duration, but that will result in snapping to the setup pose. It's more common to use AnimationState setEmptyAnimation
, which clears the track via trackEnd
when finished.You could assume an animation is no longer needed if non-looping and TrackEntry
complete
is true, but this may not always be the case. For example, maybe the animation is applied so afterward bones can be adjusted programmatically. The only time to be sure you can cease rendering is if all the tracks are empty. For your use case the assumption is probably fine, though you might consider having a way to disable it. ---
To be clear, you could cease rendering if: all tracks are null OR (non-looping AND complete)
1 year ago
-
Nate - 記事: 11795
MikalDev
Thanks Nate for the details, part of the issue is that I am trying to hide some of the complexity from the C3 devs using the C3 Spine plugin, so they don't set other animations after the current one is complete (e.g. they don't set EmptyAnimation after a non looping animation is complete). I know what you mean about adjusting programmatically, it probably is a good idea to make this an option controlled per instance (e.g. if I add a function to the C3 plugin to allow the 'aim' bone to be moved in the Spineboy Aim example, that animation is not looping and will complete, but I still want render to occur as the aim bone is moved.)
1 year ago
- MikalDev
- 記事: 70
Mark topic unread
• ページ 1 / 1
Return to Runtimes
- All times are UTC