From 6066fe00dce0be1aea66f77128abd003a123e53f Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Thu, 2 Apr 2020 00:13:43 +0200 Subject: [PATCH] library: render: move progressbar creation to module --- pathtracer/src/render/mod.rs | 1 + pathtracer/src/render/progress.rs | 10 ++++++++++ pathtracer/src/render/raytrace/raytracer.rs | 6 +----- 3 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 pathtracer/src/render/progress.rs diff --git a/pathtracer/src/render/mod.rs b/pathtracer/src/render/mod.rs index 1e2b4b2..d502605 100644 --- a/pathtracer/src/render/mod.rs +++ b/pathtracer/src/render/mod.rs @@ -18,4 +18,5 @@ pub use pathtrace::*; mod raytrace; pub use raytrace::*; +pub(crate) mod progress; pub(crate) mod utils; diff --git a/pathtracer/src/render/progress.rs b/pathtracer/src/render/progress.rs new file mode 100644 index 0000000..30698ee --- /dev/null +++ b/pathtracer/src/render/progress.rs @@ -0,0 +1,10 @@ +use indicatif::ProgressBar; + +pub fn get_progressbar(total: u64) -> ProgressBar { + let pb = ProgressBar::new(total); + pb.set_draw_delta(total / 10000); + pb.set_style(indicatif::ProgressStyle::default_bar().template( + "{spinner:.green} [{elapsed_precise}] [{wide_bar:.cyan/blue}] {percent:>3}%: {pos}/{len} pixels (ETA: {eta})", + )); + pb +} diff --git a/pathtracer/src/render/raytrace/raytracer.rs b/pathtracer/src/render/raytrace/raytracer.rs index 19b50dc..8aceb29 100644 --- a/pathtracer/src/render/raytrace/raytracer.rs +++ b/pathtracer/src/render/raytrace/raytracer.rs @@ -40,11 +40,7 @@ impl Raytracer { ); let total = (image.width() * image.height()) as u64; - let pb = indicatif::ProgressBar::new(total); - pb.set_draw_delta(total / 10000); - pb.set_style(indicatif::ProgressStyle::default_bar().template( - "{spinner:.green} [{elapsed_precise}] [{wide_bar:.cyan/blue}] {percent:>3}%: {pos}/{len} pixels (ETA: {eta})", - )); + let pb = super::super::progress::get_progressbar(total); let pixel_func = if self.scene.shot_rays > 0 { Self::anti_alias_pixel