setLocalTranslation also sets worldTranslation to localTranslation

Hi all,



whenever one uses setLocal(Translation|Rotation|Scale), the world (translation|rotation|scale) is also set to the new >>local<< value. To me it doesn't make any sense at all, and it basically means that before reading world data you must be sure that nothing has called a setLocal* method or you have to call updateWorldVectors() all the time.

I had a look at the jme code and I can't see where setting world data to current local values is required.

I also ran a test with the setLocal* methods having their overwriting-world-data-behavior commented out, and I couldn't notice any difference – except that my code that relies on proper world data now worked.



So, can someone enlighten me why this behavior exists - or can it be removed?



Thanx for any help  :smiley:

This kind of problem is allivated easily when "refresh flags" are used. Both Ardor3D and jME3 implement them. Then it becomes a simple check of whether or not the world transform is "dirty" and if so, it is updated properly based on the parent's transform. jME1/2 does not use refresh flags, instead, every frame the scene graph must be updated which also updates the world transforms.

The only way I can see how you can solve your problem is to call updateWorldTransforms() on the node before using getWorldTranslation().

I also ran a test with the setLocal* methods having their overwriting-world-data-behavior commented out, and I couldn't notice any difference -- except that my code that relies on proper world data now worked.

That's not possible. Changing the local transformation of a node also changes its world transform.

Thx for the quick reply,

but I'm afraid my issue is not that I have to updateWorldVectors() once per frame - I already do that (althougl I'd really like to see this "refresh flags" feature iin jme2).



when I call, say, setLocalTranslation, which does this:


public void setLocalTranslation(Vector3f localTranslation) {
        this.localTranslation = localTranslation;
        this.worldTranslation.set(this.localTranslation);
    }



then due to 


this.worldTranslation.set(this.localTranslation);


when I call getWorldTranslation() afterwards within the same frame, I'll get the local translation of the spatial.
how can that be correct?
When setLocalTranslation() would not overwrite worldTranslation, I'd know at least that the world data is maybe old, but it is still "world" data - so I could decide to use the world data from the beginning of the frame, but now, whenever setLocalTranslation is called, the world data becomes wrong...

any hints on this issue maybe?
That's not possible. Changing the local transformation of a node also changes its world transform

it does, but the world transform is wrong until the next updateWorldTransforms()

Maybe jme should not blindly set world to local, but either compute the world translation when doing setLocalTranslation() or not set it at all, like user123 suggested.