aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs')
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs71
1 files changed, 56 insertions, 15 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs
index c9d0909..0fabb56 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs
@@ -38,7 +38,7 @@
38 * settings use. 38 * settings use.
39 */ 39 */
40 40
41// Ubit 2012 41// Extensive change Ubit 2012
42 42
43using System; 43using System;
44using System.Collections.Generic; 44using System.Collections.Generic;
@@ -120,6 +120,16 @@ namespace OpenSim.Region.Physics.OdePlugin
120 private float m_lmEfect = 0; // current linear motor eficiency 120 private float m_lmEfect = 0; // current linear motor eficiency
121 private float m_amEfect = 0; // current angular motor eficiency 121 private float m_amEfect = 0; // current angular motor eficiency
122 122
123 public bool EngineActive
124 {
125 get
126 {
127 if (m_lmEfect > 0.01)
128 return true;
129 return false;
130 }
131 }
132
123 133
124 public ODEDynamics(OdePrim rootp) 134 public ODEDynamics(OdePrim rootp)
125 { 135 {
@@ -152,6 +162,7 @@ namespace OpenSim.Region.Physics.OdePlugin
152 m_linearMotorTimescale = vd.m_linearMotorTimescale; 162 m_linearMotorTimescale = vd.m_linearMotorTimescale;
153 if (m_linearMotorTimescale < timestep) m_linearMotorTimescale = timestep; 163 if (m_linearMotorTimescale < timestep) m_linearMotorTimescale = timestep;
154 164
165
155 m_linearMotorOffset = vd.m_linearMotorOffset; 166 m_linearMotorOffset = vd.m_linearMotorOffset;
156 167
157 //Angular properties 168 //Angular properties
@@ -614,6 +625,7 @@ namespace OpenSim.Region.Physics.OdePlugin
614 return vec; 625 return vec;
615 } 626 }
616 627
628 private const float pi = (float)Math.PI;
617 private const float halfpi = 0.5f * (float)Math.PI; 629 private const float halfpi = 0.5f * (float)Math.PI;
618 630
619 public static Vector3 ubitRot2Euler(Quaternion rot) 631 public static Vector3 ubitRot2Euler(Quaternion rot)
@@ -884,35 +896,64 @@ namespace OpenSim.Region.Physics.OdePlugin
884 float ftmp = 1.0f / m_verticalAttractionTimescale / m_verticalAttractionTimescale / _pParentScene.ODE_STEPSIZE; 896 float ftmp = 1.0f / m_verticalAttractionTimescale / m_verticalAttractionTimescale / _pParentScene.ODE_STEPSIZE;
885 float ftmp2 = m_verticalAttractionEfficiency / _pParentScene.ODE_STEPSIZE; 897 float ftmp2 = m_verticalAttractionEfficiency / _pParentScene.ODE_STEPSIZE;
886 898
887 if (Math.Abs(roll) > 0.01) // roll 899 if (roll > halfpi)
900 roll = pi - roll;
901 else if (roll < -halfpi)
902 roll = -pi - roll;
903
904 float effroll = pitch / halfpi;
905 effroll *= effroll;
906 effroll = 1 - effroll;
907 effroll *= roll;
908
909 if (Math.Abs(effroll) > 0.01) // roll
888 { 910 {
889 torque.X -= -roll * ftmp + curLocalAngVel.X * ftmp2; 911 torque.X -= -effroll * ftmp + curLocalAngVel.X * ftmp2;
890 } 912 }
891 913
892 if (Math.Abs(pitch) > 0.01 && ((m_flags & VehicleFlag.LIMIT_ROLL_ONLY) == 0)) // pitch 914 if ((m_flags & VehicleFlag.LIMIT_ROLL_ONLY) == 0)
893 { 915 {
894 torque.Y -= -pitch * ftmp + curLocalAngVel.Y * ftmp2; 916 float effpitch = roll / halfpi;
917 effpitch *= effpitch;
918 effpitch = 1 - effpitch;
919 effpitch *= pitch;
920
921 if (Math.Abs(effpitch) > 0.01) // pitch
922 {
923 torque.Y -= -effpitch * ftmp + curLocalAngVel.Y * ftmp2;
924 }
895 } 925 }
896 926
897 if (m_bankingEfficiency != 0 && Math.Abs(roll) > 0.01) 927 if (m_bankingEfficiency != 0 && Math.Abs(effroll) > 0.01)
898 { 928 {
899 float broll = roll * m_bankingEfficiency; ; 929
930 float broll = effroll;
931/*
932 if (broll > halfpi)
933 broll = pi - broll;
934 else if (broll < -halfpi)
935 broll = -pi - broll;
936*/
937 broll *= m_bankingEfficiency;
900 if (m_bankingMix != 0) 938 if (m_bankingMix != 0)
901 { 939 {
902 float vfact = Math.Abs(curLocalVel.X) / 10.0f; 940 float vfact = Math.Abs(curLocalVel.X) / 10.0f;
903 if (vfact > 1.0f) vfact = 1.0f; 941 if (vfact > 1.0f) vfact = 1.0f;
942
904 if (curLocalVel.X >= 0) 943 if (curLocalVel.X >= 0)
905 broll *= ((1 - m_bankingMix) + vfact); 944 broll *= (1 + (vfact - 1) * m_bankingMix);
906 else 945 else
907 broll *= -((1 - m_bankingMix) + vfact); 946 broll *= -(1 + (vfact - 1) * m_bankingMix);
908 } 947 }
909 broll = (broll - curLocalAngVel.Z) / m_bankingTimescale;
910 // torque.Z += broll;
911
912 // make z rot be in world Z not local as seems to be in sl 948 // make z rot be in world Z not local as seems to be in sl
913 tmpV.X = 0; 949
914 tmpV.Y = 0; 950 broll = broll / m_bankingTimescale;
915 tmpV.Z = broll; 951
952 ftmp = -Math.Abs(m_bankingEfficiency) / m_bankingTimescale;
953
954 tmpV.X = ftmp * curAngVel.X;
955 tmpV.Y = ftmp * curAngVel.Y;
956 tmpV.Z = broll + ftmp * curAngVel.Z;
916 tmpV *= irotq; 957 tmpV *= irotq;
917 958
918 torque.X += tmpV.X; 959 torque.X += tmpV.X;