Page 1 of 1

[V1] Collision between two convex colliders

Posted: Fri Jun 22, 2018 10:02 am
by snoopyuj
Hi all,

First, thank you @Norbo for creating the most powerful open source physics engine.
Really appreciate!

Straight to the point:
I found there has a gap between two convex colliders when they contact each other.
Like this:

Mobile mesh collider also has this problem, too.
Did I miss something in doc?


p.s. Sorry for my bad English :(
I can't even express my gratitude to @Norbo

Re: [V1] Collision between two convex colliders

Posted: Fri Jun 22, 2018 10:08 pm
by Norbo
You're welcome :)

This is (probably) the collision margin. v1 uses an algorithm called GJK for shallow collision detection between many shape types including convex hull pairs. Standard GJK only works with separated objects, so the collision margin is used to keep the shapes apart. You can think of it as adding a little bit of rounded 'padding'.

You can change the collision margin by setting the shape's CollisionMargin property. If not directly set, it uses CollisionDetectionSettings.DefaultMargin, which defaults to 0.04. For smaller objects or simulations, that can produce excessively large gaps.

You can reduce the collision margin to 0, but performance and quality may suffer a little bit. Collision detection would be forced to fall back to a different algorithm.

(As a side note, v2 doesn't have shape-modifying collision margins.)

Re: [V1] Collision between two convex colliders

Posted: Mon Jun 25, 2018 1:13 am
by snoopyuj
Thank you so much!
I feel so embarrassing that I didn't see this setting in code. :oops: