Mesh simplification (for MeshCollider, lossless)

Function
This script extends the Mesh class with three methods:  SnapToGrid is used to clean up any subtle position irregularities. Weld is used to combine vertices that have the same position into one. Simplify is used to combine triangles in a lossless way until no such triangle can be found in the mesh.

These simplification methods suits the needs of someone who pieces together mesh colliders from tilesets, or just don't want to optimize colliders by hand.

Optional: tweak the thresholds in HasEqualPlanes and IsParallel to suit your needs.



Original Author
Fredrik Ludvigsen (i.e. who to send bug reports to)