Added a Copy() method to PrimMesh and SculptMesh as suggested by dmiles. Sync PrimMesher.cs and SculptMesh.cs with PrimMesher.dll r36.

This commit is contained in:
Dahlia Trimble
2009-05-08 03:04:45 +00:00
parent f532767c6a
commit bd3a4e5f01
2 changed files with 75 additions and 20 deletions

View File

@@ -376,6 +376,24 @@ namespace PrimMesher
calcVertexNormals(sculptType, width, height);
}
/// <summary>
/// Duplicates a SculptMesh object. All object properties are copied by value, including lists.
/// </summary>
/// <returns></returns>
public SculptMesh Copy()
{
return new SculptMesh(this);
}
public SculptMesh(SculptMesh sm)
{
coords = new List<Coord>(sm.coords);
faces = new List<Face>(sm.faces);
viewerFaces = new List<ViewerFace>(sm.viewerFaces);
normals = new List<Coord>(sm.normals);
uvs = new List<UVCoord>(sm.uvs);
}
private void calcVertexNormals(SculptType sculptType, int xSize, int ySize)
{ // compute vertex normals by summing all the surface normals of all the triangles sharing
// each vertex and then normalizing