mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +00:00
Level: fixed logical errors in getCollisionBlocks() and getCollisionCubes()
This is the same bug that Entity->getBlocksAround() had, except this actually checks for BB intersections. What this means is that as a result of the bug, one extra layer of blocks is unnecessarily checked on the max sides of the BB. For example: Assume you have a BB with maxY -5.5 You're definitely colliding with block -6 (because you're inside it) and you want to check an extra block in case you hit something weird like a fence. So you want to check _at most_ up to block -5 (inclusive). Following this maths: -5.5 + 1 = -4.5 ceil(-4.5) = -4 This causes us to check block -4 unnecessarily. This may be a performance waste - depending on the BB size it could be proportionally a lot of blocks getting unnecessarily checked. This has not been benchmarked.
This commit is contained in:
parent
982444949c
commit
c9a0c381b1
@ -1102,9 +1102,9 @@ class Level implements ChunkManager, Metadatable{
|
||||
$minX = Math::floorFloat($bb->minX - 1);
|
||||
$minY = Math::floorFloat($bb->minY - 1);
|
||||
$minZ = Math::floorFloat($bb->minZ - 1);
|
||||
$maxX = Math::ceilFloat($bb->maxX + 1);
|
||||
$maxY = Math::ceilFloat($bb->maxY + 1);
|
||||
$maxZ = Math::ceilFloat($bb->maxZ + 1);
|
||||
$maxX = Math::floorFloat($bb->maxX + 1);
|
||||
$maxY = Math::floorFloat($bb->maxY + 1);
|
||||
$maxZ = Math::floorFloat($bb->maxZ + 1);
|
||||
|
||||
$collides = [];
|
||||
|
||||
@ -1165,9 +1165,9 @@ class Level implements ChunkManager, Metadatable{
|
||||
$minX = Math::floorFloat($bb->minX - 1);
|
||||
$minY = Math::floorFloat($bb->minY - 1);
|
||||
$minZ = Math::floorFloat($bb->minZ - 1);
|
||||
$maxX = Math::ceilFloat($bb->maxX + 1);
|
||||
$maxY = Math::ceilFloat($bb->maxY + 1);
|
||||
$maxZ = Math::ceilFloat($bb->maxZ + 1);
|
||||
$maxX = Math::floorFloat($bb->maxX + 1);
|
||||
$maxY = Math::floorFloat($bb->maxY + 1);
|
||||
$maxZ = Math::floorFloat($bb->maxZ + 1);
|
||||
|
||||
$collides = [];
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user