aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin
diff options
context:
space:
mode:
authorKitto Flora2009-12-22 00:20:04 -0500
committerKitto Flora2009-12-22 00:20:04 -0500
commit0a29842caf5dbe711490b9b323ae922c418c6c30 (patch)
tree17f1403561f8bf1238dae53ff29f126b645b6793 /OpenSim/Region/Physics/OdePlugin
parentMerge branch 'master' into careminster (diff)
downloadopensim-SC_OLD-0a29842caf5dbe711490b9b323ae922c418c6c30.zip
opensim-SC_OLD-0a29842caf5dbe711490b9b323ae922c418c6c30.tar.gz
opensim-SC_OLD-0a29842caf5dbe711490b9b323ae922c418c6c30.tar.bz2
opensim-SC_OLD-0a29842caf5dbe711490b9b323ae922c418c6c30.tar.xz
Include ChOdePlugin
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODECharacter.cs21
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs20
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs108
3 files changed, 31 insertions, 118 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index b99baa2..06ed8fb 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -1197,26 +1197,13 @@ namespace OpenSim.Region.Physics.OdePlugin
1197 public override PIDHoverType PIDHoverType { set { return; } } 1197 public override PIDHoverType PIDHoverType { set { return; } }
1198 public override float PIDHoverTau { set { return; } } 1198 public override float PIDHoverTau { set { return; } }
1199 1199
1200 public override Quaternion APIDTarget 1200 public override Quaternion APIDTarget{ set { return; } }
1201 {
1202 set { return; }
1203 }
1204 1201
1205 public override bool APIDActive 1202 public override bool APIDActive{ set { return; } }
1206 {
1207 set { return; }
1208 }
1209 1203
1210 public override float APIDStrength 1204 public override float APIDStrength{ set { return; } }
1211 {
1212 set { return; }
1213 }
1214
1215 public override float APIDDamping
1216 {
1217 set { return; }
1218 }
1219 1205
1206 public override float APIDDamping{ set { return; } }
1220 1207
1221 1208
1222 public override void SubscribeEvents(int ms) 1209 public override void SubscribeEvents(int ms)
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
index 78b15be..39cdc0f 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEDynamics.cs
@@ -23,19 +23,6 @@
23 * 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
24 * (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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * Revised Aug, Sept 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.
38 *
39 */ 26 */
40 27
41/* Revised Aug, Sept 2009 by Kitto Flora. ODEDynamics.cs replaces 28/* Revised Aug, Sept 2009 by Kitto Flora. ODEDynamics.cs replaces
@@ -133,7 +120,7 @@ namespace OpenSim.Region.Physics.OdePlugin
133// private float m_VhoverEfficiency = 0f; 120// private float m_VhoverEfficiency = 0f;
134 private float m_VhoverTimescale = 0f; 121 private float m_VhoverTimescale = 0f;
135 private float m_VhoverTargetHeight = -1.0f; // if <0 then no hover, else its the current target height 122 private float m_VhoverTargetHeight = -1.0f; // if <0 then no hover, else its the current target height
136 private float m_VehicleBuoyancy = 0f; // Set by VEHICLE_BUOYANCY, for a vehicle. 123 private float m_VehicleBuoyancy = 0f; //KF: m_VehicleBuoyancy is set by VEHICLE_BUOYANCY for a vehicle.
137 // Modifies gravity. Slider between -1 (double-gravity) and 1 (full anti-gravity) 124 // Modifies gravity. Slider between -1 (double-gravity) and 1 (full anti-gravity)
138 // KF: So far I have found no good method to combine a script-requested .Z velocity and gravity. 125 // KF: So far I have found no good method to combine a script-requested .Z velocity and gravity.
139 // Therefore only m_VehicleBuoyancy=1 (0g) will use the script-requested .Z velocity. 126 // Therefore only m_VehicleBuoyancy=1 (0g) will use the script-requested .Z velocity.
@@ -492,7 +479,7 @@ namespace OpenSim.Region.Physics.OdePlugin
492 Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); // rotq = rotation of object 479 Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); // rotq = rotation of object
493 m_dir *= rotq; // apply obj rotation to velocity vector 480 m_dir *= rotq; // apply obj rotation to velocity vector
494 481
495 // add Gravity and Buoyancy 482 // add Gravity andBuoyancy
496 // KF: So far I have found no good method to combine a script-requested 483 // KF: So far I have found no good method to combine a script-requested
497 // .Z velocity and gravity. Therefore only 0g will used script-requested 484 // .Z velocity and gravity. Therefore only 0g will used script-requested
498 // .Z velocity. >0g (m_VehicleBuoyancy < 1) will used modified gravity only. 485 // .Z velocity. >0g (m_VehicleBuoyancy < 1) will used modified gravity only.
@@ -574,7 +561,6 @@ namespace OpenSim.Region.Physics.OdePlugin
574 private Vector3 m_angularFrictionTimescale = Vector3.Zero; // body angular velocity decay rate 561 private Vector3 m_angularFrictionTimescale = Vector3.Zero; // body angular velocity decay rate
575 private Vector3 m_lastAngularVelocity = Vector3.Zero; // what was last applied to body 562 private Vector3 m_lastAngularVelocity = Vector3.Zero; // what was last applied to body
576 */ 563 */
577//if(frcount == 0) Console.WriteLine("MoveAngular ");
578 564
579 // Get what the body is doing, this includes 'external' influences 565 // Get what the body is doing, this includes 'external' influences
580 d.Vector3 angularVelocity = d.BodyGetAngularVel(Body); 566 d.Vector3 angularVelocity = d.BodyGetAngularVel(Body);
@@ -650,7 +636,7 @@ namespace OpenSim.Region.Physics.OdePlugin
650 // Deflection section tba 636 // Deflection section tba
651 637
652 // Sum velocities 638 // Sum velocities
653 m_lastAngularVelocity = m_angularMotorVelocity + vertattr; // tba: + bank + deflection 639 m_lastAngularVelocity = m_angularMotorVelocity + vertattr; // + bank + deflection
654 640
655 if (!m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f)) 641 if (!m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f))
656 { 642 {
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index 688be83..3eb3b28 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -21,18 +21,6 @@
21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *
25 * Revised August 26 2009 by Kitto Flora. ODEDynamics.cs replaces
26 * ODEVehicleSettings.cs. It and ODEPrim.cs are re-organised:
27 * ODEPrim.cs contains methods dealing with Prim editing, Prim
28 * characteristics and Kinetic motion.
29 * ODEDynamics.cs contains methods dealing with Prim Physical motion
30 * (dynamics) and the associated settings. Old Linear and angular
31 * motors for dynamic motion have been replace with MoveLinear()
32 * and MoveAngular(); 'Physical' is used only to switch ODE dynamic
33 * simualtion on/off; VEHICAL_TYPE_NONE/VEHICAL_TYPE_<other> is to
34 * switch between 'VEHICLE' parameter use and general dynamics
35 * settings use.
36 */ 24 */
37 25
38/* 26/*
@@ -93,12 +81,7 @@ namespace OpenSim.Region.Physics.OdePlugin
93 private float m_PIDTau; 81 private float m_PIDTau;
94 private float PID_D = 35f; 82 private float PID_D = 35f;
95 private float PID_G = 25f; 83 private float PID_G = 25f;
96 private bool m_usePID = false; 84 private bool m_usePID;
97
98 private Quaternion m_APIDTarget = new Quaternion();
99 private float m_APIDStrength = 0.5f;
100 private float m_APIDDamping = 0.5f;
101 private bool m_useAPID = false;
102 85
103 // KF: These next 7 params apply to llSetHoverHeight(float height, integer water, float tau), 86 // KF: These next 7 params apply to llSetHoverHeight(float height, integer water, float tau),
104 // and are for non-VEHICLES only. 87 // and are for non-VEHICLES only.
@@ -199,9 +182,6 @@ namespace OpenSim.Region.Physics.OdePlugin
199 private ODEDynamics m_vehicle; 182 private ODEDynamics m_vehicle;
200 183
201 internal int m_material = (int)Material.Wood; 184 internal int m_material = (int)Material.Wood;
202
203 private int frcount = 0; // Used to limit dynamics debug output to
204
205 185
206 public OdePrim(String primName, OdeScene parent_scene, Vector3 pos, Vector3 size, 186 public OdePrim(String primName, OdeScene parent_scene, Vector3 pos, Vector3 size,
207 Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode) 187 Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode)
@@ -1581,14 +1561,9 @@ Console.WriteLine(" JointCreateFixed");
1581 float fy = 0; 1561 float fy = 0;
1582 float fz = 0; 1562 float fz = 0;
1583 1563
1584 frcount++; // used to limit debug comment output
1585 if (frcount > 100)
1586 frcount = 0;
1587 1564
1588 if (IsPhysical && (Body != IntPtr.Zero) && !m_isSelected && !childPrim) // KF: Only move root prims. 1565 if (IsPhysical && (Body != IntPtr.Zero) && !m_isSelected && !childPrim) // KF: Only move root prims.
1589 { 1566 {
1590//if(frcount == 0) Console.WriteLine("Move " + m_primName + " VTyp " + m_vehicle.Type +
1591 // " usePID=" + m_usePID + " seHover=" + m_useHoverPID + " useAPID=" + m_useAPID);
1592 if (m_vehicle.Type != Vehicle.TYPE_NONE) 1567 if (m_vehicle.Type != Vehicle.TYPE_NONE)
1593 { 1568 {
1594 // 'VEHICLES' are dealt with in ODEDynamics.cs 1569 // 'VEHICLES' are dealt with in ODEDynamics.cs
@@ -1596,6 +1571,7 @@ Console.WriteLine(" JointCreateFixed");
1596 } 1571 }
1597 else 1572 else
1598 { 1573 {
1574//Console.WriteLine("Move " + m_primName);
1599 if(!d.BodyIsEnabled (Body)) d.BodyEnable (Body); // KF add 161009 1575 if(!d.BodyIsEnabled (Body)) d.BodyEnable (Body); // KF add 161009
1600 // NON-'VEHICLES' are dealt with here 1576 // NON-'VEHICLES' are dealt with here
1601 if (d.BodyIsEnabled(Body) && !m_angularlock.ApproxEquals(Vector3.Zero, 0.003f)) 1577 if (d.BodyIsEnabled(Body) && !m_angularlock.ApproxEquals(Vector3.Zero, 0.003f))
@@ -1617,18 +1593,21 @@ Console.WriteLine(" JointCreateFixed");
1617 //m_log.Info(m_collisionFlags.ToString()); 1593 //m_log.Info(m_collisionFlags.ToString());
1618 1594
1619 1595
1620 //KF: m_buoyancy is set by llSetBuoyancy() and is for non-vehicle. 1596 //KF: m_buoyancy should be set by llSetBuoyancy() for non-vehicle.
1597 // would come from SceneObjectPart.cs, public void SetBuoyancy(float fvalue) , PhysActor.Buoyancy = fvalue; ??
1621 // m_buoyancy: (unlimited value) <0=Falls fast; 0=1g; 1=0g; >1 = floats up 1598 // m_buoyancy: (unlimited value) <0=Falls fast; 0=1g; 1=0g; >1 = floats up
1622 // NB Prims in ODE are no subject to global gravity 1599 // gravityz multiplier = 1 - m_buoyancy
1623 fz = _parent_scene.gravityz * (1.0f - m_buoyancy) * m_mass; // force = acceleration * mass 1600 fz = _parent_scene.gravityz * (1.0f - m_buoyancy) * m_mass;
1624 1601
1625 if (m_usePID) 1602 if (m_usePID)
1626 { 1603 {
1627//if(frcount == 0) Console.WriteLine("PID " + m_primName); 1604//Console.WriteLine("PID " + m_primName);
1628 // KF - this is for object MoveToTarget. 1605 // KF - this is for object move? eg. llSetPos() ?
1629
1630 //if (!d.BodyIsEnabled(Body)) 1606 //if (!d.BodyIsEnabled(Body))
1631 //d.BodySetForce(Body, 0f, 0f, 0f); 1607 //d.BodySetForce(Body, 0f, 0f, 0f);
1608 // If we're using the PID controller, then we have no gravity
1609 //fz = (-1 * _parent_scene.gravityz) * m_mass; //KF: ?? Prims have no global gravity,so simply...
1610 fz = 0f;
1632 1611
1633 // no lock; for now it's only called from within Simulate() 1612 // no lock; for now it's only called from within Simulate()
1634 1613
@@ -1763,7 +1742,7 @@ Console.WriteLine(" JointCreateFixed");
1763 d.BodySetPosition(Body, pos.X, pos.Y, m_targetHoverHeight); 1742 d.BodySetPosition(Body, pos.X, pos.Y, m_targetHoverHeight);
1764 d.BodySetLinearVel(Body, vel.X, vel.Y, 0); 1743 d.BodySetLinearVel(Body, vel.X, vel.Y, 0);
1765 d.BodyAddForce(Body, 0, 0, fz); 1744 d.BodyAddForce(Body, 0, 0, fz);
1766 //KF this prevents furthur motions return; 1745 return;
1767 } 1746 }
1768 else 1747 else
1769 { 1748 {
@@ -1772,46 +1751,8 @@ Console.WriteLine(" JointCreateFixed");
1772 // We're flying and colliding with something 1751 // We're flying and colliding with something
1773 fz = fz + ((_target_velocity.Z - vel.Z) * (PID_D) * m_mass); 1752 fz = fz + ((_target_velocity.Z - vel.Z) * (PID_D) * m_mass);
1774 } 1753 }
1775 } // end m_useHoverPID && !m_usePID 1754 }
1776 1755
1777 if (m_useAPID)
1778 {
1779 // RotLookAt, apparently overrides all other rotation sources. Inputs:
1780 // Quaternion m_APIDTarget
1781 // float m_APIDStrength // From SL experiments, this is the time to get there
1782 // float m_APIDDamping // From SL experiments, this is damping, 1.0 = damped, 0.1 = wobbly
1783 // Also in SL the mass of the object has no effect on time to get there.
1784 // Factors:
1785//if(frcount == 0) Console.WriteLine("APID ");
1786 // get present body rotation
1787 float limit = 1.0f;
1788 float scaler = 50f; // adjusts damping time
1789 float RLAservo = 0f;
1790
1791 d.Quaternion rot = d.BodyGetQuaternion(Body);
1792 Quaternion rotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W);
1793 Quaternion rot_diff = Quaternion.Inverse(rotq) * m_APIDTarget;
1794 float diff_angle;
1795 Vector3 diff_axis;
1796 rot_diff.GetAxisAngle(out diff_axis, out diff_angle);
1797 diff_axis.Normalize();
1798 if(diff_angle > 0.01f) // diff_angle is always +ve
1799 {
1800// PhysicsVector rotforce = new PhysicsVector(diff_axis.X, diff_axis.Y, diff_axis.Z);
1801 Vector3 rotforce = new Vector3(diff_axis.X, diff_axis.Y, diff_axis.Z);
1802 rotforce = rotforce * rotq;
1803 if(diff_angle > limit) diff_angle = limit; // cap the rotate rate
1804// RLAservo = timestep / m_APIDStrength * m_mass * scaler;
1805 // rotforce = rotforce * RLAservo * diff_angle ;
1806 // d.BodyAddRelTorque(Body, rotforce.X, rotforce.Y, rotforce.Z);
1807 RLAservo = timestep / m_APIDStrength * scaler;
1808 rotforce = rotforce * RLAservo * diff_angle ;
1809 d.BodySetAngularVel (Body, rotforce.X, rotforce.Y, rotforce.Z);
1810//Console.WriteLine("axis= " + diff_axis + " angle= " + diff_angle + "servo= " + RLAservo);
1811 }
1812//if(frcount == 0) Console.WriteLine("mass= " + m_mass + " servo= " + RLAservo + " angle= " + diff_angle);
1813 } // end m_useAPID
1814
1815 fx *= m_mass; 1756 fx *= m_mass;
1816 fy *= m_mass; 1757 fy *= m_mass;
1817 //fz *= m_mass; 1758 //fz *= m_mass;
@@ -2673,7 +2614,7 @@ Console.WriteLine(" JointCreateFixed");
2673 2614
2674 m_lastposition = _position; 2615 m_lastposition = _position;
2675 m_lastorientation = _orientation; 2616 m_lastorientation = _orientation;
2676 2617
2677 l_position.X = vec.X; 2618 l_position.X = vec.X;
2678 l_position.Y = vec.Y; 2619 l_position.Y = vec.Y;
2679 l_position.Z = vec.Z; 2620 l_position.Z = vec.Z;
@@ -2681,10 +2622,6 @@ Console.WriteLine(" JointCreateFixed");
2681 l_orientation.Y = ori.Y; 2622 l_orientation.Y = ori.Y;
2682 l_orientation.Z = ori.Z; 2623 l_orientation.Z = ori.Z;
2683 l_orientation.W = ori.W; 2624 l_orientation.W = ori.W;
2684
2685// if(l_position.Y != m_lastposition.Y){
2686// Console.WriteLine("UP&V {0} {1}", m_primName, l_position);
2687// }
2688 2625
2689 if (l_position.X > ((int)_parent_scene.WorldExtents.X - 0.05f) || l_position.X < 0f || l_position.Y > ((int)_parent_scene.WorldExtents.Y - 0.05f) || l_position.Y < 0f) 2626 if (l_position.X > ((int)_parent_scene.WorldExtents.X - 0.05f) || l_position.X < 0f || l_position.Y > ((int)_parent_scene.WorldExtents.Y - 0.05f) || l_position.Y < 0f)
2690 { 2627 {
@@ -2885,17 +2822,20 @@ Console.WriteLine(" JointCreateFixed");
2885 } 2822 }
2886 public override bool PIDActive { set { m_usePID = value; } } 2823 public override bool PIDActive { set { m_usePID = value; } }
2887 public override float PIDTau { set { m_PIDTau = value; } } 2824 public override float PIDTau { set { m_PIDTau = value; } }
2888
2889 // For RotLookAt
2890 public override Quaternion APIDTarget { set { m_APIDTarget = value; } }
2891 public override bool APIDActive { set { m_useAPID = value; } }
2892 public override float APIDStrength { set { m_APIDStrength = value; } }
2893 public override float APIDDamping { set { m_APIDDamping = value; } }
2894 2825
2895 public override float PIDHoverHeight { set { m_PIDHoverHeight = value; ; } } 2826 public override float PIDHoverHeight { set { m_PIDHoverHeight = value; ; } }
2896 public override bool PIDHoverActive { set { m_useHoverPID = value; } } 2827 public override bool PIDHoverActive { set { m_useHoverPID = value; } }
2897 public override PIDHoverType PIDHoverType { set { m_PIDHoverType = value; } } 2828 public override PIDHoverType PIDHoverType { set { m_PIDHoverType = value; } }
2898 public override float PIDHoverTau { set { m_PIDHoverTau = value; } } 2829 public override float PIDHoverTau { set { m_PIDHoverTau = value; } }
2830
2831 public override Quaternion APIDTarget{ set { return; } }
2832
2833 public override bool APIDActive{ set { return; } }
2834
2835 public override float APIDStrength{ set { return; } }
2836
2837 public override float APIDDamping{ set { return; } }
2838
2899 2839
2900 private void createAMotor(Vector3 axis) 2840 private void createAMotor(Vector3 axis)
2901 { 2841 {