BGE: Fix T45110, T44174, armature animations update and mirror render.
Reveiwers:Moguri, Matpi, youle
This commit is contained in:
parent
5e241e3028
commit
d979ac4cc9
Notes:
blender-bot
2023-02-14 09:19:05 +01:00
Referenced by issue #45110, Animated Armature stops when not reflected by ImageMirror Referenced by issue #44174, Splitscreen problem with animations
|
@ -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(); )
|
||||
{
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue