Page 1 of 1

btRigidBody::setLinearVelocity on static object asserts

Posted: Tue Nov 04, 2008 7:48 pm
by jiversen
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

Re: btRigidBody::setLinearVelocity on static object asserts

Posted: Tue Nov 04, 2008 8:50 pm
by Erwin Coumans
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

Re: btRigidBody::setLinearVelocity on static object asserts

Posted: Wed Nov 05, 2008 12:33 am
by jiversen
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