library: render: pathtracer: fix off-by-one exports

This commit is contained in:
Bruno BELANYI 2020-04-08 20:24:15 +02:00
parent faa1ef1fb8
commit 1e7d0a2807

View file

@ -68,6 +68,11 @@ impl Pathtracer {
(vec, count)
},
|(mut acc, count), buf| {
for (i, pixel) in buf.into_iter().enumerate() {
acc[i] += pixel;
}
let count = count + 1; // Because count is 0-indexed
if steps.contains(&count) {
let image = buffer_to_image(&acc, count as u32, width, height);
image
@ -75,11 +80,7 @@ impl Pathtracer {
.expect("writing image failed!");
}
for (i, pixel) in buf.into_iter().enumerate() {
acc[i] += pixel;
}
(acc, count + 1)
(acc, count) // Count has been updated previously
},
);