mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 16:51:42 +00:00
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.
This commit is contained in:
parent
fa644edef3
commit
95fb1d1602
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user