aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics
diff options
context:
space:
mode:
authorRobert Adams2012-12-02 20:07:05 -0800
committerRobert Adams2012-12-03 07:59:46 -0800
commit10fcc70b36aa1b38cd92e9c4d9c441e4c0eeb5f6 (patch)
tree06ab58e92bd94dbe68e9f87edfa36360bcb51f3b /OpenSim/Region/Physics
parentBulletSim: format vehicle detail logging messages so vehicle changs are group... (diff)
downloadopensim-SC-10fcc70b36aa1b38cd92e9c4d9c441e4c0eeb5f6.zip
opensim-SC-10fcc70b36aa1b38cd92e9c4d9c441e4c0eeb5f6.tar.gz
opensim-SC-10fcc70b36aa1b38cd92e9c4d9c441e4c0eeb5f6.tar.bz2
opensim-SC-10fcc70b36aa1b38cd92e9c4d9c441e4c0eeb5f6.tar.xz
BulletSim: revert angular vertical attraction from motor to code. The motor code did not return the restoring difference but the current value. Remove unused commented out code.
Diffstat (limited to 'OpenSim/Region/Physics')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs66
1 files changed, 19 insertions, 47 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index cbad3bf..4d067cf 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -125,7 +125,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
125 //Attractor properties 125 //Attractor properties
126 private BSVMotor m_verticalAttractionMotor = new BSVMotor("VerticalAttraction"); 126 private BSVMotor m_verticalAttractionMotor = new BSVMotor("VerticalAttraction");
127 private float m_verticalAttractionEfficiency = 1.0f; // damped 127 private float m_verticalAttractionEfficiency = 1.0f; // damped
128 private float m_verticalAttractionTimescale = 500f; // Timescale > 300 means no vert attractor. 128 private float m_verticalAttractionTimescale = 600f; // Timescale > 500 means no vert attractor.
129 129
130 public BSDynamics(BSScene myScene, BSPrim myPrim) 130 public BSDynamics(BSScene myScene, BSPrim myPrim)
131 { 131 {
@@ -573,6 +573,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
573 // Vector3 localInertia = new Vector3(1f, 1f, 1f); 573 // Vector3 localInertia = new Vector3(1f, 1f, 1f);
574 Vector3 localInertia = new Vector3(m_vehicleMass, m_vehicleMass, m_vehicleMass); 574 Vector3 localInertia = new Vector3(m_vehicleMass, m_vehicleMass, m_vehicleMass);
575 BulletSimAPI.SetMassProps2(Prim.PhysBody.ptr, m_vehicleMass, localInertia); 575 BulletSimAPI.SetMassProps2(Prim.PhysBody.ptr, m_vehicleMass, localInertia);
576 BulletSimAPI.UpdateInertiaTensor2(Prim.PhysBody.ptr);
576 577
577 VDetailLog("{0},BSDynamics.Refresh,frict={1},inert={2},aDamp={3}", 578 VDetailLog("{0},BSDynamics.Refresh,frict={1},inert={2},aDamp={3}",
578 Prim.LocalID, friction, localInertia, angularDamping); 579 Prim.LocalID, friction, localInertia, angularDamping);
@@ -958,34 +959,6 @@ namespace OpenSim.Region.Physics.BulletSPlugin
958 // Apply the effect of the angular motor. 959 // Apply the effect of the angular motor.
959 private void MoveAngular(float pTimestep) 960 private void MoveAngular(float pTimestep)
960 { 961 {
961 // m_angularMotorDirection // angular velocity requested by LSL motor
962 // m_angularMotorVelocity // current angular motor velocity (ramps up and down)
963 // m_angularMotorTimescale // motor angular velocity ramp up time
964 // m_angularMotorDecayTimescale // motor angular velocity decay rate
965 // m_angularFrictionTimescale // body angular velocity decay rate
966 // m_lastAngularVelocity // what was last applied to body
967
968 /*
969 if (m_angularMotorDirection.LengthSquared() > 0.0001)
970 {
971 Vector3 origVel = m_angularMotorVelocity;
972 Vector3 origDir = m_angularMotorDirection;
973
974 // new velocity += error / ( time to get there / step interval)
975 // requested direction - current vehicle direction
976 m_angularMotorVelocity += (m_angularMotorDirection - m_angularMotorVelocity) / (m_angularMotorTimescale / pTimestep);
977 // decay requested direction
978 m_angularMotorDirection *= (1.0f - (pTimestep * 1.0f/m_angularMotorDecayTimescale));
979
980 VDetailLog("{0}, MoveAngular,angularMotorApply,angTScale={1},timeStep={2},origvel={3},origDir={4},vel={5}",
981 Prim.LocalID, m_angularMotorTimescale, pTimestep, origVel, origDir, m_angularMotorVelocity);
982 }
983 else
984 {
985 m_angularMotorVelocity = Vector3.Zero;
986 }
987 */
988
989 Vector3 angularMotorContribution = m_angularMotor.Step(pTimestep); 962 Vector3 angularMotorContribution = m_angularMotor.Step(pTimestep);
990 963
991 // ================================================================== 964 // ==================================================================
@@ -1050,9 +1023,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1050 // ================================================================== 1023 // ==================================================================
1051 if (m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f)) 1024 if (m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f))
1052 { 1025 {
1053 m_lastAngularVelocity = Vector3.Zero; // Reduce small value to zero.
1054 // TODO: zeroing is good but it also sets values in unmanaged code. Remove the stores when idle. 1026 // TODO: zeroing is good but it also sets values in unmanaged code. Remove the stores when idle.
1055 VDetailLog("{0}, MoveAngular,done,zero,lastAngular={1}", Prim.LocalID, m_lastAngularVelocity); 1027 VDetailLog("{0}, MoveAngular,done,zero", Prim.LocalID);
1056 VehicleRotationalVelocity = Vector3.Zero; 1028 VehicleRotationalVelocity = Vector3.Zero;
1057 Prim.ZeroAngularMotion(true); 1029 Prim.ZeroAngularMotion(true);
1058 } 1030 }
@@ -1063,15 +1035,14 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1063 // Since we are stuffing the angular velocity directly into the object, the computed 1035 // Since we are stuffing the angular velocity directly into the object, the computed
1064 // velocity needs to be scaled by the timestep. 1036 // velocity needs to be scaled by the timestep.
1065 // Also remove any motion that is on the object so added motion is only from vehicle. 1037 // Also remove any motion that is on the object so added motion is only from vehicle.
1066 Vector3 applyAngularForce = ((m_lastAngularVelocity * pTimestep) - VehicleRotationalVelocity); 1038 Vector3 setAngularVelocity = ((m_lastAngularVelocity * pTimestep) - VehicleRotationalVelocity);
1067 // Unscale the force by the angular factor so it overwhelmes the Bullet additions. 1039 VehicleRotationalVelocity = setAngularVelocity;
1068 VehicleRotationalVelocity = applyAngularForce;
1069 1040
1070 VDetailLog("{0}, MoveAngular,done,nonZero,angMotor={1},vertAttr={2},bank={3},deflect={4},newAngForce={5},lastAngular={6}", 1041 VDetailLog("{0}, MoveAngular,done,nonZero,angMotorContrib={1},vertAttrContrib={2},bankContrib={3},deflectContrib={4},totalContrib={5},setAngVelocity={6}",
1071 Prim.LocalID, 1042 Prim.LocalID,
1072 angularMotorContribution, verticalAttractionContribution, 1043 angularMotorContribution, verticalAttractionContribution,
1073 bankingContribution, deflectionContribution, 1044 bankingContribution, deflectionContribution,
1074 applyAngularForce, m_lastAngularVelocity 1045 m_lastAngularVelocity, setAngularVelocity
1075 ); 1046 );
1076 } 1047 }
1077 } 1048 }
@@ -1083,12 +1054,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1083 // If vertical attaction timescale is reasonable and we applied an angular force last time... 1054 // If vertical attaction timescale is reasonable and we applied an angular force last time...
1084 if (m_verticalAttractionTimescale < 500) 1055 if (m_verticalAttractionTimescale < 500)
1085 { 1056 {
1057 /*
1086 Vector3 verticalError = Vector3.UnitZ * VehicleOrientation; 1058 Vector3 verticalError = Vector3.UnitZ * VehicleOrientation;
1087 verticalError.Normalize(); 1059 verticalError.Normalize();
1088 m_verticalAttractionMotor.SetCurrent(verticalError); 1060 m_verticalAttractionMotor.SetCurrent(verticalError);
1089 m_verticalAttractionMotor.SetTarget(Vector3.UnitZ); 1061 m_verticalAttractionMotor.SetTarget(Vector3.UnitZ);
1090 ret = m_verticalAttractionMotor.Step(pTimestep); 1062 ret = m_verticalAttractionMotor.Step(pTimestep);
1091 /* 1063 */
1092 // Take a vector pointing up and convert it from world to vehicle relative coords. 1064 // Take a vector pointing up and convert it from world to vehicle relative coords.
1093 Vector3 verticalError = Vector3.UnitZ * VehicleOrientation; 1065 Vector3 verticalError = Vector3.UnitZ * VehicleOrientation;
1094 verticalError.Normalize(); 1066 verticalError.Normalize();
@@ -1108,25 +1080,25 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1108 } 1080 }
1109 1081
1110 // Y error means needed rotation around X axis and visa versa. 1082 // Y error means needed rotation around X axis and visa versa.
1111 verticalAttractionContribution.X = verticalError.Y; 1083 ret.X = verticalError.Y;
1112 verticalAttractionContribution.Y = - verticalError.X; 1084 ret.Y = - verticalError.X;
1113 verticalAttractionContribution.Z = 0f; 1085 ret.Z = 0f;
1114 1086
1115 // scale by the time scale and timestep 1087 // scale by the time scale and timestep
1116 Vector3 unscaledContrib = verticalAttractionContribution; 1088 Vector3 unscaledContrib = ret;
1117 verticalAttractionContribution /= m_verticalAttractionTimescale; 1089 ret /= m_verticalAttractionTimescale;
1118 verticalAttractionContribution *= pTimestep; 1090 ret *= pTimestep;
1119 1091
1120 // apply efficiency 1092 // apply efficiency
1121 Vector3 preEfficiencyContrib = verticalAttractionContribution; 1093 Vector3 preEfficiencyContrib = ret;
1094 // Effenciency squared seems to give a more realistic effect
1122 float efficencySquared = m_verticalAttractionEfficiency * m_verticalAttractionEfficiency; 1095 float efficencySquared = m_verticalAttractionEfficiency * m_verticalAttractionEfficiency;
1123 verticalAttractionContribution *= (m_verticalAttractionEfficiency * m_verticalAttractionEfficiency); 1096 ret *= efficencySquared;
1124 1097
1125 VDetailLog("{0}, MoveAngular,verticalAttraction,,verticalError={1},unscaled={2},preEff={3},eff={4},effSq={5},vertAttr={6}", 1098 VDetailLog("{0}, MoveAngular,verticalAttraction,,verticalError={1},unscaled={2},preEff={3},eff={4},effSq={5},vertAttr={6}",
1126 Prim.LocalID, verticalError, unscaledContrib, preEfficiencyContrib, 1099 Prim.LocalID, verticalError, unscaledContrib, preEfficiencyContrib,
1127 m_verticalAttractionEfficiency, efficencySquared, 1100 m_verticalAttractionEfficiency, efficencySquared,
1128 verticalAttractionContribution); 1101 ret);
1129 */
1130 1102
1131 } 1103 }
1132 return ret; 1104 return ret;