vanderlin / ofxBox2d

Openframework wrapper for box2d
zlib License
320 stars 122 forks source link

calling ofxBox2d multiple times will crash #93

Closed mihai-moldovan closed 5 years ago

mihai-moldovan commented 9 years ago

In case I want to reinitialise the world and I call ofxBox2d.init() again after setting the ground, the framework will crash.

Proposed fix in ofBox2d.init(): first destroy the ground, then delete the world: if(ground!=NULL) { world->DestroyBody(ground); ground = NULL; }

delete world; world = NULL; world = new b2World(b2Vec2(gravity.x, gravity.y)); world->SetAllowSleeping(doSleep); //world->SetDebugDraw(&debugRender);