Fix Issue 680, compilation error using Visual Studio 2005, service pack 1, quicksort compare function needs to be in a class.

Toggle between GJK and SAT (initializePolyhedralFeatures) in convexDecomposition at easch restart of the demo (spacebar)
This commit is contained in:
erwin.coumans
2012-12-17 20:38:31 +00:00
parent c4548ec746
commit 7e14e79da0
4 changed files with 28 additions and 15 deletions

View File

@@ -28,7 +28,8 @@ subject to the following restrictions:
#include "LinearMath/btIDebugDraw.h"
#include "LinearMath/btGeometryUtil.h"
#include "BulletCollision/CollisionShapes/btShapeHull.h"
#include "GLDebugDrawer.h"
GLDebugDrawer gDebugDrawer;
//#define TEST_SERIALIZATION
//#define NO_OBJ_TO_BULLET
@@ -69,6 +70,8 @@ btVector3 convexDecompositionObjectOffset(10,0,0);
unsigned int tcount = 0;
//sEnableSAT creates the data structures required for performing SAT tests between convex polyhedra, as alternative to GJK
bool sEnableSAT = false;
void ConvexDecompositionDemo::initPhysics()
{
@@ -153,11 +156,14 @@ m_collisionConfiguration = new btDefaultCollisionConfiguration();
void ConvexDecompositionDemo::initPhysics(const char* filename)
{
sEnableSAT = !sEnableSAT;
gContactAddedCallback = &MyContactCallback;
setupEmptyDynamicsWorld();
getDynamicsWorld()->setDebugDrawer(&gDebugDrawer);
setTexturing(true);
setShadows(true);
@@ -327,7 +333,8 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
btConvexHullShape* convexShape = new btConvexHullShape(&(vertices[0].getX()),vertices.size());
#endif
if (sEnableSAT)
convexShape->initializePolyhedralFeatures();
convexShape->setMargin(0.01f);
m_convexShapes.push_back(convexShape);
m_convexCentroids.push_back(centroid);
@@ -395,6 +402,8 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
convexShape->addPoint(hull->getVertexPointer()[i]);
}
if (sEnableSAT)
convexShape->initializePolyhedralFeatures();
delete tmpConvexShape;
delete hull;
@@ -737,5 +746,8 @@ void ConvexDecompositionDemo::exitPhysics()
}
void ConvexDecompositionDemo::clientResetScene()
{
exitPhysics();
initPhysics("file.obj");
}

View File

@@ -64,6 +64,8 @@ public:
void exitPhysics();
virtual void clientResetScene();
virtual ~ConvexDecompositionDemo()
{
exitPhysics();

View File

@@ -6,7 +6,6 @@
#include "btBulletDynamicsCommon.h"
GLDebugDrawer gDebugDrawer;
int main(int argc,char** argv)
{
@@ -17,13 +16,9 @@ int main(int argc,char** argv)
convexDecompDemo->initPhysics(filename);
convexDecompDemo->getDynamicsWorld()->setDebugDrawer(&gDebugDrawer);
convexDecompDemo->clientResetScene();
glutmain(argc, argv,640,480,"Bullet Physics Demo. http://www.continuousphysics.com/Bullet/phpBB2/",convexDecompDemo);
delete convexDecompDemo;

View File

@@ -1931,11 +1931,15 @@ void btConvexHullInternal::merge(IntermediateHull& h0, IntermediateHull& h1)
}
}
static bool pointCmp(const btConvexHullInternal::Point32& p, const btConvexHullInternal::Point32& q)
class pointCmp
{
return (p.y < q.y) || ((p.y == q.y) && ((p.x < q.x) || ((p.x == q.x) && (p.z < q.z))));
}
public:
bool operator() ( const btConvexHullInternal::Point32& p, const btConvexHullInternal::Point32& q ) const
{
return (p.y < q.y) || ((p.y == q.y) && ((p.x < q.x) || ((p.x == q.x) && (p.z < q.z))));
}
};
void btConvexHullInternal::compute(const void* coords, bool doubleCoords, int stride, int count)
{
@@ -2026,7 +2030,7 @@ void btConvexHullInternal::compute(const void* coords, bool doubleCoords, int st
points[i].index = i;
}
}
points.quickSort(pointCmp);
points.quickSort(pointCmp());
vertexPool.reset();
vertexPool.setArraySize(count);