Help to speed up skeleton animations


(Nirvan) #1

Hi all

I finished application for 2D skeletonal animations and I am under implementating this to FP. But now I see there is a problem. Not in calculations but in render time. All sprites are rotated, and origins are very important. Rotating sprites slow down FP as hell and when I want to use preRotation it’s faster but in preRotation sprites are rotated to center origin and it’s very bad. Even if preRotation is scaled ( -1 ) it slows down very much.

There are files: http://www.mediafire.com/?feourhut5czgzhk

There are files (previous): http://www.mediafire.com/?1dmpp0t5vg5pajl

Almost all done ( I must repair unBind function and maybe a little more optimize code but without it I see it is fast enough ). If you will use preRotation go to TBAskeleton, and on the end of update function change sprite[i].graphic.angle = ___a[i]; to frameAngle.

And there you can preview swf: http://shadowsgames.net/tests/TBAforFP.swf

Use arrows to move, hold down arrow to “dance” animation. Press space to hit animation. Press mouse to add new player.

Can you guys help me to find solution for it? There was a lot of work to this application and I was making it especially for FP. Thanks!


(azrafe7) #2

Hey dude, that looks awesome by the way! :wink:

I’ll look into the code tomorrow if I have time, and be sure I’ll get back to you if I find a way to help.

Thanks for the efforts so far!


(azrafe7) #3

Took a brief look at the code and…

Don’t know if this is right, but it seems that PreRotation autocalcs the pivot to be the center of the Image (the most common case in which a user would use it, but also what makes your “strangeRobot” look messy) so…

:pray: RaptorNonFuit, EGO HIS VERBIS TE VOCO!?

Just trying to summon @NotARaptor about PreRotation (I might be totally wrong, but I seem to recall that HE was the one behind that class - damn the things we’ve lost on the old site! -, although I’m not so sure of it as of now). Hope he will provide some more insights nonetheless.

Don’t mind the evocation, right pal?! :grimacing:

EDIT: Also… mirroring is an issue to look carefully into.


(JP Mortiboys) #4

qui me a somno excitantur?

Erm, no - I didn’t have anything to do with the PreRotation class; I did do a post of rotated masks for collisions though.

I can take a look at the PreRotation class and try and sort out the problem if you like though, when I get some time.


(Nirvan) #5

It’s a shame because there will be needed rotate every one degrees for animation to look very smooth. If preRotation will be loaded with 360 images I think memory usage will be very big.

Also I tested skeletons speed without rendering. 750skeletons = 30 fps :grin: update 28ms 350 skeletons = 60fps update 13ms, but even more, update calculations should be disabled when skeleton if out of view, so it’s very fast. I thought if this will be problem but I see that not at all. So I can add more data, like additional bones position changing or scalling.

Edit: I added animaitions layering to separate animate bones: http://shadowsgames.net/tests/TBAforFP2.swf Now if you attack during running you will not stop. But I kept class without it, it’s TBAskeletonSimple

Files: http://www.mediafire.com/?feourhut5czgzhk


Trivial Bone Animator
(kgbkgb) #6

So I took a look at the PreRotation.as and lines 48-50 seem to deal with origin and it seems it generates a image strip after centering the origin point. So maybe you can modify this class to add a constructor parameter to include an option where you can specify a point in the image to rotate about.

Or you could simply copy the class to like PreRotationNirvan.as and change lines 48-50 values to coincide with where you’d like the image to be rotated about.

At-least that’s what i think it does, i could be totally wrong.

–Also-- I found that if you constantly tap fast a button that plays animation the animation plays but you tick it everytime you tap the key.


(Abel Toy) #7

The problem with a non-centered origin is you have to keep in mind the size of the prerrotated buffer will have to be larger OR offset its x and y position when rotating accordingly, which would be the preferred method.


(JP Mortiboys) #8

TestPreRotation.swf(88.3 KB)


(JP Mortiboys) #9

While this seems to work perfectly when using PreRotation instead of Image (with frameAngle instead of angle for rotating), plugging it in naively to the skeletal animation system doesn’t seem to work. Hmmmmm.

In any case, rendering is definitely going to be a bottleneck if you want 100+ animated skeletons. I wonder if using drawTriangles(), combined with a bitmap fill and texture-atlas style graphic would be faster… this warrants a little trip to the testing room.


(Nirvan) #10

Sorry for my absence but now I working on few more things for animator ( bezier nurbs, simple IK etc. ) and I think I will a little change TBAskeleton class, when I finish all features for aniamtor I will return here ;). Thanks for support anyway


(Abel Toy) #11

Hiyaaa @NotARaptor, happy to see you around.

I replied to the push request on your PreRotation code! It’s about the memory footprint of the origins array.