+ CMake build system fix under Windows: don't define _WINDOWS to allow Glut console demo to build properly
+ Allow user to enable useConvexConservativeDistanceUtil . Use dynamicsWorld->getDispatchInfo().m_useConvexConservativeDistanceUtil = true; (see Demos/Benchmarks/Benchmark4 (convex objects falling down) + Fix for plane drawing (just wire-frame) + Gimpact: use collision margin of 0.07 for demo (because BULLET_TRIANGLE_COLLISION is used) + replace dot,cross,distance,angle,triple in btVector3 by btDot, btCross,btDistance,btAngle,btDistance to avoid naming conflicts + Some fixes in GJK penetration depth normal direction (broken in a previous commit) + fix in calculateDiffAxisAngleQuaternion to make ConvexConservativeDistanceUtil work properly + allow debug drawing to debug btContinuousConvexCollision + add comment/warning that btTriangleMesh::findOrAddVertex is an internal method, users should use addTriangle instead
This commit is contained in:
@@ -302,7 +302,9 @@ void BenchmarkDemo::initPhysics()
|
||||
|
||||
btDiscreteDynamicsWorld* dynamicsWorld;
|
||||
m_dynamicsWorld = dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_overlappingPairCache,m_solver,m_collisionConfiguration);
|
||||
dynamicsWorld->getSimulationIslandManager()->setSplitIslands(false);
|
||||
//dynamicsWorld->getSimulationIslandManager()->setSplitIslands(false);
|
||||
dynamicsWorld->getDispatchInfo().m_useConvexConservativeDistanceUtil = true;
|
||||
dynamicsWorld->getDispatchInfo().m_convexConservativeDistanceThreshold = 0.01;
|
||||
|
||||
|
||||
m_dynamicsWorld->setGravity(btVector3(0,-10,0));
|
||||
|
||||
@@ -26,10 +26,10 @@ int main(int argc,char** argv)
|
||||
{
|
||||
GLDebugDrawer gDebugDrawer;
|
||||
|
||||
BenchmarkDemo1 benchmarkDemo;
|
||||
// BenchmarkDemo1 benchmarkDemo;
|
||||
// BenchmarkDemo2 benchmarkDemo;
|
||||
// BenchmarkDemo3 benchmarkDemo;
|
||||
// BenchmarkDemo4 benchmarkDemo;
|
||||
BenchmarkDemo4 benchmarkDemo;
|
||||
// BenchmarkDemo5 benchmarkDemo;
|
||||
// BenchmarkDemo6 benchmarkDemo;
|
||||
// BenchmarkDemo7 benchmarkDemo;
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include "GLDebugDrawer.h"
|
||||
#include "btBulletDynamicsCommon.h"
|
||||
|
||||
#ifndef _WINDOWS
|
||||
|
||||
GLDebugDrawer gDebugDrawer;
|
||||
|
||||
int main(int argc,char** argv)
|
||||
@@ -29,4 +31,10 @@ int main(int argc,char** argv)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
DemoApplication* createDemo()
|
||||
{
|
||||
ConvexDecompositionDemo* convexDecompDemo = new ConvexDecompositionDemo();
|
||||
return convexDecompDemo;
|
||||
}
|
||||
#endif _WINDOWS
|
||||
|
||||
@@ -280,7 +280,10 @@ void GimpactConcaveDemo::initGImpactCollision()
|
||||
btGImpactConvexDecompositionShape * trimesh = new
|
||||
btGImpactConvexDecompositionShape(
|
||||
m_indexVertexArrays, btVector3(1.f,1.f,1.f),btScalar(0.01));
|
||||
trimesh->setMargin(0.07);
|
||||
trimesh->updateBound();
|
||||
|
||||
|
||||
#else
|
||||
btGImpactMeshShape * trimesh = new btGImpactMeshShape(m_indexVertexArrays);
|
||||
trimesh->setLocalScaling(btVector3(1.f,1.f,1.f));
|
||||
@@ -314,6 +317,7 @@ void GimpactConcaveDemo::initGImpactCollision()
|
||||
btGImpactConvexDecompositionShape * trimesh2 = new
|
||||
btGImpactConvexDecompositionShape(
|
||||
m_indexVertexArrays2, btVector3(4.f,4.f,4.f),btScalar(0.01));
|
||||
trimesh2->setMargin(0.07);
|
||||
trimesh2->updateBound();
|
||||
#else
|
||||
btGImpactMeshShape * trimesh2 = new btGImpactMeshShape(m_indexVertexArrays2);
|
||||
|
||||
@@ -21,7 +21,7 @@ class btDefaultCollisionConfiguration;
|
||||
|
||||
//#define BULLET_TRIANGLE_COLLISION 1
|
||||
#define BULLET_GIMPACT 1
|
||||
#define BULLET_GIMPACT_CONVEX_DECOMPOSITION 1
|
||||
//#define BULLET_GIMPACT_CONVEX_DECOMPOSITION 1
|
||||
|
||||
#define TEST_GIMPACT_TORUS
|
||||
|
||||
|
||||
@@ -25,15 +25,15 @@ subject to the following restrictions:
|
||||
#include "BulletMultiThreaded/SpuGatheringCollisionDispatcher.h"
|
||||
#include "BulletMultiThreaded/Win32ThreadSupport.h"
|
||||
#include "GLDebugFont.h"
|
||||
//@ extern int gSkippedCol;
|
||||
//@ extern int gProcessedCol;
|
||||
extern int gSkippedCol;
|
||||
extern int gProcessedCol;
|
||||
|
||||
|
||||
|
||||
#define SPEC_TEST 0
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define LARGE_DEMO 0
|
||||
#define LARGE_DEMO 1
|
||||
// #define LARGE_DEMO 1
|
||||
#else
|
||||
#define LARGE_DEMO 1
|
||||
@@ -192,6 +192,8 @@ void BasicDemo3D::initPhysics()
|
||||
btDefaultCollisionConstructionInfo dci;
|
||||
dci.m_defaultMaxPersistentManifoldPoolSize=100000;
|
||||
dci.m_defaultMaxCollisionAlgorithmPoolSize=100000;
|
||||
dci.m_customCollisionAlgorithmMaxElementSize = sizeof(SpuContactManifoldCollisionAlgorithm);
|
||||
|
||||
|
||||
///SpuContactManifoldCollisionAlgorithm is larger than any of the other collision algorithms
|
||||
//@@ dci.m_customMaxCollisionAlgorithmSize = sizeof(SpuContactManifoldCollisionAlgorithm);
|
||||
@@ -243,13 +245,18 @@ btCudaBroadphase::btCudaBroadphase( btOverlappingPairCache* overlappingPairCache
|
||||
#ifdef USE_CUDA_BROADPHASE
|
||||
m_broadphase = new btCudaBroadphase(gPairCache, gWorldMin, gWorldMax,numOfCellsX, numOfCellsY, numOfCellsZ,MAX_SMALL_PROXIES,20,18,8,1./1.5);
|
||||
#else
|
||||
|
||||
#if DBVT
|
||||
btDbvtBroadphase* dbvt = new btDbvtBroadphase(gPairCache);
|
||||
m_broadphase = dbvt;
|
||||
dbvt->m_deferedcollide=false;
|
||||
dbvt->m_prediction = 0.f;
|
||||
|
||||
#else
|
||||
m_broadphase = new btAxisSweep3(gWorldMin,gWorldMax,32000,gPairCache,true);//(btDbvtBroadphase(gPairCache);
|
||||
#endif //DBVT
|
||||
|
||||
#endif
|
||||
//m_broadphase = new btAxisSweep3(gWorldMin,gWorldMax,32000,0,true);//(btDbvtBroadphase(gPairCache);
|
||||
|
||||
|
||||
// create solvers for tests
|
||||
///the default constraint solver
|
||||
@@ -808,7 +815,6 @@ void BasicDemo3D::outputDebugInfo(int & xOffset,int & yStart, int yIncr)
|
||||
sprintf(buf,"# pairs = %d",getDynamicsWorld()->getBroadphase()->getOverlappingPairCache()->getNumOverlappingPairs());
|
||||
GLDebugDrawString(xOffset,yStart,buf);
|
||||
|
||||
/*@@
|
||||
|
||||
yStart += yIncr;
|
||||
glRasterPos3f(xOffset,yStart,0);
|
||||
@@ -822,12 +828,13 @@ void BasicDemo3D::outputDebugInfo(int & xOffset,int & yStart, int yIncr)
|
||||
|
||||
yStart += yIncr;
|
||||
glRasterPos3f(xOffset,yStart,0);
|
||||
sprintf(buf,"culled narrowphase collisions=%f",btScalar(gSkippedCol)/(gProcessedCol+gSkippedCol));
|
||||
btScalar fract = (gProcessedCol+gSkippedCol)? btScalar(gSkippedCol)/(gProcessedCol+gSkippedCol) : 0.f;
|
||||
sprintf(buf,"culled narrowphase collisions=%f",fract);
|
||||
GLDebugDrawString(xOffset,yStart,buf);
|
||||
yStart += yIncr;
|
||||
@@*/
|
||||
|
||||
|
||||
gProcessedCol = 0;
|
||||
gSkippedCol = 0;
|
||||
|
||||
}
|
||||
} // BasicDemo3D::outputDebugInfo()
|
||||
|
||||
@@ -1065,11 +1065,11 @@ void HfFluidDemo::clientMoveAndDisplay()
|
||||
const btVector3 rayTo=getRayTo(x,y);
|
||||
const btVector3 rayDir=(rayTo-rayFrom).normalized();
|
||||
const btVector3 N=(m_cameraTargetPosition-m_cameraPosition).normalized();
|
||||
const btScalar O=dot(m_impact,N);
|
||||
const btScalar den=dot(N,rayDir);
|
||||
const btScalar O=btDot(m_impact,N);
|
||||
const btScalar den=btDot(N,rayDir);
|
||||
if((den*den)>0)
|
||||
{
|
||||
const btScalar num=O-dot(N,rayFrom);
|
||||
const btScalar num=O-btDot(N,rayFrom);
|
||||
const btScalar hit=num/den;
|
||||
if((hit>0)&&(hit<1500))
|
||||
{
|
||||
|
||||
@@ -557,8 +557,8 @@ void HfFluidDemo_GL_ShapeDrawer::drawShadow(btScalar* m,const btVector3& extrus
|
||||
glBegin(GL_QUADS);
|
||||
for(int i=0;i<sc->m_edges.size();++i)
|
||||
{
|
||||
const btScalar d=dot(sc->m_edges[i].n[0],extrusion);
|
||||
if((d*dot(sc->m_edges[i].n[1],extrusion))<0)
|
||||
const btScalar d=btDot(sc->m_edges[i].n[0],extrusion);
|
||||
if((d*btDot(sc->m_edges[i].n[1],extrusion))<0)
|
||||
{
|
||||
const int q= d<0?1:0;
|
||||
const btVector3& a= hull->getVertexPointer()[sc->m_edges[i].v[q]];
|
||||
|
||||
@@ -39,7 +39,34 @@ void GLDebugDrawer::drawSphere (const btVector3& p, btScalar radius, const btVec
|
||||
glColor4f (color.getX(), color.getY(), color.getZ(), btScalar(1.0f));
|
||||
glPushMatrix ();
|
||||
glTranslatef (p.getX(), p.getY(), p.getZ());
|
||||
// glutSolidSphere (radius, 10, 10);
|
||||
|
||||
int lats = 5;
|
||||
int longs = 5;
|
||||
|
||||
int i, j;
|
||||
for(i = 0; i <= lats; i++) {
|
||||
btScalar lat0 = SIMD_PI * (-btScalar(0.5) + (btScalar) (i - 1) / lats);
|
||||
btScalar z0 = radius*sin(lat0);
|
||||
btScalar zr0 = radius*cos(lat0);
|
||||
|
||||
btScalar lat1 = SIMD_PI * (-btScalar(0.5) + (btScalar) i / lats);
|
||||
btScalar z1 = radius*sin(lat1);
|
||||
btScalar zr1 = radius*cos(lat1);
|
||||
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for(j = 0; j <= longs; j++) {
|
||||
btScalar lng = 2 * SIMD_PI * (btScalar) (j - 1) / longs;
|
||||
btScalar x = cos(lng);
|
||||
btScalar y = sin(lng);
|
||||
|
||||
glNormal3f(x * zr0, y * zr0, z0);
|
||||
glVertex3f(x * zr0, y * zr0, z0);
|
||||
glNormal3f(x * zr1, y * zr1, z1);
|
||||
glVertex3f(x * zr1, y * zr1, z1);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
@@ -62,7 +89,7 @@ void GLDebugDrawer::drawTriangle(const btVector3& a,const btVector3& b,const btV
|
||||
{
|
||||
// if (m_debugMode > 0)
|
||||
{
|
||||
const btVector3 n=cross(b-a,c-a).normalized();
|
||||
const btVector3 n=btCross(b-a,c-a).normalized();
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor4f(color.getX(), color.getY(), color.getZ(),alpha);
|
||||
glNormal3d(n.getX(),n.getY(),n.getZ());
|
||||
|
||||
@@ -365,7 +365,7 @@ GL_ShapeDrawer::ShapeCache* GL_ShapeDrawer::cache(btConvexShape* shape)
|
||||
for(int i=0;i<ni;i+=3)
|
||||
{
|
||||
const unsigned int* ti=pi+i;
|
||||
const btVector3 nrm=cross(pv[ti[1]]-pv[ti[0]],pv[ti[2]]-pv[ti[0]]).normalized();
|
||||
const btVector3 nrm=btCross(pv[ti[1]]-pv[ti[0]],pv[ti[2]]-pv[ti[0]]).normalized();
|
||||
for(int j=2,k=0;k<3;j=k++)
|
||||
{
|
||||
const unsigned int a=ti[j];
|
||||
@@ -857,8 +857,7 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
|
||||
else
|
||||
{
|
||||
#else
|
||||
if (shape->isConcave())//>getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE||shape->getShapeType() == GIMPACT_SHAPE_PROXYTYPE)
|
||||
// if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
|
||||
if (shape->isConcave() && !shape->isInfinite())
|
||||
{
|
||||
btConcaveShape* concaveMesh = (btConcaveShape*) shape;
|
||||
|
||||
@@ -939,8 +938,8 @@ void GL_ShapeDrawer::drawShadow(btScalar* m,const btVector3& extrusion,const bt
|
||||
glBegin(GL_QUADS);
|
||||
for(int i=0;i<sc->m_edges.size();++i)
|
||||
{
|
||||
const btScalar d=dot(sc->m_edges[i].n[0],extrusion);
|
||||
if((d*dot(sc->m_edges[i].n[1],extrusion))<0)
|
||||
const btScalar d=btDot(sc->m_edges[i].n[0],extrusion);
|
||||
if((d*btDot(sc->m_edges[i].n[1],extrusion))<0)
|
||||
{
|
||||
const int q= d<0?1:0;
|
||||
const btVector3& a= hull->getVertexPointer()[sc->m_edges[i].v[q]];
|
||||
|
||||
@@ -118,11 +118,11 @@ void SoftDemo::clientMoveAndDisplay()
|
||||
const btVector3 rayTo=getRayTo(x,y);
|
||||
const btVector3 rayDir=(rayTo-rayFrom).normalized();
|
||||
const btVector3 N=(m_cameraTargetPosition-m_cameraPosition).normalized();
|
||||
const btScalar O=dot(m_impact,N);
|
||||
const btScalar den=dot(N,rayDir);
|
||||
const btScalar O=btDot(m_impact,N);
|
||||
const btScalar den=btDot(N,rayDir);
|
||||
if((den*den)>0)
|
||||
{
|
||||
const btScalar num=O-dot(N,rayFrom);
|
||||
const btScalar num=O-btDot(N,rayFrom);
|
||||
const btScalar hit=num/den;
|
||||
if((hit>0)&&(hit<1500))
|
||||
{
|
||||
@@ -1442,8 +1442,8 @@ void SoftDemo::renderme()
|
||||
const btScalar a= (btScalar)0.5;
|
||||
const btVector3 n= m_softBodyWorldInfo.water_normal;
|
||||
const btVector3 o= -n*m_softBodyWorldInfo.water_offset;
|
||||
const btVector3 x= cross(n,axis[n.minAxis()]).normalized();
|
||||
const btVector3 y= cross(x,n).normalized();
|
||||
const btVector3 x= btCross(n,axis[n.minAxis()]).normalized();
|
||||
const btVector3 y= btCross(x,n).normalized();
|
||||
const btScalar s= 25;
|
||||
idraw->drawTriangle(o-x*s-y*s,o+x*s-y*s,o+x*s+y*s,c,a);
|
||||
idraw->drawTriangle(o-x*s-y*s,o+x*s+y*s,o-x*s+y*s,c,a);
|
||||
|
||||
Reference in New Issue
Block a user