Margins: added or subtracted

Please don't post Bullet support questions here, use the above forums instead.
Post Reply
zenux
Posts: 3
Joined: Wed Apr 03, 2013 8:13 pm

Margins: added or subtracted

Post by zenux »

Hello,

I'm trying to create a small physics engine for fun.
I have implemented GJK and EPA algorithms.

Now, I would like to use these algorithms: use GJK for small depth penetrations and EPA for the rest (hybrid algorithm). To do that, I need margin on my objects.
When I read the Bullet user manual, we can see that the margins are sometimes subtracted from objects (box shape) or sometimes added to object (convex hull, cylinder, cone).

Why we don't subtract the margin for convex hull ? What are the difficulties ?
Moreover, add the margin to convex hull will "round' the convex hull which will cause some imprecision errors, no ?

Thank you in advance.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Margins: added or subtracted

Post by Erwin Coumans »

You could always use internal/embedded margins. For convex shapes, you need to make some effort, to shrink the original convex hull.
In the case of Bullet, there is a utility to shrink the convex hull and recompute its vertices, so you can embed the margin.
In a nutshell:
1) create plane equations, given the vertices of the convex hull
2) move the plane equations inwards, over the collision margin
3) re-compute vertices at the intersection of the new plane equations
(see btGeometryUtil::getPlaneEquationsFromVertices and ConvexDecompositionDemo SHRINK_OBJECT_INWARDS)

And indeed, using margins, either embedded inside the original shape or added/extended outside of the shape, will make the edges and corners rounded,
so it is an approximation (except for spheres obviously). As long as you don't use large margins, the error is not big.
Post Reply