diff options
author | Mitchell Stokes <mogurijin@gmail.com> | 2011-08-11 11:19:37 +0400 |
---|---|---|
committer | Mitchell Stokes <mogurijin@gmail.com> | 2011-08-11 11:19:37 +0400 |
commit | 78f89c3bbf6c7faa3b364f75f7fd52d9f62762e6 (patch) | |
tree | 51b3c2219480edb789490de1e8478665d5a60548 /source/gameengine/Ketsji/KX_KetsjiEngine.cpp | |
parent | ef18ec335ff8496d1a047615073c7258eeffa371 (diff) |
BGE Animations: Animation updates are now handled separately from logic/physics updates. This allows the animations to be updated at the full fps specified by the user. Before, updates were not happening frequently enough. For example, a 30fps animation my only update at 20~30fps, which would cause some noticeable lag. This my not be the best solution since at this point we may be dropping frames (not being in the while(frames) loop), and we're not updating as often as the physics engine might want for bone parented physics objects.
Diffstat (limited to 'source/gameengine/Ketsji/KX_KetsjiEngine.cpp')
-rw-r--r-- | source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 421e642a6df..6fb03d0a573 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -581,7 +581,7 @@ else framestep = (frames*timestep)/m_maxLogicFrame; frames = m_maxLogicFrame; } - + while (frames) { @@ -655,16 +655,6 @@ else scene->LogicUpdateFrame(m_frameTime, true); scene->LogicEndFrame(); - - // Handle animations - double anim_timestep = 1.0/scene->GetAnimationFPS(); - if (m_clockTime - m_previousAnimTime > anim_timestep) - { - m_previousAnimTime = m_clockTime; - m_logger->StartLog(tc_animations, m_kxsystem->GetTimeInSeconds(), true); - SG_SetActiveStage(SG_STAGE_ANIMATION_UPDATE); - scene->UpdateAnimations(m_frameTime); - } // Actuators can affect the scenegraph m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true); @@ -777,7 +767,22 @@ else } } + + // Handle the animations independently of the logic time step + m_logger->StartLog(tc_animations, m_kxsystem->GetTimeInSeconds(), true); + SG_SetActiveStage(SG_STAGE_ANIMATION_UPDATE); + double anim_timestep = 1.0/KX_GetActiveScene()->GetAnimationFPS(); + if (m_clockTime - m_previousAnimTime > anim_timestep) + { + // Sanity/debug print to make sure we're actually going at the fps we want (should be close to anim_timestep) + // printf("Anim fps: %f\n", 1.0/(m_clockTime - m_previousAnimTime)); + m_previousAnimTime = m_clockTime; + for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); ++sceneit) + { + (*sceneit)->UpdateAnimations(m_frameTime); + } + } m_previousClockTime = m_clockTime; // Start logging time spend outside main loop |