From: Brendan Hansen Date: Fri, 31 Dec 2021 04:06:16 +0000 (-0600) Subject: random cleanup X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=dc97e66537e858893d5b11ffb9ff665b41dec9d3;p=voxel-shooter.git random cleanup --- diff --git a/src/main.onyx b/src/main.onyx index 50fbcdc..135d1e6 100644 --- a/src/main.onyx +++ b/src/main.onyx @@ -150,17 +150,11 @@ draw :: () { glLineWidth(2); chunk_highlight_block(~~selected_block.x, ~~selected_block.y, ~~selected_block.z); - #if false { - aabb_buffer := (cast(^AABB) alloc.from_stack(sizeof [128] AABB))[0 .. 128]; - aabbs := world_get_aabbs(world, camera.position, 5, aabb_buffer); - for^ aabbs do chunk_highlight_block(it.x0, it.y0, it.z0); - } + ww, wh: i32; + glfwGetWindowSize(window, ^ww, ^wh); + font_print(font, ~~(ww / 2), ~~(wh / 2), "."); if debug_screen { - ww, wh: i32; - glfwGetWindowSize(window, ^ww, ^wh); - font_print(font, ~~(ww / 2), ~~(wh / 2), "."); - font_print(font, 0, 32, "FPS: {}", game_fps); font_print(font, 0, 64, "Position: {}", camera.position); font_print(font, 0, 96, "Facing: {}", camera.y_rot * 180 / math.PI); diff --git a/src/player.onyx b/src/player.onyx index e9d6ecb..3c634fb 100644 --- a/src/player.onyx +++ b/src/player.onyx @@ -77,7 +77,8 @@ player_update :: (use player: ^Player, dt: f32) { } if is_button_just_down(GLFW_MOUSE_BUTTON_RIGHT) { - world_set_block(world, selected_block.x + dir.x, selected_block.y + dir.y, selected_block.z + dir.z, block_make(1,0,0,1)); + target := selected_block + dir; + world_set_block(world, target.x, target.y, target.z, block_make(1,0,0,1)); } } diff --git a/src/vecmath.onyx b/src/vecmath.onyx index c57891d..95abdf1 100644 --- a/src/vecmath.onyx +++ b/src/vecmath.onyx @@ -43,6 +43,10 @@ Vector3 :: struct [conv.Custom_Format.{format_vector3}] { #operator - macro (v1, v2: Vector3) => Vector3.{ v1.x - v2.x, v1.y - v2.y, v1.z - v2.z }; #operator * macro (v: Vector3, s: f32) => Vector3.{ v.x * s, v.y * s, v.z * s }; +#operator + macro (v1, v2: Vector3i) => Vector3i.{ v1.x + v2.x, v1.y + v2.y, v1.z + v2.z }; +#operator - macro (v1, v2: Vector3i) => Vector3i.{ v1.x - v2.x, v1.y - v2.y, v1.z - v2.z }; +#operator * macro (v: Vector3i, s: i32) => Vector3i.{ v.x * s, v.y * s, v.z * s }; + #local { conv :: package core.conv diff --git a/src/world.onyx b/src/world.onyx index a852b1e..2a1bf35 100644 --- a/src/world.onyx +++ b/src/world.onyx @@ -92,7 +92,7 @@ Ray :: struct { } @Relocate // to a utils file -ray_cast :: (ray: Ray, max_distance: f32, ctx: $T, is_solid: (T, Vector3i) -> bool, out_block: ^Vector3i, out_dir: ^Vector3i) -> bool { +ray_cast :: (ray: Ray, max_distance: f32, ctx: rawptr, is_solid: (rawptr, Vector3i) -> bool, out_block: ^Vector3i, out_dir: ^Vector3i) -> bool { pos := Vector3i.{ ~~math.floor(ray.origin.x), ~~math.floor(ray.origin.y), ~~math.floor(ray.origin.z) }; dir := ray.direction;