A faster way to check if a block's AABBs can exceed its 1x1x1 cell #6604
Labels
Category: Core
Related to internal functionality
Performance
Type: Enhancement
Contributes features or other improvements to PocketMine-MP
Problem description
PocketMine-MP/src/world/World.php
Lines 1570 to 1578 in f60120a
This code multiplies the performance impact of block AABB collision checking (used for entity movement).
It's only needed to ensure blocks with oversized AABBs like fences are correctly accounted for during collision checks.
However, these blocks are the exception and not the norm, so paying a performance penalty on all blocks is pretty unpleasant.
Proposed solution
If we had a way to tell from the block's stateID whether its AABB may exceed the cell boundaries, we could avoid a lot of unnecessary work in this function. Unfortunately I don't see a nice way to implement this without BC breaks.
Blocks currently aren't required to declare this information, so we'd have to infer it by looking at the results of
getCollisionBoxes()
for each state. This is OK sincerecalculateCollisionBoxes()
is supposed to only be influenced by state anyway (not coordinates).However, AABB overflow can also be influenced by stuff like
getModelPositionOffset()
, which is currently not restricted in any way.Options are:
Block::mayExceedCellBounds()
which returnstrue
by default, overridden tofalse
for most PM blocks (boilerplaty but preserves BC)RuntimeBlockStateRegistry->oversizedAABB
(array<stateID, bool>
), which would need reflection to check whethergetModelPositionOffset()
is overridden (shitty hack but little code needed)Alternative solutions or workarounds
No response
The text was updated successfully, but these errors were encountered: