diff --git a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs index 27bf078214..d9c40774b0 100644 --- a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs +++ b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs @@ -577,7 +577,9 @@ namespace OpenSim.Client.MXP.ClientStack pe.ObjectFragment.AngularAcceleration = new float[4]; pe.ObjectFragment.AngularVelocity = new float[] { rvel.X, rvel.Y, rvel.Z, 0.0f }; pe.ObjectFragment.BoundingSphereRadius = primShape.Scale.Length()/2.0f; - pe.ObjectFragment.Location = new float[] { pos.X, pos.Y, pos.Z }; + + pe.ObjectFragment.Location = new float[] { pos.X - 120.0f, pos.Z, pos.Y - 128.0f }; + pe.ObjectFragment.Mass = 1.0f; pe.ObjectFragment.ObjectId = objectID.Guid; pe.ObjectFragment.Orientation = new float[] { rotation.X, rotation.Y, rotation.Z, rotation.W }; diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 27180729de..4fce4ac4d6 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -88,6 +88,21 @@ namespace OpenSim.Framework return Math.Sqrt(dx * dx + dy * dy + dz * dz); } + /// + /// Returns true if the distance beween A and B is less than amount. Significantly faster than GetDistanceTo since it eliminates the Sqrt. + /// + /// + /// + /// + /// + public static bool DistanceLessThan(Vector3 a, Vector3 b, double amount) + { + float dx = a.X - b.X; + float dy = a.Y - b.Y; + float dz = a.Z - b.Z; + return (dx*dx + dy*dy + dz*dz) < (amount*amount); + } + /// /// Get the magnitude of a 3d vector /// diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 2a3f068b5c..8d81812eea 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 d1aef1c29a..2ca0342fe4 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; //}