From 36d146bf272f33eb54de80579b163f27f2703fd4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 26 Nov 2013 00:43:35 +0000 Subject: fix position changes when sitting on a prim with position and/or orientation explicitly specified --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 31 +++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7a1017f..42a9b4d 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2267,7 +2267,6 @@ namespace OpenSim.Region.Framework.Scenes m_sitAvatarHeight = PhysicsActor.Size.Z; bool canSit = false; - Vector3 pos = part.AbsolutePosition + offset; if (part.IsSitTargetSet && part.SitTargetAvatar == UUID.Zero) { @@ -2277,10 +2276,24 @@ namespace OpenSim.Region.Framework.Scenes offset = part.SitTargetPosition; sitOrientation = part.SitTargetOrientation; + +// m_log.DebugFormat("Old sit orient {0}", sitOrientation); + if (part.IsRoot) + sitOrientation = sitOrientation; + else + sitOrientation = part.RotationOffset * sitOrientation; +// m_log.DebugFormat("New sit orient {0}", sitOrientation); + +// m_log.DebugFormat("Old sit offset {0}", offset); + offset = offset * sitOrientation; +// m_log.DebugFormat("New sit offset {0}", offset); + canSit = true; } else { + Vector3 pos = part.AbsolutePosition + offset; + if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) { // m_log.DebugFormat( @@ -2590,8 +2603,20 @@ namespace OpenSim.Region.Framework.Scenes //Quaternion result = (sitTargetOrient * vq) * nq; - m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT + part.OffsetPosition; - Rotation = part.RotationOffset * sitTargetOrient; + Vector3 newPos = sitTargetPos + SIT_TARGET_ADJUSTMENT; + + if (part.IsRoot) + Rotation = sitTargetOrient; + else + Rotation = part.RotationOffset * sitTargetOrient; + +// m_log.DebugFormat("Old offset2 {0}", newPos); + newPos = newPos * Rotation; +// m_log.DebugFormat("New offset2 {0}", newPos); + + newPos += part.OffsetPosition; + + m_pos = newPos; ParentPosition = part.AbsolutePosition; } else -- cgit v1.1 From a3c72dafe6459f20297a937bb4bca3dc00a24c9f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 26 Nov 2013 01:40:55 +0000 Subject: Only translate linked prim specified offset pos by the link prim rotation, not any specified avatar rotation as well. Don't translate root prim position by avatar rotation. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 28 +++++++++++++----------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 42a9b4d..a73d140 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2277,16 +2277,15 @@ namespace OpenSim.Region.Framework.Scenes offset = part.SitTargetPosition; sitOrientation = part.SitTargetOrientation; -// m_log.DebugFormat("Old sit orient {0}", sitOrientation); - if (part.IsRoot) - sitOrientation = sitOrientation; - else + if (!part.IsRoot) + { + // m_log.DebugFormat("Old sit orient {0}", sitOrientation); sitOrientation = part.RotationOffset * sitOrientation; -// m_log.DebugFormat("New sit orient {0}", sitOrientation); - + // m_log.DebugFormat("New sit orient {0}", sitOrientation); // m_log.DebugFormat("Old sit offset {0}", offset); - offset = offset * sitOrientation; + offset = offset * part.RotationOffset; // m_log.DebugFormat("New sit offset {0}", offset); + } canSit = true; } @@ -2604,19 +2603,22 @@ namespace OpenSim.Region.Framework.Scenes //Quaternion result = (sitTargetOrient * vq) * nq; Vector3 newPos = sitTargetPos + SIT_TARGET_ADJUSTMENT; + Quaternion newRot; if (part.IsRoot) - Rotation = sitTargetOrient; + { + newRot = sitTargetOrient; + } else - Rotation = part.RotationOffset * sitTargetOrient; - -// m_log.DebugFormat("Old offset2 {0}", newPos); - newPos = newPos * Rotation; -// m_log.DebugFormat("New offset2 {0}", newPos); + { + newPos = newPos * part.RotationOffset; + newRot = part.RotationOffset * sitTargetOrient; + } newPos += part.OffsetPosition; m_pos = newPos; + Rotation = newRot; ParentPosition = part.AbsolutePosition; } else -- cgit v1.1 From 0785210e29c75b09084321dca0569c9e4b73f858 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 27 Nov 2013 02:08:22 +0000 Subject: Fix stand positions rather than having the stand jump to the root prim. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 56 +++++++++++++++++++++--- 1 file changed, 49 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a73d140..f9b598f 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -499,6 +499,7 @@ namespace OpenSim.Region.Framework.Scenes } else { +// m_log.DebugFormat("[SCENE PRESENCE]: Fetching abs pos where PhysicsActor == null and parent part {0} for {1}", Name, Scene.Name); // Obtain the correct position of a seated avatar. // In addition to providing the correct position while // the avatar is seated, this value will also @@ -515,14 +516,14 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart sitPart = ParentPart; if (sitPart != null) - return sitPart.AbsolutePosition + (m_pos * sitPart.GetWorldRotation()); + return sitPart.AbsolutePosition; } return m_pos; } set { -// m_log.DebugFormat("[SCENE PRESENCE]: Setting position of {0} in {1} to {2}", Name, Scene.Name, value); +// m_log.DebugFormat("[SCENE PRESENCE]: Setting position of {0} to {1} in {2}", Name, value, Scene.Name); // Util.PrintCallStack(); if (PhysicsActor != null) @@ -2174,8 +2175,6 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); SitGround = false; - if (PhysicsActor == null) - AddToPhysicalScene(false); if (ParentID != 0) { @@ -2198,11 +2197,53 @@ namespace OpenSim.Region.Framework.Scenes ParentPosition = part.GetWorldPosition(); ControllingClient.SendClearFollowCamProperties(part.ParentUUID); - m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); - ParentPosition = Vector3.Zero; - ParentID = 0; ParentPart = null; + + Quaternion standRotation; + + if (part.SitTargetAvatar == UUID) + { + standRotation = part.GetWorldRotation(); + + if (!part.IsRoot) + standRotation = standRotation * part.SitTargetOrientation; +// standRotation = part.RotationOffset * part.SitTargetOrientation; +// else +// standRotation = part.SitTargetOrientation; + + } + else + { + standRotation = Rotation; + } + + //Vector3 standPos = ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); + //Vector3 standPos = ParentPosition; + +// Vector3 standPositionAdjustment +// = part.SitTargetPosition + new Vector3(0.5f, 0f, m_sitAvatarHeight / 2f); + Vector3 adjustmentForSitPosition = part.SitTargetPosition * part.GetWorldRotation(); + + // XXX: This is based on the physics capsule sizes. Need to find a better way to read this rather than + // hardcoding here. + Vector3 adjustmentForSitPose = new Vector3(0.74f, 0f, 0f) * standRotation; + + Vector3 standPos = ParentPosition + adjustmentForSitPosition + adjustmentForSitPose; + + m_log.DebugFormat( + "[SCENE PRESENCE]: Setting stand to pos {0}, (adjustmentForSitPosition {1}, adjustmentForSitPose {2}) rotation {3} for {4} in {5}", + standPos, adjustmentForSitPosition, adjustmentForSitPose, standRotation, Name, Scene.Name); + + Rotation = standRotation; + AbsolutePosition = standPos; + ParentPosition = Vector3.Zero; + + // We need to wait until we have calculated proper stand positions before sitting up the physical + // avatar to avoid race conditions. + if (PhysicsActor == null) + AddToPhysicalScene(false); + SendAvatarDataToAllAgents(); m_requestedSitTargetID = 0; @@ -2859,6 +2900,7 @@ namespace OpenSim.Region.Framework.Scenes lastTerseUpdateToAllClientsTick = currentTick; lastPositionSentToAllClients = OffsetPosition; +// Console.WriteLine("Scheduled update for {0} in {1}", Name, Scene.Name); m_scene.ForEachClient(SendTerseUpdateToClient); } TriggerScenePresenceUpdated(); -- cgit v1.1 From f9193e3c51f0de6047906549640c59dc05b7e9d5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 29 Nov 2013 01:50:12 +0000 Subject: Restore SP.AbsolutePosition to properly return actual absolute position when sitting --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index f9b598f..a52263b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -516,7 +516,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart sitPart = ParentPart; if (sitPart != null) - return sitPart.AbsolutePosition; + return sitPart.AbsolutePosition + (m_pos * sitPart.GetWorldRotation()); } return m_pos; -- cgit v1.1 From 868c0c27469067d25add501569e5fb12f8a79c12 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 29 Nov 2013 01:56:49 +0000 Subject: Fix regression where sitting on ground stopped working. This was due to the PhysicsActor no longer being recreated on stand from ground. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a52263b..0fb5477 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2174,11 +2174,12 @@ namespace OpenSim.Region.Framework.Scenes { // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); + bool satOnObject = IsSatOnObject; + SceneObjectPart part = ParentPart; SitGround = false; - if (ParentID != 0) + if (satOnObject) { - SceneObjectPart part = ParentPart; TaskInventoryDictionary taskIDict = part.TaskInventory; if (taskIDict != null) { @@ -2238,19 +2239,21 @@ namespace OpenSim.Region.Framework.Scenes Rotation = standRotation; AbsolutePosition = standPos; ParentPosition = Vector3.Zero; + } - // We need to wait until we have calculated proper stand positions before sitting up the physical - // avatar to avoid race conditions. - if (PhysicsActor == null) - AddToPhysicalScene(false); + // We need to wait until we have calculated proper stand positions before sitting up the physical + // avatar to avoid race conditions. + if (PhysicsActor == null) + AddToPhysicalScene(false); + if (satOnObject) + { SendAvatarDataToAllAgents(); m_requestedSitTargetID = 0; part.RemoveSittingAvatar(UUID); - if (part != null) - part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); + part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); } Animator.TrySetMovementAnimation("STAND"); -- cgit v1.1 From 84bfde3bdf8c49697475693264db2445d02e5fdf Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 29 Nov 2013 02:45:14 +0000 Subject: Comment out debug sit message accidently left active --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 0fb5477..a74069d 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2232,9 +2232,9 @@ namespace OpenSim.Region.Framework.Scenes Vector3 standPos = ParentPosition + adjustmentForSitPosition + adjustmentForSitPose; - m_log.DebugFormat( - "[SCENE PRESENCE]: Setting stand to pos {0}, (adjustmentForSitPosition {1}, adjustmentForSitPose {2}) rotation {3} for {4} in {5}", - standPos, adjustmentForSitPosition, adjustmentForSitPose, standRotation, Name, Scene.Name); +// m_log.DebugFormat( +// "[SCENE PRESENCE]: Setting stand to pos {0}, (adjustmentForSitPosition {1}, adjustmentForSitPose {2}) rotation {3} for {4} in {5}", +// standPos, adjustmentForSitPosition, adjustmentForSitPose, standRotation, Name, Scene.Name); Rotation = standRotation; AbsolutePosition = standPos; -- cgit v1.1 From 5f0e763062d347f188e01ad5febc1bd59e32b367 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 29 Nov 2013 02:48:59 +0000 Subject: Remove unused sp.ParentPosition, which has not been used for some time --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 10 ---------- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 13 ++----------- 2 files changed, 2 insertions(+), 21 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index dcbb509..ea9d0d8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -789,16 +789,6 @@ namespace OpenSim.Region.Framework.Scenes m_log.ErrorFormat("[SCENEOBJECTPART]: GROUP POSITION. {0}", e); } } - - // TODO if we decide to do sitting in a more SL compatible way (multiple avatars per prim), this has to be fixed, too - if (SitTargetAvatar != UUID.Zero) - { - ScenePresence avatar; - if (ParentGroup.Scene.TryGetScenePresence(SitTargetAvatar, out avatar)) - { - avatar.ParentPosition = GetWorldPosition(); - } - } } } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a74069d..9cb9303 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -480,8 +480,6 @@ namespace OpenSim.Region.Framework.Scenes get { return (IClientCore)ControllingClient; } } - public Vector3 ParentPosition { get; set; } - /// /// Position of this avatar relative to the region the avatar is in /// @@ -540,10 +538,7 @@ namespace OpenSim.Region.Framework.Scenes // Don't update while sitting. The PhysicsActor above is null whilst sitting. if (ParentID == 0) - { m_pos = value; - ParentPosition = Vector3.Zero; - } //m_log.DebugFormat( // "[ENTITY BASE]: In {0} set AbsolutePosition of {1} to {2}", @@ -2195,7 +2190,7 @@ namespace OpenSim.Region.Framework.Scenes } } - ParentPosition = part.GetWorldPosition(); + Vector3 sitPartWorldPosition = part.GetWorldPosition(); ControllingClient.SendClearFollowCamProperties(part.ParentUUID); ParentID = 0; @@ -2230,7 +2225,7 @@ namespace OpenSim.Region.Framework.Scenes // hardcoding here. Vector3 adjustmentForSitPose = new Vector3(0.74f, 0f, 0f) * standRotation; - Vector3 standPos = ParentPosition + adjustmentForSitPosition + adjustmentForSitPose; + Vector3 standPos = sitPartWorldPosition + adjustmentForSitPosition + adjustmentForSitPose; // m_log.DebugFormat( // "[SCENE PRESENCE]: Setting stand to pos {0}, (adjustmentForSitPosition {1}, adjustmentForSitPose {2}) rotation {3} for {4} in {5}", @@ -2238,7 +2233,6 @@ namespace OpenSim.Region.Framework.Scenes Rotation = standRotation; AbsolutePosition = standPos; - ParentPosition = Vector3.Zero; } // We need to wait until we have calculated proper stand positions before sitting up the physical @@ -2663,7 +2657,6 @@ namespace OpenSim.Region.Framework.Scenes m_pos = newPos; Rotation = newRot; - ParentPosition = part.AbsolutePosition; } else { @@ -2671,8 +2664,6 @@ namespace OpenSim.Region.Framework.Scenes // being sat upon. m_pos -= part.GroupPosition; - ParentPosition = part.AbsolutePosition; - // m_log.DebugFormat( // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", // Name, part.AbsolutePosition, m_pos, ParentPosition, part.Name, part.LocalId); -- cgit v1.1 From 4bd4f1cd832b543fd60b73d75c494bf7422f86f0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 30 Nov 2013 01:14:12 +0000 Subject: Remove nudgehack from SP.HandleAgentUpdate by making MovementFlag a uint rather than a byte --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 25 ++++++------------------ 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 9cb9303..a34c44c 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -351,7 +351,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// Record user movement inputs. /// - public byte MovementFlag { get; private set; } + public uint MovementFlag { get; private set; } private bool m_updateflag; @@ -1695,10 +1695,7 @@ namespace OpenSim.Region.Framework.Scenes else dirVectors = Dir_Vectors; - // The fact that MovementFlag is a byte needs to be fixed - // it really should be a uint // A DIR_CONTROL_FLAG occurs when the user is trying to move in a particular direction. - uint nudgehack = 250; foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) { if (((uint)flags & (uint)DCF) != 0) @@ -1715,29 +1712,19 @@ namespace OpenSim.Region.Framework.Scenes // Why did I get this? } - if ((MovementFlag & (byte)(uint)DCF) == 0) - { - if (DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE || - DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT_NUDGE) - { - MovementFlag |= (byte)nudgehack; - } - + if ((MovementFlag & (uint)DCF) == 0) + { //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF); - MovementFlag += (byte)(uint)DCF; + MovementFlag += (uint)DCF; update_movementflag = true; } } else { - if ((MovementFlag & (byte)(uint)DCF) != 0 || - ((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE || - DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT_NUDGE) - && ((MovementFlag & (byte)nudgehack) == nudgehack)) - ) // This or is for Nudge forward + if ((MovementFlag & (uint)DCF) != 0) { //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with lack of {1}", Name, DCF); - MovementFlag -= ((byte)(uint)DCF); + MovementFlag -= (uint)DCF; update_movementflag = true; /* -- cgit v1.1 From 4cde02a2a36dd7f6afce49e5e6db78af021ab14b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 30 Nov 2013 01:44:30 +0000 Subject: Implement most effects of AGENT_CONTROL_STOP AGENT_CONTROL_STOP is specified to SP.HandleAgentUpdate if the user holds down the space bar on a viewer. For a stopped avatar, this prevents fly or walk/run (though not rotate) until released. For a walking/running avatar, this reduces movement to half speed. For a flying avatar, this stops the avatar. These are observed behaviours on the LL grid - there was no previous OpenSimulator implementation This commit introduces an optional parameter to SP.AddNewMovement(), which means that it will no longer compile on .NET 3.5 or earlier versions of Mono than 2.8 Currently, this does not work for jumping, and if used whilst flying the avatar continues the fly animation even though it does not move --- .../Scenes/Animation/ScenePresenceAnimator.cs | 17 ++- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 131 ++++++++++++++------- 2 files changed, 104 insertions(+), 44 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 3b5a5bd..5beee73 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -403,11 +403,18 @@ namespace OpenSim.Region.Framework.Scenes.Animation Falling = false; // Walking / crouchwalking / running if (move.Z < 0f) + { return "CROUCHWALK"; - else if (m_scenePresence.SetAlwaysRun) - return "RUN"; - else - return "WALK"; + } + // We need to prevent these animations if the user tries to make their avatar walk or run whilst + // specifying AGENT_CONTROL_STOP (pressing down space on viewers). + else if (!m_scenePresence.AgentControlStopActive) + { + if (m_scenePresence.SetAlwaysRun) + return "RUN"; + else + return "WALK"; + } } else if (!m_jumping) { @@ -435,6 +442,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation /// 'true' if the animation was changed public bool UpdateMovementAnimations() { +// m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Updating movement animations for {0}", m_scenePresence.Name); + bool ret = false; lock (m_animations) { diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a34c44c..7a6a334 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -355,6 +355,11 @@ namespace OpenSim.Region.Framework.Scenes private bool m_updateflag; + /// + /// Is the agent stop control flag currently active? + /// + public bool AgentControlStopActive { get; private set; } + public bool Updated { set { m_updateflag = value; } @@ -768,6 +773,14 @@ namespace OpenSim.Region.Framework.Scenes set { m_speedModifier = value; } } + /// + /// Modifier for agent movement if we get an AGENT_CONTROL_STOP whilst walking or running + /// + /// + /// AGENT_CONTRL_STOP comes about if user holds down space key on viewers. + /// + private float AgentControlStopSlowWhilstMoving = 0.5f; + private bool m_forceFly; public bool ForceFly @@ -1634,7 +1647,6 @@ namespace OpenSim.Region.Framework.Scenes if ((oldState & (uint)AgentState.Editing) != 0 && State == (uint)AgentState.None) ControllingClient.SendAgentTerseUpdate(this); - PhysicsActor actor = PhysicsActor; if (actor == null) { @@ -1712,7 +1724,7 @@ namespace OpenSim.Region.Framework.Scenes // Why did I get this? } - if ((MovementFlag & (uint)DCF) == 0) + if (((MovementFlag & (uint)DCF) == 0) & !AgentControlStopActive) { //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF); MovementFlag += (uint)DCF; @@ -1744,6 +1756,13 @@ namespace OpenSim.Region.Framework.Scenes i++; } + // Detect AGENT_CONTROL_STOP state changes + if (AgentControlStopActive != ((flags & AgentManager.ControlFlags.AGENT_CONTROL_STOP) != 0)) + { + AgentControlStopActive = !AgentControlStopActive; + update_movementflag = true; + } + if (MovingToTarget) { // If the user has pressed a key then we want to cancel any move to target. @@ -1769,53 +1788,79 @@ namespace OpenSim.Region.Framework.Scenes // Only do this if we're flying if (Flying && !ForceFly) { - // Landing detection code - - // Are the landing controls requirements filled? - bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || - ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); - - //m_log.Debug("[CONTROL]: " +flags); - // Applies a satisfying roll effect to the avatar when flying. - if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0 && (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0) + // Need to stop in mid air if user holds down AGENT_CONTROL_STOP + if (AgentControlStopActive) { - ApplyFlyingRoll( - FLY_ROLL_RADIANS_PER_UPDATE, - (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0, - (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0); - } - else if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0 && - (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) - { - ApplyFlyingRoll( - -FLY_ROLL_RADIANS_PER_UPDATE, - (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0, - (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0); + agent_control_v3 = Vector3.Zero; } else { - if (m_AngularVelocity.Z != 0) - m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_UPDATE); - } + // Landing detection code - if (Flying && IsColliding && controlland) - { - // nesting this check because LengthSquared() is expensive and we don't - // want to do it every step when flying. - if ((Velocity.LengthSquared() <= LAND_VELOCITYMAG_MAX)) - StopFlying(); + // Are the landing controls requirements filled? + bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || + ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); + + //m_log.Debug("[CONTROL]: " +flags); + // Applies a satisfying roll effect to the avatar when flying. + if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0 && (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0) + { + ApplyFlyingRoll( + FLY_ROLL_RADIANS_PER_UPDATE, + (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0, + (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0); + } + else if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0 && + (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) + { + ApplyFlyingRoll( + -FLY_ROLL_RADIANS_PER_UPDATE, + (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0, + (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0); + } + else + { + if (m_AngularVelocity.Z != 0) + m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_UPDATE); + } + + if (Flying && IsColliding && controlland) + { + // nesting this check because LengthSquared() is expensive and we don't + // want to do it every step when flying. + if ((Velocity.LengthSquared() <= LAND_VELOCITYMAG_MAX)) + StopFlying(); + } } } +// m_log.DebugFormat("[SCENE PRESENCE]: MovementFlag {0} for {1}", MovementFlag, Name); + // If the agent update does move the avatar, then calculate the force ready for the velocity update, // which occurs later in the main scene loop - if (update_movementflag || (update_rotation && DCFlagKeyPressed)) + // We also need to update if the user rotates their avatar whilst it is slow walking/running (if they + // held down AGENT_CONTROL_STOP whilst normal walking/running). However, we do not want to update + // if the user rotated whilst holding down AGENT_CONTROL_STOP when already still (which locks the + // avatar location in place). + if (update_movementflag + || (update_rotation && DCFlagKeyPressed && (!AgentControlStopActive || MovementFlag != 0))) { -// m_log.DebugFormat( -// "[SCENE PRESENCE]: In {0} adding velocity of {1} to {2}, umf = {3}, ur = {4}", -// m_scene.RegionInfo.RegionName, agent_control_v3, Name, update_movementflag, update_rotation); +// if (update_movementflag || !AgentControlStopActive || MovementFlag != 0) +// { +// m_log.DebugFormat( +// "[SCENE PRESENCE]: In {0} adding velocity of {1} to {2}, umf = {3}, mf = {4}, ur = {5}", +// m_scene.RegionInfo.RegionName, agent_control_v3, Name, +// update_movementflag, MovementFlag, update_rotation); + + float speedModifier; + + if (AgentControlStopActive) + speedModifier = 0.5f; + else + speedModifier = 1; - AddNewMovement(agent_control_v3); + AddNewMovement(agent_control_v3, speedModifier); +// } } // else // { @@ -1828,7 +1873,10 @@ namespace OpenSim.Region.Framework.Scenes // } if (update_movementflag && ParentID == 0) + { +// m_log.DebugFormat("[SCENE PRESENCE]: Updating movement animations for {0}", Name); Animator.UpdateMovementAnimations(); + } SendControlsToScripts(flagsForScripts); } @@ -2711,10 +2759,13 @@ namespace OpenSim.Region.Framework.Scenes /// Rotate the avatar to the given rotation and apply a movement in the given relative vector /// /// The vector in which to move. This is relative to the rotation argument - public void AddNewMovement(Vector3 vec) + /// + /// Optional additional speed modifier for this particular add. Default is 1 + public void AddNewMovement(Vector3 vec, float thisAddSpeedModifier = 1) { // m_log.DebugFormat( -// "[SCENE PRESENCE]: Adding new movement {0} with rotation {1} for {2}", vec, Rotation, Name); +// "[SCENE PRESENCE]: Adding new movement {0} with rotation {1}, thisAddSpeedModifier {2} for {3}", +// vec, Rotation, thisAddSpeedModifier, Name); Vector3 direc = vec * Rotation; direc.Normalize(); @@ -2732,7 +2783,7 @@ namespace OpenSim.Region.Framework.Scenes if ((vec.Z == 0f) && !Flying) direc.Z = 0f; // Prevent camera WASD up. - direc *= 0.03f * 128f * SpeedModifier; + direc *= 0.03f * 128f * SpeedModifier * thisAddSpeedModifier; // m_log.DebugFormat("[SCENE PRESENCE]: Force to apply before modification was {0} for {1}", direc, Name); -- cgit v1.1 From 96018afab40fc59b890448f2fa826cd296650b48 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 30 Nov 2013 01:52:45 +0000 Subject: Remove unused SP.Updated flag, which appears unused for many years and was only set true once and never reset --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7a6a334..d74d92b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -353,19 +353,11 @@ namespace OpenSim.Region.Framework.Scenes /// public uint MovementFlag { get; private set; } - private bool m_updateflag; - /// /// Is the agent stop control flag currently active? /// public bool AgentControlStopActive { get; private set; } - public bool Updated - { - set { m_updateflag = value; } - get { return m_updateflag; } - } - private bool m_invulnerable = true; public bool Invulnerable @@ -3688,8 +3680,6 @@ namespace OpenSim.Region.Framework.Scenes { Vector3 force = m_forceToApply.Value; - Updated = true; - Velocity = force; m_forceToApply = null; -- cgit v1.1 From 8ebad908008d098dd01f2218e3e125e54ce2c784 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 30 Nov 2013 01:56:46 +0000 Subject: Actually use the SP.AgentControlStopSlowWhilstMoving parameter intoroduced for slow walk/run in 4cfe02a rather than the magic number --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index d74d92b..1dc7e20 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1847,7 +1847,7 @@ namespace OpenSim.Region.Framework.Scenes float speedModifier; if (AgentControlStopActive) - speedModifier = 0.5f; + speedModifier = AgentControlStopSlowWhilstMoving; else speedModifier = 1; -- cgit v1.1 From 62a2d7836fb36f66a0e42b20f4596e517eb52354 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 3 Dec 2013 02:27:40 +0000 Subject: Ignore X and Y body rotations when sent by mouse look. Fixes http://opensimulator.org/mantis/view.php?id=3274 When not in mouselook, avatar only sends rotations around the Z plane (since that's the only way an avatar can rotate). However, in mouselook it also sends X and Y information. But sending X and Y in terse updates causes issues with wrong camera movement in mouselook. So strip out X and Y components for now. If this is an issue, then could strip out before sending avatar terse update, though this generates more cpu work. Thanks to mirceakitsune for suggesting an initial fix --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 1dc7e20..dae20a5 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1648,12 +1648,24 @@ namespace OpenSim.Region.Framework.Scenes if (AllowMovement && !SitGround) { - Quaternion bodyRotation = agentData.BodyRotation; +// m_log.DebugFormat("[SCENE PRESENCE]: Initial body rotation {0} for {1}", agentData.BodyRotation, Name); + bool update_rotation = false; - if (bodyRotation != Rotation) + // Whilst not in mouselook, an avatar will transmit only the Z rotation as this is the only axis + // it rotates around. + // In mouselook, X and Y co-ordinate will also be sent but when used in Rotation, these cause unwanted + // excessive up and down movements of the camera when looking up and down. + // See http://opensimulator.org/mantis/view.php?id=3274 + // This does not affect head movement, since this is controlled entirely by camera movement rather than + // body rotation. It does not affect sitting avatar since it's the sitting part rotation that takes + // effect, not the avatar rotation. + // However, if we do need to store X and Y rotations in the future, another solution needs to be found + // for the mouselook bug. Possibly, one could strip out X and Y rotations before sending the avatar + // update messages. + if (agentData.BodyRotation.Z != Rotation.Z || agentData.BodyRotation.W != Rotation.W) { - Rotation = bodyRotation; + Rotation = new Quaternion(0, 0, agentData.BodyRotation.Z, agentData.BodyRotation.W); update_rotation = true; } -- cgit v1.1 From 17b32b764acd815400d9eb903aaec6dcebd60ac7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 5 Dec 2013 02:10:46 +0000 Subject: Fix regression where mouse look flight direction no longer worked by zeroing x/y rot before sending agent updates, instead of before any agent update processing It turns out that the x/y rot data in mouselook is needed to implement this and to push the avatar against the ground if walking in mouselook. Doing this in the terse send so that we preserve mouselook rotation information --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index dae20a5..7ed3a4b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1652,20 +1652,9 @@ namespace OpenSim.Region.Framework.Scenes bool update_rotation = false; - // Whilst not in mouselook, an avatar will transmit only the Z rotation as this is the only axis - // it rotates around. - // In mouselook, X and Y co-ordinate will also be sent but when used in Rotation, these cause unwanted - // excessive up and down movements of the camera when looking up and down. - // See http://opensimulator.org/mantis/view.php?id=3274 - // This does not affect head movement, since this is controlled entirely by camera movement rather than - // body rotation. It does not affect sitting avatar since it's the sitting part rotation that takes - // effect, not the avatar rotation. - // However, if we do need to store X and Y rotations in the future, another solution needs to be found - // for the mouselook bug. Possibly, one could strip out X and Y rotations before sending the avatar - // update messages. - if (agentData.BodyRotation.Z != Rotation.Z || agentData.BodyRotation.W != Rotation.W) + if (agentData.BodyRotation != Rotation) { - Rotation = new Quaternion(0, 0, agentData.BodyRotation.Z, agentData.BodyRotation.W); + Rotation = agentData.BodyRotation; update_rotation = true; } -- cgit v1.1