Bullet Collision Algorithm questions

User avatar
projectileman
Posts: 109
Joined: Thu Dec 14, 2006 4:27 pm
Location: Colombia

Bullet Collision Algorithm questions

Post by projectileman »

Hi. Currently I'm working on a new version of GIMPACT and the new ConcaveConcaveAlgorithm ( Alias btGImpactCollisionAlgorithm)

I have an issue on generating contacts, specially in creating btPersistentManifold objects. How Bullet creates contacts in its collision algorithms?

What I think right now, is that Bullet proceeds as following:

1) Given a pair of Bodies, The btCollisionDispatcher creates a new collision algorithm algorithm with findAlgorithm, This algorithm takes as parameters the Dispatcher, and the Manifold Result (btManifoldResult).

2) Then the algorithm has to create a new btPersistentManifold* by calling m_dispatcher->getNewManifold(body0,body1);

3) The algorithm tells to the Manifold Result that the current btPersistentManifold is the created in the step 2 ( m_resultOut->setPersistentManifold(m_manifoldPtr) )

3) The algorithm generates contact points, and it stores these contact poins by calling m_resultOut->addContactPoint(normal,point,distance);


Well, please tell me if I'm wrong!

Problems begin when the algorithm dispatch the collision to a new created Collision algorithm; for example, in compound shapes it is needed to redirect the collision to a ConvexConvexAlgorithm for collide two children.

At this point I don't know how to tell to the subcreated algorithm to taking the manifold created in early stage. So we get a useless manifold that won't be taken by the subcreated collision algorithms.

Also I don't know why I have to call m_dispatcher->releaseManifold(m_manifoldPtr); before making collisiions.

Any Ideas??

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

Re: Bullet Collision Algorithm questions

Post by Erwin Coumans »

projectileman wrote:Problems begin when the algorithm dispatch the collision to a new created Collision algorithm; for example, in compound shapes it is needed to redirect the collision to a ConvexConvexAlgorithm for collide two children.

At this point I don't know how to tell to the subcreated algorithm to taking the manifold created in early stage. So we get a useless manifold that won't be taken by the subcreated collision algorithms.
The first argument to the btConvexConvexAlgorithm constructor is an optional persistent manifold pointer. The compound collision algorithm can pass its persistent manifold pointer. For 2 single convex objects (no compounds, concave etc) the btConvexConvexAlgorithm will be constructed without a persistent manifold, so it will create and own it later.

m_dispatcher->releaseManifold should only be called during destruction of the collision pair.

The btConvexConvexAlgorithm keeps track of ownership of the persisten manifold, and if it doesn't own this manifold, it will leave the release to the owner (compound collision algorithm).

Note that all current collision algorithms in Bullet/src only have a single collision algorithm. This might be different for GIMPACT, because concave versus concave might need multiple contact manifolds.

Thanks,
Erwin
User avatar
projectileman
Posts: 109
Joined: Thu Dec 14, 2006 4:27 pm
Location: Colombia

Post by projectileman »

Thanks Erwin,
I've already solved.the problem. The key is creating the dispatched algorithm with findAlgorithm.
Thanks.