From c719e016ed9bfbb56fd8c571b9b7b9622bcef566 Mon Sep 17 00:00:00 2001 From: Kitto Flora Date: Mon, 6 Sep 2010 21:45:07 +0000 Subject: Falling animation fix, comment out instrumentation. --- .../Scenes/Animation/ScenePresenceAnimator.cs | 95 +++++++++++++--------- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 +- OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs | 21 +++-- OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs | 18 +++- 4 files changed, 90 insertions(+), 50 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 99d9564..9658e11 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs @@ -61,6 +61,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation public bool m_jumping = false; // Add for jumping public float m_jumpVelocity = 0f; // Add for jumping private int m_landing = 0; // Add for jumping + public bool m_falling = false; // Add for falling + private float m_fallHeight; // Add for falling /// /// The scene presence that this animator applies to @@ -118,7 +120,9 @@ namespace OpenSim.Region.Framework.Scenes.Animation public void ResetAnimations() { +Console.WriteLine("ResetA............."); m_animations.Clear(); +TrySetMovementAnimation("STAND"); } /// @@ -145,7 +149,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation public string GetMovementAnimation() { //Console.WriteLine("GMA-------"); //## - const float FALL_DELAY = 0.33f; +//#@ const float FALL_DELAY = 0.33f; + const float FALL_DELAY = 800f; //## mS //rm for jumping const float PREJUMP_DELAY = 0.25f; const float PREJUMP_DELAY = 200f; // mS add for jumping const float JUMP_PERIOD = 800f; // mS add for jumping @@ -191,9 +196,11 @@ namespace OpenSim.Region.Framework.Scenes.Animation { m_animTickFall = 0; m_animTickJump = 0; - m_jumping = false; //add for jumping flag - m_jumpVelocity = 0f; //add for jumping flag + m_jumping = false; //add for jumping + m_falling = true; //add for falling + m_jumpVelocity = 0f; //add for jumping actor.Selected = false; //add for jumping flag + m_fallHeight = actor.Position.Z; // save latest flying height if (move.X != 0f || move.Y != 0f) { @@ -205,8 +212,11 @@ namespace OpenSim.Region.Framework.Scenes.Animation } else if (move.Z < 0f) { - if (actor != null && actor.IsColliding) + if (actor != null && actor.IsColliding) + { //## +//Console.WriteLine("LAND FLYING"); // ## return "LAND"; + } //# else return "HOVER_DOWN"; } @@ -223,19 +233,25 @@ namespace OpenSim.Region.Framework.Scenes.Animation // rm for jumping if (actor == null || !actor.IsColliding) if ((actor == null || !actor.IsColliding) && !m_jumping) // add for jumping { -//Console.WriteLine("FFL"); //## - float fallElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; +// rm float fallElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; + float fallElapsed = (float)(Environment.TickCount - m_animTickFall); // add, in mS float fallVelocity = (actor != null) ? actor.Velocity.Z : 0.0f; +//Console.WriteLine("falling t={0} v={1}", fallElapsed, fallVelocity); //## - if (m_animTickFall == 0 || (fallElapsed > FALL_DELAY && fallVelocity >= 0.0f)) +// rm for fall if (m_animTickFall == 0 || (fallElapsed > FALL_DELAY && fallVelocity >= 0.0f)) + if (!m_jumping && (fallVelocity < -3.0f) ) m_falling = true; // add for falling and jumping + + if (m_animTickFall == 0 || (fallVelocity >= 0.0f)) // add for jumping + // not falling yet or going up { - // Just started falling + // reset start of fall time m_animTickFall = Environment.TickCount; } // else if (!jumping && fallElapsed > FALL_DELAY) - else if (!m_jumping && fallElapsed > FALL_DELAY) // add for jumping + else if (!m_jumping && (fallElapsed > FALL_DELAY) && (fallVelocity < -3.0f) ) // add for falling and jumping { // Falling long enough to trigger the animation +//Console.WriteLine("FALLDOWN"); //## return "FALLDOWN"; } @@ -247,7 +263,6 @@ namespace OpenSim.Region.Framework.Scenes.Animation #region Jumping // section added for jumping... - Vector3 vj = Vector3.Zero; int jumptime; jumptime = Environment.TickCount - m_animTickJump; @@ -258,12 +273,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation // Start jumping, prejump m_animTickFall = 0; m_jumping = true; + m_falling = false; actor.Selected = true; // borrowed for jmping flag m_animTickJump = Environment.TickCount; - vj.Z = 0.35f; -m_jumpVelocity = 0.35f; - vj += actor.Velocity; -// #@ actor.Velocity = vj; + m_jumpVelocity = 0.35f; return "PREJUMP"; } @@ -274,8 +287,9 @@ m_jumpVelocity = 0.35f; //Console.WriteLine("LA {0}", jumptime); //## // end jumping m_jumping = false; + m_falling = false; actor.Selected = false; // borrowed for jumping flag -m_jumpVelocity = 0f; + m_jumpVelocity = 0f; m_animTickFall = Environment.TickCount; return "LAND"; } @@ -283,10 +297,7 @@ m_jumpVelocity = 0f; { //Console.WriteLine("JD {0}", jumptime); //## // jump down - vj = actor.Velocity; - vj.Z = 0f; -m_jumpVelocity = 0f; -// #@ actor.Velocity = vj; + m_jumpVelocity = 0f; return "JUMP"; } else if (jumptime > PREJUMP_DELAY) @@ -294,11 +305,7 @@ m_jumpVelocity = 0f; //Console.WriteLine("JU {0}", jumptime); //## // jump up m_jumping = true; - vj.Z = 10f; -m_jumpVelocity = 10f; - vj.X = actor.Velocity.X; - vj.Y = actor.Velocity.Y; -// #@ actor.Velocity = vj; + m_jumpVelocity = 10f; return "JUMP"; } } @@ -309,29 +316,37 @@ m_jumpVelocity = 10f; if (m_movementAnimation == "FALLDOWN") { + m_falling = false; m_animTickFall = Environment.TickCount; - // TODO: SOFT_LAND support - return "LAND"; + float fallHeight = m_fallHeight - actor.Position.Z; +//Console.WriteLine("Hit from {0}", fallHeight); //## + if (fallHeight > 15.0f) // add for falling + return "STANDUP"; + else if (fallHeight > 8.0f) // add for falling + return "SOFT_LAND"; // add for falling + else // add for falling + return "LAND"; // add for falling } - else if (m_movementAnimation == "LAND") - { // rm jumping float landElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; - int landElapsed = Environment.TickCount - m_animTickFall; // add for jumping // rm jumping if ((m_animTickFall != 0) && (landElapsed <= FALL_DELAY)) -/* Try change ## - if ((m_animTickFall != 0) && (landElapsed <= 500)) // add for jumping - return "LAND"; - */ - // NB if this is set too long a weird anim reset from some place prevents STAND from being sent to client - if ((m_animTickFall != 0) && (landElapsed <= 300)) // add for jumping +// rm for landing return "LAND"; + else if ((m_movementAnimation == "LAND") || (m_movementAnimation == "SOFT_LAND") || (m_movementAnimation == "STANDUP")) + { + int landElapsed = Environment.TickCount - m_animTickFall; // add for jumping + int limit = 1000; // add for jumping + if(m_movementAnimation == "LAND") limit = 350; // add for jumping + // 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)) // add for jumping { -//Console.WriteLine("LAND"); //## - return "LAND"; +//Console.WriteLine("Lelapse {0}", m_movementAnimation); //## + return m_movementAnimation; } else { -//Console.WriteLine("STAND"); //## +//Console.WriteLine("end/STAND"); //## + m_fallHeight = actor.Position.Z; // save latest flying height return "STAND"; } } @@ -369,6 +384,8 @@ m_jumpVelocity = 10f; // 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; // Add for falling // Walking / crouchwalking / running if (move.Z < 0f) return "CROUCHWALK"; @@ -380,6 +397,7 @@ m_jumpVelocity = 10f; // rm for jumping else else if (!m_jumping) // add for jumping { + m_falling = false; // Add for falling // Not walking if (move.Z < 0f) return "CROUCH"; @@ -389,6 +407,7 @@ m_jumpVelocity = 10f; // end section realign for jumping #endregion Ground Movement + m_falling = false; // Add for falling return m_movementAnimation; } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 2ed00a0..faf6354 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2568,9 +2568,11 @@ namespace OpenSim.Region.Framework.Scenes if (actor != null) { - if (actor.Flying) +// rm falling if (actor.Flying) + if ((actor.Flying) || Animator.m_falling) // add for falling lateral speed { - direc *= 4.0f; +// rm speed mod direc *= 4.0f; + direc *= 5.2f; // for speed mod //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); //bool colliding = (m_physicsActor.IsColliding==true); //if (controlland) diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs index 0c79aa6..ae63cfa 100644 --- a/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs @@ -269,7 +269,10 @@ namespace OpenSim.Region.Physics.OdePlugin /// public override bool IsColliding { - get { return m_iscolliding; } +//#@ get { return m_iscolliding; } + get { //## +//Console.WriteLine(">>>>>>>>>>>> IC get = {0}", m_iscolliding); //## + return m_iscolliding; } //## set { int i; @@ -307,6 +310,7 @@ namespace OpenSim.Region.Physics.OdePlugin { m_iscolliding = true; } +// ## Console.WriteLine("IC SET = {0} t{1} f{2} i {3}", value, truecount, falsecount, m_iscolliding); if (m_wascolliding != m_iscolliding) { //base.SendCollisionUpdate(new CollisionEventUpdate()); @@ -589,7 +593,7 @@ namespace OpenSim.Region.Physics.OdePlugin Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH); _parent_scene.geom_name_map[Shell] = m_name; _parent_scene.actor_name_map[Shell] = (PhysicsActor)this; -//Console.WriteLine("**** Create {2} Dicts: actor={0} name={1}", _parent_scene.actor_name_map.Count, _parent_scene.geom_name_map.Count, m_name); +Console.WriteLine("**** Create {2} Dicts: actor={0} name={1} height={3} rad={4}", _parent_scene.actor_name_map.Count, _parent_scene.geom_name_map.Count, m_name, CAPSULE_LENGTH, CAPSULE_RADIUS); d.GeomSetCategoryBits(Shell, (int)m_collisionCategories); d.GeomSetCollideBits(Shell, (int)m_collisionFlags); @@ -857,7 +861,9 @@ namespace OpenSim.Region.Physics.OdePlugin { m_pidControllerActive = false; force *= 100f; - doForce(force); +//Console.WriteLine("DF 1"); // ## + if (!force.ApproxEquals(Vector3.Zero, 0.01f)) + doForce(force); // If uncommented, things get pushed off world // // m_log.Debug("Push!"); @@ -896,7 +902,8 @@ namespace OpenSim.Region.Physics.OdePlugin d.BodyAddForce(Body, force.X, force.Y, force.Z); //d.BodySetRotation(Body, ref m_StandUpRotation); //standupStraight(); - + d.Vector3 vel = d.BodyGetLinearVel(Body); //## +//Console.WriteLine("AvVel <{0},{1},{2}>", vel.X, vel.Y, vel.Z); //## } } @@ -1103,12 +1110,14 @@ namespace OpenSim.Region.Physics.OdePlugin } if (vec.IsFinite()) { - if (!vec.ApproxEquals(Vector3.Zero, 0.01f)) + if (!vec.ApproxEquals(Vector3.Zero, 0.02f)) // 0.01 allows 0.002 !! { +//Console.WriteLine("DF 2"); // ## + doForce(vec); if (!_zeroFlag) { - AlignAvatarTiltWithCurrentDirectionOfMovement(vec); +// AlignAvatarTiltWithCurrentDirectionOfMovement(vec); } } } diff --git a/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs index ab084fd..86f9893 100644 --- a/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs @@ -713,7 +713,7 @@ namespace OpenSim.Region.Physics.OdePlugin // Test if we're colliding a geom with a space. // If so we have to drill down into the space recursively - +//Console.WriteLine("near -----------"); //## if (d.GeomIsSpace(g1) || d.GeomIsSpace(g2)) { if (g1 == IntPtr.Zero || g2 == IntPtr.Zero) @@ -844,11 +844,21 @@ namespace OpenSim.Region.Physics.OdePlugin // Testing if the collision is at the feet of the avatar //m_log.DebugFormat("[PHYSICS]: {0} - {1} - {2} - {3}", curContact.pos.Z, p2.Position.Z, (p2.Position.Z - curContact.pos.Z), (p2.Size.Z * 0.6f)); - if ((p2.Position.Z - curContact.pos.Z) > (p2.Size.Z * 0.6f)) - p2.IsColliding = true; - } +//#@ if ((p2.Position.Z - curContact.pos.Z) > (p2.Size.Z * 0.6f)) +//#@ p2.IsColliding = true; + if ((p2.Position.Z - curContact.pos.Z) > (p2.Size.Z * 0.6f)){ //## +//Console.WriteLine("AvColl 1 {0} - {1} - {2} - {3}", //## +// curContact.pos.Z, p2.Position.Z, (p2.Position.Z - curContact.pos.Z), (p2.Size.Z * 0.6f)); //## + p2.IsColliding = true; //## + }else{ +//Console.WriteLine("AvColl 2 {0} - {1} - {2} - {3}", //## +// curContact.pos.Z, p2.Position.Z, (p2.Position.Z - curContact.pos.Z), (p2.Size.Z * 0.6f)); //## + + } //## + } else { +//Console.WriteLine("AvColl 3 {0}", p2.PhysicsActorType); //## p2.IsColliding = true; } -- cgit v1.1