refactor(ChunkMeshWorker): inline fluxNewMeshes
As it is now, being able to pass a different source flux there did not improve testability.
Comparator<RenderableChunk> frontToBackComparator, Scheduler parallelScheduler, Scheduler graphicsScheduler) {
this.frontToBackComparator = frontToBackComparator;
- chunksAndNewMeshes = fluxNewMeshes(chunkMeshPublisher.asFlux(), workFunction, parallelScheduler);
+ chunksAndNewMeshes = chunkMeshPublisher.asFlux()
+ .distinct(Chunk::getPosition, () -> chunkMeshProcessing)
+ .parallel().runOn(parallelScheduler)
+ .flatMap(workFunction)
+ .sequential();
completedChunks = chunksAndNewMeshes
.publishOn(graphicsScheduler)
// throwable -> logger.error("Failed to build mesh {}", throwable);
}
- private Flux<Tuple2<Chunk, ChunkMesh>> fluxNewMeshes(Flux<Chunk> flux, Function<? super Chunk, Mono<Tuple2<Chunk, ChunkMesh>>> workFunction,
- Scheduler parallelScheduler) {
- return flux
- .distinct(Chunk::getPosition, () -> chunkMeshProcessing)
- .parallel().runOn(parallelScheduler)
- .flatMap(workFunction)
- .sequential();
- }
-
public static ChunkMeshWorker create(ChunkTessellator chunkTessellator,
WorldProvider worldProvider,
Comparator<RenderableChunk> frontToBackComparator) {
@@ -94,7 +89,7 @@ public static ChunkMeshWorker create(ChunkTessellator chunkTessellator,
}
public void add(Chunk chunk) {
- // FIXME: avoid adding duplicates
+ // TODO: avoid adding duplicates
chunksInProximityOfCamera.add(chunk);
}
