aboutsummaryrefslogtreecommitdiff
path: root/src/phys/body.odin
diff options
context:
space:
mode:
authoriamcheeseman <[email protected]>2026-03-04 16:12:25 -0500
committeriamcheeseman <[email protected]>2026-03-04 16:12:25 -0500
commit69bfcb3c5fec6957e00264d24990dd2f1263cd50 (patch)
treebab0896b254d9158b31cbe2ae1073562deef230e /src/phys/body.odin
parentccd4b29cc358d89d231e602522ca7b35d178b120 (diff)
better muntik
Diffstat (limited to 'src/phys/body.odin')
-rw-r--r--src/phys/body.odin62
1 files changed, 61 insertions, 1 deletions
diff --git a/src/phys/body.odin b/src/phys/body.odin
index 54177e5..4c9dff1 100644
--- a/src/phys/body.odin
+++ b/src/phys/body.odin
@@ -1,8 +1,9 @@
package phys
+import "core:log"
import "core:math"
import "core:math/linalg"
-import "core:log"
+import hm "core:container/handle_map"
Vec2 :: [2]f32
@@ -45,6 +46,7 @@ Raycast_Collision :: struct {
Body :: struct {
handle: Body_Handle,
+ udata: any,
bin_idx: i32,
rect: Rect,
active: bool,
@@ -157,3 +159,61 @@ raycast_to_aabb :: proc(
return
}
+
+@(require_results)
+get_velocity :: proc(h: Body_Handle) -> Vec2 {
+ return hm.get(&world.bodies, h).vel
+}
+
+set_velocity :: proc(h: Body_Handle, vel: Vec2) {
+ hm.get(&world.bodies, h).vel = vel
+}
+
+@(require_results)
+get_position :: proc(h: Body_Handle) -> Vec2 {
+ return hm.get(&world.bodies, h).pos
+}
+
+set_position :: proc(h: Body_Handle, new_pos: Vec2) {
+ b := hm.get(&world.bodies, h)
+
+ prev_bin := _hash_bin(_world_to_bin(b.pos + b.rect.start))
+ res_bin := _hash_bin(_world_to_bin(new_pos + b.rect.start))
+
+ if prev_bin != res_bin {
+ _remove_from_bins(b^)
+ b.pos = new_pos
+ _add_to_bins(b)
+ } else {
+ b.pos = new_pos
+ }
+}
+
+@(require_results)
+get_collisions :: proc(h: Body_Handle) -> bit_set[Collision_Type;u8] {
+ return hm.get(&world.bodies, h).collisions
+}
+
+@(require_results)
+get_rect :: proc(h: Body_Handle) -> Rect {
+ return hm.get(&world.bodies, h).rect
+}
+
+@(require_results)
+get_layers :: proc(h: Body_Handle) -> Layer_Set {
+ return hm.get(&world.bodies, h).layers
+}
+
+@(require_results)
+get_mask :: proc(h: Body_Handle) -> Layer_Set {
+ return hm.get(&world.bodies, h).mask
+}
+
+@(require_results)
+get_udata :: proc(h: Body_Handle) -> any {
+ return hm.get(&world.bodies, h).udata
+}
+
+set_udata :: proc(h: Body_Handle, udata: any) {
+ hm.get(&world.bodies, h).udata = udata
+}