Skip to content

Commit

Permalink
simplify graph visitation by removing is visible flag that's no longe…
Browse files Browse the repository at this point in the history
…r needed
  • Loading branch information
douira committed Nov 18, 2024
1 parent 7e7917c commit a70965c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,22 @@ public VisibleChunkCollector(int frame) {
}

@Override
public void visit(RenderSection section, boolean visible) {
RenderRegion region = section.getRegion();
ChunkRenderList renderList = region.getRenderList();
public void visit(RenderSection section) {
// only process section (and associated render list) if it has content that needs rendering
if (section.getFlags() != 0) {
RenderRegion region = section.getRegion();
ChunkRenderList renderList = 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 (renderList.getLastVisibleFrame() != this.frame) {
renderList.reset(this.frame);
if (renderList.getLastVisibleFrame() != this.frame) {
renderList.reset(this.frame);

this.sortedRenderLists.add(renderList);
}
this.sortedRenderLists.add(renderList);
}

if (visible && section.getFlags() != 0) {
renderList.add(section);
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,12 @@ private static void processQueue(Visitor visitor,
RenderSection section;

while ((section = readQueue.dequeue()) != null) {
boolean visible = isSectionVisible(section, viewport, searchDistance);
visitor.visit(section, visible);

if (!visible) {
if (!isSectionVisible(section, viewport, searchDistance)) {
continue;
}

visitor.visit(section);

int connections;

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

visitor.visit(section, true);
visitor.visit(section);

int outgoing;

Expand Down Expand Up @@ -335,6 +334,6 @@ private RenderSection getRenderSection(int x, int y, int z) {
}

public interface Visitor {
void visit(RenderSection section, boolean visible);
void visit(RenderSection section);
}
}

0 comments on commit a70965c

Please sign in to comment.