Makes vehicles work with the physics plugins.

Makes vehicles create a basic physics body when using one of the physics plugins so that they can collide with other physics-enabled objects.

Based on @rextimmy 's work.
This commit is contained in:
Areloch 2016-06-04 16:47:03 -05:00
parent 5122360552
commit 37e030f8f4
9 changed files with 161 additions and 2 deletions

View file

@ -378,3 +378,25 @@ void BtBody::setSimulationEnabled( bool enabled )
mIsEnabled = enabled;
}
void BtBody::moveKinematicTo(const MatrixF &transform)
{
AssertFatal(mActor, "BtBody::moveKinematicTo - The actor is null!");
U32 bodyflags = mActor->getCollisionFlags();
const bool isKinematic = bodyflags & BF_KINEMATIC;
if (!isKinematic)
{
Con::errorf("BtBody::moveKinematicTo is only for kinematic bodies.");
return;
}
if (mCenterOfMass)
{
MatrixF xfm;
xfm.mul(transform, *mCenterOfMass);
mActor->setCenterOfMassTransform(btCast<btTransform>(xfm));
}
else
mActor->setCenterOfMassTransform(btCast<btTransform>(transform));
}