integrated StressTest into BasicDemo.
This commit is contained in:
@@ -19,6 +19,16 @@ subject to the following restrictions:
|
|||||||
//#define CHECK_MEMORY_LEAKS 1
|
//#define CHECK_MEMORY_LEAKS 1
|
||||||
//#define USE_PARALLEL_DISPATCHER 1
|
//#define USE_PARALLEL_DISPATCHER 1
|
||||||
|
|
||||||
|
#define START_POS_X -5
|
||||||
|
#define START_POS_Y -5
|
||||||
|
#define START_POS_Z -3
|
||||||
|
|
||||||
|
|
||||||
|
///create 1000 (10x10x10) dynamic objects
|
||||||
|
#define ARRAY_SIZE_X 10
|
||||||
|
#define ARRAY_SIZE_Y 10
|
||||||
|
#define ARRAY_SIZE_Z 10
|
||||||
|
|
||||||
|
|
||||||
//#define USE_SIMPLE_DYNAMICS_WORLD 1
|
//#define USE_SIMPLE_DYNAMICS_WORLD 1
|
||||||
|
|
||||||
@@ -201,34 +211,42 @@ void BasicDemo::initPhysics()
|
|||||||
|
|
||||||
btTransform groundTransform;
|
btTransform groundTransform;
|
||||||
groundTransform.setIdentity();
|
groundTransform.setIdentity();
|
||||||
groundTransform.setOrigin(btVector3(0,-50,0));
|
groundTransform.setOrigin(btVector3(0,-56,0));
|
||||||
localCreateRigidBody(btScalar(0.),groundTransform,groundShape);
|
localCreateRigidBody(btScalar(0.),groundTransform,groundShape);
|
||||||
|
|
||||||
//create a few dynamic sphere rigidbodies (re-using the same sphere shape)
|
//create a few dynamic sphere rigidbodies (re-using the same sphere shape)
|
||||||
//btCollisionShape* sphereShape = new btBoxShape(btVector3(1,1,1));
|
//btCollisionShape* sphereShape = new btBoxShape(btVector3(1,1,1));
|
||||||
btCollisionShape* sphereShape = new btSphereShape(btScalar(1.));
|
btCollisionShape* colShape = new btSphereShape(btScalar(1.));
|
||||||
m_collisionShapes.push_back(sphereShape);
|
m_collisionShapes.push_back(colShape);
|
||||||
|
|
||||||
|
/// Create Dynamic Objects
|
||||||
|
btTransform startTransform;
|
||||||
|
startTransform.setIdentity();
|
||||||
|
|
||||||
int i;
|
|
||||||
for (i=0;i<gNumObjects;i++)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
sphereShape->setMargin(gCollisionMargin);
|
|
||||||
btTransform trans;
|
|
||||||
trans.setIdentity();
|
|
||||||
//stack them
|
|
||||||
int colsize = 2;
|
|
||||||
int row = (int)((i*HALF_EXTENTS*2)/(colsize*2*HALF_EXTENTS));
|
|
||||||
int row2 = row;
|
|
||||||
int col = (i)%(colsize)-colsize/2;
|
|
||||||
btVector3 pos(col*2*HALF_EXTENTS + (row2%2)*HALF_EXTENTS,
|
|
||||||
row*2*HALF_EXTENTS+HALF_EXTENTS,0);
|
|
||||||
|
|
||||||
trans.setOrigin(pos);
|
float start_x = START_POS_X - ARRAY_SIZE_X/2;
|
||||||
//btRigidBody* body = localCreateRigidBody(btScalar(1.),trans,sphereShape);
|
float start_y = START_POS_Y;
|
||||||
localCreateRigidBody(btScalar(1.),trans,sphereShape);
|
float start_z = START_POS_Z - ARRAY_SIZE_Z/2;
|
||||||
|
|
||||||
|
for (int k=0;k<ARRAY_SIZE_Y;k++)
|
||||||
|
{
|
||||||
|
for (int i=0;i<ARRAY_SIZE_X;i++)
|
||||||
|
{
|
||||||
|
for(int j = 0;j<ARRAY_SIZE_Z;j++)
|
||||||
|
{
|
||||||
|
startTransform.setOrigin(btVector3(
|
||||||
|
2.0*i + start_x,
|
||||||
|
2.0*k + start_y,
|
||||||
|
2.0*j + start_z));
|
||||||
|
|
||||||
|
localCreateRigidBody(1, startTransform,colShape);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
clientResetScene();
|
clientResetScene();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,377 +0,0 @@
|
|||||||
/*
|
|
||||||
Bullet Continuous Collision Detection and Physics Library
|
|
||||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied warranty.
|
|
||||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
|
||||||
subject to the following restrictions:
|
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "btBulletDynamicsCommon.h"
|
|
||||||
#include "StressTestDemo.h"
|
|
||||||
|
|
||||||
#define SHOW_NUM_DEEP_PENETRATIONS
|
|
||||||
|
|
||||||
#include "LinearMath/btDefaultMotionState.h"
|
|
||||||
#include "LinearMath/btIDebugDraw.h"
|
|
||||||
#include "LinearMath/btQuickprof.h"
|
|
||||||
#include "LinearMath/btDefaultMotionState.h"
|
|
||||||
#include "BulletCollision/BroadphaseCollision/btMultiSapBroadphase.h"
|
|
||||||
|
|
||||||
#include "BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.h"
|
|
||||||
|
|
||||||
//#define REGISTER_BOX_BOX 1
|
|
||||||
#ifdef REGISTER_BOX_BOX
|
|
||||||
#include "../Extras/AlternativeCollisionAlgorithms/BoxBoxCollisionAlgorithm.h"
|
|
||||||
#endif //REGISTER_BOX_BOX
|
|
||||||
|
|
||||||
|
|
||||||
//#define SHOW_MEMORY_DETAILS 1
|
|
||||||
|
|
||||||
//#ifdef SHOW_MEMORY_DETAILS
|
|
||||||
// #include "LinearMath/btGenericPoolAllocator.h"
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
/// Including GIMPACT here
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "BMF_Api.h"
|
|
||||||
|
|
||||||
#include "GLDebugDrawer.h"
|
|
||||||
|
|
||||||
#include "GL_ShapeDrawer.h"
|
|
||||||
#include "GlutStuff.h"
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef SHOW_NUM_DEEP_PENETRATIONS
|
|
||||||
extern int gNumDeepPenetrationChecks;
|
|
||||||
extern int gNumGjkChecks;
|
|
||||||
#endif //
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GLDebugDrawer debugDrawer;
|
|
||||||
//Real dts = 0.000001f;
|
|
||||||
btScalar dts = 1.0 / 60.0;
|
|
||||||
|
|
||||||
|
|
||||||
///**************************************************************************************
|
|
||||||
/// GIMPACT Test Demo made by DevO
|
|
||||||
///
|
|
||||||
///**************************************************************************************
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
///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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bool CustomMaterialCombinerCallback(btManifoldPoint& cp, const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1)
|
|
||||||
{
|
|
||||||
|
|
||||||
float friction0 = colObj0->getFriction();
|
|
||||||
float friction1 = colObj1->getFriction();
|
|
||||||
float restitution0 = colObj0->getRestitution();
|
|
||||||
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;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//################################## main #####################################
|
|
||||||
int main(int argc,char** argv)
|
|
||||||
{
|
|
||||||
//gContactAddedCallback = CustomMaterialCombinerCallback;
|
|
||||||
|
|
||||||
int sizeofbp = sizeof(btBroadphaseProxy);
|
|
||||||
|
|
||||||
StressTestDemo* concaveDemo = new StressTestDemo(); /// This will not be Deleted!!!
|
|
||||||
concaveDemo->initPhysics();
|
|
||||||
concaveDemo->setCameraDistance(45.f);
|
|
||||||
|
|
||||||
//cannot run stepFront yet, the OpenGL context is not opened (stepFront updates camera...)
|
|
||||||
// concaveDemo->stepFront();
|
|
||||||
// concaveDemo->stepFront();
|
|
||||||
// concaveDemo->stepFront();
|
|
||||||
// concaveDemo->stepFront();
|
|
||||||
|
|
||||||
return glutmain(argc, argv,640,480,"DevO,s GIMPACT Test Demo",concaveDemo);
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void StressTestDemo::initPhysics()
|
|
||||||
{
|
|
||||||
/// Init Bullet
|
|
||||||
m_collisionConfiguration = new btDefaultCollisionConfiguration();
|
|
||||||
|
|
||||||
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
|
|
||||||
|
|
||||||
#ifdef REGISTER_BOX_BOX
|
|
||||||
m_dispatcher->registerCollisionCreateFunc(BOX_SHAPE_PROXYTYPE,BOX_SHAPE_PROXYTYPE,new BoxBoxCollisionAlgorithm::CreateFunc);
|
|
||||||
#endif //REGISTER_BOX_BOX
|
|
||||||
|
|
||||||
|
|
||||||
LONG maxProxies = 4096;
|
|
||||||
btVector3 worldAabbMin(-1000,-1000,-1000);
|
|
||||||
btVector3 worldAabbMax( 1000, 1000, 1000);
|
|
||||||
m_broadphase = new btAxisSweep3(worldAabbMin,worldAabbMax,maxProxies);
|
|
||||||
//m_broadphase = new btMultiSapBroadphase();
|
|
||||||
//m_broadphase = new btSimpleBroadphase();
|
|
||||||
|
|
||||||
btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver();;
|
|
||||||
m_constraintSolver = solver;
|
|
||||||
|
|
||||||
btDiscreteDynamicsWorld* world = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_constraintSolver);
|
|
||||||
world->getSolverInfo().m_numIterations = 4;
|
|
||||||
// solver->setSolverMode(btSequentialImpulseConstraintSolver::SOLVER_CACHE_FRIENDLY);//btSequentialImpulseConstraintSolver::SOLVER_RANDMIZE_ORDER);
|
|
||||||
// solver->setSolverMode(btSequentialImpulseConstraintSolver::SOLVER_RANDMIZE_ORDER);
|
|
||||||
|
|
||||||
m_dynamicsWorld = world;
|
|
||||||
m_dynamicsWorld->setDebugDrawer(&debugDrawer);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// register algorithm
|
|
||||||
if(0)
|
|
||||||
{
|
|
||||||
m_spheresphere_collisionCreateFunc = new btSphereSphereCollisionAlgorithm::CreateFunc; /// NEW
|
|
||||||
|
|
||||||
m_dispatcher->registerCollisionCreateFunc(SPHERE_SHAPE_PROXYTYPE,SPHERE_SHAPE_PROXYTYPE,m_spheresphere_collisionCreateFunc);
|
|
||||||
|
|
||||||
m_spherebox_collisionCreateFunc = new btSphereBoxCollisionAlgorithm::CreateFunc;
|
|
||||||
|
|
||||||
m_dispatcher->registerCollisionCreateFunc(SPHERE_SHAPE_PROXYTYPE,BOX_SHAPE_PROXYTYPE,m_spherebox_collisionCreateFunc);
|
|
||||||
|
|
||||||
m_dispatcher->registerCollisionCreateFunc(SPHERE_SHAPE_PROXYTYPE,BOX_SHAPE_PROXYTYPE,m_spherebox_collisionCreateFunc);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//create trimesh model and shape
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Create Scene
|
|
||||||
float mass = 0.f;
|
|
||||||
btTransform startTransform;
|
|
||||||
startTransform.setIdentity();
|
|
||||||
|
|
||||||
btCollisionShape* staticboxShape1 = new btBoxShape(btVector3(20,1,20));//floor
|
|
||||||
btCollisionShape* staticboxShape2 = new btBoxShape(btVector3(1,50,200));//left wall
|
|
||||||
btCollisionShape* staticboxShape3 = new btBoxShape(btVector3(1,50,200));//right wall
|
|
||||||
btCollisionShape* staticboxShape4 = new btBoxShape(btVector3(200,50,1));//front wall
|
|
||||||
btCollisionShape* staticboxShape5 = new btBoxShape(btVector3(200,50,1));//back wall
|
|
||||||
#ifdef USE_COMPOUND
|
|
||||||
|
|
||||||
btCompoundShape* staticScenario = new btCompoundShape();//static scenario
|
|
||||||
|
|
||||||
startTransform.setOrigin(btVector3(0,-10,0));
|
|
||||||
staticScenario->addChildShape(startTransform,staticboxShape1);
|
|
||||||
startTransform.setOrigin(btVector3(-200,15,0));
|
|
||||||
staticScenario->addChildShape(startTransform,staticboxShape2);
|
|
||||||
startTransform.setOrigin(btVector3(200,15,0));
|
|
||||||
staticScenario->addChildShape(startTransform,staticboxShape3);
|
|
||||||
startTransform.setOrigin(btVector3(0,15,200));
|
|
||||||
staticScenario->addChildShape(startTransform,staticboxShape4);
|
|
||||||
startTransform.setOrigin(btVector3(0,15,-200));
|
|
||||||
staticScenario->addChildShape(startTransform,staticboxShape5);
|
|
||||||
|
|
||||||
startTransform.setOrigin(btVector3(0,0,0));
|
|
||||||
|
|
||||||
btRigidBody* staticBody = localCreateRigidBody(mass, startTransform,staticScenario);
|
|
||||||
#else
|
|
||||||
startTransform.setOrigin(btVector3(0,-7,0));//;//-10,0));
|
|
||||||
btRigidBody* staticBody = localCreateRigidBody(mass, startTransform,staticboxShape1);
|
|
||||||
/*startTransform.setOrigin(btVector3(-200,15,0));
|
|
||||||
staticBody = localCreateRigidBody(mass, startTransform,staticboxShape2);
|
|
||||||
startTransform.setOrigin(btVector3(200,15,0));
|
|
||||||
staticBody = localCreateRigidBody(mass, startTransform,staticboxShape3);
|
|
||||||
startTransform.setOrigin(btVector3(0,15,200));
|
|
||||||
staticBody = localCreateRigidBody(mass, startTransform,staticboxShape4);
|
|
||||||
startTransform.setOrigin(btVector3(0,15,-200));
|
|
||||||
staticBody = localCreateRigidBody(mass, startTransform,staticboxShape5);
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif //USE_COMPOUND
|
|
||||||
|
|
||||||
//enable custom material callback
|
|
||||||
// staticBody->setCollisionFlags(staticBody->getCollisionFlags()|btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
|
|
||||||
|
|
||||||
startTransform.setIdentity();
|
|
||||||
btCollisionShape* sphShape = new btSphereShape(1);
|
|
||||||
btScalar radii[1] = {btScalar(1)};
|
|
||||||
btVector3 poss[1]={btVector3(0,0,0)};
|
|
||||||
|
|
||||||
// btCollisionShape* sphShape = new btMultiSphereShape(btVector3(1,1,1),&poss[0],&radii[0],1);
|
|
||||||
|
|
||||||
btScalar margin(0.04);
|
|
||||||
btCollisionShape* boxShape = new btBoxShape(btVector3(1,1,1));//1.-margin,1.-margin,1.-margin));
|
|
||||||
boxShape->setMargin(margin);
|
|
||||||
|
|
||||||
|
|
||||||
/// Create Dynamic Boxes
|
|
||||||
{
|
|
||||||
|
|
||||||
float start_x = START_POS_X - ARRAY_SIZE_X/2;
|
|
||||||
float start_y = START_POS_Y;
|
|
||||||
float start_z = START_POS_Z - ARRAY_SIZE_Z/2;
|
|
||||||
|
|
||||||
for (int k=0;k<ARRAY_SIZE_Y;k++)
|
|
||||||
{
|
|
||||||
for (int i=0;i<ARRAY_SIZE_X;i++)
|
|
||||||
{
|
|
||||||
for(int j = 0;j<ARRAY_SIZE_Z;j++)
|
|
||||||
{
|
|
||||||
startTransform.setOrigin(btVector3(
|
|
||||||
2.0*i + start_x,
|
|
||||||
2.0*k + start_y,
|
|
||||||
2.0*j + start_z));
|
|
||||||
|
|
||||||
#ifdef SPHERES
|
|
||||||
|
|
||||||
localCreateRigidBody(1, startTransform,sphShape);
|
|
||||||
#else
|
|
||||||
localCreateRigidBody(1, startTransform,boxShape);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//m_debugMode |= btIDebugDraw::DBG_DrawWireframe;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void StressTestDemo::clientMoveAndDisplay()
|
|
||||||
{
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
|
|
||||||
int start, end;
|
|
||||||
|
|
||||||
start = glutGet(GLUT_ELAPSED_TIME);
|
|
||||||
|
|
||||||
float dt = float(m_clock.getTimeMicroseconds()) * 0.000001f;
|
|
||||||
|
|
||||||
m_clock.reset();
|
|
||||||
m_dynamicsWorld->stepSimulation(dt,1);
|
|
||||||
m_steps_done++;
|
|
||||||
|
|
||||||
end = glutGet(GLUT_ELAPSED_TIME);
|
|
||||||
printf("Time %d \n", end-start);
|
|
||||||
|
|
||||||
renderme();
|
|
||||||
|
|
||||||
glFlush();
|
|
||||||
glutSwapBuffers();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void StressTestDemo::displayCallback(void) {
|
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
|
|
||||||
renderme();
|
|
||||||
|
|
||||||
glFlush();
|
|
||||||
glutSwapBuffers();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void StressTestDemo::clientResetScene()
|
|
||||||
{
|
|
||||||
m_steps_done = 0;
|
|
||||||
DemoApplication::clientResetScene();
|
|
||||||
}
|
|
||||||
|
|
||||||
#define KEY_ESCAPE 0x1B
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void StressTestDemo::keyboardCallback(unsigned char key, int x, int y)
|
|
||||||
{
|
|
||||||
switch (key)
|
|
||||||
{
|
|
||||||
case '.':
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case '2':
|
|
||||||
{
|
|
||||||
dts += 0.000001f;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case '3':
|
|
||||||
{
|
|
||||||
dts -= 0.000001f; if(dts<0.000001f) dts = 0.000001f;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
DemoApplication::keyboardCallback(key, x, y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,99 +0,0 @@
|
|||||||
/*
|
|
||||||
Bullet Continuous Collision Detection and Physics Library
|
|
||||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied warranty.
|
|
||||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
|
||||||
subject to the following restrictions:
|
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
|
||||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
|
||||||
*/
|
|
||||||
#ifndef TEST_CONCAVE_DEMO_H
|
|
||||||
#define TEST_CONCAVE_DEMO_H
|
|
||||||
|
|
||||||
#include "DemoApplication.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct btCollisionAlgorithmCreateFunc;
|
|
||||||
|
|
||||||
///StressTestDemo shows usage of static concave triangle meshes
|
|
||||||
///It also shows per-triangle material (friction/restitution) through CustomMaterialCombinerCallback
|
|
||||||
class StressTestDemo : public DemoApplication
|
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
|
||||||
StressTestDemo()
|
|
||||||
: m_collisionConfiguration(NULL),
|
|
||||||
m_dispatcher(NULL),
|
|
||||||
m_broadphase(NULL),
|
|
||||||
m_constraintSolver(NULL),
|
|
||||||
m_steps_done(0),
|
|
||||||
m_spheresphere_collisionCreateFunc(0),
|
|
||||||
m_spherebox_collisionCreateFunc(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~StressTestDemo()
|
|
||||||
{
|
|
||||||
delete m_spheresphere_collisionCreateFunc;
|
|
||||||
delete m_spherebox_collisionCreateFunc;
|
|
||||||
|
|
||||||
delete m_collisionConfiguration;
|
|
||||||
delete m_dispatcher;
|
|
||||||
delete m_broadphase;
|
|
||||||
delete m_constraintSolver;
|
|
||||||
|
|
||||||
delete m_dynamicsWorld;
|
|
||||||
}
|
|
||||||
|
|
||||||
void initGImpactCollision();
|
|
||||||
void initPhysics();
|
|
||||||
|
|
||||||
virtual void clientMoveAndDisplay();
|
|
||||||
|
|
||||||
virtual void displayCallback();
|
|
||||||
|
|
||||||
virtual void clientResetScene();
|
|
||||||
|
|
||||||
virtual void keyboardCallback(unsigned char key, int x, int y);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public: ///data
|
|
||||||
unsigned int m_steps_done;
|
|
||||||
|
|
||||||
|
|
||||||
btVector3 kinTorusTran;
|
|
||||||
btQuaternion kinTorusRot;
|
|
||||||
btRigidBody *kinematicTorus;
|
|
||||||
|
|
||||||
|
|
||||||
btCollisionAlgorithmCreateFunc* m_spheresphere_collisionCreateFunc;
|
|
||||||
btCollisionAlgorithmCreateFunc* m_spherebox_collisionCreateFunc;
|
|
||||||
|
|
||||||
btDefaultCollisionConfiguration* m_collisionConfiguration;
|
|
||||||
btCollisionDispatcher* m_dispatcher;
|
|
||||||
btBroadphaseInterface* m_broadphase;
|
|
||||||
btConstraintSolver* m_constraintSolver;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#define SPHERES 1
|
|
||||||
|
|
||||||
#define START_POS_X -5
|
|
||||||
#define START_POS_Y -5
|
|
||||||
#define START_POS_Z -3
|
|
||||||
|
|
||||||
|
|
||||||
#define ARRAY_SIZE_X 10
|
|
||||||
#define ARRAY_SIZE_Y 10
|
|
||||||
#define ARRAY_SIZE_Z 10
|
|
||||||
|
|
||||||
#endif //CONCAVE_DEMO_H
|
|
||||||
|
|
||||||
@@ -43,25 +43,25 @@ m_localScaling(btScalar(1.),btScalar(1.),btScalar(1.))
|
|||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
halfExtents.setValue(
|
halfExtents.setValue(
|
||||||
m_maxHeight,
|
btScalar(m_maxHeight),
|
||||||
m_width,
|
btScalar(m_width),
|
||||||
m_length);
|
btScalar(m_length));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
halfExtents.setValue(
|
halfExtents.setValue(
|
||||||
m_width,
|
btScalar(m_width),
|
||||||
m_maxHeight,
|
btScalar(m_maxHeight),
|
||||||
m_length);
|
btScalar(m_length));
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
halfExtents.setValue(
|
halfExtents.setValue(
|
||||||
m_width,
|
btScalar(m_width),
|
||||||
m_length,
|
btScalar(m_length),
|
||||||
m_maxHeight
|
btScalar(m_maxHeight)
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user