From 730930955a7edc0bfa69ff1cac93acd024cf8d24 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Sun, 25 Oct 2009 00:40:21 -0700 Subject: Changing Scene.ForEachClient to use the synchronous for loop instead of Parallel. This is quite possibly the source of some deadlocking, and at the very least the synchronous version gives better stack traces * Lock the LLUDPClient RTO math * Add a helper function for backing off the RTO, and follow the optional advice in RFC 2988 to clear existing SRTT and RTTVAR values during a backoff * Removing the unused PrimitiveBaseShape.SculptImage parameter * Improved performance of SceneObjectPart instantiation * ZeroMesher now drops SculptData bytes like Meshmerizer, to allow the texture data to be GCed * Improved typecasting speed in MySQLLegacyRegionData.BuildShape() * Improved the instantiation of PrimitiveBaseShape --- OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Physics/Meshing') diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index f609e73..01093e2 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -281,7 +281,7 @@ namespace OpenSim.Region.Physics.Meshing if (idata == null) { - if (primShape.SculptData.Length == 0) + if (primShape.SculptData == null || primShape.SculptData.Length == 0) return null; try -- cgit v1.1 From 119cf80e13e9fccea30147e3274f5d44958248b2 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Mon, 26 Oct 2009 15:52:59 -0700 Subject: Added calls to GC.AddMemoryPressure() when unmanaged memory is allocated for ODE (helps the GC make better scheduling choices), and a call to GC.Collect() right before logins are enabled for a region. Although this doesn't change actual memory usage, it improves the reported usage from OpenSim and the operating system --- OpenSim/Region/Physics/Meshing/Mesh.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Region/Physics/Meshing') diff --git a/OpenSim/Region/Physics/Meshing/Mesh.cs b/OpenSim/Region/Physics/Meshing/Mesh.cs index 4c3cf33..e8a3e19 100644 --- a/OpenSim/Region/Physics/Meshing/Mesh.cs +++ b/OpenSim/Region/Physics/Meshing/Mesh.cs @@ -174,6 +174,9 @@ namespace OpenSim.Region.Physics.Meshing float[] result = getVertexListAsFloat(); m_pinnedVertexes = GCHandle.Alloc(result, GCHandleType.Pinned); + // Inform the garbage collector of this unmanaged allocation so it can schedule + // the next GC round more intelligently + GC.AddMemoryPressure(Buffer.ByteLength(result)); return result; } @@ -223,6 +226,9 @@ namespace OpenSim.Region.Physics.Meshing int[] result = getIndexListAsInt(); m_pinnedIndex = GCHandle.Alloc(result, GCHandleType.Pinned); + // Inform the garbage collector of this unmanaged allocation so it can schedule + // the next GC round more intelligently + GC.AddMemoryPressure(Buffer.ByteLength(result)); return result; } -- cgit v1.1 From d199767e6991d6f368661fce9c5a072e564b8a4b Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Sun, 25 Oct 2009 23:16:12 -0700 Subject: Experimental change of PhysicsVector to Vector3. Untested --- OpenSim/Region/Physics/Meshing/HelperTypes.cs | 62 +++++++++++++++++++-------- OpenSim/Region/Physics/Meshing/Mesh.cs | 7 +-- OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 21 ++++----- 3 files changed, 56 insertions(+), 34 deletions(-) (limited to 'OpenSim/Region/Physics/Meshing') 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; using OpenSim.Region.Physics.Manager; using OpenSim.Region.Physics.Meshing; -public class Vertex : PhysicsVector, IComparable +public class Vertex : IComparable { + Vector3 vector; + + public float X + { + get { return vector.X; } + set { vector.X = value; } + } + + public float Y + { + get { return vector.Y; } + set { vector.Y = value; } + } + + public float Z + { + get { return vector.Z; } + set { vector.Z = value; } + } + public Vertex(float x, float y, float z) - : base(x, y, z) { + vector.X = x; + vector.Y = y; + vector.Z = z; } public Vertex normalize() { - float tlength = length(); - if (tlength != 0) + float tlength = vector.Length(); + if (tlength != 0f) { float mul = 1.0f / tlength; - return new Vertex(X * mul, Y * mul, Z * mul); + return new Vertex(vector.X * mul, vector.Y * mul, vector.Z * mul); } else { - return new Vertex(0, 0, 0); + return new Vertex(0f, 0f, 0f); } } public Vertex cross(Vertex v) { - return new Vertex(Y * v.Z - Z * v.Y, Z * v.X - X * v.Z, X * v.Y - Y * v.X); + 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); } // disable warning: mono compiler moans about overloading @@ -160,9 +182,9 @@ public class Vertex : PhysicsVector, IComparable return X * v.X + Y * v.Y + Z * v.Z; } - public Vertex(PhysicsVector v) - : base(v.X, v.Y, v.Z) + public Vertex(Vector3 v) { + vector = v; } public Vertex Clone() @@ -175,11 +197,15 @@ public class Vertex : PhysicsVector, IComparable return new Vertex((float) Math.Cos(angle), (float) Math.Sin(angle), 0.0f); } + public float Length() + { + return vector.Length(); + } public virtual bool Equals(Vertex v, float tolerance) { - PhysicsVector diff = this - v; - float d = diff.length(); + Vertex diff = this - v; + float d = diff.Length(); if (d < tolerance) return true; @@ -369,22 +395,22 @@ public class Triangle return s1 + ";" + s2 + ";" + s3; } - public PhysicsVector getNormal() + public Vector3 getNormal() { // Vertices // Vectors for edges - PhysicsVector e1; - PhysicsVector e2; + Vector3 e1; + Vector3 e2; - e1 = new PhysicsVector(v1.X - v2.X, v1.Y - v2.Y, v1.Z - v2.Z); - e2 = new PhysicsVector(v1.X - v3.X, v1.Y - v3.Y, v1.Z - v3.Z); + e1 = new Vector3(v1.X - v2.X, v1.Y - v2.Y, v1.Z - v2.Z); + e2 = new Vector3(v1.X - v3.X, v1.Y - v3.Y, v1.Z - v3.Z); // Cross product for normal - PhysicsVector n = PhysicsVector.cross(e1, e2); + Vector3 n = Vector3.Cross(e1, e2); // Length - float l = n.length(); + float l = n.Length(); // Normalized "normal" 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; using System.Runtime.InteropServices; using OpenSim.Region.Physics.Manager; using PrimMesher; +using OpenMetaverse; namespace OpenSim.Region.Physics.Meshing { @@ -141,12 +142,12 @@ namespace OpenSim.Region.Physics.Meshing } } - public List getVertexList() + public List getVertexList() { - List result = new List(); + List result = new List(); foreach (Vertex v in m_vertices.Keys) { - result.Add(v); + result.Add(new Vector3(v.X, v.Y, v.Z)); } return result; } 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 public class Meshmerizer : IMesher { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - //private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); // 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 @@ -160,7 +159,7 @@ namespace OpenSim.Region.Physics.Meshing float minZ = float.MaxValue; float maxZ = float.MinValue; - foreach (Vertex v in meshIn.getVertexList()) + foreach (Vector3 v in meshIn.getVertexList()) { if (v != null) { @@ -185,7 +184,7 @@ namespace OpenSim.Region.Physics.Meshing } - private ulong GetMeshKey(PrimitiveBaseShape pbs, PhysicsVector size, float lod) + private ulong GetMeshKey(PrimitiveBaseShape pbs, Vector3 size, float lod) { ulong hash = 5381; @@ -245,9 +244,9 @@ namespace OpenSim.Region.Physics.Meshing hash = ((hash << 5) + hash) + (ulong)((byte)c); return ((hash << 5) + hash) + (ulong)(c >> 8); } - - private Mesh CreateMeshFromPrimMesher(string primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod) + + private Mesh CreateMeshFromPrimMesher(string primName, PrimitiveBaseShape primShape, Vector3 size, float lod) { PrimMesh primMesh; PrimMesher.SculptMesh sculptMesh; @@ -289,9 +288,6 @@ namespace OpenSim.Region.Physics.Meshing ManagedImage managedImage; // we never use this OpenJPEG.DecodeToImage(primShape.SculptData, out managedImage, out idata); - // Remove the reference to the encoded JPEG2000 data so it can be GCed - primShape.SculptData = Utils.EmptyBytes; - if (cacheSculptMaps) { try { idata.Save(decodedSculptFileName, ImageFormat.MemoryBmp); } @@ -315,8 +311,6 @@ namespace OpenSim.Region.Physics.Meshing } } - - PrimMesher.SculptMesh.SculptType sculptType; switch ((OpenMetaverse.SculptType)primShape.SculptType) { @@ -351,7 +345,6 @@ namespace OpenSim.Region.Physics.Meshing coords = sculptMesh.coords; faces = sculptMesh.faces; } - else { 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 faces = primMesh.faces; } + // Remove the reference to any JPEG2000 sculpt data so it can be GCed + primShape.SculptData = Utils.EmptyBytes; int numCoords = coords.Count; int numFaces = faces.Count; @@ -488,12 +483,12 @@ namespace OpenSim.Region.Physics.Meshing return mesh; } - public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod) + public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod) { return CreateMesh(primName, primShape, size, lod, false); } - public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod, bool isPhysical) + public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical) { Mesh mesh = null; ulong key = 0; -- cgit v1.1 From f5cad91578d9f7dbfb54d17bb476929e935682a8 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Mon, 26 Oct 2009 19:03:55 -0700 Subject: * Switched from OpenJPEG to CSJ2K in Meshmerizer * Tested the previous patch and found no regressions --- OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'OpenSim/Region/Physics/Meshing') diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index a90a89a..fbe1949 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -31,7 +31,6 @@ using System.Collections.Generic; using OpenSim.Framework; using OpenSim.Region.Physics.Manager; using OpenMetaverse; -using OpenMetaverse.Imaging; using System.Drawing; using System.Drawing.Imaging; using PrimMesher; @@ -285,8 +284,7 @@ namespace OpenSim.Region.Physics.Meshing try { - ManagedImage managedImage; // we never use this - OpenJPEG.DecodeToImage(primShape.SculptData, out managedImage, out idata); + idata = CSJ2K.J2kImage.FromBytes(primShape.SculptData); if (cacheSculptMaps) { -- cgit v1.1