Forgot one place where bounds need to be merged for motion blur.
This commit is contained in:
parent
2e3851837d
commit
9d47dfdeb2
26
src/bvh.rs
26
src/bvh.rs
|
@ -61,19 +61,27 @@ impl BVH {
|
||||||
self.depth
|
self.depth
|
||||||
}
|
}
|
||||||
|
|
||||||
fn acc_bounds<'a, T, F>(&mut self, objects1: &mut [T], bounder: &F)
|
fn acc_bounds<'a, T, F>(&mut self, objects: &mut [T], bounder: &F)
|
||||||
where F: 'a + Fn(&T) -> &'a [BBox]
|
where F: 'a + Fn(&T) -> &'a [BBox]
|
||||||
{
|
{
|
||||||
// TODO: merging of different length bounds
|
// TODO: do all of this without the temporary cache
|
||||||
|
let max_len = objects.iter().map(|obj| bounder(obj).len()).max().unwrap();
|
||||||
|
|
||||||
self.bounds_cache.clear();
|
self.bounds_cache.clear();
|
||||||
for bb in bounder(&objects1[0]).iter() {
|
self.bounds_cache.resize(max_len, BBox::new());
|
||||||
self.bounds_cache.push(*bb);
|
|
||||||
}
|
for obj in objects.iter() {
|
||||||
for obj in &objects1[1..] {
|
|
||||||
let bounds = bounder(obj);
|
let bounds = bounder(obj);
|
||||||
debug_assert!(self.bounds_cache.len() == bounds.len());
|
debug_assert!(bounds.len() > 0);
|
||||||
for i in 0..bounds.len() {
|
if bounds.len() == max_len {
|
||||||
self.bounds_cache[i] = self.bounds_cache[i] | bounds[i];
|
for i in 0..bounds.len() {
|
||||||
|
self.bounds_cache[i] |= bounds[i];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let s = (max_len - 1) as f32;
|
||||||
|
for (i, bbc) in self.bounds_cache.iter_mut().enumerate() {
|
||||||
|
*bbc |= lerp_slice(bounds, i as f32 / s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user