Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Enhanced Animations - Setting Animation Speed Kills Performance

Author
Message
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 20th May 2013 07:16 Edited at: 20th May 2013 07:16
I am writing this to hopefully illicit some helpful tips.
I have been transitioning from built-in animation to the Enhanced Animation addon. I have noticed an extreme operating performance drop.

EnAn_oacSetLimbPlayAnimSpeed oacID, Limb, Speed#, ExChild
This command is taking a very long time to execute. Every loop I was setting the animation speed of every game character. So when I switched to Enhanced Animations, I continued to do this even though you can play around with timing with the EnAn_oacUpdate oacID, Time instead.

I set it to include child limbs in a way that would control separately the upper and lower body. Then I tried to manually control speed on each limb thinking it would help. But it only made the whole thing 5 times slower.



Part of the issue is that characters can walk at differing speeds from a slow crawl to speed walking before running animation is used. So it makes sense to tweak the speed every game loop. Now the legs might be walking but the upper body might be shooting, walking, etc. So controlling the entire objects overall speed won't cut it.

I've got in some cases 100 people walking around and doing various animations across game levels. So it ends up taking anywhere between 2-20ms to process these speeds.

Character models have about 20 bones/limbs. I find myself having to creatively find automated methods for the mathematically setting the speed as least often as possible. Not just for efficiency's sake, but because the situation is so dire.

Setting animation speed with the built-in system is lighting fast. I'm not sure what it could possibly be doing here to be so slow. It's not looking up the next frame, it needs the timing value and that's only given to the EnAn_oacUpdate command.

Any info would be helpful, Thanks.

Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 20th May 2013 23:01
I continued to work on this after I posted.

I rewrote the game to make use of EnAn_AnimSetPlaySpeed( AnimID, Speed# ) and EnAn_SetDefaultPlaySpeed( Speed# ). These establish default animation speeds for specific animations.

Most of the animations had only a single specific play speed so I gave them all default speeds when loading them. This removed the need to set a custom speed on everything but walking/running/crawling animations.

Then I recognized that all the ai have specific speeds for walking etc. They vary but everyone sticks to their personal speed. So I rigged the speed setting code to abort if the desired speed is already set.

This then reduced the use of EnAn_oacSetLimbPlayAnimSpeed oacID, Limb, Speed#, ExChild to the players movement, and when ever anyone else starts to walk/run/crawl on their first frame. Technically the player isn't an exception, but analog controls make it impossible to keep at the exact same speed.


This reduced the operating time from about 20ms to around 0.1ms. It doesn't solve the real problem, but I managed to work around it.

Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 21st May 2013 01:33
It's rather late here so maybe I'm not getting the question correctly, sorry if that is the case.

Anyway, you don't have to call those commands in every loop cycle, just when you actually need to change the speed.
I agree that I don't really get why they would be that slow though; supposedly they should just set some internal value that is used as a multiplayer in oac_update().


"Why do programmers get Halloween and Christmas mixed up?"
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 21st May 2013 09:59
Yeah managed to figure that out. Added default speeds for all animations so I didn't need to keep setting them. Still the players walking speed needs to be set each frame according to analog input, since the player can control walking/running speed.

Login to post a reply

Server time is: 2026-07-07 09:51:43
Your offset time is: 2026-07-07 09:51:43