Delete rigid body assert error

User avatar
SynapticBytes
Posts: 74
Joined: Thu Feb 10, 2011 8:27 pm

Delete rigid body assert error

Post by SynapticBytes »

Somehow I am triggering the following btRigidBody assertion in certain circumstances.

Code: Select all

00171         virtual ~btRigidBody()
00172         { 
00173                 //No constraints should point to this rigidbody
00174                 //Remove constraints from the dynamics world before you delete the related rigidbodies. 
00175                 btAssert(m_constraintRefs.size()==0); 
00176         }
Now what I'm doing is creating a hinge constraint between 2 bodies. When I set the "disableCollisionsBetweenLinkedBodies=false" on adding the constraint, the delete works fine. When I set the "disableCollisionsBetweenLinkedBodies=true" the assert is fired.

Why would changing the flag between true & false set off the error?

Any ideas? Thanks.
User avatar
SynapticBytes
Posts: 74
Joined: Thu Feb 10, 2011 8:27 pm

Re: Delete rigid body assert error

Post by SynapticBytes »

I still haven't been able to figure this one out. Setting the flag to true works OK. The bodies of my hinge do Not collide. It's only when I stop my code and the world cleanup functions run that I get the error.

What does constraintRefs do? It almost seems like when you disable collisions, a reference is removed, but still registered, so the destructor is trying to delete something that doesnt exist?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Delete rigid body assert error

Post by Erwin Coumans »

The assert tries to make sure that you first remove all constraints attach to the rigidbody, before you delete the body.

We need to add better comment in that assert.
Thanks,
Erwin
User avatar
SynapticBytes
Posts: 74
Joined: Thu Feb 10, 2011 8:27 pm

Re: Delete rigid body assert error

Post by SynapticBytes »

Erwin Coumans wrote:The assert tries to make sure that you first remove all constraints attach to the rigidbody, before you delete the body.

We need to add better comment in that assert.
Thanks,
Erwin
OK that's fine for an explanation of the message, but doesn't help with my problem. My delete world code does not change, and follows the getting started tutorials. The only change in my code between triggering and not triggering this assert is that when I set the "disableCollisionsBetweenLinkedBodies" when creating a hinge constraint. If I set it to "false" the whole program works fine. If I set it to "true" the assert first when I am cleaning up my world after the program runs.