Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Thu Aug 18, 2011 3:57 pm 
Offline

Joined: Mon Jun 02, 2008 7:21 pm
Posts: 28
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?


Top
 Profile  
 
PostPosted: Fri Aug 19, 2011 9:36 pm 
Offline

Joined: Tue Dec 29, 2009 12:48 am
Posts: 21
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.


Top
 Profile  
 
PostPosted: Sat Sep 10, 2011 5:10 pm 
Offline

Joined: Mon Jun 02, 2008 7:21 pm
Posts: 28
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...


Top
 Profile  
 
PostPosted: Sat Sep 10, 2011 6:09 pm 
Offline

Joined: Tue Dec 29, 2009 12:48 am
Posts: 21
So just create your own custom collision object class that derives from btCollisionObject. Use btRigidBody.h as a guide

Code:
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group