public void CopyFrom(ControlMesh other) { if (other == null) { Reset(); return; } if (other.Vertices != null) { if (Vertices == null || Vertices.Length != other.Vertices.Length) { Vertices = new Vector3[other.Vertices.Length]; } Array.Copy(other.Vertices, Vertices, other.Vertices.Length); } else { Vertices = null; } if (other.Edges != null) { if (Edges == null || Edges.Length != other.Edges.Length) { Edges = new HalfEdge[other.Edges.Length]; } Array.Copy(other.Edges, Edges, other.Edges.Length); } else { Edges = null; } if (other.Polygons != null) { if (Polygons == null || Polygons.Length != other.Polygons.Length) { Polygons = new Polygon[other.Polygons.Length]; } for (var p = 0; p < other.Polygons.Length; p++) { if (other.Polygons[p].EdgeIndices == null || other.Polygons[p].EdgeIndices.Length == 0) { continue; } var newEdges = new int[other.Polygons[p].EdgeIndices.Length]; Array.Copy(other.Polygons[p].EdgeIndices, newEdges, other.Polygons[p].EdgeIndices.Length); Polygons[p] = new Polygon(newEdges, other.Polygons[p].TexGenIndex); } } else { Polygons = null; } IsValid = other.IsValid; Generation = other.Generation; // if (other.Shape != null) // { // if (Shape == null) // Shape = new Shape(); // Shape.CopyFrom(other.Shape); // } else // Shape = null; }
public ControlMesh(ControlMesh other) { CopyFrom(other); }