Control those Uniform distributions

I wanted to make the Uniform's into `const`s that live at the global
scope. Rust can do global const, but the `Uniform::new()` function
can't be used in that context.

As an intermediate to a *helpful* solution, I've just pushed them into a
struct. One less parameter to name even though it's the same stuff. The
compiler should be smart enough to hoist the initialization outside the
function and leave them around, but maybe not. After all, the function
isn't defined to work in such a way with the `const` keyword :v
This commit is contained in:
2023-08-18 21:12:39 -05:00
parent 4430b7c0bf
commit 601beb10a0
2 changed files with 26 additions and 14 deletions

View File

@@ -1,7 +1,7 @@
use crate::RenderContext;
use crate::Vec3;
use crate::render_line;
use crate::{render_line, DistributionContianer};
use core::cmp::Ordering;
use std::thread;
@@ -76,7 +76,7 @@ impl Dispatcher {
let mut srng = srng.clone();
let threads_result_tx = render_tx.clone();
let distribs = DistributionContianer::new();
let thread_handle = thread::spawn(move || {
while let Ok(job) = command_rx.recv() {
match job {
@@ -84,7 +84,7 @@ impl Dispatcher {
break;
}
RenderCommand::Line { line_num, context } => {
let line = render_line(line_num, &mut srng, context);
let line = render_line(line_num, &mut srng, context, &distribs);
let result = RenderResult { line_num, line };
threads_result_tx.send(result).unwrap();
}