Skip to content

Commit 423f397

Browse files
committed
fix: sync decay-gamma on config load and validate new diffusion/decay knobs
1 parent e2102ba commit 423f397

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

src/app/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ pub fn apply_live_params(
106106
new_config.diffusion_kernel = runtime_state.diffusion_kernel;
107107
new_config.diffusion_sigma = runtime_state.diffusion_sigma;
108108
new_config.diffuse_weight = runtime_state.diffuse_weight;
109+
new_config.decay_gamma = runtime_state.decay_gamma;
109110
new_config.max_brightness = runtime_state.max_brightness;
110111
new_config.terrain = runtime_state.terrain_type;
111112
new_config.terrain_strength = runtime_state.terrain_strength;

src/simulation/config.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1891,6 +1891,10 @@ impl Validatable for SimConfig {
18911891
rules::DECAY_FACTOR.validate_f32(self.decay_factor)?;
18921892
rules::MAX_BRIGHTNESS.validate_f32(self.max_brightness)?;
18931893
rules::DIFFUSION_SIGMA.validate_f32(self.diffusion_sigma)?;
1894+
rules::DECAY_GAMMA.validate_f32(self.decay_gamma)?;
1895+
rules::AFTERGLOW.validate_f32(self.afterglow)?;
1896+
rules::AFTERGLOW_RATE.validate_f32(self.afterglow_rate)?;
1897+
rules::DIFFUSE_WEIGHT.validate_f32(self.diffuse_weight)?;
18941898

18951899
// Validate time and environment parameters
18961900
rules::TIME_SCALE.validate_f32(self.time_scale)?;
@@ -2620,6 +2624,30 @@ mod tests {
26202624
);
26212625
assert_eq!(c.decay_gamma, 1.0, "decay_gamma=1 == current decay");
26222626
}
2627+
2628+
#[test]
2629+
fn validate_decay_gamma_rejects_out_of_range() {
2630+
let config = SimConfig {
2631+
decay_gamma: 9999.0,
2632+
..SimConfig::default()
2633+
};
2634+
assert!(
2635+
config.validate().is_err(),
2636+
"decay_gamma=9999.0 must be rejected"
2637+
);
2638+
}
2639+
2640+
#[test]
2641+
fn validate_decay_gamma_accepts_valid() {
2642+
let config = SimConfig {
2643+
decay_gamma: 1.0,
2644+
..SimConfig::default()
2645+
};
2646+
assert!(
2647+
config.validate().is_ok(),
2648+
"decay_gamma=1.0 must be accepted"
2649+
);
2650+
}
26232651
}
26242652

26252653
#[cfg(test)]

0 commit comments

Comments
 (0)