[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39295] branches/soc-2011-pepper/source/ gameengine/Ketsji/KX_KetsjiEngine.cpp: BGE Animations: Animation updates are now handled separately from logic/physics updates.
Mitchell Stokes
mogurijin at gmail.com
Thu Aug 11 09:19:38 CEST 2011
Revision: 39295
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39295
Author: moguri
Date: 2011-08-11 07:19:37 +0000 (Thu, 11 Aug 2011)
Log Message:
-----------
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.
Modified Paths:
--------------
branches/soc-2011-pepper/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
Modified: branches/soc-2011-pepper/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
===================================================================
--- branches/soc-2011-pepper/source/gameengine/Ketsji/KX_KetsjiEngine.cpp 2011-08-11 06:40:04 UTC (rev 39294)
+++ branches/soc-2011-pepper/source/gameengine/Ketsji/KX_KetsjiEngine.cpp 2011-08-11 07:19:37 UTC (rev 39295)
@@ -581,7 +581,7 @@
framestep = (frames*timestep)/m_maxLogicFrame;
frames = m_maxLogicFrame;
}
-
+
while (frames)
{
@@ -655,16 +655,6 @@
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 @@
}
}
+
+ // 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
More information about the Bf-blender-cvs
mailing list