From 17463391fe708ab667ec482a336b22f5fe189002 Mon Sep 17 00:00:00 2001 From: Charles Johnson <32775248+ChemicalXandco@users.noreply.github.com> Date: Mon, 13 Feb 2023 16:33:51 +0000 Subject: fix `BlockCollisions` bounding box (#68) * fix `BlockCollisions` bounding box * add test --------- Co-authored-by: Ubuntu --- azalea-physics/src/collision/world_collisions.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'azalea-physics/src/collision') diff --git a/azalea-physics/src/collision/world_collisions.rs b/azalea-physics/src/collision/world_collisions.rs index 631bc116..9ffc62a5 100644 --- a/azalea-physics/src/collision/world_collisions.rs +++ b/azalea-physics/src/collision/world_collisions.rs @@ -20,13 +20,13 @@ pub struct BlockCollisions<'a> { impl<'a> BlockCollisions<'a> { pub fn new(world: &'a World, aabb: AABB) -> Self { - let origin_x = (aabb.min_x - EPSILON) as i32 - 1; - let origin_y = (aabb.min_y - EPSILON) as i32 - 1; - let origin_z = (aabb.min_z - EPSILON) as i32 - 1; + let origin_x = (aabb.min_x - EPSILON).floor() as i32 - 1; + let origin_y = (aabb.min_y - EPSILON).floor() as i32 - 1; + let origin_z = (aabb.min_z - EPSILON).floor() as i32 - 1; - let end_x = (aabb.max_x + EPSILON) as i32 + 1; - let end_y = (aabb.max_y + EPSILON) as i32 + 1; - let end_z = (aabb.max_z + EPSILON) as i32 + 1; + let end_x = (aabb.max_x + EPSILON).floor() as i32 + 1; + let end_y = (aabb.max_y + EPSILON).floor() as i32 + 1; + let end_z = (aabb.max_z + EPSILON).floor() as i32 + 1; let cursor = Cursor3d::new(origin_x, origin_y, origin_z, end_x, end_y, end_z); -- cgit v1.2.3