[odejava] References instead of copies

Hi there,

Can’t someone (Will) make PlaceableGeom.getQuaternion() and PlaceableGeom.getPosition() pass references instead of copies?

Can you please explain what you want better. Placeable geom works both ways for both methods already. It will either create a new container object, or you can pass it an object to fill in the details.

Well, I’d like to be able to do:

myPlaceableGeom.getQuaternion().x = …
myPlaceableGeom.getPosition().x = …

Well the javadoc states this:


javax.vecmath.Vector3f       getPosition()
          Returns the current position.
 void       getPosition(float[] result)
          Returns the current position using the provided float array.
 javax.vecmath.Vector3f       getPosition(javax.vecmath.Vector3f result)
          Returns the current position using the provided Vector3f
 javax.vecmath.Quat4f       getQuaternion()
          Returns the quaternion.
 javax.vecmath.Quat4f       getQuaternion(javax.vecmath.Quat4f result)
          Returns the quaternion using the provided Quad4f

So I don’t know what else you need.

It seems Per_T wants to be able to reset the position of the object by setting the values of the returned Vector3f. However, that would go against any sort of encapsulation of data… for instance, who’s to say how position is held intenally? The vector3f you get back might have been generated from the matrix being held for the object. Who’s to say how it might change in the future…

Kev

Well, this is really not a big issue. I’ts just the way jME does it, and I thought it would be nice to have it the same way in ODE, because I’m using the two together.

If you guys wanna have it the way it is, that’s really no problem :slight_smile:

On my initial post I’d missed the


  javax.vecmath.Quat4f  getQuaternion(javax.vecmath.Quat4f result)
     Returns the quaternion using the provided Quad4f

which solves the “optimization issue”.

[quote]It seems Per_T wants to be able to reset the position of the object by setting the values of the returned Vector3f.
[/quote]
Which, of course, is very bad programming. Apart from that horrible use of side-effects, odejava does not keep anything locally anyway in the high-level classes. Setting a value immediately calls the native code directly. Reading a value does the same thing. Direct setting of a variable like that above would have no effect on the code.