From b6df9e9fe4a4b48901f2e65b85abed379616ca0b Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 5 Nov 2011 21:24:36 +0000 Subject: [PATCH 1/7] Chnaging the sit target adjustment to a more precise approximation of SL. Some small fixes ported from Avination. Some white space fixes. --- .../Region/Framework/Scenes/ScenePresence.cs | 59 +++++++++++-------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index e961bdd26d..1809b843c8 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -89,7 +89,7 @@ namespace OpenSim.Region.Framework.Scenes /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis /// issue #1716 /// - public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.1f, 0.0f, 0.3f); + public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); /// /// Movement updates for agents in neighboring regions are sent directly to clients. @@ -169,7 +169,7 @@ namespace OpenSim.Region.Framework.Scenes protected ulong crossingFromRegion; - private readonly Vector3[] Dir_Vectors = new Vector3[9]; + private readonly Vector3[] Dir_Vectors = new Vector3[11]; protected Timer m_reprioritization_timer; @@ -241,6 +241,8 @@ namespace OpenSim.Region.Framework.Scenes DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, DIR_CONTROL_FLAG_FORWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS, DIR_CONTROL_FLAG_BACKWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG, + DIR_CONTROL_FLAG_LEFT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS, + DIR_CONTROL_FLAG_RIGHT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG, DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG } @@ -479,7 +481,7 @@ namespace OpenSim.Region.Framework.Scenes { get { - if (PhysicsActor != null) + if (PhysicsActor != null && m_parentID == 0) { m_pos = PhysicsActor.Position; @@ -507,7 +509,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart part = m_scene.GetSceneObjectPart(ParentID); if (part != null) { - return ParentPosition + (m_pos * part.GetWorldRotation()); + return part.AbsolutePosition + (m_pos * part.GetWorldRotation()); } else { @@ -816,23 +818,27 @@ namespace OpenSim.Region.Framework.Scenes Dir_Vectors[3] = -Vector3.UnitY; //RIGHT Dir_Vectors[4] = Vector3.UnitZ; //UP Dir_Vectors[5] = -Vector3.UnitZ; //DOWN - Dir_Vectors[8] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge - Dir_Vectors[6] = Vector3.UnitX*2; //FORWARD - Dir_Vectors[7] = -Vector3.UnitX; //BACK + Dir_Vectors[6] = new Vector3(0.5f, 0f, 0f); //FORWARD_NUDGE + Dir_Vectors[7] = new Vector3(-0.5f, 0f, 0f); //BACK_NUDGE + Dir_Vectors[8] = new Vector3(0f, 0.5f, 0f); //LEFT_NUDGE + Dir_Vectors[9] = new Vector3(0f, -0.5f, 0f); //RIGHT_NUDGE + Dir_Vectors[10] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge } private Vector3[] GetWalkDirectionVectors() { - Vector3[] vector = new Vector3[9]; - vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -CameraAtAxis.Z); //FORWARD - vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, CameraAtAxis.Z); //BACK + Vector3[] vector = new Vector3[11]; + vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD + vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK vector[2] = Vector3.UnitY; //LEFT vector[3] = -Vector3.UnitY; //RIGHT - vector[4] = new Vector3(CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP - vector[5] = new Vector3(-CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN - vector[8] = new Vector3(-CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge - vector[6] = (new Vector3(m_CameraUpAxis.Z, 0f, -CameraAtAxis.Z) * 2); //FORWARD Nudge - vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, CameraAtAxis.Z); //BACK Nudge + vector[4] = new Vector3(m_CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP + vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN + vector[6] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD_NUDGE + vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK_NUDGE + vector[8] = Vector3.UnitY; //LEFT_NUDGE + vector[9] = -Vector3.UnitY; //RIGHT_NUDGE + vector[10] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_NUDGE return vector; } @@ -1031,12 +1037,17 @@ namespace OpenSim.Region.Framework.Scenes { if (PhysicsActor != null) { - PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; - PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; - m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); - PhysicsActor.UnSubscribeEvents(); - PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; - PhysicsActor = null; + try + { + PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; + PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; + m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); + PhysicsActor.UnSubscribeEvents(); + PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; + PhysicsActor = null; + } + catch + { } } } @@ -2049,9 +2060,9 @@ namespace OpenSim.Region.Framework.Scenes m_requestedSitTargetID = part.LocalId; //m_requestedSitOffset = offset; m_requestedSitTargetUUID = targetID; - + m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset); - + if (m_scene.PhysicsScene.SupportsRayCast()) { //m_scene.PhysicsScene.RaycastWorld(Vector3.Zero,Vector3.Zero, 0.01f,new RaycastCallback()); @@ -2270,7 +2281,7 @@ namespace OpenSim.Region.Framework.Scenes HandleAgentSit(remoteClient, agentID, "SIT"); } } - + public void HandleAgentSit(IClientAPI remoteClient, UUID agentID, string sitAnimation) { SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); From 2dc452b4a71be8359a7ff66b52c9bfc62d0c12ac Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 5 Nov 2011 21:41:16 +0000 Subject: [PATCH 2/7] ScenePresence part of the Avination animator fixes. --- .../Region/Framework/Scenes/ScenePresence.cs | 61 ++++++++++++++++++- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 1809b843c8..f0776a996e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -26,6 +26,7 @@ */ using System; +using System.Xml; using System.Collections.Generic; using System.Reflection; using System.Timers; @@ -137,6 +138,18 @@ namespace OpenSim.Region.Framework.Scenes //private int m_lastTerseSent; private Vector3? m_forceToApply; + private int m_userFlags; + public int UserFlags + { + get { return m_userFlags; } + } + private bool m_flyingOld; // add for fly velocity control + public bool m_wasFlying; // add for fly velocity control + + private int m_lastColCount = -1; //KF: Look for Collision chnages + private int m_updateCount = 0; //KF: Update Anims for a while + private static readonly int UPDATE_COUNT = 10; // how many frames to update for + private TeleportFlags m_teleportFlags; public TeleportFlags TeleportFlags { @@ -756,6 +769,7 @@ namespace OpenSim.Region.Framework.Scenes m_localId = m_scene.AllocateLocalId(); UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); + m_userFlags = account.UserFlags; if (account != null) UserLevel = account.UserLevel; @@ -1033,7 +1047,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// Removes physics plugin scene representation of this agent if it exists. /// - private void RemoveFromPhysicalScene() + public void RemoveFromPhysicalScene() { if (PhysicsActor != null) { @@ -1362,6 +1376,10 @@ namespace OpenSim.Region.Framework.Scenes #endregion Inputs + // Make anims work for client side autopilot + if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0) + m_updateCount = UPDATE_COUNT; + if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) { StandUp(); @@ -1392,6 +1410,9 @@ namespace OpenSim.Region.Framework.Scenes if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) { + m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick. + Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); + // TODO: This doesn't prevent the user from walking yet. // Setting parent ID would fix this, if we knew what value // to use. Or we could add a m_isSitting variable. @@ -1726,6 +1747,9 @@ namespace OpenSim.Region.Framework.Scenes /// public void MoveToTarget(Vector3 pos, bool noFly, bool landAtTarget) { + if (SitGround) + StandUp(); + m_log.DebugFormat( "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}", Name, pos, m_scene.RegionInfo.RegionName); @@ -2361,6 +2385,19 @@ namespace OpenSim.Region.Framework.Scenes Vector3 direc = vec * Rotation; direc.Normalize(); + if (PhysicsActor.Flying != m_flyingOld) // add for fly velocity control + { + m_flyingOld = PhysicsActor.Flying; // add for fly velocity control + if (!PhysicsActor.Flying) + m_wasFlying = true; // add for fly velocity control + } + + if (PhysicsActor.IsColliding == true) + m_wasFlying = false; // add for fly velocity control + + if ((vec.Z == 0f) && !PhysicsActor.Flying) + direc.Z = 0f; // Prevent camera WASD up. + direc *= 0.03f * 128f * SpeedModifier; if (PhysicsActor != null) @@ -2379,7 +2416,7 @@ namespace OpenSim.Region.Framework.Scenes // m_log.Info("[AGENT]: Stop Flying"); //} } - else if (!PhysicsActor.Flying && PhysicsActor.IsColliding) + if (!PhysicsActor.Flying && PhysicsActor.IsColliding) { if (direc.Z > 2.0f) { @@ -3303,13 +3340,27 @@ namespace OpenSim.Region.Framework.Scenes // The Physics Scene will send updates every 500 ms grep: PhysicsActor.SubscribeEvents( // as of this comment the interval is set in AddToPhysicalScene if (Animator != null) - Animator.UpdateMovementAnimations(); + { + if (m_updateCount > 0) + { + Animator.UpdateMovementAnimations(); + m_updateCount--; + } + } CollisionEventUpdate collisionData = (CollisionEventUpdate)e; Dictionary coldata = collisionData.m_objCollisionList; CollisionPlane = Vector4.UnitW; + // No collisions at all means we may be flying. Update always + // to make falling work + if (m_lastColCount != coldata.Count || coldata.Count == 0) + { + m_updateCount = UPDATE_COUNT; + m_lastColCount = coldata.Count; + } + if (coldata.Count != 0 && Animator != null) { switch (Animator.CurrentMovementAnimation) @@ -3410,6 +3461,10 @@ namespace OpenSim.Region.Framework.Scenes { lock (m_attachments) { + // This may be true when the attachment comes back + // from serialization after login. Clear it. + gobj.IsDeleted = false; + m_attachments.Add(gobj); } } From ac3254a5f588fa80cafd42fc40c9832e80a70229 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 5 Nov 2011 21:43:35 +0000 Subject: [PATCH 3/7] Change puvlic m_ variable to a getter property --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index f0776a996e..ebb9b0afee 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -144,7 +144,11 @@ namespace OpenSim.Region.Framework.Scenes get { return m_userFlags; } } private bool m_flyingOld; // add for fly velocity control - public bool m_wasFlying; // add for fly velocity control + public bool WasFlying + { + get { return m_wasFlying; } + } + private bool m_wasFlying; // add for fly velocity control private int m_lastColCount = -1; //KF: Look for Collision chnages private int m_updateCount = 0; //KF: Update Anims for a while From 71388fc02a9e782d5e080ae0fad22fb18e637b20 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 5 Nov 2011 22:41:00 +0000 Subject: [PATCH 4/7] Porting the ScenePresenceAnimator from Avination. Jump and fall anims now work properly. --- .../Scenes/Animation/ScenePresenceAnimator.cs | 227 +++++++++++------- .../Region/Framework/Scenes/ScenePresence.cs | 6 +- 2 files changed, 141 insertions(+), 92 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index e9e1845d4c..0410150718 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -26,6 +26,7 @@ */ using System; +using System.Threading; using System.Collections.Generic; using System.Reflection; using log4net; @@ -42,7 +43,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation /// public class ScenePresenceAnimator { -// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public AnimationSet Animations { @@ -57,11 +58,19 @@ namespace OpenSim.Region.Framework.Scenes.Animation { get { return m_movementAnimation; } } - protected string m_movementAnimation = "DEFAULT"; - + protected string m_movementAnimation = "CROUCH"; private int m_animTickFall; - private int m_animTickJump; - + public int m_animTickJump; // ScenePresence has to see this to control +Z force + public bool m_jumping = false; + public float m_jumpVelocity = 0f; + private int m_landing = 0; + public bool Falling + { + get { return m_falling; } + } + private bool m_falling = false; + private float m_fallHeight; + /// /// The scene presence that this animator applies to /// @@ -122,7 +131,9 @@ namespace OpenSim.Region.Framework.Scenes.Animation public void ResetAnimations() { +Console.WriteLine("ResetA............."); m_animations.Clear(); +TrySetMovementAnimation("STAND"); } /// @@ -152,15 +163,13 @@ namespace OpenSim.Region.Framework.Scenes.Animation /// public string GetMovementAnimation() { - const float FALL_DELAY = 0.33f; - const float PREJUMP_DELAY = 0.25f; - + const float FALL_DELAY = 800f; + const float PREJUMP_DELAY = 200f; + const float JUMP_PERIOD = 800f; #region Inputs - if (m_scenePresence.SitGround) - { - return "SIT_GROUND_CONSTRAINED"; - } + AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_scenePresence.AgentControlFlags; +// m_log.DebugFormat("[ANIM]: Control flags: {0}", controlFlags); PhysicsActor actor = m_scenePresence.PhysicsActor; // Create forward and left vectors from the current avatar rotation @@ -169,13 +178,12 @@ namespace OpenSim.Region.Framework.Scenes.Animation Vector3 left = Vector3.Transform(Vector3.UnitY, rotMatrix); // Check control flags - bool heldForward = - (((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) || ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS)); - bool heldBack = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG; - bool heldLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS; - bool heldRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG; - bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT; - bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT; + bool heldForward = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_AT_POS || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS); + bool heldBack = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG); + bool heldLeft = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS); + bool heldRight = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG); + //bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT; + //bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT; bool heldUp = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == AgentManager.ControlFlags.AGENT_CONTROL_UP_POS; bool heldDown = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG; //bool flying = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) == AgentManager.ControlFlags.AGENT_CONTROL_FLY; @@ -183,17 +191,15 @@ namespace OpenSim.Region.Framework.Scenes.Animation // Direction in which the avatar is trying to move Vector3 move = Vector3.Zero; - if (heldForward) { move.X += fwd.X; move.Y += fwd.Y; } if (heldBack) { move.X -= fwd.X; move.Y -= fwd.Y; } if (heldLeft) { move.X += left.X; move.Y += left.Y; } if (heldRight) { move.X -= left.X; move.Y -= left.Y; } if (heldUp) { move.Z += 1; } if (heldDown) { move.Z -= 1; } + if (heldForward) { move.X += fwd.X; move.Y += fwd.Y; } // Is the avatar trying to move? // bool moving = (move != Vector3.Zero); - bool jumping = m_animTickJump != 0; - #endregion Inputs #region Flying @@ -202,6 +208,11 @@ namespace OpenSim.Region.Framework.Scenes.Animation { m_animTickFall = 0; m_animTickJump = 0; + m_jumping = false; + m_falling = true; + m_jumpVelocity = 0f; + actor.Selected = false; + m_fallHeight = actor.Position.Z; // save latest flying height if (move.X != 0f || move.Y != 0f) { @@ -213,8 +224,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation } else if (move.Z < 0f) { - if (actor != null && actor.IsColliding) + if (actor != null && actor.IsColliding) + { return "LAND"; + } else return "HOVER_DOWN"; } @@ -228,107 +241,141 @@ namespace OpenSim.Region.Framework.Scenes.Animation #region Falling/Floating/Landing - if (actor == null || !actor.IsColliding) + if ((actor == null || !actor.IsColliding) && !m_jumping) { - float fallElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; + float fallElapsed = (float)(Environment.TickCount - m_animTickFall); float fallVelocity = (actor != null) ? actor.Velocity.Z : 0.0f; - if (m_animTickFall == 0 || (fallElapsed > FALL_DELAY && fallVelocity >= 0.0f)) + if (!m_jumping && (fallVelocity < -3.0f) ) m_falling = true; + + if (m_animTickFall == 0 || (fallVelocity >= 0.0f)) { - // Just started falling + // not falling yet, or going up + // reset start of fall time m_animTickFall = Environment.TickCount; } - else if (!jumping && fallElapsed > FALL_DELAY) + else if (!m_jumping && (fallElapsed > FALL_DELAY) && (fallVelocity < -3.0f) && (m_scenePresence.WasFlying)) { // Falling long enough to trigger the animation return "FALLDOWN"; } - else if (m_animTickJump == -1) - { - m_animTickJump = 0; - return "STAND"; - } return m_movementAnimation; } #endregion Falling/Floating/Landing + + #region Jumping // section added for jumping... + + int jumptime; + jumptime = Environment.TickCount - m_animTickJump; + + + if ((move.Z > 0f) && (!m_jumping)) + { + // Start jumping, prejump + m_animTickFall = 0; + m_jumping = true; + m_falling = false; + actor.Selected = true; // borrowed for jumping flag + m_animTickJump = Environment.TickCount; + m_jumpVelocity = 0.35f; + return "PREJUMP"; + } + + if(m_jumping) + { + if ( (jumptime > (JUMP_PERIOD * 1.5f)) && actor.IsColliding) + { + // end jumping + m_jumping = false; + m_falling = false; + actor.Selected = false; // borrowed for jumping flag + m_jumpVelocity = 0f; + m_animTickFall = Environment.TickCount; + return "LAND"; + } + else if (jumptime > JUMP_PERIOD) + { + // jump down + m_jumpVelocity = 0f; + return "JUMP"; + } + else if (jumptime > PREJUMP_DELAY) + { + // jump up + m_jumping = true; + m_jumpVelocity = 10f; + return "JUMP"; + } + } + + #endregion Jumping + #region Ground Movement if (m_movementAnimation == "FALLDOWN") { + m_falling = false; m_animTickFall = Environment.TickCount; - // TODO: SOFT_LAND support - return "LAND"; - } - else if (m_movementAnimation == "LAND") - { - float landElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; - if ((m_animTickFall != 0) && (landElapsed <= FALL_DELAY)) + float fallHeight = m_fallHeight - actor.Position.Z; + if (fallHeight > 15.0f) + return "STANDUP"; + else if (fallHeight > 8.0f) + return "SOFT_LAND"; + else return "LAND"; } - - m_animTickFall = 0; - - if (move.Z > 0.2f) + else if ((m_movementAnimation == "LAND") || (m_movementAnimation == "SOFT_LAND") || (m_movementAnimation == "STANDUP")) { - // Jumping - if (!jumping) - { - // Begin prejump - m_animTickJump = Environment.TickCount; - return "PREJUMP"; - } - else if (Environment.TickCount - m_animTickJump > PREJUMP_DELAY * 1000.0f) - { - // Start actual jump - if (m_animTickJump == -1) - { - // Already jumping! End the current jump - m_animTickJump = 0; - return "JUMP"; - } + int landElapsed = Environment.TickCount - m_animTickFall; + int limit = 1000; + if(m_movementAnimation == "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 - m_animTickJump = -1; - return "JUMP"; - } - else - return "JUMP"; - } - else - { - // Not jumping - m_animTickJump = 0; - - if (move.X != 0f || move.Y != 0f) + if ((m_animTickFall != 0) && (landElapsed <= limit)) { - // Walking / crouchwalking / running - if (move.Z < 0) - return "CROUCHWALK"; - else if (m_scenePresence.SetAlwaysRun) - return "RUN"; - else - return "WALK"; + return m_movementAnimation; } else { - // Not walking - if (move.Z < 0) - return "CROUCH"; - else if (heldTurnLeft) - return "TURNLEFT"; - else if (heldTurnRight) - return "TURNRIGHT"; - else - return "STAND"; + m_fallHeight = actor.Position.Z; // save latest flying height + return "STAND"; } } + // next section moved outside paren. and realigned for jumping + if (move.X != 0f || move.Y != 0f) + { + m_fallHeight = actor.Position.Z; // save latest flying height + m_falling = false; + // Walking / crouchwalking / running + if (move.Z < 0f) + return "CROUCHWALK"; + else if (m_scenePresence.SetAlwaysRun) + return "RUN"; + else + return "WALK"; + } + else if (!m_jumping) + { + m_falling = false; + // Not walking + if (move.Z < 0) + return "CROUCH"; +// else if (heldTurnLeft) +// return "TURNLEFT"; +// else if (heldTurnRight) +// return "TURNRIGHT"; + else + return "STAND"; + } #endregion Ground Movement - //return m_movementAnimation; + m_falling = false; + return m_movementAnimation; } /// @@ -337,8 +384,6 @@ namespace OpenSim.Region.Framework.Scenes.Animation public void UpdateMovementAnimations() { m_movementAnimation = GetMovementAnimation(); -// m_log.DebugFormat( -// "[SCENE PRESENCE ANIMATOR]: Got animation {0} for {1}", m_movementAnimation, m_scenePresence.Name); TrySetMovementAnimation(m_movementAnimation); } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index ebb9b0afee..287f637534 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2420,7 +2420,11 @@ namespace OpenSim.Region.Framework.Scenes // m_log.Info("[AGENT]: Stop Flying"); //} } - if (!PhysicsActor.Flying && PhysicsActor.IsColliding) + if (Animator.Falling && m_wasFlying) // if falling from flying, disable motion add + { + direc *= 0.0f; + } + else if (!PhysicsActor.Flying && PhysicsActor.IsColliding) { if (direc.Z > 2.0f) { From 4d3926694da8471d7a96447e2feadc2dd2d9d38e Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 5 Nov 2011 22:43:45 +0000 Subject: [PATCH 5/7] Remove enableprejump config option and associated code as this is now fully functional and cannot be disabled because that would break timings. --- OpenSim/Region/Framework/Scenes/Scene.cs | 3 --- bin/OpenSimDefaults.ini | 4 ---- 2 files changed, 7 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 0832975451..1e111e5f2f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -85,7 +85,6 @@ namespace OpenSim.Region.Framework.Scenes public bool m_trustBinaries; public bool m_allowScriptCrossings; public bool m_useFlySlow; - public bool m_usePreJump; protected float m_defaultDrawDistance = 255.0f; public float DefaultDrawDistance @@ -649,8 +648,6 @@ namespace OpenSim.Region.Framework.Scenes //Animation states m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); - // TODO: Change default to true once the feature is supported - m_usePreJump = startupConfig.GetBoolean("enableprejump", false); m_physicalPrim = startupConfig.GetBoolean("physical_prim", true); diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index bf1976c769..7ea710e477 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -298,10 +298,6 @@ ; won't look right until the physics engine supports it ; (i.e delays takeoff for a moment) - ; This is commented so it will come on automatically once it's - ; supported. - ; enableprejump = true - ; Simulator Stats URI ; Enable JSON simulator data by setting a URI name (case sensitive) ; Stats_URI = "jsonSimStats" From 01b6a4b62e0bdd62929633952fdc3717e9773cb3 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 5 Nov 2011 22:46:45 +0000 Subject: [PATCH 6/7] Remove some left over debug and reverse experimental reordering of ifs --- .../Framework/Scenes/Animation/ScenePresenceAnimator.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 0410150718..05cdf610b4 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -131,9 +131,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation public void ResetAnimations() { -Console.WriteLine("ResetA............."); m_animations.Clear(); -TrySetMovementAnimation("STAND"); + TrySetMovementAnimation("STAND"); } /// @@ -169,7 +168,6 @@ TrySetMovementAnimation("STAND"); #region Inputs AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_scenePresence.AgentControlFlags; -// m_log.DebugFormat("[ANIM]: Control flags: {0}", controlFlags); PhysicsActor actor = m_scenePresence.PhysicsActor; // Create forward and left vectors from the current avatar rotation @@ -191,12 +189,12 @@ TrySetMovementAnimation("STAND"); // Direction in which the avatar is trying to move Vector3 move = Vector3.Zero; + if (heldForward) { move.X += fwd.X; move.Y += fwd.Y; } if (heldBack) { move.X -= fwd.X; move.Y -= fwd.Y; } if (heldLeft) { move.X += left.X; move.Y += left.Y; } if (heldRight) { move.X -= left.X; move.Y -= left.Y; } if (heldUp) { move.Z += 1; } if (heldDown) { move.Z -= 1; } - if (heldForward) { move.X += fwd.X; move.Y += fwd.Y; } // Is the avatar trying to move? // bool moving = (move != Vector3.Zero); From bbbcdaa4625f602e4f3dcead7396e17ca7678128 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 5 Nov 2011 22:54:47 +0000 Subject: [PATCH 7/7] Remove spammy autopilot debug --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 287f637534..ce638e07be 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1754,8 +1754,8 @@ namespace OpenSim.Region.Framework.Scenes if (SitGround) StandUp(); - m_log.DebugFormat( - "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}", +// m_log.DebugFormat( +// "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}", Name, pos, m_scene.RegionInfo.RegionName); if (pos.X < 0 || pos.X >= Constants.RegionSize @@ -1820,7 +1820,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void ResetMoveToTarget() { - m_log.DebugFormat("[SCENE PRESENCE]: Resetting move to target for {0}", Name); +// m_log.DebugFormat("[SCENE PRESENCE]: Resetting move to target for {0}", Name); MovingToTarget = false; MoveToPositionTarget = Vector3.Zero;