From e48fa38ff581bd1125b9582ed3efc875f723ae86 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 27 Apr 2012 23:18:54 +0100 Subject: Oooops don't hover underground but do hover --- .../Region/Physics/UbitOdePlugin/ODEDynamics.cs | 53 +++++++++++----------- 1 file changed, 27 insertions(+), 26 deletions(-) (limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs') diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs index 53a576e..d106677 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs @@ -773,39 +773,40 @@ namespace OpenSim.Region.Physics.OdePlugin d.Vector3 pos = d.BodyGetPosition(Body); float t = _pParentScene.GetTerrainHeightAtXY(pos.X, pos.Y); + float perr; - if (t < m_VhoverHeight) // don't go underground - { - // default to global - float perr = m_VhoverHeight - pos.Z; ; + // default to global but don't go underground + if (t < m_VhoverHeight) + perr = m_VhoverHeight - pos.Z; + else + perr = t - pos.Z; ; - if ((m_flags & VehicleFlag.HOVER_GLOBAL_HEIGHT) == 0) + if ((m_flags & VehicleFlag.HOVER_GLOBAL_HEIGHT) == 0) + { + if ((m_flags & VehicleFlag.HOVER_WATER_ONLY) != 0) { - if ((m_flags & VehicleFlag.HOVER_WATER_ONLY) != 0) - { - perr += _pParentScene.GetWaterLevel(); - } - else if ((m_flags & VehicleFlag.HOVER_TERRAIN_ONLY) != 0) - { - perr += t; - } - else - { - float w = _pParentScene.GetWaterLevel(); - if (t > w) - perr += t; - else - perr += w; - } + perr += _pParentScene.GetWaterLevel(); } - if ((m_flags & VehicleFlag.HOVER_UP_ONLY) == 0 || perr > 0) + else if ((m_flags & VehicleFlag.HOVER_TERRAIN_ONLY) != 0) { - force.Z += (perr / m_VhoverTimescale / m_VhoverTimescale - curVel.Z * m_VhoverEfficiency) / m_timestep; - force.Z += _pParentScene.gravityz * (1f - m_VehicleBuoyancy); + perr += t; } - else // no buoyancy - force.Z += _pParentScene.gravityz; + else + { + float w = _pParentScene.GetWaterLevel(); + if (t > w) + perr += t; + else + perr += w; + } + } + if ((m_flags & VehicleFlag.HOVER_UP_ONLY) == 0 || perr > 0) + { + force.Z += (perr / m_VhoverTimescale / m_VhoverTimescale - curVel.Z * m_VhoverEfficiency) / m_timestep; + force.Z += _pParentScene.gravityz * (1f - m_VehicleBuoyancy); } + else // no buoyancy + force.Z += _pParentScene.gravityz; } else { -- cgit v1.1