From d9d35f9fd7141d8f7a5b3b056cae051d6de2efd5 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Mon, 12 Nov 2007 23:46:26 +0000 Subject: * Implemented Walk Vs Run in ODE. Also helps make the walk look smoother. * All thanks to unimplemented packet listing :D --- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Physics/OdePlugin') diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index c93b96f..b528b9b 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -660,6 +660,7 @@ namespace OpenSim.Region.Physics.OdePlugin private bool flying = false; private bool m_iscolliding = false; private bool m_wascolliding = false; + private bool m_alwaysRun = false; private bool[] m_colliderarr = new bool[11]; @@ -702,6 +703,11 @@ namespace OpenSim.Region.Physics.OdePlugin get { return (int)ActorTypes.Agent; } set { return; } } + public override bool SetAlwaysRun + { + get { return m_alwaysRun; } + set { m_alwaysRun = value;} + } public override bool IsPhysical { get { return false; } @@ -876,6 +882,17 @@ namespace OpenSim.Region.Physics.OdePlugin // no lock; for now it's only called from within Simulate() PhysicsVector vec = new PhysicsVector(); d.Vector3 vel = d.BodyGetLinearVel(Body); + float movementdivisor = 1f; + + if (!m_alwaysRun) + { + movementdivisor = 10.5f; + } + else + { + movementdivisor = 0.2079f; + + } // if velocity is zero, use position control; otherwise, velocity control if (_target_velocity.X == 0.0f && _target_velocity.Y == 0.0f && _target_velocity.Z == 0.0f && m_iscolliding) @@ -900,8 +917,9 @@ namespace OpenSim.Region.Physics.OdePlugin _zeroFlag = false; if (m_iscolliding || flying) { - vec.X = (_target_velocity.X - vel.X) * PID_D; - vec.Y = (_target_velocity.Y - vel.Y) * PID_D; + + vec.X = ((_target_velocity.X - vel.X)/movementdivisor) * PID_D; + vec.Y = ((_target_velocity.Y - vel.Y)/movementdivisor) * PID_D; } if (m_iscolliding && !flying && _target_velocity.Z > 0.0f) { @@ -1077,6 +1095,11 @@ namespace OpenSim.Region.Physics.OdePlugin get { return (int)ActorTypes.Prim; } set { return; } } + public override bool SetAlwaysRun + { + get { return false; } + set { return; } + } public void enableBody() { // Sets the geom to a body -- cgit v1.1