aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs26
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs95
2 files changed, 20 insertions, 101 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index d137b2a..26b8df5 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -465,15 +465,18 @@ public sealed class BSPrim : BSPhysObject
465 set { 465 set {
466 Vehicle type = (Vehicle)value; 466 Vehicle type = (Vehicle)value;
467 467
468 // Tell the scene about the vehicle so it will get processing each frame.
469 PhysicsScene.VehicleInSceneTypeChanged(this, type);
470
471 PhysicsScene.TaintedObject("setVehicleType", delegate() 468 PhysicsScene.TaintedObject("setVehicleType", delegate()
472 { 469 {
473 // Done at taint time so we're sure the physics engine is not using the variables 470 // Done at taint time so we're sure the physics engine is not using the variables
474 // Vehicle code changes the parameters for this vehicle type. 471 // Vehicle code changes the parameters for this vehicle type.
475 _vehicle.ProcessTypeChange(type); 472 _vehicle.ProcessTypeChange(type);
476 ActivateIfPhysical(false); 473 ActivateIfPhysical(false);
474
475 // If an active vehicle, register the vehicle code to be called before each step
476 if (_vehicle.Type == Vehicle.TYPE_NONE)
477 UnRegisterPreStepAction("BSPrim.Vehicle", LocalID);
478 else
479 RegisterPreStepAction("BSPrim.Vehicle", LocalID, _vehicle.Step);
477 }); 480 });
478 } 481 }
479 } 482 }
@@ -509,23 +512,6 @@ public sealed class BSPrim : BSPhysObject
509 }); 512 });
510 } 513 }
511 514
512 // Called each simulation step to advance vehicle characteristics.
513 // Called from Scene when doing simulation step so we're in taint processing time.
514 public override void StepVehicle(float timeStep)
515 {
516 if (IsPhysical && _vehicle.IsActive)
517 {
518 _vehicle.Step(timeStep);
519 /* // TEST TEST DEBUG DEBUG -- trying to reduce the extra action of Bullet simulation step
520 PhysicsScene.PostTaintObject("BSPrim.StepVehicles", LocalID, delegate()
521 {
522 // This resets the interpolation values and recomputes the tensor variables
523 BulletSimAPI.SetCenterOfMassByPosRot2(BSBody.ptr, ForcePosition, ForceOrientation);
524 });
525 */
526 }
527 }
528
529 // Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more 515 // Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more
530 public override void SetVolumeDetect(int param) { 516 public override void SetVolumeDetect(int param) {
531 bool newValue = (param != 0); 517 bool newValue = (param != 0);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index eb47178..3a129a4 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -69,10 +69,6 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
69 // every tick so OpenSim will update its animation. 69 // every tick so OpenSim will update its animation.
70 private HashSet<BSPhysObject> m_avatars = new HashSet<BSPhysObject>(); 70 private HashSet<BSPhysObject> m_avatars = new HashSet<BSPhysObject>();
71 71
72 // List of all the objects that have vehicle properties and should be called
73 // to update each physics step.
74 private List<BSPhysObject> m_vehicles = new List<BSPhysObject>();
75
76 // let my minuions use my logger 72 // let my minuions use my logger
77 public ILog Logger { get { return m_log; } } 73 public ILog Logger { get { return m_log; } }
78 74
@@ -480,21 +476,25 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
480 476
481 // update the prim states while we know the physics engine is not busy 477 // update the prim states while we know the physics engine is not busy
482 int numTaints = _taintOperations.Count; 478 int numTaints = _taintOperations.Count;
479
480 InTaintTime = true; // Only used for debugging so locking is not necessary.
481
483 ProcessTaints(); 482 ProcessTaints();
484 483
485 // Some of the prims operate with special vehicle properties 484 // Some of the physical objects requre individual, pre-step calls
486 DoPreStepActions(timeStep); 485 DoPreStepActions(timeStep);
487 486
488 // the prestep actions might have added taints 487 // the prestep actions might have added taints
489 ProcessTaints(); 488 ProcessTaints();
490 489
490 InTaintTime = false; // Only used for debugging so locking is not necessary.
491
491 // step the physical world one interval 492 // step the physical world one interval
492 m_simulationStep++; 493 m_simulationStep++;
493 int numSubSteps = 0; 494 int numSubSteps = 0;
494 495
495 try 496 try
496 { 497 {
497 if (VehiclePhysicalLoggingEnabled) DumpVehicles(); // DEBUG
498 if (PhysicsLogging.Enabled) beforeTime = Util.EnvironmentTickCount(); 498 if (PhysicsLogging.Enabled) beforeTime = Util.EnvironmentTickCount();
499 499
500 numSubSteps = BulletSimAPI.PhysicsStep2(World.ptr, timeStep, m_maxSubSteps, m_fixedTimeStep, 500 numSubSteps = BulletSimAPI.PhysicsStep2(World.ptr, timeStep, m_maxSubSteps, m_fixedTimeStep,
@@ -504,7 +504,6 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
504 DetailLog("{0},Simulate,call, frame={1}, nTaints={2}, simTime={3}, substeps={4}, updates={5}, colliders={6}, objWColl={7}", 504 DetailLog("{0},Simulate,call, frame={1}, nTaints={2}, simTime={3}, substeps={4}, updates={5}, colliders={6}, objWColl={7}",
505 DetailLogZero, m_simulationStep, numTaints, simTime, numSubSteps, 505 DetailLogZero, m_simulationStep, numTaints, simTime, numSubSteps,
506 updatedEntityCount, collidersCount, ObjectsWithCollisions.Count); 506 updatedEntityCount, collidersCount, ObjectsWithCollisions.Count);
507 if (VehiclePhysicalLoggingEnabled) DumpVehicles(); // DEBUG
508 } 507 }
509 catch (Exception e) 508 catch (Exception e)
510 { 509 {
@@ -701,15 +700,21 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
701 TaintedObject(ident, callback); 700 TaintedObject(ident, callback);
702 } 701 }
703 702
703 private void DoPreStepActions(float timeStep)
704 {
705 PreStepAction actions = BeforeStep;
706 if (actions != null)
707 actions(timeStep);
708
709 }
710
704 // When someone tries to change a property on a BSPrim or BSCharacter, the object queues 711 // When someone tries to change a property on a BSPrim or BSCharacter, the object queues
705 // a callback into itself to do the actual property change. That callback is called 712 // a callback into itself to do the actual property change. That callback is called
706 // here just before the physics engine is called to step the simulation. 713 // here just before the physics engine is called to step the simulation.
707 public void ProcessTaints() 714 public void ProcessTaints()
708 { 715 {
709 InTaintTime = true; // Only used for debugging so locking is not necessary.
710 ProcessRegularTaints(); 716 ProcessRegularTaints();
711 ProcessPostTaintTaints(); 717 ProcessPostTaintTaints();
712 InTaintTime = false;
713 } 718 }
714 719
715 private void ProcessRegularTaints() 720 private void ProcessRegularTaints()
@@ -871,68 +876,6 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
871 876
872 #endregion // Taints 877 #endregion // Taints
873 878
874 #region Vehicles
875
876 public void VehicleInSceneTypeChanged(BSPrim vehic, Vehicle newType)
877 {
878 RemoveVehiclePrim(vehic);
879 if (newType != Vehicle.TYPE_NONE)
880 {
881 // make it so the scene will call us each tick to do vehicle things
882 AddVehiclePrim(vehic);
883 }
884 }
885
886 // Make so the scene will call this prim for vehicle actions each tick.
887 // Safe to call if prim is already in the vehicle list.
888 public void AddVehiclePrim(BSPrim vehicle)
889 {
890 lock (m_vehicles)
891 {
892 if (!m_vehicles.Contains(vehicle))
893 {
894 m_vehicles.Add(vehicle);
895 }
896 }
897 }
898
899 // Remove a prim from our list of vehicles.
900 // Safe to call if the prim is not in the vehicle list.
901 public void RemoveVehiclePrim(BSPrim vehicle)
902 {
903 lock (m_vehicles)
904 {
905 if (m_vehicles.Contains(vehicle))
906 {
907 m_vehicles.Remove(vehicle);
908 }
909 }
910 }
911
912 private void DoPreStepActions(float timeStep)
913 {
914 InTaintTime = true; // Only used for debugging so locking is not necessary.
915 ProcessVehicles(timeStep);
916
917 PreStepAction actions = BeforeStep;
918 if (actions != null)
919 actions(timeStep);
920
921 InTaintTime = false;
922
923 }
924
925 // Some prims have extra vehicle actions
926 // Called at taint time!
927 private void ProcessVehicles(float timeStep)
928 {
929 foreach (BSPhysObject pobj in m_vehicles)
930 {
931 pobj.StepVehicle(timeStep);
932 }
933 }
934 #endregion Vehicles
935
936 #region INI and command line parameter processing 879 #region INI and command line parameter processing
937 880
938 #region IPhysicsParameters 881 #region IPhysicsParameters
@@ -1033,16 +976,6 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
1033 976
1034 #endregion Runtime settable parameters 977 #endregion Runtime settable parameters
1035 978
1036 // Debugging routine for dumping detailed physical information for vehicle prims
1037 private void DumpVehicles()
1038 {
1039 foreach (BSPrim prim in m_vehicles)
1040 {
1041 BulletSimAPI.DumpRigidBody2(World.ptr, prim.PhysBody.ptr);
1042 BulletSimAPI.DumpCollisionShape2(World.ptr, prim.PhysShape.ptr);
1043 }
1044 }
1045
1046 // Invoke the detailed logger and output something if it's enabled. 979 // Invoke the detailed logger and output something if it's enabled.
1047 public void DetailLog(string msg, params Object[] args) 980 public void DetailLog(string msg, params Object[] args)
1048 { 981 {