aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin
diff options
context:
space:
mode:
authorKittoFlora2009-10-26 00:10:23 +0100
committerKittoFlora2009-10-26 00:10:23 +0100
commit8428b25939d39711e732eeb3928e8a8e64aad8a9 (patch)
tree4431c6743c579dcaa83a5f979496ccc574ae25e3 /OpenSim/Region/Physics/OdePlugin
parentCommented out instrumentation in ODEPrim.cs (diff)
downloadopensim-SC_OLD-8428b25939d39711e732eeb3928e8a8e64aad8a9.zip
opensim-SC_OLD-8428b25939d39711e732eeb3928e8a8e64aad8a9.tar.gz
opensim-SC_OLD-8428b25939d39711e732eeb3928e8a8e64aad8a9.tar.bz2
opensim-SC_OLD-8428b25939d39711e732eeb3928e8a8e64aad8a9.tar.xz
Add llRotLookat pt1.
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODECharacter.cs22
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs4
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs83
3 files changed, 86 insertions, 23 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index 71ace16..8272083 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -1205,6 +1205,28 @@ namespace OpenSim.Region.Physics.OdePlugin
1205 public override bool PIDHoverActive { set { return; } } 1205 public override bool PIDHoverActive { set { return; } }
1206 public override PIDHoverType PIDHoverType { set { return; } } 1206 public override PIDHoverType PIDHoverType { set { return; } }
1207 public override float PIDHoverTau { set { return; } } 1207 public override float PIDHoverTau { set { return; } }
1208
1209 public override Quaternion APIDTarget
1210 {
1211 set { return; }
1212 }
1213
1214 public override bool APIDActive
1215 {
1216 set { return; }
1217 }
1218
1219 public override float APIDStrength
1220 {
1221 set { return; }
1222 }
1223
1224 public override float APIDDamping
1225 {
1226 set { return; }
1227 }
1228
1229
1208 1230
1209 public override void SubscribeEvents(int ms) 1231 public override void SubscribeEvents(int ms)
1210 { 1232 {
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
index 467eba0..8b57f06 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
@@ -119,7 +119,7 @@ namespace OpenSim.Region.Physics.OdePlugin
119 private float m_VhoverEfficiency = 0f; 119 private float m_VhoverEfficiency = 0f;
120 private float m_VhoverTimescale = 0f; 120 private float m_VhoverTimescale = 0f;
121 private float m_VhoverTargetHeight = -1.0f; // if <0 then no hover, else its the current target height 121 private float m_VhoverTargetHeight = -1.0f; // if <0 then no hover, else its the current target height
122 private float m_VehicleBuoyancy = 0f; //KF: m_VehicleBuoyancy is set by VEHICLE_BUOYANCY for a vehicle. 122 private float m_VehicleBuoyancy = 0f; // Set by VEHICLE_BUOYANCY, for a vehicle.
123 // Modifies gravity. Slider between -1 (double-gravity) and 1 (full anti-gravity) 123 // Modifies gravity. Slider between -1 (double-gravity) and 1 (full anti-gravity)
124 // KF: So far I have found no good method to combine a script-requested .Z velocity and gravity. 124 // KF: So far I have found no good method to combine a script-requested .Z velocity and gravity.
125 // Therefore only m_VehicleBuoyancy=1 (0g) will use the script-requested .Z velocity. 125 // Therefore only m_VehicleBuoyancy=1 (0g) will use the script-requested .Z velocity.
@@ -478,7 +478,7 @@ namespace OpenSim.Region.Physics.OdePlugin
478 Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); // rotq = rotation of object 478 Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); // rotq = rotation of object
479 m_dir *= rotq; // apply obj rotation to velocity vector 479 m_dir *= rotq; // apply obj rotation to velocity vector
480 480
481 // add Gravity andBuoyancy 481 // add Gravity and Buoyancy
482 // KF: So far I have found no good method to combine a script-requested 482 // KF: So far I have found no good method to combine a script-requested
483 // .Z velocity and gravity. Therefore only 0g will used script-requested 483 // .Z velocity and gravity. Therefore only 0g will used script-requested
484 // .Z velocity. >0g (m_VehicleBuoyancy < 1) will used modified gravity only. 484 // .Z velocity. >0g (m_VehicleBuoyancy < 1) will used modified gravity only.
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index f59f0ae..e1bf996 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -1,15 +1,4 @@
1/* 1/*
2 * Revised August 26 2009 by Kitto Flora. ODEDynamics.cs replaces
3 * ODEVehicleSettings.cs. It and ODEPrim.cs are re-organised:
4 * ODEPrim.cs contains methods dealing with Prim editing, Prim
5 * characteristics and Kinetic motion.
6 * ODEDynamics.cs contains methods dealing with Prim Physical motion
7 * (dynamics) and the associated settings. Old Linear and angular
8 * motors for dynamic motion have been replace with MoveLinear()
9 * and MoveAngular(); 'Physical' is used only to switch ODE dynamic
10 * simualtion on/off; VEHICAL_TYPE_NONE/VEHICAL_TYPE_<other> is to
11 * switch between 'VEHICLE' parameter use and general dynamics
12 * settings use.
13 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
14 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
15 * 4 *
@@ -34,6 +23,18 @@
34 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * Revised August 26 2009 by Kitto Flora. ODEDynamics.cs replaces
28 * ODEVehicleSettings.cs. It and ODEPrim.cs are re-organised:
29 * ODEPrim.cs contains methods dealing with Prim editing, Prim
30 * characteristics and Kinetic motion.
31 * ODEDynamics.cs contains methods dealing with Prim Physical motion
32 * (dynamics) and the associated settings. Old Linear and angular
33 * motors for dynamic motion have been replace with MoveLinear()
34 * and MoveAngular(); 'Physical' is used only to switch ODE dynamic
35 * simualtion on/off; VEHICAL_TYPE_NONE/VEHICAL_TYPE_<other> is to
36 * switch between 'VEHICLE' parameter use and general dynamics
37 * settings use.
37 */ 38 */
38using System; 39using System;
39using System.Collections.Generic; 40using System.Collections.Generic;
@@ -82,6 +83,14 @@ namespace OpenSim.Region.Physics.OdePlugin
82 private float PID_D = 35f; 83 private float PID_D = 35f;
83 private float PID_G = 25f; 84 private float PID_G = 25f;
84 private bool m_usePID = false; 85 private bool m_usePID = false;
86
87 private Quaternion m_APIDTarget = new Quaternion();
88 private float m_APIDStrength = 0.5f;
89 private float m_APIDDamping = 0.5f;
90
91 private float APID_D = 35f;
92 private float APID_G = 25f;
93 private bool m_useAPID = false;
85 94
86 // KF: These next 7 params apply to llSetHoverHeight(float height, integer water, float tau), 95 // KF: These next 7 params apply to llSetHoverHeight(float height, integer water, float tau),
87 // and are for non-VEHICLES only. 96 // and are for non-VEHICLES only.
@@ -93,7 +102,7 @@ namespace OpenSim.Region.Physics.OdePlugin
93 private float m_targetHoverHeight = 0f; 102 private float m_targetHoverHeight = 0f;
94 private float m_groundHeight = 0f; 103 private float m_groundHeight = 0f;
95 private float m_waterHeight = 0f; 104 private float m_waterHeight = 0f;
96 private float m_buoyancy = 0f; //KF: m_buoyancy should be set by llSetBuoyancy() for non-vehicle. 105 private float m_buoyancy = 0f; //Set by llSetBuoyancy(), for non-vehicles.
97 106
98 // private float m_tensor = 5f; 107 // private float m_tensor = 5f;
99 private int body_autodisable_frames = 20; 108 private int body_autodisable_frames = 20;
@@ -1586,21 +1595,18 @@ Console.WriteLine(" JointCreateFixed");
1586 //m_log.Info(m_collisionFlags.ToString()); 1595 //m_log.Info(m_collisionFlags.ToString());
1587 1596
1588 1597
1589 //KF: m_buoyancy should be set by llSetBuoyancy() for non-vehicle. 1598 //KF: m_buoyancy is set by llSetBuoyancy() and is for non-vehicle.
1590 // would come from SceneObjectPart.cs, public void SetBuoyancy(float fvalue) , PhysActor.Buoyancy = fvalue; ??
1591 // m_buoyancy: (unlimited value) <0=Falls fast; 0=1g; 1=0g; >1 = floats up 1599 // m_buoyancy: (unlimited value) <0=Falls fast; 0=1g; 1=0g; >1 = floats up
1592 // gravityz multiplier = 1 - m_buoyancy 1600 // NB Prims in ODE are no subject to global gravity
1593 fz = _parent_scene.gravityz * (1.0f - m_buoyancy) * m_mass; 1601 fz = _parent_scene.gravityz * (1.0f - m_buoyancy) * m_mass; // force = acceleration * mass
1594 1602
1595 if (m_usePID) 1603 if (m_usePID)
1596 { 1604 {
1597//Console.WriteLine("PID " + m_primName); 1605//Console.WriteLine("PID " + m_primName);
1598 // KF - this is for object move? eg. llSetPos() ? 1606 // KF - this is for object MoveToTarget.
1607
1599 //if (!d.BodyIsEnabled(Body)) 1608 //if (!d.BodyIsEnabled(Body))
1600 //d.BodySetForce(Body, 0f, 0f, 0f); 1609 //d.BodySetForce(Body, 0f, 0f, 0f);
1601 // If we're using the PID controller, then we have no gravity
1602 //fz = (-1 * _parent_scene.gravityz) * m_mass; //KF: ?? Prims have no global gravity,so simply...
1603 fz = 0f;
1604 1610
1605 // no lock; for now it's only called from within Simulate() 1611 // no lock; for now it's only called from within Simulate()
1606 1612
@@ -1744,8 +1750,37 @@ Console.WriteLine(" JointCreateFixed");
1744 // We're flying and colliding with something 1750 // We're flying and colliding with something
1745 fz = fz + ((_target_velocity.Z - vel.Z) * (PID_D) * m_mass); 1751 fz = fz + ((_target_velocity.Z - vel.Z) * (PID_D) * m_mass);
1746 } 1752 }
1747 } 1753 } // end m_useHoverPID && !m_usePID
1754
1755 if (m_useAPID)
1756 {
1757 // RotLookAt, apparently overrides all other rotation sources. Inputs:
1758 // Quaternion m_APIDTarget
1759 // float m_APIDStrength // perhaps ratio other forces to lookat force?
1760 // float m_APIDDamping //'seconds to critically damps in'[sic]
1761 // Factors:
1762 // float APID_D
1763 // float APID_G
1764
1765 // get present body rotation
1766 d.Quaternion rot = d.BodyGetQuaternion(Body);
1767 Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W);
1768 Quaternion rot_diff = Quaternion.Inverse(rotq) * m_APIDTarget;
1769 float diff_angle;
1770 Vector3 diff_axis;
1771 rot_diff.GetAxisAngle(out diff_axis, out diff_angle);
1772 diff_axis.Normalize();
1773 PhysicsVector rotforce = new PhysicsVector(diff_axis.X, diff_axis.Y, diff_axis.Z);
1774 float RLAservo = timestep / m_APIDDamping;
1775 rotforce = rotforce * RLAservo * m_mass;
1776 d.BodyAddTorque(Body, rotforce.X, rotforce.Y, rotforce.Z);
1777
1778 // d.BodySetAngularVel (Body, m_lastAngularVelocity.X, m_lastAngularVelocity.Y, m_lastAngularVelocity.Z);
1748 1779
1780
1781
1782 } // end m_useAPID
1783
1749 fx *= m_mass; 1784 fx *= m_mass;
1750 fy *= m_mass; 1785 fy *= m_mass;
1751 //fz *= m_mass; 1786 //fz *= m_mass;
@@ -2778,6 +2813,12 @@ Console.WriteLine(" JointCreateFixed");
2778 } 2813 }
2779 public override bool PIDActive { set { m_usePID = value; } } 2814 public override bool PIDActive { set { m_usePID = value; } }
2780 public override float PIDTau { set { m_PIDTau = value; } } 2815 public override float PIDTau { set { m_PIDTau = value; } }
2816
2817 // For RotLookAt
2818 public override Quaternion APIDTarget { set { m_APIDTarget = value; } }
2819 public override bool APIDActive { set { m_useAPID = value; } }
2820 public override float APIDStrength { set { m_APIDStrength = value; } }
2821 public override float APIDDamping { set { m_APIDDamping = value; } }
2781 2822
2782 public override float PIDHoverHeight { set { m_PIDHoverHeight = value; ; } } 2823 public override float PIDHoverHeight { set { m_PIDHoverHeight = value; ; } }
2783 public override bool PIDHoverActive { set { m_useHoverPID = value; } } 2824 public override bool PIDHoverActive { set { m_useHoverPID = value; } }