diff options
author | Kester Maddock <Christopher.Maddock.1@uni.massey.ac.nz> | 2004-12-06 14:15:50 +0300 |
---|---|---|
committer | Kester Maddock <Christopher.Maddock.1@uni.massey.ac.nz> | 2004-12-06 14:15:50 +0300 |
commit | 5590c179f5f23d338d8a4c81aa922128fbca92de (patch) | |
tree | 68f2d592be1e03b94d59e68fc433f1008eff84b9 /source/gameengine/Physics/Sumo | |
parent | e54f51c462592eb297dfa38314f4a9802d57bf95 (diff) |
Fix the case when the physics system starves the logic & renderer of CPU time. If this happens, we reduce physics precision to maintain some framerate.
Diffstat (limited to 'source/gameengine/Physics/Sumo')
-rw-r--r-- | source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp index e9f25e25e6c..fdd8079b241 100644 --- a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp +++ b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp @@ -191,6 +191,7 @@ bool SM_Scene::proceed(MT_Scalar curtime, MT_Scalar ticrate) // equal to subS (might be a little smaller). MT_Scalar subStep; int num_samples; + int frames = m_frames; // Compute the number of steps to do this update. if (ticrate > 0.0) @@ -201,9 +202,16 @@ bool SM_Scene::proceed(MT_Scalar curtime, MT_Scalar ticrate) if (num_samples > 4) { - std::cout << "Dropping physics frames! frames:" << num_samples << std::endl; - num_samples /= 4; - subStep *= 4.0; + std::cout << "Dropping physics frames! frames:" << num_samples << " substep: " << subStep << std::endl; + MT_Scalar tr = ticrate; + do + { + frames = frames / 2; + tr = tr / 2.0; + num_samples = (unsigned int)(curtime*tr + 1.0) - frames; + subStep *= 2.0; + } while (num_samples > 8); + std::cout << " frames:" << num_samples << " substep: " << subStep << std::endl; } } else @@ -226,7 +234,7 @@ bool SM_Scene::proceed(MT_Scalar curtime, MT_Scalar ticrate) { MT_Scalar time; if (ticrate > 0.) - time = MT_Scalar(m_frames + step + 1) * subStep; + time = MT_Scalar(frames + step + 1) * subStep; else time = MT_Scalar(m_frames)/65536.0 + MT_Scalar(step + 1)*subStep; |