aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs60
1 files changed, 45 insertions, 15 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs
index c9d0909..4f82c24 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;
@@ -614,6 +614,7 @@ namespace OpenSim.Region.Physics.OdePlugin
614 return vec; 614 return vec;
615 } 615 }
616 616
617 private const float pi = (float)Math.PI;
617 private const float halfpi = 0.5f * (float)Math.PI; 618 private const float halfpi = 0.5f * (float)Math.PI;
618 619
619 public static Vector3 ubitRot2Euler(Quaternion rot) 620 public static Vector3 ubitRot2Euler(Quaternion rot)
@@ -884,35 +885,64 @@ namespace OpenSim.Region.Physics.OdePlugin
884 float ftmp = 1.0f / m_verticalAttractionTimescale / m_verticalAttractionTimescale / _pParentScene.ODE_STEPSIZE; 885 float ftmp = 1.0f / m_verticalAttractionTimescale / m_verticalAttractionTimescale / _pParentScene.ODE_STEPSIZE;
885 float ftmp2 = m_verticalAttractionEfficiency / _pParentScene.ODE_STEPSIZE; 886 float ftmp2 = m_verticalAttractionEfficiency / _pParentScene.ODE_STEPSIZE;
886 887
887 if (Math.Abs(roll) > 0.01) // roll 888 if (roll > halfpi)
889 roll = pi - roll;
890 else if (roll < -halfpi)
891 roll = -pi - roll;
892
893 float effroll = pitch / halfpi;
894 effroll *= effroll;
895 effroll = 1 - effroll;
896 effroll *= roll;
897
898 if (Math.Abs(effroll) > 0.01) // roll
888 { 899 {
889 torque.X -= -roll * ftmp + curLocalAngVel.X * ftmp2; 900 torque.X -= -effroll * ftmp + curLocalAngVel.X * ftmp2;
890 } 901 }
891 902
892 if (Math.Abs(pitch) > 0.01 && ((m_flags & VehicleFlag.LIMIT_ROLL_ONLY) == 0)) // pitch 903 if ((m_flags & VehicleFlag.LIMIT_ROLL_ONLY) == 0)
893 { 904 {
894 torque.Y -= -pitch * ftmp + curLocalAngVel.Y * ftmp2; 905 float effpitch = roll / halfpi;
906 effpitch *= effpitch;
907 effpitch = 1 - effpitch;
908 effpitch *= pitch;
909
910 if (Math.Abs(effpitch) > 0.01) // pitch
911 {
912 torque.Y -= -effpitch * ftmp + curLocalAngVel.Y * ftmp2;
913 }
895 } 914 }
896 915
897 if (m_bankingEfficiency != 0 && Math.Abs(roll) > 0.01) 916 if (m_bankingEfficiency != 0 && Math.Abs(effroll) > 0.01)
898 { 917 {
899 float broll = roll * m_bankingEfficiency; ; 918
919 float broll = effroll;
920/*
921 if (broll > halfpi)
922 broll = pi - broll;
923 else if (broll < -halfpi)
924 broll = -pi - broll;
925*/
926 broll *= m_bankingEfficiency;
900 if (m_bankingMix != 0) 927 if (m_bankingMix != 0)
901 { 928 {
902 float vfact = Math.Abs(curLocalVel.X) / 10.0f; 929 float vfact = Math.Abs(curLocalVel.X) / 10.0f;
903 if (vfact > 1.0f) vfact = 1.0f; 930 if (vfact > 1.0f) vfact = 1.0f;
931
904 if (curLocalVel.X >= 0) 932 if (curLocalVel.X >= 0)
905 broll *= ((1 - m_bankingMix) + vfact); 933 broll *= (1 + (vfact - 1) * m_bankingMix);
906 else 934 else
907 broll *= -((1 - m_bankingMix) + vfact); 935 broll *= -(1 + (vfact - 1) * m_bankingMix);
908 } 936 }
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 937 // make z rot be in world Z not local as seems to be in sl
913 tmpV.X = 0; 938
914 tmpV.Y = 0; 939 broll = broll / m_bankingTimescale;
915 tmpV.Z = broll; 940
941 ftmp = -Math.Abs(m_bankingEfficiency) / m_bankingTimescale;
942
943 tmpV.X = ftmp * curAngVel.X;
944 tmpV.Y = ftmp * curAngVel.Y;
945 tmpV.Z = broll + ftmp * curAngVel.Z;
916 tmpV *= irotq; 946 tmpV *= irotq;
917 947
918 torque.X += tmpV.X; 948 torque.X += tmpV.X;