aboutsummaryrefslogtreecommitdiff
path: root/src/phys/world.odin
diff options
context:
space:
mode:
Diffstat (limited to 'src/phys/world.odin')
-rw-r--r--src/phys/world.odin35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/phys/world.odin b/src/phys/world.odin
index 0f1451c..70309b5 100644
--- a/src/phys/world.odin
+++ b/src/phys/world.odin
@@ -40,8 +40,7 @@ _world_to_bin :: proc(point: Vec2) -> (i32, i32) {
i32(math.floor(point.y / BIN_SIZE))
}
-@(private = "file")
-_get_surrounding_bins :: proc(
+get_surrounding_bins :: proc(
pos: Vec2,
allocator := context.temp_allocator,
) -> []^[dynamic]Body_Handle {
@@ -169,7 +168,7 @@ get_colliding_bodies :: proc(
rect := b.rect
rect.start += b.pos
- bin_list := _get_surrounding_bins(rect.start)
+ bin_list := get_surrounding_bins(rect.start)
for bin in bin_list {
for c_h in bin {
@@ -212,7 +211,7 @@ update_body :: proc(h: Body_Handle) {
res_rect := b.rect
res_rect.start += b.pos + b.vel * dt * p
- bin_list := _get_surrounding_bins(res_rect.start)
+ bin_list := get_surrounding_bins(res_rect.start)
for bin in bin_list {
for c_h in bin {
@@ -234,20 +233,20 @@ update_body :: proc(h: Body_Handle) {
if b.vel.y > 0 {
res_pos.y = c_rect.start.y - b.rect.size.y - b.rect.start.y
b.collisions += {.Down}
- } else {
- res_pos.y = c_rect.start.y + c_rect.size.y - b.rect.start.y
- b.collisions += {.Up}
- }
- b.collisions += {.Vertical}
- } else if aabb_vert(rect, c.rect) {
- if b.vel.x > 0 {
- res_pos.x = c_rect.start.x - b.rect.size.x - b.rect.start.x
- b.collisions += {.Left}
- } else {
- res_pos.x = c_rect.start.x + c_rect.size.x - b.rect.start.x
- b.collisions += {.Right}
- }
- b.collisions += {.Horizontal}
+ } else {
+ res_pos.y = c_rect.start.y + c_rect.size.y - b.rect.start.y
+ b.collisions += {.Up}
+ }
+ b.collisions += {.Vertical}
+ } else if aabb_vert(rect, c.rect) {
+ if b.vel.x > 0 {
+ res_pos.x = c_rect.start.x - b.rect.size.x - b.rect.start.x
+ b.collisions += {.Left}
+ } else {
+ res_pos.x = c_rect.start.x + c_rect.size.x - b.rect.start.x
+ b.collisions += {.Right}
+ }
+ b.collisions += {.Horizontal}
}
}
}