[solved] compound collision

madMAx4
Posts: 27
Joined: Fri Apr 20, 2007 7:29 pm
Location: Germany

[solved] compound collision

Post by madMAx4 »

Hi,

i'm trying to set up convex decomposition.
so i pass every piece of result (btConvexTriangleMeshShape) to a btCompoundShape.

now how do i set up collision between the compound and a btTriangleMeshShape for example?

i tried this, but nothing works:

Code: Select all

	cDispatcher->registerCollisionCreateFunc(CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE, TRIANGLE_MESH_SHAPE_PROXYTYPE, convexconcaveCollisionFunc);
	cDispatcher->registerCollisionCreateFunc(TRIANGLE_MESH_SHAPE_PROXYTYPE, CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE, swappedconvexconcaveCollisionFunc);

	cDispatcher->registerCollisionCreateFunc(COMPOUND_SHAPE_PROXYTYPE, TRIANGLE_MESH_SHAPE_PROXYTYPE, compoundCollisionFunc);
	cDispatcher->registerCollisionCreateFunc(TRIANGLE_MESH_SHAPE_PROXYTYPE, COMPOUND_SHAPE_PROXYTYPE, swappedcompoundCollisionFunc);
maybe i missed something?
thx in advance.
Last edited by madMAx4 on Fri May 11, 2007 7:55 pm, edited 1 time in total.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

You should not need to register any functions to the dispatcher, the default btCollisionDispatcher should work out-of-the box with compounds.

Check btCollisionDispatcher::internalFindCreateFunc how it populates all collision functions.

You can test compound versus triangle mesh, by making following changes to create compounds instead of boxes, around line 210 in ConcavePhysicsDemo.cpp of ConcaveDemo in Bullet 2.50:

Code: Select all

	{
		for (int i=0;i<10;i++)
		{
			btCollisionShape* boxShape = new btBoxShape(btVector3(1,1,1));
			btCompoundShape* compound = new btCompoundShape();
			btTransform tr;
			tr.setIdentity();
			compound->addChildShape(tr,boxShape);

			startTransform.setOrigin(btVector3(2*i,10,1));
			localCreateRigidBody(1, startTransform,compound);
		}
	}
Apart from that, you should use btBvhTriangleMeshShape instead of btTriangleMeshShape (although btTriangleMeshShape works too with compounds in the modified ConcaveDemo). It is probably a good idea to remove btTriangleMeshShape from the Bullet SDK.

Hope this helps,
Erwin
madMAx4
Posts: 27
Joined: Fri Apr 20, 2007 7:29 pm
Location: Germany

Post by madMAx4 »

i just found out that the ConcaveDemo doesnt work, with box shapes nor compounds. the boxes just fall through and there are no waves.
the old 2.49 one works ok.

where could be the problem?

EDIT: i have just recompiled a clean version and it's the same with the demo and my app.
madMAx4
Posts: 27
Joined: Fri Apr 20, 2007 7:29 pm
Location: Germany

Post by madMAx4 »

i completely cleaned up my project and it works perfectly now :)
compound collision with btBvhTriangleMeshShape and convex decomposition are working without any problems even in double precision mode :)

i think i never thanked you for your effort to develop and support this great library. so here's a big thx to you erwin.
ode and co. really weren't the solution, but with bullet i'm totally satisfied :)