Floating point comparison issues with bounding boxes #2100
Labels
Category: Core
Related to internal functionality
Category: Gameplay
Related to Minecraft gameplay experience
Resolution: Fixed
Issue description
Due to the impossibility of completely accurately representing most fractional numbers as floats, they should not be compared directly. However, PocketMine-MP does this in many places - most notably in
AxisAlignedBB->intersectsWith()
This is problematic because this means that any floating point error, no matter how small, will result in issues with false intersections.
Take the following example: A block with BB minY=6, maxY=7. Then you have a player standing on top of it trying to place a block next to it. Their bounding box minY is apparently 7 according to
var_dump()
, but raising theprecision
php.ini directive shows us that their BB is actually something like 6.99999999999999911182158029987476766109466552734375. This tiny difference causes the player not to be able to place blocks on the same Y coordinate while standing on top of an already placed one.This comparison should be using epsilons to compare BB bounds for intersection.
Performance must be considered for any fix applied for this because BB intersection is a heavily-used function.
Steps to reproduce the issue
OS and versions
The text was updated successfully, but these errors were encountered: