diff options
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | 78 | ||||
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | 4 | ||||
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 84 |
3 files changed, 71 insertions, 95 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 5ef6992..c9e3ca0 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | |||
@@ -43,12 +43,10 @@ public sealed class BSCharacter : BSPhysObject | |||
43 | private OMV.Vector3 _size; | 43 | private OMV.Vector3 _size; |
44 | private bool _grabbed; | 44 | private bool _grabbed; |
45 | private bool _selected; | 45 | private bool _selected; |
46 | private OMV.Vector3 _position; | ||
47 | private float _mass; | 46 | private float _mass; |
48 | private float _avatarVolume; | 47 | private float _avatarVolume; |
49 | private float _collisionScore; | 48 | private float _collisionScore; |
50 | private OMV.Vector3 _acceleration; | 49 | private OMV.Vector3 _acceleration; |
51 | private OMV.Quaternion _orientation; | ||
52 | private int _physicsActorType; | 50 | private int _physicsActorType; |
53 | private bool _isPhysical; | 51 | private bool _isPhysical; |
54 | private bool _flying; | 52 | private bool _flying; |
@@ -70,10 +68,10 @@ public sealed class BSCharacter : BSPhysObject | |||
70 | : base(parent_scene, localID, avName, "BSCharacter") | 68 | : base(parent_scene, localID, avName, "BSCharacter") |
71 | { | 69 | { |
72 | _physicsActorType = (int)ActorTypes.Agent; | 70 | _physicsActorType = (int)ActorTypes.Agent; |
73 | _position = pos; | 71 | RawPosition = pos; |
74 | 72 | ||
75 | _flying = isFlying; | 73 | _flying = isFlying; |
76 | _orientation = OMV.Quaternion.Identity; | 74 | RawOrientation = OMV.Quaternion.Identity; |
77 | RawVelocity = OMV.Vector3.Zero; | 75 | RawVelocity = OMV.Vector3.Zero; |
78 | _buoyancy = ComputeBuoyancyFromFlying(isFlying); | 76 | _buoyancy = ComputeBuoyancyFromFlying(isFlying); |
79 | Friction = BSParam.AvatarStandingFriction; | 77 | Friction = BSParam.AvatarStandingFriction; |
@@ -133,7 +131,7 @@ public sealed class BSCharacter : BSPhysObject | |||
133 | PhysScene.PE.RemoveObjectFromWorld(PhysScene.World, PhysBody); | 131 | PhysScene.PE.RemoveObjectFromWorld(PhysScene.World, PhysBody); |
134 | 132 | ||
135 | ZeroMotion(true); | 133 | ZeroMotion(true); |
136 | ForcePosition = _position; | 134 | ForcePosition = RawPosition; |
137 | 135 | ||
138 | // Set the velocity | 136 | // Set the velocity |
139 | if (m_moveActor != null) | 137 | if (m_moveActor != null) |
@@ -272,38 +270,33 @@ public sealed class BSCharacter : BSPhysObject | |||
272 | 270 | ||
273 | public override void LockAngularMotion(OMV.Vector3 axis) { return; } | 271 | public override void LockAngularMotion(OMV.Vector3 axis) { return; } |
274 | 272 | ||
275 | public override OMV.Vector3 RawPosition | ||
276 | { | ||
277 | get { return _position; } | ||
278 | set { _position = value; } | ||
279 | } | ||
280 | public override OMV.Vector3 Position { | 273 | public override OMV.Vector3 Position { |
281 | get { | 274 | get { |
282 | // Don't refetch the position because this function is called a zillion times | 275 | // Don't refetch the position because this function is called a zillion times |
283 | // _position = PhysicsScene.PE.GetObjectPosition(Scene.World, LocalID); | 276 | // RawPosition = PhysicsScene.PE.GetObjectPosition(Scene.World, LocalID); |
284 | return _position; | 277 | return RawPosition; |
285 | } | 278 | } |
286 | set { | 279 | set { |
287 | _position = value; | 280 | RawPosition = value; |
288 | 281 | ||
289 | PhysScene.TaintedObject("BSCharacter.setPosition", delegate() | 282 | PhysScene.TaintedObject("BSCharacter.setPosition", delegate() |
290 | { | 283 | { |
291 | DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); | 284 | DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, RawPosition, RawOrientation); |
292 | PositionSanityCheck(); | 285 | PositionSanityCheck(); |
293 | ForcePosition = _position; | 286 | ForcePosition = RawPosition; |
294 | }); | 287 | }); |
295 | } | 288 | } |
296 | } | 289 | } |
297 | public override OMV.Vector3 ForcePosition { | 290 | public override OMV.Vector3 ForcePosition { |
298 | get { | 291 | get { |
299 | _position = PhysScene.PE.GetPosition(PhysBody); | 292 | RawPosition = PhysScene.PE.GetPosition(PhysBody); |
300 | return _position; | 293 | return RawPosition; |
301 | } | 294 | } |
302 | set { | 295 | set { |
303 | _position = value; | 296 | RawPosition = value; |
304 | if (PhysBody.HasPhysicalBody) | 297 | if (PhysBody.HasPhysicalBody) |
305 | { | 298 | { |
306 | PhysScene.PE.SetTranslation(PhysBody, _position, _orientation); | 299 | PhysScene.PE.SetTranslation(PhysBody, RawPosition, RawOrientation); |
307 | } | 300 | } |
308 | } | 301 | } |
309 | } | 302 | } |
@@ -331,16 +324,16 @@ public sealed class BSCharacter : BSPhysObject | |||
331 | float terrainHeight = PhysScene.TerrainManager.GetTerrainHeightAtXYZ(RawPosition); | 324 | float terrainHeight = PhysScene.TerrainManager.GetTerrainHeightAtXYZ(RawPosition); |
332 | if (Position.Z < terrainHeight) | 325 | if (Position.Z < terrainHeight) |
333 | { | 326 | { |
334 | DetailLog("{0},BSCharacter.PositionSanityCheck,adjustForUnderGround,pos={1},terrain={2}", LocalID, _position, terrainHeight); | 327 | DetailLog("{0},BSCharacter.PositionSanityCheck,adjustForUnderGround,pos={1},terrain={2}", LocalID, RawPosition, terrainHeight); |
335 | _position.Z = terrainHeight + BSParam.AvatarBelowGroundUpCorrectionMeters; | 328 | RawPosition = new OMV.Vector3(RawPosition.X, RawPosition.Y, terrainHeight + BSParam.AvatarBelowGroundUpCorrectionMeters); |
336 | ret = true; | 329 | ret = true; |
337 | } | 330 | } |
338 | if ((CurrentCollisionFlags & CollisionFlags.BS_FLOATS_ON_WATER) != 0) | 331 | if ((CurrentCollisionFlags & CollisionFlags.BS_FLOATS_ON_WATER) != 0) |
339 | { | 332 | { |
340 | float waterHeight = PhysScene.TerrainManager.GetWaterLevelAtXYZ(_position); | 333 | float waterHeight = PhysScene.TerrainManager.GetWaterLevelAtXYZ(RawPosition); |
341 | if (Position.Z < waterHeight) | 334 | if (Position.Z < waterHeight) |
342 | { | 335 | { |
343 | _position.Z = waterHeight; | 336 | RawPosition = new OMV.Vector3(RawPosition.X, RawPosition.Y, waterHeight); |
344 | ret = true; | 337 | ret = true; |
345 | } | 338 | } |
346 | } | 339 | } |
@@ -360,8 +353,8 @@ public sealed class BSCharacter : BSPhysObject | |||
360 | // just assign to "Position" because of potential call loops. | 353 | // just assign to "Position" because of potential call loops. |
361 | PhysScene.TaintedObject(inTaintTime, "BSCharacter.PositionSanityCheck", delegate() | 354 | PhysScene.TaintedObject(inTaintTime, "BSCharacter.PositionSanityCheck", delegate() |
362 | { | 355 | { |
363 | DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation); | 356 | DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, RawPosition, RawOrientation); |
364 | ForcePosition = _position; | 357 | ForcePosition = RawPosition; |
365 | }); | 358 | }); |
366 | ret = true; | 359 | ret = true; |
367 | } | 360 | } |
@@ -466,19 +459,14 @@ public sealed class BSCharacter : BSPhysObject | |||
466 | get { return _acceleration; } | 459 | get { return _acceleration; } |
467 | set { _acceleration = value; } | 460 | set { _acceleration = value; } |
468 | } | 461 | } |
469 | public override OMV.Quaternion RawOrientation | ||
470 | { | ||
471 | get { return _orientation; } | ||
472 | set { _orientation = value; } | ||
473 | } | ||
474 | public override OMV.Quaternion Orientation { | 462 | public override OMV.Quaternion Orientation { |
475 | get { return _orientation; } | 463 | get { return RawOrientation; } |
476 | set { | 464 | set { |
477 | // Orientation is set zillions of times when an avatar is walking. It's like | 465 | // Orientation is set zillions of times when an avatar is walking. It's like |
478 | // the viewer doesn't trust us. | 466 | // the viewer doesn't trust us. |
479 | if (_orientation != value) | 467 | if (RawOrientation != value) |
480 | { | 468 | { |
481 | _orientation = value; | 469 | RawOrientation = value; |
482 | PhysScene.TaintedObject("BSCharacter.setOrientation", delegate() | 470 | PhysScene.TaintedObject("BSCharacter.setOrientation", delegate() |
483 | { | 471 | { |
484 | // Bullet assumes we know what we are doing when forcing orientation | 472 | // Bullet assumes we know what we are doing when forcing orientation |
@@ -486,10 +474,10 @@ public sealed class BSCharacter : BSPhysObject | |||
486 | // This forces rotation to be only around the Z axis and doesn't change any of the other axis. | 474 | // This forces rotation to be only around the Z axis and doesn't change any of the other axis. |
487 | // This keeps us from flipping the capsule over which the veiwer does not understand. | 475 | // This keeps us from flipping the capsule over which the veiwer does not understand. |
488 | float oRoll, oPitch, oYaw; | 476 | float oRoll, oPitch, oYaw; |
489 | _orientation.GetEulerAngles(out oRoll, out oPitch, out oYaw); | 477 | RawOrientation.GetEulerAngles(out oRoll, out oPitch, out oYaw); |
490 | OMV.Quaternion trimmedOrientation = OMV.Quaternion.CreateFromEulers(0f, 0f, oYaw); | 478 | OMV.Quaternion trimmedOrientation = OMV.Quaternion.CreateFromEulers(0f, 0f, oYaw); |
491 | // DetailLog("{0},BSCharacter.setOrientation,taint,val={1},valDir={2},conv={3},convDir={4}", | 479 | // DetailLog("{0},BSCharacter.setOrientation,taint,val={1},valDir={2},conv={3},convDir={4}", |
492 | // LocalID, _orientation, OMV.Vector3.UnitX * _orientation, | 480 | // LocalID, RawOrientation, OMV.Vector3.UnitX * RawOrientation, |
493 | // trimmedOrientation, OMV.Vector3.UnitX * trimmedOrientation); | 481 | // trimmedOrientation, OMV.Vector3.UnitX * trimmedOrientation); |
494 | ForceOrientation = trimmedOrientation; | 482 | ForceOrientation = trimmedOrientation; |
495 | }); | 483 | }); |
@@ -501,16 +489,16 @@ public sealed class BSCharacter : BSPhysObject | |||
501 | { | 489 | { |
502 | get | 490 | get |
503 | { | 491 | { |
504 | _orientation = PhysScene.PE.GetOrientation(PhysBody); | 492 | RawOrientation = PhysScene.PE.GetOrientation(PhysBody); |
505 | return _orientation; | 493 | return RawOrientation; |
506 | } | 494 | } |
507 | set | 495 | set |
508 | { | 496 | { |
509 | _orientation = value; | 497 | RawOrientation = value; |
510 | if (PhysBody.HasPhysicalBody) | 498 | if (PhysBody.HasPhysicalBody) |
511 | { | 499 | { |
512 | // _position = PhysicsScene.PE.GetPosition(BSBody); | 500 | // RawPosition = PhysicsScene.PE.GetPosition(BSBody); |
513 | PhysScene.PE.SetTranslation(PhysBody, _position, _orientation); | 501 | PhysScene.PE.SetTranslation(PhysBody, RawPosition, RawOrientation); |
514 | } | 502 | } |
515 | } | 503 | } |
516 | } | 504 | } |
@@ -723,9 +711,9 @@ public sealed class BSCharacter : BSPhysObject | |||
723 | { | 711 | { |
724 | // Don't change position if standing on a stationary object. | 712 | // Don't change position if standing on a stationary object. |
725 | if (!IsStationary) | 713 | if (!IsStationary) |
726 | _position = entprop.Position; | 714 | RawPosition = entprop.Position; |
727 | 715 | ||
728 | _orientation = entprop.Rotation; | 716 | RawOrientation = entprop.Rotation; |
729 | 717 | ||
730 | // Smooth velocity. OpenSimulator is VERY sensitive to changes in velocity of the avatar | 718 | // Smooth velocity. OpenSimulator is VERY sensitive to changes in velocity of the avatar |
731 | // and will send agent updates to the clients if velocity changes by more than | 719 | // and will send agent updates to the clients if velocity changes by more than |
@@ -740,8 +728,8 @@ public sealed class BSCharacter : BSPhysObject | |||
740 | // Do some sanity checking for the avatar. Make sure it's above ground and inbounds. | 728 | // Do some sanity checking for the avatar. Make sure it's above ground and inbounds. |
741 | if (PositionSanityCheck(true)) | 729 | if (PositionSanityCheck(true)) |
742 | { | 730 | { |
743 | DetailLog("{0},BSCharacter.UpdateProperties,updatePosForSanity,pos={1}", LocalID, _position); | 731 | DetailLog("{0},BSCharacter.UpdateProperties,updatePosForSanity,pos={1}", LocalID, RawPosition); |
744 | entprop.Position = _position; | 732 | entprop.Position = RawPosition; |
745 | } | 733 | } |
746 | 734 | ||
747 | // remember the current and last set values | 735 | // remember the current and last set values |
@@ -755,7 +743,7 @@ public sealed class BSCharacter : BSPhysObject | |||
755 | // base.RequestPhysicsterseUpdate(); | 743 | // base.RequestPhysicsterseUpdate(); |
756 | 744 | ||
757 | DetailLog("{0},BSCharacter.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}", | 745 | DetailLog("{0},BSCharacter.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}", |
758 | LocalID, _position, _orientation, RawVelocity, _acceleration, _rotationalVelocity); | 746 | LocalID, RawPosition, RawOrientation, RawVelocity, _acceleration, _rotationalVelocity); |
759 | } | 747 | } |
760 | } | 748 | } |
761 | } | 749 | } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index 738e2d0..a41eaf8 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | |||
@@ -197,10 +197,10 @@ public abstract class BSPhysObject : PhysicsActor | |||
197 | // Update the physical location and motion of the object. Called with data from Bullet. | 197 | // Update the physical location and motion of the object. Called with data from Bullet. |
198 | public abstract void UpdateProperties(EntityProperties entprop); | 198 | public abstract void UpdateProperties(EntityProperties entprop); |
199 | 199 | ||
200 | public abstract OMV.Vector3 RawPosition { get; set; } | 200 | public virtual OMV.Vector3 RawPosition { get; set; } |
201 | public abstract OMV.Vector3 ForcePosition { get; set; } | 201 | public abstract OMV.Vector3 ForcePosition { get; set; } |
202 | 202 | ||
203 | public abstract OMV.Quaternion RawOrientation { get; set; } | 203 | public virtual OMV.Quaternion RawOrientation { get; set; } |
204 | public abstract OMV.Quaternion ForceOrientation { get; set; } | 204 | public abstract OMV.Quaternion ForceOrientation { get; set; } |
205 | 205 | ||
206 | public OMV.Vector3 RawVelocity { get; set; } | 206 | public OMV.Vector3 RawVelocity { get; set; } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index ce4c3da..d43448e 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -51,12 +51,8 @@ public class BSPrim : BSPhysObject | |||
51 | private bool _isSelected; | 51 | private bool _isSelected; |
52 | private bool _isVolumeDetect; | 52 | private bool _isVolumeDetect; |
53 | 53 | ||
54 | // _position is what the simulator thinks the positions of the prim is. | ||
55 | private OMV.Vector3 _position; | ||
56 | |||
57 | private float _mass; // the mass of this object | 54 | private float _mass; // the mass of this object |
58 | private OMV.Vector3 _acceleration; | 55 | private OMV.Vector3 _acceleration; |
59 | private OMV.Quaternion _orientation; | ||
60 | private int _physicsActorType; | 56 | private int _physicsActorType; |
61 | private bool _isPhysical; | 57 | private bool _isPhysical; |
62 | private bool _flying; | 58 | private bool _flying; |
@@ -88,10 +84,10 @@ public class BSPrim : BSPhysObject | |||
88 | { | 84 | { |
89 | // m_log.DebugFormat("{0}: BSPrim creation of {1}, id={2}", LogHeader, primName, localID); | 85 | // m_log.DebugFormat("{0}: BSPrim creation of {1}, id={2}", LogHeader, primName, localID); |
90 | _physicsActorType = (int)ActorTypes.Prim; | 86 | _physicsActorType = (int)ActorTypes.Prim; |
91 | _position = pos; | 87 | RawPosition = pos; |
92 | _size = size; | 88 | _size = size; |
93 | Scale = size; // prims are the size the user wants them to be (different for BSCharactes). | 89 | Scale = size; // prims are the size the user wants them to be (different for BSCharactes). |
94 | _orientation = rotation; | 90 | RawOrientation = rotation; |
95 | _buoyancy = 0f; | 91 | _buoyancy = 0f; |
96 | RawVelocity = OMV.Vector3.Zero; | 92 | RawVelocity = OMV.Vector3.Zero; |
97 | _rotationalVelocity = OMV.Vector3.Zero; | 93 | _rotationalVelocity = OMV.Vector3.Zero; |
@@ -270,46 +266,42 @@ public class BSPrim : BSPhysObject | |||
270 | return; | 266 | return; |
271 | } | 267 | } |
272 | 268 | ||
273 | public override OMV.Vector3 RawPosition | ||
274 | { | ||
275 | get { return _position; } | ||
276 | set { _position = value; } | ||
277 | } | ||
278 | public override OMV.Vector3 Position { | 269 | public override OMV.Vector3 Position { |
279 | get { | 270 | get { |
280 | // don't do the GetObjectPosition for root elements because this function is called a zillion times. | 271 | // don't do the GetObjectPosition for root elements because this function is called a zillion times. |
281 | // _position = ForcePosition; | 272 | // RawPosition = ForcePosition; |
282 | return _position; | 273 | return RawPosition; |
283 | } | 274 | } |
284 | set { | 275 | set { |
285 | // If the position must be forced into the physics engine, use ForcePosition. | 276 | // If the position must be forced into the physics engine, use ForcePosition. |
286 | // All positions are given in world positions. | 277 | // All positions are given in world positions. |
287 | if (_position == value) | 278 | if (RawPosition == value) |
288 | { | 279 | { |
289 | DetailLog("{0},BSPrim.setPosition,call,positionNotChanging,pos={1},orient={2}", LocalID, _position, _orientation); | 280 | DetailLog("{0},BSPrim.setPosition,call,positionNotChanging,pos={1},orient={2}", LocalID, RawPosition, RawOrientation); |
290 | return; | 281 | return; |
291 | } | 282 | } |
292 | _position = value; | 283 | RawPosition = value; |
293 | PositionSanityCheck(false); | 284 | PositionSanityCheck(false); |
294 | 285 | ||
295 | PhysScene.TaintedObject("BSPrim.setPosition", delegate() | 286 | PhysScene.TaintedObject("BSPrim.setPosition", delegate() |
296 | { | 287 | { |
297 | DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); | 288 | DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, RawPosition, RawOrientation); |
298 | ForcePosition = _position; | 289 | ForcePosition = RawPosition; |
299 | }); | 290 | }); |
300 | } | 291 | } |
301 | } | 292 | } |
302 | 293 | ||
294 | // NOTE: overloaded by BSPrimDisplaced to handle offset for center-of-gravity. | ||
303 | public override OMV.Vector3 ForcePosition { | 295 | public override OMV.Vector3 ForcePosition { |
304 | get { | 296 | get { |
305 | _position = PhysScene.PE.GetPosition(PhysBody); | 297 | RawPosition = PhysScene.PE.GetPosition(PhysBody); |
306 | return _position; | 298 | return RawPosition; |
307 | } | 299 | } |
308 | set { | 300 | set { |
309 | _position = value; | 301 | RawPosition = value; |
310 | if (PhysBody.HasPhysicalBody) | 302 | if (PhysBody.HasPhysicalBody) |
311 | { | 303 | { |
312 | PhysScene.PE.SetTranslation(PhysBody, _position, _orientation); | 304 | PhysScene.PE.SetTranslation(PhysBody, RawPosition, RawOrientation); |
313 | ActivateIfPhysical(false); | 305 | ActivateIfPhysical(false); |
314 | } | 306 | } |
315 | } | 307 | } |
@@ -343,10 +335,10 @@ public class BSPrim : BSPhysObject | |||
343 | float targetHeight = terrainHeight + (Size.Z / 2f); | 335 | float targetHeight = terrainHeight + (Size.Z / 2f); |
344 | // If the object is below ground it just has to be moved up because pushing will | 336 | // If the object is below ground it just has to be moved up because pushing will |
345 | // not get it through the terrain | 337 | // not get it through the terrain |
346 | _position.Z = targetHeight; | 338 | RawPosition = new OMV.Vector3(RawPosition.X, RawPosition.Y, targetHeight); |
347 | if (inTaintTime) | 339 | if (inTaintTime) |
348 | { | 340 | { |
349 | ForcePosition = _position; | 341 | ForcePosition = RawPosition; |
350 | } | 342 | } |
351 | // If we are throwing the object around, zero its other forces | 343 | // If we are throwing the object around, zero its other forces |
352 | ZeroMotion(inTaintTime); | 344 | ZeroMotion(inTaintTime); |
@@ -355,7 +347,7 @@ public class BSPrim : BSPhysObject | |||
355 | 347 | ||
356 | if ((CurrentCollisionFlags & CollisionFlags.BS_FLOATS_ON_WATER) != 0) | 348 | if ((CurrentCollisionFlags & CollisionFlags.BS_FLOATS_ON_WATER) != 0) |
357 | { | 349 | { |
358 | float waterHeight = PhysScene.TerrainManager.GetWaterLevelAtXYZ(_position); | 350 | float waterHeight = PhysScene.TerrainManager.GetWaterLevelAtXYZ(RawPosition); |
359 | // TODO: a floating motor so object will bob in the water | 351 | // TODO: a floating motor so object will bob in the water |
360 | if (Math.Abs(RawPosition.Z - waterHeight) > 0.1f) | 352 | if (Math.Abs(RawPosition.Z - waterHeight) > 0.1f) |
361 | { | 353 | { |
@@ -364,7 +356,7 @@ public class BSPrim : BSPhysObject | |||
364 | 356 | ||
365 | // Apply upforce and overcome gravity. | 357 | // Apply upforce and overcome gravity. |
366 | OMV.Vector3 correctionForce = upForce - PhysScene.DefaultGravity; | 358 | OMV.Vector3 correctionForce = upForce - PhysScene.DefaultGravity; |
367 | DetailLog("{0},BSPrim.PositionSanityCheck,applyForce,pos={1},upForce={2},correctionForce={3}", LocalID, _position, upForce, correctionForce); | 359 | DetailLog("{0},BSPrim.PositionSanityCheck,applyForce,pos={1},upForce={2},correctionForce={3}", LocalID, RawPosition, upForce, correctionForce); |
368 | AddForce(correctionForce, false, inTaintTime); | 360 | AddForce(correctionForce, false, inTaintTime); |
369 | ret = true; | 361 | ret = true; |
370 | } | 362 | } |
@@ -383,11 +375,11 @@ public class BSPrim : BSPhysObject | |||
383 | uint wayOutThere = Constants.RegionSize * Constants.RegionSize; | 375 | uint wayOutThere = Constants.RegionSize * Constants.RegionSize; |
384 | // There have been instances of objects getting thrown way out of bounds and crashing | 376 | // There have been instances of objects getting thrown way out of bounds and crashing |
385 | // the border crossing code. | 377 | // the border crossing code. |
386 | if ( _position.X < -Constants.RegionSize || _position.X > wayOutThere | 378 | if ( RawPosition.X < -Constants.RegionSize || RawPosition.X > wayOutThere |
387 | || _position.Y < -Constants.RegionSize || _position.Y > wayOutThere | 379 | || RawPosition.Y < -Constants.RegionSize || RawPosition.Y > wayOutThere |
388 | || _position.Z < -Constants.RegionSize || _position.Z > wayOutThere) | 380 | || RawPosition.Z < -Constants.RegionSize || RawPosition.Z > wayOutThere) |
389 | { | 381 | { |
390 | _position = new OMV.Vector3(10, 10, 50); | 382 | RawPosition = new OMV.Vector3(10, 10, 50); |
391 | ZeroMotion(inTaintTime); | 383 | ZeroMotion(inTaintTime); |
392 | ret = true; | 384 | ret = true; |
393 | } | 385 | } |
@@ -713,23 +705,19 @@ public class BSPrim : BSPhysObject | |||
713 | get { return _acceleration; } | 705 | get { return _acceleration; } |
714 | set { _acceleration = value; } | 706 | set { _acceleration = value; } |
715 | } | 707 | } |
716 | public override OMV.Quaternion RawOrientation | 708 | |
717 | { | ||
718 | get { return _orientation; } | ||
719 | set { _orientation = value; } | ||
720 | } | ||
721 | public override OMV.Quaternion Orientation { | 709 | public override OMV.Quaternion Orientation { |
722 | get { | 710 | get { |
723 | return _orientation; | 711 | return RawOrientation; |
724 | } | 712 | } |
725 | set { | 713 | set { |
726 | if (_orientation == value) | 714 | if (RawOrientation == value) |
727 | return; | 715 | return; |
728 | _orientation = value; | 716 | RawOrientation = value; |
729 | 717 | ||
730 | PhysScene.TaintedObject("BSPrim.setOrientation", delegate() | 718 | PhysScene.TaintedObject("BSPrim.setOrientation", delegate() |
731 | { | 719 | { |
732 | ForceOrientation = _orientation; | 720 | ForceOrientation = RawOrientation; |
733 | }); | 721 | }); |
734 | } | 722 | } |
735 | } | 723 | } |
@@ -738,14 +726,14 @@ public class BSPrim : BSPhysObject | |||
738 | { | 726 | { |
739 | get | 727 | get |
740 | { | 728 | { |
741 | _orientation = PhysScene.PE.GetOrientation(PhysBody); | 729 | RawOrientation = PhysScene.PE.GetOrientation(PhysBody); |
742 | return _orientation; | 730 | return RawOrientation; |
743 | } | 731 | } |
744 | set | 732 | set |
745 | { | 733 | { |
746 | _orientation = value; | 734 | RawOrientation = value; |
747 | if (PhysBody.HasPhysicalBody) | 735 | if (PhysBody.HasPhysicalBody) |
748 | PhysScene.PE.SetTranslation(PhysBody, _position, _orientation); | 736 | PhysScene.PE.SetTranslation(PhysBody, RawPosition, RawOrientation); |
749 | } | 737 | } |
750 | } | 738 | } |
751 | public override int PhysicsActorType { | 739 | public override int PhysicsActorType { |
@@ -889,7 +877,7 @@ public class BSPrim : BSPhysObject | |||
889 | // PhysicsScene.PE.ClearAllForces(BSBody); | 877 | // PhysicsScene.PE.ClearAllForces(BSBody); |
890 | 878 | ||
891 | // For good measure, make sure the transform is set through to the motion state | 879 | // For good measure, make sure the transform is set through to the motion state |
892 | ForcePosition = _position; | 880 | ForcePosition = RawPosition; |
893 | ForceVelocity = RawVelocity; | 881 | ForceVelocity = RawVelocity; |
894 | ForceRotationalVelocity = _rotationalVelocity; | 882 | ForceRotationalVelocity = _rotationalVelocity; |
895 | 883 | ||
@@ -1543,8 +1531,8 @@ public class BSPrim : BSPhysObject | |||
1543 | // DetailLog("{0},BSPrim.UpdateProperties,entry,entprop={1}", LocalID, entprop); // DEBUG DEBUG | 1531 | // DetailLog("{0},BSPrim.UpdateProperties,entry,entprop={1}", LocalID, entprop); // DEBUG DEBUG |
1544 | 1532 | ||
1545 | // Assign directly to the local variables so the normal set actions do not happen | 1533 | // Assign directly to the local variables so the normal set actions do not happen |
1546 | _position = entprop.Position; | 1534 | RawPosition = entprop.Position; |
1547 | _orientation = entprop.Rotation; | 1535 | RawOrientation = entprop.Rotation; |
1548 | // DEBUG DEBUG DEBUG -- smooth velocity changes a bit. The simulator seems to be | 1536 | // DEBUG DEBUG DEBUG -- smooth velocity changes a bit. The simulator seems to be |
1549 | // very sensitive to velocity changes. | 1537 | // very sensitive to velocity changes. |
1550 | if (entprop.Velocity == OMV.Vector3.Zero || !entprop.Velocity.ApproxEquals(RawVelocity, BSParam.UpdateVelocityChangeThreshold)) | 1538 | if (entprop.Velocity == OMV.Vector3.Zero || !entprop.Velocity.ApproxEquals(RawVelocity, BSParam.UpdateVelocityChangeThreshold)) |
@@ -1557,13 +1545,13 @@ public class BSPrim : BSPhysObject | |||
1557 | // The sanity check can change the velocity and/or position. | 1545 | // The sanity check can change the velocity and/or position. |
1558 | if (PositionSanityCheck(true /* inTaintTime */ )) | 1546 | if (PositionSanityCheck(true /* inTaintTime */ )) |
1559 | { | 1547 | { |
1560 | entprop.Position = _position; | 1548 | entprop.Position = RawPosition; |
1561 | entprop.Velocity = RawVelocity; | 1549 | entprop.Velocity = RawVelocity; |
1562 | entprop.RotationalVelocity = _rotationalVelocity; | 1550 | entprop.RotationalVelocity = _rotationalVelocity; |
1563 | entprop.Acceleration = _acceleration; | 1551 | entprop.Acceleration = _acceleration; |
1564 | } | 1552 | } |
1565 | 1553 | ||
1566 | OMV.Vector3 direction = OMV.Vector3.UnitX * _orientation; // DEBUG DEBUG DEBUG | 1554 | OMV.Vector3 direction = OMV.Vector3.UnitX * RawOrientation; // DEBUG DEBUG DEBUG |
1567 | DetailLog("{0},BSPrim.UpdateProperties,call,entProp={1},dir={2}", LocalID, entprop, direction); | 1555 | DetailLog("{0},BSPrim.UpdateProperties,call,entProp={1},dir={2}", LocalID, entprop, direction); |
1568 | 1556 | ||
1569 | // remember the current and last set values | 1557 | // remember the current and last set values |