use of net.minecraft.client.render.chunk.ChunkOcclusionData 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);
}
}
use of net.minecraft.client.render.chunk.ChunkOcclusionData in project sodium-fabric by CaffeineMC.
the class ChunkRenderRebuildTask method performBuild.
@Override
public ChunkRenderUploadTask performBuild(VertexBufferCache buffers) {
ChunkMeshInfo meshInfo;
Object2ObjectMap<RenderLayer, BufferUploadData> uploads;
if (this.region == null) {
meshInfo = new ChunkMeshInfo();
meshInfo.occlusionGraph = new ChunkOcclusionData();
meshInfo.occlusionGraph.addOpenEdgeFaces(EnumSet.allOf(Direction.class));
uploads = Object2ObjectMaps.emptyMap();
} else {
meshInfo = this.generateMesh(buffers);
uploads = new Object2ObjectArrayMap<>();
for (RenderLayer layer : meshInfo.presentLayers) {
BufferBuilder builder = buffers.get(layer);
builder.end();
uploads.put(layer, ((CloneableBufferBuilder) builder).copyData());
}
}
return new Result(this.render, meshInfo, uploads);
}
Aggregations