changes in debug drawing, thanks to Dennis Cappendijk
See Issue 559
This commit is contained in:
@@ -53,6 +53,7 @@ namespace
|
||||
int tx, ty, tw, th;
|
||||
int gDrawAabb;
|
||||
int gWireFrame;
|
||||
int gDrawNormals;
|
||||
int gHelpText;
|
||||
int gDebugConstraints;
|
||||
int gDebugContacts;
|
||||
@@ -81,6 +82,7 @@ void setDefaultSettings()
|
||||
height = 768;//480;
|
||||
iterationCount = 10;
|
||||
gDrawAabb=0;
|
||||
gDrawNormals=0;
|
||||
gWireFrame=0;
|
||||
gDebugContacts=0;
|
||||
//enable constraint debug visualization for first demo, only if user hasn't overridden the setting
|
||||
@@ -226,7 +228,13 @@ void SimulationLoop()
|
||||
} else
|
||||
{
|
||||
demo->setDebugMode(demo->getDebugMode() & (~btIDebugDraw::DBG_DrawWireframe));
|
||||
|
||||
}
|
||||
if (gDrawNormals)
|
||||
{
|
||||
demo->setDebugMode(demo->getDebugMode() |btIDebugDraw::DBG_DrawNormals);
|
||||
} else
|
||||
{
|
||||
demo->setDebugMode(demo->getDebugMode() & (~btIDebugDraw::DBG_DrawNormals));
|
||||
}
|
||||
if (gHelpText)
|
||||
{
|
||||
@@ -327,7 +335,7 @@ void SimulationLoop()
|
||||
gDebugConstraints=0;
|
||||
} else
|
||||
{
|
||||
gDebugConstraints=1;
|
||||
gDebugConstraints=1;
|
||||
}
|
||||
|
||||
testIndex = testSelection;
|
||||
@@ -531,6 +539,7 @@ int main(int argc, char** argv)
|
||||
glui->add_checkbox_to_panel(drawPanel, "Help", &gHelpText);
|
||||
glui->add_checkbox_to_panel(drawPanel, "AABBs", &gDrawAabb);
|
||||
glui->add_checkbox_to_panel(drawPanel, "Wireframe", &gWireFrame);
|
||||
glui->add_checkbox_to_panel(drawPanel, "Normals", &gDrawNormals);
|
||||
glui->add_checkbox_to_panel(drawPanel, "Contacts", &gDebugContacts);
|
||||
glui->add_checkbox_to_panel(drawPanel, "Constraints", &gDebugConstraints);
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ void CharacterDemo::initPhysics()
|
||||
btTransform tr;
|
||||
tr.setIdentity();
|
||||
|
||||
char* bspfilename = "BspDemo.bsp";
|
||||
const char* bspfilename = "BspDemo.bsp";
|
||||
void* memoryBuffer = 0;
|
||||
|
||||
FILE* file = fopen(bspfilename,"r");
|
||||
|
||||
@@ -391,6 +391,12 @@ void DemoApplication::keyboardCallback(unsigned char key, int x, int y)
|
||||
else
|
||||
m_debugMode |= btIDebugDraw::DBG_DisableBulletLCP;
|
||||
break;
|
||||
case 'N':
|
||||
if (m_debugMode & btIDebugDraw::DBG_DrawNormals)
|
||||
m_debugMode = m_debugMode & (~btIDebugDraw::DBG_DrawNormals);
|
||||
else
|
||||
m_debugMode |= btIDebugDraw::DBG_DrawNormals;
|
||||
break;
|
||||
|
||||
case 't' :
|
||||
if (m_debugMode & btIDebugDraw::DBG_DrawText)
|
||||
|
||||
@@ -1198,15 +1198,14 @@ public:
|
||||
wv1 = m_worldTrans*triangle[1];
|
||||
wv2 = m_worldTrans*triangle[2];
|
||||
btVector3 center = (wv0+wv1+wv2)*btScalar(1./3.);
|
||||
|
||||
btVector3 normal = (wv1-wv0).cross(wv2-wv0);
|
||||
normal.normalize();
|
||||
btVector3 normalColor(1,1,0);
|
||||
m_debugDrawer->drawLine(center,center+normal,normalColor);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_DrawNormals )
|
||||
{
|
||||
btVector3 normal = (wv1-wv0).cross(wv2-wv0);
|
||||
normal.normalize();
|
||||
btVector3 normalColor(1,1,0);
|
||||
m_debugDrawer->drawLine(center,center+normal,normalColor);
|
||||
}
|
||||
m_debugDrawer->drawLine(wv0,wv1,m_color);
|
||||
m_debugDrawer->drawLine(wv1,wv2,m_color);
|
||||
m_debugDrawer->drawLine(wv2,wv0,m_color);
|
||||
@@ -1257,11 +1256,12 @@ void btCollisionWorld::debugDrawObject(const btTransform& worldTransform, const
|
||||
}
|
||||
}
|
||||
centroid*= btScalar(1.f)/btScalar(numVerts);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1388,7 +1388,7 @@ void btCollisionWorld::debugDrawObject(const btTransform& worldTransform, const
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1398,7 +1398,7 @@ void btCollisionWorld::debugDrawWorld()
|
||||
if (getDebugDrawer() && getDebugDrawer()->getDebugMode() & btIDebugDraw::DBG_DrawContactPoints)
|
||||
{
|
||||
int numManifolds = getDispatcher()->getNumManifolds();
|
||||
btVector3 color(0,0,0);
|
||||
btVector3 color(1,0.65,0);
|
||||
for (int i=0;i<numManifolds;i++)
|
||||
{
|
||||
btPersistentManifold* contactManifold = getDispatcher()->getManifoldByIndexInternal(i);
|
||||
|
||||
@@ -313,7 +313,7 @@ void btDiscreteDynamicsWorld::debugDrawWorld()
|
||||
|
||||
|
||||
|
||||
if (getDebugDrawer() && (getDebugDrawer()->getDebugMode() & (btIDebugDraw::DBG_DrawWireframe | btIDebugDraw::DBG_DrawAabb)))
|
||||
if (getDebugDrawer() && (getDebugDrawer()->getDebugMode() & (btIDebugDraw::DBG_DrawWireframe | btIDebugDraw::DBG_DrawAabb | btIDebugDraw::DBG_DrawNormals)))
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ class btIDebugDraw
|
||||
DBG_DrawConstraints = (1 << 11),
|
||||
DBG_DrawConstraintLimits = (1 << 12),
|
||||
DBG_FastWireframe = (1<<13),
|
||||
DBG_DrawNormals = (1<<14),
|
||||
DBG_MAX_DEBUG_DRAW_MODE
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user