library: render: move progressbar creation to module

This commit is contained in:
Bruno BELANYI 2020-04-02 00:13:43 +02:00
parent 70a923cf26
commit 6066fe00dc
3 changed files with 12 additions and 5 deletions

View file

@ -18,4 +18,5 @@ pub use pathtrace::*;
mod raytrace;
pub use raytrace::*;
pub(crate) mod progress;
pub(crate) mod utils;

View file

@ -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
}

View file

@ -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