Spatial's setLocalXXX() altering it's world transform

Hi

Just recently I came across jME and I get very excited to finally have an opportunity to get a deep look into how game graphics are rendered in general and maybe prototype something small myself. Because for me Java is really only language I am comfortable with - it caught me the day I tried it and since then (years ago) I’ve stuck with it exclusively.



Now after I’ve read some materials about mathematics used in 3d graphics (essential to have a clue what’s going on in the code) I am looking at the scene code itself to see what’s going on inside (jME 3 alpha 4).



Looking at how changes of spatial’s transform properties are handled, one thing bugs me. When altering spatial’s local transform in any way - setLocalTranslation / setLocalRotation() / setLocalScale() methods - there’s always a line that also copies new values (that time already in local transform) into world transform.



As I see it, this should be totally unnecessary, since world transform will still be recalculated next time it is accessed (e.g.call to getWorldXXX() or updateGeometricState() ) in updateWorldTransforms() - if the spatial has no parent, local transform is copied to world transform, if it has parent, there’s also combining with the parents world transform that was updated in advance (in checkDoTransformUpdate() ).



I just miss the reasoning behind copying values that still get overwritten later. It’s not a big deal. It’s just that I enjoy figuring out what someone else’s code does. And since there are very few situations I am unable to see the purpose, it strikes me even harder when that happens ^^.



Is there anyone who can see through that ? Or is it really useless ?

Thx

I guess it can be taken out now, it was from the time when the updateWorldTransforms() was only called when updateGeometricState() was running through. As you say, thats now happening in every situation one could get access to the world transform so its probably useless… Still, the performance advantage will probably go towards zero, copying values from one memory location to another is something a computer can do millions of times even in a millisecond :wink:

Nah, sure there will be no benefit performance-wise. I was just afraid I am missing something.