Skip to content

Commit a70965c

Browse files
committed
simplify graph visitation by removing is visible flag that's no longer needed
1 parent 7e7917c commit a70965c

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/lists/VisibleChunkCollector.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,22 @@ public VisibleChunkCollector(int frame) {
3232
}
3333

3434
@Override
35-
public void visit(RenderSection section, boolean visible) {
36-
RenderRegion region = section.getRegion();
37-
ChunkRenderList renderList = region.getRenderList();
35+
public void visit(RenderSection section) {
36+
// only process section (and associated render list) if it has content that needs rendering
37+
if (section.getFlags() != 0) {
38+
RenderRegion region = section.getRegion();
39+
ChunkRenderList renderList = region.getRenderList();
3840

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

44-
this.sortedRenderLists.add(renderList);
45-
}
44+
this.sortedRenderLists.add(renderList);
45+
}
4646

47-
if (visible && section.getFlags() != 0) {
4847
renderList.add(section);
4948
}
5049

50+
// always add to rebuild lists though, because it might just not be built yet
5151
this.addToRebuildLists(section);
5252
}
5353

common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/occlusion/OcclusionCuller.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,12 @@ private static void processQueue(Visitor visitor,
5050
RenderSection section;
5151

5252
while ((section = readQueue.dequeue()) != null) {
53-
boolean visible = isSectionVisible(section, viewport, searchDistance);
54-
visitor.visit(section, visible);
55-
56-
if (!visible) {
53+
if (!isSectionVisible(section, viewport, searchDistance)) {
5754
continue;
5855
}
5956

57+
visitor.visit(section);
58+
6059
int connections;
6160

6261
{
@@ -249,7 +248,7 @@ private void initWithinWorld(Visitor visitor, WriteQueue<RenderSection> queue, V
249248
section.setLastVisibleFrame(frame);
250249
section.setIncomingDirections(GraphDirectionSet.NONE);
251250

252-
visitor.visit(section, true);
251+
visitor.visit(section);
253252

254253
int outgoing;
255254

@@ -335,6 +334,6 @@ private RenderSection getRenderSection(int x, int y, int z) {
335334
}
336335

337336
public interface Visitor {
338-
void visit(RenderSection section, boolean visible);
337+
void visit(RenderSection section);
339338
}
340339
}

0 commit comments

Comments
 (0)