From a65c8cdc38f40a54ad4a14ed2e6168fb432c6e51 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Wed, 28 Oct 2009 12:45:40 -0700 Subject: [PATCH] * Reduce the velocity tolerance on sending terse updates to avoid slowly drifting prims/avatars * Added contacts_per_collision to the ODE config section. This allows you to reduce the maximum number of contact points ODE will generate per collision and reduce the size of the array that stores contact structures --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 13 ++++++++++--- bin/OpenSim.ini.example | 3 +++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index e1588ceebc..a99a8026d3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2394,7 +2394,7 @@ if (m_shape != null) { /// public void SendScheduledUpdates() { - const float VELOCITY_TOLERANCE = 0.01f; + const float VELOCITY_TOLERANCE = 0.0001f; const float POSITION_TOLERANCE = 0.1f; const int TIME_MS_TOLERANCE = 3000; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 92f00c44b4..9ba19d3d73 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2362,7 +2362,7 @@ namespace OpenSim.Region.Framework.Scenes public override void Update() { - const float VELOCITY_TOLERANCE = 0.01f; + const float VELOCITY_TOLERANCE = 0.0001f; const float POSITION_TOLERANCE = 10.0f; const int TIME_MS_TOLERANCE = 3000; diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 8382233dd8..6ca415b70b 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -178,8 +178,8 @@ namespace OpenSim.Region.Physics.OdePlugin //private int m_returncollisions = 10; private readonly IntPtr contactgroup; - internal IntPtr LandGeom; + internal IntPtr LandGeom; internal IntPtr WaterGeom; private float nmTerrainContactFriction = 255.0f; @@ -251,7 +251,7 @@ namespace OpenSim.Region.Physics.OdePlugin private bool m_NINJA_physics_joints_enabled = false; //private Dictionary jointpart_name_map = new Dictionary(); private readonly Dictionary> joints_connecting_actor = new Dictionary>(); - private d.ContactGeom[] contacts = new d.ContactGeom[80]; + private d.ContactGeom[] contacts; private readonly List requestedJointsToBeCreated = new List(); // lock only briefly. accessed by external code (to request new joints) and by OdeScene.Simulate() to move those joints into pending/active private readonly List pendingJoints = new List(); // can lock for longer. accessed only by OdeScene. private readonly List activeJoints = new List(); // can lock for longer. accessed only by OdeScene. @@ -397,6 +397,8 @@ namespace OpenSim.Region.Physics.OdePlugin avStandupTensor = 550000f; } + int contactsPerCollision = 80; + if (m_config != null) { IConfig physicsconfig = m_config.Configs["ODEPhysicsSettings"]; @@ -439,6 +441,8 @@ namespace OpenSim.Region.Physics.OdePlugin avCapRadius = physicsconfig.GetFloat("av_capsule_radius", 0.37f); avCapsuleTilted = physicsconfig.GetBoolean("av_capsule_tilted", true); + contactsPerCollision = physicsconfig.GetInt("contacts_per_collision", 80); + geomContactPointsStartthrottle = physicsconfig.GetInt("geom_contactpoints_start_throttling", 3); geomUpdatesPerThrottledUpdate = physicsconfig.GetInt("geom_updates_before_throttled_update", 15); geomCrossingFailuresBeforeOutofbounds = physicsconfig.GetInt("geom_crossing_failures_before_outofbounds", 5); @@ -476,10 +480,11 @@ namespace OpenSim.Region.Physics.OdePlugin m_NINJA_physics_joints_enabled = physicsconfig.GetBoolean("use_NINJA_physics_joints", false); minimumGroundFlightOffset = physicsconfig.GetFloat("minimum_ground_flight_offset", 3f); - } } + contacts = new d.ContactGeom[contactsPerCollision]; + staticPrimspace = new IntPtr[(int)(300 / metersInSpace), (int)(300 / metersInSpace)]; // Centeral contact friction and bounce @@ -773,6 +778,8 @@ namespace OpenSim.Region.Physics.OdePlugin lock (contacts) { count = d.Collide(g1, g2, contacts.Length, contacts, d.ContactGeom.SizeOf); + if (count > contacts.Length) + m_log.Error("[PHYSICS]: Got " + count + " contacts when we asked for a maximum of " + contacts.Length); } } catch (SEHException) diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 43e6c85028..63a9e117f1 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example @@ -577,6 +577,9 @@ ; used to control llMove2Target body_pid_derivative = 35 body_pid_gain = 25 + + ; maximum number of contact points to generate per collision + contacts_per_collision = 80 ; amount of time a geom/body will try to cross a region border before it gets disabled geom_crossing_failures_before_outofbounds = 5