aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs196
1 files changed, 89 insertions, 107 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index 6601479..fe7891e 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -35,6 +35,7 @@ using System.Collections.Generic;
35using System.Reflection; 35using System.Reflection;
36using System.Runtime.InteropServices; 36using System.Runtime.InteropServices;
37using OpenMetaverse; 37using OpenMetaverse;
38using OpenSim.Framework;
38using OpenSim.Region.Physics.Manager; 39using OpenSim.Region.Physics.Manager;
39 40
40namespace OpenSim.Region.Physics.BulletSPlugin 41namespace OpenSim.Region.Physics.BulletSPlugin
@@ -154,7 +155,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
154 // Return 'true' if this vehicle is doing vehicle things 155 // Return 'true' if this vehicle is doing vehicle things
155 public bool IsActive 156 public bool IsActive
156 { 157 {
157 get { return (Type != Vehicle.TYPE_NONE && !Prim.IsStatic); } 158 get { return (Type != Vehicle.TYPE_NONE && Prim.IsPhysicallyActive); }
158 } 159 }
159 160
160 #region Vehicle parameter setting 161 #region Vehicle parameter setting
@@ -230,6 +231,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
230 break; 231 break;
231 case Vehicle.ANGULAR_MOTOR_DIRECTION: 232 case Vehicle.ANGULAR_MOTOR_DIRECTION:
232 m_angularMotorDirection = new Vector3(pValue, pValue, pValue); 233 m_angularMotorDirection = new Vector3(pValue, pValue, pValue);
234 m_angularMotor.Zero();
233 m_angularMotor.SetTarget(m_angularMotorDirection); 235 m_angularMotor.SetTarget(m_angularMotorDirection);
234 break; 236 break;
235 case Vehicle.LINEAR_FRICTION_TIMESCALE: 237 case Vehicle.LINEAR_FRICTION_TIMESCALE:
@@ -263,6 +265,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
263 pValue.Y = ClampInRange(-12.56f, pValue.Y, 12.56f); 265 pValue.Y = ClampInRange(-12.56f, pValue.Y, 12.56f);
264 pValue.Z = ClampInRange(-12.56f, pValue.Z, 12.56f); 266 pValue.Z = ClampInRange(-12.56f, pValue.Z, 12.56f);
265 m_angularMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z); 267 m_angularMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z);
268 m_angularMotor.Zero();
266 m_angularMotor.SetTarget(m_angularMotorDirection); 269 m_angularMotor.SetTarget(m_angularMotorDirection);
267 break; 270 break;
268 case Vehicle.LINEAR_FRICTION_TIMESCALE: 271 case Vehicle.LINEAR_FRICTION_TIMESCALE:
@@ -687,7 +690,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
687 // Bullet does a bunch of smoothing for changing parameters. 690 // Bullet does a bunch of smoothing for changing parameters.
688 // Since the vehicle is demanding this setting, we override Bullet's smoothing 691 // Since the vehicle is demanding this setting, we override Bullet's smoothing
689 // by telling Bullet the value was the same last time. 692 // by telling Bullet the value was the same last time.
690 PhysicsScene.PE.SetInterpolationLinearVelocity(Prim.PhysBody, m_knownVelocity); 693 // PhysicsScene.PE.SetInterpolationLinearVelocity(Prim.PhysBody, m_knownVelocity);
691 } 694 }
692 695
693 if ((m_knownChanged & m_knownChangedForce) != 0) 696 if ((m_knownChanged & m_knownChangedForce) != 0)
@@ -699,7 +702,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
699 if ((m_knownChanged & m_knownChangedRotationalVelocity) != 0) 702 if ((m_knownChanged & m_knownChangedRotationalVelocity) != 0)
700 { 703 {
701 Prim.ForceRotationalVelocity = m_knownRotationalVelocity; 704 Prim.ForceRotationalVelocity = m_knownRotationalVelocity;
702 PhysicsScene.PE.SetInterpolationAngularVelocity(Prim.PhysBody, m_knownRotationalVelocity); 705 // PhysicsScene.PE.SetInterpolationAngularVelocity(Prim.PhysBody, m_knownRotationalVelocity);
703 } 706 }
704 707
705 if ((m_knownChanged & m_knownChangedRotationalImpulse) != 0) 708 if ((m_knownChanged & m_knownChangedRotationalImpulse) != 0)
@@ -719,10 +722,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin
719 722
720 // Since the computation of terrain height can be a little involved, this routine 723 // Since the computation of terrain height can be a little involved, this routine
721 // is used to fetch the height only once for each vehicle simulation step. 724 // is used to fetch the height only once for each vehicle simulation step.
725 Vector3 lastRememberedHeightPos;
722 private float GetTerrainHeight(Vector3 pos) 726 private float GetTerrainHeight(Vector3 pos)
723 { 727 {
724 if ((m_knownHas & m_knownChangedTerrainHeight) == 0) 728 if ((m_knownHas & m_knownChangedTerrainHeight) == 0 || pos != lastRememberedHeightPos)
725 { 729 {
730 lastRememberedHeightPos = pos;
726 m_knownTerrainHeight = Prim.PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(pos); 731 m_knownTerrainHeight = Prim.PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(pos);
727 m_knownHas |= m_knownChangedTerrainHeight; 732 m_knownHas |= m_knownChangedTerrainHeight;
728 } 733 }
@@ -942,10 +947,10 @@ namespace OpenSim.Region.Physics.BulletSPlugin
942 // ================================================================== 947 // ==================================================================
943 // Clamp high or low velocities 948 // Clamp high or low velocities
944 float newVelocityLengthSq = VehicleVelocity.LengthSquared(); 949 float newVelocityLengthSq = VehicleVelocity.LengthSquared();
945 if (newVelocityLengthSq > 1000f) 950 if (newVelocityLengthSq > BSParam.VehicleMaxLinearVelocity)
946 { 951 {
947 VehicleVelocity /= VehicleVelocity.Length(); 952 VehicleVelocity /= VehicleVelocity.Length();
948 VehicleVelocity *= 1000f; 953 VehicleVelocity *= BSParam.VehicleMaxLinearVelocity;
949 } 954 }
950 else if (newVelocityLengthSq < 0.001f) 955 else if (newVelocityLengthSq < 0.001f)
951 VehicleVelocity = Vector3.Zero; 956 VehicleVelocity = Vector3.Zero;
@@ -956,39 +961,25 @@ namespace OpenSim.Region.Physics.BulletSPlugin
956 961
957 public void ComputeLinearVelocity(float pTimestep) 962 public void ComputeLinearVelocity(float pTimestep)
958 { 963 {
959 Vector3 linearMotorStep = m_linearMotor.Step(pTimestep); 964 // Step the motor from the current value. Get the correction needed this step.
965 Vector3 currentVel = VehicleVelocity * Quaternion.Inverse(VehicleOrientation);
966 Vector3 linearMotorCorrectionV = m_linearMotor.Step(pTimestep, currentVel);
960 967
961 // The movement computed in the linear motor is relative to the vehicle 968 // Motor is vehicle coordinates. Rotate it to world coordinates
962 // coordinates. Rotate the movement to world coordinates. 969 Vector3 linearMotorVelocityW = linearMotorCorrectionV * VehicleOrientation;
963 Vector3 linearMotorVelocity = linearMotorStep * VehicleOrientation;
964 970
965 // If we're a ground vehicle, don't loose any Z action (like gravity acceleration). 971 // If we're a ground vehicle, don't add any upward Z movement
966 float mixFactor = 1f; // 1 means use all linear motor Z value, 0 means use all existing Z
967 if ((m_flags & VehicleFlag.LIMIT_MOTOR_UP) != 0) 972 if ((m_flags & VehicleFlag.LIMIT_MOTOR_UP) != 0)
968 { 973 {
969 if (!Prim.IsColliding) 974 if (linearMotorVelocityW.Z > 0f)
970 { 975 linearMotorVelocityW.Z = 0f;
971 // If a ground vehicle and not on the ground, I want gravity effect
972 mixFactor = 0.2f;
973 }
974 }
975 else
976 {
977 // I'm not a ground vehicle but don't totally loose the effect of the environment
978 mixFactor = 0.8f;
979 } 976 }
980 linearMotorVelocity.Z = mixFactor * linearMotorVelocity.Z + (1f - mixFactor) * VehicleVelocity.Z;
981
982 // What we want to contribute to the vehicle's existing velocity
983 Vector3 linearMotorForce = linearMotorVelocity - VehicleVelocity;
984
985 // Act against the inertia of the vehicle
986 linearMotorForce *= m_vehicleMass;
987 977
988 VehicleAddForceImpulse(linearMotorForce * pTimestep); 978 // Add this correction to the velocity to make it faster/slower.
979 VehicleVelocity += linearMotorVelocityW;
989 980
990 VDetailLog("{0}, MoveLinear,velocity,vehVel={1},step={2},stepVel={3},mix={4},force={5}", 981 VDetailLog("{0}, MoveLinear,velocity,vehVel={1},correction={2},force={3}",
991 Prim.LocalID, VehicleVelocity, linearMotorStep, linearMotorVelocity, mixFactor, linearMotorForce); 982 Prim.LocalID, VehicleVelocity, linearMotorCorrectionV, linearMotorVelocityW);
992 } 983 }
993 984
994 public void ComputeLinearTerrainHeightCorrection(float pTimestep) 985 public void ComputeLinearTerrainHeightCorrection(float pTimestep)
@@ -1132,8 +1123,6 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1132 // a downward raycast to find what is below. 1123 // a downward raycast to find what is below.
1133 public void ComputeLinearMotorUp(float pTimestep) 1124 public void ComputeLinearMotorUp(float pTimestep)
1134 { 1125 {
1135 Vector3 ret = Vector3.Zero;
1136
1137 if ((m_flags & (VehicleFlag.LIMIT_MOTOR_UP)) != 0) 1126 if ((m_flags & (VehicleFlag.LIMIT_MOTOR_UP)) != 0)
1138 { 1127 {
1139 // This code tries to decide if the object is not on the ground and then pushing down 1128 // This code tries to decide if the object is not on the ground and then pushing down
@@ -1201,62 +1190,27 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1201 // set directly on the vehicle. 1190 // set directly on the vehicle.
1202 private void MoveAngular(float pTimestep) 1191 private void MoveAngular(float pTimestep)
1203 { 1192 {
1204 // The user wants this many radians per second angular change? 1193 // VehicleRotationalVelocity = Vector3.Zero;
1205 Vector3 angularMotorContribution = m_angularMotor.Step(pTimestep);
1206 1194
1207 // ================================================================== 1195 ComputeAngularTurning(pTimestep);
1208 // From http://wiki.secondlife.com/wiki/LlSetVehicleFlags :
1209 // This flag prevents linear deflection parallel to world z-axis. This is useful
1210 // for preventing ground vehicles with large linear deflection, like bumper cars,
1211 // from climbing their linear deflection into the sky.
1212 // That is, NO_DEFLECTION_UP says angular motion should not add any pitch or roll movement
1213 // TODO: This is here because this is where ODE put it but documentation says it
1214 // is a linear effect. Where should this check go?
1215 if ((m_flags & (VehicleFlag.NO_DEFLECTION_UP)) != 0)
1216 {
1217 angularMotorContribution.X = 0f;
1218 angularMotorContribution.Y = 0f;
1219 VDetailLog("{0}, MoveAngular,noDeflectionUp,angularMotorContrib={1}", Prim.LocalID, angularMotorContribution);
1220 }
1221
1222 Vector3 verticalAttractionContribution = ComputeAngularVerticalAttraction();
1223 1196
1224 Vector3 deflectionContribution = ComputeAngularDeflection(); 1197 ComputeAngularVerticalAttraction();
1225 1198
1226 Vector3 bankingContribution = ComputeAngularBanking(); 1199 ComputeAngularDeflection();
1227 1200
1228 // ================================================================== 1201 ComputeAngularBanking();
1229 m_lastVertAttractor = verticalAttractionContribution;
1230
1231 m_lastAngularVelocity = angularMotorContribution
1232 + verticalAttractionContribution
1233 + deflectionContribution
1234 + bankingContribution;
1235
1236 // Add of the above computation are made relative to vehicle coordinates.
1237 // Convert to world coordinates.
1238 m_lastAngularVelocity *= VehicleOrientation;
1239 1202
1240 // ================================================================== 1203 // ==================================================================
1241 // Apply the correction velocity. 1204 if (VehicleRotationalVelocity.ApproxEquals(Vector3.Zero, 0.01f))
1242 // TODO: Should this be applied as an angular force (torque)?
1243 if (!m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f))
1244 {
1245 VehicleRotationalVelocity = m_lastAngularVelocity;
1246
1247 VDetailLog("{0}, MoveAngular,done,nonZero,angMotorContrib={1},vertAttrContrib={2},bankContrib={3},deflectContrib={4},totalContrib={5}",
1248 Prim.LocalID,
1249 angularMotorContribution, verticalAttractionContribution,
1250 bankingContribution, deflectionContribution,
1251 m_lastAngularVelocity
1252 );
1253 }
1254 else
1255 { 1205 {
1256 // The vehicle is not adding anything angular wise. 1206 // The vehicle is not adding anything angular wise.
1257 VehicleRotationalVelocity = Vector3.Zero; 1207 VehicleRotationalVelocity = Vector3.Zero;
1258 VDetailLog("{0}, MoveAngular,done,zero", Prim.LocalID); 1208 VDetailLog("{0}, MoveAngular,done,zero", Prim.LocalID);
1259 } 1209 }
1210 else
1211 {
1212 VDetailLog("{0}, MoveAngular,done,nonZero,angVel={1}", Prim.LocalID, VehicleRotationalVelocity);
1213 }
1260 1214
1261 // ================================================================== 1215 // ==================================================================
1262 //Offset section 1216 //Offset section
@@ -1290,6 +1244,31 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1290 } 1244 }
1291 1245
1292 } 1246 }
1247
1248 private void ComputeAngularTurning(float pTimestep)
1249 {
1250 // The user wants this many radians per second angular change?
1251 Vector3 currentAngularV = VehicleRotationalVelocity * Quaternion.Inverse(VehicleOrientation);
1252 Vector3 angularMotorContributionV = m_angularMotor.Step(pTimestep, currentAngularV);
1253
1254 // ==================================================================
1255 // From http://wiki.secondlife.com/wiki/LlSetVehicleFlags :
1256 // This flag prevents linear deflection parallel to world z-axis. This is useful
1257 // for preventing ground vehicles with large linear deflection, like bumper cars,
1258 // from climbing their linear deflection into the sky.
1259 // That is, NO_DEFLECTION_UP says angular motion should not add any pitch or roll movement
1260 // TODO: This is here because this is where ODE put it but documentation says it
1261 // is a linear effect. Where should this check go?
1262 if ((m_flags & (VehicleFlag.NO_DEFLECTION_UP)) != 0)
1263 {
1264 angularMotorContributionV.X = 0f;
1265 angularMotorContributionV.Y = 0f;
1266 }
1267
1268 VehicleRotationalVelocity += angularMotorContributionV * VehicleOrientation;
1269 VDetailLog("{0}, MoveAngular,angularTurning,angularMotorContrib={1}", Prim.LocalID, angularMotorContributionV);
1270 }
1271
1293 // From http://wiki.secondlife.com/wiki/Linden_Vehicle_Tutorial: 1272 // From http://wiki.secondlife.com/wiki/Linden_Vehicle_Tutorial:
1294 // Some vehicles, like boats, should always keep their up-side up. This can be done by 1273 // Some vehicles, like boats, should always keep their up-side up. This can be done by
1295 // enabling the "vertical attractor" behavior that springs the vehicle's local z-axis to 1274 // enabling the "vertical attractor" behavior that springs the vehicle's local z-axis to
@@ -1298,13 +1277,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1298 // and then set the VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY to control the damping. An 1277 // and then set the VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY to control the damping. An
1299 // efficiency of 0.0 will cause the spring to wobble around its equilibrium, while an 1278 // efficiency of 0.0 will cause the spring to wobble around its equilibrium, while an
1300 // efficiency of 1.0 will cause the spring to reach its equilibrium with exponential decay. 1279 // efficiency of 1.0 will cause the spring to reach its equilibrium with exponential decay.
1301 public Vector3 ComputeAngularVerticalAttraction() 1280 public void ComputeAngularVerticalAttraction()
1302 { 1281 {
1303 Vector3 ret = Vector3.Zero;
1304
1305 // If vertical attaction timescale is reasonable 1282 // If vertical attaction timescale is reasonable
1306 if (enableAngularVerticalAttraction && m_verticalAttractionTimescale < m_verticalAttractionCutoff) 1283 if (enableAngularVerticalAttraction && m_verticalAttractionTimescale < m_verticalAttractionCutoff)
1307 { 1284 {
1285 Vector3 vertContributionV = Vector3.Zero;
1286
1308 // Take a vector pointing up and convert it from world to vehicle relative coords. 1287 // Take a vector pointing up and convert it from world to vehicle relative coords.
1309 Vector3 verticalError = Vector3.UnitZ * VehicleOrientation; 1288 Vector3 verticalError = Vector3.UnitZ * VehicleOrientation;
1310 1289
@@ -1318,37 +1297,36 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1318 1297
1319 // Y error means needed rotation around X axis and visa versa. 1298 // Y error means needed rotation around X axis and visa versa.
1320 // Since the error goes from zero to one, the asin is the corresponding angle. 1299 // Since the error goes from zero to one, the asin is the corresponding angle.
1321 ret.X = (float)Math.Asin(verticalError.Y); 1300 vertContributionV.X = (float)Math.Asin(verticalError.Y);
1322 // (Tilt forward (positive X) needs to tilt back (rotate negative) around Y axis.) 1301 // (Tilt forward (positive X) needs to tilt back (rotate negative) around Y axis.)
1323 ret.Y = -(float)Math.Asin(verticalError.X); 1302 vertContributionV.Y = -(float)Math.Asin(verticalError.X);
1324 1303
1325 // If verticalError.Z is negative, the vehicle is upside down. Add additional push. 1304 // If verticalError.Z is negative, the vehicle is upside down. Add additional push.
1326 if (verticalError.Z < 0f) 1305 if (verticalError.Z < 0f)
1327 { 1306 {
1328 ret.X += PIOverFour; 1307 vertContributionV.X += PIOverFour;
1329 ret.Y += PIOverFour; 1308 // vertContribution.Y -= PIOverFour;
1330 } 1309 }
1331 1310
1332 // 'ret' is now the necessary velocity to correct tilt in one second. 1311 // 'vertContrbution' is now the necessary angular correction to correct tilt in one second.
1333 // Correction happens over a number of seconds. 1312 // Correction happens over a number of seconds.
1334 Vector3 unscaledContrib = ret; 1313 Vector3 unscaledContrib = vertContributionV; // DEBUG DEBUG
1335 ret /= m_verticalAttractionTimescale; 1314 vertContributionV /= m_verticalAttractionTimescale;
1315
1316 VehicleRotationalVelocity += vertContributionV * VehicleOrientation;
1336 1317
1337 VDetailLog("{0}, MoveAngular,verticalAttraction,,verticalError={1},unscaled={2},eff={3},ts={4},vertAttr={5}", 1318 VDetailLog("{0}, MoveAngular,verticalAttraction,,verticalError={1},unscaled={2},eff={3},ts={4},vertAttr={5}",
1338 Prim.LocalID, verticalError, unscaledContrib, m_verticalAttractionEfficiency, m_verticalAttractionTimescale, ret); 1319 Prim.LocalID, verticalError, unscaledContrib, m_verticalAttractionEfficiency, m_verticalAttractionTimescale, vertContributionV);
1339 } 1320 }
1340 return ret;
1341 } 1321 }
1342 1322
1343 // Return the angular correction to correct the direction the vehicle is pointing to be 1323 // Angular correction to correct the direction the vehicle is pointing to be
1344 // the direction is should want to be pointing. 1324 // the direction is should want to be pointing.
1345 // The vehicle is moving in some direction and correct its orientation to it is pointing 1325 // The vehicle is moving in some direction and correct its orientation to it is pointing
1346 // in that direction. 1326 // in that direction.
1347 // TODO: implement reference frame. 1327 // TODO: implement reference frame.
1348 public Vector3 ComputeAngularDeflection() 1328 public void ComputeAngularDeflection()
1349 { 1329 {
1350 Vector3 ret = Vector3.Zero;
1351
1352 // Since angularMotorUp and angularDeflection are computed independently, they will calculate 1330 // Since angularMotorUp and angularDeflection are computed independently, they will calculate
1353 // approximately the same X or Y correction. When added together (when contributions are combined) 1331 // approximately the same X or Y correction. When added together (when contributions are combined)
1354 // this creates an over-correction and then wabbling as the target is overshot. 1332 // this creates an over-correction and then wabbling as the target is overshot.
@@ -1356,6 +1334,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1356 1334
1357 if (enableAngularDeflection && m_angularDeflectionEfficiency != 0 && VehicleForwardSpeed > 0.2) 1335 if (enableAngularDeflection && m_angularDeflectionEfficiency != 0 && VehicleForwardSpeed > 0.2)
1358 { 1336 {
1337 Vector3 deflectContributionV = Vector3.Zero;
1338
1359 // The direction the vehicle is moving 1339 // The direction the vehicle is moving
1360 Vector3 movingDirection = VehicleVelocity; 1340 Vector3 movingDirection = VehicleVelocity;
1361 movingDirection.Normalize(); 1341 movingDirection.Normalize();
@@ -1381,18 +1361,19 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1381 // ret = m_angularDeflectionCorrectionMotor(1f, deflectionError); 1361 // ret = m_angularDeflectionCorrectionMotor(1f, deflectionError);
1382 1362
1383 // Scale the correction by recovery timescale and efficiency 1363 // Scale the correction by recovery timescale and efficiency
1384 ret = (-deflectionError) * m_angularDeflectionEfficiency; 1364 deflectContributionV = (-deflectionError) * m_angularDeflectionEfficiency;
1385 ret /= m_angularDeflectionTimescale; 1365 deflectContributionV /= m_angularDeflectionTimescale;
1366
1367 VehicleRotationalVelocity += deflectContributionV * VehicleOrientation;
1386 1368
1387 VDetailLog("{0}, MoveAngular,Deflection,movingDir={1},pointingDir={2},deflectError={3},ret={4}", 1369 VDetailLog("{0}, MoveAngular,Deflection,movingDir={1},pointingDir={2},deflectError={3},ret={4}",
1388 Prim.LocalID, movingDirection, pointingDirection, deflectionError, ret); 1370 Prim.LocalID, movingDirection, pointingDirection, deflectionError, deflectContributionV);
1389 VDetailLog("{0}, MoveAngular,Deflection,fwdSpd={1},defEff={2},defTS={3}", 1371 VDetailLog("{0}, MoveAngular,Deflection,fwdSpd={1},defEff={2},defTS={3}",
1390 Prim.LocalID, VehicleForwardSpeed, m_angularDeflectionEfficiency, m_angularDeflectionTimescale); 1372 Prim.LocalID, VehicleForwardSpeed, m_angularDeflectionEfficiency, m_angularDeflectionTimescale);
1391 } 1373 }
1392 return ret;
1393 } 1374 }
1394 1375
1395 // Return an angular change to rotate the vehicle around the Z axis when the vehicle 1376 // Angular change to rotate the vehicle around the Z axis when the vehicle
1396 // is tipped around the X axis. 1377 // is tipped around the X axis.
1397 // From http://wiki.secondlife.com/wiki/Linden_Vehicle_Tutorial: 1378 // From http://wiki.secondlife.com/wiki/Linden_Vehicle_Tutorial:
1398 // The vertical attractor feature must be enabled in order for the banking behavior to 1379 // The vertical attractor feature must be enabled in order for the banking behavior to
@@ -1423,12 +1404,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1423 // world z-axis is determined by the VEHICLE_BANKING_TIMESCALE. So if you want the vehicle to 1404 // world z-axis is determined by the VEHICLE_BANKING_TIMESCALE. So if you want the vehicle to
1424 // bank quickly then give it a banking timescale of about a second or less, otherwise you can 1405 // bank quickly then give it a banking timescale of about a second or less, otherwise you can
1425 // make a sluggish vehicle by giving it a timescale of several seconds. 1406 // make a sluggish vehicle by giving it a timescale of several seconds.
1426 public Vector3 ComputeAngularBanking() 1407 public void ComputeAngularBanking()
1427 { 1408 {
1428 Vector3 ret = Vector3.Zero;
1429
1430 if (enableAngularBanking && m_bankingEfficiency != 0 && m_verticalAttractionTimescale < m_verticalAttractionCutoff) 1409 if (enableAngularBanking && m_bankingEfficiency != 0 && m_verticalAttractionTimescale < m_verticalAttractionCutoff)
1431 { 1410 {
1411 Vector3 bankingContributionV = Vector3.Zero;
1412
1432 // Rotate a UnitZ vector (pointing up) to how the vehicle is oriented. 1413 // Rotate a UnitZ vector (pointing up) to how the vehicle is oriented.
1433 // As the vehicle rolls to the right or left, the Y value will increase from 1414 // As the vehicle rolls to the right or left, the Y value will increase from
1434 // zero (straight up) to 1 or -1 (full tilt right or left) 1415 // zero (straight up) to 1 or -1 (full tilt right or left)
@@ -1445,15 +1426,16 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1445 mixedYawAngle = ClampInRange(-20f, mixedYawAngle, 20f); 1426 mixedYawAngle = ClampInRange(-20f, mixedYawAngle, 20f);
1446 1427
1447 // Build the force vector to change rotation from what it is to what it should be 1428 // Build the force vector to change rotation from what it is to what it should be
1448 ret.Z = -mixedYawAngle; 1429 bankingContributionV.Z = -mixedYawAngle;
1449 1430
1450 // Don't do it all at once. 1431 // Don't do it all at once.
1451 ret /= m_bankingTimescale; 1432 bankingContributionV /= m_bankingTimescale;
1433
1434 VehicleRotationalVelocity += bankingContributionV * VehicleOrientation;
1452 1435
1453 VDetailLog("{0}, MoveAngular,Banking,rollComp={1},speed={2},rollComp={3},yAng={4},mYAng={5},ret={6}", 1436 VDetailLog("{0}, MoveAngular,Banking,rollComp={1},speed={2},rollComp={3},yAng={4},mYAng={5},ret={6}",
1454 Prim.LocalID, rollComponents, VehicleForwardSpeed, rollComponents, yawAngle, mixedYawAngle, ret); 1437 Prim.LocalID, rollComponents, VehicleForwardSpeed, rollComponents, yawAngle, mixedYawAngle, bankingContributionV);
1455 } 1438 }
1456 return ret;
1457 } 1439 }
1458 1440
1459 // This is from previous instantiations of XXXDynamics.cs. 1441 // This is from previous instantiations of XXXDynamics.cs.