#include "ui.h"
#include "log.h"
-// TODO(Brendan): Move this
-#define PI 3.141592653589793238462643383
-
-#define WINDOW_WIDTH 1600
-#define WINDOW_HEIGHT 900
-#define WINDOW_TITLE "N-Body Simulation"
-
// :ArbitraryConstant
#define PARTICLE_COUNT 2500
if (!glfwInit()) panic_and_die("Failed to initalize GLFW.");
glfwSetErrorCallback(glfw_error_handler);
- window = glfwCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_TITLE, NULL, NULL);
+ window = glfwCreateWindow(1600, 900, "N-Body Simulation", NULL, NULL);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
glfwMakeContextCurrent(window);
glfwTerminate();
}
-#define CIRCLE_POINT_COUNT 36 // NOTE(Brendan): Treat a circle as a many-sided polygon.
+#define CIRCLE_POINT_COUNT 12 // NOTE(Brendan): Treat a circle as a many-sided polygon.
// NOTE(Brendan): Returns the VAO where the mesh data was bound.
internal GLuint
foreach (i, 0, CIRCLE_POINT_COUNT)
{
f32 t = (f32) i / (f32) CIRCLE_POINT_COUNT;
- circle_points[i].x = cos(t * 2 * PI);
- circle_points[i].y = sin(t * 2 * PI);
+ circle_points[i].x = cos(t * 2 * 3.1415926535897);
+ circle_points[i].y = sin(t * 2 * 3.1415926535897);
}
GLuint vertex_buffer;
ThreadData thread_data[NUM_THREADS - 1];
};
+internal f64 TEMP_dt = 0;
+
internal void
update_bodies_partial(SimState *state, i32 index)
{
persist const f64 step = 0.01;
- foreach (i, low, high) body_accumulate_move(&state->bodies[i], &state->qt_bodies, step);
- foreach (i, low, high) body_apply_move(&state->bodies[i], step);
+ foreach (i, low, high) body_accumulate_move(&state->bodies[i], &state->qt_bodies, TEMP_dt);
+ foreach (i, low, high) body_apply_move(&state->bodies[i], TEMP_dt);
}
internal void*
if (glfwGetKey(window, GLFW_KEY_Q)) state->camera.scale *= 1.02f;
if (glfwGetKey(window, GLFW_KEY_A)) state->camera.scale /= 1.02f;
+ TEMP_dt = dt;
pthread_barrier_wait(&state->thread_sync_barrier);
update_bodies_partial(state, 0);