public override bool AddObjectToWorld(BulletWorld pWorld, BulletBody pBody)
{
DiscreteDynamicsWorld world = (pWorld as BulletWorldXNA).world;
CollisionObject cbody = (pBody as BulletBodyXNA).body;
RigidBody rbody = cbody as RigidBody;
// Bullet resets several variables when an object is added to the world. In particular,
// BulletXNA resets position and rotation. Gravity is also reset depending on the static/dynamic
// type. Of course, the collision flags in the broadphase proxy are initialized to default.
IndexedMatrix origPos = cbody.GetWorldTransform();
if (rbody != null)
{
IndexedVector3 origGrav = rbody.GetGravity();
world.AddRigidBody(rbody);
rbody.SetGravity(origGrav);
}
else
{
world.AddCollisionObject(cbody);
}
cbody.SetWorldTransform(origPos);
pBody.ApplyCollisionMask(pWorld.physicsScene);
//if (body.GetBroadphaseHandle() != null)
// world.UpdateSingleAabb(body);
return true;
}