From 588361e2a2398b963871762c2b5485c6a086cf47 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Fri, 23 Oct 2009 01:02:36 -0700 Subject: Experimental change to use an immutable array for iterating ScenePresences, avoiding locking and copying the list each time it is accessed --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 69b3ded..4f19761 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1182,8 +1182,8 @@ namespace OpenSim.Region.Framework.Scenes { // part.Inventory.RemoveScriptInstances(); - List avatars = Scene.GetScenePresences(); - for (int i = 0; i < avatars.Count; i++) + ScenePresence[] avatars = Scene.GetScenePresences(); + for (int i = 0; i < avatars.Length; i++) { if (avatars[i].ParentID == LocalId) { -- cgit v1.1 From 62f1a5e36d85b95e8f80bc073ba876873494963a Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Fri, 23 Oct 2009 02:38:59 -0700 Subject: Implemented a "FrontBack" prioritizer, using distance plus the plane equation to give double weight to prims/avatars in front of you --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 33 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 4f19761..dd8da20 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -493,8 +493,8 @@ namespace OpenSim.Region.Framework.Scenes public Vector3 GroupScale() { - Vector3 minScale = new Vector3(Constants.RegionSize,Constants.RegionSize,Constants.RegionSize); - Vector3 maxScale = new Vector3(0f,0f,0f); + Vector3 minScale = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionSize); + Vector3 maxScale = Vector3.Zero; Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f); lock (m_parts) @@ -577,7 +577,6 @@ namespace OpenSim.Region.Framework.Scenes { foreach (SceneObjectPart part in m_parts.Values) { - Vector3 worldPos = part.GetWorldPosition(); Vector3 offset = worldPos - AbsolutePosition; Quaternion worldRot; @@ -3366,6 +3365,8 @@ namespace OpenSim.Region.Framework.Scenes return GetPriorityByDistance(client); case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance: return GetPriorityBySimpleAngularDistance(client); + case Scenes.Scene.UpdatePrioritizationSchemes.FrontBack: + return GetPriorityByFrontBack(client); default: throw new InvalidOperationException("UpdatePrioritizationScheme not defined"); } @@ -3398,6 +3399,16 @@ namespace OpenSim.Region.Framework.Scenes return double.NaN; } + private double GetPriorityByFrontBack(IClientAPI client) + { + ScenePresence presence = Scene.GetScenePresence(client.AgentId); + if (presence != null) + { + return GetPriorityByFrontBack(presence.CameraPosition, presence.CameraAtAxis); + } + return double.NaN; + } + public double GetPriorityByDistance(Vector3 position) { return Vector3.Distance(AbsolutePosition, position); @@ -3427,5 +3438,21 @@ namespace OpenSim.Region.Framework.Scenes else return double.MinValue; } + + public double GetPriorityByFrontBack(Vector3 camPosition, Vector3 camAtAxis) + { + // Distance + double priority = Vector3.Distance(camPosition, AbsolutePosition); + + // Scale + //priority -= GroupScale().Length(); + + // Plane equation + float d = -Vector3.Dot(camPosition, camAtAxis); + float p = Vector3.Dot(camAtAxis, AbsolutePosition) + d; + if (p < 0.0f) priority *= 2.0f; + + return priority; + } } } -- cgit v1.1 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/Framework/Scenes/SceneObjectGroup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index dd8da20..34ada4c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1334,7 +1334,7 @@ namespace OpenSim.Region.Framework.Scenes (parcel.LandData.GroupID != GroupID || parcel.LandData.GroupID == UUID.Zero)) { - if ((DateTime.Now - RootPart.Rezzed).TotalMinutes > + if ((DateTime.UtcNow - RootPart.Rezzed).TotalMinutes > parcel.LandData.OtherCleanTime) { DetachFromBackup(); -- 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 --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 26 ++++++++++------------ 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 34ada4c..38a0cff 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1479,8 +1479,8 @@ namespace OpenSim.Region.Framework.Scenes dupe.RootPart.PhysActor = m_scene.PhysicsScene.AddPrimShape( dupe.RootPart.Name, pbs, - new PhysicsVector(dupe.RootPart.AbsolutePosition.X, dupe.RootPart.AbsolutePosition.Y, dupe.RootPart.AbsolutePosition.Z), - new PhysicsVector(dupe.RootPart.Scale.X, dupe.RootPart.Scale.Y, dupe.RootPart.Scale.Z), + dupe.RootPart.AbsolutePosition, + dupe.RootPart.Scale, dupe.RootPart.RotationOffset, dupe.RootPart.PhysActor.IsPhysical); @@ -1595,7 +1595,7 @@ namespace OpenSim.Region.Framework.Scenes */ } - public void applyImpulse(PhysicsVector impulse) + public void applyImpulse(Vector3 impulse) { // We check if rootpart is null here because scripts don't delete if you delete the host. // This means that unfortunately, we can pass a null physics actor to Simulate! @@ -1622,7 +1622,7 @@ namespace OpenSim.Region.Framework.Scenes } } - public void applyAngularImpulse(PhysicsVector impulse) + public void applyAngularImpulse(Vector3 impulse) { // We check if rootpart is null here because scripts don't delete if you delete the host. // This means that unfortunately, we can pass a null physics actor to Simulate! @@ -1641,7 +1641,7 @@ namespace OpenSim.Region.Framework.Scenes } } - public void setAngularImpulse(PhysicsVector impulse) + public void setAngularImpulse(Vector3 impulse) { // We check if rootpart is null here because scripts don't delete if you delete the host. // This means that unfortunately, we can pass a null physics actor to Simulate! @@ -1672,8 +1672,8 @@ namespace OpenSim.Region.Framework.Scenes { if (!IsAttachment) { - PhysicsVector torque = rootpart.PhysActor.Torque; - return new Vector3(torque.X, torque.Y, torque.Z); + Vector3 torque = rootpart.PhysActor.Torque; + return torque; } } } @@ -1706,7 +1706,7 @@ namespace OpenSim.Region.Framework.Scenes { if (rootpart.PhysActor != null) { - rootpart.PhysActor.PIDTarget = new PhysicsVector(target.X, target.Y, target.Z); + rootpart.PhysActor.PIDTarget = target; rootpart.PhysActor.PIDTau = tau; rootpart.PhysActor.PIDActive = true; } @@ -2374,7 +2374,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_rootPart.PhysActor.IsPhysical) { Vector3 llmoveforce = pos - AbsolutePosition; - PhysicsVector grabforce = new PhysicsVector(llmoveforce.X, llmoveforce.Y, llmoveforce.Z); + Vector3 grabforce = llmoveforce; grabforce = (grabforce / 10) * m_rootPart.PhysActor.Mass; m_rootPart.PhysActor.AddForce(grabforce,true); m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); @@ -2479,7 +2479,7 @@ namespace OpenSim.Region.Framework.Scenes rotationAxis.Normalize(); //m_log.Error("SCENE OBJECT GROUP]: rotation axis is " + rotationAxis); - PhysicsVector spinforce = new PhysicsVector(rotationAxis.X, rotationAxis.Y, rotationAxis.Z); + Vector3 spinforce = new Vector3(rotationAxis.X, rotationAxis.Y, rotationAxis.Z); spinforce = (spinforce/8) * m_rootPart.PhysActor.Mass; // 8 is an arbitrary torque scaling factor m_rootPart.PhysActor.AddAngularForce(spinforce,true); m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); @@ -2706,8 +2706,7 @@ namespace OpenSim.Region.Framework.Scenes if (scale.Z > m_scene.m_maxPhys) scale.Z = m_scene.m_maxPhys; } - part.PhysActor.Size = - new PhysicsVector(scale.X, scale.Y, scale.Z); + part.PhysActor.Size = scale; m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); } //if (part.UUID != m_rootPart.UUID) @@ -2851,8 +2850,7 @@ namespace OpenSim.Region.Framework.Scenes if (part.PhysActor != null) { - part.PhysActor.Size = - new PhysicsVector(prevScale.X, prevScale.Y, prevScale.Z); + part.PhysActor.Size = prevScale; m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); } -- cgit v1.1