From 756d53db5e9c7a2ac73e501b7883381026f3c608 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 11 Jan 2013 13:39:14 +0000 Subject: [PATCH 1/7] keyframe. Don't use group UpdateRotation since this enqueues a terse update and we are sending them imediatly --- OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index edf2befc0d..995060b8b0 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -544,8 +544,10 @@ namespace OpenSim.Region.Framework.Scenes m_nextPosition = (Vector3)m_currentFrame.Position; m_group.AbsolutePosition = m_nextPosition; - m_group.UpdateGroupRotationR((Quaternion)m_currentFrame.Rotation); + // we are sending imediate updates, no doing force a extra terseUpdate +// m_group.UpdateGroupRotationR((Quaternion)m_currentFrame.Rotation); + m_group.RootPart.RotationOffset = (Quaternion)m_currentFrame.Rotation; m_frames.RemoveAt(0); if (m_frames.Count > 0) m_currentFrame = m_frames[0]; @@ -613,7 +615,9 @@ namespace OpenSim.Region.Framework.Scenes // assuming w is a dependente var { - m_group.UpdateGroupRotationR(step); +// m_group.UpdateGroupRotationR(step); + m_group.RootPart.RotationOffset = step; + //m_group.RootPart.UpdateAngularVelocity(m_currentFrame.AngularVelocity / 2); update = true; } From 1f9dbdf8b8d8c70e654199c5f9a4258e0e6693f9 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 11 Jan 2013 14:16:45 +0000 Subject: [PATCH 2/7] same for AngularVelocity. Use normal terse updates in place of sending imediatly. If that's good for physics, needs to be good for this --- .../Region/Framework/Scenes/KeyframeMotion.cs | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 995060b8b0..43f46d10c2 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -345,9 +345,9 @@ namespace OpenSim.Region.Framework.Scenes m_baseRotation = m_group.GroupRotation; m_group.RootPart.Velocity = Vector3.Zero; - m_group.RootPart.UpdateAngularVelocity(Vector3.Zero); - m_group.SendGroupRootTerseUpdate(); - + m_group.RootPart.AngularVelocity = Vector3.Zero; +// m_group.SendGroupRootTerseUpdate(); + m_group.RootPart.ScheduleTerseUpdate(); m_frames.Clear(); } @@ -357,8 +357,10 @@ namespace OpenSim.Region.Framework.Scenes RemoveTimer(); m_group.RootPart.Velocity = Vector3.Zero; - m_group.RootPart.UpdateAngularVelocity(Vector3.Zero); - m_group.SendGroupRootTerseUpdate(); + m_group.RootPart.AngularVelocity = Vector3.Zero; +// m_group.SendGroupRootTerseUpdate(); + m_group.RootPart.ScheduleTerseUpdate(); + } private void GetNextList() @@ -489,7 +491,9 @@ namespace OpenSim.Region.Framework.Scenes if (m_group.RootPart.Velocity != Vector3.Zero) { m_group.RootPart.Velocity = Vector3.Zero; - m_group.SendGroupRootTerseUpdate(); +// m_group.SendGroupRootTerseUpdate(); + m_group.RootPart.ScheduleTerseUpdate(); + } m_inOnTimer = false; return; @@ -539,7 +543,7 @@ namespace OpenSim.Region.Framework.Scenes if (steps <= 0.0) { m_group.RootPart.Velocity = Vector3.Zero; - m_group.RootPart.UpdateAngularVelocity(Vector3.Zero); + m_group.RootPart.AngularVelocity = Vector3.Zero; m_nextPosition = (Vector3)m_currentFrame.Position; m_group.AbsolutePosition = m_nextPosition; @@ -625,7 +629,9 @@ namespace OpenSim.Region.Framework.Scenes } if (update) - m_group.SendGroupRootTerseUpdate(); +// m_group.SendGroupRootTerseUpdate(); + m_group.RootPart.ScheduleTerseUpdate(); + } catch ( Exception ex) @@ -675,7 +681,8 @@ namespace OpenSim.Region.Framework.Scenes if (m_group.RootPart.Velocity != Vector3.Zero) { m_group.RootPart.Velocity = Vector3.Zero; - m_group.SendGroupRootTerseUpdate(); +// m_group.SendGroupRootTerseUpdate(); + m_group.RootPart.ScheduleTerseUpdate(); } } @@ -686,7 +693,8 @@ namespace OpenSim.Region.Framework.Scenes if (m_group != null) { m_group.RootPart.Velocity = Vector3.Zero; - m_group.SendGroupRootTerseUpdate(); +// m_group.SendGroupRootTerseUpdate(); + m_group.RootPart.ScheduleTerseUpdate(); if (m_running && m_timer != null) { From 819f4b338d7c998a6e93b4558d6bd005a097904d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 11 Jan 2013 16:02:14 +0000 Subject: [PATCH 3/7] remove redundant lastPhysGroupPos and lastPhysGroupRot checks in SOG Update(). rootpart does more complet checks --- .../Framework/Scenes/SceneObjectGroup.cs | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 4ad8b11098..b008e6698d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -307,9 +307,6 @@ namespace OpenSim.Region.Framework.Scenes get { return RootPart.VolumeDetectActive; } } - private Vector3 lastPhysGroupPos; - private Quaternion lastPhysGroupRot; - private bool m_isBackedUp; public bool IsBackedUp @@ -2525,6 +2522,7 @@ namespace OpenSim.Region.Framework.Scenes #endregion + public override void Update() { // Check that the group was not deleted before the scheduled update @@ -2543,19 +2541,8 @@ namespace OpenSim.Region.Framework.Scenes // check to see if the physical position or rotation warrant an update. if (m_rootPart.UpdateFlag == UpdateRequired.NONE) { - bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); - - if (UsePhysics && !AbsolutePosition.ApproxEquals(lastPhysGroupPos, 0.02f)) - { - m_rootPart.UpdateFlag = UpdateRequired.TERSE; - lastPhysGroupPos = AbsolutePosition; - } - - if (UsePhysics && !GroupRotation.ApproxEquals(lastPhysGroupRot, 0.1f)) - { - m_rootPart.UpdateFlag = UpdateRequired.TERSE; - lastPhysGroupRot = GroupRotation; - } + // rootpart SendScheduledUpdates will check if a update is needed + m_rootPart.UpdateFlag = UpdateRequired.TERSE; } SceneObjectPart[] parts = m_parts.GetArray(); From d7f0bf04f6b69d7ea616f02d3f7f4381debda00e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 11 Jan 2013 16:24:48 +0000 Subject: [PATCH 4/7] update the last information sent in terse updates where they are sent to all clients and not only on Scheduled sends --- .../Framework/Scenes/SceneObjectPart.cs | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 2191cfa4d4..ff4ae85f1f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -144,7 +144,7 @@ namespace OpenSim.Region.Framework.Scenes /// public bool IsRoot { - get { return ParentGroup.RootPart == this; } + get { return Object.ReferenceEquals(ParentGroup.RootPart, this); } } /// @@ -319,7 +319,7 @@ namespace OpenSim.Region.Framework.Scenes protected Vector3 m_lastVelocity; protected Vector3 m_lastAcceleration; protected Vector3 m_lastAngularVelocity; - protected int m_lastTerseSent; + protected int m_lastUpdateSentTime; protected float m_buoyancy = 0.0f; protected Vector3 m_force; protected Vector3 m_torque; @@ -3198,6 +3198,14 @@ namespace OpenSim.Region.Framework.Scenes if (ParentGroup == null) return; + // Update the "last" values + m_lastPosition = OffsetPosition; + m_lastRotation = RotationOffset; + m_lastVelocity = Velocity; + m_lastAcceleration = Acceleration; + m_lastAngularVelocity = AngularVelocity; + m_lastUpdateSentTime = Environment.TickCount; + ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) { SendFullUpdate(avatar.ControllingClient); @@ -3271,17 +3279,10 @@ namespace OpenSim.Region.Framework.Scenes Velocity.ApproxEquals(Vector3.Zero, VELOCITY_TOLERANCE) || !AngularVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) || !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || - Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) + Environment.TickCount - m_lastUpdateSentTime > TIME_MS_TOLERANCE) { SendTerseUpdateToAllClients(); - // Update the "last" values - m_lastPosition = OffsetPosition; - m_lastRotation = RotationOffset; - m_lastVelocity = Velocity; - m_lastAcceleration = Acceleration; - m_lastAngularVelocity = AngularVelocity; - m_lastTerseSent = Environment.TickCount; } break; } @@ -3302,6 +3303,14 @@ namespace OpenSim.Region.Framework.Scenes if (ParentGroup == null || ParentGroup.Scene == null) return; + // Update the "last" values + m_lastPosition = OffsetPosition; + m_lastRotation = RotationOffset; + m_lastVelocity = Velocity; + m_lastAcceleration = Acceleration; + m_lastAngularVelocity = AngularVelocity; + m_lastUpdateSentTime = Environment.TickCount; + ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) { SendTerseUpdateToClient(client); From a892dbba63fe85e36d242e5f7dc41bc37aaafc9e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 11 Jan 2013 18:18:22 +0000 Subject: [PATCH 5/7] go back bypassing sog updates control (test) --- .../Region/Framework/Scenes/KeyframeMotion.cs | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 43f46d10c2..5cfba39452 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs @@ -346,8 +346,8 @@ namespace OpenSim.Region.Framework.Scenes m_group.RootPart.Velocity = Vector3.Zero; m_group.RootPart.AngularVelocity = Vector3.Zero; -// m_group.SendGroupRootTerseUpdate(); - m_group.RootPart.ScheduleTerseUpdate(); + m_group.SendGroupRootTerseUpdate(); +// m_group.RootPart.ScheduleTerseUpdate(); m_frames.Clear(); } @@ -358,8 +358,8 @@ namespace OpenSim.Region.Framework.Scenes m_group.RootPart.Velocity = Vector3.Zero; m_group.RootPart.AngularVelocity = Vector3.Zero; -// m_group.SendGroupRootTerseUpdate(); - m_group.RootPart.ScheduleTerseUpdate(); + m_group.SendGroupRootTerseUpdate(); +// m_group.RootPart.ScheduleTerseUpdate(); } @@ -491,8 +491,8 @@ namespace OpenSim.Region.Framework.Scenes if (m_group.RootPart.Velocity != Vector3.Zero) { m_group.RootPart.Velocity = Vector3.Zero; -// m_group.SendGroupRootTerseUpdate(); - m_group.RootPart.ScheduleTerseUpdate(); + m_group.SendGroupRootTerseUpdate(); +// m_group.RootPart.ScheduleTerseUpdate(); } m_inOnTimer = false; @@ -629,8 +629,8 @@ namespace OpenSim.Region.Framework.Scenes } if (update) -// m_group.SendGroupRootTerseUpdate(); - m_group.RootPart.ScheduleTerseUpdate(); + m_group.SendGroupRootTerseUpdate(); +// m_group.RootPart.ScheduleTerseUpdate(); } @@ -681,8 +681,8 @@ namespace OpenSim.Region.Framework.Scenes if (m_group.RootPart.Velocity != Vector3.Zero) { m_group.RootPart.Velocity = Vector3.Zero; -// m_group.SendGroupRootTerseUpdate(); - m_group.RootPart.ScheduleTerseUpdate(); + m_group.SendGroupRootTerseUpdate(); +// m_group.RootPart.ScheduleTerseUpdate(); } } @@ -693,8 +693,8 @@ namespace OpenSim.Region.Framework.Scenes if (m_group != null) { m_group.RootPart.Velocity = Vector3.Zero; -// m_group.SendGroupRootTerseUpdate(); - m_group.RootPart.ScheduleTerseUpdate(); + m_group.SendGroupRootTerseUpdate(); +// m_group.RootPart.ScheduleTerseUpdate(); if (m_running && m_timer != null) { From fcf39601687b30f088903faaa12d2b4aaa18bf1a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 11 Jan 2013 20:25:12 +0000 Subject: [PATCH 6/7] make sure keyframe rotations are normalized --- .../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 0dfcfd6166..1e1e574698 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -12691,7 +12691,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if ((data & KeyframeMotion.DataFormat.Rotation) != 0) { LSL_Types.Quaternion tempq = frames.GetQuaternionItem(idx++); - frame.Rotation = new Quaternion((float)tempq.x, (float)tempq.y, (float)tempq.z, (float)tempq.s); + Quaternion q = new Quaternion((float)tempq.x, (float)tempq.y, (float)tempq.z, (float)tempq.s); + q.Normalize(); + frame.Rotation = q; } float tempf = (float)frames.GetLSLFloatItem(idx++); From 2eb0d8b6176c223e915a2d22b1c9540156283943 Mon Sep 17 00:00:00 2001 From: dahlia Date: Thu, 10 Jan 2013 20:21:18 -0800 Subject: [PATCH 7/7] add some sanity checking to HandleAgentRequestSit handler --- .../Region/ClientStack/Linden/UDP/LLClientView.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index d46adb8863..0a865abcc8 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -6601,8 +6601,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP AgentRequestSit handlerAgentRequestSit = OnAgentRequestSit; if (handlerAgentRequestSit != null) - handlerAgentRequestSit(this, agentRequestSit.AgentData.AgentID, - agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset); + if (!(agentRequestSit.AgentData == null + || agentRequestSit.TargetObject == null + || agentRequestSit.TargetObject.TargetID == null + || agentRequestSit.TargetObject.Offset == null)) + { + var sp = m_scene.GetScenePresence(agentRequestSit.AgentData.AgentID); + if (sp == null || sp.ParentID != 0) // ignore packet if agent is already sitting + return true; + + handlerAgentRequestSit(this, agentRequestSit.AgentData.AgentID, + agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset); + } } return true; }