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.cs46
1 files changed, 30 insertions, 16 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index 805e670..f72bd74 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -96,6 +96,9 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
96 public long SimulationStep { get { return m_simulationStep; } } 96 public long SimulationStep { get { return m_simulationStep; } }
97 private int m_taintsToProcessPerStep; 97 private int m_taintsToProcessPerStep;
98 98
99 public delegate void PreStepAction(float timeStep);
100 public event PreStepAction BeforeStep;
101
99 // A value of the time now so all the collision and update routines do not have to get their own 102 // A value of the time now so all the collision and update routines do not have to get their own
100 // Set to 'now' just before all the prims and actors are called for collisions and updates 103 // Set to 'now' just before all the prims and actors are called for collisions and updates
101 public int SimulationNowTime { get; private set; } 104 public int SimulationNowTime { get; private set; }
@@ -127,7 +130,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
127 public const uint GROUNDPLANE_ID = 1; 130 public const uint GROUNDPLANE_ID = 1;
128 public const uint CHILDTERRAIN_ID = 2; // Terrain allocated based on our mega-prim childre start here 131 public const uint CHILDTERRAIN_ID = 2; // Terrain allocated based on our mega-prim childre start here
129 132
130 private float m_waterLevel; 133 public float SimpleWaterLevel { get; set; }
131 public BSTerrainManager TerrainManager { get; private set; } 134 public BSTerrainManager TerrainManager { get; private set; }
132 135
133 public ConfigurationParameters Params 136 public ConfigurationParameters Params
@@ -182,6 +185,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
182 private string m_physicsLoggingDir; 185 private string m_physicsLoggingDir;
183 private string m_physicsLoggingPrefix; 186 private string m_physicsLoggingPrefix;
184 private int m_physicsLoggingFileMinutes; 187 private int m_physicsLoggingFileMinutes;
188 private bool m_physicsLoggingDoFlush;
185 // 'true' of the vehicle code is to log lots of details 189 // 'true' of the vehicle code is to log lots of details
186 public bool VehicleLoggingEnabled { get; private set; } 190 public bool VehicleLoggingEnabled { get; private set; }
187 191
@@ -290,6 +294,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
290 m_physicsLoggingDir = pConfig.GetString("PhysicsLoggingDir", "."); 294 m_physicsLoggingDir = pConfig.GetString("PhysicsLoggingDir", ".");
291 m_physicsLoggingPrefix = pConfig.GetString("PhysicsLoggingPrefix", "physics-%REGIONNAME%-"); 295 m_physicsLoggingPrefix = pConfig.GetString("PhysicsLoggingPrefix", "physics-%REGIONNAME%-");
292 m_physicsLoggingFileMinutes = pConfig.GetInt("PhysicsLoggingFileMinutes", 5); 296 m_physicsLoggingFileMinutes = pConfig.GetInt("PhysicsLoggingFileMinutes", 5);
297 m_physicsLoggingDoFlush = pConfig.GetBoolean("PhysicsLoggingDoFlush", false);
293 // Very detailed logging for vehicle debugging 298 // Very detailed logging for vehicle debugging
294 VehicleLoggingEnabled = pConfig.GetBoolean("VehicleLoggingEnabled", false); 299 VehicleLoggingEnabled = pConfig.GetBoolean("VehicleLoggingEnabled", false);
295 300
@@ -485,8 +490,10 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
485 ProcessTaints(); 490 ProcessTaints();
486 491
487 // Some of the prims operate with special vehicle properties 492 // Some of the prims operate with special vehicle properties
488 ProcessVehicles(timeStep); 493 DoPreStepActions(timeStep);
489 ProcessTaints(); // the vehicles might have added taints 494
495 // the prestep actions might have added taints
496 ProcessTaints();
490 497
491 // step the physical world one interval 498 // step the physical world one interval
492 m_simulationStep++; 499 m_simulationStep++;
@@ -515,9 +522,9 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
515 collidersCount = 0; 522 collidersCount = 0;
516 } 523 }
517 524
518 // Don't have to use the pointers passed back since we know it is the same pinned memory we passed in 525 // Don't have to use the pointers passed back since we know it is the same pinned memory we passed in.
519 526
520 // Get a value for 'now' so all the collision and update routines don't have to get their own 527 // Get a value for 'now' so all the collision and update routines don't have to get their own.
521 SimulationNowTime = Util.EnvironmentTickCount(); 528 SimulationNowTime = Util.EnvironmentTickCount();
522 529
523 // If there were collisions, process them by sending the event to the prim. 530 // If there were collisions, process them by sending the event to the prim.
@@ -563,6 +570,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
563 ObjectsWithCollisions.Remove(po); 570 ObjectsWithCollisions.Remove(po);
564 ObjectsWithNoMoreCollisions.Clear(); 571 ObjectsWithNoMoreCollisions.Clear();
565 } 572 }
573 // Done with collisions.
566 574
567 // If any of the objects had updated properties, tell the object it has been changed by the physics engine 575 // If any of the objects had updated properties, tell the object it has been changed by the physics engine
568 if (updatedEntityCount > 0) 576 if (updatedEntityCount > 0)
@@ -586,9 +594,8 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
586 594
587 // The physics engine returns the number of milliseconds it simulated this call. 595 // The physics engine returns the number of milliseconds it simulated this call.
588 // These are summed and normalized to one second and divided by 1000 to give the reported physics FPS. 596 // These are summed and normalized to one second and divided by 1000 to give the reported physics FPS.
589 // We multiply by 55 to give a recognizable running rate (55 or less). 597 // Multiply by 55 to give a nominal frame rate of 55.
590 return numSubSteps * m_fixedTimeStep * 1000 * 55; 598 return (float)numSubSteps * m_fixedTimeStep * 1000f * 55f;
591 // return timeStep * 1000 * 55;
592 } 599 }
593 600
594 // Something has collided 601 // Something has collided
@@ -634,12 +641,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
634 641
635 public override void SetWaterLevel(float baseheight) 642 public override void SetWaterLevel(float baseheight)
636 { 643 {
637 m_waterLevel = baseheight; 644 SimpleWaterLevel = baseheight;
638 }
639 // Someday....
640 public float GetWaterLevelAtXYZ(Vector3 loc)
641 {
642 return m_waterLevel;
643 } 645 }
644 646
645 public override void DeleteTerrain() 647 public override void DeleteTerrain()
@@ -910,6 +912,16 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
910 } 912 }
911 } 913 }
912 914
915 private void DoPreStepActions(float timeStep)
916 {
917 ProcessVehicles(timeStep);
918
919 PreStepAction actions = BeforeStep;
920 if (actions != null)
921 actions(timeStep);
922
923 }
924
913 // Some prims have extra vehicle actions 925 // Some prims have extra vehicle actions
914 // Called at taint time! 926 // Called at taint time!
915 private void ProcessVehicles(float timeStep) 927 private void ProcessVehicles(float timeStep)
@@ -974,6 +986,8 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
974 // Should handle fetching the right type from the ini file and converting it. 986 // Should handle fetching the right type from the ini file and converting it.
975 // -- a delegate for getting the value as a float 987 // -- a delegate for getting the value as a float
976 // -- a delegate for setting the value from a float 988 // -- a delegate for setting the value from a float
989 // -- an optional delegate to update the value in the world. Most often used to
990 // push the new value to an in-world object.
977 // 991 //
978 // The single letter parameters for the delegates are: 992 // The single letter parameters for the delegates are:
979 // s = BSScene 993 // s = BSScene
@@ -1172,7 +1186,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
1172 (s) => { return s.m_params[0].avatarFriction; }, 1186 (s) => { return s.m_params[0].avatarFriction; },
1173 (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].avatarFriction, p, l, v); } ), 1187 (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].avatarFriction, p, l, v); } ),
1174 new ParameterDefn("AvatarStandingFriction", "Avatar friction when standing. Changed on avatar recreation.", 1188 new ParameterDefn("AvatarStandingFriction", "Avatar friction when standing. Changed on avatar recreation.",
1175 0.99f, 1189 10.0f,
1176 (s,cf,p,v) => { s.m_params[0].avatarStandingFriction = cf.GetFloat(p, v); }, 1190 (s,cf,p,v) => { s.m_params[0].avatarStandingFriction = cf.GetFloat(p, v); },
1177 (s) => { return s.m_params[0].avatarStandingFriction; }, 1191 (s) => { return s.m_params[0].avatarStandingFriction; },
1178 (s,p,l,v) => { s.m_params[0].avatarStandingFriction = v; } ), 1192 (s,p,l,v) => { s.m_params[0].avatarStandingFriction = v; } ),
@@ -1493,7 +1507,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
1493 { 1507 {
1494 PhysicsLogging.Write(msg, args); 1508 PhysicsLogging.Write(msg, args);
1495 // Add the Flush() if debugging crashes. Gets all the messages written out. 1509 // Add the Flush() if debugging crashes. Gets all the messages written out.
1496 // PhysicsLogging.Flush(); 1510 if (m_physicsLoggingDoFlush) PhysicsLogging.Flush();
1497 } 1511 }
1498 // Used to fill in the LocalID when there isn't one. It's the correct number of characters. 1512 // Used to fill in the LocalID when there isn't one. It's the correct number of characters.
1499 public const string DetailLogZero = "0000000000"; 1513 public const string DetailLogZero = "0000000000";