diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 29 |
1 files changed, 13 insertions, 16 deletions
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 | |||
2793 | } | 2793 | } |
2794 | } | 2794 | } |
2795 | 2795 | ||
2796 | /// <summary> | ||
2797 | /// Attempt to clamp the object on the Z axis at the given height over tau seconds. | ||
2798 | /// </summary> | ||
2799 | /// <param name="height">Height to hover. Height of zero disables hover.</param> | ||
2800 | /// <param name="water">False if height is calculated just from ground, otherwise uses ground or water depending on whichever is higher</param> | ||
2801 | /// <param name="tau">Number of seconds over which to reach target</param> | ||
2796 | public void llSetHoverHeight(double height, int water, double tau) | 2802 | public void llSetHoverHeight(double height, int water, double tau) |
2797 | { | 2803 | { |
2798 | m_host.AddScriptLPS(1); | 2804 | m_host.AddScriptLPS(1); |
2799 | Vector3 pos = m_host.GetWorldPosition(); | 2805 | if (m_host.PhysActor != null) |
2800 | int x = (int)(pos.X); | ||
2801 | int y = (int)(pos.Y); | ||
2802 | float landHeight = (float)World.Heightmap[x, y]; | ||
2803 | float targetHeight = landHeight + (float)height; | ||
2804 | if (water == 1) | ||
2805 | { | 2806 | { |
2806 | float waterHeight = (float)World.RegionInfo.RegionSettings.WaterHeight; | 2807 | PIDHoverType hoverType = PIDHoverType.Ground; |
2807 | if (waterHeight > targetHeight) | 2808 | if (water == 1) |
2808 | { | 2809 | { |
2809 | targetHeight = waterHeight + (float)height; | 2810 | hoverType = PIDHoverType.GroundAndWater; |
2810 | } | 2811 | } |
2811 | } | 2812 | |
2812 | if (m_host.PhysActor != null) | 2813 | m_host.SetHoverHeight((float)height, hoverType, (float)tau); |
2813 | { | ||
2814 | m_host.MoveToTarget(new Vector3(pos.X, pos.Y, targetHeight), (float)tau); | ||
2815 | m_host.PhysActor.Flying = true; | ||
2816 | } | 2814 | } |
2817 | } | 2815 | } |
2818 | 2816 | ||
@@ -2821,8 +2819,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2821 | m_host.AddScriptLPS(1); | 2819 | m_host.AddScriptLPS(1); |
2822 | if (m_host.PhysActor != null) | 2820 | if (m_host.PhysActor != null) |
2823 | { | 2821 | { |
2824 | m_host.PhysActor.Flying = false; | 2822 | m_host.SetHoverHeight(0f, PIDHoverType.Ground, 0f); |
2825 | m_host.PhysActor.PIDActive = false; | ||
2826 | } | 2823 | } |
2827 | } | 2824 | } |
2828 | 2825 | ||