Skip to content

Commit 471416f

Browse files
author
Maximilian Stiede
committed
add way to specialize WorkerState and Ray creation
TODO: add PluginAPI
1 parent 6c89994 commit 471416f

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

chunky/src/java/se/llbit/chunky/renderer/TileBasedRenderer.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.util.ArrayList;
2626
import java.util.function.BiConsumer;
2727
import java.util.function.BooleanSupplier;
28+
import java.util.function.Supplier;
2829

2930
/**
3031
* A tile based renderer. Simply call {@code submitTiles} to submit a frame's worth of tiles to the work queue.
@@ -57,6 +58,9 @@ public void setPostRender(BooleanSupplier callback) {
5758
postRender = callback;
5859
}
5960

61+
protected Supplier<WorkerState> workerStateFactory = WorkerState::new;
62+
protected Supplier<Ray> rayFactory = Ray::new;
63+
6064
/**
6165
* Create and submit tiles to the rendering pool.
6266
* Await for these tiles to finish rendering with {@code manager.pool.awaitEmpty()}.
@@ -69,8 +73,8 @@ protected void submitTiles(DefaultRenderManager manager, BiConsumer<WorkerState,
6973

7074
cachedTiles.forEach(tile ->
7175
manager.pool.submit(worker -> {
72-
WorkerState state = new WorkerState();
73-
state.ray = new Ray();
76+
WorkerState state = workerStateFactory.get();
77+
state.ray = rayFactory.get();
7478
state.ray.setNormal(0, 0, -1);
7579
state.random = worker.random;
7680

chunky/src/test/se/llbit/chunky/renderer/BlankRenderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ private static double[] render(Scene scene) throws InterruptedException {
7070
// A single worker thread is used, with fixed PRNG seed.
7171
// This makes the path tracing results deterministic.
7272
ChunkyOptions options = ChunkyOptions.getDefaults();
73-
options.renderThreads = 1;
73+
options.changeRenderConfig(config -> config.setRenderThreadCount(1));
7474
Chunky chunky = new Chunky(options);
7575
RenderContext context = new RenderContext(chunky);
7676
context.renderPoolFactory = (threads, seed) -> new RenderWorkerPool(threads, 0);

0 commit comments

Comments
 (0)