diff options
author | Dahlia Trimble | 2009-05-08 03:04:45 +0000 |
---|---|---|
committer | Dahlia Trimble | 2009-05-08 03:04:45 +0000 |
commit | bd3a4e5f01cff3831817eb5dd4adf8ea1ed7fac0 (patch) | |
tree | 5e9ac07b13118999d1d88d20f9a1e06be4b6019f /OpenSim/Region | |
parent | fix svn properties (diff) | |
download | opensim-SC_OLD-bd3a4e5f01cff3831817eb5dd4adf8ea1ed7fac0.zip opensim-SC_OLD-bd3a4e5f01cff3831817eb5dd4adf8ea1ed7fac0.tar.gz opensim-SC_OLD-bd3a4e5f01cff3831817eb5dd4adf8ea1ed7fac0.tar.bz2 opensim-SC_OLD-bd3a4e5f01cff3831817eb5dd4adf8ea1ed7fac0.tar.xz |
Added a Copy() method to PrimMesh and SculptMesh as suggested by dmiles. Sync PrimMesher.cs and SculptMesh.cs with PrimMesher.dll r36.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/Physics/Meshing/PrimMesher.cs | 77 | ||||
-rw-r--r-- | OpenSim/Region/Physics/Meshing/SculptMesh.cs | 18 |
2 files changed, 75 insertions, 20 deletions
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 | |||
945 | this.faceUVs.Add(new UVCoord(1.0f - (0.5f + c.X), 1.0f - (0.5f - c.Y))); | 945 | this.faceUVs.Add(new UVCoord(1.0f - (0.5f + c.X), 1.0f - (0.5f - c.Y))); |
946 | } | 946 | } |
947 | 947 | ||
948 | internal Profile Clone() | 948 | internal Profile Copy() |
949 | { | 949 | { |
950 | return this.Clone(true); | 950 | return this.Copy(true); |
951 | } | 951 | } |
952 | 952 | ||
953 | internal Profile Clone(bool needFaces) | 953 | internal Profile Copy(bool needFaces) |
954 | { | 954 | { |
955 | Profile clone = new Profile(); | 955 | Profile copy = new Profile(); |
956 | 956 | ||
957 | clone.coords.AddRange(this.coords); | 957 | copy.coords.AddRange(this.coords); |
958 | clone.faceUVs.AddRange(this.faceUVs); | 958 | copy.faceUVs.AddRange(this.faceUVs); |
959 | 959 | ||
960 | if (needFaces) | 960 | if (needFaces) |
961 | clone.faces.AddRange(this.faces); | 961 | copy.faces.AddRange(this.faces); |
962 | if ((clone.calcVertexNormals = this.calcVertexNormals) == true) | 962 | if ((copy.calcVertexNormals = this.calcVertexNormals) == true) |
963 | { | 963 | { |
964 | clone.vertexNormals.AddRange(this.vertexNormals); | 964 | copy.vertexNormals.AddRange(this.vertexNormals); |
965 | clone.faceNormal = this.faceNormal; | 965 | copy.faceNormal = this.faceNormal; |
966 | clone.cutNormal1 = this.cutNormal1; | 966 | copy.cutNormal1 = this.cutNormal1; |
967 | clone.cutNormal2 = this.cutNormal2; | 967 | copy.cutNormal2 = this.cutNormal2; |
968 | clone.us.AddRange(this.us); | 968 | copy.us.AddRange(this.us); |
969 | clone.faceNumbers.AddRange(this.faceNumbers); | 969 | copy.faceNumbers.AddRange(this.faceNumbers); |
970 | } | 970 | } |
971 | clone.numOuterVerts = this.numOuterVerts; | 971 | copy.numOuterVerts = this.numOuterVerts; |
972 | clone.numHollowVerts = this.numHollowVerts; | 972 | copy.numHollowVerts = this.numHollowVerts; |
973 | 973 | ||
974 | return clone; | 974 | return copy; |
975 | } | 975 | } |
976 | 976 | ||
977 | internal void AddPos(Coord v) | 977 | internal void AddPos(Coord v) |
@@ -1344,7 +1344,7 @@ namespace PrimMesher | |||
1344 | bool done = false; | 1344 | bool done = false; |
1345 | while (!done) | 1345 | while (!done) |
1346 | { | 1346 | { |
1347 | Profile newLayer = profile.Clone(); | 1347 | Profile newLayer = profile.Copy(); |
1348 | 1348 | ||
1349 | if (this.taperX == 0.0f) | 1349 | if (this.taperX == 0.0f) |
1350 | xProfileScale = 1.0f; | 1350 | xProfileScale = 1.0f; |
@@ -1730,8 +1730,8 @@ namespace PrimMesher | |||
1730 | if (angle <= startAngle + .01f || angle >= endAngle - .01f) | 1730 | if (angle <= startAngle + .01f || angle >= endAngle - .01f) |
1731 | isEndLayer = true; | 1731 | isEndLayer = true; |
1732 | 1732 | ||
1733 | //Profile newLayer = profile.Clone(isEndLayer && needEndFaces); | 1733 | //Profile newLayer = profile.Copy(isEndLayer && needEndFaces); |
1734 | Profile newLayer = profile.Clone(); | 1734 | Profile newLayer = profile.Copy(); |
1735 | 1735 | ||
1736 | float xProfileScale = (1.0f - Math.Abs(this.skew)) * this.holeSizeX; | 1736 | float xProfileScale = (1.0f - Math.Abs(this.skew)) * this.holeSizeX; |
1737 | float yProfileScale = this.holeSizeY; | 1737 | float yProfileScale = this.holeSizeY; |
@@ -2036,6 +2036,43 @@ namespace PrimMesher | |||
2036 | } | 2036 | } |
2037 | 2037 | ||
2038 | /// <summary> | 2038 | /// <summary> |
2039 | /// Duplicates a PrimMesh object. All object properties are copied by value, including lists. | ||
2040 | /// </summary> | ||
2041 | /// <returns></returns> | ||
2042 | public PrimMesh Copy() | ||
2043 | { | ||
2044 | PrimMesh copy = new PrimMesh(this.sides, this.profileStart, this.profileEnd, this.hollow, this.hollowSides); | ||
2045 | copy.twistBegin = this.twistBegin; | ||
2046 | copy.twistEnd = this.twistEnd; | ||
2047 | copy.topShearX = this.topShearX; | ||
2048 | copy.topShearY = this.topShearY; | ||
2049 | copy.pathCutBegin = this.pathCutBegin; | ||
2050 | copy.pathCutEnd = this.pathCutEnd; | ||
2051 | copy.dimpleBegin = this.dimpleBegin; | ||
2052 | copy.dimpleEnd = this.dimpleEnd; | ||
2053 | copy.skew = this.skew; | ||
2054 | copy.holeSizeX = this.holeSizeX; | ||
2055 | copy.holeSizeY = this.holeSizeY; | ||
2056 | copy.taperX = this.taperX; | ||
2057 | copy.taperY = this.taperY; | ||
2058 | copy.radius = this.radius; | ||
2059 | copy.revolutions = this.revolutions; | ||
2060 | copy.stepsPerRevolution = this.stepsPerRevolution; | ||
2061 | copy.calcVertexNormals = this.calcVertexNormals; | ||
2062 | copy.normalsProcessed = this.normalsProcessed; | ||
2063 | copy.viewerMode = this.viewerMode; | ||
2064 | copy.numPrimFaces = this.numPrimFaces; | ||
2065 | copy.errorMessage = this.errorMessage; | ||
2066 | |||
2067 | copy.coords = new List<Coord>(this.coords); | ||
2068 | copy.faces = new List<Face>(this.faces); | ||
2069 | copy.viewerFaces = new List<ViewerFace>(this.viewerFaces); | ||
2070 | copy.normals = new List<Coord>(this.normals); | ||
2071 | |||
2072 | return copy; | ||
2073 | } | ||
2074 | |||
2075 | /// <summary> | ||
2039 | /// Calculate surface normals for all of the faces in the list of faces in this mesh | 2076 | /// Calculate surface normals for all of the faces in the list of faces in this mesh |
2040 | /// </summary> | 2077 | /// </summary> |
2041 | public void CalcNormals() | 2078 | 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 | |||
376 | calcVertexNormals(sculptType, width, height); | 376 | calcVertexNormals(sculptType, width, height); |
377 | } | 377 | } |
378 | 378 | ||
379 | /// <summary> | ||
380 | /// Duplicates a SculptMesh object. All object properties are copied by value, including lists. | ||
381 | /// </summary> | ||
382 | /// <returns></returns> | ||
383 | public SculptMesh Copy() | ||
384 | { | ||
385 | return new SculptMesh(this); | ||
386 | } | ||
387 | |||
388 | public SculptMesh(SculptMesh sm) | ||
389 | { | ||
390 | coords = new List<Coord>(sm.coords); | ||
391 | faces = new List<Face>(sm.faces); | ||
392 | viewerFaces = new List<ViewerFace>(sm.viewerFaces); | ||
393 | normals = new List<Coord>(sm.normals); | ||
394 | uvs = new List<UVCoord>(sm.uvs); | ||
395 | } | ||
396 | |||
379 | private void calcVertexNormals(SculptType sculptType, int xSize, int ySize) | 397 | private void calcVertexNormals(SculptType sculptType, int xSize, int ySize) |
380 | { // compute vertex normals by summing all the surface normals of all the triangles sharing | 398 | { // compute vertex normals by summing all the surface normals of all the triangles sharing |
381 | // each vertex and then normalizing | 399 | // each vertex and then normalizing |