diff options
author | Robert Adams | 2016-09-30 19:35:44 -0700 |
---|---|---|
committer | Robert Adams | 2016-09-30 19:35:44 -0700 |
commit | c7e4b14a26c2c3a265b268a9e6c43e6c93db205e (patch) | |
tree | 7e0b9878a9acab973443b633b4c61b9343f844b3 /OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs | |
parent | MySQLFSAssetData asset type is a int not a varchar (diff) | |
download | opensim-SC-c7e4b14a26c2c3a265b268a9e6c43e6c93db205e.zip opensim-SC-c7e4b14a26c2c3a265b268a9e6c43e6c93db205e.tar.gz opensim-SC-c7e4b14a26c2c3a265b268a9e6c43e6c93db205e.tar.bz2 opensim-SC-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/PhysicsModules/BulletS/BSPrim.cs')
-rw-r--r-- | OpenSim/Region/PhysicsModules/BulletS/BSPrim.cs | 53 |
1 files changed, 10 insertions, 43 deletions
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 | ||