Adding a reference to a non-bullet rigidbody

AshMcConnell
Posts: 29
Joined: Sat Sep 23, 2006 1:35 pm
Location: Northern Ireland

Adding a reference to a non-bullet rigidbody

Post by AshMcConnell »

Hi Folks,

I am hoping to use bullet to do only collision detection. Appolgies of this is a silly question, but I couldnt find the answer when I searched.

I have written a few tests using the collisionObject + collisionWorld objects using collisionWorld->AddCollisionObject(collisionObject) and all seems to work as i'd expect (hurah!) :)

I am hoping to add a reference to my rigidbody object. I see that the AddCollisionObject creates a broadphase proxy with the reference as the collisionObject that was passed in.

I was hoping to add another AddCollisionObject method with an extra void* parameter which will be passed on to the CreateProxy method.

Is this a sensible thing to do? Does anyone see any problem with doing it that way?

Thanks for your help and thanks for giving us Bullet!

All the best,
Ash
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Adding a reference to a non-bullet rigidbody

Post by Erwin Coumans »

AshMcConnell wrote:Hi Folks,

I am hoping to use bullet to do only collision detection. Appolgies of this is a silly question, but I couldnt find the answer when I searched.

I have written a few tests using the collisionObject + collisionWorld objects using collisionWorld->AddCollisionObject(collisionObject) and all seems to work as i'd expect (hurah!) :)

I am hoping to add a reference to my rigidbody object. I see that the AddCollisionObject creates a broadphase proxy with the reference as the collisionObject that was passed in.

I was hoping to add another AddCollisionObject method with an extra void* parameter which will be passed on to the CreateProxy method.

Is this a sensible thing to do? Does anyone see any problem with doing it that way?

Thanks for your help and thanks for giving us Bullet!

All the best,
Ash
Did you try to create a CollisionObject, and then pointing its

Code: Select all

m_userObjectPointer
to your rigidbody?

Hope this helps,
Erwin
AshMcConnell
Posts: 29
Joined: Sat Sep 23, 2006 1:35 pm
Location: Northern Ireland

Post by AshMcConnell »

Oops, missed that one :oops:

So I just get the CollisionObject from the manifold like this: -

Code: Select all

CollisionObject* obA = static_cast<CollisionObject*>(contactManifold->GetBody0());
CollisionObject* obB = static_cast<CollisionObject*>(contactManifold->GetBody1());
and get my own rigidbody by doing a simple: -

Code: Select all

MyRigidBody *rb = (MyRigidBody *)obA->m_userObjectPointer;
Thanks!
All the best,
Ash