Skip to content

Commit

Permalink
Ensure region sorting order when adding empty chunk sections
Browse files Browse the repository at this point in the history
Fixes #2157
  • Loading branch information
jellysquid3 committed Nov 11, 2023
1 parent bc3c47b commit b90ca83
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,7 @@ public RenderRegion getRegion() {
return this.region;
}

public int size() {
return this.size;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,31 @@ public void add(RenderSection section) {
RenderRegion region = section.getRegion();
ChunkRenderList list = region.getRenderList();

// Even if a section does not have render objects, we must ensure the render list is initialized and put
// into the sorted queue of lists, so that we maintain the correct order of draw calls.
if (list.getLastVisibleFrame() != this.frame) {
list.reset(this.frame);

this.lists.add(list);
}

list.add(section);
// Only add the section to the render list if it actually contains render objects
if (section.getFlags() != 0) {
list.add(section);
}
}

public SortedRenderLists build() {
return new SortedRenderLists(this.lists);
var filtered = new ObjectArrayList<ChunkRenderList>(this.lists.size());

// Filter any empty render lists
for (var list : this.lists) {
if (list.size() > 0) {
filtered.add(list);
}
}

return new SortedRenderLists(filtered);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ public VisibleChunkCollector(int frame) {

@Override
public void accept(RenderSection section) {
if (section.getFlags() != 0) {
this.sortedRenderLists.add(section);
}
this.sortedRenderLists.add(section);

this.addToRebuildLists(section);
}
Expand Down

0 comments on commit b90ca83

Please sign in to comment.