From c08f75f52acf66cc739fd1542a71cd830abfb057 Mon Sep 17 00:00:00 2001 From: rextimmy Date: Wed, 28 Dec 2016 18:33:19 +1000 Subject: [PATCH] Bullet plugin update for bullet 2.85. Fix potential crash with BtPlayer::_stepForward --- Engine/source/T3D/physics/bullet/bt.h | 8 +--- Engine/source/T3D/physics/bullet/btPlayer.cpp | 2 +- Engine/source/T3D/physics/bullet/btWorld.cpp | 41 ++----------------- Engine/source/T3D/physics/bullet/btWorld.h | 2 - 4 files changed, 6 insertions(+), 47 deletions(-) diff --git a/Engine/source/T3D/physics/bullet/bt.h b/Engine/source/T3D/physics/bullet/bt.h index 394fdc7de2..76b3ee71b2 100644 --- a/Engine/source/T3D/physics/bullet/bt.h +++ b/Engine/source/T3D/physics/bullet/bt.h @@ -39,10 +39,4 @@ #include #include -#include -#include -#include -#include - - -#endif // _BULLET_H_ \ No newline at end of file +#endif // _BULLET_H_ diff --git a/Engine/source/T3D/physics/bullet/btPlayer.cpp b/Engine/source/T3D/physics/bullet/btPlayer.cpp index 793f6053cb..2d412ddb94 100644 --- a/Engine/source/T3D/physics/bullet/btPlayer.cpp +++ b/Engine/source/T3D/physics/bullet/btPlayer.cpp @@ -342,7 +342,7 @@ void BtPlayer::_stepForward( btVector3 *inOutCurrPos, const btVector3 &displacem start.setOrigin( *inOutCurrPos ); end.setOrigin( *inOutCurrPos + disp ); - BtPlayerSweepCallback callback( mGhostObject, disp.length2() > 0.0f ? disp.normalized() : disp ); + BtPlayerSweepCallback callback( mGhostObject, disp.length2() > SIMD_EPSILON ? disp.normalized() : disp ); callback.m_collisionFilterGroup = mGhostObject->getBroadphaseHandle()->m_collisionFilterGroup; callback.m_collisionFilterMask = mGhostObject->getBroadphaseHandle()->m_collisionFilterMask; diff --git a/Engine/source/T3D/physics/bullet/btWorld.cpp b/Engine/source/T3D/physics/bullet/btWorld.cpp index 231b1e3e1f..3b2a5777c4 100644 --- a/Engine/source/T3D/physics/bullet/btWorld.cpp +++ b/Engine/source/T3D/physics/bullet/btWorld.cpp @@ -33,11 +33,6 @@ #include "console/consoleTypes.h" #include "scene/sceneRenderState.h" #include "T3D/gameBase/gameProcess.h" -#ifdef _WIN32 -#include "BulletMultiThreaded/Win32ThreadSupport.h" -#elif defined (USE_PTHREADS) -#include "BulletMultiThreaded/PosixThreadSupport.h" -#endif BtWorld::BtWorld() : mProcessList( NULL ), @@ -46,8 +41,7 @@ BtWorld::BtWorld() : mTickCount( 0 ), mIsEnabled( false ), mEditorTimeScale( 1.0f ), - mDynamicsWorld( NULL ), - mThreadSupportCollision( NULL ) + mDynamicsWorld( NULL ) { } @@ -59,33 +53,7 @@ bool BtWorld::initWorld( bool isServer, ProcessList *processList ) { // Collision configuration contains default setup for memory, collision setup. mCollisionConfiguration = new btDefaultCollisionConfiguration(); - - // TODO: There is something wrong with multithreading - // and compound convex shapes... so disable it for now. - static const U32 smMaxThreads = 1; - - // Different initialization with threading enabled. - if ( smMaxThreads > 1 ) - { - - // TODO: ifdef assumes smMaxThread is always one at this point. MACOSX support to be decided -#ifdef WIN32 - mThreadSupportCollision = new Win32ThreadSupport( - Win32ThreadSupport::Win32ThreadConstructionInfo( isServer ? "bt_servercol" : "bt_clientcol", - processCollisionTask, - createCollisionLocalStoreMemory, - smMaxThreads ) ); - - mDispatcher = new SpuGatheringCollisionDispatcher( mThreadSupportCollision, - smMaxThreads, - mCollisionConfiguration ); -#endif // WIN32 - } - else - { - mThreadSupportCollision = NULL; - mDispatcher = new btCollisionDispatcher( mCollisionConfiguration ); - } + mDispatcher = new btCollisionDispatcher( mCollisionConfiguration ); btVector3 worldMin( -2000, -2000, -1000 ); btVector3 worldMax( 2000, 2000, 1000 ); @@ -134,7 +102,6 @@ void BtWorld::_destroy() SAFE_DELETE( mSolver ); SAFE_DELETE( mBroadphase ); SAFE_DELETE( mDispatcher ); - SAFE_DELETE( mThreadSupportCollision ); SAFE_DELETE( mCollisionConfiguration ); } @@ -144,12 +111,12 @@ void BtWorld::tickPhysics( U32 elapsedMs ) return; // Did we forget to call getPhysicsResults somewhere? - AssertFatal( !mIsSimulating, "PhysXWorld::tickPhysics() - Already simulating!" ); + AssertFatal( !mIsSimulating, "BtWorld::tickPhysics() - Already simulating!" ); // The elapsed time should be non-zero and // a multiple of TickMs! AssertFatal( elapsedMs != 0 && - ( elapsedMs % TickMs ) == 0 , "PhysXWorld::tickPhysics() - Got bad elapsed time!" ); + ( elapsedMs % TickMs ) == 0 , "BtWorld::tickPhysics() - Got bad elapsed time!" ); PROFILE_SCOPE(BtWorld_TickPhysics); diff --git a/Engine/source/T3D/physics/bullet/btWorld.h b/Engine/source/T3D/physics/bullet/btWorld.h index e859a671a1..f625371a3f 100644 --- a/Engine/source/T3D/physics/bullet/btWorld.h +++ b/Engine/source/T3D/physics/bullet/btWorld.h @@ -37,7 +37,6 @@ #endif class ProcessList; -class btThreadSupportInterface; class PhysicsBody; @@ -54,7 +53,6 @@ class BtWorld : public PhysicsWorld btCollisionDispatcher *mDispatcher; btConstraintSolver *mSolver; btDefaultCollisionConfiguration *mCollisionConfiguration; - btThreadSupportInterface *mThreadSupportCollision; bool mErrorReport;