Part of #116901. The algorithm is very complicated to I didn't adjust it. The changes are just removing the data struct and un-sharing some code to make things a bit simpler. I also changed the loop to iterate over faces rather than triangles to avoid the reverse triangle to face lookup. This removes the need to create the `corner_tri_faces` map, saving 4 bytes per triangle.