BGE Bullet fix: physics debug representation of cone shape does not take Up axis...
authorBenoit Bolsee <benoit.bolsee@online.be>
Thu, 21 Aug 2008 14:07:24 +0000 (14:07 +0000)
committerBenoit Bolsee <benoit.bolsee@online.be>
Thu, 21 Aug 2008 14:07:24 +0000 (14:07 +0000)
extern/bullet2/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp

index 29719ec9a3ec3becfc9d39d3aaf966f435913df3..1017c8af6eafb5f47360e954886d0e6d413cc00d 100644 (file)
@@ -856,10 +856,26 @@ void btDiscreteDynamicsWorld::debugDrawObject(const btTransform& worldTransform,
                                btScalar radius = coneShape->getRadius();//+coneShape->getMargin();
                                btScalar height = coneShape->getHeight();//+coneShape->getMargin();
                                btVector3 start = worldTransform.getOrigin();
                                btScalar radius = coneShape->getRadius();//+coneShape->getMargin();
                                btScalar height = coneShape->getHeight();//+coneShape->getMargin();
                                btVector3 start = worldTransform.getOrigin();
-                               getDebugDrawer()->drawLine(start+worldTransform.getBasis() * btVector3(btScalar(0.),btScalar(0.),btScalar(0.5)*height),start+worldTransform.getBasis() * btVector3(radius,btScalar(0.),btScalar(-0.5)*height),color);
-                               getDebugDrawer()->drawLine(start+worldTransform.getBasis() * btVector3(btScalar(0.),btScalar(0.),btScalar(0.5)*height),start+worldTransform.getBasis() * btVector3(-radius,btScalar(0.),btScalar(-0.5)*height),color);
-                               getDebugDrawer()->drawLine(start+worldTransform.getBasis() * btVector3(btScalar(0.),btScalar(0.),btScalar(0.5)*height),start+worldTransform.getBasis() * btVector3(btScalar(0.),radius,btScalar(-0.5)*height),color);
-                               getDebugDrawer()->drawLine(start+worldTransform.getBasis() * btVector3(btScalar(0.),btScalar(0.),btScalar(0.5)*height),start+worldTransform.getBasis() * btVector3(btScalar(0.),-radius,btScalar(-0.5)*height),color);
+                               // insert here Bullet 2.69 that fixes representation of cone
+                               int upAxis= coneShape->getConeUpIndex();
+                               
+                               btVector3       offsetHeight(0,0,0);
+                               offsetHeight[upAxis] = height * btScalar(0.5);
+                               btVector3       offsetRadius(0,0,0);
+                               offsetRadius[(upAxis+1)%3] = radius;
+                               btVector3       offset2Radius(0,0,0);
+                               offset2Radius[(upAxis+2)%3] = radius;
+
+                               getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight+offsetRadius),color);
+                               getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight-offsetRadius),color);
+                               getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight+offset2Radius),color);
+                               getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight-offset2Radius),color);
+
+                               // buggy code that does not take into account the direction of the cone
+                               //getDebugDrawer()->drawLine(start+worldTransform.getBasis() * btVector3(btScalar(0.),btScalar(0.),btScalar(0.5)*height),start+worldTransform.getBasis() * btVector3(radius,btScalar(0.),btScalar(-0.5)*height),color);
+                               //getDebugDrawer()->drawLine(start+worldTransform.getBasis() * btVector3(btScalar(0.),btScalar(0.),btScalar(0.5)*height),start+worldTransform.getBasis() * btVector3(-radius,btScalar(0.),btScalar(-0.5)*height),color);
+                               //getDebugDrawer()->drawLine(start+worldTransform.getBasis() * btVector3(btScalar(0.),btScalar(0.),btScalar(0.5)*height),start+worldTransform.getBasis() * btVector3(btScalar(0.),radius,btScalar(-0.5)*height),color);
+                               //getDebugDrawer()->drawLine(start+worldTransform.getBasis() * btVector3(btScalar(0.),btScalar(0.),btScalar(0.5)*height),start+worldTransform.getBasis() * btVector3(btScalar(0.),-radius,btScalar(-0.5)*height),color);
                                break;
 
                        }
                                break;
 
                        }