Skip to content

Commit

Permalink
Bullet plugin update for bullet 2.85.
Browse files Browse the repository at this point in the history
Fix potential crash with BtPlayer::_stepForward
  • Loading branch information
rextimmy committed Dec 28, 2016
1 parent 540c9b7 commit c08f75f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 47 deletions.
8 changes: 1 addition & 7 deletions Engine/source/T3D/physics/bullet/bt.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,4 @@
#include <BulletCollision/CollisionDispatch/btGhostObject.h>
#include <BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h>

#include <BulletMultiThreaded/PlatformDefinitions.h>
#include <BulletMultiThreaded/SpuGatheringCollisionDispatcher.h>
#include <BulletMultiThreaded/Win32ThreadSupport.h>
#include <BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.h>


#endif // _BULLET_H_
#endif // _BULLET_H_
2 changes: 1 addition & 1 deletion Engine/source/T3D/physics/bullet/btPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
41 changes: 4 additions & 37 deletions Engine/source/T3D/physics/bullet/btWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ),
Expand All @@ -46,8 +41,7 @@ BtWorld::BtWorld() :
mTickCount( 0 ),
mIsEnabled( false ),
mEditorTimeScale( 1.0f ),
mDynamicsWorld( NULL ),
mThreadSupportCollision( NULL )
mDynamicsWorld( NULL )
{
}

Expand All @@ -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 );
Expand Down Expand Up @@ -134,7 +102,6 @@ void BtWorld::_destroy()
SAFE_DELETE( mSolver );
SAFE_DELETE( mBroadphase );
SAFE_DELETE( mDispatcher );
SAFE_DELETE( mThreadSupportCollision );
SAFE_DELETE( mCollisionConfiguration );
}

Expand All @@ -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);

Expand Down
2 changes: 0 additions & 2 deletions Engine/source/T3D/physics/bullet/btWorld.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#endif

class ProcessList;
class btThreadSupportInterface;
class PhysicsBody;


Expand All @@ -54,7 +53,6 @@ class BtWorld : public PhysicsWorld
btCollisionDispatcher *mDispatcher;
btConstraintSolver *mSolver;
btDefaultCollisionConfiguration *mCollisionConfiguration;
btThreadSupportInterface *mThreadSupportCollision;

bool mErrorReport;

Expand Down

0 comments on commit c08f75f

Please sign in to comment.