diff options
| author | Charles Johnson <32775248+ChemicalXandco@users.noreply.github.com> | 2023-02-13 16:33:51 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-13 10:33:51 -0600 |
| commit | 17463391fe708ab667ec482a336b22f5fe189002 (patch) | |
| tree | 2c8020a0598cb59187dcfd06c77d973b4fae3f1d /azalea-physics/src/collision | |
| parent | 1b3d6f9581689e9caa0e2dd14dcf48c20fb06ed7 (diff) | |
| download | azalea-drasl-17463391fe708ab667ec482a336b22f5fe189002.tar.xz | |
fix `BlockCollisions` bounding box (#68)
* fix `BlockCollisions` bounding box
* add test
---------
Co-authored-by: Ubuntu <github@matdoes.dev>
Diffstat (limited to 'azalea-physics/src/collision')
| -rw-r--r-- | azalea-physics/src/collision/world_collisions.rs | 12 |
1 files changed, 6 insertions, 6 deletions
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); |
