//-------------------------------------------------------------- void ofxBulletWorldRigid::destroy() { cout << "ofxBulletWorldRigid :: destroy : destroy() " << endl; //cleanup in the reverse order of creation/initialization int i; //remove/delete constraints if(world != NULL) { removeMouseConstraint(); cout << "ofxBulletWorldRigid :: destroy : num constraints= " << world->getNumConstraints() << endl; for (i = world->getNumConstraints()-1; i >= 0; i--) { btTypedConstraint* constraint = world->getConstraint(i); world->removeConstraint(constraint); delete constraint; } } //remove the rigidbodies from the dynamics world and delete them if(world != NULL) { cout << "ofxBulletWorldRigid :: destroy : num collision objects= " << world->getNumCollisionObjects() << endl; for (i = world->getNumCollisionObjects()-1; i >= 0; i--) { btCollisionObject* obj = world->getCollisionObjectArray()[i]; btRigidBody* body = btRigidBody::upcast(obj); if (body != 0 && body != NULL && body->getMotionState()) { delete body->getMotionState(); } world->removeCollisionObject( obj ); delete obj; } } if(world != NULL) delete world; world = NULL; if(solver != NULL) delete solver; solver = NULL; if(dispatcher != NULL) delete dispatcher; dispatcher = NULL; if(collisionConfig != NULL) delete collisionConfig; collisionConfig = NULL; if(broadphase != NULL) delete broadphase; broadphase = NULL; }
//-------------------------------------------------------------- void ofxBulletWorldSoft::mouseReleased( ofMouseEventArgs &a ) { _bMouseDown = false; removeMouseConstraint(); }