diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 55 |
1 files changed, 42 insertions, 13 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 7aa2d92..e6b8507 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -311,13 +311,14 @@ public sealed class BSPrim : BSPhysObject | |||
311 | _position = value; | 311 | _position = value; |
312 | PositionSanityCheck(false); | 312 | PositionSanityCheck(false); |
313 | 313 | ||
314 | // A linkset might need to know if a component information changed. | ||
315 | Linkset.UpdateProperties(this, false); | ||
316 | |||
317 | PhysicsScene.TaintedObject("BSPrim.setPosition", delegate() | 314 | PhysicsScene.TaintedObject("BSPrim.setPosition", delegate() |
318 | { | 315 | { |
319 | DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); | 316 | DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); |
320 | ForcePosition = _position; | 317 | ForcePosition = _position; |
318 | |||
319 | // A linkset might need to know if a component information changed. | ||
320 | Linkset.UpdateProperties(UpdatedProperties.Position, this); | ||
321 | |||
321 | }); | 322 | }); |
322 | } | 323 | } |
323 | } | 324 | } |
@@ -502,6 +503,12 @@ public sealed class BSPrim : BSPhysObject | |||
502 | RegisterPreStepAction("BSPrim.setForce", LocalID, | 503 | RegisterPreStepAction("BSPrim.setForce", LocalID, |
503 | delegate(float timeStep) | 504 | delegate(float timeStep) |
504 | { | 505 | { |
506 | if (!IsPhysicallyActive) | ||
507 | { | ||
508 | UnRegisterPreStepAction("BSPrim.setForce", LocalID); | ||
509 | return; | ||
510 | } | ||
511 | |||
505 | DetailLog("{0},BSPrim.setForce,preStep,force={1}", LocalID, _force); | 512 | DetailLog("{0},BSPrim.setForce,preStep,force={1}", LocalID, _force); |
506 | if (PhysBody.HasPhysicalBody) | 513 | if (PhysBody.HasPhysicalBody) |
507 | { | 514 | { |
@@ -627,6 +634,12 @@ public sealed class BSPrim : BSPhysObject | |||
627 | RegisterPreStepAction("BSPrim.setTorque", LocalID, | 634 | RegisterPreStepAction("BSPrim.setTorque", LocalID, |
628 | delegate(float timeStep) | 635 | delegate(float timeStep) |
629 | { | 636 | { |
637 | if (!IsPhysicallyActive) | ||
638 | { | ||
639 | UnRegisterPreStepAction("BSPrim.setTorque", LocalID); | ||
640 | return; | ||
641 | } | ||
642 | |||
630 | if (PhysBody.HasPhysicalBody) | 643 | if (PhysBody.HasPhysicalBody) |
631 | AddAngularForce(_torque, false, true); | 644 | AddAngularForce(_torque, false, true); |
632 | } | 645 | } |
@@ -670,12 +683,13 @@ public sealed class BSPrim : BSPhysObject | |||
670 | return; | 683 | return; |
671 | _orientation = value; | 684 | _orientation = value; |
672 | 685 | ||
673 | // A linkset might need to know if a component information changed. | ||
674 | Linkset.UpdateProperties(this, false); | ||
675 | |||
676 | PhysicsScene.TaintedObject("BSPrim.setOrientation", delegate() | 686 | PhysicsScene.TaintedObject("BSPrim.setOrientation", delegate() |
677 | { | 687 | { |
678 | ForceOrientation = _orientation; | 688 | ForceOrientation = _orientation; |
689 | |||
690 | // A linkset might need to know if a component information changed. | ||
691 | Linkset.UpdateProperties(UpdatedProperties.Orientation, this); | ||
692 | |||
679 | }); | 693 | }); |
680 | } | 694 | } |
681 | } | 695 | } |
@@ -977,10 +991,10 @@ public sealed class BSPrim : BSPhysObject | |||
977 | } | 991 | } |
978 | set { | 992 | set { |
979 | _rotationalVelocity = value; | 993 | _rotationalVelocity = value; |
994 | Util.ClampV(_rotationalVelocity, BSParam.MaxAngularVelocity); | ||
980 | // m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity); | 995 | // m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity); |
981 | PhysicsScene.TaintedObject("BSPrim.setRotationalVelocity", delegate() | 996 | PhysicsScene.TaintedObject("BSPrim.setRotationalVelocity", delegate() |
982 | { | 997 | { |
983 | DetailLog("{0},BSPrim.SetRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity); | ||
984 | ForceRotationalVelocity = _rotationalVelocity; | 998 | ForceRotationalVelocity = _rotationalVelocity; |
985 | }); | 999 | }); |
986 | } | 1000 | } |
@@ -993,7 +1007,9 @@ public sealed class BSPrim : BSPhysObject | |||
993 | _rotationalVelocity = value; | 1007 | _rotationalVelocity = value; |
994 | if (PhysBody.HasPhysicalBody) | 1008 | if (PhysBody.HasPhysicalBody) |
995 | { | 1009 | { |
1010 | DetailLog("{0},BSPrim.ForceRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity); | ||
996 | PhysicsScene.PE.SetAngularVelocity(PhysBody, _rotationalVelocity); | 1011 | PhysicsScene.PE.SetAngularVelocity(PhysBody, _rotationalVelocity); |
1012 | // PhysicsScene.PE.SetInterpolationAngularVelocity(PhysBody, _rotationalVelocity); | ||
997 | ActivateIfPhysical(false); | 1013 | ActivateIfPhysical(false); |
998 | } | 1014 | } |
999 | } | 1015 | } |
@@ -1061,10 +1077,16 @@ public sealed class BSPrim : BSPhysObject | |||
1061 | 1077 | ||
1062 | RegisterPreStepAction("BSPrim.PIDTarget", LocalID, delegate(float timeStep) | 1078 | RegisterPreStepAction("BSPrim.PIDTarget", LocalID, delegate(float timeStep) |
1063 | { | 1079 | { |
1080 | if (!IsPhysicallyActive) | ||
1081 | { | ||
1082 | UnRegisterPreStepAction("BSPrim.PIDTarget", LocalID); | ||
1083 | return; | ||
1084 | } | ||
1085 | |||
1064 | OMV.Vector3 origPosition = RawPosition; // DEBUG DEBUG (for printout below) | 1086 | OMV.Vector3 origPosition = RawPosition; // DEBUG DEBUG (for printout below) |
1065 | 1087 | ||
1066 | // 'movePosition' is where we'd like the prim to be at this moment. | 1088 | // 'movePosition' is where we'd like the prim to be at this moment. |
1067 | OMV.Vector3 movePosition = _targetMotor.Step(timeStep); | 1089 | OMV.Vector3 movePosition = RawPosition + _targetMotor.Step(timeStep); |
1068 | 1090 | ||
1069 | // If we are very close to our target, turn off the movement motor. | 1091 | // If we are very close to our target, turn off the movement motor. |
1070 | if (_targetMotor.ErrorIsZero()) | 1092 | if (_targetMotor.ErrorIsZero()) |
@@ -1108,6 +1130,9 @@ public sealed class BSPrim : BSPhysObject | |||
1108 | 1130 | ||
1109 | RegisterPreStepAction("BSPrim.Hover", LocalID, delegate(float timeStep) | 1131 | RegisterPreStepAction("BSPrim.Hover", LocalID, delegate(float timeStep) |
1110 | { | 1132 | { |
1133 | if (!IsPhysicallyActive) | ||
1134 | return; | ||
1135 | |||
1111 | _hoverMotor.SetCurrent(RawPosition.Z); | 1136 | _hoverMotor.SetCurrent(RawPosition.Z); |
1112 | _hoverMotor.SetTarget(ComputeCurrentPIDHoverHeight()); | 1137 | _hoverMotor.SetTarget(ComputeCurrentPIDHoverHeight()); |
1113 | float targetHeight = _hoverMotor.Step(timeStep); | 1138 | float targetHeight = _hoverMotor.Step(timeStep); |
@@ -1172,10 +1197,14 @@ public sealed class BSPrim : BSPhysObject | |||
1172 | public override float APIDDamping { set { return; } } | 1197 | public override float APIDDamping { set { return; } } |
1173 | 1198 | ||
1174 | public override void AddForce(OMV.Vector3 force, bool pushforce) { | 1199 | public override void AddForce(OMV.Vector3 force, bool pushforce) { |
1200 | // Per documentation, max force is limited. | ||
1201 | OMV.Vector3 addForce = Util.ClampV(force, BSParam.MaxAddForceMagnitude); | ||
1202 | |||
1175 | // Since this force is being applied in only one step, make this a force per second. | 1203 | // Since this force is being applied in only one step, make this a force per second. |
1176 | OMV.Vector3 addForce = force / PhysicsScene.LastTimeStep; | 1204 | addForce /= PhysicsScene.LastTimeStep; |
1177 | AddForce(addForce, pushforce, false); | 1205 | AddForce(addForce, pushforce, false /* inTaintTime */); |
1178 | } | 1206 | } |
1207 | |||
1179 | // Applying a force just adds this to the total force on the object. | 1208 | // Applying a force just adds this to the total force on the object. |
1180 | // This added force will only last the next simulation tick. | 1209 | // This added force will only last the next simulation tick. |
1181 | public void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) { | 1210 | public void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) { |
@@ -1184,9 +1213,9 @@ public sealed class BSPrim : BSPhysObject | |||
1184 | { | 1213 | { |
1185 | if (force.IsFinite()) | 1214 | if (force.IsFinite()) |
1186 | { | 1215 | { |
1187 | OMV.Vector3 addForce = Util.ClampV(force, BSParam.MaxAddForceMagnitude); | ||
1188 | // DetailLog("{0},BSPrim.addForce,call,force={1}", LocalID, addForce); | 1216 | // DetailLog("{0},BSPrim.addForce,call,force={1}", LocalID, addForce); |
1189 | 1217 | ||
1218 | OMV.Vector3 addForce = force; | ||
1190 | PhysicsScene.TaintedObject(inTaintTime, "BSPrim.AddForce", delegate() | 1219 | PhysicsScene.TaintedObject(inTaintTime, "BSPrim.AddForce", delegate() |
1191 | { | 1220 | { |
1192 | // Bullet adds this central force to the total force for this tick | 1221 | // Bullet adds this central force to the total force for this tick |
@@ -1621,7 +1650,7 @@ public sealed class BSPrim : BSPhysObject | |||
1621 | // TODO: handle physics introduced by Bullet with computed vehicle physics. | 1650 | // TODO: handle physics introduced by Bullet with computed vehicle physics. |
1622 | if (_vehicle.IsActive) | 1651 | if (_vehicle.IsActive) |
1623 | { | 1652 | { |
1624 | entprop.RotationalVelocity = OMV.Vector3.Zero; | 1653 | // entprop.RotationalVelocity = OMV.Vector3.Zero; |
1625 | } | 1654 | } |
1626 | 1655 | ||
1627 | // 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 |
@@ -1660,7 +1689,7 @@ public sealed class BSPrim : BSPhysObject | |||
1660 | */ | 1689 | */ |
1661 | 1690 | ||
1662 | // The linkset implimentation might want to know about this. | 1691 | // The linkset implimentation might want to know about this. |
1663 | Linkset.UpdateProperties(this, true); | 1692 | Linkset.UpdateProperties(UpdatedProperties.EntPropUpdates, this); |
1664 | } | 1693 | } |
1665 | } | 1694 | } |
1666 | } | 1695 | } |