Array<Body> bodies;
};
+internal void
+sim_state_init(SimState* state)
+{
+ // NOTE(Brendan): Need to initialize the array since it does not get constructed because I refuse to use the 'new' keyword. alloc<T> uses malloc under the hood and cannot initialize the result.
+ state->bodies.init();
+ state->bodies.ensure_capacity(1024);
+
+ foreach (i, 0, 1024)
+ {
+ Body tmp_body;
+ tmp_body.pos = V2f{ randf(0, 800), randf(0, 800) };
+ tmp_body.vel = V2f{ randf(-50.0f, 50.0f), randf(-50.0f, 50.0f) };
+ tmp_body.mass = randf(2.0f, 10.0f);
+ tmp_body.color_idx = rand() % 4;
+ state->bodies.push(tmp_body);
+ }
+}
+
#define CIRCLE_POINT_COUNT 36 // NOTE(Brendan): Treat a circle as a many-sided polygon.
glUniform4fv(planet_colors_loc, 4, planet_colors);
auto state = alloc<SimState>();
- // NOTE(Brendan): Need to initialize the array since it does not get constructed because I refuse to use the 'new' keyword. alloc<T> uses malloc under the hood and cannot initialize the result.
- state->bodies.init();
- state->bodies.ensure_capacity(1024);
-
- foreach (i, 0, 1024)
- {
- Body tmp_body;
- tmp_body.pos = V2f{ randf(0, 800), randf(0, 800) };
- tmp_body.vel = V2f{ randf(-50.0f, 50.0f), randf(-50.0f, 50.0f) };
- tmp_body.mass = randf(2.0f, 10.0f);
- tmp_body.color_idx = rand() % 4;
- state->bodies.push(tmp_body);
- }
+ sim_state_init(state);
{
glBindVertexArray(circle_mesh);