From d21601d497e81108860e880653757dc3773cdb47 Mon Sep 17 00:00:00 2001 From: Dahlia Trimble Date: Thu, 12 Feb 2009 07:58:10 +0000 Subject: [PATCH] Thanks Kitto Flora for a patch that adds automatic min fly height to ODE - Mantis #3134 --- CONTRIBUTORS.txt | 1 + .../Region/Physics/OdePlugin/ODECharacter.cs | 12 +++++++++++- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 18 ++++++++++-------- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index ea32241a57..e214720957 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -61,6 +61,7 @@ Patches * Kayne * Kevin Cozens * kinoc (Daxtron Labs) +* Kitto Flora * krtaylor (IBM) * lulurun * M.Igarashi diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index 2cdc988650..b2981fe8d8 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -832,8 +832,18 @@ namespace OpenSim.Region.Physics.OdePlugin if (flying) { vec.Z += ((-1 * _parent_scene.gravityz)*m_mass); - } + //Added for auto fly height. Kitto Flora + d.Vector3 pos = d.BodyGetPosition(Body); + float ground_height = _parent_scene.GetTerrainHeightAtXY(pos.X, pos.Y); + float target_altitude = ground_height + 3.0f; // This is the min fly height + if(pos.Z < target_altitude) + { + vec.Z += (target_altitude - pos.Z) * PID_P * 5.0f; + } + // end add Kitto Flora + + } doForce(vec); } diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index d7d471f1d6..0f18be4ab8 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -1,3 +1,4 @@ + /* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. @@ -205,7 +206,7 @@ namespace OpenSim.Region.Physics.OdePlugin private float[] _watermap; private bool m_filterCollisions = true; - // private float[] _origheightmap; + private float[] _origheightmap; // Used for Fly height. Kitto Flora private d.NearCallback nearCallback; public d.TriCallback triCallback; @@ -1284,12 +1285,13 @@ namespace OpenSim.Region.Physics.OdePlugin } #endregion - -// TODO: unused -// private float GetTerrainHeightAtXY(float x, float y) -// { -// return (float)_origheightmap[(int)y * Constants.RegionSize + (int)x]; -// } + +// Recovered for use by fly height. Kitto Flora + public float GetTerrainHeightAtXY(float x, float y) + { + return (float)_origheightmap[(int)y * Constants.RegionSize + (int)x]; + } +// End recovered. Kitto Flora public void addCollisionEventReporting(PhysicsActor obj) { @@ -2958,7 +2960,7 @@ namespace OpenSim.Region.Physics.OdePlugin { // this._heightmap[i] = (double)heightMap[i]; // dbm (danx0r) -- creating a buffer zone of one extra sample all around - // _origheightmap = heightMap; + _origheightmap = heightMap; // Used for Fly height. Kitto Flora const uint heightmapWidth = m_regionWidth + 2; const uint heightmapHeight = m_regionHeight + 2; const uint heightmapWidthSamples = 2*m_regionWidth + 2;