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

@ -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 )
{