Jump to content
  • Advertisement
Sign in to follow this  
K_I_L_E_R

Scenegraph state changes, my strange way of dealing with them

This topic is 4503 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

Most people believe I'm weird. Moreso the teacher when I handed in my assignment and told him that I'm managing matrix state changes without saving the state of the matrix in question (IE: no push/pop). Instead I use loadMatrix/multMatrix for all animation and it works perfectly, even under complex scenes. My question is whether it's common to forego the push/pop matrix stacks in favour of loading/multiplying? Some of the techniques I use within my scenegraph are unorthodox. This isn't the first nor last I created my own method which is considered strange by everyone except myself but it is a method in which I'm confused as to whether it's done commonly or is it just me behaving badly. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
the methods loadMatrix and multMatrix are in my point of view not so performant like just push/pop the matrix but if you havnt problems with the speed at all, there should be no problem using this instead...

Share this post


Link to post
Share on other sites
If I understand this correctly, you do:

loadMatrix(car)
draw car body
multMatrix(wheel1)
draw wheel
loadMatrix(car)
multMatrix(wheel2)
draw wheel
...etc

instead of the typical:

loadMatrix(car)
draw car body
pushMatrix
multMatrix(wheel1)
draw wheel
popMatrix
pushMatrix
multMatrix(wheel2)
draw wheel
popMatrix
...etc

If we cancel out the common parts, the net effect is you are substituting the push/pop combo for a loadMatrix. Push/pop have no data parameters to pass to the video card, so they are faster. If you have a race game with five cars with 4 wheels each, you would be sending 15 unnecessary matrices for every frame. That is why your method is not done commonly.

Share this post


Link to post
Share on other sites
The way you handle the matrices depends on the way you traverse the scenegraph.
If you just traverse it from top to bottom, push/pop can save you a bit of processing (very little), if you sort your render commands by shader / texture / back to front for blended one, etc.. push/pop are not that usefull.

Anyway, if you manage cleanly your matrice stack on the CPU, I don't think that you will get any performance boost with push/pop.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!