mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
Merge pull request #1903 from rextimmy/physics_applyforce
PhysicsShape applyForce function
This commit is contained in:
commit
aa121c50b7
|
|
@ -356,7 +356,7 @@ void BtBody::applyImpulse( const Point3F &origin, const Point3F &force )
|
|||
mActor->activate();
|
||||
}
|
||||
|
||||
void BtBody::applyTorque(const Point3F &torque)
|
||||
void BtBody::applyTorque( const Point3F &torque )
|
||||
{
|
||||
AssertFatal(mActor, "BtBody::applyTorque - The actor is null!");
|
||||
AssertFatal(isDynamic(), "BtBody::applyTorque - This call is only for dynamics!");
|
||||
|
|
@ -367,6 +367,24 @@ void BtBody::applyTorque(const Point3F &torque)
|
|||
mActor->activate();
|
||||
}
|
||||
|
||||
void BtBody::applyForce( const Point3F &force )
|
||||
{
|
||||
AssertFatal(mActor, "BtBody::applyForce - The actor is null!");
|
||||
AssertFatal(isDynamic(), "BtBody::applyForce - This call is only for dynamics!");
|
||||
|
||||
if (mCenterOfMass)
|
||||
{
|
||||
Point3F relForce(force);
|
||||
mCenterOfMass->mulV(relForce);
|
||||
mActor->applyCentralForce(btCast<btVector3>(relForce));
|
||||
}
|
||||
else
|
||||
mActor->applyCentralForce(btCast<btVector3>(force));
|
||||
|
||||
if (!mActor->isActive())
|
||||
mActor->activate();
|
||||
}
|
||||
|
||||
Box3F BtBody::getWorldBounds()
|
||||
{
|
||||
btVector3 min, max;
|
||||
|
|
|
|||
|
|
@ -111,7 +111,8 @@ public:
|
|||
F32 staticFriction );
|
||||
virtual void applyCorrection( const MatrixF &xfm );
|
||||
virtual void applyImpulse( const Point3F &origin, const Point3F &force );
|
||||
virtual void applyTorque(const Point3F &torque);
|
||||
virtual void applyTorque( const Point3F &torque );
|
||||
virtual void applyForce( const Point3F &force );
|
||||
virtual void findContact(SceneObject **contactObject, VectorF *contactNormal, Vector<SceneObject*> *outOverlapObjects) const;
|
||||
virtual void moveKinematicTo(const MatrixF &xfm);
|
||||
|
||||
|
|
|
|||
|
|
@ -115,7 +115,10 @@ public:
|
|||
virtual void applyImpulse( const Point3F &origin, const Point3F &force ) = 0;
|
||||
|
||||
///
|
||||
virtual void applyTorque(const Point3F &torque) = 0;
|
||||
virtual void applyTorque( const Point3F &torque ) = 0;
|
||||
|
||||
///
|
||||
virtual void applyForce( const Point3F &force ) = 0;
|
||||
|
||||
|
||||
virtual void findContact(SceneObject **contactObject,
|
||||
|
|
|
|||
|
|
@ -863,6 +863,12 @@ void PhysicsShape::applyTorque( const Point3F &torque )
|
|||
mPhysicsRep->applyTorque( torque );
|
||||
}
|
||||
|
||||
void PhysicsShape::applyForce( const Point3F &force )
|
||||
{
|
||||
if (mPhysicsRep && mPhysicsRep->isDynamic())
|
||||
mPhysicsRep->applyForce( force );
|
||||
}
|
||||
|
||||
void PhysicsShape::applyRadialImpulse( const Point3F &origin, F32 radius, F32 magnitude )
|
||||
{
|
||||
if ( !mPhysicsRep || !mPhysicsRep->isDynamic() )
|
||||
|
|
@ -1193,4 +1199,12 @@ DefineEngineMethod( PhysicsShape, applyTorque, void, (Point3F torque), ,
|
|||
"@note This value is ignored on physics shapes that are not dynamic. Wakes up the dynamic physics shape if it is sleeping.\n")
|
||||
{
|
||||
object->applyTorque( torque );
|
||||
}
|
||||
|
||||
DefineEngineMethod(PhysicsShape, applyForce, void, (Point3F force), ,
|
||||
"@brief Add a force to a dynamic physics shape.\n\n"
|
||||
"@param force to apply to the dynamic physics shape\n"
|
||||
"@note This value is ignored on physics shapes that are not dynamic. Wakes up the dynamic physics shape if it is sleeping.\n")
|
||||
{
|
||||
object->applyForce( force );
|
||||
}
|
||||
|
|
@ -247,6 +247,7 @@ public:
|
|||
void applyImpulse( const Point3F &pos, const VectorF &vec );
|
||||
void applyRadialImpulse( const Point3F &origin, F32 radius, F32 magnitude );
|
||||
void applyTorque( const Point3F &torque );
|
||||
void applyForce( const Point3F &force );
|
||||
void setScale(const VectorF & scale);
|
||||
|
||||
// GameBase
|
||||
|
|
|
|||
|
|
@ -427,6 +427,16 @@ void Px3Body::applyTorque( const Point3F &torque )
|
|||
actor->addTorque( px3Cast<physx::PxVec3>(torque), physx::PxForceMode::eFORCE, true);
|
||||
}
|
||||
|
||||
void Px3Body::applyForce( const Point3F &force )
|
||||
{
|
||||
AssertFatal(mActor, "Px3Body::applyTorque - The actor is null!");
|
||||
|
||||
mWorld->releaseWriteLock();
|
||||
physx::PxRigidDynamic *actor = mActor->is<physx::PxRigidDynamic>();
|
||||
if (mIsEnabled && isDynamic())
|
||||
actor->addForce( px3Cast<physx::PxVec3>(force), physx::PxForceMode::eFORCE, true);
|
||||
}
|
||||
|
||||
void Px3Body::findContact(SceneObject **contactObject,
|
||||
VectorF *contactNormal,
|
||||
Vector<SceneObject*> *outOverlapObjects) const
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ public:
|
|||
virtual void applyCorrection( const MatrixF &xfm );
|
||||
virtual void applyImpulse( const Point3F &origin, const Point3F &force );
|
||||
virtual void applyTorque( const Point3F &torque );
|
||||
virtual void applyForce( const Point3F &force );
|
||||
virtual void findContact(SceneObject **contactObject, VectorF *contactNormal,
|
||||
Vector<SceneObject*> *outOverlapObjects) const;
|
||||
virtual void moveKinematicTo(const MatrixF &xfm);
|
||||
|
|
|
|||
Loading…
Reference in a new issue