Jump to content
  • Advertisement
Sign in to follow this  
Triad_prague

Where should I update child's absolute position n rotation

This topic is 2597 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm facing another issues right now, but first let me tell you how my update sequences look like:

-I use fixed timestep
-the update() function is called 60 times a sec
-update() and render is loosely coupled

here's sort of what it's like:

while(lasttime < curtime)
{
update(frameskip);
lasttime += frameskip;
}
render(); //loosely coupled, isn't it?


I calculate all entity's absolute position and rotation in update() function. then I render them in render(). thing is, for example I got a character holding a sword. that means I should do the calculation (hierarchically) in update() function to calculate sword's position and rotation and then I do the calculation again in render() (for the character) this time for rendering. That means I gotta do the calculation twice. the position n rotation update is important because it's used in collision detection step.
I wonder if that's what other games do, but I'm not sure. It seems to inefficient. If you were me, how would you do it guys? please help :(

Share this post


Link to post
Share on other sites
Advertisement
Why do you need to recalculate the positions/rotations in render()?

In my code update() saves world-space transforms for each mesh/object and render() simply reuses the results of last update() cycle.

Share this post


Link to post
Share on other sites

because that means I have to save each bone's absolute matrix per entity, which uses a lot of memory...

It depends on your definition of "lot of"
If you are doing rotations with quaternions, you only have to save 3-component rotation and 3-component translation per bone.
But I'd suggest you not to worry about it, unless it turns out to be bottleneck in final code. Use whatever method is clearer and easier to maintain.

Share this post


Link to post
Share on other sites

I wonder if that's what other games do, but I'm not sure. It seems to inefficient. If you were me, how would you do it guys? please help :(



Just cache the results. The additional memory usage is negligible. If you are using a decent maths library (i.e. SIMD optimised), the computation cost becomes fairly low as well.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!