Skip to content

Commit abd7168

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

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

0 commit comments

Comments
 (0)