Removing a childShape from a btCompoundShape crash

dekarguy
Posts: 6
Joined: Thu Jul 10, 2008 11:47 pm

Removing a childShape from a btCompoundShape crash

Post by dekarguy »

In bullet 2.70, I was using the following code to remove a childShape from a btCompoundShape

Code: Select all

m_pBulletWorld->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(m_pRigidBody->getBroadphaseHandle(), m_pBulletWorld->getDispatcher());
((btCompoundShape*)m_pRigidBody->getCollisionShape())->removeChildShape(m_pHitShape);

delete(m_pHitShape);
m_pHitShape = NULL;


just updated to 2.73 SP1 and I am now getting a crash in

Code: Select all

m_childCollisionAlgorithms[index]->processCollision(m_compoundColObj,m_otherObj,m_dispatchInfo,m_resultOut);
where m_childCollisionAlgorithms[index] has an out of range index of 2 (since there is only 1 child currently)

Any ideas how to clear things up to properly be able to remove a child of a compound collision object?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Removing a childShape from a btCompoundShape crash

Post by Erwin Coumans »

This features was broken in 2.73 SP1.

Can you upgrade to Bullet 2.74 beta and see if this fixes the issue?
Thanks,
Erwin
dekarguy
Posts: 6
Joined: Thu Jul 10, 2008 11:47 pm

Re: Removing a childShape from a btCompoundShape crash

Post by dekarguy »

I updated to 2.74b1 and was unable to check if it worked, as SetLinearVelocity seemed to be broken, making the situation I was testing untestable. I've reverted to 2.70 and everything is working fine.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Removing a childShape from a btCompoundShape crash

Post by Erwin Coumans »

dekarguy wrote:SetLinearVelocity seemed to be broken
We are not aware of any issue with setLinearVelocity or applyImpulse. Can you reproduce that in any of the Bullet demos?
Thanks,
Erwin
dekarguy
Posts: 6
Joined: Thu Jul 10, 2008 11:47 pm

Re: Removing a childShape from a btCompoundShape crash

Post by dekarguy »

If its not showing up anywhere else, it is most probably something configured wrong in our codebase.

Since we have bullet stable right now at 2.70 on our project, and 2.73/2.74 aren't bringing any features we need except some optimizations (and we aren't multi-core), we can't dedicate the time needed to investigate and solve the problem.

Next project we'll probably re-integrate whatever the newest version of bullet is at the time and go from there, could just be a case of bad merging with the overrides we've placed in bullet for our system
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York

Re: Removing a childShape from a btCompoundShape crash

Post by sparkprime »

I just got this (or a very similar) problem with latest svn (I just started using the removal of child shapes feature).

Here is a patch that fixes it for me:

Code: Select all

Index: src/BulletCollision/CollisionShapes/btCompoundShape.cpp
===================================================================
--- src/BulletCollision/CollisionShapes/btCompoundShape.cpp (revision 2052)
+++ src/BulletCollision/CollisionShapes/btCompoundShape.cpp (working copy)
@@ -110,6 +110,7 @@
        m_dynamicAabbTree->remove(m_children[childShapeIndex].m_node);
    }
    m_children.swap(childShapeIndex,m_children.size()-1);
+    if (m_dynamicAabbTree) m_children[childShapeIndex].m_node->dataAsInt = childShapeIndex;
    m_children.pop_back();

 }
To help debugging this in future, I also added this assert before the getNumChildShapes() part of btCompoundLeafCallback::Process in btCompoundCollisionAlgorithm.cpp

Code: Select all

assert(index>=0); assert(index<compoundShape->getNumChildShapes());
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Removing a childShape from a btCompoundShape crash

Post by Erwin Coumans »

Good find.

Can you please file an issue in the google issue tracker with a patch against latest trunk?
http://code.google.com/p/bullet/issues/list

Thanks a lot,
Erwin