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:
@@ -28,7 +28,8 @@ subject to the following restrictions:
|
|||||||
#include "LinearMath/btIDebugDraw.h"
|
#include "LinearMath/btIDebugDraw.h"
|
||||||
#include "LinearMath/btGeometryUtil.h"
|
#include "LinearMath/btGeometryUtil.h"
|
||||||
#include "BulletCollision/CollisionShapes/btShapeHull.h"
|
#include "BulletCollision/CollisionShapes/btShapeHull.h"
|
||||||
|
#include "GLDebugDrawer.h"
|
||||||
|
GLDebugDrawer gDebugDrawer;
|
||||||
//#define TEST_SERIALIZATION
|
//#define TEST_SERIALIZATION
|
||||||
//#define NO_OBJ_TO_BULLET
|
//#define NO_OBJ_TO_BULLET
|
||||||
|
|
||||||
@@ -69,6 +70,8 @@ btVector3 convexDecompositionObjectOffset(10,0,0);
|
|||||||
|
|
||||||
unsigned int tcount = 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()
|
void ConvexDecompositionDemo::initPhysics()
|
||||||
{
|
{
|
||||||
@@ -153,11 +156,14 @@ m_collisionConfiguration = new btDefaultCollisionConfiguration();
|
|||||||
void ConvexDecompositionDemo::initPhysics(const char* filename)
|
void ConvexDecompositionDemo::initPhysics(const char* filename)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
sEnableSAT = !sEnableSAT;
|
||||||
|
|
||||||
gContactAddedCallback = &MyContactCallback;
|
gContactAddedCallback = &MyContactCallback;
|
||||||
|
|
||||||
setupEmptyDynamicsWorld();
|
setupEmptyDynamicsWorld();
|
||||||
|
|
||||||
|
getDynamicsWorld()->setDebugDrawer(&gDebugDrawer);
|
||||||
|
|
||||||
setTexturing(true);
|
setTexturing(true);
|
||||||
setShadows(true);
|
setShadows(true);
|
||||||
|
|
||||||
@@ -327,7 +333,8 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
|
|||||||
|
|
||||||
btConvexHullShape* convexShape = new btConvexHullShape(&(vertices[0].getX()),vertices.size());
|
btConvexHullShape* convexShape = new btConvexHullShape(&(vertices[0].getX()),vertices.size());
|
||||||
#endif
|
#endif
|
||||||
|
if (sEnableSAT)
|
||||||
|
convexShape->initializePolyhedralFeatures();
|
||||||
convexShape->setMargin(0.01f);
|
convexShape->setMargin(0.01f);
|
||||||
m_convexShapes.push_back(convexShape);
|
m_convexShapes.push_back(convexShape);
|
||||||
m_convexCentroids.push_back(centroid);
|
m_convexCentroids.push_back(centroid);
|
||||||
@@ -395,6 +402,8 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
|
|||||||
convexShape->addPoint(hull->getVertexPointer()[i]);
|
convexShape->addPoint(hull->getVertexPointer()[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sEnableSAT)
|
||||||
|
convexShape->initializePolyhedralFeatures();
|
||||||
delete tmpConvexShape;
|
delete tmpConvexShape;
|
||||||
delete hull;
|
delete hull;
|
||||||
|
|
||||||
@@ -737,5 +746,8 @@ void ConvexDecompositionDemo::exitPhysics()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ConvexDecompositionDemo::clientResetScene()
|
||||||
|
{
|
||||||
|
exitPhysics();
|
||||||
|
initPhysics("file.obj");
|
||||||
|
}
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ public:
|
|||||||
|
|
||||||
void exitPhysics();
|
void exitPhysics();
|
||||||
|
|
||||||
|
virtual void clientResetScene();
|
||||||
|
|
||||||
virtual ~ConvexDecompositionDemo()
|
virtual ~ConvexDecompositionDemo()
|
||||||
{
|
{
|
||||||
exitPhysics();
|
exitPhysics();
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
#include "btBulletDynamicsCommon.h"
|
#include "btBulletDynamicsCommon.h"
|
||||||
|
|
||||||
|
|
||||||
GLDebugDrawer gDebugDrawer;
|
|
||||||
|
|
||||||
int main(int argc,char** argv)
|
int main(int argc,char** argv)
|
||||||
{
|
{
|
||||||
@@ -17,10 +16,6 @@ int main(int argc,char** argv)
|
|||||||
|
|
||||||
convexDecompDemo->initPhysics(filename);
|
convexDecompDemo->initPhysics(filename);
|
||||||
|
|
||||||
convexDecompDemo->getDynamicsWorld()->setDebugDrawer(&gDebugDrawer);
|
|
||||||
|
|
||||||
|
|
||||||
convexDecompDemo->clientResetScene();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1931,11 +1931,15 @@ void btConvexHullInternal::merge(IntermediateHull& h0, IntermediateHull& h1)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class pointCmp
|
||||||
static bool pointCmp(const btConvexHullInternal::Point32& p, const btConvexHullInternal::Point32& q)
|
|
||||||
{
|
{
|
||||||
|
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))));
|
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)
|
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[i].index = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
points.quickSort(pointCmp);
|
points.quickSort(pointCmp());
|
||||||
|
|
||||||
vertexPool.reset();
|
vertexPool.reset();
|
||||||
vertexPool.setArraySize(count);
|
vertexPool.setArraySize(count);
|
||||||
|
|||||||
Reference in New Issue
Block a user