Moving a btCollisionObject

Salb
Posts: 4
Joined: Sun May 01, 2011 11:57 pm

Moving a btCollisionObject

Post by Salb »

I only use Bullet for mouse picking objects in my current project. I only have a btCollisionWorld (I don't use the dynamics library at all). The raytesting works fine against objects that don't move. But with objects that move when I try to translate them like this:

Code: Select all

btTransform transform(btQuaternion::getIdentity(),btVector3(visible_position.x, visible_position.y, visible_position.z));
collision_object->setWorldTransform(transform);
//collision_object->activate(); //one of many things I tried
I find I can't ray pick them anymore (I suppose because the AABB doesn't move or gets invalidated or w/e).

I tried removing the collision objects and creating new ones and adding them to the world everytime they move. However this is too slow as I have hundreds of shapes that are continuously moving and it kills my framerate.

Is there a fast way to move a btCollisionObject?
Mr.Orange
Posts: 11
Joined: Mon Apr 18, 2011 10:03 am

Re: Moving a btCollisionObject

Post by Mr.Orange »

Hi Salb,

I can't give you a decent answer, but maybe some hints that might get you closer to what you actually wanna do.

1.: if your collision objects are rigid bodies, cast them and try body->setCenterOfMassTransform(transform). Don't know why, but sometimes it helps...

2.: you can experiment with

Code: Select all

collision_object->forceActivationState(ACTIVE_TAG);
collision_object->activate();
collision_object->setDeactivationTime(0);
Especially after reset operations these calls are necessary for proper moving behavior.

Greets,
Mr.Orange 8)
Salb
Posts: 4
Joined: Sun May 01, 2011 11:57 pm

Re: Moving a btCollisionObject

Post by Salb »

Thanks for the help buddy, your suggestion didn't work but it gave me the idea to look for this method:

Code: Select all

collisionWorld->updateAabbs();
And that did it. So simple :oops:
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: Moving a btCollisionObject

Post by Flix »

Just to add that it should be possible to update aabbs on a per object basis with:

Code: Select all

collisionWorld->updateSingleAabb(myMovingCollisionObject);
AFAIK when using dynamic worlds that line is still useful (when moving static objects only) if we set:

Code: Select all

world->setForceUpdateAllAabbs(false)
.