Skip to content

Commit 0287a6f

Browse files
committed
added option to disable series approximation
1 parent 243d021 commit 0287a6f

File tree

3 files changed

+46
-19
lines changed

3 files changed

+46
-19
lines changed

default.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ data_storage_interval = 100
1919

2020
valid_iteration_probe_multiplier = 0.01
2121

22-
experimental = true
22+
series_approximation_tiled = true
23+
series_approximation_enabled = true
2324

2425
coloring_type = "iteration"
2526

src/math/series_approximation.rs

+27-6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub struct SeriesApproximation {
1212
pub maximum_iteration: usize,
1313
pub delta_pixel_square: FloatExtended,
1414
pub order: usize,
15+
pub generated_order: usize,
1516
pub coefficients: Vec<Vec<ComplexExtended>>,
1617
probe_start: Vec<ComplexExtended>,
1718
approximation_probes: Vec<Vec<ComplexExtended>>,
@@ -21,7 +22,8 @@ pub struct SeriesApproximation {
2122
pub valid_iterations: Vec<usize>,
2223
pub valid_interpolation: Vec<usize>,
2324
pub probe_sampling: usize,
24-
pub experimental: bool,
25+
pub tiled: bool,
26+
pub enabled: bool,
2527
pub valid_iteration_probe_multiplier: f32,
2628
pub data_storage_interval: usize,
2729
pub fractal_type: FractalType
@@ -32,7 +34,8 @@ impl SeriesApproximation {
3234
maximum_iteration: usize,
3335
delta_pixel_square: FloatExtended,
3436
probe_sampling: usize,
35-
experimental: bool,
37+
tiled: bool,
38+
enabled: bool,
3639
valid_iteration_probe_multiplier: f32,
3740
data_storage_interval: usize,
3841
fractal_type: FractalType) -> Self {
@@ -42,6 +45,7 @@ impl SeriesApproximation {
4245
maximum_iteration,
4346
delta_pixel_square,
4447
order,
48+
generated_order: 0,
4549
coefficients: Vec::new(),
4650
probe_start: Vec::new(),
4751
approximation_probes: Vec::new(),
@@ -51,14 +55,20 @@ impl SeriesApproximation {
5155
valid_iterations: Vec::new(),
5256
valid_interpolation: Vec::new(),
5357
probe_sampling,
54-
experimental,
58+
tiled,
59+
enabled,
5560
valid_iteration_probe_multiplier,
5661
data_storage_interval,
5762
fractal_type
5863
}
5964
}
6065

6166
pub fn generate_approximation(&mut self, center_reference: &Reference, series_approximation_counter: &Arc<AtomicUsize>, stop_flag: &Arc<AtomicBool>) {
67+
if !self.enabled {
68+
series_approximation_counter.store(1, Ordering::SeqCst);
69+
return;
70+
}
71+
6272
series_approximation_counter.store(0, Ordering::SeqCst);
6373

6474
// Reset the coefficients
@@ -116,6 +126,9 @@ impl SeriesApproximation {
116126

117127
// self.coefficients.push(next_coefficients);
118128
}
129+
130+
// TODO maybe need something here to say series approximation was complete
131+
self.generated_order = self.order;
119132
}
120133

121134
pub fn check_approximation(&mut self,
@@ -128,6 +141,15 @@ impl SeriesApproximation {
128141
image_height: usize,
129142
center_reference: &Reference,
130143
series_validation_counter: &Arc<AtomicUsize>) {
144+
145+
if !self.enabled {
146+
self.min_valid_iteration = 1;
147+
self.max_valid_iteration = 1;
148+
149+
series_validation_counter.store(2, Ordering::SeqCst);
150+
return;
151+
}
152+
131153
series_validation_counter.store(0, Ordering::SeqCst);
132154

133155
// Delete the previous probes and calculate new ones
@@ -396,9 +418,8 @@ impl SeriesApproximation {
396418
self.valid_interpolation.push(min_interpolation);
397419
}
398420
}
399-
400421

401-
self.max_valid_iteration = if self.experimental {
422+
self.max_valid_iteration = if self.tiled {
402423
*self.valid_interpolation.iter().max().unwrap()
403424
} else {
404425
self.min_valid_iteration
@@ -422,7 +443,7 @@ impl SeriesApproximation {
422443
// print!("\x08]\n");
423444
// }
424445

425-
if !self.experimental {
446+
if !self.tiled {
426447
self.valid_interpolation = vec![self.min_valid_iteration; (self.probe_sampling - 1) * (self.probe_sampling - 1)];
427448
}
428449
}

src/renderer.rs

+17-12
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ pub struct FractalRenderer {
4242
pub pixel_data_type: DataType,
4343
pub jitter: bool,
4444
pub jitter_factor: f64,
45-
pub experimental: bool,
4645
show_output: bool,
4746
pub progress: ProgressCounters,
4847
pub render_time: u128,
@@ -68,8 +67,11 @@ impl FractalRenderer {
6867
let frame_offset = settings.get_int("frame_offset").unwrap_or(0) as usize;
6968
let zoom_scale_factor = settings.get_float("zoom_scale").unwrap_or(2.0);
7069
let display_glitches = settings.get_bool("display_glitches").unwrap_or(false);
70+
7171
let auto_adjust_iterations = settings.get_bool("auto_adjust_iterations").unwrap_or(true);
72-
let experimental = settings.get_bool("experimental").unwrap_or(false);
72+
let series_approximation_tiled = settings.get_bool("series_approximation_tiled").unwrap_or(true);
73+
let series_approximation_enabled = settings.get_bool("series_approximation_enabled").unwrap_or(true);
74+
7375
let probe_sampling = settings.get_int("probe_sampling").unwrap_or(3) as usize;
7476
let remove_centre = settings.get_bool("remove_centre").unwrap_or(false);
7577

@@ -176,7 +178,8 @@ impl FractalRenderer {
176178
maximum_iteration,
177179
FloatExtended::new(0.0, 0),
178180
probe_sampling,
179-
experimental,
181+
series_approximation_tiled,
182+
series_approximation_enabled,
180183
valid_iteration_probe_multiplier,
181184
data_storage_interval,
182185
fractal_type);
@@ -237,7 +240,6 @@ impl FractalRenderer {
237240
pixel_data_type,
238241
jitter,
239242
jitter_factor,
240-
experimental,
241243
show_output,
242244
progress: ProgressCounters::new(maximum_iteration),
243245
render_time: 0,
@@ -302,7 +304,7 @@ impl FractalRenderer {
302304
tx.send(()).unwrap();
303305
return;
304306
};
305-
307+
306308
self.series_approximation.maximum_iteration = self.center_reference.current_iteration;
307309
self.series_approximation.generate_approximation(&self.center_reference, &self.progress.series_approximation, &stop_flag);
308310
} else {
@@ -322,7 +324,7 @@ impl FractalRenderer {
322324
drop(export);
323325

324326
// Check to see if the series approximation order has changed intraframe
325-
if self.series_approximation.order != (self.series_approximation.coefficients[0].len() - 1) {
327+
if self.series_approximation.enabled && self.series_approximation.order != self.series_approximation.generated_order {
326328
self.series_approximation.min_valid_iteration = 1;
327329
self.series_approximation.generate_approximation(&self.center_reference, &self.progress.series_approximation, &stop_flag);
328330
}
@@ -360,13 +362,12 @@ impl FractalRenderer {
360362
-self.zoom.exponent,
361363
cos_rotate,
362364
sin_rotate,
363-
delta_pixel,
365+
delta_pixel,
364366
self.image_width,
365367
self.image_height,
366368
&self.center_reference,
367369
&self.progress.series_validation);
368370

369-
// -1 because we already know that 1 iteration can be skipped (take z = c)
370371
self.progress.min_series_approximation.store(self.series_approximation.min_valid_iteration, Ordering::SeqCst);
371372
self.progress.max_series_approximation.store(self.series_approximation.max_valid_iteration, Ordering::SeqCst);
372373

@@ -402,8 +403,8 @@ impl FractalRenderer {
402403
let mut i = (index % self.image_width) as f64;
403404
let mut j = (index / self.image_width) as f64;
404405

405-
let chosen_iteration = if self.fractal_type == FractalType::Mandelbrot2 {
406-
if self.experimental {
406+
let chosen_iteration = if self.series_approximation.enabled {
407+
if self.series_approximation.tiled {
407408
let test1 = (i * sampling_resolution_width).floor() as usize;
408409
let test2 = (j * sampling_resolution_height).floor() as usize;
409410

@@ -809,7 +810,10 @@ impl FractalRenderer {
809810
self.zoom_scale_factor = settings.get_float("zoom_scale").unwrap_or(2.0);
810811
self.data_export.lock().display_glitches = settings.get_bool("display_glitches").unwrap_or(false);
811812
self.auto_adjust_iterations = settings.get_bool("auto_adjust_iterations").unwrap_or(true);
812-
self.experimental = settings.get_bool("experimental").unwrap_or(false);
813+
814+
let series_approximation_tiled = settings.get_bool("series_approximation_tiled").unwrap_or(true);
815+
let series_approximation_enabled = settings.get_bool("series_approximation_enabled").unwrap_or(true);
816+
813817
let probe_sampling = settings.get_int("probe_sampling").unwrap_or(3) as usize;
814818
self.remove_centre = settings.get_bool("remove_centre").unwrap_or(true);
815819

@@ -878,7 +882,8 @@ impl FractalRenderer {
878882
self.maximum_iteration,
879883
FloatExtended::new(0.0, 0),
880884
probe_sampling,
881-
self.experimental,
885+
series_approximation_tiled,
886+
series_approximation_enabled,
882887
valid_iteration_probe_multiplier,
883888
data_storage_interval,
884889
self.fractal_type);

0 commit comments

Comments
 (0)