From 95fb1d160242de9f3b50f8d5c8b96199a331fca6 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 14 Mar 2018 16:52:05 +0000 Subject: [PATCH] AxisAlignedBB: added epsilon for floating-point comparison (#2101) This fixes bugs where, for example, one cannot place a block below oneself at y=7.0. --- src/pocketmine/math/AxisAlignedBB.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pocketmine/math/AxisAlignedBB.php b/src/pocketmine/math/AxisAlignedBB.php index 85eb2042e..a126ff720 100644 --- a/src/pocketmine/math/AxisAlignedBB.php +++ b/src/pocketmine/math/AxisAlignedBB.php @@ -282,12 +282,14 @@ class AxisAlignedBB{ * Returns whether any part of the specified AABB is inside (intersects with) this one. * * @param AxisAlignedBB $bb + * @param float $epsilon + * * @return bool */ - public function intersectsWith(AxisAlignedBB $bb) : bool{ - if($bb->maxX > $this->minX and $bb->minX < $this->maxX){ - if($bb->maxY > $this->minY and $bb->minY < $this->maxY){ - return $bb->maxZ > $this->minZ and $bb->minZ < $this->maxZ; + public function intersectsWith(AxisAlignedBB $bb, float $epsilon = 0.00001) : bool{ + if($bb->maxX - $this->minX > $epsilon and $this->maxX - $bb->minX > $epsilon){ + if($bb->maxY - $this->minY > $epsilon and $this->maxY - $bb->minY > $epsilon){ + return $bb->maxZ - $this->minZ > $epsilon and $this->maxZ - $bb->minZ > $epsilon; } }