class btMotionState : void getWorldTransform() ?

durium
Posts: 4
Joined: Tue Apr 24, 2012 7:34 pm

class btMotionState : void getWorldTransform() ?

Post by durium »

Hi all !

I am going through some tutorials to use bullet with my ogre3d application.
I have read that i needed to use the btMotionState class.

When i found it, i discovered a weird function called getWorldTransform, with a return type void which asked for an argument...
In most of the tutorials I've read so far, i believe that this function was used as a setter :

Code: Select all

virtual void getWorldTransform(btTransform worldTrans) const{
    worldTrans = mTransformation;
}
However it is named as a getter...
Is it normal ?
anthrax11
Posts: 72
Joined: Wed Feb 24, 2010 9:49 pm

Re: class btMotionState : void getWorldTransform() ?

Post by anthrax11 »

Hi!

If getWorldTransform returned a btTransform, then it would have to allocate memory for holding the return value. Instead, the value is written directly to an existing btTransform to save time and space. So it's just a useful optimization.

Note that btTransform is a class, so the parameter is really a pointer. That's why the parameter you pass can be modified by the function.

This allows you to allocate a single btTransform and use it every time you need to do the getWorldTransform.
durium
Posts: 4
Joined: Tue Apr 24, 2012 7:34 pm

Re: class btMotionState : void getWorldTransform() ?

Post by durium »

ok thanks!

I should had read it more carefully...
First time i see that...