diff --git a/Demos/AllBulletDemos/DemoEntries.cpp b/Demos/AllBulletDemos/DemoEntries.cpp index b0c284c48..2f4c47613 100644 --- a/Demos/AllBulletDemos/DemoEntries.cpp +++ b/Demos/AllBulletDemos/DemoEntries.cpp @@ -119,7 +119,18 @@ btDemoEntry g_demoEntries[] = {"SoftBody Torus",SoftDemo13::Create}, {"SoftBody Torus Match",SoftDemo14::Create}, {"SoftBody Bunny",SoftDemo15::Create}, - {"SoftBody Bunny Match",SoftDemo16::Create}, + {"SoftBody Bunny Match",SoftDemo16::Create}, + {"SoftBody Init Cutting",SoftDemo17::Create}, + {"SoftBody Cluster Deform",SoftDemo18::Create}, + {"SoftBody Cluster Collide1",SoftDemo19::Create}, + {"SoftBody Cluster Collide2",SoftDemo20::Create}, + {"SoftBody Cluster Socket",SoftDemo21::Create}, + {"SoftBody Cluster Hinge",SoftDemo22::Create}, + {"SoftBody Cluster Combine",SoftDemo23::Create}, + {"SoftBody Cluster Car",SoftDemo24::Create}, + {"SoftBody Cluster Robot",SoftDemo25::Create}, + {"SoftBody Cluster Stack Soft",SoftDemo26::Create}, + {"SoftBody Cluster Stack Mixed",SoftDemo27::Create}, {"DynamicControlDemo",MotorDemo::Create}, {"RagdollDemo",RagdollDemo::Create}, {"SliderConstraint",SliderConstraintDemo::Create}, diff --git a/Demos/AllBulletDemos/Main.cpp b/Demos/AllBulletDemos/Main.cpp index d6909f1e9..ee13fe0d4 100644 --- a/Demos/AllBulletDemos/Main.cpp +++ b/Demos/AllBulletDemos/Main.cpp @@ -328,7 +328,22 @@ void MouseMotion(int x, int y) int main(int argc, char** argv) { - + +//#define CHECK_FPU_EXCEPTIONS 1 +#ifdef CHECK_FPU_EXCEPTIONS + + int cw = _control87(0, 0); + + // Set the exception masks off, turn exceptions on + cw &= ~(EM_ZERODIVIDE | EM_INVALID); + + printf("control87 = %#x\n", cw); + + // Set the control word + _control87(cw, MCW_EM); +#endif //CHECK_FPU_EXCEPTIONS + + setDefaultSettings(); int bulletVersion = btGetVersion(); diff --git a/Demos/BasicDemo/BasicDemo.cpp b/Demos/BasicDemo/BasicDemo.cpp index 361722fcb..2997e7bcd 100644 --- a/Demos/BasicDemo/BasicDemo.cpp +++ b/Demos/BasicDemo/BasicDemo.cpp @@ -77,6 +77,8 @@ void BasicDemo::displayCallback(void) { void BasicDemo::initPhysics() { + setTexturing(true); + setShadows(true); setCameraDistance(btScalar(50.)); @@ -102,8 +104,8 @@ void BasicDemo::initPhysics() m_dynamicsWorld->setGravity(btVector3(0,-10,0)); ///create a few basic rigid bodies -// btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.))); - btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),50); + btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.))); +// btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),50); m_collisionShapes.push_back(groundShape); diff --git a/Demos/BspDemo/BspDemo.cpp b/Demos/BspDemo/BspDemo.cpp index f20e3aae0..4f066bcf8 100644 --- a/Demos/BspDemo/BspDemo.cpp +++ b/Demos/BspDemo/BspDemo.cpp @@ -133,8 +133,9 @@ BspDemo::~BspDemo() void BspDemo::initPhysics(char* bspfilename) { + setTexturing(true); + setShadows(false); - m_cameraUp = btVector3(0,0,1); m_forwardAxis = 1; diff --git a/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp b/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp index 13f221c48..687c2a521 100644 --- a/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp +++ b/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp @@ -319,6 +319,9 @@ float myFrictionModel( btRigidBody& body1, btRigidBody& body2, btManifoldPoint& void CcdPhysicsDemo::initPhysics() { + setTexturing(true); + setShadows(false); + #ifdef USE_PARALLEL_DISPATCHER #ifdef WIN32 m_threadSupportSolver = 0; diff --git a/Demos/CollisionDemo/CollisionDemo.cpp b/Demos/CollisionDemo/CollisionDemo.cpp index 31f6ce0b1..207b08fa2 100644 --- a/Demos/CollisionDemo/CollisionDemo.cpp +++ b/Demos/CollisionDemo/CollisionDemo.cpp @@ -226,13 +226,16 @@ void CollisionDemo::displayCallback(void) { convexConvex.getClosestPoints(input ,gjkOutput,0); + btVector3 worldBoundsMin(-1000,-1000,-1000); + btVector3 worldBoundsMax(1000,1000,1000); + for (i=0;igetBroadphase()->getBroadphaseAabb(worldBoundsMin,worldBoundsMax); for (i=0;im_fraction,hitTrans); hitTrans.getOpenGLMatrix(m); - m_shapeDrawer.drawOpenGL(m,shapePtr[0],btVector3(0,1,0),getDebugMode()); + m_shapeDrawer.drawOpenGL(m,shapePtr[0],btVector3(0,1,0),getDebugMode(),worldBoundsMin,worldBoundsMax); btTransformUtil::integrateTransform(fromTrans[i],linVels[i],angVels[i],rayResultPtr->m_fraction,hitTrans); hitTrans.getOpenGLMatrix(m); - m_shapeDrawer.drawOpenGL(m,shapePtr[i],btVector3(0,1,1),getDebugMode()); + m_shapeDrawer.drawOpenGL(m,shapePtr[i],btVector3(0,1,1),getDebugMode(),worldBoundsMin,worldBoundsMax); } diff --git a/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.cpp b/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.cpp index 6ec0f46aa..2a693c304 100644 --- a/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.cpp +++ b/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.cpp @@ -59,6 +59,9 @@ unsigned int tcount = 0; void ConvexDecompositionDemo::initPhysics(const char* filename) { + setTexturing(true); + setShadows(true); + setCameraDistance(26.f); ConvexDecomposition::WavefrontObj wo; diff --git a/Demos/DoublePrecisionDemo/DoublePrecisionDemo.cpp b/Demos/DoublePrecisionDemo/DoublePrecisionDemo.cpp index 46fea51f4..2b869e74c 100644 --- a/Demos/DoublePrecisionDemo/DoublePrecisionDemo.cpp +++ b/Demos/DoublePrecisionDemo/DoublePrecisionDemo.cpp @@ -121,6 +121,10 @@ void DoublePrecisionDemo::displayCallback(void) int i; + btVector3 worldBoundsMin,worldBoundsMax; + collisionWorld->getBroadphase()->getBroadphaseAabb(worldBoundsMin,worldBoundsMax); + + ///one way to draw all the contact points is iterating over contact manifolds / points: int numManifolds = collisionWorld->getDispatcher()->getNumManifolds(); for (i=0;igetBroadphase()->getBroadphaseAabb(worldBoundsMin,worldBoundsMax); + + int numObjects = m_dynamicsWorld->getNumCollisionObjects(); btVector3 wireColor(1,0,0); for (int i=0;igetCollisionShape(),wireColor,getDebugMode()); + m_shapeDrawer.drawOpenGL(m,colObj->getCollisionShape(),wireColor,getDebugMode(),worldBoundsMin,worldBoundsMax); } @@ -364,6 +368,9 @@ btCollisionShape * GimpactConcaveDemo::createBunnyShape() //------------------------------------------------------------------------------ void GimpactConcaveDemo::initPhysics() { + setTexturing(true); + setShadows(false); + setCameraDistance(45.f); diff --git a/Demos/GjkConvexCastDemo/LinearConvexCastDemo.cpp b/Demos/GjkConvexCastDemo/LinearConvexCastDemo.cpp index f62d6fdf2..00e4c965f 100644 --- a/Demos/GjkConvexCastDemo/LinearConvexCastDemo.cpp +++ b/Demos/GjkConvexCastDemo/LinearConvexCastDemo.cpp @@ -135,6 +135,10 @@ void LinearConvexCastDemo::displayCallback(void) gGjkSimplexSolver.reset(); + + btVector3 worldBoundsMin(-1000,-1000,-1000); + btVector3 worldBoundsMax(1000,1000,1000); + //btGjkConvexCast convexCaster(shapePtr[ 0 ], shapePtr[ 1 ], &gGjkSimplexSolver ); btSubsimplexConvexCast convexCaster( shapePtr[ 0 ], shapePtr[ 1 ], &gGjkSimplexSolver ); @@ -154,11 +158,11 @@ void LinearConvexCastDemo::displayCallback(void) btTransform tmp = tr[0]; tmp.setOrigin(result.m_hitPoint); tmp.getOpenGLMatrix(m3); - m_shapeDrawer.drawOpenGL( m3, &sphere, btVector3( 1, 0, 1 ), getDebugMode() ); + m_shapeDrawer.drawOpenGL( m3, &sphere, btVector3( 1, 0, 1 ), getDebugMode() ,worldBoundsMin,worldBoundsMax); - m_shapeDrawer.drawOpenGL( m1, shapePtr[ 0 ], btVector3( 1, 0, 0 ), getDebugMode() ); - m_shapeDrawer.drawOpenGL( m2, shapePtr[ 1 ], btVector3( 1, 0, 0 ), getDebugMode() ); + m_shapeDrawer.drawOpenGL( m1, shapePtr[ 0 ], btVector3( 1, 0, 0 ), getDebugMode() ,worldBoundsMin,worldBoundsMax); + m_shapeDrawer.drawOpenGL( m2, shapePtr[ 1 ], btVector3( 1, 0, 0 ), getDebugMode() ,worldBoundsMin,worldBoundsMax); btVector3 originA, originB; originA.setInterpolate3( tr[ 0 ].getOrigin(), toA.getOrigin(), result.m_fraction ); @@ -173,8 +177,8 @@ void LinearConvexCastDemo::displayCallback(void) A.getOpenGLMatrix( m1 ); B.getOpenGLMatrix( m2 ); - m_shapeDrawer.drawOpenGL( m1, shapePtr[ 0 ], btVector3( 1, 1, 0 ), getDebugMode() ); - m_shapeDrawer.drawOpenGL( m2, shapePtr[ 1 ], btVector3( 1, 1, 0 ), getDebugMode() ); + m_shapeDrawer.drawOpenGL( m1, shapePtr[ 0 ], btVector3( 1, 1, 0 ), getDebugMode() ,worldBoundsMin,worldBoundsMax); + m_shapeDrawer.drawOpenGL( m2, shapePtr[ 1 ], btVector3( 1, 1, 0 ), getDebugMode() ,worldBoundsMin,worldBoundsMax); glFlush(); glutSwapBuffers(); diff --git a/Demos/MovingConcaveDemo/ConcavePhysicsDemo.cpp b/Demos/MovingConcaveDemo/ConcavePhysicsDemo.cpp index bd594dc49..d4179c50f 100644 --- a/Demos/MovingConcaveDemo/ConcavePhysicsDemo.cpp +++ b/Demos/MovingConcaveDemo/ConcavePhysicsDemo.cpp @@ -1492,6 +1492,10 @@ void ConcaveDemo::renderme() if (m_dynamicsWorld) { + btVector3 worldBoundsMin,worldBoundsMax; + getDynamicsWorld()->getBroadphase()->getBroadphaseAabb(worldBoundsMin,worldBoundsMax); + + int numObjects = m_dynamicsWorld->getNumCollisionObjects(); btVector3 wireColor(1,0,0); for (int i=0;igetCollisionShape(),wireColor,getDebugMode()); + m_shapeDrawer.drawOpenGL(m,colObj->getCollisionShape(),wireColor,getDebugMode(),worldBoundsMin,worldBoundsMax); } diff --git a/Demos/MultiThreadedDemo/CMakeLists.txt b/Demos/MultiThreadedDemo/CMakeLists.txt index ce4bc7edf..a2d15d79f 100644 --- a/Demos/MultiThreadedDemo/CMakeLists.txt +++ b/Demos/MultiThreadedDemo/CMakeLists.txt @@ -23,4 +23,7 @@ ADD_EXECUTABLE(MultiThreadedDemo MultiThreadedDemo.cpp MultiThreadedDemo.h ) +IF (UNIX) + TARGET_LINK_LIBRARIES(MultiThreadedDemo pthread) +ENDIF(UNIX) diff --git a/Demos/OpenGL/DebugCastResult.h b/Demos/OpenGL/DebugCastResult.h index fc2ba5662..65adbfe61 100644 --- a/Demos/OpenGL/DebugCastResult.h +++ b/Demos/OpenGL/DebugCastResult.h @@ -70,12 +70,15 @@ struct btDebugCastResult : public btConvexCast::CastResult virtual void DebugDraw(btScalar fraction) { + btVector3 worldBoundsMin(-1000,-1000,-1000); + btVector3 worldBoundsMax(1000,1000,1000); + btScalar m[16]; btTransform hitTrans; btTransformUtil::integrateTransform(m_fromTrans,m_linVel,m_angVel,fraction,hitTrans); hitTrans.getOpenGLMatrix(m); - m_shapeDrawer->drawOpenGL(m,m_shape,btVector3(1,0,0),btIDebugDraw::DBG_NoDebug); + m_shapeDrawer->drawOpenGL(m,m_shape,btVector3(1,0,0),btIDebugDraw::DBG_NoDebug,worldBoundsMin,worldBoundsMax); } }; diff --git a/Demos/OpenGL/DemoApplication.cpp b/Demos/OpenGL/DemoApplication.cpp index c8f9d5a6c..e27a0264a 100644 --- a/Demos/OpenGL/DemoApplication.cpp +++ b/Demos/OpenGL/DemoApplication.cpp @@ -78,6 +78,9 @@ m_shootBoxShape(0), #ifndef BT_NO_PROFILE m_profileIterator = CProfileManager::Get_Iterator(); #endif //BT_NO_PROFILE + + m_shapeDrawer.enableTexture(true); + m_enableshadows = false; } @@ -957,11 +960,15 @@ for(int i=0;igetBroadphase()->getBroadphaseAabb(aabbMin,aabbMax); + switch(pass) { - case 0: m_shapeDrawer.drawOpenGL(m,colObj->getCollisionShape(),wireColor,getDebugMode());break; - case 1: m_shapeDrawer.drawShadow(m,m_sundirection*rot,colObj->getCollisionShape());break; - case 2: m_shapeDrawer.drawOpenGL(m,colObj->getCollisionShape(),wireColor*0.3,0);break; + case 0: m_shapeDrawer.drawOpenGL(m,colObj->getCollisionShape(),wireColor,getDebugMode(),aabbMin,aabbMax);break; + case 1: m_shapeDrawer.drawShadow(m,m_sundirection*rot,colObj->getCollisionShape(),aabbMin,aabbMax);break; + case 2: m_shapeDrawer.drawOpenGL(m,colObj->getCollisionShape(),wireColor*0.3,0,aabbMin,aabbMax);break; } } } diff --git a/Demos/OpenGL/GL_ShapeDrawer.cpp b/Demos/OpenGL/GL_ShapeDrawer.cpp index d00507a8f..2a3633aa7 100644 --- a/Demos/OpenGL/GL_ShapeDrawer.cpp +++ b/Demos/OpenGL/GL_ShapeDrawer.cpp @@ -360,7 +360,7 @@ GL_ShapeDrawer::ShapeCache* GL_ShapeDrawer::cache(btConvexShape* shape) return(sc); } -void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, const btVector3& color,int debugMode) +void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, const btVector3& color,int debugMode,const btVector3& worldBoundsMin,const btVector3& worldBoundsMax) { @@ -378,7 +378,7 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons {0,0,scalingFactor,0}, {0,0,0,1}}; - drawOpenGL( (btScalar*)tmpScaling,convexShape,color,debugMode); + drawOpenGL( (btScalar*)tmpScaling,convexShape,color,debugMode,worldBoundsMin,worldBoundsMax); } glPopMatrix(); return; @@ -393,7 +393,7 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons const btCollisionShape* colShape = compoundShape->getChildShape(i); btScalar childMat[16]; childTrans.getOpenGLMatrix(childMat); - drawOpenGL(childMat,colShape,color,debugMode); + drawOpenGL(childMat,colShape,color,debugMode,worldBoundsMin,worldBoundsMax); } } else @@ -447,9 +447,12 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons { glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,m_texturehandle); + } else + { + glDisable(GL_TEXTURE_2D); } - + glColor3f(color.x(),color.y(), color.z()); bool useWireframeFallback = true; @@ -692,17 +695,11 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons // if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE) { btConcaveShape* concaveMesh = (btConcaveShape*) shape; - //btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30)); - //btVector3 aabbMax(100,100,100);//btScalar(1e30),btScalar(1e30),btScalar(1e30)); - - //todo pass camera, for some culling - btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30)); - btVector3 aabbMin(-btScalar(1e30),-btScalar(1e30),-btScalar(1e30)); GlDrawcallback drawCallback; drawCallback.m_wireframe = (debugMode & btIDebugDraw::DBG_DrawWireframe)!=0; - concaveMesh->processAllTriangles(&drawCallback,aabbMin,aabbMax); + concaveMesh->processAllTriangles(&drawCallback,worldBoundsMin,worldBoundsMax); } #endif @@ -749,7 +746,7 @@ if(m_textureenabled) glDisable(GL_TEXTURE_2D); } // -void GL_ShapeDrawer::drawShadow(btScalar* m,const btVector3& extrusion,const btCollisionShape* shape) +void GL_ShapeDrawer::drawShadow(btScalar* m,const btVector3& extrusion,const btCollisionShape* shape,const btVector3& worldBoundsMin,const btVector3& worldBoundsMax) { glPushMatrix(); btglMultMatrix(m); @@ -762,7 +759,7 @@ void GL_ShapeDrawer::drawShadow(btScalar* m,const btVector3& extrusion,const bt {0,scalingFactor,0,0}, {0,0,scalingFactor,0}, {0,0,0,1}}; - drawShadow((btScalar*)tmpScaling,extrusion,convexShape); + drawShadow((btScalar*)tmpScaling,extrusion,convexShape,worldBoundsMin,worldBoundsMax); glPopMatrix(); return; } @@ -775,7 +772,7 @@ void GL_ShapeDrawer::drawShadow(btScalar* m,const btVector3& extrusion,const bt const btCollisionShape* colShape = compoundShape->getChildShape(i); btScalar childMat[16]; childTrans.getOpenGLMatrix(childMat); - drawShadow(childMat,extrusion*childTrans.getBasis(),colShape); + drawShadow(childMat,extrusion*childTrans.getBasis(),colShape,worldBoundsMin,worldBoundsMax); } } else @@ -812,17 +809,11 @@ void GL_ShapeDrawer::drawShadow(btScalar* m,const btVector3& extrusion,const bt // if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE) { btConcaveShape* concaveMesh = (btConcaveShape*) shape; - //btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30)); - //btVector3 aabbMax(100,100,100);//btScalar(1e30),btScalar(1e30),btScalar(1e30)); - - //todo pass camera, for some culling - btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30)); - btVector3 aabbMin(-btScalar(1e30),-btScalar(1e30),-btScalar(1e30)); GlDrawcallback drawCallback; drawCallback.m_wireframe = false; - concaveMesh->processAllTriangles(&drawCallback,aabbMin,aabbMax); + concaveMesh->processAllTriangles(&drawCallback,worldBoundsMin,worldBoundsMax); } glPopMatrix(); diff --git a/Demos/OpenGL/GL_ShapeDrawer.h b/Demos/OpenGL/GL_ShapeDrawer.h index 69748e013..f979a4a57 100644 --- a/Demos/OpenGL/GL_ShapeDrawer.h +++ b/Demos/OpenGL/GL_ShapeDrawer.h @@ -47,8 +47,8 @@ class GL_ShapeDrawer virtual ~GL_ShapeDrawer(); ///drawOpenGL might allocate temporary memoty, stores pointer in shape userpointer - void drawOpenGL(btScalar* m, const btCollisionShape* shape, const btVector3& color,int debugMode); - void drawShadow(btScalar* m, const btVector3& extrusion,const btCollisionShape* shape); + void drawOpenGL(btScalar* m, const btCollisionShape* shape, const btVector3& color,int debugMode,const btVector3& worldBoundsMin,const btVector3& worldBoundsMax); + void drawShadow(btScalar* m, const btVector3& extrusion,const btCollisionShape* shape,const btVector3& worldBoundsMin,const btVector3& worldBoundsMax); bool enableTexture(bool enable) { bool p=m_textureenabled;m_textureenabled=enable;return(p); } diff --git a/Demos/RagdollDemo/RagdollDemo.cpp b/Demos/RagdollDemo/RagdollDemo.cpp index 62274a28e..9f1ab9db5 100644 --- a/Demos/RagdollDemo/RagdollDemo.cpp +++ b/Demos/RagdollDemo/RagdollDemo.cpp @@ -309,6 +309,9 @@ void RagdollDemo::initPhysics() { // Setup the basic world + setTexturing(true); + setShadows(true); + setCameraDistance(btScalar(5.)); m_collisionConfiguration = new btDefaultCollisionConfiguration(); diff --git a/Demos/SimplexDemo/SimplexDemo.cpp b/Demos/SimplexDemo/SimplexDemo.cpp index 907f2d265..65f801850 100644 --- a/Demos/SimplexDemo/SimplexDemo.cpp +++ b/Demos/SimplexDemo/SimplexDemo.cpp @@ -76,6 +76,9 @@ void SimplexDemo::displayCallback() btScalar m[16]; int i; + btVector3 worldBoundsMin(-1000,-1000,-1000); + btVector3 worldBoundsMax(1000,1000,1000); + for (i=0;igetBroadphase()->getBroadphaseAabb(worldBoundsMin,worldBoundsMax); + + + for (i=0;igetNumWheels();i++) { //synchronize the wheels with the (interpolated) chassis worldtransform m_vehicle->updateWheelTransform(i,true); //draw wheels (cylinders) m_vehicle->getWheelInfo(i).m_worldTransform.getOpenGLMatrix(m); - m_shapeDrawer.drawOpenGL(m,&wheelShape,wheelColor,getDebugMode()); + m_shapeDrawer.drawOpenGL(m,&wheelShape,wheelColor,getDebugMode(),worldBoundsMin,worldBoundsMax); } diff --git a/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp b/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp index 8802d0e78..3f94f4d4e 100644 --- a/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp +++ b/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp @@ -231,11 +231,11 @@ btCollisionAlgorithmCreateFunc* btDefaultCollisionConfiguration::getCollisionAlg if ((proxyType0 == TRIANGLE_SHAPE_PROXYTYPE ) && (proxyType1==SPHERE_SHAPE_PROXYTYPE)) { return m_triangleSphereCF; - } + } if ((proxyType0 == BOX_SHAPE_PROXYTYPE) && (proxyType1 == BOX_SHAPE_PROXYTYPE)) { - //return m_boxBoxCF; + return m_boxBoxCF; } if (btBroadphaseProxy::isConvex(proxyType0) && (proxyType1 == STATIC_PLANE_PROXYTYPE)) diff --git a/src/BulletCollision/CollisionShapes/btOptimizedBvh.cpp b/src/BulletCollision/CollisionShapes/btOptimizedBvh.cpp index fdf2ddc85..dbf7f11dd 100644 --- a/src/BulletCollision/CollisionShapes/btOptimizedBvh.cpp +++ b/src/BulletCollision/CollisionShapes/btOptimizedBvh.cpp @@ -803,10 +803,10 @@ void btOptimizedBvh::walkStacklessQuantizedTreeAgainstRay(btNodeOverlapCallback* btVector3 rayDirection = (rayTarget-raySource); rayDirection.normalize (); lambda_max = rayDirection.dot(rayTarget-raySource); - ///what about division by zero? - rayDirection[0] = btScalar(1.0) / rayDirection[0]; - rayDirection[1] = btScalar(1.0) / rayDirection[1]; - rayDirection[2] = btScalar(1.0) / rayDirection[2]; + ///what about division by zero? --> just set rayDirection[i] to 1.0 + rayDirection[0] = rayDirection[0] == btScalar(0.0) ? btScalar(1.0) : btScalar(1.0) / rayDirection[0]; + rayDirection[1] = rayDirection[1] == btScalar(0.0) ? btScalar(1.0) : btScalar(1.0) / rayDirection[1]; + rayDirection[2] = rayDirection[2] == btScalar(0.0) ? btScalar(1.0) : btScalar(1.0) / rayDirection[2]; unsigned int sign[3] = { rayDirection[0] < 0.0, rayDirection[1] < 0.0, rayDirection[2] < 0.0}; #endif @@ -1365,3 +1365,4 @@ m_bvhQuantization(self.m_bvhQuantization) } + diff --git a/src/BulletCollision/NarrowPhaseCollision/btGjkEpa2.cpp b/src/BulletCollision/NarrowPhaseCollision/btGjkEpa2.cpp index f4f061ad1..01a4d8b08 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btGjkEpa2.cpp +++ b/src/BulletCollision/NarrowPhaseCollision/btGjkEpa2.cpp @@ -901,7 +901,8 @@ if(gjk_status==GJK::eStatus::Valid) const btVector3 delta= results.witnesses[0]- results.witnesses[1]; const btScalar length= delta.length(); - results.normal = delta/length; + if (length >= SIMD_EPSILON) + results.normal = delta/length; return(-length); } } diff --git a/src/BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.cpp b/src/BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.cpp index 8b0249680..4c709a8c3 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.cpp +++ b/src/BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.cpp @@ -137,7 +137,10 @@ bool btSubsimplexConvexCast::calcTimeOfImpact( result.m_fraction = lambda; - result.m_normal = n.normalized(); + if (n.length2() >= (SIMD_EPSILON*SIMD_EPSILON)) + result.m_normal = n.normalized(); + else + result.m_normal = btVector3(btScalar(0.0), btScalar(0.0), btScalar(0.0)); //don't report time of impact for motion away from the contact normal (or causes minor penetration) if (result.m_normal.dot(r)>=-result.m_allowedPenetration) @@ -151,3 +154,4 @@ bool btSubsimplexConvexCast::calcTimeOfImpact( + diff --git a/src/BulletSoftBody/btSoftBody.cpp b/src/BulletSoftBody/btSoftBody.cpp index 5babfa914..c8cf5b1d1 100644 --- a/src/BulletSoftBody/btSoftBody.cpp +++ b/src/BulletSoftBody/btSoftBody.cpp @@ -1723,7 +1723,9 @@ void btSoftBody::updateNormals() } for(i=0,ni=m_nodes.size();iSIMD_EPSILON) + m_nodes[i].m_n /= len; } }