private static PolySet Inset(ICollection <Polygon> polygons, IList <Vector3> vertices, PolySet polys, float insetDistance) { PolySet stitchedPolys = StitchPolys(polygons, vertices, polys, out EdgeSet stitchedEdge); Dictionary <int, Vector3> inwardDirections = EdgeSet.GetInwardDirections(stitchedEdge, vertices); // Push each vertex inwards, then correct // it's height so that it's as far from the center of // the planet as it was before. foreach (KeyValuePair <int, Vector3> kvp in inwardDirections) { int vertIndex = kvp.Key; Vector3 inwardDirection = kvp.Value; Vector3 vertex = vertices[vertIndex]; float originalHeight = vertex.magnitude; vertex += inwardDirection * insetDistance; vertex = vertex.normalized * originalHeight; vertices[vertIndex] = vertex; } return(stitchedPolys); }