From c9b5516ca8664786d85a6c3f48bb831476050c6e Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sat, 9 Feb 2008 05:18:52 +0000 Subject: * Adds Top Shear support to the Meshmerizer for the Cube prim and the Cylinder prim. --- OpenSim/Region/Physics/Meshing/Extruder.cs | 10 ++++ OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 71 ++++++++++++++++++++++++++- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 5 ++ OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 3 ++ 4 files changed, 87 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Physics/Meshing/Extruder.cs b/OpenSim/Region/Physics/Meshing/Extruder.cs index 5886c9e..086261b 100644 --- a/OpenSim/Region/Physics/Meshing/Extruder.cs +++ b/OpenSim/Region/Physics/Meshing/Extruder.cs @@ -40,6 +40,8 @@ namespace OpenSim.Region.Physics.Meshing public float taperTopFactorY = 1f; public float taperBotFactorX = 1f; public float taperBotFactorY = 1f; + public float pushX = 0f; + public float pushY = 0f; public Mesh Extrude(Mesh m) { @@ -54,10 +56,17 @@ namespace OpenSim.Region.Physics.Meshing if (v == null) continue; + // This is the top + // Set the Z + .5 to match the rest of the scale of the mesh + // Scale it by Size, and Taper the scaling v.Z = +.5f; v.X *= (size.X * taperTopFactorX); v.Y *= (size.Y * taperTopFactorY); v.Z *= size.Z; + + //Push the top of the object over by the Top Shear amount + v.X += pushX * size.X; + v.Y += pushY * size.X; } foreach (Vertex v in workingMinus.vertices) @@ -65,6 +74,7 @@ namespace OpenSim.Region.Physics.Meshing if (v == null) continue; + // This is the bottom v.Z = -.5f; v.X *= (size.X * taperBotFactorX); v.Y *= (size.Y * taperBotFactorY); diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index a2bbd3a..641e25d 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -183,11 +183,14 @@ namespace OpenSim.Region.Physics.Meshing UInt16 profileEnd = primShape.ProfileEnd; UInt16 taperX = primShape.PathScaleX; UInt16 taperY = primShape.PathScaleY; + UInt16 pathShearX = primShape.PathShearX; + UInt16 pathShearY = primShape.PathShearY; //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 @@ -242,7 +245,7 @@ namespace OpenSim.Region.Physics.Meshing // Calculated separately to avoid errors cutHull.AddVertex(legEnd); - m_log.Debug(String.Format("Starting cutting of the hollow shape from the prim {1}", 0, primName)); + //m_log.Debug(String.Format("Starting cutting of the hollow shape from the prim {1}", 0, primName)); SimpleHull cuttedHull = SimpleHull.SubtractHull(outerHull, cutHull); outerHull = cuttedHull; @@ -334,6 +337,37 @@ namespace OpenSim.Region.Physics.Meshing } } + + if (pathShearX != 0) + { + if (pathShearX > 50) { + // Complimentary byte. Negative values wrap around the byte. Positive values go up to 50 + extr.pushX = (((float)(256 - pathShearX) / 100) * -1f); + // m_log.Warn("pushX: " + extr.pushX); + } + else + { + extr.pushX = (float)pathShearX / 100; + // m_log.Warn("pushX: " + extr.pushX); + } + } + + if (pathShearY != 0) + { + if (pathShearY > 50) { + // Complimentary byte. Negative values wrap around the byte. Positive values go up to 50 + extr.pushY = (((float)(256 - pathShearY) / 100) * -1f); + //m_log.Warn("pushY: " + extr.pushY); + } + else + { + extr.pushY = (float)pathShearY / 100; + //m_log.Warn("pushY: " + extr.pushY); + } + } + + + Mesh result = extr.Extrude(m); result.DumpRaw(baseDir, primName, "Z extruded"); return result; @@ -346,6 +380,9 @@ namespace OpenSim.Region.Physics.Meshing UInt16 profileEnd = primShape.ProfileEnd; UInt16 taperX = primShape.PathScaleX; UInt16 taperY = primShape.PathScaleY; + UInt16 pathShearX = primShape.PathShearX; + UInt16 pathShearY = primShape.PathShearY; + // 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 @@ -653,7 +690,37 @@ namespace OpenSim.Region.Physics.Meshing //m_log.Warn("taperBotFactorY: " + extr.taperBotFactorY.ToString()); } } - + + if (pathShearX != 0) + { + if (pathShearX > 50) + { + // Complimentary byte. Negative values wrap around the byte. Positive values go up to 50 + extr.pushX = (((float)(256 - pathShearX) / 100) * -1f); + //m_log.Warn("pushX: " + extr.pushX); + } + else + { + extr.pushX = (float)pathShearX / 100; + //m_log.Warn("pushX: " + extr.pushX); + } + } + + if (pathShearY != 0) + { + if (pathShearY > 50) + { + // Complimentary byte. Negative values wrap around the byte. Positive values go up to 50 + extr.pushY = (((float)(256 - pathShearY) / 100) * -1f); + //m_log.Warn("pushY: " + extr.pushY); + } + else + { + extr.pushY = (float)pathShearY / 100; + //m_log.Warn("pushY: " + extr.pushY); + } + } + Mesh result = extr.Extrude(m); result.DumpRaw(baseDir, primName, "Z extruded"); return result; diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 52a975e..d171947 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -389,7 +389,12 @@ namespace OpenSim.Region.Physics.OdePlugin { disableBody(); } + + // This sleeper is there to moderate how long it takes between + // setting up the mesh and pre-processing it when we get rapid fire mesh requests on a single object System.Threading.Thread.Sleep(10); + + float[] vertexList = mesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory int[] indexList = mesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage int VertexCount = vertexList.GetLength(0)/3; diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 0ee8eb5..2b3d186 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -1014,6 +1014,9 @@ namespace OpenSim.Region.Physics.OdePlugin if ((pbs.PathScaleX != 100) || (pbs.PathScaleY != 100)) return true; + if ((pbs.PathShearX != 0) || (pbs.PathShearY != 0)) + return true; + if (pbs.ProfileShape == ProfileShape.Circle && pbs.PathCurve == (byte)Extrusion.Straight) return true; -- cgit v1.1