Skip to content

Commit b6cb828

Browse files
committed
additional changes to allow for progressbars
1 parent 8288ee9 commit b6cb828

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

src/renderer.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::thread;
1515
use std::sync::Arc;
1616
use std::sync::mpsc;
1717

18-
use atomic_counter::AtomicCounter;
18+
use atomic_counter::{AtomicCounter, RelaxedCounter};
1919

2020

2121
pub struct FractalRenderer {
@@ -257,7 +257,9 @@ impl FractalRenderer {
257257

258258
// Check to see if the series approximation order has changed intraframe
259259
if self.series_approximation.order != (self.series_approximation.coefficients[0].len() - 1) {
260-
// println!("order was: {}, is now: {}", (self.series_approximation.coefficients[0].len() - 1), self.series_approximation.order);
260+
// TODO make it so that the value is set back to zero, rather than remade
261+
// self.progress.reset_series_approximation();
262+
261263
self.series_approximation.generate_approximation(&self.center_reference, &self.progress.series_approximation);
262264
}
263265
}
@@ -436,6 +438,8 @@ impl FractalRenderer {
436438
});
437439

438440
let glitched_pixels = pixel_data.len() as f64;
441+
self.progress.glitched_maximum.add(pixel_data.len());
442+
439443
let complete_pixels = total_pixels - glitched_pixels;
440444

441445
let (tx, rx) = mpsc::channel();
@@ -468,7 +472,7 @@ impl FractalRenderer {
468472
let mut glitch_reference = self.series_approximation.get_reference(glitch_reference_pixel.delta_centre, &self.center_reference);
469473

470474
correction_references += 1;
471-
glitch_reference.run(&self.progress.reference, &self.progress.reference_maximum);
475+
glitch_reference.run(&Arc::new(RelaxedCounter::new(0)), &Arc::new(RelaxedCounter::new(0)));
472476

473477
let delta_current_reference = self.series_approximation.evaluate(glitch_reference_pixel.delta_centre, glitch_reference.start_iteration);
474478

@@ -521,7 +525,7 @@ impl FractalRenderer {
521525

522526
self.render_time = frame_time.elapsed().as_millis();
523527

524-
self.progress.reset(self.maximum_iteration);
528+
self.progress.reset();
525529

526530
if self.show_output {
527531
print!("| {:<15}", saving_time.elapsed().as_millis());

src/util/progress.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ pub struct ProgressCounters {
77
pub reference_maximum: Arc<RelaxedCounter>,
88
pub series_approximation: Arc<RelaxedCounter>,
99
pub series_validation: Arc<RelaxedCounter>,
10-
pub iteration: Arc<RelaxedCounter>
10+
pub iteration: Arc<RelaxedCounter>,
11+
pub glitched_maximum: Arc<RelaxedCounter>,
1112
}
1213

1314
impl ProgressCounters {
@@ -18,14 +19,21 @@ impl ProgressCounters {
1819
series_approximation: Arc::new(RelaxedCounter::new(0)),
1920
series_validation: Arc::new(RelaxedCounter::new(0)),
2021
iteration: Arc::new(RelaxedCounter::new(0)),
22+
glitched_maximum: Arc::new(RelaxedCounter::new(0)),
2123
}
2224
}
2325

24-
pub fn reset(&mut self, maximum_iteration: usize) {
25-
self.reference = Arc::new(RelaxedCounter::new(0));
26-
self.reference_maximum = Arc::new(RelaxedCounter::new(maximum_iteration));
27-
self.series_approximation = Arc::new(RelaxedCounter::new(0));
26+
// TODO just set these to zero rather than reset
27+
// Reset without the series approximation changed
28+
pub fn reset(&mut self) {
2829
self.series_validation = Arc::new(RelaxedCounter::new(0));
2930
self.iteration = Arc::new(RelaxedCounter::new(0));
31+
self.glitched_maximum = Arc::new(RelaxedCounter::new(0));
32+
}
33+
34+
// TODO just set these to zero rather than reset
35+
// Reset with the series approximation changed
36+
pub fn reset_series_approximation(&mut self) {
37+
self.series_approximation = Arc::new(RelaxedCounter::new(0));
3038
}
3139
}

0 commit comments

Comments
 (0)