use of grondag.canvas.chunk.occlusion.ChunkOcclusionMap in project canvas by vram-guild.
the class MixinChunkOcclusionGraphBuilder method buildFast.
@Inject(method = "build", at = @At("HEAD"), cancellable = true, require = 1)
public void buildFast(CallbackInfoReturnable<ChunkOcclusionData> ci) {
if (Configurator.fastChunkOcclusion) {
// PERF: any way to avoid allocation?
final ChunkOcclusionData result = new ChunkOcclusionData();
if (4096 - openCount < 256) {
// set all visible
result.fill(true);
((ChunkOcclusionGraphExt) result).canvas_visibilityData(DirectionSet.ALL);
} else if (openCount == 0) {
result.fill(false);
((ChunkOcclusionGraphExt) result).canvas_visibilityData(DirectionSet.NONE);
} else {
final BitSet bitSet = closed;
final ChunkOcclusionMap facingMap = ChunkOcclusionMap.claim();
for (final int i : EDGE_POINTS) {
if (!bitSet.get(i)) {
final Pair<Set<Direction>, IntArrayList> floodResult = getOpenFacesFast(i);
final Set<Direction> fillSet = floodResult.getLeft();
// set multiple visible
result.addOpenEdgeFaces(fillSet);
final byte setIndex = (byte) DirectionSet.sharedIndex(fillSet);
final IntArrayList list = floodResult.getRight();
final int limit = list.size();
for (int j = 0; j < limit; j++) {
facingMap.setIndex(list.getInt(j), setIndex);
}
}
}
((ChunkOcclusionGraphExt) result).canvas_visibilityData(facingMap);
}
ci.setReturnValue(result);
}
}
Aggregations