Box shape scale dynamically

Post Reply
Posts: 1
Joined: Sun Nov 05, 2017 1:56 pm

Box shape scale dynamically

Post by antmuse » Sun Nov 05, 2017 2:08 pm

Hello, I have a problem I hope to get help.
I want to create a KINEMATIC body with box shape. I want to change the shape scale dynamically. But once it's changed, there's no collision. What should I do?
Any one can help me, thanks a lot.

Posts: 10
Joined: Tue Jul 18, 2017 7:48 pm

Re: Box shape scale dynamically

Post by kossio » Wed Nov 08, 2017 8:56 am

yo, probably your body gets deactivated.

I guess if you call body->setActivationState(DISABLE_DEACTIVATION) everything should start to work as expected?

User avatar
Posts: 386
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Box shape scale dynamically

Post by drleviathan » Wed Nov 08, 2017 4:43 pm

When you change the shape of an object that is in the world you may invalidate the bounding box being used in the broadphase. This isn't a serious problem when the new shape is smaller than the old and is contained inside the old bounding box: maybe your simulation will have to process a few extra narrowphase checks that could have been culled and you waste a few CPU cycles. However, if the new shape is bigger then the simulation might not notice a collision until two objects are deeply penetrating, which causes unexpected penetrations and non-physical results.

So, when you swap in a new shape you should make sure to update the broadphase bounding box. Activating the object will cause this to happen in the next substep automagically, and is probably the best way because it may also activate nearby objects whose deactivated state is dependent on the old object's shape (e.g. they were resting on top of the old shape). However, you can update the bounding box explicitly without activation by using btCollisionWorld::updateSingleAabb().

Post Reply