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);
}
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));
}
}
#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
}
@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;