From b637a11b58292cb6165317b317dc077a79ee6779 Mon Sep 17 00:00:00 2001
From: Charles Krinke
Date: Fri, 6 Mar 2009 23:01:35 +0000
Subject: Fixes Mantis #3260. Thank you kindly, MCortez for a patch that:
llSetHoverHeight() should not clamp the x/y position of an object the way
MoveTo does, and it should recalculate the absolute height to hover at as an
object moves to reflect the current ground/water height under it. Correctly
implementing required adjusting the Physics interfaces and implementing at
the physics plug-in level. The attached is a patch that correctly implements
llSetHoverHeight() including updates to the ODE physics plug-in.
---
.../Shared/Api/Implementation/LSL_Api.cs | 29 ++++++++++------------
1 file changed, 13 insertions(+), 16 deletions(-)
(limited to 'OpenSim/Region/ScriptEngine')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 517453e..62b52f2 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2793,26 +2793,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
+ ///
+ /// Attempt to clamp the object on the Z axis at the given height over tau seconds.
+ ///
+ /// Height to hover. Height of zero disables hover.
+ /// False if height is calculated just from ground, otherwise uses ground or water depending on whichever is higher
+ /// Number of seconds over which to reach target
public void llSetHoverHeight(double height, int water, double tau)
{
m_host.AddScriptLPS(1);
- Vector3 pos = m_host.GetWorldPosition();
- int x = (int)(pos.X);
- int y = (int)(pos.Y);
- float landHeight = (float)World.Heightmap[x, y];
- float targetHeight = landHeight + (float)height;
- if (water == 1)
+ if (m_host.PhysActor != null)
{
- float waterHeight = (float)World.RegionInfo.RegionSettings.WaterHeight;
- if (waterHeight > targetHeight)
+ PIDHoverType hoverType = PIDHoverType.Ground;
+ if (water == 1)
{
- targetHeight = waterHeight + (float)height;
+ hoverType = PIDHoverType.GroundAndWater;
}
- }
- if (m_host.PhysActor != null)
- {
- m_host.MoveToTarget(new Vector3(pos.X, pos.Y, targetHeight), (float)tau);
- m_host.PhysActor.Flying = true;
+
+ m_host.SetHoverHeight((float)height, hoverType, (float)tau);
}
}
@@ -2821,8 +2819,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1);
if (m_host.PhysActor != null)
{
- m_host.PhysActor.Flying = false;
- m_host.PhysActor.PIDActive = false;
+ m_host.SetHoverHeight(0f, PIDHoverType.Ground, 0f);
}
}
--
cgit v1.1