aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs')
-rw-r--r--OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs76
1 files changed, 55 insertions, 21 deletions
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
index c2a6a9b..e3ac315 100644
--- a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
@@ -85,8 +85,10 @@ namespace OpenSim.Region.Physics.OdePlugin
85 private Vector3 m_taintVelocity; 85 private Vector3 m_taintVelocity;
86 private Vector3 m_taintTorque; 86 private Vector3 m_taintTorque;
87 private Quaternion m_taintrot; 87 private Quaternion m_taintrot;
88 private Vector3 m_angularlock = Vector3.One; 88 private Vector3 m_angularlock = Vector3.One; // Current setting
89 private Vector3 m_taintAngularLock = Vector3.One; 89 private Vector3 m_taintAngularLock = Vector3.One; // Request from LSL
90
91
90 private IntPtr Amotor = IntPtr.Zero; 92 private IntPtr Amotor = IntPtr.Zero;
91 93
92 private Vector3 m_PIDTarget; 94 private Vector3 m_PIDTarget;
@@ -405,10 +407,10 @@ namespace OpenSim.Region.Physics.OdePlugin
405 m_disabled = false; 407 m_disabled = false;
406 408
407 // The body doesn't already have a finite rotation mode set here 409 // The body doesn't already have a finite rotation mode set here
408 if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0.0f)) && _parent == null) 410 /* ### if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0.0f)) && _parent == null)
409 { 411 {
410 createAMotor(m_angularlock); 412 createAMotor(m_angularlock);
411 } 413 } */
412 if (m_vehicle.Type != Vehicle.TYPE_NONE) 414 if (m_vehicle.Type != Vehicle.TYPE_NONE)
413 { 415 {
414 m_vehicle.Enable(Body, _parent_scene); 416 m_vehicle.Enable(Body, _parent_scene);
@@ -958,8 +960,10 @@ namespace OpenSim.Region.Physics.OdePlugin
958 960
959 if (m_taintCollidesWater != m_collidesWater) 961 if (m_taintCollidesWater != m_collidesWater)
960 changefloatonwater(timestep); 962 changefloatonwater(timestep);
961 963
964 // ##*
962 if (!m_angularlock.ApproxEquals(m_taintAngularLock,0f)) 965 if (!m_angularlock.ApproxEquals(m_taintAngularLock,0f))
966//Console.WriteLine("ALchange req {0} is {1}", m_taintAngularLock, m_angularlock);
963 changeAngularLock(timestep); 967 changeAngularLock(timestep);
964 968
965 } 969 }
@@ -970,15 +974,21 @@ namespace OpenSim.Region.Physics.OdePlugin
970 } 974 }
971 975
972 976
973 private void changeAngularLock(float timestep) 977 private void changeAngularLock(float timestep) // ##*
974 { 978 {
975 // do we have a Physical object? 979 // do we have a Physical object?
976 if (Body != IntPtr.Zero) 980// if (Body != IntPtr.Zero)
977 { 981// {
978 //Check that we have a Parent 982 //Check that we have a Parent
979 //If we have a parent then we're not authorative here 983 //If we have a parent then we're not authorative here
980 if (_parent == null) 984 if (_parent == null)
981 { 985 {
986//Console.WriteLine("Alock changed to {0}", m_taintAngularLock);
987 m_angularlock = m_taintAngularLock;
988 m_vehicle.SetAngularLock(m_angularlock);
989
990
991/*
982 if (!m_taintAngularLock.ApproxEquals(Vector3.One, 0f)) 992 if (!m_taintAngularLock.ApproxEquals(Vector3.One, 0f))
983 { 993 {
984 //d.BodySetFiniteRotationMode(Body, 0); 994 //d.BodySetFiniteRotationMode(Body, 0);
@@ -997,7 +1007,9 @@ namespace OpenSim.Region.Physics.OdePlugin
997 } 1007 }
998 // Store this for later in case we get turned into a separate body 1008 // Store this for later in case we get turned into a separate body
999 m_angularlock = m_taintAngularLock; 1009 m_angularlock = m_taintAngularLock;
1000 1010 m_vehicle.SetAngularLock(m_angularlock);
1011 } */
1012 }
1001 } 1013 }
1002 1014
1003 private void changelink(float timestep) 1015 private void changelink(float timestep)
@@ -1140,10 +1152,10 @@ namespace OpenSim.Region.Physics.OdePlugin
1140 prm.m_disabled = false; 1152 prm.m_disabled = false;
1141 1153
1142 // The body doesn't already have a finite rotation mode set here 1154 // The body doesn't already have a finite rotation mode set here
1143 if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null) 1155 /* ### if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null)
1144 { 1156 {
1145 prm.createAMotor(m_angularlock); 1157 prm.createAMotor(m_angularlock);
1146 } 1158 } */
1147 prm.Body = Body; 1159 prm.Body = Body;
1148 _parent_scene.addActivePrim(prm); 1160 _parent_scene.addActivePrim(prm);
1149 } 1161 }
@@ -1183,10 +1195,10 @@ namespace OpenSim.Region.Physics.OdePlugin
1183 m_disabled = false; 1195 m_disabled = false;
1184 1196
1185 // The body doesn't already have a finite rotation mode set here 1197 // The body doesn't already have a finite rotation mode set here
1186 if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null) 1198 /* ### if ((!m_angularlock.ApproxEquals(Vector3.Zero, 0f)) && _parent == null)
1187 { 1199 {
1188 createAMotor(m_angularlock); 1200 createAMotor(m_angularlock);
1189 } 1201 } */
1190 d.BodySetPosition(Body, Position.X, Position.Y, Position.Z); 1202 d.BodySetPosition(Body, Position.X, Position.Y, Position.Z);
1191 if (m_vehicle.Type != Vehicle.TYPE_NONE) m_vehicle.Enable(Body, _parent_scene); 1203 if (m_vehicle.Type != Vehicle.TYPE_NONE) m_vehicle.Enable(Body, _parent_scene);
1192 _parent_scene.addActivePrim(this); 1204 _parent_scene.addActivePrim(this);
@@ -1600,14 +1612,17 @@ Console.WriteLine(" JointCreateFixed");
1600 { 1612 {
1601 if(!d.BodyIsEnabled (Body)) d.BodyEnable (Body); // KF add 161009 1613 if(!d.BodyIsEnabled (Body)) d.BodyEnable (Body); // KF add 161009
1602 // NON-'VEHICLES' are dealt with here 1614 // NON-'VEHICLES' are dealt with here
1603 if (d.BodyIsEnabled(Body) && !m_angularlock.ApproxEquals(Vector3.Zero, 0.003f)) 1615 // m_angularlock = <1,1,1> means no lock. a 0 on axis means locked.
1616
1617// NB this may be wrong - may lock global axis! Should be LOCAL axis!
1618 if (d.BodyIsEnabled(Body) && !m_angularlock.ApproxEquals(Vector3.One, 0.003f))
1604 { 1619 {
1605 d.Vector3 avel2 = d.BodyGetAngularVel(Body); 1620 d.Vector3 avel2 = d.BodyGetAngularVel(Body);
1606 if (m_angularlock.X == 1) 1621 if (m_angularlock.X == 0)
1607 avel2.X = 0; 1622 avel2.X = 0;
1608 if (m_angularlock.Y == 1) 1623 if (m_angularlock.Y == 0)
1609 avel2.Y = 0; 1624 avel2.Y = 0;
1610 if (m_angularlock.Z == 1) 1625 if (m_angularlock.Z == 0)
1611 avel2.Z = 0; 1626 avel2.Z = 0;
1612 d.BodySetAngularVel(Body, avel2.X, avel2.Y, avel2.Z); 1627 d.BodySetAngularVel(Body, avel2.X, avel2.Y, avel2.Z);
1613 } 1628 }
@@ -1808,6 +1823,17 @@ Console.WriteLine(" JointCreateFixed");
1808 // d.BodyAddRelTorque(Body, rotforce.X, rotforce.Y, rotforce.Z); 1823 // d.BodyAddRelTorque(Body, rotforce.X, rotforce.Y, rotforce.Z);
1809 RLAservo = timestep / m_APIDStrength * scaler; 1824 RLAservo = timestep / m_APIDStrength * scaler;
1810 rotforce = rotforce * RLAservo * diff_angle ; 1825 rotforce = rotforce * RLAservo * diff_angle ;
1826
1827 if (m_angularlock.X == 0)
1828 rotforce.X = 0;
1829 if (m_angularlock.Y == 0)
1830 rotforce.Y = 0;
1831 if (m_angularlock.Z == 0)
1832 rotforce.Z = 0;
1833
1834
1835
1836
1811 d.BodySetAngularVel (Body, rotforce.X, rotforce.Y, rotforce.Z); 1837 d.BodySetAngularVel (Body, rotforce.X, rotforce.Y, rotforce.Z);
1812//Console.WriteLine("axis= " + diff_axis + " angle= " + diff_angle + "servo= " + RLAservo); 1838//Console.WriteLine("axis= " + diff_axis + " angle= " + diff_angle + "servo= " + RLAservo);
1813 } 1839 }
@@ -1878,11 +1904,11 @@ Console.WriteLine(" JointCreateFixed");
1878 { 1904 {
1879 // KF: If this is a root prim do BodySet 1905 // KF: If this is a root prim do BodySet
1880 d.BodySetQuaternion(Body, ref myrot); 1906 d.BodySetQuaternion(Body, ref myrot);
1881 if (m_isphysical) 1907 /* ### if (m_isphysical)
1882 { 1908 {
1883 if (!m_angularlock.ApproxEquals(Vector3.One, 0f)) 1909 if (!m_angularlock.ApproxEquals(Vector3.One, 0f))
1884 createAMotor(m_angularlock); 1910 createAMotor(m_angularlock);
1885 } 1911 } */
1886 } 1912 }
1887 else 1913 else
1888 { 1914 {
@@ -2516,7 +2542,14 @@ Console.WriteLine(" JointCreateFixed");
2516 } 2542 }
2517 } 2543 }
2518 } 2544 }
2519 2545/*
2546 public Vector3 AngularLock
2547 {
2548 get { return m_angularlock; }
2549 set { }
2550 }
2551
2552*/
2520 public override float CollisionScore 2553 public override float CollisionScore
2521 { 2554 {
2522 get { return m_collisionscore; } 2555 get { return m_collisionscore; }
@@ -2922,8 +2955,9 @@ Console.WriteLine(" JointCreateFixed");
2922 public override PIDHoverType PIDHoverType { set { m_PIDHoverType = value; } } 2955 public override PIDHoverType PIDHoverType { set { m_PIDHoverType = value; } }
2923 public override float PIDHoverTau { set { m_PIDHoverTau = value; } } 2956 public override float PIDHoverTau { set { m_PIDHoverTau = value; } }
2924 2957
2925 private void createAMotor(Vector3 axis) 2958 private void createAMotor(Vector3 axis) // ##*
2926 { 2959 {
2960Console.WriteLine(" createAMotor called! ----------------------------");
2927 if (Body == IntPtr.Zero) 2961 if (Body == IntPtr.Zero)
2928 return; 2962 return;
2929 2963