4
\$\begingroup\$

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?

\$\endgroup\$
  • \$\begingroup\$ If you aleady inegrated bullet to your engine, why not try it? :) Anyway, I would assume local scaling sets the scaling of the collider in its local space - meaning that it gets scaled according to the origin of the mesh. \$\endgroup\$ – János Turánszki Jan 5 '15 at 18:01
  • \$\begingroup\$ @JánosTuránszki Well.. try it means to rewrite parts of the engine :) I was not expection to use scale at first (models were scaled to its real sizes from Blender), but now I have to because of shrinking \$\endgroup\$ – Martin Perry Jan 5 '15 at 18:17
  • \$\begingroup\$ possible duplicate of Bullet Physic: Transform body after adding \$\endgroup\$ – Steven Jan 5 '15 at 18:23
  • \$\begingroup\$ Could be a duplicate of gamedev.stackexchange.com/questions/45203/… - why not try using btRigidBody::setWorldTransform(...) ? \$\endgroup\$ – Steven Jan 5 '15 at 18:25
  • \$\begingroup\$ setWorldTransform doesn´t have a scale part \$\endgroup\$ – Martin Perry Jan 5 '15 at 18:58
10
\$\begingroup\$

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.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.