From d8f715e225e4fd7e14e37b5bd22d08ca8fc42ee1 Mon Sep 17 00:00:00 2001 From: Tim Baker Date: Thu, 7 Sep 2017 20:53:53 -0700 Subject: [PATCH] Fixed updateAnimables() for all_count < job_count --- src/animation/animation_system.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/animation/animation_system.cpp b/src/animation/animation_system.cpp index 9cfbac032..7f1317190 100644 --- a/src/animation/animation_system.cpp +++ b/src/animation/animation_system.cpp @@ -975,11 +975,13 @@ struct AnimationSceneImpl LUMIX_FINAL : public AnimationScene void updateAnimables(float time_delta) { + if (m_animables.size() == 0) return; + MTJD::Manager& mtjd = m_engine.getMTJDManager(); IAllocator& allocator = m_engine.getAllocator(); MTJD::Job* jobs[16]; - int job_count = Math::minimum((int)mtjd.getCpuThreadsCount(), lengthOf(jobs)); + int job_count = Math::minimum((int)mtjd.getCpuThreadsCount(), lengthOf(jobs), m_animables.size()); ASSERT(job_count > 0); for (int i = 0; i < job_count; ++i) { @@ -989,7 +991,7 @@ struct AnimationSceneImpl LUMIX_FINAL : public AnimationScene PROFILE_BLOCK("Animate Job"); int all_count = m_animables.size(); int batch_count = all_count / job_count; - if (i == job_count - 1) batch_count += all_count - 1 - (job_count * batch_count); + if (i == job_count - 1) batch_count = all_count - ((job_count - 1) * batch_count); for (int j = 0; j < batch_count; ++j) { Animable& animable = m_animables.at(j + i * all_count / job_count);