f64 frame_delta = 0.0;
i32 frame_count = 0;
- clock_t total_clock_delta = 0;
while (!glfwWindowShouldClose(window))
{
delta = curr_time - last_time;
last_time = curr_time;
- clock_t before_update = clock();
update(state, delta);
- clock_t after_update = clock();
- total_clock_delta += (after_update - before_update);
frame_count += 1;
draw(state);
frame_delta += delta;
if (frame_delta >= 1.0)
{
- total_clock_delta = 0;
frame_delta -= 1.0;
frame_rate = frame_count;
frame_count = 0;
Camera camera;
};
-// @CLEANUP
-internal f64 TEMP_dt = 0;
-
internal void
sim_state_init(SimState* state)
{
f64 frame_delta = 0.0;
i32 frame_count = 0;
- clock_t total_clock_delta = 0;
- clock_t before_update, after_update;
#pragma omp parallel
{
while (!glfwWindowShouldClose(window))
{
+ // NOTE(Brendan): Compute the delta time and update camera variables.
#pragma omp master
{
curr_time = glfwGetTime();
delta = curr_time - last_time;
last_time = curr_time;
- before_update = clock();
-
glfwGetWindowSize(window, &state->camera.window_width, &state->camera.window_height);
persist const f32 camera_move_speed = 6;
if (glfwGetKey(window, GLFW_KEY_RIGHT)) state->camera.offset.x += camera_move_speed;
if (glfwGetKey(window, GLFW_KEY_Q)) state->camera.scale *= 1.02f;
if (glfwGetKey(window, GLFW_KEY_A)) state->camera.scale /= 1.02f;
-
- TEMP_dt = delta;
}
+ // NOTE(Brendan): Calculate how each body will move.
#pragma omp for
for (int i = 0; i < global_settings.body_count; i++)
- body_accumulate_move(&state->bodies[i], &state->qt_bodies, TEMP_dt);
+ body_accumulate_move(&state->bodies[i], &state->qt_bodies, delta);
+ // NOTE(Brendan): Move each of the bodies.
#pragma omp for
for (int i = 0; i < global_settings.body_count; i++)
- body_apply_move(&state->bodies[i], TEMP_dt);
+ body_apply_move(&state->bodies[i], delta);
+ // NOTE(Brendan): Draw the scene.
#pragma omp master
{
- after_update = clock();
- total_clock_delta += (after_update - before_update);
-
frame_count += 1;
draw(state);
frame_delta += delta;
if (frame_delta >= 1.0)
{
- total_clock_delta = 0;
frame_delta -= 1.0;
frame_rate = frame_count;
frame_count = 0;
glfwPollEvents();
}
+ // NOTE(Brendan): One of the threads recompute the Quad Tree.
#pragma omp single
{
state->qt_bodies.init(AABB { -2000, -2000, 4000, 4000 });
f64 frame_delta = 0.0;
i32 frame_count = 0;
- clock_t total_clock_delta = 0;
while (!glfwWindowShouldClose(window))
{
delta = curr_time - last_time;
last_time = curr_time;
- clock_t before_update = clock();
update(state, delta);
- clock_t after_update = clock();
- total_clock_delta += (after_update - before_update);
frame_count += 1;
draw(state);
frame_delta += delta;
if (frame_delta >= 1.0)
{
- total_clock_delta = 0;
frame_delta -= 1.0;
frame_rate = frame_count;
frame_count = 0;