raster fixes + cheap opts #40
No files matched your search
+26
@@ -122,6 +122,9 @@ public class OcclusionCuller {
|
|||||||
private boolean isCameraInUnloadedSection;
|
private boolean isCameraInUnloadedSection;
|
||||||
private boolean isMultiRootSearch;
|
private boolean isMultiRootSearch;
|
||||||
|
|
||||||
|
// Lattice index of the camera section when it is the search root, else -1. It is visited inline, never tested.
|
||||||
|
private int cameraSectionIndex;
|
||||||
|
|
||||||
public OcclusionCuller(SectionLattice lattice, int minSectionY, int maxSectionY, boolean rasterOcclusion) {
|
public OcclusionCuller(SectionLattice lattice, int minSectionY, int maxSectionY, boolean rasterOcclusion) {
|
||||||
this.lattice = lattice;
|
this.lattice = lattice;
|
||||||
this.minSectionY = minSectionY;
|
this.minSectionY = minSectionY;
|
||||||
@@ -180,6 +183,7 @@ public class OcclusionCuller {
|
|||||||
|
|
||||||
this.isCameraInUnloadedSection = false;
|
this.isCameraInUnloadedSection = false;
|
||||||
this.isMultiRootSearch = false;
|
this.isMultiRootSearch = false;
|
||||||
|
this.cameraSectionIndex = -1;
|
||||||
this.init(visitor, viewport, searchDistance, useOcclusionCulling, frame);
|
this.init(visitor, viewport, searchDistance, useOcclusionCulling, frame);
|
||||||
if (this.isCameraInUnloadedSection) {
|
if (this.isCameraInUnloadedSection) {
|
||||||
useOcclusionCulling = false;
|
useOcclusionCulling = false;
|
||||||
@@ -192,6 +196,7 @@ public class OcclusionCuller {
|
|||||||
|
|
||||||
if (this.rasterActive) {
|
if (this.rasterActive) {
|
||||||
this.rasterOccluder.prepareScene(frame, viewport, searchDistance);
|
this.rasterOccluder.prepareScene(frame, viewport, searchDistance);
|
||||||
|
this.occludeCameraSection(viewport);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.process(visitor, viewport, searchDistance, useOcclusionCulling, allowFrustumClamping, frame);
|
this.process(visitor, viewport, searchDistance, useOcclusionCulling, allowFrustumClamping, frame);
|
||||||
@@ -359,6 +364,25 @@ public class OcclusionCuller {
|
|||||||
this.visibleCount = visibleCount;
|
this.visibleCount = visibleCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void occludeCameraSection(Viewport viewport) {
|
||||||
|
int idx = this.cameraSectionIndex;
|
||||||
|
|
||||||
|
if (idx < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
long sm = this.lattice.sectionMeta[idx];
|
||||||
|
|
||||||
|
if (!PackedSectionMetadata.hasOccluderData(sm)
|
||||||
|
|| (PackedSectionMetadata.getVisualsFlags(sm) & (1 << RenderVisualsService.HAS_BLOCK_GEOMETRY)) == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var origin = viewport.getChunkCoord();
|
||||||
|
this.rasterOccluder.occludeSectionAt(origin.x() << 4, origin.y() << 4, origin.z() << 4,
|
||||||
|
this.lattice.occluderData[idx]);
|
||||||
|
}
|
||||||
|
|
||||||
private RasterOccluder.SectionVisibility rasterTest(int[] occluderBounds, int[][] occluderData,
|
private RasterOccluder.SectionVisibility rasterTest(int[] occluderBounds, int[][] occluderData,
|
||||||
int idx, int chunkX, int chunkY, int chunkZ, int camX, int camY, int camZ,
|
int idx, int chunkX, int chunkY, int chunkZ, int camX, int camY, int camZ,
|
||||||
int meta, boolean hasOccluderData) {
|
int meta, boolean hasOccluderData) {
|
||||||
@@ -573,6 +597,8 @@ public class OcclusionCuller {
|
|||||||
var origin = viewport.getChunkCoord();
|
var origin = viewport.getChunkCoord();
|
||||||
int idx = this.lattice.indexOf(origin.x(), origin.y(), origin.z());
|
int idx = this.lattice.indexOf(origin.x(), origin.y(), origin.z());
|
||||||
|
|
||||||
|
this.cameraSectionIndex = idx;
|
||||||
|
|
||||||
// The camera section is loaded and, after ensureWindowCovers, installed
|
// The camera section is loaded and, after ensureWindowCovers, installed
|
||||||
// in the lattice interior.
|
// in the lattice interior.
|
||||||
long frameStamp = SectionLattice.frameStamp(frame);
|
long frameStamp = SectionLattice.frameStamp(frame);
|
||||||
|
|||||||
+6
@@ -176,6 +176,12 @@ public final class RasterOccluder extends BoxOccluder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Draws a section's occluder boxes without a preceding {@link #testSection}, for a section the search never tests. */
|
||||||
|
public void occludeSectionAt(int originX, int originY, int originZ, int[] data) {
|
||||||
|
prepareRegion(originX, originY, originZ, PackedBox.rangeFromSquareChunkDist(0), 0);
|
||||||
|
occludeSection(data);
|
||||||
|
}
|
||||||
|
|
||||||
/** Draws the section's occluder boxes for the region prepared by the last {@link #testSection}. */
|
/** Draws the section's occluder boxes for the region prepared by the last {@link #testSection}. */
|
||||||
public void occludeSection(int[] data) {
|
public void occludeSection(int[] data) {
|
||||||
if (!AbstractRasterizer.STATS) {
|
if (!AbstractRasterizer.STATS) {
|
||||||
|
|||||||
Reference in new issue
Block a user