Fix deletion of debug drawer (use a static global)

Fixes issue 608
This commit is contained in:
erwin.coumans
2012-03-15 21:56:57 +00:00
parent f4cf504223
commit 6fe42c183a

View File

@@ -29,6 +29,7 @@
#include "BulletSoftBody/btSoftBodyHelpers.h" #include "BulletSoftBody/btSoftBodyHelpers.h"
#include "GLDebugDrawer.h" #include "GLDebugDrawer.h"
static GLDebugDrawer dDebugDraw2;
#include "LinearMath/btQuickprof.h" #include "LinearMath/btQuickprof.h"
@@ -173,7 +174,7 @@ DemoApplication* CreatDemo(btDemoEntry* entry)
btAssert(demo); btAssert(demo);
if (demo->getDynamicsWorld()) if (demo->getDynamicsWorld())
{ {
demo->getDynamicsWorld()->setDebugDrawer(new GLDebugDrawer()); demo->getDynamicsWorld()->setDebugDrawer(&dDebugDraw2);
gDrawTextures = demo->getTexturing(); gDrawTextures = demo->getTexturing();
gDrawShadows = demo->getShadows(); gDrawShadows = demo->getShadows();
if (glui) if (glui)
@@ -339,8 +340,6 @@ void SimulationLoop()
} }
testIndex = testSelection; testIndex = testSelection;
if (demo->getDynamicsWorld() && demo->getDynamicsWorld()->getDebugDrawer())
delete demo->getDynamicsWorld()->getDebugDrawer();
delete demo; delete demo;
entry = g_demoEntries + testIndex; entry = g_demoEntries + testIndex;
demo = CreatDemo(entry); demo = CreatDemo(entry);
@@ -353,8 +352,6 @@ void SimulationLoop()
void RestartScene() void RestartScene()
{ {
if (demo->getDynamicsWorld() && demo->getDynamicsWorld()->getDebugDrawer())
delete demo->getDynamicsWorld()->getDebugDrawer();
delete demo; delete demo;
entry = g_demoEntries + testIndex; entry = g_demoEntries + testIndex;
demo = CreatDemo(entry); demo = CreatDemo(entry);
@@ -378,8 +375,6 @@ void Keyboard(unsigned char key, int x, int y)
// Press 'r' to reset. // Press 'r' to reset.
case 'r': case 'r':
if (demo->getDynamicsWorld() && demo->getDynamicsWorld()->getDebugDrawer())
delete demo->getDynamicsWorld()->getDebugDrawer();
delete demo; delete demo;
demo = CreatDemo(entry); demo = CreatDemo(entry);
Resize(width,height); Resize(width,height);