Mesh tunnelling - help/examples?

jammiedodger
Posts: 4
Joined: Tue Jul 12, 2011 11:42 am

Mesh tunnelling - help/examples?

Post by jammiedodger »

Apologies for the very often-asked question. I'm working on a simple marble-rolling physics game. Bullet has been great to implement and I've gotten good results very quickly.

Version one of the game used a btStaticPlaneShape for the resting base and a btConvexHullShape (a cylinder that I found the code for on these forums) to provide the boundary surround. Marbles were just basic implicit btSphereShape objects. Everything worked very nicely, no tunnelling or problems.

For version two, I'm looking to change this setup to use meshes or some other implementation that gives me an asset pipeline that means I can build more complex levels. I've experimented with a btTriangleMesh and a btHeightFieldTerrainShape for the floor/base - and a btTriangleMesh for the surround. As soon as I switch to these constructs, I get tunnelling happening with my spheres, when they reach high velocities.

Video here: http://www.youtube.com/watch?v=HEMpBVIj8Ug

I'm trying to resolve this - but hoped that someone might be able to offer some advice or links to code examples to try out. I'm guessing that I need to look into a more complex collision detection set-up - but as this is my first time using Bullet, I'm struggling a little with where to go next. I've looked at a lot of posts on the forum and the FAQ and I'm a little stuck with implementing (for example) continuous collision detection.

Thanks very much for any help/advice.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Mesh tunnelling - help/examples?

Post by Erwin Coumans »

Can you try enabling CCD for the ball, tune the following parameters

Code: Select all

		body->setCcdMotionThreshold(0.0001);
		body->setCcdSweptSphereRadius(0.4f);
Make sure the setCcdSweptSphereRadius is fully embedded inside the rigid body (smaller than the actual object radius)

Please let us know if that helps,
Erwin
jammiedodger
Posts: 4
Joined: Tue Jul 12, 2011 11:42 am

Re: Mesh tunnelling - help/examples?

Post by jammiedodger »

Many thanks - I'm so far able to get around the issue by sticking to using primitives which have been more robust for purpose, but I will certainly give your suggestions a try. I'll let you know if I have any success.

Thanks for the help!
jammiedodger
Posts: 4
Joined: Tue Jul 12, 2011 11:42 am

Re: Mesh tunnelling - help/examples?

Post by jammiedodger »

Your solution worked a treat, many thanks for the awesome help.