re-create debug drawer after 'resetSimulation', also avoid memory leak after doing so.

this fixes wireframe.
Also use <CTRL>+hotkey, to avoid conflicts with user-specified keyboard functions.
This commit is contained in:
Erwin Coumans
2017-04-11 16:03:07 -07:00
parent fe199bea09
commit 80e87d5ccb
3 changed files with 92 additions and 80 deletions

View File

@@ -201,6 +201,8 @@ void MyKeyboardCallback(int key, int state)
//if (handled) //if (handled)
// return; // return;
if (s_window && s_window->isModifierKeyPressed(B3G_CONTROL))
{
if (key=='a' && state) if (key=='a' && state)
{ {
gDebugDrawFlags ^= btIDebugDraw::DBG_DrawAabb; gDebugDrawFlags ^= btIDebugDraw::DBG_DrawAabb;
@@ -293,6 +295,7 @@ void MyKeyboardCallback(int key, int state)
b3Printf("F1 released %d",count++); b3Printf("F1 released %d",count++);
} }
} }
}
if (key==B3G_ESCAPE && s_window) if (key==B3G_ESCAPE && s_window)
{ {

View File

@@ -338,6 +338,12 @@ void OpenGLGuiHelper::render(const btDiscreteDynamicsWorld* rbWorld)
void OpenGLGuiHelper::createPhysicsDebugDrawer(btDiscreteDynamicsWorld* rbWorld) void OpenGLGuiHelper::createPhysicsDebugDrawer(btDiscreteDynamicsWorld* rbWorld)
{ {
btAssert(rbWorld); btAssert(rbWorld);
if (m_data->m_debugDraw)
{
delete m_data->m_debugDraw;
m_data->m_debugDraw = 0;
}
m_data->m_debugDraw = new MyDebugDrawer(m_data->m_glApp); m_data->m_debugDraw = new MyDebugDrawer(m_data->m_glApp);
rbWorld->setDebugDrawer(m_data->m_debugDraw ); rbWorld->setDebugDrawer(m_data->m_debugDraw );

View File

@@ -1515,7 +1515,10 @@ void PhysicsServerCommandProcessor::createEmptyDynamicsWorld()
// m_data->m_dynamicsWorld->getSolverInfo().m_minimumSolverBatchSize = 2; // m_data->m_dynamicsWorld->getSolverInfo().m_minimumSolverBatchSize = 2;
//todo: islands/constraints are buggy in btMultiBodyDynamicsWorld! (performance + see slipping grasp) //todo: islands/constraints are buggy in btMultiBodyDynamicsWorld! (performance + see slipping grasp)
if (m_data->m_guiHelper)
{
m_data->m_guiHelper->createPhysicsDebugDrawer(m_data->m_dynamicsWorld);
}
m_data->m_dynamicsWorld->setInternalTickCallback(logCallback,this); m_data->m_dynamicsWorld->setInternalTickCallback(logCallback,this);
} }