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:
authorPorteries Tristan <republicthunderbolt9@gmail.com>2015-06-22 17:44:16 +0300
committerPorteries Tristan <republicthunderbolt9@gmail.com>2015-06-22 19:16:31 +0300
commitd979ac4cc9967c5dce27461926396abe5de54b3d (patch)
tree8fb5c431335916bf865d36f597c9803a7353e3b6 /source/gameengine
parent5e241e3028b0c68ae745c35ba5b5f566036f2608 (diff)
BGE: Fix T45110, T44174, armature animations update and mirror render.
Reveiwers:Moguri, Matpi, youle
Diffstat (limited to 'source/gameengine')
-rw-r--r--source/gameengine/Ketsji/BL_ActionManager.cpp7
-rw-r--r--source/gameengine/Ketsji/BL_ActionManager.h3
-rw-r--r--source/gameengine/Ketsji/KX_Dome.cpp3
-rw-r--r--source/gameengine/Ketsji/KX_KetsjiEngine.cpp54
-rw-r--r--source/gameengine/Ketsji/KX_KetsjiEngine.h3
-rw-r--r--source/gameengine/VideoTexture/ImageRender.cpp3
6 files changed, 45 insertions, 28 deletions
diff --git a/source/gameengine/Ketsji/BL_ActionManager.cpp b/source/gameengine/Ketsji/BL_ActionManager.cpp
index 07adce73b4a..c3d0f9e9ad0 100644
--- a/source/gameengine/Ketsji/BL_ActionManager.cpp
+++ b/source/gameengine/Ketsji/BL_ActionManager.cpp
@@ -28,7 +28,8 @@
#include "BL_ActionManager.h"
BL_ActionManager::BL_ActionManager(class KX_GameObject *obj):
- m_obj(obj)
+ m_obj(obj),
+ m_prevUpdate(-1.0f)
{
}
@@ -131,6 +132,10 @@ bool BL_ActionManager::IsActionDone(short layer)
void BL_ActionManager::Update(float curtime)
{
+ if (m_prevUpdate == curtime)
+ return;
+ m_prevUpdate = curtime;
+
BL_ActionMap::iterator it;
for (it = m_layers.begin(); it != m_layers.end(); )
{
diff --git a/source/gameengine/Ketsji/BL_ActionManager.h b/source/gameengine/Ketsji/BL_ActionManager.h
index 148097f995e..45bcd104826 100644
--- a/source/gameengine/Ketsji/BL_ActionManager.h
+++ b/source/gameengine/Ketsji/BL_ActionManager.h
@@ -51,6 +51,9 @@ private:
class KX_GameObject* m_obj;
BL_ActionMap m_layers;
+ // The last update time to avoid double animation update.
+ float m_prevUpdate;
+
/**
* Check if an action exists
*/
diff --git a/source/gameengine/Ketsji/KX_Dome.cpp b/source/gameengine/Ketsji/KX_Dome.cpp
index f58fee88d48..07bed647b29 100644
--- a/source/gameengine/Ketsji/KX_Dome.cpp
+++ b/source/gameengine/Ketsji/KX_Dome.cpp
@@ -2044,6 +2044,9 @@ void KX_Dome::RenderDomeFrame(KX_Scene* scene, KX_Camera* cam, int i)
cam->NodeUpdateGS(0.f);
scene->CalculateVisibleMeshes(m_rasterizer,cam);
+
+ m_engine->UpdateAnimations(scene);
+
scene->RenderBuckets(camtrans, m_rasterizer);
}
diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
index 40af9b4ca39..be0cd8433f7 100644
--- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
+++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
@@ -690,13 +690,6 @@ bool KX_KetsjiEngine::NextFrame()
// update levels of detail
scene->UpdateObjectLods();
- 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();
@@ -741,26 +734,6 @@ bool KX_KetsjiEngine::NextFrame()
frames--;
}
- // Handle the animations independently of the logic time step
- if (GetRestrictAnimationFPS())
- {
- double clocktime = m_kxsystem->GetTimeInSeconds();
- m_logger->StartLog(tc_animations, clocktime, true);
- SG_SetActiveStage(SG_STAGE_ANIMATION_UPDATE);
-
- double anim_timestep = 1.0/KX_GetActiveScene()->GetAnimationFPS();
- if (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 = clocktime;
- for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); ++sceneit)
- {
- (*sceneit)->UpdateAnimations(clocktime);
- }
- }
- }
-
// Start logging time spend outside main loop
m_logger->StartLog(tc_outside, m_kxsystem->GetTimeInSeconds(), true);
@@ -1049,6 +1022,23 @@ void KX_KetsjiEngine::GetSceneViewport(KX_Scene *scene, KX_Camera* cam, RAS_Rect
}
}
+void KX_KetsjiEngine::UpdateAnimations(KX_Scene *scene)
+{
+ // Handle the animations independently of the logic time step
+ if (GetRestrictAnimationFPS()) {
+ double anim_timestep = 1.0 / KX_GetActiveScene()->GetAnimationFPS();
+ if (m_frameTime - m_previousAnimTime > anim_timestep || m_frameTime == m_previousAnimTime) {
+ // 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_frameTime - m_previousAnimTime));
+ m_previousAnimTime = m_frameTime;
+ for (KX_SceneList::iterator sceneit = m_scenes.begin(); sceneit != m_scenes.end(); ++sceneit)
+ (*sceneit)->UpdateAnimations(m_frameTime);
+ }
+ }
+ else
+ scene->UpdateAnimations(m_frameTime);
+}
+
void KX_KetsjiEngine::RenderShadowBuffers(KX_Scene *scene)
{
CListValue *lightlist = scene->GetLightList();
@@ -1082,6 +1072,12 @@ void KX_KetsjiEngine::RenderShadowBuffers(KX_Scene *scene)
/* update scene */
scene->CalculateVisibleMeshes(m_rasterizer, cam, raslight->GetShadowLayer());
+ m_logger->StartLog(tc_animations, m_kxsystem->GetTimeInSeconds(), true);
+ SG_SetActiveStage(SG_STAGE_ANIMATION_UPDATE);
+ UpdateAnimations(scene);
+ m_logger->StartLog(tc_rasterizer, m_kxsystem->GetTimeInSeconds(), true);
+ SG_SetActiveStage(SG_STAGE_RENDER);
+
/* render */
m_rasterizer->ClearDepthBuffer();
m_rasterizer->ClearColorBuffer();
@@ -1220,6 +1216,10 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam)
scene->CalculateVisibleMeshes(m_rasterizer,cam);
+ m_logger->StartLog(tc_animations, m_kxsystem->GetTimeInSeconds(), true);
+ SG_SetActiveStage(SG_STAGE_ANIMATION_UPDATE);
+ UpdateAnimations(scene);
+
m_logger->StartLog(tc_rasterizer, m_kxsystem->GetTimeInSeconds(), true);
SG_SetActiveStage(SG_STAGE_RENDER);
diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h
index 4392769ed02..cd473451111 100644
--- a/source/gameengine/Ketsji/KX_KetsjiEngine.h
+++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h
@@ -272,6 +272,9 @@ public:
void SetCameraOverrideViewMatrix(const MT_CmMatrix4x4& mat);
void SetCameraOverrideClipping(float near, float far);
void SetCameraOverrideLens(float lens);
+
+ // Update animations for object in this scene
+ void UpdateAnimations(KX_Scene *scene);
/**
* Sets display of all frames.
diff --git a/source/gameengine/VideoTexture/ImageRender.cpp b/source/gameengine/VideoTexture/ImageRender.cpp
index 66bb160a624..2f85122cae8 100644
--- a/source/gameengine/VideoTexture/ImageRender.cpp
+++ b/source/gameengine/VideoTexture/ImageRender.cpp
@@ -297,8 +297,11 @@ void ImageRender::Render()
// TODO: implement an explicit function in rasterizer to restore the left buffer.
m_rasterizer->SetEye(RAS_IRasterizer::RAS_STEREO_LEFTEYE);
}
+
m_scene->CalculateVisibleMeshes(m_rasterizer,m_camera);
+ m_engine->UpdateAnimations(m_scene);
+
m_scene->RenderBuckets(camtrans, m_rasterizer);
m_scene->RenderFonts();