mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
Merge pull request #571 from DavidWyand-GG/BulletImpulseFix
Bullet physics applyImpulse() fix
This commit is contained in:
commit
0a45c470f3
|
|
@ -335,16 +335,22 @@ void BtBody::applyImpulse( const Point3F &origin, const Point3F &force )
|
|||
AssertFatal( mActor, "BtBody::applyImpulse - The actor is null!" );
|
||||
AssertFatal( isDynamic(), "BtBody::applyImpulse - This call is only for dynamics!" );
|
||||
|
||||
// Convert the world position to local
|
||||
MatrixF trans = btCast<MatrixF>( mActor->getCenterOfMassTransform() );
|
||||
trans.inverse();
|
||||
Point3F localOrigin( origin );
|
||||
trans.mulP( localOrigin );
|
||||
|
||||
if ( mCenterOfMass )
|
||||
{
|
||||
Point3F relOrigin( origin );
|
||||
Point3F relOrigin( localOrigin );
|
||||
mCenterOfMass->mulP( relOrigin );
|
||||
Point3F relForce( force );
|
||||
mCenterOfMass->mulV( relForce );
|
||||
mActor->applyImpulse( btCast<btVector3>( relForce ), btCast<btVector3>( relOrigin ) );
|
||||
}
|
||||
else
|
||||
mActor->applyImpulse( btCast<btVector3>( force ), btCast<btVector3>( origin ) );
|
||||
mActor->applyImpulse( btCast<btVector3>( force ), btCast<btVector3>( localOrigin ) );
|
||||
|
||||
if ( !mActor->isActive() )
|
||||
mActor->activate();
|
||||
|
|
|
|||
Loading…
Reference in a new issue