Skip to content

Commit

Permalink
also add the child nodes partition distances to the workspace for tri…
Browse files Browse the repository at this point in the history
…ggering on node reuse
  • Loading branch information
douira committed Dec 15, 2023
1 parent cccb206 commit 90c3632
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ class InnerBinaryPartitionBSPNode extends InnerPartitionBSPNode {
@Override
void addPartitionPlanes(BSPWorkspace workspace) {
workspace.addAlignedPartitionPlane(this.axis, this.planeDistance);

// also add the planes of the children
if (this.inside instanceof InnerPartitionBSPNode inside) {
inside.addPartitionPlanes(workspace);
}
if (this.outside instanceof InnerPartitionBSPNode outside) {
outside.addPartitionPlanes(workspace);
}
}

private void collectInside(BSPSortState sortState, Vector3fc cameraPos) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ void addPartitionPlanes(BSPWorkspace workspace) {
for (int i = 0; i < this.planeDistances.length; i++) {
workspace.addAlignedPartitionPlane(this.axis, this.planeDistances[i]);
}

// recurse on children to also add their planes
for (var partition : this.partitions) {
if (partition instanceof InnerPartitionBSPNode inner) {
inner.addPartitionPlanes(workspace);
}
}
}

private void collectPlaneQuads(BSPSortState sortState, int planeIndex) {
Expand Down

0 comments on commit 90c3632

Please sign in to comment.