diff options
author | Robert Adams | 2012-09-14 11:12:23 -0700 |
---|---|---|
committer | Robert Adams | 2012-09-15 15:32:05 -0700 |
commit | f35bd6eb7d5b0eb1a6d385f5f1d0147acfc3c8ef (patch) | |
tree | bdf3a433ab70e767f0d5d46a0b2933862228bbeb | |
parent | BulletSim: remove timeStep parameter from calls for vehicle parameter setting... (diff) | |
download | opensim-SC_OLD-f35bd6eb7d5b0eb1a6d385f5f1d0147acfc3c8ef.zip opensim-SC_OLD-f35bd6eb7d5b0eb1a6d385f5f1d0147acfc3c8ef.tar.gz opensim-SC_OLD-f35bd6eb7d5b0eb1a6d385f5f1d0147acfc3c8ef.tar.bz2 opensim-SC_OLD-f35bd6eb7d5b0eb1a6d385f5f1d0147acfc3c8ef.tar.xz |
BulletSim: another attempt at computing physics FPS correctly.
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index c38867f..52997dd 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | |||
@@ -110,11 +110,6 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
110 | private long m_simulationStep = 0; | 110 | private long m_simulationStep = 0; |
111 | public long SimulationStep { get { return m_simulationStep; } } | 111 | public long SimulationStep { get { return m_simulationStep; } } |
112 | 112 | ||
113 | // The length of the last timestep we were asked to simulate. | ||
114 | // This is used by the vehicle code. Since the vehicle code is called | ||
115 | // once per simulation step, its constants need to be scaled by this. | ||
116 | public float LastSimulatedTimestep { get; private set; } | ||
117 | |||
118 | // A value of the time now so all the collision and update routines do not have to get their own | 113 | // A value of the time now so all the collision and update routines do not have to get their own |
119 | // Set to 'now' just before all the prims and actors are called for collisions and updates | 114 | // Set to 'now' just before all the prims and actors are called for collisions and updates |
120 | public int SimulationNowTime { get; private set; } | 115 | public int SimulationNowTime { get; private set; } |
@@ -469,12 +464,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
469 | int collidersCount = 0; | 464 | int collidersCount = 0; |
470 | IntPtr collidersPtr; | 465 | IntPtr collidersPtr; |
471 | 466 | ||
472 | LastSimulatedTimestep = timeStep; | ||
473 | |||
474 | // prevent simulation until we've been initialized | 467 | // prevent simulation until we've been initialized |
475 | if (!m_initialized) return 10.0f; | 468 | if (!m_initialized) return 5.0f; |
476 | |||
477 | int simulateStartTime = Util.EnvironmentTickCount(); | ||
478 | 469 | ||
479 | // update the prim states while we know the physics engine is not busy | 470 | // update the prim states while we know the physics engine is not busy |
480 | int numTaints = _taintedObjects.Count; | 471 | int numTaints = _taintedObjects.Count; |
@@ -514,7 +505,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
514 | // This is a kludge to get avatar movement updates. | 505 | // This is a kludge to get avatar movement updates. |
515 | // ODE sends collisions for avatars even if there are have been no collisions. This updates | 506 | // ODE sends collisions for avatars even if there are have been no collisions. This updates |
516 | // avatar animations and stuff. | 507 | // avatar animations and stuff. |
517 | // If you fix avatar animation updates, remove this overhead and let collisions happen. | 508 | // If you fix avatar animation updates, remove this overhead and let normal collision processing happen. |
518 | m_objectsWithCollisions = new HashSet<BSPhysObject>(m_avatarsWithCollisions); | 509 | m_objectsWithCollisions = new HashSet<BSPhysObject>(m_avatarsWithCollisions); |
519 | 510 | ||
520 | // If there were collisions, process them by sending the event to the prim. | 511 | // If there were collisions, process them by sending the event to the prim. |
@@ -561,18 +552,10 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
561 | } | 552 | } |
562 | } | 553 | } |
563 | 554 | ||
564 | // this is a waste since the outside routine also calcuates the physics simulation | 555 | // The physics engine returns the number of milliseconds it simulated this call. |
565 | // period. TODO: There should be a way of computing physics frames from simulator computation. | 556 | // These are summed and normalized to one second and divided by 1000 to give the reported physics FPS. |
566 | // long simulateTotalTime = Util.EnvironmentTickCountSubtract(simulateStartTime); | 557 | // Since Bullet normally does 5 or 6 substeps, this will normally sum to about 60 FPS. |
567 | // return (timeStep * (float)simulateTotalTime); | 558 | return numSubSteps * m_fixedTimeStep; |
568 | |||
569 | // TODO: FIX THIS: fps calculation possibly wrong. | ||
570 | // This calculation says 1/timeStep is the ideal frame rate. Any time added to | ||
571 | // that by the physics simulation gives a slower frame rate. | ||
572 | long totalSimulationTime = Util.EnvironmentTickCountSubtract(simulateStartTime); | ||
573 | if (totalSimulationTime >= timeStep) | ||
574 | return 0; | ||
575 | return 1f / (timeStep + totalSimulationTime); | ||
576 | } | 559 | } |
577 | 560 | ||
578 | // Something has collided | 561 | // Something has collided |