aboutsummaryrefslogtreecommitdiff
path: root/src/phys/world.odin
diff options
context:
space:
mode:
authoriamcheeseman <[hidden email]>2026-01-13 00:01:44 -0500
committeriamcheeseman <[hidden email]>2026-01-13 00:01:44 -0500
commitafb58a61abd0e8114a090ab0ad664d59c10dd4b1 (patch)
tree241788a343d7a206f1bb9394519d6f562eda8c21 /src/phys/world.odin
parent58de3f9ddc72c5dbf433e45babb43a06c819cb4f (diff)
formatter
Diffstat (limited to 'src/phys/world.odin')
-rw-r--r--src/phys/world.odin23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/phys/world.odin b/src/phys/world.odin
index 51a85a5..c263459 100644
--- a/src/phys/world.odin
+++ b/src/phys/world.odin
@@ -26,19 +26,19 @@ destroy_world :: proc() {
delete(world.bodies)
}
-@(private="file")
+@(private = "file")
hash_bin :: proc(x: i32, y: i32) -> u32 {
return transmute(u32)((x * 73856093) ~ (y * 19349663))
}
-@(private="file")
+@(private = "file")
world_to_bin :: proc(point: Vec2) -> (i32, i32) {
- return \
- i32(math.floor(point.x / BIN_SIZE)),
- i32(math.floor(point.y / BIN_SIZE))
+ return i32(
+ math.floor(point.x / BIN_SIZE),
+ ), i32(math.floor(point.y / BIN_SIZE))
}
-@(private="file")
+@(private = "file")
get_surrounding_bins :: proc(
pos: Vec2,
allocator := context.temp_allocator,
@@ -49,8 +49,8 @@ get_surrounding_bins :: proc(
idx := 0
- for offset_x in -1..=1 {
- for offset_y in -1..=1 {
+ for offset_x in -1 ..= 1 {
+ for offset_y in -1 ..= 1 {
bin_idx := hash_bin(center_x + i32(offset_x), center_y + i32(offset_y))
bin := &world.bins[bin_idx % BIN_COUNT]
neighbors[idx] = bin
@@ -61,13 +61,13 @@ get_surrounding_bins :: proc(
return neighbors
}
-@(private="file")
+@(private = "file")
find_bin :: proc(b: Body) -> ^[dynamic]Body_Handle {
bin_x, bin_y := world_to_bin(b.pos + b.rect.start)
return &world.bins[hash_bin(bin_x, bin_y) % BIN_COUNT]
}
-@(private="file")
+@(private = "file")
add_to_bins :: proc(b: ^Body) {
bin := find_bin(b^)
idx := i32(len(bin))
@@ -75,7 +75,7 @@ add_to_bins :: proc(b: ^Body) {
b.bin_idx = idx
}
-@(private="file")
+@(private = "file")
remove_from_bins :: proc(b: Body) {
bin := find_bin(b)
@@ -214,4 +214,3 @@ set_body_position :: proc(h: Body_Handle, new_pos: Vec2) {
b.pos = new_pos
}
}
-