From c2f3ff872dd88b4382b41844a4faa632129d1760 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Mon, 23 Feb 2009 06:55:42 +0000 Subject: * Performance Changes: * Moves Entity Updates into a seperate thread, allowing for OpenSim to utilize a computers CPU more effectively in return for potentially greater user and prim capacity. * Removes an expensive Sqrt call performed during Update on each object. This should lower CPU requirements for high-prim regions with physics enabled. * MXP Changes: Centers the region around 0,0 for primitives instead of 128,128. Prim display should now look more correct for MXP viewers. --- OpenSim/Region/Framework/Scenes/Scene.cs | 16 +++++++++++++++- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 4 ++-- 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 2a3f068..8d81812 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -64,6 +64,8 @@ namespace OpenSim.Region.Framework.Scenes protected Timer m_restartWaitTimer = new Timer(); + protected Thread m_updateEntitiesThread; + public SimStatsReporter StatsReporter; protected List m_regionRestartNotifyList = new List(); @@ -852,7 +854,19 @@ namespace OpenSim.Region.Framework.Scenes otherMS = Environment.TickCount; // run through all entities looking for updates (slow) if (m_frame % m_update_entities == 0) - m_sceneGraph.UpdateEntities(); + { + if (m_updateEntitiesThread == null) + { + m_updateEntitiesThread = new Thread(m_sceneGraph.UpdateEntities); + ThreadTracker.Add(m_updateEntitiesThread); + } + + if(!m_updateEntitiesThread.IsAlive) + m_updateEntitiesThread.Start(); + + //m_sceneGraph.UpdateEntities(); + } + // run through entities that have scheduled themselves for // updates looking for updates(faster) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index d1aef1c..2ca0342 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1733,12 +1733,12 @@ namespace OpenSim.Region.Framework.Scenes //return; //} - if ((Util.GetDistanceTo(lastPhysGroupPos, AbsolutePosition) > 0.02) && UsePhysics) + if (Util.DistanceLessThan(lastPhysGroupPos, AbsolutePosition, 0.02) && UsePhysics) { m_rootPart.UpdateFlag = 1; lastPhysGroupPos = AbsolutePosition; } - //foreach (SceneObjectPart part in m_parts.Values) + //foreach (SceneObjectPart part in m_parts.Values) //{ //if (part.UpdateFlag == 0) part.UpdateFlag = 1; //} -- cgit v1.1