aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorRobert Adams2016-09-30 19:35:44 -0700
committerRobert Adams2016-09-30 19:35:44 -0700
commitc7e4b14a26c2c3a265b268a9e6c43e6c93db205e (patch)
tree7e0b9878a9acab973443b633b4c61b9343f844b3 /OpenSim/Region
parentMySQLFSAssetData asset type is a int not a varchar (diff)
downloadopensim-SC_OLD-c7e4b14a26c2c3a265b268a9e6c43e6c93db205e.zip
opensim-SC_OLD-c7e4b14a26c2c3a265b268a9e6c43e6c93db205e.tar.gz
opensim-SC_OLD-c7e4b14a26c2c3a265b268a9e6c43e6c93db205e.tar.bz2
opensim-SC_OLD-c7e4b14a26c2c3a265b268a9e6c43e6c93db205e.tar.xz
BulletSim: fix problem with avatar velocity going to zero when flying across
region boundries. Move code for Velocity, ForceVelocity and SetMomentum to BSPhysObject and have both BSPrim and BSCharacter share the code.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs19
-rwxr-xr-xOpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs45
-rw-r--r--OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs53
3 files changed, 58 insertions, 59 deletions
diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs b/OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs
index 5ad2136..213f2eb 100644
--- a/OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs
@@ -52,7 +52,6 @@ public sealed class BSCharacter : BSPhysObject
52 private bool _setAlwaysRun; 52 private bool _setAlwaysRun;
53 private bool _throttleUpdates; 53 private bool _throttleUpdates;
54 private bool _floatOnWater; 54 private bool _floatOnWater;
55 private OMV.Vector3 _rotationalVelocity;
56 private bool _kinematic; 55 private bool _kinematic;
57 private float _buoyancy; 56 private float _buoyancy;
58 57
@@ -291,7 +290,7 @@ public sealed class BSCharacter : BSPhysObject
291 { 290 {
292 RawVelocity = OMV.Vector3.Zero; 291 RawVelocity = OMV.Vector3.Zero;
293 _acceleration = OMV.Vector3.Zero; 292 _acceleration = OMV.Vector3.Zero;
294 _rotationalVelocity = OMV.Vector3.Zero; 293 RawRotationalVelocity = OMV.Vector3.Zero;
295 294
296 // Zero some other properties directly into the physics engine 295 // Zero some other properties directly into the physics engine
297 PhysScene.TaintedObject(inTaintTime, LocalID, "BSCharacter.ZeroMotion", delegate() 296 PhysScene.TaintedObject(inTaintTime, LocalID, "BSCharacter.ZeroMotion", delegate()
@@ -303,7 +302,7 @@ public sealed class BSCharacter : BSPhysObject
303 302
304 public override void ZeroAngularMotion(bool inTaintTime) 303 public override void ZeroAngularMotion(bool inTaintTime)
305 { 304 {
306 _rotationalVelocity = OMV.Vector3.Zero; 305 RawRotationalVelocity = OMV.Vector3.Zero;
307 306
308 PhysScene.TaintedObject(inTaintTime, LocalID, "BSCharacter.ZeroMotion", delegate() 307 PhysScene.TaintedObject(inTaintTime, LocalID, "BSCharacter.ZeroMotion", delegate()
309 { 308 {
@@ -618,14 +617,6 @@ public sealed class BSCharacter : BSPhysObject
618 }); 617 });
619 } 618 }
620 } 619 }
621 public override OMV.Vector3 RotationalVelocity {
622 get { return _rotationalVelocity; }
623 set { _rotationalVelocity = value; }
624 }
625 public override OMV.Vector3 ForceRotationalVelocity {
626 get { return _rotationalVelocity; }
627 set { _rotationalVelocity = value; }
628 }
629 public override bool Kinematic { 620 public override bool Kinematic {
630 get { return _kinematic; } 621 get { return _kinematic; }
631 set { _kinematic = value; } 622 set { _kinematic = value; }
@@ -716,8 +707,6 @@ public sealed class BSCharacter : BSPhysObject
716 707
717 public override void AddAngularForce(bool inTaintTime, OMV.Vector3 force) { 708 public override void AddAngularForce(bool inTaintTime, OMV.Vector3 force) {
718 } 709 }
719 public override void SetMomentum(OMV.Vector3 momentum) {
720 }
721 710
722 // The avatar's physical shape (whether capsule or cube) is unit sized. BulletSim sets 711 // The avatar's physical shape (whether capsule or cube) is unit sized. BulletSim sets
723 // the scale of that unit shape to create the avatars full size. 712 // the scale of that unit shape to create the avatars full size.
@@ -841,7 +830,7 @@ public sealed class BSCharacter : BSPhysObject
841 RawVelocity = entprop.Velocity; 830 RawVelocity = entprop.Velocity;
842 831
843 _acceleration = entprop.Acceleration; 832 _acceleration = entprop.Acceleration;
844 _rotationalVelocity = entprop.RotationalVelocity; 833 RawRotationalVelocity = entprop.RotationalVelocity;
845 834
846 // Do some sanity checking for the avatar. Make sure it's above ground and inbounds. 835 // Do some sanity checking for the avatar. Make sure it's above ground and inbounds.
847 if (PositionSanityCheck(true)) 836 if (PositionSanityCheck(true))
@@ -861,7 +850,7 @@ public sealed class BSCharacter : BSPhysObject
861 // PhysScene.PostUpdate(this); 850 // PhysScene.PostUpdate(this);
862 851
863 DetailLog("{0},BSCharacter.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}", 852 DetailLog("{0},BSCharacter.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}",
864 LocalID, RawPosition, RawOrientation, RawVelocity, _acceleration, _rotationalVelocity); 853 LocalID, RawPosition, RawOrientation, RawVelocity, _acceleration, RawRotationalVelocity);
865 } 854 }
866} 855}
867} 856}
diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs b/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs
index bb21f0c..7c6f213 100755
--- a/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs
@@ -239,6 +239,8 @@ public abstract class BSPhysObject : PhysicsActor
239 public virtual OMV.Vector3 RawVelocity { get; set; } 239 public virtual OMV.Vector3 RawVelocity { get; set; }
240 public abstract OMV.Vector3 ForceVelocity { get; set; } 240 public abstract OMV.Vector3 ForceVelocity { get; set; }
241 241
242 public OMV.Vector3 RawRotationalVelocity { get; set; }
243
242 // RawForce is a constant force applied to object (see Force { set; } ) 244 // RawForce is a constant force applied to object (see Force { set; } )
243 public OMV.Vector3 RawForce { get; set; } 245 public OMV.Vector3 RawForce { get; set; }
244 public OMV.Vector3 RawTorque { get; set; } 246 public OMV.Vector3 RawTorque { get; set; }
@@ -250,7 +252,48 @@ public abstract class BSPhysObject : PhysicsActor
250 public abstract void AddAngularForce(bool inTaintTime, OMV.Vector3 force); 252 public abstract void AddAngularForce(bool inTaintTime, OMV.Vector3 force);
251 public abstract void AddForce(bool inTaintTime, OMV.Vector3 force); 253 public abstract void AddForce(bool inTaintTime, OMV.Vector3 force);
252 254
253 public abstract OMV.Vector3 ForceRotationalVelocity { get; set; } 255 // PhysicsActor.SetMomentum
256 // All the physics engined use this as a way of forcing the velocity to something.
257 public override void SetMomentum(OMV.Vector3 momentum)
258 {
259 // This doesn't just set Velocity=momentum because velocity is ramped up to (see MoveActor)
260 RawVelocity = momentum;
261 PhysScene.TaintedObject(LocalID, TypeName + ".SetMomentum", delegate()
262 {
263 // DetailLog("{0},BSPrim.SetMomentum,taint,vel={1}", LocalID, RawVelocity);
264 ForceVelocity = RawVelocity;
265 });
266 }
267
268 public override OMV.Vector3 RotationalVelocity {
269 get {
270 return RawRotationalVelocity;
271 }
272 set {
273 RawRotationalVelocity = value;
274 Util.ClampV(RawRotationalVelocity, BSParam.MaxAngularVelocity);
275 // m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity);
276 PhysScene.TaintedObject(LocalID, TypeName + ".setRotationalVelocity", delegate()
277 {
278 ForceRotationalVelocity = RawRotationalVelocity;
279 });
280 }
281 }
282 public OMV.Vector3 ForceRotationalVelocity {
283 get {
284 return RawRotationalVelocity;
285 }
286 set {
287 RawRotationalVelocity = Util.ClampV(value, BSParam.MaxAngularVelocity);
288 if (PhysBody.HasPhysicalBody)
289 {
290 DetailLog("{0},{1}.ForceRotationalVel,taint,rotvel={2}", LocalID, TypeName, RawRotationalVelocity);
291 PhysScene.PE.SetAngularVelocity(PhysBody, RawRotationalVelocity);
292 // PhysicsScene.PE.SetInterpolationAngularVelocity(PhysBody, _rotationalVelocity);
293 ActivateIfPhysical(false);
294 }
295 }
296 }
254 297
255 public abstract float ForceBuoyancy { get; set; } 298 public abstract float ForceBuoyancy { get; set; }
256 299
diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs b/OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs
index fd9b834..78a617d 100644
--- a/OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs
+++ b/OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs
@@ -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,15 +266,15 @@ 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 }
@@ -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
@@ -1008,7 +1007,7 @@ public class BSPrim : BSPhysObject
1008 // For good measure, make sure the transform is set through to the motion state 1007 // For good measure, make sure the transform is set through to the motion state
1009 ForcePosition = RawPosition; 1008 ForcePosition = RawPosition;
1010 ForceVelocity = RawVelocity; 1009 ForceVelocity = RawVelocity;
1011 ForceRotationalVelocity = _rotationalVelocity; 1010 ForceRotationalVelocity = RawRotationalVelocity;
1012 1011
1013 // A dynamic object has mass 1012 // A dynamic object has mass
1014 UpdatePhysicalMassProperties(RawMass, false); 1013 UpdatePhysicalMassProperties(RawMass, false);
@@ -1128,35 +1127,6 @@ public class BSPrim : BSPhysObject
1128 }); 1127 });
1129 } 1128 }
1130 } 1129 }
1131 public override OMV.Vector3 RotationalVelocity {
1132 get {
1133 return _rotationalVelocity;
1134 }
1135 set {
1136 _rotationalVelocity = value;
1137 Util.ClampV(_rotationalVelocity, BSParam.MaxAngularVelocity);
1138 // m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity);
1139 PhysScene.TaintedObject(LocalID, "BSPrim.setRotationalVelocity", delegate()
1140 {
1141 ForceRotationalVelocity = _rotationalVelocity;
1142 });
1143 }
1144 }
1145 public override OMV.Vector3 ForceRotationalVelocity {
1146 get {
1147 return _rotationalVelocity;
1148 }
1149 set {
1150 _rotationalVelocity = Util.ClampV(value, BSParam.MaxAngularVelocity);
1151 if (PhysBody.HasPhysicalBody)
1152 {
1153 DetailLog("{0},BSPrim.ForceRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity);
1154 PhysScene.PE.SetAngularVelocity(PhysBody, _rotationalVelocity);
1155 // PhysicsScene.PE.SetInterpolationAngularVelocity(PhysBody, _rotationalVelocity);
1156 ActivateIfPhysical(false);
1157 }
1158 }
1159 }
1160 public override bool Kinematic { 1130 public override bool Kinematic {
1161 get { return _kinematic; } 1131 get { return _kinematic; }
1162 set { _kinematic = value; 1132 set { _kinematic = value;
@@ -1358,9 +1328,6 @@ public class BSPrim : BSPhysObject
1358 }); 1328 });
1359 } 1329 }
1360 1330
1361 public override void SetMomentum(OMV.Vector3 momentum) {
1362 // DetailLog("{0},BSPrim.SetMomentum,call,mom={1}", LocalID, momentum);
1363 }
1364 #region Mass Calculation 1331 #region Mass Calculation
1365 1332
1366 private float CalculateMass() 1333 private float CalculateMass()
@@ -1930,7 +1897,7 @@ public class BSPrim : BSPhysObject
1930 if (entprop.Velocity == OMV.Vector3.Zero || !entprop.Velocity.ApproxEquals(RawVelocity, BSParam.UpdateVelocityChangeThreshold)) 1897 if (entprop.Velocity == OMV.Vector3.Zero || !entprop.Velocity.ApproxEquals(RawVelocity, BSParam.UpdateVelocityChangeThreshold))
1931 RawVelocity = entprop.Velocity; 1898 RawVelocity = entprop.Velocity;
1932 _acceleration = entprop.Acceleration; 1899 _acceleration = entprop.Acceleration;
1933 _rotationalVelocity = entprop.RotationalVelocity; 1900 RawRotationalVelocity = entprop.RotationalVelocity;
1934 1901
1935 // DetailLog("{0},BSPrim.UpdateProperties,afterAssign,entprop={1}", LocalID, entprop); // DEBUG DEBUG 1902 // DetailLog("{0},BSPrim.UpdateProperties,afterAssign,entprop={1}", LocalID, entprop); // DEBUG DEBUG
1936 1903
@@ -1939,7 +1906,7 @@ public class BSPrim : BSPhysObject
1939 { 1906 {
1940 entprop.Position = RawPosition; 1907 entprop.Position = RawPosition;
1941 entprop.Velocity = RawVelocity; 1908 entprop.Velocity = RawVelocity;
1942 entprop.RotationalVelocity = _rotationalVelocity; 1909 entprop.RotationalVelocity = RawRotationalVelocity;
1943 entprop.Acceleration = _acceleration; 1910 entprop.Acceleration = _acceleration;
1944 } 1911 }
1945 1912