Page 1 of 1

[solved] compound collision bug

Posted: Tue Dec 14, 2010 11:09 am
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!

Re: compound collision bug

Posted: Tue Dec 14, 2010 4:47 pm
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

Re: compound collision bug

Posted: Wed Dec 15, 2010 9:01 am
by O-san
Thanks, that solved it =)

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