aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/PhysicsModules/Ode
diff options
context:
space:
mode:
authorUbitUmarov2015-10-20 23:57:57 +0100
committerUbitUmarov2015-10-20 23:57:57 +0100
commit747044f5872a2856ad3079662a736cee3f5acf71 (patch)
treee6bbe20887af47d751f2cc56042e6b254f3a11c6 /OpenSim/Region/PhysicsModules/Ode
parent stop using a vector3 to store axis locks 3bit flags in ubOde (diff)
downloadopensim-SC_OLD-747044f5872a2856ad3079662a736cee3f5acf71.zip
opensim-SC_OLD-747044f5872a2856ad3079662a736cee3f5acf71.tar.gz
opensim-SC_OLD-747044f5872a2856ad3079662a736cee3f5acf71.tar.bz2
opensim-SC_OLD-747044f5872a2856ad3079662a736cee3f5acf71.tar.xz
stop using a vector3 to store axis locks 3bit flags also in ode
Diffstat (limited to 'OpenSim/Region/PhysicsModules/Ode')
-rw-r--r--OpenSim/Region/PhysicsModules/Ode/ODECharacter.cs2
-rw-r--r--OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs101
2 files changed, 47 insertions, 56 deletions
diff --git a/OpenSim/Region/PhysicsModules/Ode/ODECharacter.cs b/OpenSim/Region/PhysicsModules/Ode/ODECharacter.cs
index 8048e26..c1afe13 100644
--- a/OpenSim/Region/PhysicsModules/Ode/ODECharacter.cs
+++ b/OpenSim/Region/PhysicsModules/Ode/ODECharacter.cs
@@ -595,7 +595,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
595 595
596 public override void delink() {} 596 public override void delink() {}
597 597
598 public override void LockAngularMotion(Vector3 axis) {} 598 public override void LockAngularMotion(byte axislocks) {}
599 599
600// This code is very useful. Written by DanX0r. We're just not using it right now. 600// This code is very useful. Written by DanX0r. We're just not using it right now.
601// Commented out to prevent a warning. 601// Commented out to prevent a warning.
diff --git a/OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs b/OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs
index 061beea..0a57dc9 100644
--- a/OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs
+++ b/OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs
@@ -111,10 +111,12 @@ namespace OpenSim.Region.PhysicsModule.ODE
111 private Vector3 m_taintVelocity; 111 private Vector3 m_taintVelocity;
112 private Vector3 m_taintTorque; 112 private Vector3 m_taintTorque;
113 private Quaternion m_taintrot; 113 private Quaternion m_taintrot;
114 private Vector3 m_angularlock = Vector3.One; 114
115 private Vector3 m_taintAngularLock = Vector3.One;
116 private IntPtr Amotor = IntPtr.Zero; 115 private IntPtr Amotor = IntPtr.Zero;
117 116
117 private byte m_taintAngularLock = 0;
118 private byte m_angularlock = 0;
119
118 private bool m_assetFailed = false; 120 private bool m_assetFailed = false;
119 121
120 private Vector3 m_PIDTarget; 122 private Vector3 m_PIDTarget;
@@ -452,7 +454,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
452 m_disabled = false; 454 m_disabled = false;
453 455
454 // The body doesn't already have a finite rotation mode set here 456 // The body doesn't already have a finite rotation mode set here
455 if ((!m_angularlock.ApproxEquals(Vector3.One, 0.0f)) && _parent == null) 457 if (m_angularlock != 0 && _parent == null)
456 { 458 {
457 createAMotor(m_angularlock); 459 createAMotor(m_angularlock);
458 } 460 }
@@ -1008,7 +1010,7 @@ Console.WriteLine("ZProcessTaints for " + Name);
1008 if (m_taintCollidesWater != m_collidesWater) 1010 if (m_taintCollidesWater != m_collidesWater)
1009 changefloatonwater(); 1011 changefloatonwater();
1010 1012
1011 if (!m_angularlock.ApproxEquals(m_taintAngularLock,0f)) 1013 if (m_taintAngularLock != m_angularlock)
1012 changeAngularLock(); 1014 changeAngularLock();
1013 } 1015 }
1014 1016
@@ -1024,10 +1026,8 @@ Console.WriteLine("ZProcessTaints for " + Name);
1024 //If we have a parent then we're not authorative here 1026 //If we have a parent then we're not authorative here
1025 if (_parent == null) 1027 if (_parent == null)
1026 { 1028 {
1027 if (!m_taintAngularLock.ApproxEquals(Vector3.One, 0f)) 1029 if (m_taintAngularLock != 0)
1028 { 1030 {
1029 //d.BodySetFiniteRotationMode(Body, 0);
1030 //d.BodySetFiniteRotationAxis(Body,m_taintAngularLock.X,m_taintAngularLock.Y,m_taintAngularLock.Z);
1031 createAMotor(m_taintAngularLock); 1031 createAMotor(m_taintAngularLock);
1032 } 1032 }
1033 else 1033 else
@@ -1041,7 +1041,6 @@ Console.WriteLine("ZProcessTaints for " + Name);
1041 } 1041 }
1042 } 1042 }
1043 1043
1044 // Store this for later in case we get turned into a separate body
1045 m_angularlock = m_taintAngularLock; 1044 m_angularlock = m_taintAngularLock;
1046 } 1045 }
1047 1046
@@ -1237,7 +1236,8 @@ Console.WriteLine("ZProcessTaints for " + Name);
1237 m_disabled = false; 1236 m_disabled = false;
1238 1237
1239 // The body doesn't already have a finite rotation mode set here 1238 // The body doesn't already have a finite rotation mode set here
1240 if ((!m_angularlock.ApproxEquals(Vector3.One, 0f)) && _parent == null) 1239 // or remove
1240 if (_parent == null)
1241 { 1241 {
1242 createAMotor(m_angularlock); 1242 createAMotor(m_angularlock);
1243 } 1243 }
@@ -1707,21 +1707,6 @@ Console.WriteLine(" JointCreateFixed");
1707 { 1707 {
1708//Console.WriteLine("Move " + Name); 1708//Console.WriteLine("Move " + Name);
1709 if (!d.BodyIsEnabled (Body)) d.BodyEnable (Body); // KF add 161009 1709 if (!d.BodyIsEnabled (Body)) d.BodyEnable (Body); // KF add 161009
1710 // NON-'VEHICLES' are dealt with here
1711// if (d.BodyIsEnabled(Body) && !m_angularlock.ApproxEquals(Vector3.Zero, 0.003f))
1712// {
1713// d.Vector3 avel2 = d.BodyGetAngularVel(Body);
1714// /*
1715// if (m_angularlock.X == 1)
1716// avel2.X = 0;
1717// if (m_angularlock.Y == 1)
1718// avel2.Y = 0;
1719// if (m_angularlock.Z == 1)
1720// avel2.Z = 0;
1721// d.BodySetAngularVel(Body, avel2.X, avel2.Y, avel2.Z);
1722// */
1723// }
1724 //float PID_P = 900.0f;
1725 1710
1726 float m_mass = CalculateMass(); 1711 float m_mass = CalculateMass();
1727 1712
@@ -1950,8 +1935,8 @@ Console.WriteLine(" JointCreateFixed");
1950 d.BodySetQuaternion(Body, ref myrot); 1935 d.BodySetQuaternion(Body, ref myrot);
1951 if (IsPhysical) 1936 if (IsPhysical)
1952 { 1937 {
1953 if (!m_angularlock.ApproxEquals(Vector3.One, 0f)) 1938 // create or remove locks
1954 createAMotor(m_angularlock); 1939 createAMotor(m_angularlock);
1955 } 1940 }
1956 } 1941 }
1957 else 1942 else
@@ -2719,21 +2704,10 @@ Console.WriteLine(" JointCreateFixed");
2719 m_taintparent = null; 2704 m_taintparent = null;
2720 } 2705 }
2721 2706
2722 public override void LockAngularMotion(Vector3 axis) 2707 public override void LockAngularMotion(byte axislocks)
2723 { 2708 {
2724 // reverse the zero/non zero values for ODE. 2709 // m_log.DebugFormat("[axislocks]: {0}", axislocks);
2725 if (axis.IsFinite()) 2710 m_taintAngularLock = axislocks;
2726 {
2727 axis.X = (axis.X > 0) ? 1f : 0f;
2728 axis.Y = (axis.Y > 0) ? 1f : 0f;
2729 axis.Z = (axis.Z > 0) ? 1f : 0f;
2730 m_log.DebugFormat("[axislock]: <{0},{1},{2}>", axis.X, axis.Y, axis.Z);
2731 m_taintAngularLock = axis;
2732 }
2733 else
2734 {
2735 m_log.WarnFormat("[PHYSICS]: Got NaN locking axis from Scene on Object {0}", Name);
2736 }
2737 } 2711 }
2738 2712
2739 internal void UpdatePositionAndVelocity() 2713 internal void UpdatePositionAndVelocity()
@@ -3021,7 +2995,7 @@ Console.WriteLine(" JointCreateFixed");
3021 2995
3022 public override float APIDDamping{ set { return; } } 2996 public override float APIDDamping{ set { return; } }
3023 2997
3024 private void createAMotor(Vector3 axis) 2998 private void createAMotor(byte axislocks)
3025 { 2999 {
3026 if (Body == IntPtr.Zero) 3000 if (Body == IntPtr.Zero)
3027 return; 3001 return;
@@ -3032,13 +3006,32 @@ Console.WriteLine(" JointCreateFixed");
3032 Amotor = IntPtr.Zero; 3006 Amotor = IntPtr.Zero;
3033 } 3007 }
3034 3008
3035 float axisnum = 3; 3009 if(axislocks == 0)
3036 3010 return;
3037 axisnum = (axisnum - (axis.X + axis.Y + axis.Z));
3038 3011
3039 // PhysicsVector totalSize = new PhysicsVector(_size.X, _size.Y, _size.Z); 3012 int axisnum = 0;
3013 bool axisX = false;
3014 bool axisY = false;
3015 bool axisZ = false;
3016 if((axislocks & 0x02) != 0)
3017 {
3018 axisnum++;
3019 axisX = true;
3020 }
3021 if((axislocks & 0x04) != 0)
3022 {
3023 axisnum++;
3024 axisY = true;
3025 }
3026 if((axislocks & 0x08) != 0)
3027 {
3028 axisnum++;
3029 axisZ = true;
3030 }
3040 3031
3041 3032 if(axisnum == 0)
3033 return;
3034
3042 // Inverse Inertia Matrix, set the X, Y, and/r Z inertia to 0 then invert it again. 3035 // Inverse Inertia Matrix, set the X, Y, and/r Z inertia to 0 then invert it again.
3043 d.Mass objMass; 3036 d.Mass objMass;
3044 d.MassSetZero(out objMass); 3037 d.MassSetZero(out objMass);
@@ -3061,23 +3054,21 @@ Console.WriteLine(" JointCreateFixed");
3061 3054
3062 mathmat = Inverse(mathmat); 3055 mathmat = Inverse(mathmat);
3063 */ 3056 */
3064 if (axis.X == 0) 3057 if (axisX)
3065 { 3058 {
3066 mathmat.M33 = 50.0000001f; 3059 mathmat.M33 = 50.0000001f;
3067 //objMass.I.M22 = 0; 3060 //objMass.I.M22 = 0;
3068 } 3061 }
3069 if (axis.Y == 0) 3062 if (axisY)
3070 { 3063 {
3071 mathmat.M22 = 50.0000001f; 3064 mathmat.M22 = 50.0000001f;
3072 //objMass.I.M11 = 0; 3065 //objMass.I.M11 = 0;
3073 } 3066 }
3074 if (axis.Z == 0) 3067 if (axisZ)
3075 { 3068 {
3076 mathmat.M11 = 50.0000001f; 3069 mathmat.M11 = 50.0000001f;
3077 //objMass.I.M00 = 0; 3070 //objMass.I.M00 = 0;
3078 } 3071 }
3079
3080
3081 3072
3082 mathmat = Inverse(mathmat); 3073 mathmat = Inverse(mathmat);
3083 objMass = FromMatrix4(mathmat, ref objMass); 3074 objMass = FromMatrix4(mathmat, ref objMass);
@@ -3104,25 +3095,25 @@ Console.WriteLine(" JointCreateFixed");
3104 d.JointSetAMotorNumAxes(Amotor,(int)axisnum); 3095 d.JointSetAMotorNumAxes(Amotor,(int)axisnum);
3105 int i = 0; 3096 int i = 0;
3106 3097
3107 if (axis.X == 0) 3098 if (axisX)
3108 { 3099 {
3109 d.JointSetAMotorAxis(Amotor, i, 0, 1, 0, 0); 3100 d.JointSetAMotorAxis(Amotor, i, 0, 1, 0, 0);
3110 i++; 3101 i++;
3111 } 3102 }
3112 3103
3113 if (axis.Y == 0) 3104 if (axisY)
3114 { 3105 {
3115 d.JointSetAMotorAxis(Amotor, i, 0, 0, 1, 0); 3106 d.JointSetAMotorAxis(Amotor, i, 0, 0, 1, 0);
3116 i++; 3107 i++;
3117 } 3108 }
3118 3109
3119 if (axis.Z == 0) 3110 if (axisZ)
3120 { 3111 {
3121 d.JointSetAMotorAxis(Amotor, i, 0, 0, 0, 1); 3112 d.JointSetAMotorAxis(Amotor, i, 0, 0, 0, 1);
3122 i++; 3113 i++;
3123 } 3114 }
3124 3115
3125 for (int j = 0; j < (int)axisnum; j++) 3116// for (int j = 0; j < (int)axisnum; j++)
3126 { 3117 {
3127 //d.JointSetAMotorAngle(Amotor, j, 0); 3118 //d.JointSetAMotorAngle(Amotor, j, 0);
3128 } 3119 }