From 10b41ba4554e3a13796cc3b55663e373f12af2cb Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Tue, 13 Nov 2007 05:10:14 +0000 Subject: [PATCH] * Fixed the walk vs fall animation. * Tweaked a few things --- .../Environment/Scenes/ScenePresence.cs | 10 +-- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 68 ++++++++++++++++++- 2 files changed, 71 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 69bf05a74b..48f3ef0dec 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -458,7 +458,7 @@ namespace OpenSim.Region.Environment.Scenes + (((float)m_visualParams[125] / 255.0f) / 1.5f); if (PhysicsActor != null) { - PhysicsVector SetSize = new PhysicsVector(0, 0, m_avHeight); + PhysicsVector SetSize = new PhysicsVector(0.45f, 0.6f, m_avHeight); PhysicsActor.Size = SetSize; } //OpenSim.Framework.Console.MainLog.Instance.Verbose("CLIENT", "Set Avatar Height to: " + (1.50856f + (((float)m_visualParams[25] / 255.0f) * (2.525506f - 1.50856f))).ToString() + "m" + " Leglength: " + ((float)m_visualParams[125]).ToString() + ":" + (((float)m_visualParams[125] / 255.0f)).ToString() + "m"); @@ -681,11 +681,11 @@ namespace OpenSim.Region.Environment.Scenes } else { - if (!PhysicsActor.IsColliding && m_physicsActor.Velocity.Z > 6) + if (!PhysicsActor.IsColliding && m_physicsActor.Velocity.Z < -6) { SendAnimPack(Animations.AnimsLLUUID["FALLDOWN"], 1); } - else if (!PhysicsActor.IsColliding && Velocity.Z > 0) + else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && (m_movementflag & (uint) MainAvatar.ControlFlags.AGENT_CONTROL_UP_POS) != 0) { SendAnimPack(Animations.AnimsLLUUID["JUMP"], 1); } @@ -716,11 +716,11 @@ namespace OpenSim.Region.Environment.Scenes } else { - if (!PhysicsActor.IsColliding && m_physicsActor.Velocity.Z > 6 && !m_physicsActor.Flying) + if (!PhysicsActor.IsColliding && m_physicsActor.Velocity.Z < -6 && !m_physicsActor.Flying) { SendAnimPack(Animations.AnimsLLUUID["FALLDOWN"], 1); } - else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && !m_physicsActor.Flying) + else if (!PhysicsActor.IsColliding && Velocity.Z > 0 && !m_physicsActor.Flying && (m_movementflag & (uint) MainAvatar.ControlFlags.AGENT_CONTROL_UP_POS) != 0) { SendAnimPack(Animations.AnimsLLUUID["JUMP"], 1); } diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index a39746776a..7eca7edf15 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -659,11 +659,17 @@ namespace OpenSim.Region.Physics.OdePlugin public float CAPSULE_LENGTH = 0.79f; private bool flying = false; private bool m_iscolliding = false; + private bool m_iscollidingGround = false; private bool m_wascolliding = false; + private bool m_wascollidingGround = false; private bool m_alwaysRun = false; + private bool m_hackSentFall = false; + private bool m_hackSentFly = false; private string m_name = ""; private bool[] m_colliderarr = new bool[11]; + private bool[] m_colliderGroundarr = new bool[11]; + private bool jumping = false; //private float gravityAccel; @@ -775,8 +781,50 @@ namespace OpenSim.Region.Physics.OdePlugin } public override bool CollidingGround { - get { return false; } - set { return; } + get { return m_iscollidingGround; } + set + { + int i; + int truecount = 0; + int falsecount = 0; + + if (m_colliderGroundarr.Length >= 10) + { + for (i = 0; i < 10; i++) + { + m_colliderGroundarr[i] = m_colliderGroundarr[i + 1]; + } + } + m_colliderGroundarr[10] = value; + + for (i = 0; i < 11; i++) + { + if (m_colliderGroundarr[i]) + { + truecount++; + } + else + { + falsecount++; + } + } + + // Equal truecounts and false counts means we're colliding with something. + + if (falsecount > 1.2 * truecount) + { + m_iscollidingGround = false; + } + else + { + m_iscollidingGround = true; + } + if (m_wascollidingGround != m_iscollidingGround) + { + //base.SendCollisionUpdate(new CollisionEventUpdate()); + } + m_wascollidingGround = m_iscollidingGround; + } } public override bool CollidingObj { @@ -1017,7 +1065,23 @@ namespace OpenSim.Region.Physics.OdePlugin vec = d.BodyGetLinearVel(Body); _velocity.X = (vec.X); _velocity.Y = (vec.Y); + _velocity.Z = (vec.Z); + if (_velocity.Z < -6 && !m_hackSentFall) + { + m_hackSentFall = true; + base.SendCollisionUpdate(new CollisionEventUpdate()); + } + else if (flying && !m_hackSentFly) + { + //m_hackSentFly = true; + //base.SendCollisionUpdate(new CollisionEventUpdate()); + } + else + { + m_hackSentFly = false; + m_hackSentFall = false; + } } }