Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Floating point comparison issues with bounding boxes #2100

Closed
dktapps opened this issue Mar 14, 2018 · 1 comment
Closed

Floating point comparison issues with bounding boxes #2100

dktapps opened this issue Mar 14, 2018 · 1 comment
Labels
Category: Core Related to internal functionality Category: Gameplay Related to Minecraft gameplay experience Resolution: Fixed

Comments

@dktapps
Copy link
Member

dktapps commented Mar 14, 2018

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 the precision 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

  1. place a block
  2. jump on top of it and stand on its edge
  3. try to place a block on the same level as it while standing over the space

OS and versions

  • PocketMine-MP: ddc9dca
  • PHP: 7.2.2
  • Server OS: linux
@dktapps dktapps added Category: Gameplay Related to Minecraft gameplay experience Category: Core Related to internal functionality Priority: High Status: Debugged Cause of the bug has been found, but not fixed labels Mar 14, 2018
@dktapps
Copy link
Member Author

dktapps commented Mar 14, 2018

Fixed in #2101 .

@dktapps dktapps closed this as completed Mar 14, 2018
@dktapps dktapps added Resolution: Fixed and removed Priority: High Status: Debugged Cause of the bug has been found, but not fixed labels Mar 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Core Related to internal functionality Category: Gameplay Related to Minecraft gameplay experience Resolution: Fixed
Projects
None yet
Development

No branches or pull requests

1 participant