diff options
author | Charles Krinke | 2009-03-06 23:01:35 +0000 |
---|---|---|
committer | Charles Krinke | 2009-03-06 23:01:35 +0000 |
commit | b637a11b58292cb6165317b317dc077a79ee6779 (patch) | |
tree | 18d9b2e82ae782fec726f3baa2d60c76433a7406 /OpenSim/Region/Physics | |
parent | add back .config files for all tests in an attempt to debug why these (diff) | |
download | opensim-SC-b637a11b58292cb6165317b317dc077a79ee6779.zip opensim-SC-b637a11b58292cb6165317b317dc077a79ee6779.tar.gz opensim-SC-b637a11b58292cb6165317b317dc077a79ee6779.tar.bz2 opensim-SC-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.
Diffstat (limited to 'OpenSim/Region/Physics')
-rw-r--r-- | OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs | 8 | ||||
-rw-r--r-- | OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs | 7 | ||||
-rw-r--r-- | OpenSim/Region/Physics/Manager/PhysicsActor.cs | 26 | ||||
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 7 | ||||
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 101 | ||||
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 5 | ||||
-rw-r--r-- | OpenSim/Region/Physics/POSPlugin/POSCharacter.cs | 6 | ||||
-rw-r--r-- | OpenSim/Region/Physics/POSPlugin/POSPrim.cs | 6 | ||||
-rw-r--r-- | OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs | 13 |
9 files changed, 177 insertions, 2 deletions
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 | ||