From 19bd27071a05513584d977104a57e562f2a63232 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Fri, 18 Jul 2014 18:13:38 +0100 Subject: [PATCH] refactor: slightly adjust some code in ODECharacter.Move() to eliminate a condition check without changing the logic --- .../Region/Physics/OdePlugin/ODECharacter.cs | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index 2fac33fe65..7df74f3ec6 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -890,29 +890,30 @@ namespace OpenSim.Region.Physics.OdePlugin // vec, _target_velocity, movementdivisor, vel); } - if (m_iscolliding && !flying && _target_velocity.Z > 0.0f) - { - // We're colliding with something and we're not flying but we're moving - // This means we're walking or running. - d.Vector3 pos = d.BodyGetPosition(Body); - vec.Z = (_target_velocity.Z - vel.Z) * PID_D + (_zeroPosition.Z - pos.Z) * PID_P; - vec.X = ((_target_velocity.X - vel.X) / 1.2f) * PID_D; - vec.Y = ((_target_velocity.Y - vel.Y) / 1.2f) * PID_D; - } - else if (!m_iscolliding && !flying) - { - // we're not colliding and we're not flying so that means we're falling! - // m_iscolliding includes collisions with the ground. - - vec.X = ((_target_velocity.X - vel.X) / 1.2f) * PID_D; - vec.Y = ((_target_velocity.Y - vel.Y) / 1.2f) * PID_D; - } - if (flying) { // This also acts as anti-gravity so that we hover when flying rather than fall. vec.Z = (_target_velocity.Z - vel.Z) * (PID_D); } + else + { + if (m_iscolliding && _target_velocity.Z > 0.0f) + { + // We're colliding with something and we're not flying but we're moving + // This means we're walking or running. + d.Vector3 pos = d.BodyGetPosition(Body); + vec.Z = (_target_velocity.Z - vel.Z) * PID_D + (_zeroPosition.Z - pos.Z) * PID_P; + vec.X = ((_target_velocity.X - vel.X) / 1.2f) * PID_D; + vec.Y = ((_target_velocity.Y - vel.Y) / 1.2f) * PID_D; + } + else if (!m_iscolliding) + { + // we're not colliding and we're not flying so that means we're falling! + // m_iscolliding includes collisions with the ground. + vec.X = ((_target_velocity.X - vel.X) / 1.2f) * PID_D; + vec.Y = ((_target_velocity.Y - vel.Y) / 1.2f) * PID_D; + } + } } if (flying)