Collision Questions

LaceySnr
Posts: 11
Joined: Fri Mar 20, 2009 11:11 am

Collision Questions

Post by LaceySnr »

Hi guys,

I started plugging bullet into my OpenGL engine last week for collision detection only and so far haven't been 100% successful.

ATM I'm just using a few btConvexHullShapes and adding them to a btCollisionWorld, updating their transforms using the OpenGL matrices at render time and then calling performDiscreteCollisionDetection().

ATM however, I seem to get no contacts reported when objects are intersecting - I can tell some tests are going on because the frame rate drops when two objects are close (probably intersecting aabb's). I wanted to use the debug draw stuff but debugDrawWorld doesn't exist in btCollisionWorld, only in the dynamics stuff. Is it ok to use one of those as a btCollisionWorld object?

Also is there a way to optimise collision detection such that only the first contact point is found for two objects? I don't really need to know all the details about a collision - just want to know that one has happened.

Finally (deep breath) how do I go about setting up call backs for collisions, the documentation seems a little thin on the ground in that area - the collision interface demo simply lists stepping through the manifolds + contact points (which I'm currently using to get the number of contact points - 0).

Cheers,

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

Re: Collision Questions

Post by Erwin Coumans »

LaceySnr wrote: ATM however, I seem to get no contacts reported when objects are intersecting - I can tell some tests are going on because the frame rate drops when two objects are close (probably intersecting aabb's). I wanted to use the debug draw stuff but debugDrawWorld doesn't exist in btCollisionWorld, only in the dynamics stuff. Is it ok to use one of those as a btCollisionWorld object?
We will enable debug drawing for btCollisionWorld, you can track progress in this issue. For now, please use a btDiscreteDynamicsWorld (which extends btCollisionWorld), and fill it will btCollisionObjects, to enable debug visualization.
Also is there a way to optimise collision detection such that only the first contact point is found for two objects? I don't really need to know all the details about a collision - just want to know that one has happened.
The best optimization is to reduce the number of vertices in the convex objects, more then 64 points is usually overkill. There is an automatic method to reduce the number of points, using the btShapeHull utility (see latest user manual, Bullet_User_Manual.pdf, included in the Bullet source code distribution).
Finally (deep breath) how do I go about setting up call backs for collisions, the documentation seems a little thin on the ground in that area - the collision interface demo simply lists stepping through the manifolds + contact points (which I'm currently using to get the number of contact points - 0).
Iterating over all contact manifolds + contact points is generally the best way, as described in the wiki. Some developers use/abuse the internal contact add/removed callbacks to detect collisions, but those won't give you all contact points, and they are only meant as an advanced way to customize contact data, such as friction and restitution. The same wiki page also mentionsthat you can use a btGhostObject that keeps track of only its own overlapping objects (to avoid iterating over all persistent manifolds).

Hope this helps,
Erwin
LaceySnr
Posts: 11
Joined: Fri Mar 20, 2009 11:11 am

Re: Collision Questions

Post by LaceySnr »

Thanks Erwin,

I guess I'll get that debug drawing working and then go from there - hopefully that'll give me some idea of why my objects aren't reporting contacts as I expect.

I've been reading that certain shapes are for static geometry only, while others are for dynamic objects - is this still relevant when only using the collision detection routines?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Collision Questions

Post by Erwin Coumans »

LaceySnr wrote: I've been reading that certain shapes are for static geometry only, while others are for dynamic objects - is this still relevant when only using the collision detection routines?
This restriction only applies when you use those collision shapes for rigid bodies, because some collision shapes can't provide an appropriate inertia tensor. Note that there is no collision algorithm to detection collisions among/between btStaticPlaneShapes and btHeightfieldTerrainShape.
LaceySnr
Posts: 11
Joined: Fri Mar 20, 2009 11:11 am

Re: Collision Questions

Post by LaceySnr »

Another quickie...

When rendering collision points with the debug drawer, should they be in world space? All my contact points which render appear to be around the origin, when the AABB's for the objects involved can be quite some distance away.

I've noticed the collision interface demo uses some functions to get their positions on particular objects, but since the renderer is simply fed a position I assumed it would be in world coords - is this incorrect?