Experiences with Bullet Continuous Collision Detection?

I’m looking for advice on setting up CCD. I’m currently tweaking the physics of a Bullet vehicle driving on a static collision mesh. I’ve created a collision box for the vehicle and enabled CCD as follows:

		
chassis_np = render.attachNewNode(BulletRigidBodyNode('Vehicle'))
chassis_np.node().addShape(
			BulletBoxShape(car_dimensions),
			TransformState.makePos(chassis_offset))
			
chassis_np.setPos(car_start_pos)
chassis_np.setRenderModeWireframe()
chassis_np.node().setMass(car_mass)			
chassis_np.node().setDeactivationEnabled(False)
physics_world.attachRigidBody(chassis_np.node())
		
chassis_np.node().setCcdSweptSphereRadius(car_dimensions.getY())
chassis_np.node().setCcdMotionThreshold(1e-7)

If I start the vehicle 10m above the collision mesh and drop it, it bounces off as expected, but if it starts 100m up, it passes right through without even a twitch. This is independent of whether or not I use the last two lines above.

The vehicle will also tunnel through a HeightFieldCollisionShape under the same conditions, although it snags a bit while passing through.

The guys making PonyKart are using Bullet vehicles and left the following comments in their source:

			// set up this stuff... not quite sure what it's for, but you need it if you want the CCD to work for the karts
			dispatcher.RegisterCollisionCreateFunc(BroadphaseNativeType.ConvexTriangleMeshShape, BroadphaseNativeType.ConvexTriangleMeshShape,
				dcc.GetCollisionAlgorithmCreateFunc(BroadphaseNativeType.TriangleMeshShape, BroadphaseNativeType.TriangleMeshShape));

So I suspect there may be some more details I’m missing. Would appreciate any input.

LOL. Neither do I know. There is not really much documentation for the C++ Bullet API. Seems like these guys use a C#/.Net wrapper for Bullet.

“BroadphaseNativeType” is not an enum type I know from the Bullet API, and “dcc.GetCollisionAlgorithmCreateFunc” also seems like their own extensions to Bullet.

Can you investigate some more what these guys are doing here? Otherwise I have no chance to implement something similar.

Yeah, the official documentation for Bullet is pretty scanty. I’m more interested in knowing if anyone has gotten Bullet CCD to work in Panda. If not, I will most likely roll my own, or fall back on the default Panda3D physics which includes CCD. It will be hard to do without it because I want blistering speed and huge, True Lies-style motorcycle jumps.

Well, this would be me, for example. Look at the samples linked fron the manual. There is a CCD sample contained in the zip-archive, which works perfect.

Your problem is not about CCD in general, but about fast moving vehicles.

I want to see a sample which reproduces what you describe. I have modified my vehicle example, but even starting with 1000 meters above the ground the vehicle didn’t tunnel through the ground. So I’d like to understand what is going on in your case.

Oh God, I thought that zip archive only contained a cube model. You’ve just saved me a ton of work. I’ll look over the samples and get back to you.

Is it OK with you if I link these on the “Panda3D Manual: Using Bullet with Panda3D” page, instead of the Hello World page? That was the reason I missed it the first time.

Hallelujah! It was this line:

physics_world.doPhysics(dt, 20, 1.0/180.0)

I had only called doPhysics with the delta-t value. When I provide the other parameters, it not only keeps the vehicle from tunneling through the terrain after huge jumps, it also keeps it from “tripping” over seams in the terrain mesh.

I’ll see if I can dig up any more info on the substep and substep size parameters, and report back.