Problem with Static Plane Shape

Dominik
Posts: 32
Joined: Fri Dec 19, 2008 2:51 pm

Problem with Static Plane Shape

Post by Dominik »

Hi
I have some rather strange problem with the StaticPlane shape.
I create my objects by first setting construction info, and then using this to create objects.

Code: Select all

// m_pObjectConstruct holds construction info, like shape, mass, etc.
// Looks the same for all shape types

ApplyTransformation(); // sets up the Matrix that is returned to getWorldTransform

memcpy( m_a3fExtents, m_pObjectConstruct->m_a3fExtents, 3*sizeof(float) );

m_bUseOwnInertia = m_pObjectConstruct->m_bUseOwnInertia;
btVector3 v3BtInertia;
v3BtInertia = btVector3 ( pObjectConstruct->m_a3fInertia[0],
					pObjectConstruct->m_a3fInertia[1],
					pObjectConstruct->m_a3fInertia[2] );
btRigidBody::btRigidBodyConstructionInfo oBtObjectInfo(
					m_pObjectConstruct->m_fMass, this, 
					m_pObjectConstruct->m_pBtCollisionShape,
					v3BtInertia );
/*setting mass, inertia, etc. properties*/

m_pBtObject = new btRigidBody( oBtObjectInfo );
m_bIsInitialized = true;
m_pBtObject->setUserPointer( this );
m_pBtObject->setCollisionFlags( m_pBtObject->getCollisionFlags() |
						btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK );

m_pBtObject->setCcdMotionThreshold( m_pObjectConstruct->m_fCCDMotionTreshold );
m_pBtObject->setCcdSweptSphereRadius( m_pObjectConstruct->m_fCCDSphereRadius );		

m_pBtWorld->addRigidBody( m_pBtObject );
ApplyTransformation();
m_pBtObject->setWorldTransform( m_matBtPhysicsTransform );
This method is used for all kinds of shapes, also for the static plane.
Now, when using the described method, everything works fine when I use the debug version of Bullet, but in Release mode, all other objects fall right through the static plane.
The cause of the ptroblem is the first line, ApplyTransformation(), which sets up the matrix that is returned by the getWorldTransform() call.
Now, if I remove this ApplyTransform call, the Release mode works fine, but now the Debug mode is broken and the shape doesn't collide anymore :shock:

Any ideas on that?