some demo cleanup, part 0
This commit is contained in:
@@ -13,62 +13,24 @@ subject to the following restrictions:
|
|||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#define USE_GROUND_BOX 1
|
|
||||||
//#define PRINT_CONTACT_STATISTICS 1
|
|
||||||
//#define USE_PARALLEL_DISPATCHER 1
|
|
||||||
|
|
||||||
#define START_POS_X -5
|
|
||||||
#define START_POS_Y -5
|
|
||||||
#define START_POS_Z -3
|
|
||||||
|
|
||||||
|
|
||||||
///create 125 (5x5x5) dynamic object
|
///create 125 (5x5x5) dynamic object
|
||||||
#define ARRAY_SIZE_X 5
|
#define ARRAY_SIZE_X 5
|
||||||
#define ARRAY_SIZE_Y 5
|
#define ARRAY_SIZE_Y 5
|
||||||
#define ARRAY_SIZE_Z 5
|
#define ARRAY_SIZE_Z 5
|
||||||
|
|
||||||
|
//maximum number of objects (and allow user to shoot additional boxes)
|
||||||
|
#define MAX_PROXIES (ARRAY_SIZE_X*ARRAY_SIZE_Y*ARRAY_SIZE_Z + 1024)
|
||||||
|
|
||||||
//#define USE_SIMPLE_DYNAMICS_WORLD 1
|
#define START_POS_X -5
|
||||||
|
#define START_POS_Y -5
|
||||||
|
#define START_POS_Z -3
|
||||||
|
|
||||||
int gNumObjects = 120;
|
|
||||||
#define HALF_EXTENTS btScalar(1.)
|
|
||||||
#include "btBulletDynamicsCommon.h"
|
|
||||||
#include "BulletCollision/BroadphaseCollision/btMultiSapBroadphase.h"
|
|
||||||
#include "LinearMath/btIDebugDraw.h"
|
|
||||||
#include "GLDebugDrawer.h"
|
|
||||||
#include <stdio.h> //printf debugging
|
|
||||||
btScalar deltaTime = btScalar(1./60.);
|
|
||||||
#include "BasicDemo.h"
|
#include "BasicDemo.h"
|
||||||
#include "GL_ShapeDrawer.h"
|
|
||||||
#include "GlutStuff.h"
|
#include "GlutStuff.h"
|
||||||
|
///btBulletDynamicsCommon.h is the main Bullet include file, contains most common include files.
|
||||||
|
#include "btBulletDynamicsCommon.h"
|
||||||
|
#include <stdio.h> //printf debugging
|
||||||
|
|
||||||
#ifdef USE_PARALLEL_DISPATCHER
|
|
||||||
#include "../../Extras/BulletMultiThreaded/SpuGatheringCollisionDispatcher.h"
|
|
||||||
#include "../../Extras/BulletMultiThreaded/Win32ThreadSupport.h"
|
|
||||||
#include "../../Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.h"
|
|
||||||
#endif//USE_PARALLEL_DISPATCHER
|
|
||||||
|
|
||||||
|
|
||||||
#include <LinearMath/btAlignedObjectArray.h>
|
|
||||||
|
|
||||||
////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
class myTest
|
|
||||||
{
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern int gNumManifold;
|
|
||||||
extern int gOverlappingPairs;
|
|
||||||
extern int gTotalContactPoints;
|
|
||||||
|
|
||||||
void BasicDemo::clientMoveAndDisplay()
|
void BasicDemo::clientMoveAndDisplay()
|
||||||
{
|
{
|
||||||
@@ -77,24 +39,19 @@ void BasicDemo::clientMoveAndDisplay()
|
|||||||
//simple dynamics world doesn't handle fixed-time-stepping
|
//simple dynamics world doesn't handle fixed-time-stepping
|
||||||
float ms = m_clock.getTimeMicroseconds();
|
float ms = m_clock.getTimeMicroseconds();
|
||||||
m_clock.reset();
|
m_clock.reset();
|
||||||
float minFPS = 1000000.f/60.f;
|
|
||||||
if (ms > minFPS)
|
|
||||||
ms = minFPS;
|
|
||||||
|
|
||||||
|
///step the simulation
|
||||||
if (m_dynamicsWorld)
|
if (m_dynamicsWorld)
|
||||||
|
{
|
||||||
m_dynamicsWorld->stepSimulation(ms / 1000000.f);
|
m_dynamicsWorld->stepSimulation(ms / 1000000.f);
|
||||||
|
//optional but useful: debug drawing
|
||||||
|
m_dynamicsWorld->debugDrawWorld();
|
||||||
|
}
|
||||||
|
|
||||||
renderme();
|
renderme();
|
||||||
|
|
||||||
glFlush();
|
glFlush();
|
||||||
//some additional debugging info
|
|
||||||
#ifdef PRINT_CONTACT_STATISTICS
|
|
||||||
printf("num manifolds: %i\n",gNumManifold);
|
|
||||||
printf("num gOverlappingPairs: %i\n",gOverlappingPairs);
|
|
||||||
printf("num gTotalContactPoints : %i\n",gTotalContactPoints );
|
|
||||||
#endif //PRINT_CONTACT_STATISTICS
|
|
||||||
|
|
||||||
gTotalContactPoints = 0;
|
|
||||||
glutSwapBuffers();
|
glutSwapBuffers();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -107,6 +64,10 @@ void BasicDemo::displayCallback(void) {
|
|||||||
|
|
||||||
renderme();
|
renderme();
|
||||||
|
|
||||||
|
//optional but useful: debug drawing to detect problems
|
||||||
|
if (m_dynamicsWorld)
|
||||||
|
m_dynamicsWorld->debugDrawWorld();
|
||||||
|
|
||||||
glFlush();
|
glFlush();
|
||||||
glutSwapBuffers();
|
glutSwapBuffers();
|
||||||
}
|
}
|
||||||
@@ -120,73 +81,29 @@ void BasicDemo::initPhysics()
|
|||||||
|
|
||||||
setCameraDistance(btScalar(50.));
|
setCameraDistance(btScalar(50.));
|
||||||
|
|
||||||
|
///collision configuration contains default setup for memory, collision setup
|
||||||
m_collisionConfiguration = new btDefaultCollisionConfiguration();
|
m_collisionConfiguration = new btDefaultCollisionConfiguration();
|
||||||
|
|
||||||
#ifdef USE_PARALLEL_DISPATCHER
|
///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded)
|
||||||
|
|
||||||
#ifdef USE_WIN32_THREADING
|
|
||||||
|
|
||||||
int maxNumOutstandingTasks = 4;//number of maximum outstanding tasks
|
|
||||||
Win32ThreadSupport* threadSupport = new Win32ThreadSupport(Win32ThreadSupport::Win32ThreadConstructionInfo(
|
|
||||||
"collision",
|
|
||||||
processCollisionTask,
|
|
||||||
createCollisionLocalStoreMemory,
|
|
||||||
maxNumOutstandingTasks));
|
|
||||||
#else
|
|
||||||
///todo other platform threading
|
|
||||||
///Playstation 3 SPU (SPURS) version is available through PS3 Devnet
|
|
||||||
///Libspe2 SPU support will be available soon
|
|
||||||
///pthreads version
|
|
||||||
///you can hook it up to your custom task scheduler by deriving from btThreadSupportInterface
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
m_dispatcher = new SpuGatheringCollisionDispatcher(threadSupport,maxNumOutstandingTasks,collisionConfiguration);
|
|
||||||
#else
|
|
||||||
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
|
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
|
||||||
#endif //USE_PARALLEL_DISPATCHER
|
|
||||||
|
|
||||||
#define USE_SWEEP_AND_PRUNE 1
|
///the maximum size of the collision world. Make sure objects stay within these boundaries
|
||||||
#ifdef USE_SWEEP_AND_PRUNE
|
///Don't make the world AABB size too large, it will harm simulation quality and performance
|
||||||
#define maxProxies 8192
|
|
||||||
btVector3 worldAabbMin(-10000,-10000,-10000);
|
btVector3 worldAabbMin(-10000,-10000,-10000);
|
||||||
btVector3 worldAabbMax(10000,10000,10000);
|
btVector3 worldAabbMax(10000,10000,10000);
|
||||||
m_overlappingPairCache = new btAxisSweep3(worldAabbMin,worldAabbMax,maxProxies);
|
m_overlappingPairCache = new btAxisSweep3(worldAabbMin,worldAabbMax,MAX_PROXIES);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#else
|
|
||||||
m_overlappingPairCache = new btSimpleBroadphase;
|
|
||||||
#endif //USE_SWEEP_AND_PRUNE
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
///the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded)
|
||||||
btSequentialImpulseConstraintSolver* sol = new btSequentialImpulseConstraintSolver;
|
btSequentialImpulseConstraintSolver* sol = new btSequentialImpulseConstraintSolver;
|
||||||
m_solver = sol;
|
m_solver = sol;
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_SIMPLE_DYNAMICS_WORLD
|
|
||||||
//btSimpleDynamicsWorld doesn't support 'cache friendly' optimization, so disable this
|
|
||||||
sol->setSolverMode(btSequentialImpulseConstraintSolver::SOLVER_RANDMIZE_ORDER);
|
|
||||||
m_dynamicsWorld = new btSimpleDynamicsWorld(m_dispatcher,m_overlappingPairCache,m_solver,m_collisionConfiguration);
|
|
||||||
#else
|
|
||||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_overlappingPairCache,m_solver,m_collisionConfiguration);
|
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_overlappingPairCache,m_solver,m_collisionConfiguration);
|
||||||
#endif //USE_SIMPLE_DYNAMICS_WORLD
|
|
||||||
m_dynamicsWorld->getDispatchInfo().m_enableSPU = true;
|
|
||||||
|
|
||||||
m_dynamicsWorld->setGravity(btVector3(0,-10,0));
|
m_dynamicsWorld->setGravity(btVector3(0,-10,0));
|
||||||
|
|
||||||
|
|
||||||
///create a few basic rigid bodies
|
///create a few basic rigid bodies
|
||||||
|
|
||||||
|
|
||||||
//static ground
|
|
||||||
#ifdef USE_GROUND_BOX
|
|
||||||
btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.)));
|
btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.)));
|
||||||
#else
|
|
||||||
btCollisionShape* groundShape = new btSphereShape(btScalar(50.));
|
|
||||||
#endif//USE_GROUND_BOX
|
|
||||||
|
|
||||||
m_collisionShapes.push_back(groundShape);
|
m_collisionShapes.push_back(groundShape);
|
||||||
|
|
||||||
@@ -200,7 +117,7 @@ void BasicDemo::initPhysics()
|
|||||||
btCollisionShape* colShape = new btSphereShape(btScalar(1.));
|
btCollisionShape* colShape = new btSphereShape(btScalar(1.));
|
||||||
m_collisionShapes.push_back(colShape);
|
m_collisionShapes.push_back(colShape);
|
||||||
|
|
||||||
/// Create Dynamic Objects
|
/// Create Dynamic Objects
|
||||||
btTransform startTransform;
|
btTransform startTransform;
|
||||||
startTransform.setIdentity();
|
startTransform.setIdentity();
|
||||||
|
|
||||||
|
|||||||
@@ -21,15 +21,6 @@ subject to the following restrictions:
|
|||||||
#include "GL_ShapeDrawer.h"
|
#include "GL_ShapeDrawer.h"
|
||||||
#include "GlutStuff.h"
|
#include "GlutStuff.h"
|
||||||
|
|
||||||
//#define USE_PARALLEL_DISPATCHER 1
|
|
||||||
#ifdef USE_PARALLEL_DISPATCHER
|
|
||||||
#include "../../Extras/BulletMultiThreaded/SpuGatheringCollisionDispatcher.h"
|
|
||||||
#include "../../Extras/BulletMultiThreaded/Win32ThreadSupport.h"
|
|
||||||
#include "../../Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.h"
|
|
||||||
#endif//USE_PARALLEL_DISPATCHER
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static btVector3* gVertices=0;
|
static btVector3* gVertices=0;
|
||||||
static int* gIndices=0;
|
static int* gIndices=0;
|
||||||
@@ -226,64 +217,13 @@ public:
|
|||||||
|
|
||||||
static btConvexcastBatch convexcastBatch;
|
static btConvexcastBatch convexcastBatch;
|
||||||
|
|
||||||
///User can override this material combiner by implementing gContactAddedCallback and setting body0->m_collisionFlags |= btCollisionObject::customMaterialCallback;
|
|
||||||
inline btScalar calculateCombinedFriction(float friction0,float friction1)
|
|
||||||
{
|
|
||||||
btScalar friction = friction0 * friction1;
|
|
||||||
|
|
||||||
const btScalar MAX_FRICTION = 10.f;
|
|
||||||
if (friction < -MAX_FRICTION)
|
|
||||||
friction = -MAX_FRICTION;
|
|
||||||
if (friction > MAX_FRICTION)
|
|
||||||
friction = MAX_FRICTION;
|
|
||||||
return friction;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
inline btScalar calculateCombinedRestitution(float restitution0,float restitution1)
|
|
||||||
{
|
|
||||||
return restitution0 * restitution1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static bool CustomMaterialCombinerCallback(btManifoldPoint& cp, const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1)
|
|
||||||
{
|
|
||||||
|
|
||||||
float friction0 = colObj0->getFriction();
|
const int NUM_VERTS_X = 30;
|
||||||
float friction1 = colObj1->getFriction();
|
const int NUM_VERTS_Y = 30;
|
||||||
float restitution0 = colObj0->getRestitution();
|
const int totalVerts = NUM_VERTS_X*NUM_VERTS_Y;
|
||||||
float restitution1 = colObj1->getRestitution();
|
|
||||||
|
|
||||||
if (colObj0->getCollisionFlags() & btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK)
|
|
||||||
{
|
|
||||||
friction0 = 1.0;//partId0,index0
|
|
||||||
restitution0 = 0.f;
|
|
||||||
}
|
|
||||||
if (colObj1->getCollisionFlags() & btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK)
|
|
||||||
{
|
|
||||||
if (index1&1)
|
|
||||||
{
|
|
||||||
friction1 = 1.0f;//partId1,index1
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
friction1 = 0.f;
|
|
||||||
}
|
|
||||||
restitution1 = 0.f;
|
|
||||||
}
|
|
||||||
|
|
||||||
cp.m_combinedFriction = calculateCombinedFriction(friction0,friction1);
|
|
||||||
cp.m_combinedRestitution = calculateCombinedRestitution(restitution0,restitution1);
|
|
||||||
|
|
||||||
//this return value is currently ignored, but to be on the safe side: return false if you don't calculate friction
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern ContactAddedCallback gContactAddedCallback;
|
|
||||||
|
|
||||||
const int NUM_VERTS_X = 30;
|
|
||||||
const int NUM_VERTS_Y = 30;
|
|
||||||
const int totalVerts = NUM_VERTS_X*NUM_VERTS_Y;
|
|
||||||
|
|
||||||
void ConcaveConvexcastDemo::setVertexPositions(float waveheight, float offset)
|
void ConcaveConvexcastDemo::setVertexPositions(float waveheight, float offset)
|
||||||
{
|
{
|
||||||
@@ -326,10 +266,7 @@ void ConcaveConvexcastDemo::initPhysics()
|
|||||||
{
|
{
|
||||||
#define TRISIZE 10.f
|
#define TRISIZE 10.f
|
||||||
|
|
||||||
gContactAddedCallback = CustomMaterialCombinerCallback;
|
|
||||||
|
|
||||||
#define USE_TRIMESH_SHAPE 1
|
|
||||||
#ifdef USE_TRIMESH_SHAPE
|
|
||||||
|
|
||||||
int vertStride = sizeof(btVector3);
|
int vertStride = sizeof(btVector3);
|
||||||
int indexStride = 3*sizeof(int);
|
int indexStride = 3*sizeof(int);
|
||||||
@@ -367,99 +304,22 @@ void ConcaveConvexcastDemo::initPhysics()
|
|||||||
|
|
||||||
bool useQuantizedAabbCompression = true;
|
bool useQuantizedAabbCompression = true;
|
||||||
|
|
||||||
//comment out the next line to read the BVH from disk (first run the demo once to create the BVH)
|
|
||||||
#define SERIALIZE_TO_DISK 1
|
|
||||||
#ifdef SERIALIZE_TO_DISK
|
|
||||||
trimeshShape = new btBvhTriangleMeshShape(m_indexVertexArrays,useQuantizedAabbCompression);
|
trimeshShape = new btBvhTriangleMeshShape(m_indexVertexArrays,useQuantizedAabbCompression);
|
||||||
|
|
||||||
m_collisionShapes.push_back(trimeshShape);
|
m_collisionShapes.push_back(trimeshShape);
|
||||||
|
|
||||||
|
|
||||||
///we can serialize the BVH data
|
|
||||||
void* buffer = 0;
|
|
||||||
int numBytes = trimeshShape->getOptimizedBvh()->calculateSerializeBufferSize();
|
|
||||||
buffer = btAlignedAlloc(numBytes,16);
|
|
||||||
bool swapEndian = false;
|
|
||||||
trimeshShape->getOptimizedBvh()->serialize(buffer,numBytes,swapEndian);
|
|
||||||
FILE* file = fopen("bvh.bin","wb");
|
|
||||||
fwrite(buffer,1,numBytes,file);
|
|
||||||
fclose(file);
|
|
||||||
btAlignedFree(buffer);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
trimeshShape = new btBvhTriangleMeshShape(m_indexVertexArrays,useQuantizedAabbCompression,false);
|
|
||||||
|
|
||||||
char* fileName = "bvh.bin";
|
|
||||||
|
|
||||||
FILE* file = fopen(fileName,"rb");
|
|
||||||
int size=0;
|
|
||||||
btOptimizedBvh* bvh = 0;
|
|
||||||
|
|
||||||
if (fseek(file, 0, SEEK_END) || (size = ftell(file)) == EOF || fseek(file, 0, SEEK_SET)) { /* File operations denied? ok, just close and return failure */
|
|
||||||
printf("Error: cannot get filesize from %s\n", fileName);
|
|
||||||
exit(0);
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
|
|
||||||
fseek(file, 0, SEEK_SET);
|
|
||||||
|
|
||||||
int buffersize = size+btOptimizedBvh::getAlignmentSerializationPadding();
|
|
||||||
|
|
||||||
void* buffer = btAlignedAlloc(buffersize,16);
|
|
||||||
int read = fread(buffer,1,size,file);
|
|
||||||
fclose(file);
|
|
||||||
bool swapEndian = false;
|
|
||||||
bvh = btOptimizedBvh::deSerializeInPlace(buffer,buffersize,swapEndian);
|
|
||||||
}
|
|
||||||
|
|
||||||
trimeshShape->setOptimizedBvh(bvh);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
btCollisionShape* groundShape = trimeshShape;
|
btCollisionShape* groundShape = trimeshShape;
|
||||||
|
|
||||||
#else
|
|
||||||
btCollisionShape* groundShape = new btBoxShape(btVector3(50,3,50));
|
|
||||||
m_collisionShapes.push_back(groundShape);
|
|
||||||
|
|
||||||
#endif //USE_TRIMESH_SHAPE
|
|
||||||
|
|
||||||
m_collisionConfiguration = new btDefaultCollisionConfiguration();
|
m_collisionConfiguration = new btDefaultCollisionConfiguration();
|
||||||
|
|
||||||
#ifdef USE_PARALLEL_DISPATCHER
|
|
||||||
|
|
||||||
#ifdef USE_WIN32_THREADING
|
|
||||||
|
|
||||||
int maxNumOutstandingTasks = 4;//number of maximum outstanding tasks
|
|
||||||
Win32ThreadSupport* threadSupport = new Win32ThreadSupport(Win32ThreadSupport::Win32ThreadConstructionInfo(
|
|
||||||
"collision",
|
|
||||||
processCollisionTask,
|
|
||||||
createCollisionLocalStoreMemory,
|
|
||||||
maxNumOutstandingTasks));
|
|
||||||
#else
|
|
||||||
///todo other platform threading
|
|
||||||
///Playstation 3 SPU (SPURS) version is available through PS3 Devnet
|
|
||||||
///Libspe2 SPU support will be available soon
|
|
||||||
///pthreads version
|
|
||||||
///you can hook it up to your custom task scheduler by deriving from btThreadSupportInterface
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_dispatcher = new SpuGatheringCollisionDispatcher(threadSupport,maxNumOutstandingTasks,m_collisionConfiguration);
|
|
||||||
#else
|
|
||||||
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
|
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
|
||||||
#endif//USE_PARALLEL_DISPATCHER
|
|
||||||
|
|
||||||
|
|
||||||
btVector3 worldMin(-1000,-1000,-1000);
|
btVector3 worldMin(-1000,-1000,-1000);
|
||||||
btVector3 worldMax(1000,1000,1000);
|
btVector3 worldMax(1000,1000,1000);
|
||||||
m_broadphase = new btAxisSweep3(worldMin,worldMax);
|
m_broadphase = new btAxisSweep3(worldMin,worldMax);
|
||||||
m_solver = new btSequentialImpulseConstraintSolver();
|
m_solver = new btSequentialImpulseConstraintSolver();
|
||||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
|
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
|
||||||
#ifdef USE_PARALLEL_DISPATCHER
|
|
||||||
m_dynamicsWorld->getDispatchInfo().m_enableSPU=true;
|
|
||||||
#endif //USE_PARALLEL_DISPATCHER
|
|
||||||
|
|
||||||
float mass = 0.f;
|
float mass = 0.f;
|
||||||
btTransform startTransform;
|
btTransform startTransform;
|
||||||
|
|||||||
@@ -20,15 +20,6 @@ subject to the following restrictions:
|
|||||||
#include "GL_ShapeDrawer.h"
|
#include "GL_ShapeDrawer.h"
|
||||||
#include "GlutStuff.h"
|
#include "GlutStuff.h"
|
||||||
|
|
||||||
//#define USE_PARALLEL_DISPATCHER 1
|
|
||||||
#ifdef USE_PARALLEL_DISPATCHER
|
|
||||||
#include "../../Extras/BulletMultiThreaded/SpuGatheringCollisionDispatcher.h"
|
|
||||||
#include "../../Extras/BulletMultiThreaded/Win32ThreadSupport.h"
|
|
||||||
#include "../../Extras/BulletMultiThreaded/SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.h"
|
|
||||||
#endif//USE_PARALLEL_DISPATCHER
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static btVector3* gVertices=0;
|
static btVector3* gVertices=0;
|
||||||
static int* gIndices=0;
|
static int* gIndices=0;
|
||||||
@@ -211,27 +202,6 @@ public:
|
|||||||
|
|
||||||
static btRaycastBar raycastBar;
|
static btRaycastBar raycastBar;
|
||||||
|
|
||||||
///User can override this material combiner by implementing gContactAddedCallback and setting body0->m_collisionFlags |= btCollisionObject::customMaterialCallback;
|
|
||||||
inline btScalar calculateCombinedFriction(float friction0,float friction1)
|
|
||||||
{
|
|
||||||
btScalar friction = friction0 * friction1;
|
|
||||||
|
|
||||||
const btScalar MAX_FRICTION = 10.f;
|
|
||||||
if (friction < -MAX_FRICTION)
|
|
||||||
friction = -MAX_FRICTION;
|
|
||||||
if (friction > MAX_FRICTION)
|
|
||||||
friction = MAX_FRICTION;
|
|
||||||
return friction;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
inline btScalar calculateCombinedRestitution(float restitution0,float restitution1)
|
|
||||||
{
|
|
||||||
return restitution0 * restitution1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const int NUM_VERTS_X = 30;
|
const int NUM_VERTS_X = 30;
|
||||||
const int NUM_VERTS_Y = 30;
|
const int NUM_VERTS_Y = 30;
|
||||||
@@ -316,6 +286,7 @@ void ConcaveRaycastDemo::initPhysics()
|
|||||||
bool useQuantizedAabbCompression = true;
|
bool useQuantizedAabbCompression = true;
|
||||||
|
|
||||||
trimeshShape = new btBvhTriangleMeshShape(m_indexVertexArrays,useQuantizedAabbCompression);
|
trimeshShape = new btBvhTriangleMeshShape(m_indexVertexArrays,useQuantizedAabbCompression);
|
||||||
|
m_collisionShapes.push_back(trimeshShape);
|
||||||
|
|
||||||
btCollisionShape* groundShape = trimeshShape;
|
btCollisionShape* groundShape = trimeshShape;
|
||||||
|
|
||||||
@@ -449,6 +420,7 @@ void ConcaveRaycastDemo::exitPhysics()
|
|||||||
|
|
||||||
delete m_collisionConfiguration;
|
delete m_collisionConfiguration;
|
||||||
|
|
||||||
|
delete[] gVertices;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -328,7 +328,10 @@ void MotorDemo::clientMoveAndDisplay()
|
|||||||
|
|
||||||
|
|
||||||
if (m_dynamicsWorld)
|
if (m_dynamicsWorld)
|
||||||
|
{
|
||||||
m_dynamicsWorld->stepSimulation(ms / 1000000.f);
|
m_dynamicsWorld->stepSimulation(ms / 1000000.f);
|
||||||
|
m_dynamicsWorld->debugDrawWorld();
|
||||||
|
}
|
||||||
|
|
||||||
renderme();
|
renderme();
|
||||||
|
|
||||||
@@ -349,7 +352,7 @@ void MotorDemo::displayCallback()
|
|||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
if (m_dynamicsWorld)
|
if (m_dynamicsWorld)
|
||||||
m_dynamicsWorld->updateAabbs();
|
m_dynamicsWorld->debugDrawWorld();
|
||||||
|
|
||||||
renderme();
|
renderme();
|
||||||
|
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ public:
|
|||||||
|
|
||||||
void debugDrawObject(const btTransform& worldTransform, const btCollisionShape* shape, const btVector3& color);
|
void debugDrawObject(const btTransform& worldTransform, const btCollisionShape* shape, const btVector3& color);
|
||||||
|
|
||||||
void debugDrawWorld();
|
virtual void debugDrawWorld();
|
||||||
|
|
||||||
virtual void setConstraintSolver(btConstraintSolver* solver);
|
virtual void setConstraintSolver(btConstraintSolver* solver);
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ class btDynamicsWorld : public btCollisionWorld
|
|||||||
|
|
||||||
virtual void updateAabbs() = 0;
|
virtual void updateAabbs() = 0;
|
||||||
|
|
||||||
|
virtual void debugDrawWorld() = 0;
|
||||||
|
|
||||||
virtual void addConstraint(btTypedConstraint* constraint, bool disableCollisionsBetweenLinkedBodies=false) { (void)constraint;};
|
virtual void addConstraint(btTypedConstraint* constraint, bool disableCollisionsBetweenLinkedBodies=false) { (void)constraint;};
|
||||||
|
|
||||||
virtual void removeConstraint(btTypedConstraint* constraint) {(void)constraint;};
|
virtual void removeConstraint(btTypedConstraint* constraint) {(void)constraint;};
|
||||||
|
|||||||
Reference in New Issue
Block a user