aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-05-23 23:53:44 +0100
committerJustin Clark-Casey (justincc)2013-05-23 23:53:44 +0100
commite597a7d94e446a2bdd668cca5e910653fdad04b7 (patch)
tree9328b97d12c3c5c280be3a794855630532714da6 /OpenSim/Region
parentFix bug where a cloned object would report the wrong llGetNumberOfPrims() whe... (diff)
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-e597a7d94e446a2bdd668cca5e910653fdad04b7.zip
opensim-SC_OLD-e597a7d94e446a2bdd668cca5e910653fdad04b7.tar.gz
opensim-SC_OLD-e597a7d94e446a2bdd668cca5e910653fdad04b7.tar.bz2
opensim-SC_OLD-e597a7d94e446a2bdd668cca5e910653fdad04b7.tar.xz
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Physics/Meshing/Meshmerizer.cs57
1 files changed, 53 insertions, 4 deletions
diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
index adc0dc9..fd45efe 100644
--- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
+++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
@@ -83,6 +83,7 @@ namespace OpenSim.Region.Physics.Meshing
83 private float minSizeForComplexMesh = 0.2f; // prims with all dimensions smaller than this will have a bounding box mesh 83 private float minSizeForComplexMesh = 0.2f; // prims with all dimensions smaller than this will have a bounding box mesh
84 84
85 private List<List<Vector3>> mConvexHulls = null; 85 private List<List<Vector3>> mConvexHulls = null;
86 private List<Vector3> mBoundingHull = null;
86 87
87 private Dictionary<ulong, Mesh> m_uniqueMeshes = new Dictionary<ulong, Mesh>(); 88 private Dictionary<ulong, Mesh> m_uniqueMeshes = new Dictionary<ulong, Mesh>();
88 89
@@ -324,6 +325,9 @@ namespace OpenSim.Region.Physics.Meshing
324 faces = new List<Face>(); 325 faces = new List<Face>();
325 OSD meshOsd = null; 326 OSD meshOsd = null;
326 327
328 mConvexHulls = null;
329 mBoundingHull = null;
330
327 if (primShape.SculptData.Length <= 0) 331 if (primShape.SculptData.Length <= 0)
328 { 332 {
329 // XXX: At the moment we can not log here since ODEPrim, for instance, ends up triggering this 333 // XXX: At the moment we can not log here since ODEPrim, for instance, ends up triggering this
@@ -385,13 +389,41 @@ namespace OpenSim.Region.Physics.Meshing
385 try 389 try
386 { 390 {
387 OSDMap convexBlock = (OSDMap)map["physics_convex"]; 391 OSDMap convexBlock = (OSDMap)map["physics_convex"];
392
393 Vector3 min = new Vector3(-0.5f, -0.5f, -0.5f);
394 if (convexBlock.ContainsKey("Min")) min = convexBlock["Min"].AsVector3();
395 Vector3 max = new Vector3(0.5f, 0.5f, 0.5f);
396 if (convexBlock.ContainsKey("Max")) max = convexBlock["Max"].AsVector3();
397
398 List<Vector3> boundingHull = null;
399
400 if (convexBlock.ContainsKey("BoundingVerts"))
401 {
402 // decompress and decode bounding hull points
403 byte[] boundingVertsBytes = DecompressOsd(convexBlock["BoundingVerts"].AsBinary()).AsBinary();
404 boundingHull = new List<Vector3>();
405 for (int i = 0; i < boundingVertsBytes.Length;)
406 {
407 ushort uX = Utils.BytesToUInt16(boundingVertsBytes, i); i += 2;
408 ushort uY = Utils.BytesToUInt16(boundingVertsBytes, i); i += 2;
409 ushort uZ = Utils.BytesToUInt16(boundingVertsBytes, i); i += 2;
410
411 Vector3 pos = new Vector3(
412 Utils.UInt16ToFloat(uX, min.X, max.X),
413 Utils.UInt16ToFloat(uY, min.Y, max.Y),
414 Utils.UInt16ToFloat(uZ, min.Z, max.Z)
415 );
416
417 boundingHull.Add(pos);
418 }
419
420 mBoundingHull = boundingHull;
421 if (debugDetail) m_log.DebugFormat("{0} prim='{1}': parsed bounding hull. nHulls={2}", LogHeader, primName, mBoundingHull.Count);
422 }
423
388 if (convexBlock.ContainsKey("HullList")) 424 if (convexBlock.ContainsKey("HullList"))
389 { 425 {
390 byte[] hullList = convexBlock["HullList"].AsBinary(); 426 byte[] hullList = convexBlock["HullList"].AsBinary();
391 Vector3 min = new Vector3(-0.5f, -0.5f, -0.5f);
392 if (convexBlock.ContainsKey("Min")) min = convexBlock["Min"].AsVector3();
393 Vector3 max = new Vector3(0.5f, 0.5f, 0.5f);
394 if (convexBlock.ContainsKey("Max")) max = convexBlock["Max"].AsVector3();
395 427
396 // decompress and decode hull points 428 // decompress and decode hull points
397 byte[] posBytes = DecompressOsd(convexBlock["Positions"].AsBinary()).AsBinary(); 429 byte[] posBytes = DecompressOsd(convexBlock["Positions"].AsBinary()).AsBinary();
@@ -799,6 +831,23 @@ namespace OpenSim.Region.Physics.Meshing
799 /// temporary prototype code - please do not use until the interface has been finalized! 831 /// temporary prototype code - please do not use until the interface has been finalized!
800 /// </summary> 832 /// </summary>
801 /// <param name="size">value to scale the hull points by</param> 833 /// <param name="size">value to scale the hull points by</param>
834 /// <returns>a list of vertices in the bounding hull if it exists and has been successfully decoded, otherwise null</returns>
835 public List<Vector3> GetBoundingHull(Vector3 size)
836 {
837 if (mBoundingHull == null)
838 return null;
839
840 List<Vector3> verts = new List<Vector3>();
841 foreach (var vert in mBoundingHull)
842 verts.Add(vert * size);
843
844 return verts;
845 }
846
847 /// <summary>
848 /// temporary prototype code - please do not use until the interface has been finalized!
849 /// </summary>
850 /// <param name="size">value to scale the hull points by</param>
802 /// <returns>a list of hulls if they exist and have been successfully decoded, otherwise null</returns> 851 /// <returns>a list of hulls if they exist and have been successfully decoded, otherwise null</returns>
803 public List<List<Vector3>> GetConvexHulls(Vector3 size) 852 public List<List<Vector3>> GetConvexHulls(Vector3 size)
804 { 853 {