Advertisement

Invalid internal pointers after startup

Started by January 30, 2014 09:57 AM
0 comments, last by bmarci 10 years, 10 months ago

Hi, I've been playing around with bullet and bumped into a problem.

The collision shapes cannot be deleted right after they are created.

Here are some samples;

First the init:


coll_config=new btDefaultCollisionConfiguration();
coll_dispatch=new btCollisionDispatcher(coll_config);
overlap_paircache=new btDbvtBroadphase();
solver=new btSequentialImpulseConstraintSolver;
world=new btDiscreteDynamicsWorld(coll_dispatch,overlap_paircache,solver,coll_config);

world->setGravity(btVector3(0,-9.81f,0));

pretty simple, from the basic samples.

And this is weird:


// Create the shape
btCollisionShape* shape=new btBoxShape(btVector3(1,1,1));
btVector3 inertia(0,0,0);
shape->calculateLocalInertia(5,inertia);
	
btTransform trans;
trans.setBasis(btMatrix3x3(1,0,0,0,1,0,0,0,1));
trans.setOrigin(btVector3(0,0,0));

btDefaultMotionState* mstate=new btDefaultMotionState(trans);
btRigidBody::btRigidBodyConstructionInfo ci(5,mstate,shape,inertia);
btRigidBody* body=new btRigidBody(ci);
world->addRigidBody(body);

// And remove!
btCollisionObject* obj=world->getCollisionObjectArray()[0];
delete body->getCollisionShape();
delete body->getMotionState();
delete body;
world->removeCollisionObject(obj);
delete obj;

The remove method is also from some basic sample.

But in this case the removeCollisionObject() references some uninitialized broadphase proxy pointer.

in btDbvtBroadphase::destroyProxy

The same happens with SimpleBroadphaseProxy.

the strange thing is, the whole thing works after the simulation is running for some time.

Did anybody have anything similar???

Sorry, my bad unsure.png

the "body" and "obj" are the same pointer and freed before remove.

This topic is closed to new replies.

Advertisement