fixed thread sync error
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 13 Nov 2020 23:13:24 +0000 (17:13 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 13 Nov 2020 23:13:24 +0000 (17:13 -0600)
src/physics.cpp
src/sim.cpp

index 9c497f162b83ebd553220f677805133a6730c57d..38de5f898885f368e662ee6387c5c0a8c89bd898 100644 (file)
@@ -5,7 +5,7 @@
 // NOTE(Brendan): This represents the piecewise function:
 //
 // F(d) = {
-//     0 < d < 1:                      (1 / d) - 1
+//     0 < d < 1:                      r * (1 - d) / d
 //     1 <= d < distance_range + 1:    (-4 * max_force / (distance_range ^ 2)) * (d - (distance_range / 2) - 1) ^ 2 + max_force,
 //     otherwise:                      0
 // }
index cda4e1aa4c063e2511b94ebf301be9673c9c6769..76462f377eef20cc27b11ea026241c3ba7f9af43 100644 (file)
@@ -146,6 +146,7 @@ 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, TEMP_dt);
+    pthread_barrier_wait(&state->thread_sync_barrier);
     foreach (i, low, high) body_apply_move(&state->bodies[i], TEMP_dt);
 }