improved robustness of penetrations involving triangles and boxes, by adding their 'preferred' penetration directions.
added wireframe/solid mode for meshes updated solid penetration depth solver (comparison in Extras)
This commit is contained in:
@@ -121,7 +121,10 @@ void ConcaveDemo::initPhysics()
|
||||
{
|
||||
for (int j=0;j<NUM_VERTS_Y;j++)
|
||||
{
|
||||
gVertices[i+j*NUM_VERTS_X].setValue((i-NUM_VERTS_X*0.5f)*TRIANGLE_SIZE,2.f*sinf((float)i)*cosf((float)j),(j-NUM_VERTS_Y*0.5f)*TRIANGLE_SIZE);
|
||||
gVertices[i+j*NUM_VERTS_X].setValue((i-NUM_VERTS_X*0.5f)*TRIANGLE_SIZE,
|
||||
//0.f,
|
||||
2.f*sinf((float)i)*cosf((float)j),
|
||||
(j-NUM_VERTS_Y*0.5f)*TRIANGLE_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +159,7 @@ void ConcaveDemo::initPhysics()
|
||||
float mass = 0.f;
|
||||
btTransform startTransform;
|
||||
startTransform.setIdentity();
|
||||
startTransform.setOrigin(btVector3(0,0,0));
|
||||
startTransform.setOrigin(btVector3(0,-2,0));
|
||||
|
||||
btRigidBody* staticBody = localCreateRigidBody(mass, startTransform,trimeshShape);
|
||||
|
||||
|
||||
@@ -65,22 +65,43 @@ void GL_ShapeDrawer::drawCoordSystem() {
|
||||
|
||||
class GlDrawcallback : public btTriangleCallback
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
bool m_wireframe;
|
||||
|
||||
GlDrawcallback()
|
||||
:m_wireframe(false)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void processTriangle(btVector3* triangle,int partId, int triangleIndex)
|
||||
{
|
||||
glBegin(GL_LINES);
|
||||
glColor3f(1, 0, 0);
|
||||
glVertex3d(triangle[0].getX(), triangle[0].getY(), triangle[0].getZ());
|
||||
glVertex3d(triangle[1].getX(), triangle[1].getY(), triangle[1].getZ());
|
||||
glColor3f(0, 1, 0);
|
||||
glVertex3d(triangle[2].getX(), triangle[2].getY(), triangle[2].getZ());
|
||||
glVertex3d(triangle[1].getX(), triangle[1].getY(), triangle[1].getZ());
|
||||
glColor3f(0, 0, 1);
|
||||
glVertex3d(triangle[2].getX(), triangle[2].getY(), triangle[2].getZ());
|
||||
glVertex3d(triangle[0].getX(), triangle[0].getY(), triangle[0].getZ());
|
||||
glEnd();
|
||||
|
||||
if (m_wireframe)
|
||||
{
|
||||
glBegin(GL_LINES);
|
||||
glColor3f(1, 0, 0);
|
||||
glVertex3d(triangle[0].getX(), triangle[0].getY(), triangle[0].getZ());
|
||||
glVertex3d(triangle[1].getX(), triangle[1].getY(), triangle[1].getZ());
|
||||
glColor3f(0, 1, 0);
|
||||
glVertex3d(triangle[2].getX(), triangle[2].getY(), triangle[2].getZ());
|
||||
glVertex3d(triangle[1].getX(), triangle[1].getY(), triangle[1].getZ());
|
||||
glColor3f(0, 0, 1);
|
||||
glVertex3d(triangle[2].getX(), triangle[2].getY(), triangle[2].getZ());
|
||||
glVertex3d(triangle[0].getX(), triangle[0].getY(), triangle[0].getZ());
|
||||
glEnd();
|
||||
} else
|
||||
{
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(1, 0, 0);
|
||||
glVertex3d(triangle[0].getX(), triangle[0].getY(), triangle[0].getZ());
|
||||
glColor3f(0, 1, 0);
|
||||
glVertex3d(triangle[1].getX(), triangle[1].getY(), triangle[1].getZ());
|
||||
glColor3f(0, 0, 1);
|
||||
glVertex3d(triangle[2].getX(), triangle[2].getY(), triangle[2].getZ());
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -312,6 +333,7 @@ void GL_ShapeDrawer::drawOpenGL(float* m, const btCollisionShape* shape, const b
|
||||
btVector3 aabbMin(-1e30f,-1e30f,-1e30f);
|
||||
|
||||
GlDrawcallback drawCallback;
|
||||
drawCallback.m_wireframe = (debugMode & btIDebugDraw::DBG_DrawWireframe)!=0;
|
||||
|
||||
concaveMesh->processAllTriangles(&drawCallback,aabbMin,aabbMax);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user