tunneling on btBvhTriangleMeshShape

mickey
Posts: 107
Joined: Fri Sep 19, 2008 6:08 pm

tunneling on btBvhTriangleMeshShape

Post by mickey »

Sorry, a little bit lost on all the collision discussion as which one i should really follow so i decided to post my own problem.

please see screenshot:

Image

It was loaded into a btBvhTriangleMeshShape by filling up a btTriangleIndexVertexArray.

When i try to shoot a bullet primitive shape to a btBvhTriangleMeshShape a lot of times it just goes right through (as you can see on the screen shot) - and as well as getting stuck inside (there's one in the screen shot with a tint of red).

Also, one thing i find out, when i first create the btBvhTriangleMeshShape the collision margin is set to 0? is this suppose to be the correct behavior? In any case, i set it to 0.5 - pretty big from the default collision margin, but tunneling still occurs. The initial speed is only less than 100.0f if that helps.

However, when i try to shoot right through a btBoxShape, it has far less tunneling than a btBvhTriangleMeshShape, so not sure what's the difference.

Many thanks in advance.
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York

Re: tunneling on btBvhTriangleMeshShape

Post by sparkprime »

I can't make out much from your screenshot, maybe a non-wireframe one would help.

What speeds are you shooting at, and how large are your projectiles? 100m/s is very fast if your objects are not huge, about 250mph. When the CCD dynamics is finished this will be less of a problem but for now you have to either reduce your speeds, increase the simulation frequency, or both. Triangles are infinitely thin, remember.

Boxes are not infinitely thin, so are completely different. You can tunnel into (but not through) a box and you will bounce right out again (possibly through to the other side if you penetrated more than half way through it).

This is the general idea behind the collision margin: btBvhTriangleMeshShape is for static (non-moving) bodies only, and such bodies do not collide with each other. They only collide with dynamic objects. A collision margin is only needed for one of the bodies in the colliding pair so the margin can be elided for all static bodies.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: tunneling on btBvhTriangleMeshShape

Post by Erwin Coumans »

This method might help, but we need to improve support for triangle meshes:

http://www.bulletphysics.com/mediawiki- ... n_Clamping
mickey
Posts: 107
Joined: Fri Sep 19, 2008 6:08 pm

Re: tunneling on btBvhTriangleMeshShape

Post by mickey »

Hi Sparkprime,

I shoot the primitives at 1.0 unit size at an initial speed of 90.

Does that mean having extra collision margins on the static bodies would not yield any improved result?

Hi Erwin,

there's no setCCdMotionThreadshold anymore on btCollisionObject, but there's a setCcdSquareMotionThreshold so not sure if that should be the one I would use. In any case i tried it as well and it didn't help. Same thing with setCcdSweptSphereRadius.
mickey
Posts: 107
Joined: Fri Sep 19, 2008 6:08 pm

Re: tunneling on btBvhTriangleMeshShape

Post by mickey »

setting the 2 methods definitely helped:

body->setCcdMotionThreshold(1.0f);
body->setCcdSweptSphereRadius(0.2f);

the penetration and objects getting stuck definitely lessened, however it did not completely eliminate it.

Some of my primitive shapes (box,cylinder etc) still penetrates and gets stuck inside a btBvhTriangleMeshShape.

So I have 2 questions:

1. Is there anything else I can set to make sure 100% no penetration?
2. Does the CCD only works on convex shapes? So there's no CCD between convex and concave? Perhaps this is the reason for the penetration and the convex shapes getting stuck?

Thanks.
User avatar
Dragonlord
Posts: 198
Joined: Mon Sep 04, 2006 5:31 pm
Location: Switzerland

Re: tunneling on btBvhTriangleMeshShape

Post by Dragonlord »

Have you adjusted the size to your objects ( since you posted here a 1-1 copy from the wiki )?
mickey
Posts: 107
Joined: Fri Sep 19, 2008 6:08 pm

Re: tunneling on btBvhTriangleMeshShape

Post by mickey »

Thanks for asking, yes. I tried scaling the world and the moving convex objects, as well as adjusting the step simulation and fixing my game fps to 60.

I tried a fixed 1/60.0f with a sub step of 4 on stepSimulation, also tried the stepSimulation in the bullet demo ie.

ms = g_pApp->getDeltaTimeMicroseconds();
m_dynamicsWorld->stepSimulation( ms / 1000000.f, 10 );

I need to make sure that when I scale both my scene and my objects, they are proporition. I can't have a barrel or crate bigger than for instance, the entrance door to a house or it would be unrealistic.
User avatar
Dragonlord
Posts: 198
Joined: Mon Sep 04, 2006 5:31 pm
Location: Switzerland

Re: tunneling on btBvhTriangleMeshShape

Post by Dragonlord »

That's not what I mean. If your object is for example only 0.1m in size then you need 0.02m as ccd threshold not 0.2m .