aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorCharles Krinke2009-03-06 23:01:35 +0000
committerCharles Krinke2009-03-06 23:01:35 +0000
commitb637a11b58292cb6165317b317dc077a79ee6779 (patch)
tree18d9b2e82ae782fec726f3baa2d60c76433a7406
parentadd back .config files for all tests in an attempt to debug why these (diff)
downloadopensim-SC_OLD-b637a11b58292cb6165317b317dc077a79ee6779.zip
opensim-SC_OLD-b637a11b58292cb6165317b317dc077a79ee6779.tar.gz
opensim-SC_OLD-b637a11b58292cb6165317b317dc077a79ee6779.tar.bz2
opensim-SC_OLD-b637a11b58292cb6165317b317dc077a79ee6779.tar.xz
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.
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs31
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs17
-rw-r--r--OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs8
-rw-r--r--OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs7
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsActor.cs26
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODECharacter.cs7
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs101
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs5
-rw-r--r--OpenSim/Region/Physics/POSPlugin/POSCharacter.cs6
-rw-r--r--OpenSim/Region/Physics/POSPlugin/POSPrim.cs6
-rw-r--r--OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs13
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs29
12 files changed, 238 insertions, 18 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 4f61342..a88f8a9 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1617,6 +1617,37 @@ namespace OpenSim.Region.Framework.Scenes
1617 } 1617 }
1618 1618
1619 /// <summary> 1619 /// <summary>
1620 /// Uses a PID to attempt to clamp the object on the Z axis at the given height over tau seconds.
1621 /// </summary>
1622 /// <param name="height">Height to hover. Height of zero disables hover.</param>
1623 /// <param name="hoverType">Determines what the height is relative to </param>
1624 /// <param name="tau">Number of seconds over which to reach target</param>
1625 public void SetHoverHeight(float height, PIDHoverType hoverType, float tau)
1626 {
1627 SceneObjectPart rootpart = m_rootPart;
1628 if (rootpart != null)
1629 {
1630 if (rootpart.PhysActor != null)
1631 {
1632 if (height != 0f)
1633 {
1634 rootpart.PhysActor.PIDHoverHeight = height;
1635 rootpart.PhysActor.PIDHoverType = hoverType;
1636 rootpart.PhysActor.PIDTau = tau;
1637 rootpart.PhysActor.PIDHoverActive = true;
1638 }
1639 else
1640 {
1641 rootpart.PhysActor.PIDHoverActive = false;
1642 }
1643 }
1644 }
1645 }
1646
1647
1648
1649
1650 /// <summary>
1620 /// Set the owner of the root part. 1651 /// Set the owner of the root part.
1621 /// </summary> 1652 /// </summary>
1622 /// <param name="part"></param> 1653 /// <param name="part"></param>
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index ede007e..4efadc3 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -1748,6 +1748,23 @@ if (m_shape != null) {
1748 } 1748 }
1749 } 1749 }
1750 1750
1751 /// <summary>
1752 /// Uses a PID to attempt to clamp the object on the Z axis at the given height over tau seconds.
1753 /// </summary>
1754 /// <param name="height">Height to hover. Height of zero disables hover.</param>
1755 /// <param name="hoverType">Determines what the height is relative to </param>
1756 /// <param name="tau">Number of seconds over which to reach target</param>
1757 public void SetHoverHeight(float height, PIDHoverType hoverType, float tau)
1758 {
1759 m_parentGroup.SetHoverHeight(height, hoverType, tau);
1760 }
1761
1762 public void StopHover()
1763 {
1764 m_parentGroup.SetHoverHeight(0f, PIDHoverType.Ground, 0f);
1765 }
1766
1767
1751 public virtual void OnGrab(Vector3 offsetPos, IClientAPI remoteClient) 1768 public virtual void OnGrab(Vector3 offsetPos, IClientAPI remoteClient)
1752 { 1769 {
1753 } 1770 }
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
index 3081077..284837b 100644
--- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
+++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs
@@ -447,9 +447,17 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
447 public override void CrossingFailure() 447 public override void CrossingFailure()
448 { 448 {
449 } 449 }
450
450 public override PhysicsVector PIDTarget { set { return; } } 451 public override PhysicsVector PIDTarget { set { return; } }
451 public override bool PIDActive { set { return; } } 452 public override bool PIDActive { set { return; } }
452 public override float PIDTau { set { return; } } 453 public override float PIDTau { set { return; } }
454
455 public override float PIDHoverHeight { set { return; } }
456 public override bool PIDHoverActive { set { return; } }
457 public override PIDHoverType PIDHoverType { set { return; } }
458 public override float PIDHoverTau { set { return; } }
459
460
453 public override void SubscribeEvents(int ms) 461 public override void SubscribeEvents(int ms)
454 { 462 {
455 463
diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
index 8891163..ea72c8c 100644
--- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
+++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs
@@ -1225,6 +1225,13 @@ namespace OpenSim.Region.Physics.BulletXPlugin
1225 public override PhysicsVector PIDTarget { set { return; } } 1225 public override PhysicsVector PIDTarget { set { return; } }
1226 public override bool PIDActive { set { return; } } 1226 public override bool PIDActive { set { return; } }
1227 public override float PIDTau { set { return; } } 1227 public override float PIDTau { set { return; } }
1228
1229 public override float PIDHoverHeight { set { return; } }
1230 public override bool PIDHoverActive { set { return; } }
1231 public override PIDHoverType PIDHoverType { set { return; } }
1232 public override float PIDHoverTau { set { return; } }
1233
1234
1228 public override void SubscribeEvents(int ms) 1235 public override void SubscribeEvents(int ms)
1229 { 1236 {
1230 1237
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
index 0f75c46..c4bb889 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs
@@ -44,6 +44,14 @@ namespace OpenSim.Region.Physics.Manager
44 Ground = 3 44 Ground = 3
45 } 45 }
46 46
47 public enum PIDHoverType
48 {
49 Ground
50 , GroundAndWater
51 , Water
52 , Absolute
53 }
54
47 public class CollisionEventUpdate : EventArgs 55 public class CollisionEventUpdate : EventArgs
48 { 56 {
49 // Raising the event on the object, so don't need to provide location.. further up the tree knows that info. 57 // Raising the event on the object, so don't need to provide location.. further up the tree knows that info.
@@ -204,9 +212,20 @@ namespace OpenSim.Region.Physics.Manager
204 public abstract PhysicsVector RotationalVelocity { get; set; } 212 public abstract PhysicsVector RotationalVelocity { get; set; }
205 public abstract bool Kinematic { get; set; } 213 public abstract bool Kinematic { get; set; }
206 public abstract float Buoyancy { get; set; } 214 public abstract float Buoyancy { get; set; }
215
216 // Used for MoveTo
207 public abstract PhysicsVector PIDTarget { set;} 217 public abstract PhysicsVector PIDTarget { set;}
208 public abstract bool PIDActive { set;} 218 public abstract bool PIDActive { set;}
209 public abstract float PIDTau { set; } 219 public abstract float PIDTau { set; }
220
221 // Used for llSetHoverHeight and maybe vehicle height
222 // Hover Height will override MoveTo target's Z
223 public abstract bool PIDHoverActive { set;}
224 public abstract float PIDHoverHeight { set;}
225 public abstract PIDHoverType PIDHoverType { set;}
226 public abstract float PIDHoverTau { set;}
227
228
210 public abstract void AddForce(PhysicsVector force, bool pushforce); 229 public abstract void AddForce(PhysicsVector force, bool pushforce);
211 public abstract void AddAngularForce(PhysicsVector force, bool pushforce); 230 public abstract void AddAngularForce(PhysicsVector force, bool pushforce);
212 public abstract void SetMomentum(PhysicsVector momentum); 231 public abstract void SetMomentum(PhysicsVector momentum);
@@ -430,6 +449,11 @@ namespace OpenSim.Region.Physics.Manager
430 public override bool PIDActive { set { return; } } 449 public override bool PIDActive { set { return; } }
431 public override float PIDTau { set { return; } } 450 public override float PIDTau { set { return; } }
432 451
452 public override float PIDHoverHeight { set { return; } }
453 public override bool PIDHoverActive { set { return; } }
454 public override PIDHoverType PIDHoverType { set { return; } }
455 public override float PIDHoverTau { set { return; } }
456
433 public override void SetMomentum(PhysicsVector momentum) 457 public override void SetMomentum(PhysicsVector momentum)
434 { 458 {
435 } 459 }
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index 9991ab1..a62409c 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -922,9 +922,16 @@ namespace OpenSim.Region.Physics.OdePlugin
922 public override void CrossingFailure() 922 public override void CrossingFailure()
923 { 923 {
924 } 924 }
925
925 public override PhysicsVector PIDTarget { set { return; } } 926 public override PhysicsVector PIDTarget { set { return; } }
926 public override bool PIDActive { set { return; } } 927 public override bool PIDActive { set { return; } }
927 public override float PIDTau { set { return; } } 928 public override float PIDTau { set { return; } }
929
930 public override float PIDHoverHeight { set { return; } }
931 public override bool PIDHoverActive { set { return; } }
932 public override PIDHoverType PIDHoverType { set { return; } }
933 public override float PIDHoverTau { set { return; } }
934
928 public override void SubscribeEvents(int ms) 935 public override void SubscribeEvents(int ms)
929 { 936 {
930 m_eventsubscription = ms; 937 m_eventsubscription = ms;
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index ae0bb11..f164048 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -69,11 +69,20 @@ namespace OpenSim.Region.Physics.OdePlugin
69 private float m_PIDTau = 0f; 69 private float m_PIDTau = 0f;
70 private float PID_D = 35f; 70 private float PID_D = 35f;
71 private float PID_G = 25f; 71 private float PID_G = 25f;
72 private bool m_usePID = false;
73
74 private float m_PIDHoverHeight = 0f;
75 private float m_PIDHoverTau = 0f;
76 private bool m_useHoverPID = false;
77 private PIDHoverType m_PIDHoverType = PIDHoverType.Ground;
78 private float m_targetHoverHeight = 0f;
79 private float m_groundHeight = 0f;
80 private float m_waterHeight = 0f;
81
72 private float m_tensor = 5f; 82 private float m_tensor = 5f;
73 private int body_autodisable_frames = 20; 83 private int body_autodisable_frames = 20;
74 private IMesh primMesh = null; 84 private IMesh primMesh = null;
75 85
76 private bool m_usePID = false;
77 86
78 private const CollisionCategories m_default_collisionFlags = (CollisionCategories.Geom 87 private const CollisionCategories m_default_collisionFlags = (CollisionCategories.Geom
79 | CollisionCategories.Space 88 | CollisionCategories.Space
@@ -1554,6 +1563,91 @@ namespace OpenSim.Region.Physics.OdePlugin
1554 } 1563 }
1555 } 1564 }
1556 1565
1566 // Hover PID Controller needs to be mutually exlusive to MoveTo PID controller
1567 if (m_useHoverPID && !m_usePID)
1568 {
1569 // If we're using the PID controller, then we have no gravity
1570 fz = (-1 * _parent_scene.gravityz) * m_mass;
1571
1572 // no lock; for now it's only called from within Simulate()
1573
1574 // If the PID Controller isn't active then we set our force
1575 // calculating base velocity to the current position
1576
1577 if ((m_PIDTau < 1))
1578 {
1579 PID_G = PID_G / m_PIDTau;
1580 }
1581
1582 if ((PID_G - m_PIDTau) <= 0)
1583 {
1584 PID_G = m_PIDTau + 1;
1585 }
1586
1587
1588 // Where are we, and where are we headed?
1589 d.Vector3 pos = d.BodyGetPosition(Body);
1590 d.Vector3 vel = d.BodyGetLinearVel(Body);
1591
1592 // determine what our target height really is based on HoverType
1593 switch (m_PIDHoverType)
1594 {
1595 case PIDHoverType.Absolute:
1596 m_targetHoverHeight = m_PIDHoverHeight;
1597 break;
1598 case PIDHoverType.Ground:
1599 m_groundHeight = _parent_scene.GetTerrainHeightAtXY(pos.X, pos.Y);
1600 m_targetHoverHeight = m_groundHeight + m_PIDHoverHeight;
1601 break;
1602 case PIDHoverType.GroundAndWater:
1603 m_groundHeight = _parent_scene.GetTerrainHeightAtXY(pos.X, pos.Y);
1604 m_waterHeight = _parent_scene.GetWaterLevel();
1605 if (m_groundHeight > m_waterHeight)
1606 {
1607 m_targetHoverHeight = m_groundHeight + m_PIDHoverHeight;
1608 }
1609 else
1610 {
1611 m_targetHoverHeight = m_waterHeight + m_PIDHoverHeight;
1612 }
1613 break;
1614 case PIDHoverType.Water:
1615 m_waterHeight = _parent_scene.GetWaterLevel();
1616 m_targetHoverHeight = m_waterHeight + m_PIDHoverHeight;
1617 break;
1618 }
1619
1620
1621 _target_velocity =
1622 new PhysicsVector(0.0f, 0.0f,
1623 (m_targetHoverHeight - pos.Z) * ((PID_G - m_PIDHoverTau) * timestep)
1624 );
1625
1626 // if velocity is zero, use position control; otherwise, velocity control
1627
1628 if (_target_velocity.IsIdentical(PhysicsVector.Zero, 0.1f))
1629 {
1630 // keep track of where we stopped. No more slippin' & slidin'
1631
1632 // We only want to deactivate the PID Controller if we think we want to have our surrogate
1633 // react to the physics scene by moving it's position.
1634 // Avatar to Avatar collisions
1635 // Prim to avatar collisions
1636
1637 d.BodySetPosition(Body, pos.X, pos.Y, m_targetHoverHeight);
1638 d.BodySetLinearVel(Body, vel.X, vel.Y, 0);
1639 d.BodyAddForce(Body, 0, 0, fz);
1640 return;
1641 }
1642 else
1643 {
1644 _zeroFlag = false;
1645
1646 // We're flying and colliding with something
1647 fz = fz + ((_target_velocity.Z - vel.Z) * (PID_D) * m_mass);
1648 }
1649 }
1650
1557 fx *= m_mass; 1651 fx *= m_mass;
1558 fy *= m_mass; 1652 fy *= m_mass;
1559 //fz *= m_mass; 1653 //fz *= m_mass;
@@ -2622,6 +2716,11 @@ namespace OpenSim.Region.Physics.OdePlugin
2622 public override bool PIDActive { set { m_usePID = value; } } 2716 public override bool PIDActive { set { m_usePID = value; } }
2623 public override float PIDTau { set { m_PIDTau = value; } } 2717 public override float PIDTau { set { m_PIDTau = value; } }
2624 2718
2719 public override float PIDHoverHeight { set { m_PIDHoverHeight = value; ; } }
2720 public override bool PIDHoverActive { set { m_useHoverPID = value; } }
2721 public override PIDHoverType PIDHoverType { set { m_PIDHoverType = value; } }
2722 public override float PIDHoverTau { set { m_PIDHoverTau = value; } }
2723
2625 private void createAMotor(PhysicsVector axis) 2724 private void createAMotor(PhysicsVector axis)
2626 { 2725 {
2627 if (Body == IntPtr.Zero) 2726 if (Body == IntPtr.Zero)
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index 359e7b3..b94f374 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -3031,6 +3031,11 @@ namespace OpenSim.Region.Physics.OdePlugin
3031 { 3031 {
3032 } 3032 }
3033 3033
3034 public float GetWaterLevel()
3035 {
3036 return waterlevel;
3037 }
3038
3034 public override void SetWaterLevel(float baseheight) 3039 public override void SetWaterLevel(float baseheight)
3035 { 3040 {
3036 waterlevel = baseheight; 3041 waterlevel = baseheight;
diff --git a/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs b/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs
index 4230a57..0320931 100644
--- a/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs
+++ b/OpenSim/Region/Physics/POSPlugin/POSCharacter.cs
@@ -288,6 +288,12 @@ namespace OpenSim.Region.Physics.POSPlugin
288 set { return; } 288 set { return; }
289 } 289 }
290 290
291 public override float PIDHoverHeight { set { return; } }
292 public override bool PIDHoverActive { set { return; } }
293 public override PIDHoverType PIDHoverType { set { return; } }
294 public override float PIDHoverTau { set { return; } }
295
296
291 public override void SubscribeEvents(int ms) 297 public override void SubscribeEvents(int ms)
292 { 298 {
293 } 299 }
diff --git a/OpenSim/Region/Physics/POSPlugin/POSPrim.cs b/OpenSim/Region/Physics/POSPlugin/POSPrim.cs
index bf96c35..526a2c6 100644
--- a/OpenSim/Region/Physics/POSPlugin/POSPrim.cs
+++ b/OpenSim/Region/Physics/POSPlugin/POSPrim.cs
@@ -283,6 +283,12 @@ namespace OpenSim.Region.Physics.POSPlugin
283 set { return; } 283 set { return; }
284 } 284 }
285 285
286 public override float PIDHoverHeight { set { return; } }
287 public override bool PIDHoverActive { set { return; } }
288 public override PIDHoverType PIDHoverType { set { return; } }
289 public override float PIDHoverTau { set { return; } }
290
291
286 public override void SubscribeEvents(int ms) 292 public override void SubscribeEvents(int ms)
287 { 293 {
288 } 294 }
diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
index 120eed9..7bbca9d 100644
--- a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
+++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs
@@ -490,9 +490,16 @@ namespace OpenSim.Region.Physics.PhysXPlugin
490 { 490 {
491 491
492 } 492 }
493
493 public override PhysicsVector PIDTarget { set { return; } } 494 public override PhysicsVector PIDTarget { set { return; } }
494 public override bool PIDActive { set { return; } } 495 public override bool PIDActive { set { return; } }
495 public override float PIDTau { set { return; } } 496 public override float PIDTau { set { return; } }
497
498 public override float PIDHoverHeight { set { return; } }
499 public override bool PIDHoverActive { set { return; } }
500 public override PIDHoverType PIDHoverType { set { return; } }
501 public override float PIDHoverTau { set { return; } }
502
496 public override void SubscribeEvents(int ms) 503 public override void SubscribeEvents(int ms)
497 { 504 {
498 505
@@ -765,10 +772,16 @@ namespace OpenSim.Region.Physics.PhysXPlugin
765 public override void CrossingFailure() 772 public override void CrossingFailure()
766 { 773 {
767 } 774 }
775
768 public override PhysicsVector PIDTarget { set { return; } } 776 public override PhysicsVector PIDTarget { set { return; } }
769 public override bool PIDActive { set { return; } } 777 public override bool PIDActive { set { return; } }
770 public override float PIDTau { set { return; } } 778 public override float PIDTau { set { return; } }
771 779
780 public override float PIDHoverHeight { set { return; } }
781 public override bool PIDHoverActive { set { return; } }
782 public override PIDHoverType PIDHoverType { set { return; } }
783 public override float PIDHoverTau { set { return; } }
784
772 public override void SubscribeEvents(int ms) 785 public override void SubscribeEvents(int ms)
773 { 786 {
774 787
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