aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs')
-rw-r--r--OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs157
1 files changed, 86 insertions, 71 deletions
diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs b/OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs
index 6f27ac7..f085d70 100644
--- a/OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs
@@ -33,7 +33,7 @@ using log4net;
33using OMV = OpenMetaverse; 33using OMV = OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Region.PhysicsModules.SharedBase; 35using OpenSim.Region.PhysicsModules.SharedBase;
36using OpenSim.Region.PhysicsModule.ConvexDecompositionDotNet; 36using OpenSim.Region.PhysicsModules.ConvexDecompositionDotNet;
37 37
38namespace OpenSim.Region.PhysicsModule.BulletS 38namespace OpenSim.Region.PhysicsModule.BulletS
39{ 39{
@@ -59,7 +59,6 @@ public class BSPrim : BSPhysObject
59 private bool _setAlwaysRun; 59 private bool _setAlwaysRun;
60 private bool _throttleUpdates; 60 private bool _throttleUpdates;
61 private bool _floatOnWater; 61 private bool _floatOnWater;
62 private OMV.Vector3 _rotationalVelocity;
63 private bool _kinematic; 62 private bool _kinematic;
64 private float _buoyancy; 63 private float _buoyancy;
65 64
@@ -90,7 +89,7 @@ public class BSPrim : BSPhysObject
90 RawOrientation = rotation; 89 RawOrientation = rotation;
91 _buoyancy = 0f; 90 _buoyancy = 0f;
92 RawVelocity = OMV.Vector3.Zero; 91 RawVelocity = OMV.Vector3.Zero;
93 _rotationalVelocity = OMV.Vector3.Zero; 92 RawRotationalVelocity = OMV.Vector3.Zero;
94 BaseShape = pbs; 93 BaseShape = pbs;
95 _isPhysical = pisPhysical; 94 _isPhysical = pisPhysical;
96 _isVolumeDetect = false; 95 _isVolumeDetect = false;
@@ -256,7 +255,7 @@ public class BSPrim : BSPhysObject
256 { 255 {
257 RawVelocity = OMV.Vector3.Zero; 256 RawVelocity = OMV.Vector3.Zero;
258 _acceleration = OMV.Vector3.Zero; 257 _acceleration = OMV.Vector3.Zero;
259 _rotationalVelocity = OMV.Vector3.Zero; 258 RawRotationalVelocity = OMV.Vector3.Zero;
260 259
261 // Zero some other properties in the physics engine 260 // Zero some other properties in the physics engine
262 PhysScene.TaintedObject(inTaintTime, LocalID, "BSPrim.ZeroMotion", delegate() 261 PhysScene.TaintedObject(inTaintTime, LocalID, "BSPrim.ZeroMotion", delegate()
@@ -267,33 +266,33 @@ public class BSPrim : BSPhysObject
267 } 266 }
268 public override void ZeroAngularMotion(bool inTaintTime) 267 public override void ZeroAngularMotion(bool inTaintTime)
269 { 268 {
270 _rotationalVelocity = OMV.Vector3.Zero; 269 RawRotationalVelocity = OMV.Vector3.Zero;
271 // Zero some other properties in the physics engine 270 // Zero some other properties in the physics engine
272 PhysScene.TaintedObject(inTaintTime, LocalID, "BSPrim.ZeroMotion", delegate() 271 PhysScene.TaintedObject(inTaintTime, LocalID, "BSPrim.ZeroMotion", delegate()
273 { 272 {
274 // DetailLog("{0},BSPrim.ZeroAngularMotion,call,rotVel={1}", LocalID, _rotationalVelocity); 273 // DetailLog("{0},BSPrim.ZeroAngularMotion,call,rotVel={1}", LocalID, _rotationalVelocity);
275 if (PhysBody.HasPhysicalBody) 274 if (PhysBody.HasPhysicalBody)
276 { 275 {
277 PhysScene.PE.SetInterpolationAngularVelocity(PhysBody, _rotationalVelocity); 276 PhysScene.PE.SetInterpolationAngularVelocity(PhysBody, RawRotationalVelocity);
278 PhysScene.PE.SetAngularVelocity(PhysBody, _rotationalVelocity); 277 PhysScene.PE.SetAngularVelocity(PhysBody, RawRotationalVelocity);
279 } 278 }
280 }); 279 });
281 } 280 }
282 281
283 public override void LockAngularMotion(OMV.Vector3 axis) 282 public override void LockAngularMotion(byte axislocks)
284 { 283 {
285 DetailLog("{0},BSPrim.LockAngularMotion,call,axis={1}", LocalID, axis); 284 DetailLog("{0},BSPrim.LockAngularMotion,call,axis={1}", LocalID, axislocks);
286 285
287 ApplyAxisLimits(ExtendedPhysics.PHYS_AXIS_UNLOCK_ANGULAR, 0f, 0f); 286 ApplyAxisLimits(ExtendedPhysics.PHYS_AXIS_UNLOCK_ANGULAR, 0f, 0f);
288 if (axis.X != 1) 287 if ((axislocks & 0x02) != 0)
289 { 288 {
290 ApplyAxisLimits(ExtendedPhysics.PHYS_AXIS_LOCK_ANGULAR_X, 0f, 0f); 289 ApplyAxisLimits(ExtendedPhysics.PHYS_AXIS_LOCK_ANGULAR_X, 0f, 0f);
291 } 290 }
292 if (axis.Y != 1) 291 if ((axislocks & 0x04) != 0)
293 { 292 {
294 ApplyAxisLimits(ExtendedPhysics.PHYS_AXIS_LOCK_ANGULAR_Y, 0f, 0f); 293 ApplyAxisLimits(ExtendedPhysics.PHYS_AXIS_LOCK_ANGULAR_Y, 0f, 0f);
295 } 294 }
296 if (axis.Z != 1) 295 if ((axislocks & 0x08) != 0)
297 { 296 {
298 ApplyAxisLimits(ExtendedPhysics.PHYS_AXIS_LOCK_ANGULAR_Z, 0f, 0f); 297 ApplyAxisLimits(ExtendedPhysics.PHYS_AXIS_LOCK_ANGULAR_Z, 0f, 0f);
299 } 298 }
@@ -394,7 +393,7 @@ public class BSPrim : BSPhysObject
394 // Apply upforce and overcome gravity. 393 // Apply upforce and overcome gravity.
395 OMV.Vector3 correctionForce = upForce - PhysScene.DefaultGravity; 394 OMV.Vector3 correctionForce = upForce - PhysScene.DefaultGravity;
396 DetailLog("{0},BSPrim.PositionSanityCheck,applyForce,pos={1},upForce={2},correctionForce={3}", LocalID, RawPosition, upForce, correctionForce); 395 DetailLog("{0},BSPrim.PositionSanityCheck,applyForce,pos={1},upForce={2},correctionForce={3}", LocalID, RawPosition, upForce, correctionForce);
397 AddForce(correctionForce, false, inTaintTime); 396 AddForce(inTaintTime, correctionForce);
398 ret = true; 397 ret = true;
399 } 398 }
400 } 399 }
@@ -426,9 +425,9 @@ public class BSPrim : BSPhysObject
426 RawVelocity = Util.ClampV(RawVelocity, BSParam.MaxLinearVelocity); 425 RawVelocity = Util.ClampV(RawVelocity, BSParam.MaxLinearVelocity);
427 ret = true; 426 ret = true;
428 } 427 }
429 if (_rotationalVelocity.LengthSquared() > BSParam.MaxAngularVelocitySquared) 428 if (RawRotationalVelocity.LengthSquared() > BSParam.MaxAngularVelocitySquared)
430 { 429 {
431 _rotationalVelocity = Util.ClampV(_rotationalVelocity, BSParam.MaxAngularVelocity); 430 RawRotationalVelocity = Util.ClampV(RawRotationalVelocity, BSParam.MaxAngularVelocity);
432 ret = true; 431 ret = true;
433 } 432 }
434 433
@@ -647,6 +646,59 @@ public class BSPrim : BSPhysObject
647 }); 646 });
648 } 647 }
649 648
649 public override void SetVehicle(object pvdata)
650 {
651 PhysScene.TaintedObject(LocalID, "BSPrim.SetVehicle", delegate ()
652 {
653 BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */);
654 if (vehicleActor != null && (pvdata is VehicleData) )
655 {
656 VehicleData vdata = (VehicleData)pvdata;
657 // vehicleActor.ProcessSetVehicle((VehicleData)vdata);
658
659 vehicleActor.ProcessTypeChange(vdata.m_type);
660 vehicleActor.ProcessVehicleFlags(-1, false);
661 vehicleActor.ProcessVehicleFlags((int)vdata.m_flags, false);
662
663 // Linear properties
664 vehicleActor.ProcessVectorVehicleParam(Vehicle.LINEAR_MOTOR_DIRECTION, vdata.m_linearMotorDirection);
665 vehicleActor.ProcessVectorVehicleParam(Vehicle.LINEAR_FRICTION_TIMESCALE, vdata.m_linearFrictionTimescale);
666 vehicleActor.ProcessFloatVehicleParam(Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE, vdata.m_linearMotorDecayTimescale);
667 vehicleActor.ProcessFloatVehicleParam(Vehicle.LINEAR_MOTOR_TIMESCALE, vdata.m_linearMotorTimescale);
668 vehicleActor.ProcessVectorVehicleParam(Vehicle.LINEAR_MOTOR_OFFSET, vdata.m_linearMotorOffset);
669
670 //Angular properties
671 vehicleActor.ProcessVectorVehicleParam(Vehicle.ANGULAR_MOTOR_DIRECTION, vdata.m_angularMotorDirection);
672 vehicleActor.ProcessFloatVehicleParam(Vehicle.ANGULAR_MOTOR_TIMESCALE, vdata.m_angularMotorTimescale);
673 vehicleActor.ProcessFloatVehicleParam(Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE, vdata.m_angularMotorDecayTimescale);
674 vehicleActor.ProcessVectorVehicleParam(Vehicle.ANGULAR_FRICTION_TIMESCALE, vdata.m_angularFrictionTimescale);
675
676 //Deflection properties
677 vehicleActor.ProcessFloatVehicleParam(Vehicle.ANGULAR_DEFLECTION_EFFICIENCY, vdata.m_angularDeflectionEfficiency);
678 vehicleActor.ProcessFloatVehicleParam(Vehicle.ANGULAR_DEFLECTION_TIMESCALE, vdata.m_angularDeflectionTimescale);
679 vehicleActor.ProcessFloatVehicleParam(Vehicle.LINEAR_DEFLECTION_EFFICIENCY, vdata.m_linearDeflectionEfficiency);
680 vehicleActor.ProcessFloatVehicleParam(Vehicle.LINEAR_DEFLECTION_TIMESCALE, vdata.m_linearDeflectionTimescale);
681
682 //Banking properties
683 vehicleActor.ProcessFloatVehicleParam(Vehicle.BANKING_EFFICIENCY, vdata.m_bankingEfficiency);
684 vehicleActor.ProcessFloatVehicleParam(Vehicle.BANKING_MIX, vdata.m_bankingMix);
685 vehicleActor.ProcessFloatVehicleParam(Vehicle.BANKING_TIMESCALE, vdata.m_bankingTimescale);
686
687 //Hover and Buoyancy properties
688 vehicleActor.ProcessFloatVehicleParam(Vehicle.HOVER_HEIGHT, vdata.m_VhoverHeight);
689 vehicleActor.ProcessFloatVehicleParam(Vehicle.HOVER_EFFICIENCY, vdata.m_VhoverEfficiency);
690 vehicleActor.ProcessFloatVehicleParam(Vehicle.HOVER_TIMESCALE, vdata.m_VhoverTimescale);
691 vehicleActor.ProcessFloatVehicleParam(Vehicle.BUOYANCY, vdata.m_VehicleBuoyancy);
692
693 //Attractor properties
694 vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, vdata.m_verticalAttractionEfficiency);
695 vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_TIMESCALE, vdata.m_verticalAttractionTimescale);
696
697 vehicleActor.ProcessRotationVehicleParam(Vehicle.REFERENCE_FRAME, vdata.m_referenceFrame);
698 }
699 });
700 }
701
650 // Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more 702 // Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more
651 public override void SetVolumeDetect(int param) { 703 public override void SetVolumeDetect(int param) {
652 bool newValue = (param != 0); 704 bool newValue = (param != 0);
@@ -735,22 +787,9 @@ public class BSPrim : BSPhysObject
735 } 787 }
736 } 788 }
737 } 789 }
738 public override OMV.Vector3 Velocity {
739 get { return RawVelocity; }
740 set {
741 RawVelocity = value;
742 PhysScene.TaintedObject(LocalID, "BSPrim.setVelocity", delegate()
743 {
744 // DetailLog("{0},BSPrim.SetVelocity,taint,vel={1}", LocalID, RawVelocity);
745 ForceVelocity = RawVelocity;
746 });
747 }
748 }
749 public override OMV.Vector3 ForceVelocity { 790 public override OMV.Vector3 ForceVelocity {
750 get { return RawVelocity; } 791 get { return RawVelocity; }
751 set { 792 set {
752 PhysScene.AssertInTaintTime("BSPrim.ForceVelocity");
753
754 RawVelocity = Util.ClampV(value, BSParam.MaxLinearVelocity); 793 RawVelocity = Util.ClampV(value, BSParam.MaxLinearVelocity);
755 if (PhysBody.HasPhysicalBody) 794 if (PhysBody.HasPhysicalBody)
756 { 795 {
@@ -955,7 +994,7 @@ public class BSPrim : BSPhysObject
955 // For good measure, make sure the transform is set through to the motion state 994 // For good measure, make sure the transform is set through to the motion state
956 ForcePosition = RawPosition; 995 ForcePosition = RawPosition;
957 ForceVelocity = RawVelocity; 996 ForceVelocity = RawVelocity;
958 ForceRotationalVelocity = _rotationalVelocity; 997 ForceRotationalVelocity = RawRotationalVelocity;
959 998
960 // A dynamic object has mass 999 // A dynamic object has mass
961 UpdatePhysicalMassProperties(RawMass, false); 1000 UpdatePhysicalMassProperties(RawMass, false);
@@ -1075,35 +1114,6 @@ public class BSPrim : BSPhysObject
1075 }); 1114 });
1076 } 1115 }
1077 } 1116 }
1078 public override OMV.Vector3 RotationalVelocity {
1079 get {
1080 return _rotationalVelocity;
1081 }
1082 set {
1083 _rotationalVelocity = value;
1084 Util.ClampV(_rotationalVelocity, BSParam.MaxAngularVelocity);
1085 // m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity);
1086 PhysScene.TaintedObject(LocalID, "BSPrim.setRotationalVelocity", delegate()
1087 {
1088 ForceRotationalVelocity = _rotationalVelocity;
1089 });
1090 }
1091 }
1092 public override OMV.Vector3 ForceRotationalVelocity {
1093 get {
1094 return _rotationalVelocity;
1095 }
1096 set {
1097 _rotationalVelocity = Util.ClampV(value, BSParam.MaxAngularVelocity);
1098 if (PhysBody.HasPhysicalBody)
1099 {
1100 DetailLog("{0},BSPrim.ForceRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity);
1101 PhysScene.PE.SetAngularVelocity(PhysBody, _rotationalVelocity);
1102 // PhysicsScene.PE.SetInterpolationAngularVelocity(PhysBody, _rotationalVelocity);
1103 ActivateIfPhysical(false);
1104 }
1105 }
1106 }
1107 public override bool Kinematic { 1117 public override bool Kinematic {
1108 get { return _kinematic; } 1118 get { return _kinematic; }
1109 set { _kinematic = value; 1119 set { _kinematic = value;
@@ -1132,14 +1142,14 @@ public class BSPrim : BSPhysObject
1132 } 1142 }
1133 } 1143 }
1134 1144
1135 public override bool PIDActive 1145 public override bool PIDActive
1136 { 1146 {
1137 get 1147 get
1138 { 1148 {
1139 return MoveToTargetActive; 1149 return MoveToTargetActive;
1140 } 1150 }
1141 1151
1142 set 1152 set
1143 { 1153 {
1144 MoveToTargetActive = value; 1154 MoveToTargetActive = value;
1145 1155
@@ -1167,12 +1177,16 @@ public class BSPrim : BSPhysObject
1167 // if the actor exists, tell it to refresh its values. 1177 // if the actor exists, tell it to refresh its values.
1168 actor.Refresh(); 1178 actor.Refresh();
1169 } 1179 }
1170 1180
1171 } 1181 }
1172 } 1182 }
1173 // Used for llSetHoverHeight and maybe vehicle height 1183 // Used for llSetHoverHeight and maybe vehicle height
1174 // Hover Height will override MoveTo target's Z 1184 // Hover Height will override MoveTo target's Z
1175 public override bool PIDHoverActive { 1185 public override bool PIDHoverActive {
1186 get
1187 {
1188 return base.HoverActive;
1189 }
1176 set { 1190 set {
1177 base.HoverActive = value; 1191 base.HoverActive = value;
1178 EnableActor(HoverActive, HoverActorName, delegate() 1192 EnableActor(HoverActive, HoverActorName, delegate()
@@ -1192,14 +1206,18 @@ public class BSPrim : BSPhysObject
1192 // Per documentation, max force is limited. 1206 // Per documentation, max force is limited.
1193 OMV.Vector3 addForce = Util.ClampV(force, BSParam.MaxAddForceMagnitude); 1207 OMV.Vector3 addForce = Util.ClampV(force, BSParam.MaxAddForceMagnitude);
1194 1208
1195 // Since this force is being applied in only one step, make this a force per second. 1209 // Push forces seem to be scaled differently (follow pattern in ubODE)
1196 addForce /= PhysScene.LastTimeStep; 1210 if (!pushforce) {
1197 AddForce(addForce, pushforce, false /* inTaintTime */); 1211 // Since this force is being applied in only one step, make this a force per second.
1212 addForce /= PhysScene.LastTimeStep;
1213 }
1214
1215 AddForce(false /* inTaintTime */, addForce);
1198 } 1216 }
1199 1217
1200 // Applying a force just adds this to the total force on the object. 1218 // Applying a force just adds this to the total force on the object.
1201 // This added force will only last the next simulation tick. 1219 // This added force will only last the next simulation tick.
1202 public override void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) { 1220 public override void AddForce(bool inTaintTime, OMV.Vector3 force) {
1203 // for an object, doesn't matter if force is a pushforce or not 1221 // for an object, doesn't matter if force is a pushforce or not
1204 if (IsPhysicallyActive) 1222 if (IsPhysicallyActive)
1205 { 1223 {
@@ -1258,7 +1276,7 @@ public class BSPrim : BSPhysObject
1258 } 1276 }
1259 1277
1260 // BSPhysObject.AddAngularForce() 1278 // BSPhysObject.AddAngularForce()
1261 public override void AddAngularForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) 1279 public override void AddAngularForce(bool inTaintTime, OMV.Vector3 force)
1262 { 1280 {
1263 if (force.IsFinite()) 1281 if (force.IsFinite())
1264 { 1282 {
@@ -1297,9 +1315,6 @@ public class BSPrim : BSPhysObject
1297 }); 1315 });
1298 } 1316 }
1299 1317
1300 public override void SetMomentum(OMV.Vector3 momentum) {
1301 // DetailLog("{0},BSPrim.SetMomentum,call,mom={1}", LocalID, momentum);
1302 }
1303 #region Mass Calculation 1318 #region Mass Calculation
1304 1319
1305 private float CalculateMass() 1320 private float CalculateMass()
@@ -1869,7 +1884,7 @@ public class BSPrim : BSPhysObject
1869 if (entprop.Velocity == OMV.Vector3.Zero || !entprop.Velocity.ApproxEquals(RawVelocity, BSParam.UpdateVelocityChangeThreshold)) 1884 if (entprop.Velocity == OMV.Vector3.Zero || !entprop.Velocity.ApproxEquals(RawVelocity, BSParam.UpdateVelocityChangeThreshold))
1870 RawVelocity = entprop.Velocity; 1885 RawVelocity = entprop.Velocity;
1871 _acceleration = entprop.Acceleration; 1886 _acceleration = entprop.Acceleration;
1872 _rotationalVelocity = entprop.RotationalVelocity; 1887 RawRotationalVelocity = entprop.RotationalVelocity;
1873 1888
1874 // DetailLog("{0},BSPrim.UpdateProperties,afterAssign,entprop={1}", LocalID, entprop); // DEBUG DEBUG 1889 // DetailLog("{0},BSPrim.UpdateProperties,afterAssign,entprop={1}", LocalID, entprop); // DEBUG DEBUG
1875 1890
@@ -1878,7 +1893,7 @@ public class BSPrim : BSPhysObject
1878 { 1893 {
1879 entprop.Position = RawPosition; 1894 entprop.Position = RawPosition;
1880 entprop.Velocity = RawVelocity; 1895 entprop.Velocity = RawVelocity;
1881 entprop.RotationalVelocity = _rotationalVelocity; 1896 entprop.RotationalVelocity = RawRotationalVelocity;
1882 entprop.Acceleration = _acceleration; 1897 entprop.Acceleration = _acceleration;
1883 } 1898 }
1884 1899