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

Add epsilon to section distance check #2823

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,10 @@ private static boolean isWithinRenderDistance(CameraTransform camera, RenderSect

// coordinates of the point to compare (in view space)
// this is the closest point within the bounding box to the center (0, 0, 0)
float dx = nearestToZero(ox, ox + 16) - camera.fracX;
float dy = nearestToZero(oy, oy + 16) - camera.fracY;
float dz = nearestToZero(oz, oz + 16) - camera.fracZ;
// the bounding box is expanded by 1 block in each direction due to the maximum allowed size of block models.
float dx = nearestToZero(ox - 1, ox + 17) - camera.fracX;
float dy = nearestToZero(oy - 1, oy + 17) - camera.fracY;
float dz = nearestToZero(oz - 1, oz + 17) - camera.fracZ;

// vanilla's "cylindrical fog" algorithm
// max(length(distance.xz), abs(distance.y))
Expand All @@ -179,7 +180,8 @@ private static int nearestToZero(int min, int max) {
// 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 */;
private static final float CHUNK_SECTION_SIZE = 8.0f /* chunk bounds */ + 1.0f /* maximum model extent */
burgerindividual marked this conversation as resolved.
Show resolved Hide resolved
+ 0.125f /* fp error epsilon */;

public static boolean isWithinFrustum(Viewport viewport, RenderSection section) {
return viewport.isBoxVisible(section.getCenterX(), section.getCenterY(), section.getCenterZ(),
Expand Down