From 96c191f4fdbd64009fc210b8c911c832723bb10e Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 3 Dec 2011 00:09:18 +0000 Subject: [PATCH 1/5] Stop SP.HandleAgentUpdate() and PhysicsCollisionUpdate() from being processed if we're dealing with a child ScenePresence. Neither of these can have any effect on child agents Now leaving warning about trying to set animation on a child agent active. Might temporarily pop up now and again. --- .../Scenes/Animation/ScenePresenceAnimator.cs | 14 ++++++-------- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 11 +++++++---- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 6b1208cbb0..a2805d20bc 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -158,14 +158,12 @@ namespace OpenSim.Region.Framework.Scenes.Animation SendAnimPack(); } } - // Don't leave this on since on teleports SP.HandleAgentUpdate() still hammers us for a while after it teleports -// else -// { -// m_log.WarnFormat( -// "[SCENE PRESENCE ANIMATOR]: Tried to set movement animation {0} on child presence {1}", -// anim, m_scenePresence.Name); -// throw new Exception(string.Format("aaargh on setting {0}", anim)); -// } + else + { + m_log.WarnFormat( + "[SCENE PRESENCE ANIMATOR]: Tried to set movement animation {0} on child presence {1}", + anim, m_scenePresence.Name); + } } /// diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b93b67de45..c517978ded 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1293,11 +1293,11 @@ namespace OpenSim.Region.Framework.Scenes // "[SCENE PRESENCE]: In {0} received agent update from {1}", // Scene.RegionInfo.RegionName, remoteClient.Name); - //if (IsChildAgent) - //{ + if (IsChildAgent) + { // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent"); - // return; - //} + return; + } ++m_movementUpdateCount; if (m_movementUpdateCount < 1) @@ -3280,6 +3280,9 @@ namespace OpenSim.Region.Framework.Scenes // Event called by the physics plugin to tell the avatar about a collision. private void PhysicsCollisionUpdate(EventArgs e) { + if (IsChildAgent) + return; + //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) // The Physics Scene will send updates every 500 ms grep: PhysicsActor.SubscribeEvents( // as of this comment the interval is set in AddToPhysicalScene From 5ba8ca5662efb9c4f595e9a703535661d72e5b2f Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 3 Dec 2011 00:27:21 +0000 Subject: [PATCH 2/5] Rename ScenePresenceAnimator.GetMovementAnimation() -> DetermineMovementAnimation() for better code readability --- .../Scenes/Animation/ScenePresenceAnimator.cs | 11 ++++++++--- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index a2805d20bc..cac936ce63 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -59,6 +59,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation get { return m_movementAnimation; } } protected string m_movementAnimation = "CROUCH"; + private int m_animTickFall; public int m_animTickJump; // ScenePresence has to see this to control +Z force public bool m_jumping = false; @@ -146,6 +147,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation { if (!m_scenePresence.IsChildAgent) { +// m_log.DebugFormat( +// "[SCENE PRESENCE ANIMATOR]: Setting movement animation {0} for {1}", +// anim, m_scenePresence.Name); + if (m_animations.TrySetDefaultAnimation( anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID)) { @@ -169,7 +174,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation /// /// This method determines the proper movement related animation /// - public string GetMovementAnimation() + public string DetermineMovementAnimation() { const float FALL_DELAY = 800f; const float PREJUMP_DELAY = 200f; @@ -283,7 +288,6 @@ namespace OpenSim.Region.Framework.Scenes.Animation int jumptime; jumptime = Environment.TickCount - m_animTickJump; - if ((move.Z > 0f) && (!m_jumping)) { // Start jumping, prejump @@ -387,6 +391,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation #endregion Ground Movement m_falling = false; + return m_movementAnimation; } @@ -395,7 +400,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation /// public void UpdateMovementAnimations() { - m_movementAnimation = GetMovementAnimation(); + m_movementAnimation = DetermineMovementAnimation(); TrySetMovementAnimation(m_movementAnimation); } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 6c54c9beb1..2812683f6d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -5554,7 +5554,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api flags |= ScriptBaseClass.AGENT_TYPING; } - string agentMovementAnimation = agent.Animator.GetMovementAnimation(); + string agentMovementAnimation = agent.Animator.DetermineMovementAnimation(); if (agentMovementAnimation == "CROUCH") { From 8185ce8b4afab459655f5cd362b2c6bbb98c28c3 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 3 Dec 2011 00:30:13 +0000 Subject: [PATCH 3/5] Do a cagent.Anims != null check in SP.CopyFrom() --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c517978ded..7156137aad 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3195,7 +3195,9 @@ namespace OpenSim.Region.Framework.Scenes } catch { } - Animator.Animations.FromArray(cAgent.Anims); + // FIXME: Why is this null check necessary? Where are the cases where we get a null Anims object? + if (cAgent.Anims != null) + Animator.Animations.FromArray(cAgent.Anims); if (cAgent.AttachmentObjects != null && cAgent.AttachmentObjects.Count > 0) { From 5bbfb082ddf963037bf291caa9327ef9c7eff3e9 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 3 Dec 2011 00:33:24 +0000 Subject: [PATCH 4/5] Use agent.Animator.CurrentMovementAnimation in llGetAgentInfo() rather than asking for a new determination --- .../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 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 2812683f6d..6c418df6ad 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -5554,7 +5554,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api flags |= ScriptBaseClass.AGENT_TYPING; } - string agentMovementAnimation = agent.Animator.DetermineMovementAnimation(); + string agentMovementAnimation = agent.Animator.CurrentMovementAnimation; if (agentMovementAnimation == "CROUCH") { From 0ca8491bbeab74e4cb50521d4857104c7e0a59b9 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 3 Dec 2011 00:40:08 +0000 Subject: [PATCH 5/5] refactor: Use just ScenePresenceAnimator.CurrentMovementAnimation rather than duplicating it with m_movementAnimation --- .../Scenes/Animation/ScenePresenceAnimator.cs | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index cac936ce63..2a6b8eaed2 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -54,11 +54,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation /// /// The current movement animation /// - public string CurrentMovementAnimation - { - get { return m_movementAnimation; } - } - protected string m_movementAnimation = "CROUCH"; + public string CurrentMovementAnimation { get; private set; } private int m_animTickFall; public int m_animTickJump; // ScenePresence has to see this to control +Z force @@ -80,6 +76,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation public ScenePresenceAnimator(ScenePresence sp) { m_scenePresence = sp; + CurrentMovementAnimation = "CROUCH"; } public void AddAnimation(UUID animID, UUID objectID) @@ -174,7 +171,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation /// /// This method determines the proper movement related animation /// - public string DetermineMovementAnimation() + private string DetermineMovementAnimation() { const float FALL_DELAY = 800f; const float PREJUMP_DELAY = 200f; @@ -277,7 +274,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation return "FALLDOWN"; } - return m_movementAnimation; + return CurrentMovementAnimation; } #endregion Falling/Floating/Landing @@ -331,7 +328,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation #region Ground Movement - if (m_movementAnimation == "FALLDOWN") + if (CurrentMovementAnimation == "FALLDOWN") { m_falling = false; m_animTickFall = Environment.TickCount; @@ -344,16 +341,17 @@ namespace OpenSim.Region.Framework.Scenes.Animation else return "LAND"; } - else if ((m_movementAnimation == "LAND") || (m_movementAnimation == "SOFT_LAND") || (m_movementAnimation == "STANDUP")) + else if ((CurrentMovementAnimation == "LAND") || (CurrentMovementAnimation == "SOFT_LAND") || (CurrentMovementAnimation == "STANDUP")) { int landElapsed = Environment.TickCount - m_animTickFall; int limit = 1000; - if(m_movementAnimation == "LAND") limit = 350; + if (CurrentMovementAnimation == "LAND") + limit = 350; // NB if the above is set too long a weird anim reset from some place prevents STAND from being sent to client if ((m_animTickFall != 0) && (landElapsed <= limit)) { - return m_movementAnimation; + return CurrentMovementAnimation; } else { @@ -392,7 +390,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation m_falling = false; - return m_movementAnimation; + return CurrentMovementAnimation; } /// @@ -400,8 +398,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation /// public void UpdateMovementAnimations() { - m_movementAnimation = DetermineMovementAnimation(); - TrySetMovementAnimation(m_movementAnimation); + CurrentMovementAnimation = DetermineMovementAnimation(); + TrySetMovementAnimation(CurrentMovementAnimation); } public UUID[] GetAnimationArray()