From 1c0f3a1f21ba580d5d0cb6325c10ee5d53ab35d4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 20 Mar 2012 00:40:03 +0000 Subject: Fix crash where two scene loop threads could changes m_MeshToTriMeshMap at the same time. Have to lock m_MeshToTriMeshMap as property is static and with more than one region two scene loops could try to manipulate at the same time. --- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/Physics') diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 97890ee..1f79cd8 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -842,17 +842,23 @@ namespace OpenSim.Region.Physics.OdePlugin mesh.getIndexListAsPtrToIntArray(out indices, out triStride, out indexCount); // Also fixed, needs release after usage mesh.releaseSourceMeshData(); // free up the original mesh data to save memory - if (m_MeshToTriMeshMap.ContainsKey(mesh)) - { - _triMeshData = m_MeshToTriMeshMap[mesh]; - } - else - { - _triMeshData = d.GeomTriMeshDataCreate(); - d.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride); - d.GeomTriMeshDataPreprocess(_triMeshData); - m_MeshToTriMeshMap[mesh] = _triMeshData; + // We must lock here since m_MeshToTriMeshMap is static and multiple scene threads may call this method at + // the same time. + lock (m_MeshToTriMeshMap) + { + if (m_MeshToTriMeshMap.ContainsKey(mesh)) + { + _triMeshData = m_MeshToTriMeshMap[mesh]; + } + else + { + _triMeshData = d.GeomTriMeshDataCreate(); + + d.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride); + d.GeomTriMeshDataPreprocess(_triMeshData); + m_MeshToTriMeshMap[mesh] = _triMeshData; + } } // _parent_scene.waitForSpaceUnlock(m_targetSpace); -- cgit v1.1 From 5f2a65c9762f626bc3389bcd85ae20e45aa09b04 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 20 Mar 2012 20:28:58 +0000 Subject: refactor: Eliminate unnecessary duplicate avCapsuleTilted --- OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Physics') diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs index 598530c..1f8c2ca 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs @@ -181,8 +181,12 @@ namespace OpenSim.Region.Physics.OdePlugin private float avPIDP = 1400f; private float avCapRadius = 0.37f; private float avStandupTensor = 2000000f; - private bool avCapsuleTilted = true; // true = old compatibility mode with leaning capsule; false = new corrected mode - public bool IsAvCapsuleTilted { get { return avCapsuleTilted; } set { avCapsuleTilted = value; } } + + /// + /// true = old compatibility mode with leaning capsule; false = new corrected mode + /// + public bool IsAvCapsuleTilted { get; private set; } + private float avDensity = 80f; // private float avHeightFudgeFactor = 0.52f; private float avMovementDivisorWalk = 1.3f; @@ -501,7 +505,7 @@ namespace OpenSim.Region.Physics.OdePlugin avMovementDivisorWalk = physicsconfig.GetFloat("av_movement_divisor_walk", 1.3f); avMovementDivisorRun = physicsconfig.GetFloat("av_movement_divisor_run", 0.8f); avCapRadius = physicsconfig.GetFloat("av_capsule_radius", 0.37f); - avCapsuleTilted = physicsconfig.GetBoolean("av_capsule_tilted", false); + IsAvCapsuleTilted = physicsconfig.GetBoolean("av_capsule_tilted", false); contactsPerCollision = physicsconfig.GetInt("contacts_per_collision", 80); -- cgit v1.1 From 86bd287b5346063edb0f62ceb96ee08c6ee80c18 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 20 Mar 2012 20:39:33 +0000 Subject: refactor: precalculate the fixed movement factor for avatar tilting (sqrt(2)) rather than doing it multiple times on every move. --- OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 21 +++++++++++++-------- OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 3 +++ 2 files changed, 16 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Physics') diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index 6d1f41d..8397eb4 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -115,6 +115,11 @@ namespace OpenSim.Region.Physics.OdePlugin private float m_tainted_CAPSULE_LENGTH; // set when the capsule length changes. /// + /// Base movement for calculating tilt. + /// + private float m_tiltBaseMovement = (float)Math.Sqrt(2); + + /// /// Used to introduce a fixed tilt because a straight-up capsule falls through terrain, probably a bug in terrain collider /// private float m_tiltMagnitudeWhenProjectedOnXYPlane = 0.1131371f; @@ -524,14 +529,14 @@ namespace OpenSim.Region.Physics.OdePlugin if (movementVector.Y > 0) { // northeast - movementVector.X = (float)Math.Sqrt(2.0); - movementVector.Y = (float)Math.Sqrt(2.0); + movementVector.X = m_tiltBaseMovement; + movementVector.Y = m_tiltBaseMovement; } else { // southeast - movementVector.X = (float)Math.Sqrt(2.0); - movementVector.Y = -(float)Math.Sqrt(2.0); + movementVector.X = m_tiltBaseMovement; + movementVector.Y = -m_tiltBaseMovement; } } else @@ -540,14 +545,14 @@ namespace OpenSim.Region.Physics.OdePlugin if (movementVector.Y > 0) { // northwest - movementVector.X = -(float)Math.Sqrt(2.0); - movementVector.Y = (float)Math.Sqrt(2.0); + movementVector.X = -m_tiltBaseMovement; + movementVector.Y = m_tiltBaseMovement; } else { // southwest - movementVector.X = -(float)Math.Sqrt(2.0); - movementVector.Y = -(float)Math.Sqrt(2.0); + movementVector.X = -m_tiltBaseMovement; + movementVector.Y = -m_tiltBaseMovement; } } diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs index 1f8c2ca..842ff91 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs @@ -185,6 +185,9 @@ namespace OpenSim.Region.Physics.OdePlugin /// /// true = old compatibility mode with leaning capsule; false = new corrected mode /// + /// + /// Even when set to false, the capsule still tilts but this is done in a different way. + /// public bool IsAvCapsuleTilted { get; private set; } private float avDensity = 80f; -- cgit v1.1 From 4c41b53a4b82aaadc4dda9019a3501fc8413d85e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 20 Mar 2012 23:35:50 +0000 Subject: Add prim name to "[MESH]: No recognized physics mesh..." log message --- OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Physics') diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index 6f6ed7f..3bd15ce 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -358,7 +358,7 @@ namespace OpenSim.Region.Physics.Meshing if (physicsParms == null) { - m_log.Warn("[MESH]: no recognized physics mesh found in mesh asset"); + m_log.WarnFormat("[MESH]: No recognized physics mesh found in mesh asset for {0}", primName); return false; } -- cgit v1.1