Page 1 of 1

Problems creating convex hull (minimumDistance)

Posted: Tue Jun 27, 2017 11:28 pm
by Nablablan
actually, an old problem (already hat it with oder bepu version) but i wonder why it came back (with 1.5):
when creating convex hulls. i had that before that in new ConvexHullShape().ComputeDescription.ComputeMinimumRadius it complains about negative distances.
Is it possibly a bug? Bc in ComputeDescription() "you" compute the points and than in the same method later it complains: "Invalid distance. Ensure the mesh is convex, has consistent winding, and contains the passed-in center."
I don't see how I can influence that, I only give it a list of points
I use the ConvexHullHelper.RemoveRedundantPoints() to remove points, which says "cellSize: Size of cells to determine redundancy". I got around that problem by trying out different values
the points are
https://pastebin.com/PSv77uya
the fraud minimumDist is -0.0100421356

side question: the cellSize of ConvexHullHelper.RemoveRedundantPoints, what exactly does it mean?
I thinks it is: When I set to 1.0f it combines every points with distance less than 1.0f or removes one of them, I am wrong am I?

Re: Problems creating convex hull (minimumDistance)

Posted: Wed Jun 28, 2017 7:25 pm
by Norbo
The convex hull algorithm is definitely a bit... finicky, in numerical terms. It's some very old code that needs a full rewrite. (And it's getting one in v2.)

That said, I tried to create a convex hull shape out of that point set and it appears to work in the demos. This could be a matter of extremely tiny numerical differences- a different order of arithmetic or precision casts could easily cause a problem.

Generally speaking, the more coincident/colinear/coplanar points there are, the more likely the implementation is to fail. Note that you can bypass the algorithm entirely by using a ConvexHullShape constructor that lets you specify every detail manually. That's handy if you already have the surface vertices and inertias cached somewhere. You can get that data from anywhere, too- you don't have to use the convex hull algorithm in the library.
side question: the cellSize of ConvexHullHelper.RemoveRedundantPoints, what exactly does it mean?
I thinks it is: When I set to 1.0f it combines every points with distance less than 1.0f or removes one of them, I am wrong am I?
That's about right- if there are a bunch of points within the same spot (with the 'spot' having a width equal to the parameter), only one of those points will be kept. The remainder will be removed. This helps avoid coincident points which can confuse the algorithm and which don't significantly change the result.

Re: Problems creating convex hull (minimumDistance)

Posted: Tue Jul 04, 2017 10:39 am
by Nablablan
okay, well then I have to make all computations deterministic,more or less, or I add the baked set of points and descriptions into the release

oh, i see you added this constructor

Code: Select all

public ConvexHullShape(IList<Vector3> localSurfaceVertices, ConvexShapeDescription description)
(https://github.com/bepu/bepuphysics1/bl ... llShape.cs)
very handy :)
so now I don't need to hack one in :D