5

I have added Bullet to my game engine. So far I am using translation and rotation, and it works fine. But now, I want to scale my geometry (eg. user can drink some potion an became small :-)).

I am using

btWorldTransform.setOrigin(origin);
btWorldTransform.setRotation(rotation);

to set position of bullet body directly (it is done only once in initial object placement in scene or in case of teleportation etc. otherwise position is updated by bullet and forces)

Now, if I put object into scene, I set its btCollisionShape and that has some fixed size. Now, I change size of my scene object, graphics has scale, but what to do with bullet collision shape?

I have found setLocalScaling method, but I am not sure if it is, what I want. Can someone verify this?

Martin Perry
  • 1,106
  • 1
  • 12
  • 29

1 Answers1

13

Bullet does not allow the transform associated with a RigidBody to have any scale or shear in it. This is not uncommon; many other physics engines have this restriction as scale and shear can make the internal dynamics simulation very difficult to solve.

Instead of scaling the rigid body you will need to instead scale the shape used for collision detection. This is done by calling btCollisionShape::setLocalScaling(). You may need to call btCollisionWorld::updateSingleAABB( rigidbody ) to get the new bounding box of the scale to take effect.

Steven
  • 3,062
  • 16
  • 24