aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/Meshing
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/Meshing')
-rw-r--r--OpenSim/Region/Physics/Meshing/HelperTypes.cs62
-rw-r--r--OpenSim/Region/Physics/Meshing/Mesh.cs7
-rw-r--r--OpenSim/Region/Physics/Meshing/Meshmerizer.cs21
3 files changed, 56 insertions, 34 deletions
diff --git a/OpenSim/Region/Physics/Meshing/HelperTypes.cs b/OpenSim/Region/Physics/Meshing/HelperTypes.cs
index 232245f..8cd8dcf 100644
--- a/OpenSim/Region/Physics/Meshing/HelperTypes.cs
+++ b/OpenSim/Region/Physics/Meshing/HelperTypes.cs
@@ -33,30 +33,52 @@ using OpenMetaverse;
33using OpenSim.Region.Physics.Manager; 33using OpenSim.Region.Physics.Manager;
34using OpenSim.Region.Physics.Meshing; 34using OpenSim.Region.Physics.Meshing;
35 35
36public class Vertex : PhysicsVector, IComparable<Vertex> 36public class Vertex : IComparable<Vertex>
37{ 37{
38 Vector3 vector;
39
40 public float X
41 {
42 get { return vector.X; }
43 set { vector.X = value; }
44 }
45
46 public float Y
47 {
48 get { return vector.Y; }
49 set { vector.Y = value; }
50 }
51
52 public float Z
53 {
54 get { return vector.Z; }
55 set { vector.Z = value; }
56 }
57
38 public Vertex(float x, float y, float z) 58 public Vertex(float x, float y, float z)
39 : base(x, y, z)
40 { 59 {
60 vector.X = x;
61 vector.Y = y;
62 vector.Z = z;
41 } 63 }
42 64
43 public Vertex normalize() 65 public Vertex normalize()
44 { 66 {
45 float tlength = length(); 67 float tlength = vector.Length();
46 if (tlength != 0) 68 if (tlength != 0f)
47 { 69 {
48 float mul = 1.0f / tlength; 70 float mul = 1.0f / tlength;
49 return new Vertex(X * mul, Y * mul, Z * mul); 71 return new Vertex(vector.X * mul, vector.Y * mul, vector.Z * mul);
50 } 72 }
51 else 73 else
52 { 74 {
53 return new Vertex(0, 0, 0); 75 return new Vertex(0f, 0f, 0f);
54 } 76 }
55 } 77 }
56 78
57 public Vertex cross(Vertex v) 79 public Vertex cross(Vertex v)
58 { 80 {
59 return new Vertex(Y * v.Z - Z * v.Y, Z * v.X - X * v.Z, X * v.Y - Y * v.X); 81 return new Vertex(vector.Y * v.Z - vector.Z * v.Y, vector.Z * v.X - vector.X * v.Z, vector.X * v.Y - vector.Y * v.X);
60 } 82 }
61 83
62 // disable warning: mono compiler moans about overloading 84 // disable warning: mono compiler moans about overloading
@@ -160,9 +182,9 @@ public class Vertex : PhysicsVector, IComparable<Vertex>
160 return X * v.X + Y * v.Y + Z * v.Z; 182 return X * v.X + Y * v.Y + Z * v.Z;
161 } 183 }
162 184
163 public Vertex(PhysicsVector v) 185 public Vertex(Vector3 v)
164 : base(v.X, v.Y, v.Z)
165 { 186 {
187 vector = v;
166 } 188 }
167 189
168 public Vertex Clone() 190 public Vertex Clone()
@@ -175,11 +197,15 @@ public class Vertex : PhysicsVector, IComparable<Vertex>
175 return new Vertex((float) Math.Cos(angle), (float) Math.Sin(angle), 0.0f); 197 return new Vertex((float) Math.Cos(angle), (float) Math.Sin(angle), 0.0f);
176 } 198 }
177 199
200 public float Length()
201 {
202 return vector.Length();
203 }
178 204
179 public virtual bool Equals(Vertex v, float tolerance) 205 public virtual bool Equals(Vertex v, float tolerance)
180 { 206 {
181 PhysicsVector diff = this - v; 207 Vertex diff = this - v;
182 float d = diff.length(); 208 float d = diff.Length();
183 if (d < tolerance) 209 if (d < tolerance)
184 return true; 210 return true;
185 211
@@ -369,22 +395,22 @@ public class Triangle
369 return s1 + ";" + s2 + ";" + s3; 395 return s1 + ";" + s2 + ";" + s3;
370 } 396 }
371 397
372 public PhysicsVector getNormal() 398 public Vector3 getNormal()
373 { 399 {
374 // Vertices 400 // Vertices
375 401
376 // Vectors for edges 402 // Vectors for edges
377 PhysicsVector e1; 403 Vector3 e1;
378 PhysicsVector e2; 404 Vector3 e2;
379 405
380 e1 = new PhysicsVector(v1.X - v2.X, v1.Y - v2.Y, v1.Z - v2.Z); 406 e1 = new Vector3(v1.X - v2.X, v1.Y - v2.Y, v1.Z - v2.Z);
381 e2 = new PhysicsVector(v1.X - v3.X, v1.Y - v3.Y, v1.Z - v3.Z); 407 e2 = new Vector3(v1.X - v3.X, v1.Y - v3.Y, v1.Z - v3.Z);
382 408
383 // Cross product for normal 409 // Cross product for normal
384 PhysicsVector n = PhysicsVector.cross(e1, e2); 410 Vector3 n = Vector3.Cross(e1, e2);
385 411
386 // Length 412 // Length
387 float l = n.length(); 413 float l = n.Length();
388 414
389 // Normalized "normal" 415 // Normalized "normal"
390 n = n/l; 416 n = n/l;
diff --git a/OpenSim/Region/Physics/Meshing/Mesh.cs b/OpenSim/Region/Physics/Meshing/Mesh.cs
index e8a3e19..f781ff9 100644
--- a/OpenSim/Region/Physics/Meshing/Mesh.cs
+++ b/OpenSim/Region/Physics/Meshing/Mesh.cs
@@ -31,6 +31,7 @@ using System.IO;
31using System.Runtime.InteropServices; 31using System.Runtime.InteropServices;
32using OpenSim.Region.Physics.Manager; 32using OpenSim.Region.Physics.Manager;
33using PrimMesher; 33using PrimMesher;
34using OpenMetaverse;
34 35
35namespace OpenSim.Region.Physics.Meshing 36namespace OpenSim.Region.Physics.Meshing
36{ 37{
@@ -141,12 +142,12 @@ namespace OpenSim.Region.Physics.Meshing
141 } 142 }
142 } 143 }
143 144
144 public List<PhysicsVector> getVertexList() 145 public List<Vector3> getVertexList()
145 { 146 {
146 List<PhysicsVector> result = new List<PhysicsVector>(); 147 List<Vector3> result = new List<Vector3>();
147 foreach (Vertex v in m_vertices.Keys) 148 foreach (Vertex v in m_vertices.Keys)
148 { 149 {
149 result.Add(v); 150 result.Add(new Vector3(v.X, v.Y, v.Z));
150 } 151 }
151 return result; 152 return result;
152 } 153 }
diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
index 01093e2..a90a89a 100644
--- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
+++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
@@ -61,7 +61,6 @@ namespace OpenSim.Region.Physics.Meshing
61 public class Meshmerizer : IMesher 61 public class Meshmerizer : IMesher
62 { 62 {
63 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 63 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
64 //private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
65 64
66 // Setting baseDir to a path will enable the dumping of raw files 65 // Setting baseDir to a path will enable the dumping of raw files
67 // raw files can be imported by blender so a visual inspection of the results can be done 66 // raw files can be imported by blender so a visual inspection of the results can be done
@@ -160,7 +159,7 @@ namespace OpenSim.Region.Physics.Meshing
160 float minZ = float.MaxValue; 159 float minZ = float.MaxValue;
161 float maxZ = float.MinValue; 160 float maxZ = float.MinValue;
162 161
163 foreach (Vertex v in meshIn.getVertexList()) 162 foreach (Vector3 v in meshIn.getVertexList())
164 { 163 {
165 if (v != null) 164 if (v != null)
166 { 165 {
@@ -185,7 +184,7 @@ namespace OpenSim.Region.Physics.Meshing
185 184
186 } 185 }
187 186
188 private ulong GetMeshKey(PrimitiveBaseShape pbs, PhysicsVector size, float lod) 187 private ulong GetMeshKey(PrimitiveBaseShape pbs, Vector3 size, float lod)
189 { 188 {
190 ulong hash = 5381; 189 ulong hash = 5381;
191 190
@@ -245,9 +244,9 @@ namespace OpenSim.Region.Physics.Meshing
245 hash = ((hash << 5) + hash) + (ulong)((byte)c); 244 hash = ((hash << 5) + hash) + (ulong)((byte)c);
246 return ((hash << 5) + hash) + (ulong)(c >> 8); 245 return ((hash << 5) + hash) + (ulong)(c >> 8);
247 } 246 }
248
249 247
250 private Mesh CreateMeshFromPrimMesher(string primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod) 248
249 private Mesh CreateMeshFromPrimMesher(string primName, PrimitiveBaseShape primShape, Vector3 size, float lod)
251 { 250 {
252 PrimMesh primMesh; 251 PrimMesh primMesh;
253 PrimMesher.SculptMesh sculptMesh; 252 PrimMesher.SculptMesh sculptMesh;
@@ -289,9 +288,6 @@ namespace OpenSim.Region.Physics.Meshing
289 ManagedImage managedImage; // we never use this 288 ManagedImage managedImage; // we never use this
290 OpenJPEG.DecodeToImage(primShape.SculptData, out managedImage, out idata); 289 OpenJPEG.DecodeToImage(primShape.SculptData, out managedImage, out idata);
291 290
292 // Remove the reference to the encoded JPEG2000 data so it can be GCed
293 primShape.SculptData = Utils.EmptyBytes;
294
295 if (cacheSculptMaps) 291 if (cacheSculptMaps)
296 { 292 {
297 try { idata.Save(decodedSculptFileName, ImageFormat.MemoryBmp); } 293 try { idata.Save(decodedSculptFileName, ImageFormat.MemoryBmp); }
@@ -315,8 +311,6 @@ namespace OpenSim.Region.Physics.Meshing
315 } 311 }
316 } 312 }
317 313
318
319
320 PrimMesher.SculptMesh.SculptType sculptType; 314 PrimMesher.SculptMesh.SculptType sculptType;
321 switch ((OpenMetaverse.SculptType)primShape.SculptType) 315 switch ((OpenMetaverse.SculptType)primShape.SculptType)
322 { 316 {
@@ -351,7 +345,6 @@ namespace OpenSim.Region.Physics.Meshing
351 coords = sculptMesh.coords; 345 coords = sculptMesh.coords;
352 faces = sculptMesh.faces; 346 faces = sculptMesh.faces;
353 } 347 }
354
355 else 348 else
356 { 349 {
357 float pathShearX = primShape.PathShearX < 128 ? (float)primShape.PathShearX * 0.01f : (float)(primShape.PathShearX - 256) * 0.01f; 350 float pathShearX = primShape.PathShearX < 128 ? (float)primShape.PathShearX * 0.01f : (float)(primShape.PathShearX - 256) * 0.01f;
@@ -466,6 +459,8 @@ namespace OpenSim.Region.Physics.Meshing
466 faces = primMesh.faces; 459 faces = primMesh.faces;
467 } 460 }
468 461
462 // Remove the reference to any JPEG2000 sculpt data so it can be GCed
463 primShape.SculptData = Utils.EmptyBytes;
469 464
470 int numCoords = coords.Count; 465 int numCoords = coords.Count;
471 int numFaces = faces.Count; 466 int numFaces = faces.Count;
@@ -488,12 +483,12 @@ namespace OpenSim.Region.Physics.Meshing
488 return mesh; 483 return mesh;
489 } 484 }
490 485
491 public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod) 486 public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod)
492 { 487 {
493 return CreateMesh(primName, primShape, size, lod, false); 488 return CreateMesh(primName, primShape, size, lod, false);
494 } 489 }
495 490
496 public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod, bool isPhysical) 491 public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical)
497 { 492 {
498 Mesh mesh = null; 493 Mesh mesh = null;
499 ulong key = 0; 494 ulong key = 0;