aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
diff options
context:
space:
mode:
authorRobert Adams2013-01-11 16:36:34 -0800
committerRobert Adams2013-01-11 16:47:53 -0800
commit459fcd81c9d6e7c92738b40f1b4b4fe746699379 (patch)
tree6555a0076aa18c3634ad89ef8c3d097d67edb08b /OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
parentBulletSim: add osGetPhysicsEngineType() LSL function and update (diff)
downloadopensim-SC_OLD-459fcd81c9d6e7c92738b40f1b4b4fe746699379.zip
opensim-SC_OLD-459fcd81c9d6e7c92738b40f1b4b4fe746699379.tar.gz
opensim-SC_OLD-459fcd81c9d6e7c92738b40f1b4b4fe746699379.tar.bz2
opensim-SC_OLD-459fcd81c9d6e7c92738b40f1b4b4fe746699379.tar.xz
BulletSim: move center of gravity of linkset to its geometric center.
Necessitated allowing simulator and physical position of a body to get out of sync since Bullet assumes that <0,0,0> is the center of mass. Update DLLs and SOs for the UpdateChildTransform so positions of individual prim in a linkset can be implemented.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs40
1 files changed, 30 insertions, 10 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 02d06b4..003dc54 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -50,7 +50,10 @@ public sealed class BSPrim : BSPhysObject
50 private bool _grabbed; 50 private bool _grabbed;
51 private bool _isSelected; 51 private bool _isSelected;
52 private bool _isVolumeDetect; 52 private bool _isVolumeDetect;
53
54 // _position is what the simulator thinks the positions of the prim is.
53 private OMV.Vector3 _position; 55 private OMV.Vector3 _position;
56
54 private float _mass; // the mass of this object 57 private float _mass; // the mass of this object
55 private float _density; 58 private float _density;
56 private OMV.Vector3 _force; 59 private OMV.Vector3 _force;
@@ -320,18 +323,37 @@ public sealed class BSPrim : BSPhysObject
320 } 323 }
321 public override OMV.Vector3 ForcePosition { 324 public override OMV.Vector3 ForcePosition {
322 get { 325 get {
323 _position = PhysicsScene.PE.GetPosition(PhysBody); 326 _position = PhysicsScene.PE.GetPosition(PhysBody) - PositionDisplacement;
324 return _position; 327 return _position;
325 } 328 }
326 set { 329 set {
327 _position = value; 330 _position = value;
328 if (PhysBody.HasPhysicalBody) 331 if (PhysBody.HasPhysicalBody)
329 { 332 {
330 PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation); 333 PhysicsScene.PE.SetTranslation(PhysBody, _position + PositionDisplacement, _orientation);
331 ActivateIfPhysical(false); 334 ActivateIfPhysical(false);
332 } 335 }
333 } 336 }
334 } 337 }
338 // Override to have position displacement immediately update the physical position.
339 // A feeble attempt to keep the sim and physical positions in sync
340 // Must be called at taint time.
341 public override OMV.Vector3 PositionDisplacement
342 {
343 get
344 {
345 return base.PositionDisplacement;
346 }
347 set
348 {
349 base.PositionDisplacement = value;
350 PhysicsScene.TaintedObject(PhysicsScene.InTaintTime, "BSPrim.setPosition", delegate()
351 {
352 if (PhysBody.HasPhysicalBody)
353 PhysicsScene.PE.SetTranslation(PhysBody, _position + base.PositionDisplacement, _orientation);
354 });
355 }
356 }
335 357
336 // Check that the current position is sane and, if not, modify the position to make it so. 358 // Check that the current position is sane and, if not, modify the position to make it so.
337 // Check for being below terrain and being out of bounds. 359 // Check for being below terrain and being out of bounds.
@@ -590,6 +612,7 @@ public sealed class BSPrim : BSPhysObject
590 _velocity = value; 612 _velocity = value;
591 if (PhysBody.HasPhysicalBody) 613 if (PhysBody.HasPhysicalBody)
592 { 614 {
615 DetailLog("{0},BSPrim.ForceVelocity,taint,vel={1}", LocalID, _velocity);
593 PhysicsScene.PE.SetLinearVelocity(PhysBody, _velocity); 616 PhysicsScene.PE.SetLinearVelocity(PhysBody, _velocity);
594 ActivateIfPhysical(false); 617 ActivateIfPhysical(false);
595 } 618 }
@@ -654,12 +677,7 @@ public sealed class BSPrim : BSPhysObject
654 677
655 PhysicsScene.TaintedObject("BSPrim.setOrientation", delegate() 678 PhysicsScene.TaintedObject("BSPrim.setOrientation", delegate()
656 { 679 {
657 if (PhysBody.HasPhysicalBody) 680 ForceOrientation = _orientation;
658 {
659 // _position = PhysicsScene.PE.GetObjectPosition(PhysicsScene.World, BSBody);
660 // DetailLog("{0},BSPrim.setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation);
661 PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation);
662 }
663 }); 681 });
664 } 682 }
665 } 683 }
@@ -674,7 +692,8 @@ public sealed class BSPrim : BSPhysObject
674 set 692 set
675 { 693 {
676 _orientation = value; 694 _orientation = value;
677 PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation); 695 if (PhysBody.HasPhysicalBody)
696 PhysicsScene.PE.SetTranslation(PhysBody, _position + PositionDisplacement, _orientation);
678 } 697 }
679 } 698 }
680 public override int PhysicsActorType { 699 public override int PhysicsActorType {
@@ -813,7 +832,7 @@ public sealed class BSPrim : BSPhysObject
813 // PhysicsScene.PE.ClearAllForces(BSBody); 832 // PhysicsScene.PE.ClearAllForces(BSBody);
814 833
815 // For good measure, make sure the transform is set through to the motion state 834 // For good measure, make sure the transform is set through to the motion state
816 PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation); 835 PhysicsScene.PE.SetTranslation(PhysBody, _position + PositionDisplacement, _orientation);
817 836
818 // Center of mass is at the center of the object 837 // Center of mass is at the center of the object
819 // DEBUG DEBUG PhysicsScene.PE.SetCenterOfMassByPosRot(Linkset.LinksetRoot.PhysBody, _position, _orientation); 838 // DEBUG DEBUG PhysicsScene.PE.SetCenterOfMassByPosRot(Linkset.LinksetRoot.PhysBody, _position, _orientation);
@@ -1615,6 +1634,7 @@ public sealed class BSPrim : BSPhysObject
1615 } 1634 }
1616 1635
1617 // Assign directly to the local variables so the normal set actions do not happen 1636 // Assign directly to the local variables so the normal set actions do not happen
1637 entprop.Position -= PositionDisplacement;
1618 _position = entprop.Position; 1638 _position = entprop.Position;
1619 _orientation = entprop.Rotation; 1639 _orientation = entprop.Rotation;
1620 _velocity = entprop.Velocity; 1640 _velocity = entprop.Velocity;