From bd3a4e5f01cff3831817eb5dd4adf8ea1ed7fac0 Mon Sep 17 00:00:00 2001 From: Dahlia Trimble Date: Fri, 8 May 2009 03:04:45 +0000 Subject: Added a Copy() method to PrimMesh and SculptMesh as suggested by dmiles. Sync PrimMesher.cs and SculptMesh.cs with PrimMesher.dll r36. --- OpenSim/Region/Physics/Meshing/PrimMesher.cs | 77 ++++++++++++++++++++-------- OpenSim/Region/Physics/Meshing/SculptMesh.cs | 18 +++++++ 2 files changed, 75 insertions(+), 20 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/Meshing/PrimMesher.cs b/OpenSim/Region/Physics/Meshing/PrimMesher.cs index ca16b63..936bb02 100644 --- a/OpenSim/Region/Physics/Meshing/PrimMesher.cs +++ b/OpenSim/Region/Physics/Meshing/PrimMesher.cs @@ -945,33 +945,33 @@ namespace PrimMesher this.faceUVs.Add(new UVCoord(1.0f - (0.5f + c.X), 1.0f - (0.5f - c.Y))); } - internal Profile Clone() + internal Profile Copy() { - return this.Clone(true); + return this.Copy(true); } - internal Profile Clone(bool needFaces) + internal Profile Copy(bool needFaces) { - Profile clone = new Profile(); + Profile copy = new Profile(); - clone.coords.AddRange(this.coords); - clone.faceUVs.AddRange(this.faceUVs); + copy.coords.AddRange(this.coords); + copy.faceUVs.AddRange(this.faceUVs); if (needFaces) - clone.faces.AddRange(this.faces); - if ((clone.calcVertexNormals = this.calcVertexNormals) == true) + copy.faces.AddRange(this.faces); + if ((copy.calcVertexNormals = this.calcVertexNormals) == true) { - clone.vertexNormals.AddRange(this.vertexNormals); - clone.faceNormal = this.faceNormal; - clone.cutNormal1 = this.cutNormal1; - clone.cutNormal2 = this.cutNormal2; - clone.us.AddRange(this.us); - clone.faceNumbers.AddRange(this.faceNumbers); + copy.vertexNormals.AddRange(this.vertexNormals); + copy.faceNormal = this.faceNormal; + copy.cutNormal1 = this.cutNormal1; + copy.cutNormal2 = this.cutNormal2; + copy.us.AddRange(this.us); + copy.faceNumbers.AddRange(this.faceNumbers); } - clone.numOuterVerts = this.numOuterVerts; - clone.numHollowVerts = this.numHollowVerts; + copy.numOuterVerts = this.numOuterVerts; + copy.numHollowVerts = this.numHollowVerts; - return clone; + return copy; } internal void AddPos(Coord v) @@ -1344,7 +1344,7 @@ namespace PrimMesher bool done = false; while (!done) { - Profile newLayer = profile.Clone(); + Profile newLayer = profile.Copy(); if (this.taperX == 0.0f) xProfileScale = 1.0f; @@ -1730,8 +1730,8 @@ namespace PrimMesher if (angle <= startAngle + .01f || angle >= endAngle - .01f) isEndLayer = true; - //Profile newLayer = profile.Clone(isEndLayer && needEndFaces); - Profile newLayer = profile.Clone(); + //Profile newLayer = profile.Copy(isEndLayer && needEndFaces); + Profile newLayer = profile.Copy(); float xProfileScale = (1.0f - Math.Abs(this.skew)) * this.holeSizeX; float yProfileScale = this.holeSizeY; @@ -2036,6 +2036,43 @@ namespace PrimMesher } /// + /// Duplicates a PrimMesh object. All object properties are copied by value, including lists. + /// + /// + public PrimMesh Copy() + { + PrimMesh copy = new PrimMesh(this.sides, this.profileStart, this.profileEnd, this.hollow, this.hollowSides); + copy.twistBegin = this.twistBegin; + copy.twistEnd = this.twistEnd; + copy.topShearX = this.topShearX; + copy.topShearY = this.topShearY; + copy.pathCutBegin = this.pathCutBegin; + copy.pathCutEnd = this.pathCutEnd; + copy.dimpleBegin = this.dimpleBegin; + copy.dimpleEnd = this.dimpleEnd; + copy.skew = this.skew; + copy.holeSizeX = this.holeSizeX; + copy.holeSizeY = this.holeSizeY; + copy.taperX = this.taperX; + copy.taperY = this.taperY; + copy.radius = this.radius; + copy.revolutions = this.revolutions; + copy.stepsPerRevolution = this.stepsPerRevolution; + copy.calcVertexNormals = this.calcVertexNormals; + copy.normalsProcessed = this.normalsProcessed; + copy.viewerMode = this.viewerMode; + copy.numPrimFaces = this.numPrimFaces; + copy.errorMessage = this.errorMessage; + + copy.coords = new List(this.coords); + copy.faces = new List(this.faces); + copy.viewerFaces = new List(this.viewerFaces); + copy.normals = new List(this.normals); + + return copy; + } + + /// /// Calculate surface normals for all of the faces in the list of faces in this mesh /// public void CalcNormals() diff --git a/OpenSim/Region/Physics/Meshing/SculptMesh.cs b/OpenSim/Region/Physics/Meshing/SculptMesh.cs index 5b8a5be..77b1771 100644 --- a/OpenSim/Region/Physics/Meshing/SculptMesh.cs +++ b/OpenSim/Region/Physics/Meshing/SculptMesh.cs @@ -376,6 +376,24 @@ namespace PrimMesher calcVertexNormals(sculptType, width, height); } + /// + /// Duplicates a SculptMesh object. All object properties are copied by value, including lists. + /// + /// + public SculptMesh Copy() + { + return new SculptMesh(this); + } + + public SculptMesh(SculptMesh sm) + { + coords = new List(sm.coords); + faces = new List(sm.faces); + viewerFaces = new List(sm.viewerFaces); + normals = new List(sm.normals); + uvs = new List(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 -- cgit v1.1