aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs68
1 files changed, 40 insertions, 28 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 8b00a33..54bf063 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -59,7 +59,6 @@ public sealed class BSPrim : BSPhysObject
59 private OMV.Vector3 _force; 59 private OMV.Vector3 _force;
60 private OMV.Vector3 _velocity; 60 private OMV.Vector3 _velocity;
61 private OMV.Vector3 _torque; 61 private OMV.Vector3 _torque;
62 private float _collisionScore;
63 private OMV.Vector3 _acceleration; 62 private OMV.Vector3 _acceleration;
64 private OMV.Quaternion _orientation; 63 private OMV.Quaternion _orientation;
65 private int _physicsActorType; 64 private int _physicsActorType;
@@ -74,7 +73,7 @@ public sealed class BSPrim : BSPhysObject
74 private bool _kinematic; 73 private bool _kinematic;
75 private float _buoyancy; 74 private float _buoyancy;
76 75
77 private BSDynamics _vehicle; 76 public BSDynamics VehicleController { get; private set; }
78 77
79 private BSVMotor _targetMotor; 78 private BSVMotor _targetMotor;
80 private OMV.Vector3 _PIDTarget; 79 private OMV.Vector3 _PIDTarget;
@@ -108,7 +107,7 @@ public sealed class BSPrim : BSPhysObject
108 _friction = PhysicsScene.Params.defaultFriction; 107 _friction = PhysicsScene.Params.defaultFriction;
109 _restitution = PhysicsScene.Params.defaultRestitution; 108 _restitution = PhysicsScene.Params.defaultRestitution;
110 109
111 _vehicle = new BSDynamics(PhysicsScene, this); // add vehicleness 110 VehicleController = new BSDynamics(PhysicsScene, this); // add vehicleness
112 111
113 _mass = CalculateMass(); 112 _mass = CalculateMass();
114 113
@@ -147,9 +146,9 @@ public sealed class BSPrim : BSPhysObject
147 { 146 {
148 DetailLog("{0},BSPrim.Destroy,taint,", LocalID); 147 DetailLog("{0},BSPrim.Destroy,taint,", LocalID);
149 // If there are physical body and shape, release my use of same. 148 // If there are physical body and shape, release my use of same.
150 PhysicsScene.Shapes.DereferenceBody(PhysBody, true, null); 149 PhysicsScene.Shapes.DereferenceBody(PhysBody, null);
151 PhysBody.Clear(); 150 PhysBody.Clear();
152 PhysicsScene.Shapes.DereferenceShape(PhysShape, true, null); 151 PhysicsScene.Shapes.DereferenceShape(PhysShape, null);
153 PhysShape.Clear(); 152 PhysShape.Clear();
154 }); 153 });
155 } 154 }
@@ -182,11 +181,19 @@ public sealed class BSPrim : BSPhysObject
182 181
183 public override bool ForceBodyShapeRebuild(bool inTaintTime) 182 public override bool ForceBodyShapeRebuild(bool inTaintTime)
184 { 183 {
185 PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ForceBodyShapeRebuild", delegate() 184 if (inTaintTime)
186 { 185 {
187 _mass = CalculateMass(); // changing the shape changes the mass 186 _mass = CalculateMass(); // changing the shape changes the mass
188 CreateGeomAndObject(true); 187 CreateGeomAndObject(true);
189 }); 188 }
189 else
190 {
191 PhysicsScene.TaintedObject("BSPrim.ForceBodyShapeRebuild", delegate()
192 {
193 _mass = CalculateMass(); // changing the shape changes the mass
194 CreateGeomAndObject(true);
195 });
196 }
190 return true; 197 return true;
191 } 198 }
192 public override bool Grabbed { 199 public override bool Grabbed {
@@ -345,6 +352,10 @@ public sealed class BSPrim : BSPhysObject
345 { 352 {
346 bool ret = false; 353 bool ret = false;
347 354
355 // We don't care where non-physical items are placed
356 if (!IsPhysicallyActive)
357 return ret;
358
348 if (!PhysicsScene.TerrainManager.IsWithinKnownTerrain(RawPosition)) 359 if (!PhysicsScene.TerrainManager.IsWithinKnownTerrain(RawPosition))
349 { 360 {
350 // The physical object is out of the known/simulated area. 361 // The physical object is out of the known/simulated area.
@@ -513,7 +524,7 @@ public sealed class BSPrim : BSPhysObject
513 524
514 public override int VehicleType { 525 public override int VehicleType {
515 get { 526 get {
516 return (int)_vehicle.Type; // if we are a vehicle, return that type 527 return (int)VehicleController.Type; // if we are a vehicle, return that type
517 } 528 }
518 set { 529 set {
519 Vehicle type = (Vehicle)value; 530 Vehicle type = (Vehicle)value;
@@ -522,14 +533,20 @@ public sealed class BSPrim : BSPhysObject
522 { 533 {
523 // Done at taint time so we're sure the physics engine is not using the variables 534 // Done at taint time so we're sure the physics engine is not using the variables
524 // Vehicle code changes the parameters for this vehicle type. 535 // Vehicle code changes the parameters for this vehicle type.
525 _vehicle.ProcessTypeChange(type); 536 VehicleController.ProcessTypeChange(type);
526 ActivateIfPhysical(false); 537 ActivateIfPhysical(false);
527 538
528 // If an active vehicle, register the vehicle code to be called before each step 539 // If an active vehicle, register the vehicle code to be called before each step
529 if (_vehicle.Type == Vehicle.TYPE_NONE) 540 if (VehicleController.Type == Vehicle.TYPE_NONE)
541 {
530 UnRegisterPreStepAction("BSPrim.Vehicle", LocalID); 542 UnRegisterPreStepAction("BSPrim.Vehicle", LocalID);
543 PhysicsScene.AfterStep -= VehicleController.PostStep;
544 }
531 else 545 else
532 RegisterPreStepAction("BSPrim.Vehicle", LocalID, _vehicle.Step); 546 {
547 RegisterPreStepAction("BSPrim.Vehicle", LocalID, VehicleController.Step);
548 PhysicsScene.AfterStep += VehicleController.PostStep;
549 }
533 }); 550 });
534 } 551 }
535 } 552 }
@@ -537,7 +554,7 @@ public sealed class BSPrim : BSPhysObject
537 { 554 {
538 PhysicsScene.TaintedObject("BSPrim.VehicleFloatParam", delegate() 555 PhysicsScene.TaintedObject("BSPrim.VehicleFloatParam", delegate()
539 { 556 {
540 _vehicle.ProcessFloatVehicleParam((Vehicle)param, value); 557 VehicleController.ProcessFloatVehicleParam((Vehicle)param, value);
541 ActivateIfPhysical(false); 558 ActivateIfPhysical(false);
542 }); 559 });
543 } 560 }
@@ -545,7 +562,7 @@ public sealed class BSPrim : BSPhysObject
545 { 562 {
546 PhysicsScene.TaintedObject("BSPrim.VehicleVectorParam", delegate() 563 PhysicsScene.TaintedObject("BSPrim.VehicleVectorParam", delegate()
547 { 564 {
548 _vehicle.ProcessVectorVehicleParam((Vehicle)param, value); 565 VehicleController.ProcessVectorVehicleParam((Vehicle)param, value);
549 ActivateIfPhysical(false); 566 ActivateIfPhysical(false);
550 }); 567 });
551 } 568 }
@@ -553,7 +570,7 @@ public sealed class BSPrim : BSPhysObject
553 { 570 {
554 PhysicsScene.TaintedObject("BSPrim.VehicleRotationParam", delegate() 571 PhysicsScene.TaintedObject("BSPrim.VehicleRotationParam", delegate()
555 { 572 {
556 _vehicle.ProcessRotationVehicleParam((Vehicle)param, rotation); 573 VehicleController.ProcessRotationVehicleParam((Vehicle)param, rotation);
557 ActivateIfPhysical(false); 574 ActivateIfPhysical(false);
558 }); 575 });
559 } 576 }
@@ -561,7 +578,7 @@ public sealed class BSPrim : BSPhysObject
561 { 578 {
562 PhysicsScene.TaintedObject("BSPrim.VehicleFlags", delegate() 579 PhysicsScene.TaintedObject("BSPrim.VehicleFlags", delegate()
563 { 580 {
564 _vehicle.ProcessVehicleFlags(param, remove); 581 VehicleController.ProcessVehicleFlags(param, remove);
565 }); 582 });
566 } 583 }
567 584
@@ -638,11 +655,6 @@ public sealed class BSPrim : BSPhysObject
638 // DetailLog("{0},BSPrim.SetTorque,call,torque={1}", LocalID, _torque); 655 // DetailLog("{0},BSPrim.SetTorque,call,torque={1}", LocalID, _torque);
639 } 656 }
640 } 657 }
641 public override float CollisionScore {
642 get { return _collisionScore; }
643 set { _collisionScore = value;
644 }
645 }
646 public override OMV.Vector3 Acceleration { 658 public override OMV.Vector3 Acceleration {
647 get { return _acceleration; } 659 get { return _acceleration; }
648 set { _acceleration = value; } 660 set { _acceleration = value; }
@@ -747,7 +759,7 @@ public sealed class BSPrim : BSPhysObject
747 // isSolid: other objects bounce off of this object 759 // isSolid: other objects bounce off of this object
748 // isVolumeDetect: other objects pass through but can generate collisions 760 // isVolumeDetect: other objects pass through but can generate collisions
749 // collisionEvents: whether this object returns collision events 761 // collisionEvents: whether this object returns collision events
750 private void UpdatePhysicalParameters() 762 public void UpdatePhysicalParameters()
751 { 763 {
752 // DetailLog("{0},BSPrim.UpdatePhysicalParameters,entry,body={1},shape={2}", LocalID, BSBody, BSShape); 764 // DetailLog("{0},BSPrim.UpdatePhysicalParameters,entry,body={1},shape={2}", LocalID, BSBody, BSShape);
753 765
@@ -759,7 +771,7 @@ public sealed class BSPrim : BSPhysObject
759 MakeDynamic(IsStatic); 771 MakeDynamic(IsStatic);
760 772
761 // Update vehicle specific parameters (after MakeDynamic() so can change physical parameters) 773 // Update vehicle specific parameters (after MakeDynamic() so can change physical parameters)
762 _vehicle.Refresh(); 774 VehicleController.Refresh();
763 775
764 // Arrange for collision events if the simulator wants them 776 // Arrange for collision events if the simulator wants them
765 EnableCollisions(SubscribedEvents()); 777 EnableCollisions(SubscribedEvents());
@@ -1593,15 +1605,15 @@ public sealed class BSPrim : BSPhysObject
1593 public void CreateGeomAndObject(bool forceRebuild) 1605 public void CreateGeomAndObject(bool forceRebuild)
1594 { 1606 {
1595 // Create the correct physical representation for this type of object. 1607 // Create the correct physical representation for this type of object.
1596 // Updates PhysBody and PhysShape with the new information. 1608 // Updates base.PhysBody and base.PhysShape with the new information.
1597 // Ignore 'forceRebuild'. This routine makes the right choices and changes of necessary. 1609 // Ignore 'forceRebuild'. This routine makes the right choices and changes of necessary.
1598 PhysicsScene.Shapes.GetBodyAndShape(false, PhysicsScene.World, this, null, delegate(BulletBody dBody) 1610 PhysicsScene.Shapes.GetBodyAndShape(false /*forceRebuild */, PhysicsScene.World, this, null, delegate(BulletBody dBody)
1599 { 1611 {
1600 // Called if the current prim body is about to be destroyed. 1612 // Called if the current prim body is about to be destroyed.
1601 // Remove all the physical dependencies on the old body. 1613 // Remove all the physical dependencies on the old body.
1602 // (Maybe someday make the changing of BSShape an event to be subscribed to by BSLinkset, ...) 1614 // (Maybe someday make the changing of BSShape an event to be subscribed to by BSLinkset, ...)
1603 Linkset.RemoveBodyDependencies(this); 1615 Linkset.RemoveBodyDependencies(this);
1604 _vehicle.RemoveBodyDependencies(this); 1616 VehicleController.RemoveBodyDependencies(this);
1605 }); 1617 });
1606 1618
1607 // Make sure the properties are set on the new object 1619 // Make sure the properties are set on the new object
@@ -1618,9 +1630,9 @@ public sealed class BSPrim : BSPhysObject
1618 { 1630 {
1619 // A temporary kludge to suppress the rotational effects introduced on vehicles by Bullet 1631 // A temporary kludge to suppress the rotational effects introduced on vehicles by Bullet
1620 // TODO: handle physics introduced by Bullet with computed vehicle physics. 1632 // TODO: handle physics introduced by Bullet with computed vehicle physics.
1621 if (_vehicle.IsActive) 1633 if (VehicleController.IsActive)
1622 { 1634 {
1623 // entprop.RotationalVelocity = OMV.Vector3.Zero; 1635 entprop.RotationalVelocity = OMV.Vector3.Zero;
1624 } 1636 }
1625 1637
1626 // DetailLog("{0},BSPrim.UpdateProperties,entry,entprop={1}", LocalID, entprop); // DEBUG DEBUG 1638 // DetailLog("{0},BSPrim.UpdateProperties,entry,entprop={1}", LocalID, entprop); // DEBUG DEBUG
@@ -1643,7 +1655,7 @@ public sealed class BSPrim : BSPhysObject
1643 // DetailLog("{0},BSPrim.UpdateProperties,afterAssign,entprop={1}", LocalID, entprop); // DEBUG DEBUG 1655 // DetailLog("{0},BSPrim.UpdateProperties,afterAssign,entprop={1}", LocalID, entprop); // DEBUG DEBUG
1644 1656
1645 // The sanity check can change the velocity and/or position. 1657 // The sanity check can change the velocity and/or position.
1646 if (IsPhysical && PositionSanityCheck(true /* inTaintTime */ )) 1658 if (PositionSanityCheck(true /* inTaintTime */ ))
1647 { 1659 {
1648 entprop.Position = _position; 1660 entprop.Position = _position;
1649 entprop.Velocity = _velocity; 1661 entprop.Velocity = _velocity;