problem with "delete world"

Leibniz
Posts: 1
Joined: Fri Jul 18, 2008 7:45 pm

problem with "delete world"

Post by Leibniz »

Hi,

I am new to Bullet and came across a little problem with destroying instances of btDiscreteDynamicsWorld. If I add a rigid body to a btDiscreteDynamicsWorld and then try to delete it, I get the following error:
pure virtual method called
terminate called without an active exception
Aborted (core dumped)
If I just remove the rigid bodies before deleting it, I don't get an error. The following minimal code demonstrates the problem. Maybe you can tell me what I am doing wrong.

Code: Select all

#include "btBulletDynamicsCommon.h"

int main(int argc, char* argv[]) {
	btCollisionConfiguration* collisionCfg = new btDefaultCollisionConfiguration;
	btDiscreteDynamicsWorld* world = new btDiscreteDynamicsWorld(
			new btCollisionDispatcher(collisionCfg),
			new btAxisSweep3(
				btVector3(-100, -100, -100),
				btVector3(100, 100, 100),
				128),
			new btSequentialImpulseConstraintSolver,
			collisionCfg);

	btTransform transform;

	btRigidBody* body = new btRigidBody(
			1.0,
			new btDefaultMotionState(transform),
			new btBoxShape(btVector3(2, 2, 2)),
			btVector3(10.0, 10.0, 10.0));

	world->addRigidBody(body);

	delete world->getDispatcher();
	delete world->getBroadphase();
	delete world->getConstraintSolver();
	delete world; // results in an error

	delete body->getMotionState();
	delete body->getCollisionShape();
	delete body;

	return 0;
}
Wavesonics
Posts: 71
Joined: Thu May 22, 2008 8:03 pm

Re: problem with "delete world"

Post by Wavesonics »

I'm pretty sure you should remove all of the ridged bodies from the simulation first.