Can't drive btCollisionObject from btMotionState?

Post Reply
PaulMartz
Posts: 28
Joined: Mon Jun 02, 2008 7:21 pm

Can't drive btCollisionObject from btMotionState?

Post by PaulMartz »

Hi -- I'm using Bullet for collision detection only, so I'm linking with just libBulletCollision and not using btRigidBody. I'm also visualizing the btCollisionObjects (with OSG).

I've discovered that there is no clean way to update the world transform of a btCollisionObject and also keep the graphics in sync, because btCollisionObject doesn't support btMotionState. This seems odd to me, because btMotionState is part of libBulletLinearMath, so it could be used/supported by btCollisionObject. However, it appears that btRigidBody is the only class that supports btMotionState to keep graphics in sync.

As a workaround, I currently set the world transform of both the btCollisionObject and the visual representation of that object. This works fine, but ideally it'd be cleaner to be able to use a btMotionState to keep these in sync and just set the world transform once.

Is there a reason why btCollisionObject doesn't support btMotionState?

I could probably modify Bullet to make this work, but wanted to start a discussion before I started the code dev. It seems like I'd just need to move the setMotionState member fundtion (and associated variable) to btCollisionObject, and let btRigidBody inherit them. Seems like that's about all that is needed, but there might be more.

Thoughts? Should I give it a try and post a patch to googlecode?
jazztickets
Posts: 21
Joined: Tue Dec 29, 2009 12:48 am

Re: Can't drive btCollisionObject from btMotionState?

Post by jazztickets »

PaulMartz wrote:Is there a reason why btCollisionObject doesn't support btMotionState?
Seems like motion states would only be used when the physics simulation updates the object internally. Since you're only using it for collision, you control when the objects move, not bullet.
PaulMartz
Posts: 28
Joined: Mon Jun 02, 2008 7:21 pm

Re: Can't drive btCollisionObject from btMotionState?

Post by PaulMartz »

Agreed -- If I'm not using libBulletDynamics to drive the btCollisionObject, then presumably I'm using something else to drive them. Of couse I am; and it's my own application. :-)

But, just like with a rigid body dynamics simulation, I still have a need to keep the visual representation in sync with the collision representation. The btMotionState class seems tailor-made for this purpose.

btMotionState is even in libLinearMath, a place where libBulletCollision can easily access it. But currently Bullet only uses btMotionState for rigid body dynamics. Being able to also use it for collision-only seems like a feature that is just waiting to be implemented...
jazztickets
Posts: 21
Joined: Tue Dec 29, 2009 12:48 am

Re: Can't drive btCollisionObject from btMotionState?

Post by jazztickets »

So just create your own custom collision object class that derives from btCollisionObject. Use btRigidBody.h as a guide

Code: Select all

class btMyCollisionObject: public btCollisionObject
{
    btMotionState*	m_optionalMotionState;
}
Though you'd have to create your own custom btDynamicsWorld to handle your new object.

Hacking the source code is easier, just less maintainable when new versions come out.
Post Reply