ConvexHull faces

With the enormous contribution of @carolhmj I have this ConvexHull going on but there are some things going on that i don’t understand. Focus on the buildRenderableMesh() section from line 379- 421.
Probably best have the console open too.
Because the convex-hull I did a this.renderableMesh.forceSharedVertices();
but ended up with way too many faces for the vertices so i tried a this.faces = this.faces.filter(face => face.mark === 0); in line 385.
faces are marked with a const FaceTypes = { VISIBLE: 0, NON_CONVEX: 1, DELETED: 2, }
in lines 425 - 429

Questions:

  • what to do with the newFaces which are also marked as 0 (visible)
  • why can’t i set colors to the vertices (mesh turns black)
  • what’s going on with the faces/facets? when you run the script a couple of times and rotate the mesh you’ll find it’s sometimes perfect and sometimes you see glitches
    Thanks in advance :slight_smile:

I can answer for the vertex color: you have to push values and not color object.
Change visible in this PG:

For the rest, I’ll let @carolhmj :slight_smile:

1 Like

The code there is an implementation of the 3D Quickhull algorithm, the original repo has a pdf containing some implementation details and references I used. It’s been a while through so not all the details are clear on my mind anymore :stuck_out_tongue:

  • newFaces should be only part of the hull construction process so you should just be able to ignore it
  • Cedric already answered that :slight_smile:
  • This looks like faces with inside pointing normals that aren’t being marked as deleted, it’s probably a bug in the hull construction code :sweat_smile: You could debug it and see where’s that happening, or you could remove these faces after the hull is constructed.

Thanks for looking into that @Cedric :slight_smile: I just didn’t know that.
And thank you for doing this @carolhmj , you did a great job and I am very grateful!

2 Likes

It’s not perfect yet but it appears to be better :slight_smile:

2 Likes

Nice!!! :smile: