Skip to content

Commit

Permalink
Adjust the size of a chunk section's bounding box in frustum checks
Browse files Browse the repository at this point in the history
This should fix some rare issues with floating-point
precision at extreme angles. It also ensures that certain block
models (such as the Lectern) will still be rendered at the
furthest extents of a chunk section.
  • Loading branch information
jellysquid3 authored and embeddedt committed Oct 31, 2023
1 parent 0686f56 commit a00c355
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,13 @@ private static int nearestToZero(int min, int max) {
return clamped;
}

// The bounding box of a chunk section must be large enough to contain all possible geometry within it. Block models
// can extend outside a block volume by +/- 1.0 blocks on all axis. Additionally, we make use of a small epsilon
// to deal with floating point imprecision during a frustum check (see GH#2132).
private static final float CHUNK_SECTION_SIZE = 8.0f /* chunk bounds */ + 1.0f /* maximum model extent */ + 0.125f /* epsilon */;

public static boolean isOutsideFrustum(Viewport viewport, RenderSection section) {
return !viewport.isBoxVisible(section.getCenterX(), section.getCenterY(), section.getCenterZ(), 8.0f);
return !viewport.isBoxVisible(section.getCenterX(), section.getCenterY(), section.getCenterZ(), CHUNK_SECTION_SIZE);
}

private void init(Consumer<RenderSection> visitor,
Expand Down

0 comments on commit a00c355

Please sign in to comment.