Bullet plugin update for bullet 2.85.

Fix potential crash with BtPlayer::_stepForward
This commit is contained in:
rextimmy 2016-12-28 18:33:19 +10:00
parent 540c9b72c0
commit c08f75f52a
4 changed files with 6 additions and 47 deletions

View file

@ -39,10 +39,4 @@
#include <BulletCollision/CollisionDispatch/btGhostObject.h> #include <BulletCollision/CollisionDispatch/btGhostObject.h>
#include <BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h> #include <BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h>
#include <BulletMultiThreaded/PlatformDefinitions.h> #endif // _BULLET_H_
#include <BulletMultiThreaded/SpuGatheringCollisionDispatcher.h>
#include <BulletMultiThreaded/Win32ThreadSupport.h>
#include <BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.h>
#endif // _BULLET_H_

View file

@ -342,7 +342,7 @@ void BtPlayer::_stepForward( btVector3 *inOutCurrPos, const btVector3 &displacem
start.setOrigin( *inOutCurrPos ); start.setOrigin( *inOutCurrPos );
end.setOrigin( *inOutCurrPos + disp ); 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_collisionFilterGroup = mGhostObject->getBroadphaseHandle()->m_collisionFilterGroup;
callback.m_collisionFilterMask = mGhostObject->getBroadphaseHandle()->m_collisionFilterMask; callback.m_collisionFilterMask = mGhostObject->getBroadphaseHandle()->m_collisionFilterMask;

View file

@ -33,11 +33,6 @@
#include "console/consoleTypes.h" #include "console/consoleTypes.h"
#include "scene/sceneRenderState.h" #include "scene/sceneRenderState.h"
#include "T3D/gameBase/gameProcess.h" #include "T3D/gameBase/gameProcess.h"
#ifdef _WIN32
#include "BulletMultiThreaded/Win32ThreadSupport.h"
#elif defined (USE_PTHREADS)
#include "BulletMultiThreaded/PosixThreadSupport.h"
#endif
BtWorld::BtWorld() : BtWorld::BtWorld() :
mProcessList( NULL ), mProcessList( NULL ),
@ -46,8 +41,7 @@ BtWorld::BtWorld() :
mTickCount( 0 ), mTickCount( 0 ),
mIsEnabled( false ), mIsEnabled( false ),
mEditorTimeScale( 1.0f ), mEditorTimeScale( 1.0f ),
mDynamicsWorld( NULL ), mDynamicsWorld( NULL )
mThreadSupportCollision( NULL )
{ {
} }
@ -59,33 +53,7 @@ bool BtWorld::initWorld( bool isServer, ProcessList *processList )
{ {
// Collision configuration contains default setup for memory, collision setup. // Collision configuration contains default setup for memory, collision setup.
mCollisionConfiguration = new btDefaultCollisionConfiguration(); mCollisionConfiguration = new btDefaultCollisionConfiguration();
mDispatcher = new btCollisionDispatcher( mCollisionConfiguration );
// 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 );
}
btVector3 worldMin( -2000, -2000, -1000 ); btVector3 worldMin( -2000, -2000, -1000 );
btVector3 worldMax( 2000, 2000, 1000 ); btVector3 worldMax( 2000, 2000, 1000 );
@ -134,7 +102,6 @@ void BtWorld::_destroy()
SAFE_DELETE( mSolver ); SAFE_DELETE( mSolver );
SAFE_DELETE( mBroadphase ); SAFE_DELETE( mBroadphase );
SAFE_DELETE( mDispatcher ); SAFE_DELETE( mDispatcher );
SAFE_DELETE( mThreadSupportCollision );
SAFE_DELETE( mCollisionConfiguration ); SAFE_DELETE( mCollisionConfiguration );
} }
@ -144,12 +111,12 @@ void BtWorld::tickPhysics( U32 elapsedMs )
return; return;
// Did we forget to call getPhysicsResults somewhere? // 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 // The elapsed time should be non-zero and
// a multiple of TickMs! // a multiple of TickMs!
AssertFatal( elapsedMs != 0 && 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); PROFILE_SCOPE(BtWorld_TickPhysics);

View file

@ -37,7 +37,6 @@
#endif #endif
class ProcessList; class ProcessList;
class btThreadSupportInterface;
class PhysicsBody; class PhysicsBody;
@ -54,7 +53,6 @@ protected:
btCollisionDispatcher *mDispatcher; btCollisionDispatcher *mDispatcher;
btConstraintSolver *mSolver; btConstraintSolver *mSolver;
btDefaultCollisionConfiguration *mCollisionConfiguration; btDefaultCollisionConfiguration *mCollisionConfiguration;
btThreadSupportInterface *mThreadSupportCollision;
bool mErrorReport; bool mErrorReport;