Fixed updateAnimables() for all_count < job_count

This commit is contained in:
Tim Baker 2017-09-07 20:53:53 -07:00 committed by Mikulas Florek
parent b139d45afe
commit d8f715e225

View file

@ -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);