Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Bolsee <benoit.bolsee@online.be>2011-09-07 19:34:04 +0400
committerBenoit Bolsee <benoit.bolsee@online.be>2011-09-07 19:34:04 +0400
commitdbd6658d737b1592a633ddf6397be14e50e434d9 (patch)
tree57081721d70622a3c3141909b258f9bce8a5b1e3 /source/gameengine/Ketsji/KX_KetsjiEngine.cpp
parentb5bd86e5907c3fa98546dabeda9703dfb15862f4 (diff)
parent884fc84793be1c5fdd6643ad267331381f8e1c6b (diff)
svn merge -r 37306:39975 https://svn.blender.org/svnroot/bf-blender/trunk/blender
Diffstat (limited to 'source/gameengine/Ketsji/KX_KetsjiEngine.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_KetsjiEngine.cpp86
1 files changed, 51 insertions, 35 deletions
diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
index eef543e629c..db919b7bc5a 100644
--- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
+++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
@@ -68,7 +68,10 @@
#include "KX_PyConstraintBinding.h"
#include "PHY_IPhysicsEnvironment.h"
-#include "AUD_C-API.h"
+#ifdef WITH_AUDASPACE
+# include "AUD_C-API.h"
+# include "AUD_I3DDevice.h"
+#endif
#include "NG_NetworkScene.h"
#include "NG_NetworkDeviceInterface.h"
@@ -91,10 +94,10 @@
const char KX_KetsjiEngine::m_profileLabels[tc_numCategories][15] = {
"Physics:", // tc_physics
- "Logic", // tc_logic
+ "Logic:", // tc_logic
+ "Animations:", // tc_animations
"Network:", // tc_network
"Scenegraph:", // tc_scenegraph
- "Sound:", // tc_sound
"Rasterizer:", // tc_rasterizer
"Services:", // tc_services
"Overhead:", // tc_overhead
@@ -108,13 +111,14 @@ double KX_KetsjiEngine::m_anim_framerate = 25.0;
double KX_KetsjiEngine::m_suspendedtime = 0.0;
double KX_KetsjiEngine::m_suspendeddelta = 0.0;
double KX_KetsjiEngine::m_average_framerate = 0.0;
+bool KX_KetsjiEngine::m_restrict_anim_fps = false;
/**
* Constructor of the Ketsji Engine
*/
KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system)
- : m_canvas(NULL),
+ : m_canvas(NULL),
m_rasterizer(NULL),
m_kxsystem(system),
m_rendertools(NULL),
@@ -137,6 +141,7 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system)
m_frameTime(0.f),
m_clockTime(0.f),
m_previousClockTime(0.f),
+ m_previousAnimTime(0.f),
m_exitcode(KX_EXIT_REQUEST_NO_REQUEST),
@@ -578,7 +583,7 @@ else
framestep = (frames*timestep)/m_maxLogicFrame;
frames = m_maxLogicFrame;
}
-
+
while (frames)
{
@@ -657,7 +662,14 @@ else
m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
SG_SetActiveStage(SG_STAGE_ACTUATOR_UPDATE);
scene->UpdateParents(m_frameTime);
-
+
+ if (!GetRestrictAnimationFPS())
+ {
+ m_logger->StartLog(tc_animations, m_kxsystem->GetTimeInSeconds(), true);
+ SG_SetActiveStage(SG_STAGE_ANIMATION_UPDATE);
+ scene->UpdateAnimations(m_frameTime);
+ }
+
m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true);
SG_SetActiveStage(SG_STAGE_PHYSICS2);
scene->GetPhysicsEnvironment()->beginFrame();
@@ -681,8 +693,6 @@ else
else
if(scene->getSuspendedTime()==0.0)
scene->setSuspendedTime(m_clockTime);
-
- DoSound(scene);
m_logger->StartLog(tc_services, m_kxsystem->GetTimeInSeconds(), true);
}
@@ -758,14 +768,30 @@ else
if(scene->getSuspendedTime()==0.0)
scene->setSuspendedTime(m_clockTime);
- DoSound(scene);
-
m_logger->StartLog(tc_services, m_kxsystem->GetTimeInSeconds(), true);
}
}
+
+ // Handle the animations independently of the logic time step
+ if (GetRestrictAnimationFPS())
+ {
+ m_logger->StartLog(tc_animations, m_kxsystem->GetTimeInSeconds(), true);
+ SG_SetActiveStage(SG_STAGE_ANIMATION_UPDATE);
- m_previousClockTime = m_clockTime;
+ 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
m_logger->StartLog(tc_outside, m_kxsystem->GetTimeInSeconds(), true);
@@ -974,29 +1000,6 @@ const STR_String& KX_KetsjiEngine::GetExitString()
}
-
-void KX_KetsjiEngine::DoSound(KX_Scene* scene)
-{
- m_logger->StartLog(tc_sound, m_kxsystem->GetTimeInSeconds(), true);
-
- KX_Camera* cam = scene->GetActiveCamera();
- if (!cam)
- return;
-
- float f[4];
-
- cam->NodeGetWorldPosition().getValue(f);
- AUD_setListenerLocation(f);
-
- cam->GetLinearVelocity().getValue(f);
- AUD_setListenerVelocity(f);
-
- cam->NodeGetWorldOrientation().getRotation().getValue(f);
- AUD_setListenerOrientation(f);
-}
-
-
-
void KX_KetsjiEngine::SetBackGround(KX_WorldInfo* wi)
{
if (wi->hasWorld())
@@ -1220,7 +1223,7 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam)
projmat.setValue(m_overrideCamProjMat.getPointer());
cam->SetProjectionMatrix(projmat);
}
- } else if (cam->hasValidProjectionMatrix() && !cam->GetViewport() )
+ } else if (cam->hasValidProjectionMatrix())
{
m_rasterizer->SetProjectionMatrix(cam->GetProjectionMatrix());
} else
@@ -1334,6 +1337,9 @@ To run once per scene
*/
void KX_KetsjiEngine::PostRenderScene(KX_Scene* scene)
{
+ // We need to first make sure our viewport is correct (enabling multiple viewports can mess this up)
+ m_canvas->SetViewPort(0, 0, m_canvas->GetWidth(), m_canvas->GetHeight());
+
m_rendertools->MotionBlur(m_rasterizer);
scene->Render2DFilters(m_canvas);
#ifdef WITH_PYTHON
@@ -1799,6 +1805,16 @@ void KX_KetsjiEngine::SetMaxPhysicsFrame(int frame)
m_maxPhysicsFrame = frame;
}
+bool KX_KetsjiEngine::GetRestrictAnimationFPS()
+{
+ return m_restrict_anim_fps;
+}
+
+void KX_KetsjiEngine::SetRestrictAnimationFPS(bool bRestrictAnimFPS)
+{
+ m_restrict_anim_fps = bRestrictAnimFPS;
+}
+
double KX_KetsjiEngine::GetAnimFrameRate()
{
return m_anim_framerate;