btRigidBody::setLinearVelocity on static object asserts

Post Reply
jiversen
Posts: 7
Joined: Tue Nov 04, 2008 4:27 pm

btRigidBody::setLinearVelocity on static object asserts

Post by jiversen » Tue Nov 04, 2008 7:48 pm

Bullet 2.72

I'm not sure if this is an expected, but I get a crash if I set linear velocity on a Static object.

Thanks,
Jason

User avatar
Erwin Coumans
Site Admin
Posts: 4183
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: btRigidBody::setLinearVelocity on static object asserts

Post by Erwin Coumans » Tue Nov 04, 2008 8:50 pm

It is just an assert in debug mode firing off, not a real crash right? If not, what is the call stack?

You can remove the assert, but don't expect the object to move.
The static object won't move when you set its velocity. That is why it is called static. If you want motion, use dynamic or kinematic objects.

We could remove the assert, it would allow to create some interesting interaction due to friction: dynamic objects that touch the static object try to match its velocity. This can be useful for conveyor belts etc.

Thanks,
Erwin

jiversen
Posts: 7
Joined: Tue Nov 04, 2008 4:27 pm

Re: btRigidBody::setLinearVelocity on static object asserts

Post by jiversen » Wed Nov 05, 2008 12:33 am

Ah yes, thank you Erwin. That does make sense.

My assumption is that the setting of linear velocity would just be zeroed out for static objects in the API. I was just updating objects' motions in the same manner for all objects, assuming that it'd "do the right thing" with Static objects, and I wouldn't have to test for isStaticObject() myself. However, I can see there might be a reason to do the conveyor-belt behaviour for those certain rare times.

Perhaps in idea might be to have a variadic on the function like this: setVelocity( btVector3 v, bool zeroForStaticObjects=true ) ?

Either way, now that I know, I'm happy:)

Jason

Post Reply