aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSScene.cs')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs95
1 files changed, 14 insertions, 81 deletions
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 {