Do pure intersection tests still need a collision margin?

Post Reply
mqnc
Posts: 6
Joined: Fri Jun 29, 2018 10:23 am

Do pure intersection tests still need a collision margin?

Post by mqnc »

Hi!

I want to move objects (compound shape from cubes and btMultiSphereShape) on a predefined path through a static environment (btBvhTriangleMeshShape). All I care about is whether collision happened or not and where it happened if it happened. No resolving, no dynamics, only find intersections. If I get the idea of collision margins correctly, they are only required for having stable dynamics, so can I set them to zero safely, right?

Cheers!
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Do pure intersection tests still need a collision margin?

Post by drleviathan »

I've heard there is a performance benefit of the collision margin. It takes fewer CPU cycles to compute the result for two shapes that overlap margins but do not actually intersect their fundamental boundaries. This is rumor (I haven't verified) but from what I remember about what I was told: the GJK algorithm is used to compute the contact point info, and this algorithm tries to compute the nearest two points between two convex shapes. The algorithm is fast when the objects overlap by their margins or less but the failure case when the margins have been violated takes longer to evaluate, and then once deep penetration has been determined the true penetration calculation requires even more CPU cycles.

So, if you're trying to do lots of intersection calculations in real-time then maybe zero-length collision margins would be a problem. Otherwise, if you have few objects and/or you don't need real time results then: go ahead and zero your margins.

All that said, you should probably just try it with zero margins anyway to see how well it works, and then report back here.
Post Reply