BulletSim: rework physics FPS calculation to make a more realistic number.
parent
ebbf349c6a
commit
11a4b9ec1d
|
@ -413,7 +413,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
|
||||||
// prevent simulation until we've been initialized
|
// prevent simulation until we've been initialized
|
||||||
if (!m_initialized) return 10.0f;
|
if (!m_initialized) return 10.0f;
|
||||||
|
|
||||||
long simulateStartTime = Util.EnvironmentTickCount();
|
int simulateStartTime = Util.EnvironmentTickCount();
|
||||||
|
|
||||||
// update the prim states while we know the physics engine is not busy
|
// update the prim states while we know the physics engine is not busy
|
||||||
ProcessTaints();
|
ProcessTaints();
|
||||||
|
@ -511,8 +511,13 @@ public class BSScene : PhysicsScene, IPhysicsParameters
|
||||||
// long simulateTotalTime = Util.EnvironmentTickCountSubtract(simulateStartTime);
|
// long simulateTotalTime = Util.EnvironmentTickCountSubtract(simulateStartTime);
|
||||||
// return (timeStep * (float)simulateTotalTime);
|
// return (timeStep * (float)simulateTotalTime);
|
||||||
|
|
||||||
// TODO: FIX THIS: fps calculation wrong. This calculation always returns about 1 in normal operation.
|
// TODO: FIX THIS: fps calculation possibly wrong.
|
||||||
return timeStep / (numSubSteps * m_fixedTimeStep) * 1000f;
|
// This calculation says 1/timeStep is the ideal frame rate. Any time added to
|
||||||
|
// that by the physics simulation gives a slower frame rate.
|
||||||
|
long totalSimulationTime = Util.EnvironmentTickCountSubtract(simulateStartTime);
|
||||||
|
if (totalSimulationTime >= timeStep)
|
||||||
|
return 0;
|
||||||
|
return 1f / (timeStep + totalSimulationTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Something has collided
|
// Something has collided
|
||||||
|
|
Loading…
Reference in New Issue