aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorRobert Adams2013-01-21 23:43:24 -0800
committerRobert Adams2013-01-21 23:43:24 -0800
commit80b1e32bfa00a2d3354f0d7e0df83a5b0b3e2c49 (patch)
tree6d6ca5dbbdc60f2b9464d03a773facdcf11bb80a
parentBulletSim: allow changing position and rotation of a child of a linkset (diff)
downloadopensim-SC_OLD-80b1e32bfa00a2d3354f0d7e0df83a5b0b3e2c49.zip
opensim-SC_OLD-80b1e32bfa00a2d3354f0d7e0df83a5b0b3e2c49.tar.gz
opensim-SC_OLD-80b1e32bfa00a2d3354f0d7e0df83a5b0b3e2c49.tar.bz2
opensim-SC_OLD-80b1e32bfa00a2d3354f0d7e0df83a5b0b3e2c49.tar.xz
BulletSim: Tweeks to vehicle motion.
Pass through old angular velocity making for smoother transitions. Remove some old kludges for angular motion (damping and rotvel suppression).
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs21
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSParam.cs2
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs3
3 files changed, 11 insertions, 15 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index f8fc3de..dbe44de 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -1192,7 +1192,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1192 // set directly on the vehicle. 1192 // set directly on the vehicle.
1193 private void MoveAngular(float pTimestep) 1193 private void MoveAngular(float pTimestep)
1194 { 1194 {
1195 VehicleRotationalVelocity = Vector3.Zero; 1195 // VehicleRotationalVelocity = Vector3.Zero;
1196 1196
1197 ComputeAngularTurning(pTimestep); 1197 ComputeAngularTurning(pTimestep);
1198 1198
@@ -1203,12 +1203,6 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1203 ComputeAngularBanking(); 1203 ComputeAngularBanking();
1204 1204
1205 // ================================================================== 1205 // ==================================================================
1206 // All of the above computation are made relative to vehicle coordinates.
1207 // Convert to world coordinates.
1208 // TODO: Should this be applied as an angular force (torque)?
1209 VehicleRotationalVelocity *= VehicleOrientation;
1210
1211 // ==================================================================
1212 if (VehicleRotationalVelocity.ApproxEquals(Vector3.Zero, 0.01f)) 1206 if (VehicleRotationalVelocity.ApproxEquals(Vector3.Zero, 0.01f))
1213 { 1207 {
1214 // The vehicle is not adding anything angular wise. 1208 // The vehicle is not adding anything angular wise.
@@ -1256,7 +1250,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1256 private void ComputeAngularTurning(float pTimestep) 1250 private void ComputeAngularTurning(float pTimestep)
1257 { 1251 {
1258 // The user wants this many radians per second angular change? 1252 // The user wants this many radians per second angular change?
1259 Vector3 angularMotorContribution = m_angularMotor.Step(pTimestep); 1253 Vector3 currentAngular = VehicleRotationalVelocity * Quaternion.Inverse(VehicleOrientation);
1254 Vector3 angularMotorContribution = m_angularMotor.Step(pTimestep, currentAngular);
1260 1255
1261 // ================================================================== 1256 // ==================================================================
1262 // From http://wiki.secondlife.com/wiki/LlSetVehicleFlags : 1257 // From http://wiki.secondlife.com/wiki/LlSetVehicleFlags :
@@ -1272,7 +1267,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1272 angularMotorContribution.Y = 0f; 1267 angularMotorContribution.Y = 0f;
1273 } 1268 }
1274 1269
1275 VehicleRotationalVelocity += angularMotorContribution; 1270 VehicleRotationalVelocity += angularMotorContribution * VehicleOrientation;
1276 VDetailLog("{0}, MoveAngular,angularTurning,angularMotorContrib={1}", Prim.LocalID, angularMotorContribution); 1271 VDetailLog("{0}, MoveAngular,angularTurning,angularMotorContrib={1}", Prim.LocalID, angularMotorContribution);
1277 } 1272 }
1278 1273
@@ -1312,7 +1307,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1312 if (verticalError.Z < 0f) 1307 if (verticalError.Z < 0f)
1313 { 1308 {
1314 vertContribution.X += PIOverFour; 1309 vertContribution.X += PIOverFour;
1315 vertContribution.Y += PIOverFour; 1310 // vertContribution.Y -= PIOverFour;
1316 } 1311 }
1317 1312
1318 // 'vertContrbution' is now the necessary angular correction to correct tilt in one second. 1313 // 'vertContrbution' is now the necessary angular correction to correct tilt in one second.
@@ -1320,7 +1315,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1320 Vector3 unscaledContrib = vertContribution; // DEBUG DEBUG 1315 Vector3 unscaledContrib = vertContribution; // DEBUG DEBUG
1321 vertContribution /= m_verticalAttractionTimescale; 1316 vertContribution /= m_verticalAttractionTimescale;
1322 1317
1323 VehicleRotationalVelocity += vertContribution; 1318 VehicleRotationalVelocity += vertContribution * VehicleOrientation;
1324 1319
1325 VDetailLog("{0}, MoveAngular,verticalAttraction,,verticalError={1},unscaled={2},eff={3},ts={4},vertAttr={5}", 1320 VDetailLog("{0}, MoveAngular,verticalAttraction,,verticalError={1},unscaled={2},eff={3},ts={4},vertAttr={5}",
1326 Prim.LocalID, verticalError, unscaledContrib, m_verticalAttractionEfficiency, m_verticalAttractionTimescale, vertContribution); 1321 Prim.LocalID, verticalError, unscaledContrib, m_verticalAttractionEfficiency, m_verticalAttractionTimescale, vertContribution);
@@ -1371,7 +1366,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1371 deflectContribution = (-deflectionError) * m_angularDeflectionEfficiency; 1366 deflectContribution = (-deflectionError) * m_angularDeflectionEfficiency;
1372 deflectContribution /= m_angularDeflectionTimescale; 1367 deflectContribution /= m_angularDeflectionTimescale;
1373 1368
1374 VehicleRotationalVelocity += deflectContribution; 1369 VehicleRotationalVelocity += deflectContribution * VehicleOrientation;
1375 1370
1376 VDetailLog("{0}, MoveAngular,Deflection,movingDir={1},pointingDir={2},deflectError={3},ret={4}", 1371 VDetailLog("{0}, MoveAngular,Deflection,movingDir={1},pointingDir={2},deflectError={3},ret={4}",
1377 Prim.LocalID, movingDirection, pointingDirection, deflectionError, deflectContribution); 1372 Prim.LocalID, movingDirection, pointingDirection, deflectionError, deflectContribution);
@@ -1438,7 +1433,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1438 // Don't do it all at once. 1433 // Don't do it all at once.
1439 bankingContribution /= m_bankingTimescale; 1434 bankingContribution /= m_bankingTimescale;
1440 1435
1441 VehicleRotationalVelocity += bankingContribution; 1436 VehicleRotationalVelocity += bankingContribution * VehicleOrientation;
1442 1437
1443 VDetailLog("{0}, MoveAngular,Banking,rollComp={1},speed={2},rollComp={3},yAng={4},mYAng={5},ret={6}", 1438 VDetailLog("{0}, MoveAngular,Banking,rollComp={1},speed={2},rollComp={3},yAng={4},mYAng={5},ret={6}",
1444 Prim.LocalID, rollComponents, VehicleForwardSpeed, rollComponents, yawAngle, mixedYawAngle, bankingContribution); 1439 Prim.LocalID, rollComponents, VehicleForwardSpeed, rollComponents, yawAngle, mixedYawAngle, bankingContribution);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
index 2b4488a..da7438a 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
@@ -450,7 +450,7 @@ public static class BSParam
450 (s) => { return (float)VehicleMaxAngularVelocity; }, 450 (s) => { return (float)VehicleMaxAngularVelocity; },
451 (s,p,l,v) => { VehicleMaxAngularVelocity = v; } ), 451 (s,p,l,v) => { VehicleMaxAngularVelocity = v; } ),
452 new ParameterDefn("VehicleAngularDamping", "Factor to damp vehicle angular movement per second (0.0 - 1.0)", 452 new ParameterDefn("VehicleAngularDamping", "Factor to damp vehicle angular movement per second (0.0 - 1.0)",
453 0.95f, 453 0.0f,
454 (s,cf,p,v) => { VehicleAngularDamping = cf.GetFloat(p, v); }, 454 (s,cf,p,v) => { VehicleAngularDamping = cf.GetFloat(p, v); },
455 (s) => { return VehicleAngularDamping; }, 455 (s) => { return VehicleAngularDamping; },
456 (s,p,l,v) => { VehicleAngularDamping = v; } ), 456 (s,p,l,v) => { VehicleAngularDamping = v; } ),
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 468ff40..e6b8507 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -1009,6 +1009,7 @@ public sealed class BSPrim : BSPhysObject
1009 { 1009 {
1010 DetailLog("{0},BSPrim.ForceRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity); 1010 DetailLog("{0},BSPrim.ForceRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity);
1011 PhysicsScene.PE.SetAngularVelocity(PhysBody, _rotationalVelocity); 1011 PhysicsScene.PE.SetAngularVelocity(PhysBody, _rotationalVelocity);
1012 // PhysicsScene.PE.SetInterpolationAngularVelocity(PhysBody, _rotationalVelocity);
1012 ActivateIfPhysical(false); 1013 ActivateIfPhysical(false);
1013 } 1014 }
1014 } 1015 }
@@ -1649,7 +1650,7 @@ public sealed class BSPrim : BSPhysObject
1649 // TODO: handle physics introduced by Bullet with computed vehicle physics. 1650 // TODO: handle physics introduced by Bullet with computed vehicle physics.
1650 if (_vehicle.IsActive) 1651 if (_vehicle.IsActive)
1651 { 1652 {
1652 entprop.RotationalVelocity = OMV.Vector3.Zero; 1653 // entprop.RotationalVelocity = OMV.Vector3.Zero;
1653 } 1654 }
1654 1655
1655 // Assign directly to the local variables so the normal set actions do not happen 1656 // Assign directly to the local variables so the normal set actions do not happen