Skip to content

Commit

Permalink
fix section sorting by correcting the camera offset
Browse files Browse the repository at this point in the history
  • Loading branch information
douira committed Nov 16, 2024
1 parent 96c957f commit fa820d4
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ public void traverse(SectionTree.VisibleSectionVisitor visitor, Viewport viewpor

var transform = viewport.getTransform();

// + 1 to section position to compensate for shifted global offset
this.cameraOffsetX = (transform.intX >> 4) - this.offsetX + 1;
this.cameraOffsetY = (transform.intY >> 4) - this.offsetY + 1;
this.cameraOffsetZ = (transform.intZ >> 4) - this.offsetZ + 1;
// + 1 to offset section position to compensate for shifted global offset
// adjust camera block position to account for fractional part of camera position
this.cameraOffsetX = ((transform.intX + (int) Math.signum(transform.fracX)) >> 4) - this.offsetX + 1;
this.cameraOffsetY = ((transform.intY + (int) Math.signum(transform.fracY)) >> 4) - this.offsetY + 1;
this.cameraOffsetZ = ((transform.intZ + (int) Math.signum(transform.fracZ)) >> 4) - this.offsetZ + 1;

// everything is already inside the distance limit if the build distance is smaller
var initialInside = this.distanceLimit >= buildDistance ? INSIDE_DISTANCE : 0;
Expand Down

0 comments on commit fa820d4

Please sign in to comment.