[solved] compound collision bug

O-san
Posts: 19
Joined: Mon May 11, 2009 8:46 am

[solved] compound collision bug

Post by O-san »

Hello!

I am scaling a child shape of a compound object. The scaling seems fine in debug draw but the collisions does not take place. The body should be pushed out from a nearby wall when the child gets enlarged, this does not happen. I have tried scaling the shape without a compound object and that works fine, the body gets pushed out. Here's my code for scaling the object:

Code: Select all

    if (mBody->getCollisionShape()->isCompound()){
      btCompoundShape * comp = (btCompoundShape *)mBody->getCollisionShape();
      btCollisionShape * child = comp->getChildShape(0);
      if(child!=0){
        child->setLocalScaling(btVector3(2.5,2.5,1));
      }
      ((btCompoundShape *)mBody->getCollisionShape())->recalculateLocalAabb();
    }
I have also tried updating the inertia tensor and setMassProps without any success. Any help appreciated!
Last edited by O-san on Wed Dec 15, 2010 9:02 am, edited 1 time in total.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: compound collision bug

Post by Erwin Coumans »

To fix the collision issues, try calling the

Code: Select all

void	btCompoundShape::updateChildTransform(int childIndex, const btTransform& newChildTransform)
using the old transform. This should update the internal data structures.

For the inertia tensor, make sure to remove the object from the world before making the change, and re-insert it afterwards.
Thanks,
Erwin
O-san
Posts: 19
Joined: Mon May 11, 2009 8:46 am

Re: compound collision bug

Post by O-san »

Thanks, that solved it =)

Is it necessary to update the inertia tensor if I have disabled angular factor with setAngularFactor(0)?