separate global tick from draw so on tick any node can request a redraw

This commit is contained in:
2018-10-08 12:03:57 +02:00
parent c9c7b9f1c4
commit 5bb8f8845b
8 changed files with 30 additions and 19 deletions

View File

@@ -427,8 +427,11 @@ std::set<UITouch*> ignored_touch;
- (void)glkView:(GLKView *)view drawInRect:(CGRect)rect
{
static auto time = std::chrono::steady_clock::now();
static double elapsed = 0;
auto now = std::chrono::steady_clock::now();
auto dt = std::chrono::duration<float>(now - time);
time = now;
elapsed += dt.count();
std::deque<std::packaged_task<void()>> working_list;
if (!tasklist.empty())
@@ -436,6 +439,8 @@ std::set<UITouch*> ignored_touch;
std::lock_guard<std::mutex> lock(task_mutex);
working_list = std::move(tasklist);
}
App::I.tick(dt.count());
[self async_lock];
if (!(App::I.redraw || App::I.animate || !working_list.empty()))
@@ -451,10 +456,10 @@ std::set<UITouch*> ignored_touch;
working_list.pop_front();
}
App::I.clear();
App::I.update(dt.count());
App::I.update(elapsed);
[self.context presentRenderbuffer:GL_FRAMEBUFFER];
[self async_unlock];
time = now;
elapsed = 0;
}
@end