Skip to content

Commit a00c355

Browse files
jellysquid3embeddedt
authored andcommitted
Adjust the size of a chunk section's bounding box in frustum checks
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.
1 parent 0686f56 commit a00c355

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/java/me/jellysquid/mods/sodium/client/render/chunk/occlusion/OcclusionCuller.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,13 @@ private static int nearestToZero(int min, int max) {
177177
return clamped;
178178
}
179179

180+
// The bounding box of a chunk section must be large enough to contain all possible geometry within it. Block models
181+
// can extend outside a block volume by +/- 1.0 blocks on all axis. Additionally, we make use of a small epsilon
182+
// to deal with floating point imprecision during a frustum check (see GH#2132).
183+
private static final float CHUNK_SECTION_SIZE = 8.0f /* chunk bounds */ + 1.0f /* maximum model extent */ + 0.125f /* epsilon */;
184+
180185
public static boolean isOutsideFrustum(Viewport viewport, RenderSection section) {
181-
return !viewport.isBoxVisible(section.getCenterX(), section.getCenterY(), section.getCenterZ(), 8.0f);
186+
return !viewport.isBoxVisible(section.getCenterX(), section.getCenterY(), section.getCenterZ(), CHUNK_SECTION_SIZE);
182187
}
183188

184189
private void init(Consumer<RenderSection> visitor,

0 commit comments

Comments
 (0)