re-enable debug drawing of box, instead of using the generic convex path.
Fixes Issue 622. Thanks for the report!
This commit is contained in:
@@ -1251,57 +1251,6 @@ void btCollisionWorld::debugDrawObject(const btTransform& worldTransform, const
|
||||
} else
|
||||
{
|
||||
|
||||
/// for polyhedral shapes
|
||||
if (shape->isPolyhedral())
|
||||
{
|
||||
btPolyhedralConvexShape* polyshape = (btPolyhedralConvexShape*) shape;
|
||||
|
||||
int i;
|
||||
if (polyshape->getConvexPolyhedron())
|
||||
{
|
||||
const btConvexPolyhedron* poly = polyshape->getConvexPolyhedron();
|
||||
for (i=0;i<poly->m_faces.size();i++)
|
||||
{
|
||||
btVector3 centroid(0,0,0);
|
||||
int numVerts = poly->m_faces[i].m_indices.size();
|
||||
if (numVerts)
|
||||
{
|
||||
int lastV = poly->m_faces[i].m_indices[numVerts-1];
|
||||
for (int v=0;v<poly->m_faces[i].m_indices.size();v++)
|
||||
{
|
||||
int curVert = poly->m_faces[i].m_indices[v];
|
||||
centroid+=poly->m_vertices[curVert];
|
||||
getDebugDrawer()->drawLine(worldTransform*poly->m_vertices[lastV],worldTransform*poly->m_vertices[curVert],color);
|
||||
lastV = curVert;
|
||||
}
|
||||
}
|
||||
centroid*= btScalar(1.f)/btScalar(numVerts);
|
||||
if (getDebugDrawer()->getDebugMode() & btIDebugDraw::DBG_DrawNormals)
|
||||
{
|
||||
btVector3 normalColor(1,1,0);
|
||||
btVector3 faceNormal(poly->m_faces[i].m_plane[0],poly->m_faces[i].m_plane[1],poly->m_faces[i].m_plane[2]);
|
||||
getDebugDrawer()->drawLine(worldTransform*centroid,worldTransform*(centroid+faceNormal),normalColor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
} else
|
||||
{
|
||||
for (i=0;i<polyshape->getNumEdges();i++)
|
||||
{
|
||||
btVector3 a,b;
|
||||
polyshape->getEdge(i,a,b);
|
||||
btVector3 wa = worldTransform * a;
|
||||
btVector3 wb = worldTransform * b;
|
||||
getDebugDrawer()->drawLine(wa,wb,color);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (shape->getShapeType())
|
||||
{
|
||||
|
||||
@@ -1380,6 +1329,56 @@ void btCollisionWorld::debugDrawObject(const btTransform& worldTransform, const
|
||||
default:
|
||||
{
|
||||
|
||||
/// for polyhedral shapes
|
||||
if (shape->isPolyhedral())
|
||||
{
|
||||
btPolyhedralConvexShape* polyshape = (btPolyhedralConvexShape*) shape;
|
||||
|
||||
int i;
|
||||
if (polyshape->getConvexPolyhedron())
|
||||
{
|
||||
const btConvexPolyhedron* poly = polyshape->getConvexPolyhedron();
|
||||
for (i=0;i<poly->m_faces.size();i++)
|
||||
{
|
||||
btVector3 centroid(0,0,0);
|
||||
int numVerts = poly->m_faces[i].m_indices.size();
|
||||
if (numVerts)
|
||||
{
|
||||
int lastV = poly->m_faces[i].m_indices[numVerts-1];
|
||||
for (int v=0;v<poly->m_faces[i].m_indices.size();v++)
|
||||
{
|
||||
int curVert = poly->m_faces[i].m_indices[v];
|
||||
centroid+=poly->m_vertices[curVert];
|
||||
getDebugDrawer()->drawLine(worldTransform*poly->m_vertices[lastV],worldTransform*poly->m_vertices[curVert],color);
|
||||
lastV = curVert;
|
||||
}
|
||||
}
|
||||
centroid*= btScalar(1.f)/btScalar(numVerts);
|
||||
if (getDebugDrawer()->getDebugMode() & btIDebugDraw::DBG_DrawNormals)
|
||||
{
|
||||
btVector3 normalColor(1,1,0);
|
||||
btVector3 faceNormal(poly->m_faces[i].m_plane[0],poly->m_faces[i].m_plane[1],poly->m_faces[i].m_plane[2]);
|
||||
getDebugDrawer()->drawLine(worldTransform*centroid,worldTransform*(centroid+faceNormal),normalColor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
} else
|
||||
{
|
||||
for (i=0;i<polyshape->getNumEdges();i++)
|
||||
{
|
||||
btVector3 a,b;
|
||||
polyshape->getEdge(i,a,b);
|
||||
btVector3 wa = worldTransform * a;
|
||||
btVector3 wb = worldTransform * b;
|
||||
getDebugDrawer()->drawLine(wa,wb,color);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (shape->isConcave())
|
||||
{
|
||||
btConcaveShape* concaveMesh = (btConcaveShape*) shape;
|
||||
@@ -1407,7 +1406,7 @@ void btCollisionWorld::debugDrawObject(const btTransform& worldTransform, const
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user