When making a btTransform, why is setIdentity() necessary?

Jonathan
Posts: 36
Joined: Sun Feb 10, 2013 6:52 pm

When making a btTransform, why is setIdentity() necessary?

Post by Jonathan »

What does btTransform::setIdentity() do?

I had some code that wasn't generating any collision pairs, and after doing a little digging around, I realized the btTransform I was passing to my custom MotionState hadn't called setIdentity(). After calling it everything works fine, but why?

If there is some 3D math term I can Google, just let me know what the term is, because I wasn't finding much with my combinations of 'identity'.
Mako_energy02
Posts: 171
Joined: Sun Jan 17, 2010 4:47 am

Re: When making a btTransform, why is setIdentity() necessar

Post by Mako_energy02 »

"SetIdentity" really just sets a safe default value for each of the data members, usually (0,0,0) on a Vector3, or (0,0,0,1) on a quaternion. Without calling it the data members in the transform can have any value. Imo, SetIdentity() should be called in the constructor.
Jonathan
Posts: 36
Joined: Sun Feb 10, 2013 6:52 pm

Re: When making a btTransform, why is setIdentity() necessar

Post by Jonathan »

Mako_energy02 wrote:"SetIdentity" really just sets a safe default value for each of the data members, usually (0,0,0) on a Vector3, or (0,0,0,1) on a quaternion. Without calling it the data members in the transform can have any value. Imo, SetIdentity() should be called in the constructor.
Ah thanks! Makes sense... just weird that there must be a situation where default initializing the values of a transform are somehow too expensive to do automatically in the constructor.
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: When making a btTransform, why is setIdentity() necessar

Post by Flix »

Jonathan wrote: just weird that there must be a situation where default initializing the values of a transform are somehow too expensive to do automatically in the constructor.
Probably when you initialize long arrays or containers (e.g. 10000 or more elements) at once...
laadams85
Posts: 18
Joined: Wed May 22, 2013 1:45 pm

Re: When making a btTransform, why is setIdentity() necessar

Post by laadams85 »

Mako_energy02 wrote:"SetIdentity" really just sets a safe default value for each of the data members, usually (0,0,0) on a Vector3, or (0,0,0,1) on a quaternion. Without calling it the data members in the transform can have any value. Imo, SetIdentity() should be called in the constructor.
Well that's not entirely correct. Setting the identity for a transform is setting the rotation matrix (basis) equal to the identity matrix, you can google that, and setting the origin to zero. This represents no rotation and no displacement. Transforming a vector using the identity transform will give you that vector back.