cradle
19-04-2007 13:35:23
Hello all, a small query regarding ribbon trails, time steps, and bad performance.
Usually, if you have a ribbon trail, you attach it to a node, and call the node's updatePosition once per frame and that updates the ribbon trail. However, if your display is decoupled from the time between frames, and is instead coupled to the physics engine, you need the trail to be updated each physics step (using the step size) instead of each frame update (using time between frames) as using the frame time results in trails with incorrect lengths. I solved this problem with the following: (pseudo-code-ified)
So, my problem? This is giving me a massive performance hit! Using just eyeballing, having more than 30 or so ribbon trails reduces the framerate to below 1 fps, and using profiling I can identify that (during ribbon trail intensive scenes) the postStep method is second only to 'go()' in terms of time spent in the method.
This can be contrasted to the following:
Which when used results in playable framerates with over 70 ribbon trails, and the frameEnded method not showing up in the top 30 methods in profiling (albeit with the trails being completely the wrong length).
Is there a simple solution to this? Have I missed some ribbon-trail magic that would do this for me faster? Any ideas on how to make it faster?
- Glenn
Usually, if you have a ribbon trail, you attach it to a node, and call the node's updatePosition once per frame and that updates the ribbon trail. However, if your display is decoupled from the time between frames, and is instead coupled to the physics engine, you need the trail to be updated each physics step (using the step size) instead of each frame update (using time between frames) as using the frame time results in trails with incorrect lengths. I solved this problem with the following: (pseudo-code-ified)
postStep():
trail._timeUpdate(stepSize)
node.setPosition(body.getPosition())
trail.nodeUpdated(node)
So, my problem? This is giving me a massive performance hit! Using just eyeballing, having more than 30 or so ribbon trails reduces the framerate to below 1 fps, and using profiling I can identify that (during ribbon trail intensive scenes) the postStep method is second only to 'go()' in terms of time spent in the method.
This can be contrasted to the following:
frameEnded():
node.setPosition(body.getPosition())
Which when used results in playable framerates with over 70 ribbon trails, and the frameEnded method not showing up in the top 30 methods in profiling (albeit with the trails being completely the wrong length).
Is there a simple solution to this? Have I missed some ribbon-trail magic that would do this for me faster? Any ideas on how to make it faster?
- Glenn