Skip to content

Commit

Permalink
fix incorrect multi forest size calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
douira committed Nov 10, 2024
1 parent 6e2f4ef commit ba79561
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
- experiment with non-linear distance scaling (if < some radius, bonus priority for being close)
*/
public class PendingTaskCollector implements OcclusionCuller.GraphOcclusionVisitor {
// offset is shifted by 1 to encompass all sections towards the negative
// TODO: is this the correct way of calculating the minimum possible section index?
private static final int DISTANCE_OFFSET = 1;
public static final int SECTION_Y_MIN = -128; // used instead of baseOffsetY to accommodate all permissible y values (-2048 to 2048 blocks)

// tunable parameters for the priority calculation.
Expand All @@ -48,7 +45,7 @@ public class PendingTaskCollector implements OcclusionCuller.GraphOcclusionVisit
public PendingTaskCollector(Viewport viewport, float buildDistance, boolean frustumTested) {
this.creationTime = System.nanoTime();
this.isFrustumTested = frustumTested;
var offsetDistance = Mth.ceil(buildDistance / 16.0f) + DISTANCE_OFFSET;
var offsetDistance = Mth.ceil(buildDistance / 16.0f) + 1;

var transform = viewport.getTransform();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public abstract class BaseMultiForest<T extends Tree> extends BaseForest<T> {
public BaseMultiForest(int baseOffsetX, int baseOffsetY, int baseOffsetZ, float buildDistance) {
super(baseOffsetX, baseOffsetY, baseOffsetZ, buildDistance);

this.forestDim = (int) Math.ceil(buildDistance / 64.0);
this.forestDim = (int) Math.ceil((buildDistance / 8.0 + 1) / 64.0);
this.trees = this.makeTrees(this.forestDim * this.forestDim * this.forestDim);
}

Expand Down Expand Up @@ -62,6 +62,7 @@ public int getPresence(int x, int y, int z) {
var treeIndex = this.getTreeIndexAbsolute(x, y, z);
var tree = this.trees[treeIndex];
if (tree != null) {
this.lastTree = tree;
return tree.getPresence(x, y, z);
}
return TraversableTree.OUT_OF_BOUNDS;
Expand Down

0 comments on commit ba79561

Please sign in to comment.