diff options
author | Julian T <julian@jtle.dk> | 2021-02-12 23:33:50 +0100 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2021-02-12 23:34:09 +0100 |
commit | 14f7b47f2c2315d0de5e52d31c57fe07a15d08ad (patch) | |
tree | f512e7e0939fd151cf9196004611e3cd82a95773 /src/sample | |
parent | 49c6adb0db70ffc30eaac33b66eacf7574b34e26 (diff) |
Implement multithreaded compiling of tiles
Diffstat (limited to 'src/sample')
-rw-r--r-- | src/sample/mod.rs | 2 | ||||
-rw-r--r-- | src/sample/uniform.rs | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/sample/mod.rs b/src/sample/mod.rs index 88e1aa9..1a53921 100644 --- a/src/sample/mod.rs +++ b/src/sample/mod.rs @@ -16,6 +16,8 @@ pub trait Sampler { Vector2f::new_xy(self.get_sample(), self.get_sample()) } + fn clone_and_seed(&mut self) -> Box<dyn Sampler + Send>; + fn get_unit_vector(&mut self) -> Vector3f { let s2d = self.get_sample_2d(); diff --git a/src/sample/uniform.rs b/src/sample/uniform.rs index 2cd3156..c144f27 100644 --- a/src/sample/uniform.rs +++ b/src/sample/uniform.rs @@ -30,4 +30,10 @@ impl Sampler for UniformSampler { fn get_sample(&mut self) -> Float { self.d.sample(&mut self.r) } + + fn clone_and_seed(&mut self) -> Box<dyn Sampler + Send> { + let mut n = self.clone(); + n.r = Pcg32::seed_from_u64(self.r.next_u64()); + Box::new(n) + } } |