registerCollisionCreateFunc works but why?!

ChrisC
Posts: 12
Joined: Wed Nov 29, 2006 9:27 am

registerCollisionCreateFunc works but why?!

Post by ChrisC »

atm I'm using (without understanding...)

Code: Select all

gimpactCollisionCreateFunc = new btConcaveConcaveCollisionAlgorithm::CreateFunc;

dispatcher->registerCollisionCreateFunc(GIMPACT_SHAPE_PROXYTYPE,GIMPACT_SHAPE_PROXYTYPE,gimpactCollisionCreateFunc);
dispatcher->registerCollisionCreateFunc(TRIANGLE_MESH_SHAPE_PROXYTYPE,GIMPACT_SHAPE_PROXYTYPE,gimpactCollisionCreateFunc);
dispatcher->registerCollisionCreateFunc(GIMPACT_SHAPE_PROXYTYPE,TRIANGLE_MESH_SHAPE_PROXYTYPE,gimpactCollisionCreateFunc);
I fully expected to have to register gimpact shapes against every primitive type why does this seem to work ?

why does [type A] to [type B] collision NOT equal [type B] to [type A] collison ?

I've looked in the API docs and code for any info but seem to have come up short, so I guess I'm not the only one using this stuff without understanding how / why it should be used in any particular way :(

for all I know a few extra register calls could greatly improve stuff (or break it!).

At any rate I've been using a torus shape as a moving concave mesh with other primitive shapes and I'm really impressed with the speed and stability :D TOP JOB guys!!!!
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: registerCollisionCreateFunc works but why?!

Post by Erwin Coumans »

The MovingConcaveDemo show how to use GIMPACT shapes. No additional information is required.
I fully expected to have to register gimpact shapes against every primitive type why does this seem to work ?
Why does [type A] to [type B] collision NOT equal [type B] to [type A] collison ?
Bullet will need to swap the collision shapes, and registers a swapped version of the algorithm. The algorithm IS equal, but the create func has a swapped flag. The Bullet User Manual shows the default CollisionMatrix.

You should not need to worry about those internals. All collision shapes will interact with GIMPACT shape, because it implements the btConcaveShape interface, so it produces triangles on request. The dispatcher will dispatch triangle versus collision shape type, using the registered collision function.
At any rate I've been using a torus shape as a moving concave mesh with other primitive shapes and I'm really impressed with the speed and stability :D TOP JOB guys!!!!
Thanks to Francisco for GIMPACT integration.

Erwin
ChrisC
Posts: 12
Joined: Wed Nov 29, 2006 9:27 am

Post by ChrisC »

The algorithm IS equal, but the create func has a swapped flag.
I missed this bit, what and where is the swapped flag?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

ChrisC wrote:
The algorithm IS equal, but the create func has a swapped flag.
I missed this bit, what and where is the swapped flag?
See http://www.continuousphysics.com/Bullet ... eFunc.html

For example, btSphereBoxCollisionAlgorithm is registered twice using its CreateFunc into the CollisionMap: sphere versus box, and for box versus sphere (with the swapped bit to true).

Notice that Bullet will recursively call the Collision Dispatcher for compound and concave shapes, which complicates swapping.

Erwin
ChrisC
Posts: 12
Joined: Wed Nov 29, 2006 9:27 am

Post by ChrisC »

that URL just seems to be a list of structures members , I still don't see any swapped flag and without any real explanation I can't see how its supposed to be used...

Just what is a SwappedCreateFunc it is not described anywhere
(other than another list of structure members without description)

is
btConvexConcaveCollisionAlgorithm::CreateFunc
for A to B

the same as A to B and B to A SwappedCreateFunc together???

is so why bother with the SwappedCreateFunc at all?

now I'm even more confused
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

ChrisC wrote:that URL just seems to be a list of structures members , I still don't see any swapped flag and without any real explanation I can't see how its supposed to be used...
Please do a text search on 'swapped' and you will find it in the link I posted.
This inernal functionality is quite complicated, and not meant as API.
now I'm even more confused
If this internal code gets you confused, I would recommend not to digg any deeper and just use the API as the demos show.
Butters9637
Posts: 7
Joined: Tue Mar 06, 2007 3:26 am

Post by Butters9637 »

I did some experiments on the demo
I use the code

Code: Select all

//	m_sphereBoxCF = new btSphereBoxCollisionAlgorithm::CreateFunc;
	m_boxSphereCF = new btSphereBoxCollisionAlgorithm::CreateFunc;
	m_boxSphereCF->m_swapped = true;
//	m_dispatcher->registerCollisionCreateFunc(SPHERE_SHAPE_PROXYTYPE,BOX_SHAPE_PROXYTYPE,m_sphereBoxCF);
	m_dispatcher->registerCollisionCreateFunc(BOX_SHAPE_PROXYTYPE,SPHERE_SHAPE_PROXYTYPE,m_boxSphereCF);
those spheres could still collide with the ground. I don`t know why it still works.is "m_dispatcher->registerCollisionCreateFunc(SPHERE_SHAPE_PROXYTYPE,BOX_SHAPE_PROXYTYPE,m_sphereBoxCF);"
not necessary? if they are not here then in what circumstances they are necessary. sorry for my broken English .