From 1e7d0a28072623d27460c0b384d7faefdcd361d8 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 8 Apr 2020 20:24:15 +0200 Subject: [PATCH] library: render: pathtracer: fix off-by-one exports --- pathtracer/src/render/pathtrace/pathtracer.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pathtracer/src/render/pathtrace/pathtracer.rs b/pathtracer/src/render/pathtrace/pathtracer.rs index 2699086..088fe2f 100644 --- a/pathtracer/src/render/pathtrace/pathtracer.rs +++ b/pathtracer/src/render/pathtrace/pathtracer.rs @@ -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 }, );