/// <summary> /// You need to add borders to vault before calling this /// </summary> static bool Calculate_All_RMC_points(GameObject rmc) { // suppose MeshVerts returns nxm unconstrained mesh Vector3[] verts = GetMeshVerts(rmc); Vector3 pos = Vpos2tpos(rmc); Quarter[] tile_quarters = Quarter.Generate_Quarters(rmc); for (int index = 0; index < verts.Length; index++) { Vector3Int v = Vector3Int.RoundToInt(rmc.transform.TransformPoint(verts[index])); if (!Consts.IsWithinMapBounds(v)) { continue; } // find a quarter that given vertex belongs to and get information about restriction pattern Quarter quarter = tile_quarters.Aggregate( (minItem, nextItem) => Consts.Distance(minItem.pos, v) < Consts.Distance(nextItem.pos, v) ? minItem : nextItem); if (quarter.qt.Unrestricted()) { verts[index].y = Consts.current_heights[Consts.PosToIndex(v)]; } else if (quarter.qt.Both_restricted()) { if (Consts.Lies_on_restricted_border(v, BorderType.Horizontal, quarter)) { verts[index].y = Calculate_horizontal_height(v); } else if (Consts.Lies_on_restricted_border(v, BorderType.Vertical, quarter)) { verts[index].y = Calculate_vertical_height(v); } else if (quarter.original_grid.Contains(Consts.PosToIndex(v))) { verts[index].y = Consts.current_heights[Consts.PosToIndex(v)]; } else { if (quarter.original_grid.Contains(Consts.PosToIndex(new Vector3(v.x / 4 * 4, v.y, v.z)))) { verts[index].y = Calculate_horizontal_height(v); } else if (quarter.original_grid.Contains(Consts.PosToIndex(new Vector3(v.x, v.y, v.z / 4 * 4)))) { verts[index].y = Calculate_vertical_height(v); } else { verts[index].y = Razor_both_restricted_formula(v); } } } else if (quarter.qt.Horizontal_restricted()) { if (!quarter.original_grid.Contains(Consts.PosToIndex(v)) || Consts.Lies_on_restricted_border(v, BorderType.Horizontal, quarter)) { verts[index].y = Calculate_horizontal_height(v); } else { verts[index].y = Consts.current_heights[Consts.PosToIndex(v)]; } } else if (quarter.qt.Vertical_restricted()) { if (!quarter.original_grid.Contains(Consts.PosToIndex(v)) || Consts.Lies_on_restricted_border(v, BorderType.Vertical, quarter)) { verts[index].y = Calculate_vertical_height(v); } else { verts[index].y = Consts.current_heights[Consts.PosToIndex(v)]; } } Consts.current_heights[Consts.PosToIndex(v)] = verts[index].y; if (float.IsNaN(verts[index].y) || float.IsInfinity(verts[index].y)) { return(false); } } UpdateMeshes(rmc, verts); return(true); }