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