mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-03 04:20:30 +00:00
Resolves merging-order conflicts for the vehicle physics PR, as well as correcting cmake not blacklisting the componentGroup files if TORQUE_EXPERIMENTAL_EC was flipped off.
This commit is contained in:
commit
3a73344abb
36 changed files with 357 additions and 46 deletions
|
|
@ -442,3 +442,25 @@ void BtBody::findContact(SceneObject **contactObject,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
|
@ -113,6 +113,8 @@ public:
|
|||
virtual void applyImpulse( const Point3F &origin, const Point3F &force );
|
||||
|
||||
virtual void findContact(SceneObject **contactObject, VectorF *contactNormal, Vector<SceneObject*> *outOverlapObjects) const;
|
||||
virtual void moveKinematicTo(const MatrixF &xfm);
|
||||
|
||||
};
|
||||
|
||||
#endif // _T3D_PHYSICS_BTBODY_H_
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ void BtPlayer::init( const char *type,
|
|||
mObject = obj;
|
||||
mWorld = (BtWorld*)world;
|
||||
|
||||
mSlopeAngle = runSurfaceCos;
|
||||
mStepHeight = stepHeight;
|
||||
|
||||
//if ( dStricmp( type, "Capsule" ) == 0 )
|
||||
|
|
@ -102,6 +103,17 @@ Point3F BtPlayer::move( const VectorF &disp, CollisionList &outCol )
|
|||
{
|
||||
AssertFatal( mGhostObject, "BtPlayer::move - The controller is null!" );
|
||||
|
||||
if (!mWorld->isEnabled())
|
||||
{
|
||||
btTransform currentTrans = mGhostObject->getWorldTransform();
|
||||
btVector3 currentPos = currentTrans.getOrigin();
|
||||
|
||||
Point3F returnPos = btCast<Point3F>(currentPos);
|
||||
|
||||
returnPos.z -= mOriginOffset;
|
||||
return returnPos;
|
||||
}
|
||||
|
||||
// First recover from any penetrations from the previous tick.
|
||||
U32 numPenetrationLoops = 0;
|
||||
bool touchingContact = false;
|
||||
|
|
@ -305,16 +317,9 @@ bool BtPlayer::_sweep( btVector3 *inOutCurrPos, const btVector3 &disp, Collision
|
|||
col.normal = btCast<Point3F>( callback.m_hitNormalWorld );
|
||||
col.object = PhysicsUserData::getObject( callback.m_hitCollisionObject->getUserPointer() );
|
||||
|
||||
if (disp.z() < 0.0f)
|
||||
{
|
||||
// We're sweeping down as part of the stepping routine. In this
|
||||
// case we want to have the collision normal only point in the opposite direction.
|
||||
// i.e. up If we include the sideways part of the normal then the Player class
|
||||
// velocity calculations using this normal will affect the player's forwards
|
||||
// momentum. This is especially noticable on stairs as the rounded bottom of
|
||||
// the capsule slides up the corner of a stair.
|
||||
col.normal.set(0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
F32 vd = col.normal.z;
|
||||
if (vd < mSlopeAngle)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -57,6 +57,10 @@ protected:
|
|||
///
|
||||
F32 mOriginOffset;
|
||||
|
||||
///
|
||||
F32 mSlopeAngle;
|
||||
///
|
||||
|
||||
///
|
||||
F32 mStepHeight;
|
||||
///
|
||||
|
|
|
|||
|
|
@ -117,6 +117,10 @@ public:
|
|||
virtual void findContact(SceneObject **contactObject,
|
||||
VectorF *contactNormal,
|
||||
Vector<SceneObject*> *outOverlapObjects) const = 0;
|
||||
|
||||
///
|
||||
virtual void moveKinematicTo(const MatrixF &xfm) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -468,4 +468,22 @@ void Px3Body::findContact(SceneObject **contactObject,
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}void Px3Body::moveKinematicTo(const MatrixF &transform)
|
||||
{
|
||||
AssertFatal(mActor, "Px3Body::moveKinematicTo - The actor is null!");
|
||||
|
||||
const bool isKinematic = mBodyFlags & BF_KINEMATIC;
|
||||
if (!isKinematic)
|
||||
{
|
||||
Con::errorf("Px3Body::moveKinematicTo is only for kinematic bodies.");
|
||||
return;
|
||||
}
|
||||
|
||||
mWorld->lockScene();
|
||||
|
||||
physx::PxRigidDynamic *actor = mActor->is<physx::PxRigidDynamic>();
|
||||
actor->setKinematicTarget(px3Cast<physx::PxTransform>(transform));
|
||||
|
||||
mWorld->unlockScene();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -120,6 +120,8 @@ public:
|
|||
|
||||
virtual void findContact(SceneObject **contactObject, VectorF *contactNormal,
|
||||
Vector<SceneObject*> *outOverlapObjects) const;
|
||||
virtual void moveKinematicTo(const MatrixF &xfm);
|
||||
|
||||
};
|
||||
|
||||
#endif // _PX3BODY_H_
|
||||
|
|
|
|||
|
|
@ -329,3 +329,33 @@ Box3F Px3Player::getWorldBounds()
|
|||
return px3Cast<Box3F>( bounds );
|
||||
}
|
||||
|
||||
bool Px3Player::testSpacials(const Point3F &nPos, const Point3F &nSize) const
|
||||
{
|
||||
F32 offset = nSize.z * 0.5f;
|
||||
F32 radius = getMax(nSize.x, nSize.y) * 0.5f - mSkinWidth;
|
||||
F32 height = (nSize.z - (radius * 2.0f)) * 0.5f;
|
||||
height -= mSkinWidth * 2.0f;
|
||||
physx::PxCapsuleGeometry geom(radius, height);
|
||||
|
||||
physx::PxVec3 pos(nPos.x, nPos.y, nPos.z + offset);
|
||||
physx::PxQuat orientation(Float_HalfPi, physx::PxVec3(0.0f, 1.0f, 0.0f));
|
||||
|
||||
physx::PxOverlapBuffer hit;
|
||||
physx::PxQueryFilterData queryFilter(physx::PxQueryFlag::eANY_HIT | physx::PxQueryFlag::eSTATIC | physx::PxQueryFlag::eDYNAMIC);
|
||||
queryFilter.data.word0 = PX3_DEFAULT;
|
||||
bool hasHit = mWorld->getScene()->overlap(geom, physx::PxTransform(pos, orientation), hit, queryFilter);
|
||||
|
||||
return !hasHit; // Return true if there are no overlapping objects
|
||||
}
|
||||
|
||||
void Px3Player::setSpacials(const Point3F &nPos, const Point3F &nSize)
|
||||
{
|
||||
mOriginOffset = nSize.z * 0.5f;
|
||||
F32 radius = getMax(nSize.x, nSize.y) * 0.5f - mSkinWidth;
|
||||
F32 height = nSize.z - (radius * 2.0f);
|
||||
height -= mSkinWidth * 2.0f;
|
||||
|
||||
mWorld->releaseWriteLock();
|
||||
mController->resize(height);
|
||||
px3GetFirstShape(mController->getActor())->getCapsuleGeometry(mGeometry);
|
||||
}
|
||||
|
|
@ -94,8 +94,8 @@ public:
|
|||
PhysicsWorld *world );
|
||||
virtual Point3F move( const VectorF &displacement, CollisionList &outCol );
|
||||
virtual void findContact( SceneObject **contactObject, VectorF *contactNormal, Vector<SceneObject*> *outOverlapObjects ) const;
|
||||
virtual bool testSpacials( const Point3F &nPos, const Point3F &nSize ) const { return true; }
|
||||
virtual void setSpacials( const Point3F &nPos, const Point3F &nSize ) {}
|
||||
virtual bool testSpacials( const Point3F &nPos, const Point3F &nSize ) const;
|
||||
virtual void setSpacials( const Point3F &nPos, const Point3F &nSize );
|
||||
virtual void enableCollision();
|
||||
virtual void disableCollision();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -62,7 +62,8 @@ Px3World::Px3World(): mScene( NULL ),
|
|||
mIsEnabled( false ),
|
||||
mEditorTimeScale( 1.0f ),
|
||||
mAccumulator( 0 ),
|
||||
mControllerManager( NULL )
|
||||
mControllerManager(NULL),
|
||||
mIsSceneLocked(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -335,6 +336,62 @@ void Px3World::releaseWriteLock()
|
|||
//AssertFatal( mScene->isWritable(), "PhysX3World::releaseWriteLock() - We should have been writable now!" );
|
||||
}
|
||||
|
||||
void Px3World::lockScenes()
|
||||
{
|
||||
Px3World *world = dynamic_cast<Px3World*>(PHYSICSMGR->getWorld("server"));
|
||||
|
||||
if (world)
|
||||
world->lockScene();
|
||||
|
||||
world = dynamic_cast<Px3World*>(PHYSICSMGR->getWorld("client"));
|
||||
|
||||
if (world)
|
||||
world->lockScene();
|
||||
}
|
||||
|
||||
void Px3World::unlockScenes()
|
||||
{
|
||||
Px3World *world = dynamic_cast<Px3World*>(PHYSICSMGR->getWorld("server"));
|
||||
|
||||
if (world)
|
||||
world->unlockScene();
|
||||
|
||||
world = dynamic_cast<Px3World*>(PHYSICSMGR->getWorld("client"));
|
||||
|
||||
if (world)
|
||||
world->unlockScene();
|
||||
}
|
||||
|
||||
void Px3World::lockScene()
|
||||
{
|
||||
if (!mScene)
|
||||
return;
|
||||
|
||||
if (mIsSceneLocked)
|
||||
{
|
||||
Con::printf("Px3World: Attempting to lock a scene that is already locked.");
|
||||
return;
|
||||
}
|
||||
|
||||
mScene->lockWrite();
|
||||
mIsSceneLocked = true;
|
||||
}
|
||||
|
||||
void Px3World::unlockScene()
|
||||
{
|
||||
if (!mScene)
|
||||
return;
|
||||
|
||||
if (!mIsSceneLocked)
|
||||
{
|
||||
Con::printf("Px3World: Attempting to unlock a scene that is not locked.");
|
||||
return;
|
||||
}
|
||||
|
||||
mScene->unlockWrite();
|
||||
mIsSceneLocked = false;
|
||||
}
|
||||
|
||||
bool Px3World::castRay( const Point3F &startPnt, const Point3F &endPnt, RayInfo *ri, const Point3F &impulse )
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ protected:
|
|||
bool mIsEnabled;
|
||||
bool mIsSimulating;
|
||||
bool mIsServer;
|
||||
bool mIsSceneLocked;
|
||||
U32 mTickCount;
|
||||
ProcessList *mProcessList;
|
||||
F32 mEditorTimeScale;
|
||||
|
|
@ -96,11 +97,15 @@ public:
|
|||
void releaseWriteLock();
|
||||
bool isServer(){return mIsServer;}
|
||||
physx::PxController* createController( physx::PxControllerDesc &desc );
|
||||
void lockScene();
|
||||
void unlockScene();
|
||||
//static
|
||||
static bool restartSDK( bool destroyOnly = false, Px3World *clientWorld = NULL, Px3World *serverWorld = NULL );
|
||||
static void releaseWriteLocks();
|
||||
static physx::PxCooking *getCooking();
|
||||
static void setTiming(F32 stepTime,U32 maxIterations);
|
||||
static void lockScenes();
|
||||
static void unlockScenes();
|
||||
};
|
||||
|
||||
#endif // _PX3WORLD_H_
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue