btRigidBody/btGhostObject

Post Reply
Kysen
Posts: 1
Joined: Sun Aug 23, 2009 4:15 am

btRigidBody/btGhostObject

Post by Kysen »

I was wondering if it was possible to use btRigidBody to return only the objects it has come into contact with. I don't need the contact points at all.

In my game I had set up missiles and other projectiles using a crude ray test of fixed length attached to the rigidbody but this has proved insufficient especially with area of effect projectiles. I have read up on btGhostObject and have seen that it has methods that provide exactly what I want, namely getOverlappingPairs/getOverlappingObject. The problem that arose when I tried converting my projectiles to this btCollisionObject type is that the movement functions 'setLinearVelocity' 'setGravity' are not present along with other features like setting mass/motion states. So my projectiles no longer move.

Another issue I have is that my btRigidBodies use collision masks implemented in the same way as the tutorial that came along with the SDK. Can the same technique be applied to btGhostObject? so I can filter unwanted collisions.
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: btRigidBody/btGhostObject

Post by Flix »

I think you shouldn't use ghost objects at all, but should implement a contact callback system.

If you really need to store a list of colliding bodies, I suggest you extend from btRigidBody, add a list of btRigidBody* in it and a flag to enable collision monitoring (and a "upcast" method for the new class).

Then at each physic internal substep you process the manifolds, upcast each body to the new class, if successfull you check the flag, if true you add bodies to the list (you must clear it at the beginning of the process).

Hope it makes sense.

P.S. Maybe in your case there's no need to keep a list of colliding bodies...

[edit] Well, to be honest, it's easier to use a ghost object indeed, and simply set its transform to be equal to the one of your rigid body each step... I'm sorry for having discarded this solution too early at the beginning of this post.
Post Reply