rasterized occlusion culling #38
+8
-4
@@ -226,6 +226,8 @@ public class OcclusionCuller {
|
|||||||
final long[] queue = this.queue;
|
final long[] queue = this.queue;
|
||||||
final long[] apertures = this.apertures;
|
final long[] apertures = this.apertures;
|
||||||
final long[] visibleCells = this.visibleCells;
|
final long[] visibleCells = this.visibleCells;
|
||||||
|
final int[] occluderBounds = this.lattice.occluderBounds;
|
||||||
|
final int[][] occluderData = this.lattice.occluderData;
|
||||||
int visibleCount = this.visibleCount;
|
int visibleCount = this.visibleCount;
|
||||||
final int baseX = this.lattice.baseX, baseY = this.lattice.baseY, baseZ = this.lattice.baseZ;
|
final int baseX = this.lattice.baseX, baseY = this.lattice.baseY, baseZ = this.lattice.baseZ;
|
||||||
|
|
||||||
@@ -302,7 +304,8 @@ public class OcclusionCuller {
|
|||||||
boolean traverse = visible;
|
boolean traverse = visible;
|
||||||
|
|
||||||
if (this.rasterActive && visible) {
|
if (this.rasterActive && visible) {
|
||||||
RasterOccluder.SectionVisibility result = this.rasterTest(idx, chunkX, chunkY, chunkZ, camX, camY, camZ,
|
RasterOccluder.SectionVisibility result = this.rasterTest(occluderBounds, occluderData,
|
||||||
|
idx, chunkX, chunkY, chunkZ, camX, camY, camZ,
|
||||||
compactMeta, PackedSectionMetadata.hasOccluderData(sm), regionId, regionX, regionY, regionZ);
|
compactMeta, PackedSectionMetadata.hasOccluderData(sm), regionId, regionX, regionY, regionZ);
|
||||||
visible = result == RasterOccluder.SectionVisibility.VISIBLE;
|
visible = result == RasterOccluder.SectionVisibility.VISIBLE;
|
||||||
traverse = result != RasterOccluder.SectionVisibility.HIDDEN;
|
traverse = result != RasterOccluder.SectionVisibility.HIDDEN;
|
||||||
@@ -358,7 +361,8 @@ public class OcclusionCuller {
|
|||||||
this.visibleCount = visibleCount;
|
this.visibleCount = visibleCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
private RasterOccluder.SectionVisibility rasterTest(int idx, int chunkX, int chunkY, int chunkZ, int camX, int camY, int camZ,
|
private RasterOccluder.SectionVisibility rasterTest(int[] occluderBounds, int[][] occluderData,
|
||||||
|
int idx, int chunkX, int chunkY, int chunkZ, int camX, int camY, int camZ,
|
||||||
int meta, boolean hasOccluderData,
|
int meta, boolean hasOccluderData,
|
||||||
int regionId, int regionX, int regionY, int regionZ) {
|
int regionId, int regionX, int regionY, int regionZ) {
|
||||||
var occluder = this.rasterOccluder;
|
var occluder = this.rasterOccluder;
|
||||||
@@ -380,12 +384,12 @@ public class OcclusionCuller {
|
|||||||
(PackedSectionMetadata.getCompactVisualsFlags(meta) & (1 << RenderVisualsService.HAS_BLOCK_GEOMETRY)) != 0;
|
(PackedSectionMetadata.getCompactVisualsFlags(meta) & (1 << RenderVisualsService.HAS_BLOCK_GEOMETRY)) != 0;
|
||||||
|
|
||||||
// the flag spares the many sections without data the loads below, which rarely hit cache
|
// the flag spares the many sections without data the loads below, which rarely hit cache
|
||||||
int bounds = hasOccluderData ? this.lattice.occluderBounds[idx] : PackedBox.FULL_BOX;
|
int bounds = hasOccluderData ? occluderBounds[idx] : PackedBox.FULL_BOX;
|
||||||
|
|
||||||
RasterOccluder.SectionVisibility result = occluder.testSection(chunkX << 4, chunkY << 4, chunkZ << 4, squaredChunkDist, bounds);
|
RasterOccluder.SectionVisibility result = occluder.testSection(chunkX << 4, chunkY << 4, chunkZ << 4, squaredChunkDist, bounds);
|
||||||
|
|
||||||
if (result == RasterOccluder.SectionVisibility.VISIBLE && hasGeometry && hasOccluderData) {
|
if (result == RasterOccluder.SectionVisibility.VISIBLE && hasGeometry && hasOccluderData) {
|
||||||
occluder.occludeSection(this.lattice.occluderData[idx]);
|
occluder.occludeSection(occluderData[idx]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Reference in new issue
Block a user