aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
diff options
context:
space:
mode:
authorMelanie2013-05-04 01:22:12 +0100
committerMelanie2013-05-04 01:22:12 +0100
commit3aa83738e2a845d05bb25ab81634d0540971c0bf (patch)
tree411d946b817b020c72f3d9a35926215e28bf2d95 /OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
parentMerge branch 'master' into careminster (diff)
parentMerge branch 'master' into bulletsim4 (diff)
downloadopensim-SC-3aa83738e2a845d05bb25ab81634d0540971c0bf.zip
opensim-SC-3aa83738e2a845d05bb25ab81634d0540971c0bf.tar.gz
opensim-SC-3aa83738e2a845d05bb25ab81634d0540971c0bf.tar.bz2
opensim-SC-3aa83738e2a845d05bb25ab81634d0540971c0bf.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Region/Application/OpenSimBase.cs OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs41
1 files changed, 21 insertions, 20 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index 612c68b..c5bee6d 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -559,9 +559,6 @@ namespace OpenSim.Region.Physics.BulletSPlugin
559 break; 559 break;
560 } 560 }
561 561
562 // Update any physical parameters based on this type.
563 Refresh();
564
565 m_linearMotor = new BSVMotor("LinearMotor", m_linearMotorTimescale, 562 m_linearMotor = new BSVMotor("LinearMotor", m_linearMotorTimescale,
566 m_linearMotorDecayTimescale, m_linearFrictionTimescale, 563 m_linearMotorDecayTimescale, m_linearFrictionTimescale,
567 1f); 564 1f);
@@ -589,6 +586,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin
589 { 586 {
590 RegisterForSceneEvents(); 587 RegisterForSceneEvents();
591 } 588 }
589
590 // Update any physical parameters based on this type.
591 Refresh();
592 } 592 }
593 #endregion // Vehicle parameter setting 593 #endregion // Vehicle parameter setting
594 594
@@ -596,6 +596,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
596 public override void Refresh() 596 public override void Refresh()
597 { 597 {
598 // If asking for a refresh, reset the physical parameters before the next simulation step. 598 // If asking for a refresh, reset the physical parameters before the next simulation step.
599 // Called whether active or not since the active state may be updated before the next step.
599 m_physicsScene.PostTaintObject("BSDynamics.Refresh", ControllingPrim.LocalID, delegate() 600 m_physicsScene.PostTaintObject("BSDynamics.Refresh", ControllingPrim.LocalID, delegate()
600 { 601 {
601 SetPhysicalParameters(); 602 SetPhysicalParameters();
@@ -625,7 +626,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
625 // Vehicles report collision events so we know when it's on the ground 626 // Vehicles report collision events so we know when it's on the ground
626 m_physicsScene.PE.AddToCollisionFlags(ControllingPrim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS); 627 m_physicsScene.PE.AddToCollisionFlags(ControllingPrim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS);
627 628
628 ControllingPrim.Inertia = m_physicsScene.PE.CalculateLocalInertia(ControllingPrim.PhysShape, m_vehicleMass); 629 ControllingPrim.Inertia = m_physicsScene.PE.CalculateLocalInertia(ControllingPrim.PhysShape.physShapeInfo, m_vehicleMass);
629 m_physicsScene.PE.SetMassProps(ControllingPrim.PhysBody, m_vehicleMass, ControllingPrim.Inertia); 630 m_physicsScene.PE.SetMassProps(ControllingPrim.PhysBody, m_vehicleMass, ControllingPrim.Inertia);
630 m_physicsScene.PE.UpdateInertiaTensor(ControllingPrim.PhysBody); 631 m_physicsScene.PE.UpdateInertiaTensor(ControllingPrim.PhysBody);
631 632
@@ -649,7 +650,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
649 } 650 }
650 651
651 // BSActor.RemoveBodyDependencies 652 // BSActor.RemoveBodyDependencies
652 public override void RemoveBodyDependencies() 653 public override void RemoveDependencies()
653 { 654 {
654 Refresh(); 655 Refresh();
655 } 656 }
@@ -789,7 +790,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
789 if ((m_knownHas & m_knownChangedTerrainHeight) == 0 || pos != lastRememberedHeightPos) 790 if ((m_knownHas & m_knownChangedTerrainHeight) == 0 || pos != lastRememberedHeightPos)
790 { 791 {
791 lastRememberedHeightPos = pos; 792 lastRememberedHeightPos = pos;
792 m_knownTerrainHeight = ControllingPrim.PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(pos); 793 m_knownTerrainHeight = ControllingPrim.PhysScene.TerrainManager.GetTerrainHeightAtXYZ(pos);
793 m_knownHas |= m_knownChangedTerrainHeight; 794 m_knownHas |= m_knownChangedTerrainHeight;
794 } 795 }
795 return m_knownTerrainHeight; 796 return m_knownTerrainHeight;
@@ -801,7 +802,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
801 { 802 {
802 if ((m_knownHas & m_knownChangedWaterLevel) == 0) 803 if ((m_knownHas & m_knownChangedWaterLevel) == 0)
803 { 804 {
804 m_knownWaterLevel = ControllingPrim.PhysicsScene.TerrainManager.GetWaterLevelAtXYZ(pos); 805 m_knownWaterLevel = ControllingPrim.PhysScene.TerrainManager.GetWaterLevelAtXYZ(pos);
805 m_knownHas |= m_knownChangedWaterLevel; 806 m_knownHas |= m_knownChangedWaterLevel;
806 } 807 }
807 return (float)m_knownWaterLevel; 808 return (float)m_knownWaterLevel;
@@ -1019,7 +1020,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1019 Vector3 origVelW = VehicleVelocity; // DEBUG DEBUG 1020 Vector3 origVelW = VehicleVelocity; // DEBUG DEBUG
1020 VehicleVelocity /= VehicleVelocity.Length(); 1021 VehicleVelocity /= VehicleVelocity.Length();
1021 VehicleVelocity *= BSParam.VehicleMaxLinearVelocity; 1022 VehicleVelocity *= BSParam.VehicleMaxLinearVelocity;
1022 VDetailLog("{0}, MoveLinear,clampMax,origVelW={1},lenSq={2},maxVelSq={3},,newVelW={4}", 1023 VDetailLog("{0}, MoveLinear,clampMax,origVelW={1},lenSq={2},maxVelSq={3},,newVelW={4}",
1023 ControllingPrim.LocalID, origVelW, newVelocityLengthSq, BSParam.VehicleMaxLinearVelocitySquared, VehicleVelocity); 1024 ControllingPrim.LocalID, origVelW, newVelocityLengthSq, BSParam.VehicleMaxLinearVelocitySquared, VehicleVelocity);
1024 } 1025 }
1025 else if (newVelocityLengthSq < 0.001f) 1026 else if (newVelocityLengthSq < 0.001f)
@@ -1094,7 +1095,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1094 if (VehiclePosition.Z > m_VhoverTargetHeight) 1095 if (VehiclePosition.Z > m_VhoverTargetHeight)
1095 m_VhoverTargetHeight = VehiclePosition.Z; 1096 m_VhoverTargetHeight = VehiclePosition.Z;
1096 } 1097 }
1097 1098
1098 if ((m_flags & VehicleFlag.LOCK_HOVER_HEIGHT) != 0) 1099 if ((m_flags & VehicleFlag.LOCK_HOVER_HEIGHT) != 0)
1099 { 1100 {
1100 if (Math.Abs(VehiclePosition.Z - m_VhoverTargetHeight) > 0.2f) 1101 if (Math.Abs(VehiclePosition.Z - m_VhoverTargetHeight) > 0.2f)
@@ -1188,7 +1189,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1188 // used with conjunction with banking: the strength of the banking will decay when the 1189 // used with conjunction with banking: the strength of the banking will decay when the
1189 // vehicle no longer experiences collisions. The decay timescale is the same as 1190 // vehicle no longer experiences collisions. The decay timescale is the same as
1190 // VEHICLE_BANKING_TIMESCALE. This is to help prevent ground vehicles from steering 1191 // VEHICLE_BANKING_TIMESCALE. This is to help prevent ground vehicles from steering
1191 // when they are in mid jump. 1192 // when they are in mid jump.
1192 // TODO: this code is wrong. Also, what should it do for boats (height from water)? 1193 // TODO: this code is wrong. Also, what should it do for boats (height from water)?
1193 // This is just using the ground and a general collision check. Should really be using 1194 // This is just using the ground and a general collision check. Should really be using
1194 // a downward raycast to find what is below. 1195 // a downward raycast to find what is below.
@@ -1254,7 +1255,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1254 1255
1255 VehicleAddForce(appliedGravity); 1256 VehicleAddForce(appliedGravity);
1256 1257
1257 VDetailLog("{0}, MoveLinear,applyGravity,vehGrav={1},collid={2},fudge={3},mass={4},appliedForce={3}", 1258 VDetailLog("{0}, MoveLinear,applyGravity,vehGrav={1},collid={2},fudge={3},mass={4},appliedForce={3}",
1258 ControllingPrim.LocalID, m_VehicleGravity, 1259 ControllingPrim.LocalID, m_VehicleGravity,
1259 ControllingPrim.IsColliding, BSParam.VehicleGroundGravityFudge, m_vehicleMass, appliedGravity); 1260 ControllingPrim.IsColliding, BSParam.VehicleGroundGravityFudge, m_vehicleMass, appliedGravity);
1260 } 1261 }
@@ -1330,7 +1331,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1330 // From http://wiki.secondlife.com/wiki/LlSetVehicleFlags : 1331 // From http://wiki.secondlife.com/wiki/LlSetVehicleFlags :
1331 // This flag prevents linear deflection parallel to world z-axis. This is useful 1332 // This flag prevents linear deflection parallel to world z-axis. This is useful
1332 // for preventing ground vehicles with large linear deflection, like bumper cars, 1333 // for preventing ground vehicles with large linear deflection, like bumper cars,
1333 // from climbing their linear deflection into the sky. 1334 // from climbing their linear deflection into the sky.
1334 // That is, NO_DEFLECTION_UP says angular motion should not add any pitch or roll movement 1335 // That is, NO_DEFLECTION_UP says angular motion should not add any pitch or roll movement
1335 // TODO: This is here because this is where ODE put it but documentation says it 1336 // TODO: This is here because this is where ODE put it but documentation says it
1336 // is a linear effect. Where should this check go? 1337 // is a linear effect. Where should this check go?
@@ -1463,7 +1464,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1463 VehicleRotationalVelocity += (vertContributionV * VehicleOrientation); 1464 VehicleRotationalVelocity += (vertContributionV * VehicleOrientation);
1464 1465
1465 VDetailLog("{0}, MoveAngular,verticalAttraction,,origRotVW={1},vertError={2},unscaledV={3},eff={4},ts={5},vertContribV={6}", 1466 VDetailLog("{0}, MoveAngular,verticalAttraction,,origRotVW={1},vertError={2},unscaledV={3},eff={4},ts={5},vertContribV={6}",
1466 Prim.LocalID, origRotVelW, verticalError, unscaledContribVerticalErrorV, 1467 Prim.LocalID, origRotVelW, verticalError, unscaledContribVerticalErrorV,
1467 m_verticalAttractionEfficiency, m_verticalAttractionTimescale, vertContributionV); 1468 m_verticalAttractionEfficiency, m_verticalAttractionTimescale, vertContributionV);
1468 */ 1469 */
1469 } 1470 }
@@ -1530,13 +1531,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1530 // produce a angular velocity around the yaw-axis, causing the vehicle to turn. The magnitude 1531 // produce a angular velocity around the yaw-axis, causing the vehicle to turn. The magnitude
1531 // of the yaw effect will be proportional to the 1532 // of the yaw effect will be proportional to the
1532 // VEHICLE_BANKING_EFFICIENCY, the angle of the roll rotation, and sometimes the vehicle's 1533 // VEHICLE_BANKING_EFFICIENCY, the angle of the roll rotation, and sometimes the vehicle's
1533 // velocity along its preferred axis of motion. 1534 // velocity along its preferred axis of motion.
1534 // The VEHICLE_BANKING_EFFICIENCY can vary between -1 and +1. When it is positive then any 1535 // The VEHICLE_BANKING_EFFICIENCY can vary between -1 and +1. When it is positive then any
1535 // positive rotation (by the right-hand rule) about the roll-axis will effect a 1536 // positive rotation (by the right-hand rule) about the roll-axis will effect a
1536 // (negative) torque around the yaw-axis, making it turn to the right--that is the 1537 // (negative) torque around the yaw-axis, making it turn to the right--that is the
1537 // vehicle will lean into the turn, which is how real airplanes and motorcycle's work. 1538 // vehicle will lean into the turn, which is how real airplanes and motorcycle's work.
1538 // Negating the banking coefficient will make it so that the vehicle leans to the 1539 // Negating the banking coefficient will make it so that the vehicle leans to the
1539 // outside of the turn (not very "physical" but might allow interesting vehicles so why not?). 1540 // outside of the turn (not very "physical" but might allow interesting vehicles so why not?).
1540 // The VEHICLE_BANKING_MIX is a fake (i.e. non-physical) parameter that is useful for making 1541 // The VEHICLE_BANKING_MIX is a fake (i.e. non-physical) parameter that is useful for making
1541 // banking vehicles do what you want rather than what the laws of physics allow. 1542 // banking vehicles do what you want rather than what the laws of physics allow.
1542 // For example, consider a real motorcycle...it must be moving forward in order for 1543 // For example, consider a real motorcycle...it must be moving forward in order for
@@ -1548,11 +1549,11 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1548 // totally static (0.0) and totally dynamic (1.0). By "static" we mean that the 1549 // totally static (0.0) and totally dynamic (1.0). By "static" we mean that the
1549 // banking effect depends only on the vehicle's rotation about its roll-axis compared 1550 // banking effect depends only on the vehicle's rotation about its roll-axis compared
1550 // to "dynamic" where the banking is also proportional to its velocity along its 1551 // to "dynamic" where the banking is also proportional to its velocity along its
1551 // roll-axis. Finding the best value of the "mixture" will probably require trial and error. 1552 // roll-axis. Finding the best value of the "mixture" will probably require trial and error.
1552 // The time it takes for the banking behavior to defeat a preexisting angular velocity about the 1553 // The time it takes for the banking behavior to defeat a preexisting angular velocity about the
1553 // world z-axis is determined by the VEHICLE_BANKING_TIMESCALE. So if you want the vehicle to 1554 // world z-axis is determined by the VEHICLE_BANKING_TIMESCALE. So if you want the vehicle to
1554 // bank quickly then give it a banking timescale of about a second or less, otherwise you can 1555 // bank quickly then give it a banking timescale of about a second or less, otherwise you can
1555 // make a sluggish vehicle by giving it a timescale of several seconds. 1556 // make a sluggish vehicle by giving it a timescale of several seconds.
1556 public void ComputeAngularBanking() 1557 public void ComputeAngularBanking()
1557 { 1558 {
1558 if (enableAngularBanking && m_bankingEfficiency != 0 && m_verticalAttractionTimescale < m_verticalAttractionCutoff) 1559 if (enableAngularBanking && m_bankingEfficiency != 0 && m_verticalAttractionTimescale < m_verticalAttractionCutoff)
@@ -1581,7 +1582,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1581 1582
1582 //VehicleRotationalVelocity += bankingContributionV * VehicleOrientation; 1583 //VehicleRotationalVelocity += bankingContributionV * VehicleOrientation;
1583 VehicleRotationalVelocity += bankingContributionV; 1584 VehicleRotationalVelocity += bankingContributionV;
1584 1585
1585 1586
1586 VDetailLog("{0}, MoveAngular,Banking,rollComp={1},speed={2},rollComp={3},yAng={4},mYAng={5},ret={6}", 1587 VDetailLog("{0}, MoveAngular,Banking,rollComp={1},speed={2},rollComp={3},yAng={4},mYAng={5},ret={6}",
1587 ControllingPrim.LocalID, rollComponents, VehicleForwardSpeed, rollComponents, yawAngle, mixedYawAngle, bankingContributionV); 1588 ControllingPrim.LocalID, rollComponents, VehicleForwardSpeed, rollComponents, yawAngle, mixedYawAngle, bankingContributionV);
@@ -1637,8 +1638,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1637 // Invoke the detailed logger and output something if it's enabled. 1638 // Invoke the detailed logger and output something if it's enabled.
1638 private void VDetailLog(string msg, params Object[] args) 1639 private void VDetailLog(string msg, params Object[] args)
1639 { 1640 {
1640 if (ControllingPrim.PhysicsScene.VehicleLoggingEnabled) 1641 if (ControllingPrim.PhysScene.VehicleLoggingEnabled)
1641 ControllingPrim.PhysicsScene.DetailLog(msg, args); 1642 ControllingPrim.PhysScene.DetailLog(msg, args);
1642 } 1643 }
1643 } 1644 }
1644} 1645}