library: render: progress: fix refresh for pathtracing

This commit is contained in:
Antoine Martin 2020-04-07 23:21:31 +02:00
parent b89e01107d
commit 82dee9fde5
3 changed files with 23 additions and 7 deletions

View file

@ -38,7 +38,7 @@ impl Pathtracer {
); );
let total = width * height; let total = width * height;
let p = super::super::progress::get_progressbar(self.scene.shot_rays as u64); let p = super::super::progress::get_passes_progressbar(self.scene.shot_rays);
// Ensure at least one round of shots // Ensure at least one round of shots
let img_buf = (0..self.scene.shot_rays.max(1)) let img_buf = (0..self.scene.shot_rays.max(1))

View file

@ -1,10 +1,26 @@
use indicatif::ProgressBar; use indicatif::{ProgressBar, ProgressStyle};
pub fn get_progressbar(total: u64) -> ProgressBar { pub fn get_progressbar(total: u64, style: &str) -> ProgressBar {
let pb = ProgressBar::new(total); let pb = ProgressBar::new(total);
pb.set_draw_delta((total / 10000).max(1)); pb.set_draw_delta((total / 10000).max(1));
pb.set_style(indicatif::ProgressStyle::default_bar().template( pb.set_style(ProgressStyle::default_bar().template(style));
"{spinner:.green} [{elapsed_precise}] [{wide_bar:.cyan/blue}] {percent:>3}%: {pos}/{len} pixels (ETA: {eta})", pb
)); }
pub fn get_pixels_progressbar(total: u64) -> ProgressBar {
get_progressbar(
total,
"{spinner:.green} [{elapsed_precise}] [{wide_bar:.cyan/blue}] {percent:>3}%: {pos}/{len} pixels (ETA: {eta})",
)
}
pub fn get_passes_progressbar(total: u32) -> ProgressBar {
let pb = get_progressbar(
total as u64,
"{spinner:.green} [{elapsed_precise}] [{wide_bar:.cyan/blue}] {percent:>3}%: {pos}/{len} passes (ETA: {eta})",
);
pb.enable_steady_tick(1000);
pb pb
} }

View file

@ -40,7 +40,7 @@ impl Raytracer {
); );
let total = (image.width() * image.height()) as u64; let total = (image.width() * image.height()) as u64;
let pb = super::super::progress::get_progressbar(total); let pb = super::super::progress::get_pixels_progressbar(total);
let pixel_func = if self.scene.shot_rays > 0 { let pixel_func = if self.scene.shot_rays > 0 {
Self::anti_alias_pixel Self::anti_alias_pixel