Thanks Kitto Flora for a patch that adds automatic min fly height to ODE - Mantis #3134

0.6.3-post-fixes
Dahlia Trimble 2009-02-12 07:58:10 +00:00
parent 4ee99e2aab
commit d21601d497
3 changed files with 22 additions and 9 deletions

View File

@ -61,6 +61,7 @@ Patches
* Kayne * Kayne
* Kevin Cozens * Kevin Cozens
* kinoc (Daxtron Labs) * kinoc (Daxtron Labs)
* Kitto Flora
* krtaylor (IBM) * krtaylor (IBM)
* lulurun * lulurun
* M.Igarashi * M.Igarashi

View File

@ -832,8 +832,18 @@ namespace OpenSim.Region.Physics.OdePlugin
if (flying) if (flying)
{ {
vec.Z += ((-1 * _parent_scene.gravityz)*m_mass); 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); doForce(vec);
} }

View File

@ -1,3 +1,4 @@
/* /*
* Copyright (c) Contributors, http://opensimulator.org/ * Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders. * See CONTRIBUTORS.TXT for a full list of copyright holders.
@ -205,7 +206,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private float[] _watermap; private float[] _watermap;
private bool m_filterCollisions = true; private bool m_filterCollisions = true;
// private float[] _origheightmap; private float[] _origheightmap; // Used for Fly height. Kitto Flora
private d.NearCallback nearCallback; private d.NearCallback nearCallback;
public d.TriCallback triCallback; public d.TriCallback triCallback;
@ -1285,11 +1286,12 @@ namespace OpenSim.Region.Physics.OdePlugin
#endregion #endregion
// TODO: unused // Recovered for use by fly height. Kitto Flora
// private float GetTerrainHeightAtXY(float x, float y) public float GetTerrainHeightAtXY(float x, float y)
// { {
// return (float)_origheightmap[(int)y * Constants.RegionSize + (int)x]; return (float)_origheightmap[(int)y * Constants.RegionSize + (int)x];
// } }
// End recovered. Kitto Flora
public void addCollisionEventReporting(PhysicsActor obj) public void addCollisionEventReporting(PhysicsActor obj)
{ {
@ -2958,7 +2960,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
// this._heightmap[i] = (double)heightMap[i]; // this._heightmap[i] = (double)heightMap[i];
// dbm (danx0r) -- creating a buffer zone of one extra sample all around // 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 heightmapWidth = m_regionWidth + 2;
const uint heightmapHeight = m_regionHeight + 2; const uint heightmapHeight = m_regionHeight + 2;
const uint heightmapWidthSamples = 2*m_regionWidth + 2; const uint heightmapWidthSamples = 2*m_regionWidth + 2;