{
if (0 < d && d < 1)
{
- return (1 / d) - 1;
+ return (1.0f / d) - 1.0f;
}
if (1 <= d && d < br.distance_range + 1)
internal const
BodyRelation body_relations[(i32) BodyType::Count][(i32) BodyType::Count] = {
// Red Green Blue White
- /* Red */ { { 10.0f, 10.0f }, { 0.0f, 0.0f }, { 10.0f, -2.0f }, { 0.0f, 0.0f } },
- /* Green */ { { 0.0f, 0.0f }, { 0.0f, 0.0f }, { 0.0f, 0.0f }, { 0.0f, 0.0f } },
- /* Blue */ { { 4.0f, 10.0f }, { 0.0f, 0.0f }, { 3.0f, -2.0f }, { 0.0f, 0.0f } },
- /* White */ { { 0.0f, 0.0f }, { 0.0f, 0.0f }, { 0.0f, 0.0f }, { 0.0f, 0.0f } },
+ /* Red */ { { 10.0f, 10.0f }, { 0.0f, 0.0f }, { 10.0f, -2.0f }, { 0.0f, 0.0f } },
+ /* Green */ { { 0.0f, 0.0f }, { 0.0f, 0.0f }, { 0.0f, 0.0f }, { 0.0f, 0.0f } },
+ /* Blue */ { { 4.0f, 10.0f }, { 0.0f, 0.0f }, { 3.0f, -2.0f }, { 0.0f, 0.0f } },
+ /* White */ { { 0.0f, 0.0f }, { 0.0f, 0.0f }, { 0.0f, 0.0f }, { 0.0f, 0.0f } },
};
internal bool
V2f force = { 0.0f, 0.0f };
other_bodies.clear();
- qt_bodies.query(AABB { body->pos.x - 200, body->pos.y - 200, 400, 400 }, &other_bodies);
+ qt_bodies.query(AABB { body->pos.x - 300, body->pos.y - 300, 600, 600 }, &other_bodies);
For (other_bodies)
{
internal void
update(SimState* state, f64 dt)
{
- left_over_dt += dt;
const f64 step = 0.01;
- while (left_over_dt >= step)
- {
- state->qt_bodies.init(AABB { -(f32) window_width, -(f32)window_height, (f32) window_width * 2, (f32) window_height * 2 });
- state->qt_body_allocator.reset();
- For (state->bodies) state->qt_bodies.insert(&it, &state->qt_body_allocator);
+ state->qt_bodies.init(AABB { -(f32) window_width, -(f32)window_height, (f32) window_width * 2, (f32) window_height * 2 });
+ state->qt_body_allocator.reset();
+ For (state->bodies) state->qt_bodies.insert(&it, &state->qt_body_allocator);
+
+ For (state->bodies) body_accumulate_move(&it, state->qt_bodies, step);
+ For (state->bodies) {
+ body_apply_move(&it);
+ /*
+ if (it.pos.x < -window_width) it.pos.x = -window_width;
+ else if (it.pos.x >= window_width * 2) it.pos.x = window_width * 2;
- For (state->bodies) body_accumulate_move(&it, state->qt_bodies, step);
- For (state->bodies) {
- body_apply_move(&it);
- /*
- if (it.pos.x < -window_width) it.pos.x = -window_width;
- else if (it.pos.x >= window_width * 2) it.pos.x = window_width * 2;
-
- if (it.pos.y < -window_height) it.pos.y = -window_height;
- else if (it.pos.y >= window_height * 2) it.pos.y = window_height * 2;
+ if (it.pos.y < -window_height) it.pos.y = -window_height;
+ else if (it.pos.y >= window_height * 2) it.pos.y = window_height * 2;
*/
-
- if (it.pos.x < 0) it.pos.x = 0;
- else if (it.pos.x >= window_width) it.pos.x = window_width;
-
- if (it.pos.y < 0) it.pos.y = 0;
- else if (it.pos.y >= window_height) it.pos.y = window_height;
- }
- left_over_dt -= step;
+ /*
+ if (it.pos.x < 0) { it.pos.x = 0; it.vel.x = 0; }
+ else if (it.pos.x >= window_width) { it.pos.x = window_width; it.vel.x = 0; }
+
+ if (it.pos.y < 0) { it.pos.y = 0; it.vel.y = 0; }
+ else if (it.pos.y >= window_height) { it.pos.y = window_height; it.vel.y = 0; }
+*/
}
}