From fadf5b479fea038f129cf85e1fb02857d19ac38f Mon Sep 17 00:00:00 2001
From: Teravus Ovares
Date: Fri, 8 Feb 2008 23:28:38 +0000
Subject: * Added Taper support to the Meshmerizer for Cube and Cylinder. *
 Removed the hull verbosity

---
 OpenSim/Region/Physics/Meshing/Extruder.cs    | 13 +++--
 OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 68 ++++++++++++++++++++++++++-
 OpenSim/Region/Physics/Meshing/SimpleHull.cs  | 16 +++----
 3 files changed, 83 insertions(+), 14 deletions(-)

(limited to 'OpenSim')

diff --git a/OpenSim/Region/Physics/Meshing/Extruder.cs b/OpenSim/Region/Physics/Meshing/Extruder.cs
index 7ef5b5b..5886c9e 100644
--- a/OpenSim/Region/Physics/Meshing/Extruder.cs
+++ b/OpenSim/Region/Physics/Meshing/Extruder.cs
@@ -36,6 +36,11 @@ namespace OpenSim.Region.Physics.Meshing
         public float stopParameter;
         public PhysicsVector size;
 
+        public float taperTopFactorX = 1f;
+        public float taperTopFactorY = 1f;
+        public float taperBotFactorX = 1f;
+        public float taperBotFactorY = 1f;
+
         public Mesh Extrude(Mesh m)
         {
             // Currently only works for iSteps=1;
@@ -50,8 +55,8 @@ namespace OpenSim.Region.Physics.Meshing
                     continue;
 
                 v.Z = +.5f;
-                v.X *= size.X;
-                v.Y *= size.Y;
+                v.X *= (size.X * taperTopFactorX);
+                v.Y *= (size.Y * taperTopFactorY);
                 v.Z *= size.Z;
             }
 
@@ -61,8 +66,8 @@ namespace OpenSim.Region.Physics.Meshing
                     continue;
 
                 v.Z = -.5f;
-                v.X *= size.X;
-                v.Y *= size.Y;
+                v.X *= (size.X * taperBotFactorX);
+                v.Y *= (size.Y * taperBotFactorY);
                 v.Z *= size.Z;
             }
 
diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
index 2d80287..a2bbd3a 100644
--- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
+++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
@@ -58,7 +58,7 @@ namespace OpenSim.Region.Physics.Meshing
         // Setting baseDir to a path will enable the dumping of raw files
         // raw files can be imported by blender so a visual inspection of the results can be done
         //        const string baseDir = "rawFiles";
-        private const string baseDir = null;
+        private const string baseDir = null; //"rawFiles";
 
         private static void IntersectionParameterPD(PhysicsVector p1, PhysicsVector r1, PhysicsVector p2,
                                                     PhysicsVector r2, ref float lambda, ref float mu)
@@ -181,7 +181,13 @@ namespace OpenSim.Region.Physics.Meshing
             UInt16 hollowFactor = primShape.ProfileHollow;
             UInt16 profileBegin = primShape.ProfileBegin;
             UInt16 profileEnd = primShape.ProfileEnd;
+            UInt16 taperX = primShape.PathScaleX;
+            UInt16 taperY = primShape.PathScaleY;
 
+            //m_log.Error("pathShear:" + primShape.PathShearX.ToString() + "," + primShape.PathShearY.ToString());
+            //m_log.Error("pathTaper:" + primShape.PathTaperX.ToString() + "," + primShape.PathTaperY.ToString());
+            //m_log.Error("ProfileBegin:" + primShape.ProfileBegin.ToString() + "," + primShape.ProfileBegin.ToString());
+            //m_log.Error("PathScale:" + primShape.PathScaleX.ToString() + "," + primShape.PathScaleY.ToString());
             // Procedure: This is based on the fact that the upper (plus) and lower (minus) Z-surface
             // of a block are basically the same
             // They may be warped differently but the shape is identical
@@ -299,6 +305,35 @@ namespace OpenSim.Region.Physics.Meshing
 
             extr.size = size;
 
+            if (taperX != 100)
+            {
+                if (taperX > 100)
+                {
+                    extr.taperTopFactorX = 1.0f - ((float)taperX / 200);
+                    //m_log.Warn("taperTopFactorX: " + extr.taperTopFactorX.ToString());
+                }
+                else
+                {
+                    extr.taperBotFactorX = 1.0f - ((100 - (float)taperX) / 100);
+                    //m_log.Warn("taperBotFactorX: " + extr.taperBotFactorX.ToString());
+                }
+                
+            }
+
+            if (taperY != 100)
+            {
+                if (taperY > 100)
+                {
+                    extr.taperTopFactorY = 1.0f - ((float)taperY / 200);
+                    //m_log.Warn("taperTopFactorY: " + extr.taperTopFactorY.ToString());
+                }
+                else
+                {
+                    extr.taperBotFactorY = 1.0f - ((100 - (float)taperY) / 100);
+                    //m_log.Warn("taperBotFactorY: " + extr.taperBotFactorY.ToString());
+                }
+            }
+            
             Mesh result = extr.Extrude(m);
             result.DumpRaw(baseDir, primName, "Z extruded");
             return result;
@@ -309,7 +344,8 @@ namespace OpenSim.Region.Physics.Meshing
             UInt16 hollowFactor = primShape.ProfileHollow;
             UInt16 profileBegin = primShape.ProfileBegin;
             UInt16 profileEnd = primShape.ProfileEnd;
-
+            UInt16 taperX = primShape.PathScaleX;
+            UInt16 taperY = primShape.PathScaleY;
             // Procedure: This is based on the fact that the upper (plus) and lower (minus) Z-surface
             // of a block are basically the same
             // They may be warped differently but the shape is identical
@@ -589,7 +625,35 @@ namespace OpenSim.Region.Physics.Meshing
             Extruder extr = new Extruder();
 
             extr.size = size;
+            if (taperX != 100)
+            {
+                if (taperX > 100)
+                {
+                    extr.taperTopFactorX = 1.0f - ((float)taperX / 200);
+                    //m_log.Warn("taperTopFactorX: " + extr.taperTopFactorX.ToString());
+                }
+                else
+                {
+                    extr.taperBotFactorX = 1.0f - ((100 - (float)taperX) / 100);
+                    //m_log.Warn("taperBotFactorX: " + extr.taperBotFactorX.ToString());
+                }
+
+            }
 
+            if (taperY != 100)
+            {
+                if (taperY > 100)
+                {
+                    extr.taperTopFactorY = 1.0f - ((float)taperY / 200);
+                    //m_log.Warn("taperTopFactorY: " + extr.taperTopFactorY.ToString());
+                }
+                else
+                {
+                    extr.taperBotFactorY = 1.0f - ((100 - (float)taperY) / 100);
+                    //m_log.Warn("taperBotFactorY: " + extr.taperBotFactorY.ToString());
+                }
+            }
+            
             Mesh result = extr.Extrude(m);
             result.DumpRaw(baseDir, primName, "Z extruded");
             return result;
diff --git a/OpenSim/Region/Physics/Meshing/SimpleHull.cs b/OpenSim/Region/Physics/Meshing/SimpleHull.cs
index 9209860..e9cce3b 100644
--- a/OpenSim/Region/Physics/Meshing/SimpleHull.cs
+++ b/OpenSim/Region/Physics/Meshing/SimpleHull.cs
@@ -245,9 +245,9 @@ namespace OpenSim.Region.Physics.Meshing
             SimpleHull otherHullClone = otherHull.Clone();
             bool intersects = false;
 
-            m_log.Debug("State before intersection detection");
-            m_log.Debug(String.Format("The baseHull is:\n{1}", 0, baseHullClone.ToString()));
-            m_log.Debug(String.Format("The otherHull is:\n{1}", 0, otherHullClone.ToString()));
+            //m_log.Debug("State before intersection detection");
+            //m_log.Debug(String.Format("The baseHull is:\n{1}", 0, baseHullClone.ToString()));
+            //m_log.Debug(String.Format("The otherHull is:\n{1}", 0, otherHullClone.ToString()));
 
             {
                 int iBase, iOther;
@@ -276,8 +276,8 @@ namespace OpenSim.Region.Physics.Meshing
                 }
             }
 
-            m_log.Debug("State after intersection detection for the base hull");
-            m_log.Debug(String.Format("The baseHull is:\n{1}", 0, baseHullClone.ToString()));
+            //m_log.Debug("State after intersection detection for the base hull");
+            //m_log.Debug(String.Format("The baseHull is:\n{1}", 0, baseHullClone.ToString()));
 
             {
                 int iOther, iBase;
@@ -305,8 +305,8 @@ namespace OpenSim.Region.Physics.Meshing
                 }
             }
 
-            m_log.Debug("State after intersection detection for the base hull");
-            m_log.Debug(String.Format("The otherHull is:\n{1}", 0, otherHullClone.ToString()));
+            //m_log.Debug("State after intersection detection for the base hull");
+            //m_log.Debug(String.Format("The otherHull is:\n{1}", 0, otherHullClone.ToString()));
 
 
             bool otherIsInBase = baseHullClone.containsPointsFrom(otherHullClone);
@@ -389,7 +389,7 @@ namespace OpenSim.Region.Physics.Meshing
                     done = true;
             }
 
-            m_log.Debug(String.Format("The resulting Hull is:\n{1}", 0, result.ToString()));
+            //m_log.Debug(String.Format("The resulting Hull is:\n{1}", 0, result.ToString()));
 
             return result;
         }
-- 
cgit v1.1