From 89ad23a925c8919daf322d1ddcb98fa42b8b1616 Mon Sep 17 00:00:00 2001 From: DavidWyand-GG Date: Wed, 17 Oct 2012 14:45:13 -0400 Subject: [PATCH] Fix for Issue #96 for DAE updating crash --- Engine/source/T3D/physics/physicsWorld.h | 5 +++++ Engine/source/T3D/physics/physx/pxPlayer.cpp | 10 +++++++++- Engine/source/T3D/physics/physx/pxPlayer.h | 2 ++ Engine/source/T3D/physics/physx/pxWorld.cpp | 7 ++++++- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Engine/source/T3D/physics/physicsWorld.h b/Engine/source/T3D/physics/physicsWorld.h index 0db190098..115c32324 100644 --- a/Engine/source/T3D/physics/physicsWorld.h +++ b/Engine/source/T3D/physics/physicsWorld.h @@ -42,6 +42,8 @@ class PhysicsWorld { protected: + Signal mStaticChangedSignal; + Signal mUpdateSignal; /// The current gravity force. @@ -58,6 +60,9 @@ public: /// Signal& getUpdateSignal() { return mUpdateSignal; } + // Called when a static body in the scene has been removed. + Signal& getStaticChangedSignal() { return mStaticChangedSignal; } + /// Overloaded to do debug drawing. /// /// It is assumed the GFX state is setup prior to this call for diff --git a/Engine/source/T3D/physics/physx/pxPlayer.cpp b/Engine/source/T3D/physics/physx/pxPlayer.cpp index 3aec57495..cf4ca9038 100644 --- a/Engine/source/T3D/physics/physx/pxPlayer.cpp +++ b/Engine/source/T3D/physics/physx/pxPlayer.cpp @@ -53,7 +53,8 @@ void PxPlayer::_releaseController() if ( mController ) { mController->getActor()->userData = NULL; - mWorld->releaseController( *mController ); + mWorld->getStaticChangedSignal().remove( this, &PxPlayer::_onStaticChanged ); + mWorld->releaseController( *mController ); mController = NULL; } } @@ -99,6 +100,8 @@ void PxPlayer::init( const char *type, //mOriginOffset = 1.0f; } + mWorld->getStaticChangedSignal().notify( this, &PxPlayer::_onStaticChanged ); + // Put the kinematic actor on group 29. NxActor *kineActor = mController->getActor(); kineActor->setGroup( 29 ); @@ -110,6 +113,11 @@ void PxPlayer::init( const char *type, kineActor->userData = &mUserData; } +void PxPlayer::_onStaticChanged() +{ + mController->reportSceneChanged(); +} + void PxPlayer::_onPhysicsReset( PhysicsResetEvent reset ) { // The PhysX controller will crash out if it doesn't clear its diff --git a/Engine/source/T3D/physics/physx/pxPlayer.h b/Engine/source/T3D/physics/physx/pxPlayer.h index 2c35817c9..419ddcc2b 100644 --- a/Engine/source/T3D/physics/physx/pxPlayer.h +++ b/Engine/source/T3D/physics/physx/pxPlayer.h @@ -71,6 +71,8 @@ protected: void _onPhysicsReset( PhysicsResetEvent reset ); + void _onStaticChanged(); + public: PxPlayer(); diff --git a/Engine/source/T3D/physics/physx/pxWorld.cpp b/Engine/source/T3D/physics/physx/pxWorld.cpp index bbccc105c..c4f33a21d 100644 --- a/Engine/source/T3D/physics/physx/pxWorld.cpp +++ b/Engine/source/T3D/physics/physx/pxWorld.cpp @@ -569,9 +569,11 @@ void PxWorld::_releaseQueues() mReleaseJointQueue.clear(); // Now release any actors still pending in the queue. + bool staticChanged = false; for ( S32 i = 0; i < mReleaseActorQueue.size(); i++ ) { - NxActor *currActor = mReleaseActorQueue[i]; + NxActor *currActor = mReleaseActorQueue[i]; + staticChanged |= !currActor->isDynamic(); mScene->releaseActor( *currActor ); } @@ -618,6 +620,9 @@ void PxWorld::_releaseQueues() mScene->releaseFluid( *currFluid ); } mReleaseFluidQueue.clear(); + + if ( staticChanged ) + mStaticChangedSignal.trigger(); } void PxWorld::setEnabled( bool enabled )