I have a horizontal planar mesh that I believe could be reduced in polys (illustrative example of before and possible after below --all vertices have the same y value).
My approach so far would be to do this:
var vertices = mesh.vertices;
foreach (var vertex in vertices)
{
if (isVertexOnEdgeOfMesh(vertex, mesh)) continue;
var connectingVertices = GetConnectingVertices(vertex, mesh);
var removable = true;
foreach (var connectingVertex in connectingVertices)
{
if (vertex.y == connectingVertex.y) continue;
removable = false;
break;
}
if (removable)
{
//remove vertex here
}
}
The idea is to remove any vertex that is not on an edge, and that also shares the same y value with all of its neighbors.
I’m not sure if this is even the right approach, but even if it is, I don’t know how to remove the vertex without screwing up the triangles in the mesh. I don’t see any reason why this type of thing shouldn’t be possible, give the layout of the mesh, but maybe I’m missing something?