Skip to content

Commit acb0d7c

Browse files
committed
added max valid iterations
1 parent 81aa09e commit acb0d7c

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

src/math/series_approximation.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub struct SeriesApproximation {
2020
approximation_probes: Vec<Vec<ComplexExtended>>,
2121
approximation_probes_derivative: Vec<Vec<ComplexExtended>>,
2222
pub min_valid_iteration: usize,
23+
pub max_valid_iteration: usize,
2324
pub valid_iterations: Vec<usize>,
2425
pub valid_interpolation: Vec<usize>,
2526
pub probe_sampling: usize,
@@ -49,6 +50,7 @@ impl SeriesApproximation {
4950
approximation_probes: Vec::new(),
5051
approximation_probes_derivative: Vec::new(),
5152
min_valid_iteration: 1,
53+
max_valid_iteration: 1,
5254
valid_iterations: Vec::new(),
5355
valid_interpolation: Vec::new(),
5456
probe_sampling,
@@ -360,6 +362,8 @@ impl SeriesApproximation {
360362
}
361363
}
362364

365+
self.max_valid_iteration = self.valid_interpolation.iter().max().unwrap().clone();
366+
363367
// println!("series approximation valid interpolation buffer:");
364368
// let temp_size = self.probe_sampling - 1;
365369
// for i in 0..temp_size {

src/renderer.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ impl FractalRenderer {
217217
self.center_reference.run(&self.progress.reference, &self.progress.reference_maximum, &stop_flag);
218218

219219
if stop_flag.get() >= 1 {
220+
self.progress.reset();
220221
self.render_time = frame_time.elapsed().as_millis();
221222
return;
222223
};
@@ -244,6 +245,7 @@ impl FractalRenderer {
244245
}
245246

246247
if stop_flag.get() >= 1 {
248+
self.progress.reset();
247249
self.render_time = frame_time.elapsed().as_millis();
248250
return;
249251
};
@@ -276,9 +278,12 @@ impl FractalRenderer {
276278
&self.center_reference,
277279
&self.progress.series_validation);
278280

279-
self.progress.min_series_approximation.add(self.series_approximation.min_valid_iteration);
281+
// -1 because we already know that 1 iteration can be skipped (take z = c)
282+
self.progress.min_series_approximation.add(self.series_approximation.min_valid_iteration - 1);
283+
self.progress.max_series_approximation.add(self.series_approximation.max_valid_iteration - 1);
280284

281285
if stop_flag.get() >= 1 {
286+
self.progress.reset();
282287
self.render_time = frame_time.elapsed().as_millis();
283288
return;
284289
};
@@ -377,6 +382,7 @@ impl FractalRenderer {
377382
};
378383

379384
if stop_flag.get() >= 1 {
385+
self.progress.reset();
380386
self.render_time = frame_time.elapsed().as_millis();
381387
return;
382388
};
@@ -470,6 +476,7 @@ impl FractalRenderer {
470476

471477
if stop_flag.get() >= 1 {
472478
self.render_time = frame_time.elapsed().as_millis();
479+
self.progress.reset();
473480
return;
474481
};
475482

src/util/progress.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pub struct ProgressCounters {
77
pub reference_maximum: Arc<RelaxedCounter>,
88
pub series_approximation: Arc<RelaxedCounter>,
99
pub min_series_approximation: Arc<RelaxedCounter>,
10+
pub max_series_approximation: Arc<RelaxedCounter>,
1011
pub series_validation: Arc<RelaxedCounter>,
1112
pub iteration: Arc<RelaxedCounter>,
1213
pub glitched_maximum: Arc<RelaxedCounter>,
@@ -18,7 +19,8 @@ impl ProgressCounters {
1819
reference: Arc::new(RelaxedCounter::new(0)),
1920
reference_maximum: Arc::new(RelaxedCounter::new(maximum_iteration - 1)),
2021
series_approximation: Arc::new(RelaxedCounter::new(0)),
21-
min_series_approximation: Arc::new(RelaxedCounter::new(0)),
22+
min_series_approximation: Arc::new(RelaxedCounter::new(1)),
23+
max_series_approximation: Arc::new(RelaxedCounter::new(1)),
2224
series_validation: Arc::new(RelaxedCounter::new(0)),
2325
iteration: Arc::new(RelaxedCounter::new(0)),
2426
glitched_maximum: Arc::new(RelaxedCounter::new(0))
@@ -28,7 +30,8 @@ impl ProgressCounters {
2830
// TODO just set these to zero rather than reset
2931
// Reset without the series approximation changed
3032
pub fn reset(&mut self) {
31-
self.min_series_approximation = Arc::new(RelaxedCounter::new(0));
33+
self.min_series_approximation = Arc::new(RelaxedCounter::new(1));
34+
self.max_series_approximation = Arc::new(RelaxedCounter::new(1));
3235
self.series_validation = Arc::new(RelaxedCounter::new(0));
3336
self.iteration = Arc::new(RelaxedCounter::new(0));
3437
self.glitched_maximum = Arc::new(RelaxedCounter::new(0));

0 commit comments

Comments
 (0)