diff options
| author | Xander Swan <[hidden email]> | 2026-01-01 18:32:20 -0500 |
|---|---|---|
| committer | Xander Swan <[hidden email]> | 2026-01-01 18:32:20 -0500 |
| commit | 65a2ceda55198dab3bab75c06c0d50adeb0a1101 (patch) | |
| tree | 2a08400520f60fcd86b381bc840bb5c739ff998a /src/phys | |
| parent | dc373b507ca68ada2cbf4c8e0d7949d6bc46ed9b (diff) | |
lots of changes + player dash
Diffstat (limited to 'src/phys')
| -rw-r--r-- | src/phys/world.odin | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/phys/world.odin b/src/phys/world.odin index 8470872..51a85a5 100644 --- a/src/phys/world.odin +++ b/src/phys/world.odin @@ -68,11 +68,11 @@ find_bin :: proc(b: Body) -> ^[dynamic]Body_Handle { } @(private="file") -add_to_bins :: proc(b: Body) { - bin := find_bin(b) +add_to_bins :: proc(b: ^Body) { + bin := find_bin(b^) idx := i32(len(bin)) append(bin, b.handle) - world.bodies[b.handle].bin_idx = idx + b.bin_idx = idx } @(private="file") @@ -84,8 +84,10 @@ remove_from_bins :: proc(b: Body) { last := pop(bin) if last != b.handle { + // log.debug(last, b.handle) + last_body := get_body(last) bin[b.bin_idx] = last - world.bodies[last].bin_idx = b.bin_idx + last_body.bin_idx = b.bin_idx } } @@ -113,7 +115,7 @@ add_body :: proc(b: Body) -> (Body_Handle, ^Body) { body := &world.bodies[world.handles[handle]] body.handle = handle - add_to_bins(body^) + add_to_bins(body) return handle, body } @@ -125,11 +127,11 @@ remove_body :: proc(h: Body_Handle) { last := pop(&world.bodies) if last.handle != h { - world.bodies[h] = last + world.bodies[world.handles[h]] = last world.handles[last.handle] = world.handles[h] } - append(&world.unused_handles, b.handle) + append(&world.unused_handles, h) } update_body :: proc(h: Body_Handle) { @@ -207,7 +209,7 @@ set_body_position :: proc(h: Body_Handle, new_pos: Vec2) { if prev_bin != res_bin { remove_from_bins(b^) b.pos = new_pos - add_to_bins(b^) + add_to_bins(b) } else { b.pos = new_pos } |
