mirror of
https://github.com/storytold/effectcraft.git
synced 2026-10-28 20:16:52 -06:00
Split effect upgrade step out of upgrade_effects to cut cognitive complexity
Moves the per-group body into upgrade_effect_group. Behavior is unchanged; the engine test suite passes (664 tests).
This commit is contained in:
+26
-13
@@ -1218,19 +1218,7 @@ pub fn upgrade_effects(p: &mut Project) {
|
||||
let Some(fx) = l.props.sub_mut("effects") else { continue };
|
||||
for n in &mut fx.children {
|
||||
let effectcraft_project::Node::Group(g) = n else { continue };
|
||||
let effectcraft_project::GroupKind::Effect { effect } = &g.kind else { continue };
|
||||
if let Some(spec) = effectcraft_effects::find(effect) {
|
||||
let composite = legacy_particles
|
||||
&& matches!(spec.id, "ec.sim.ccparticlesystems2" | "ec.sim.ccparticleworld")
|
||||
&& g.get("compositeWithOriginal").is_none();
|
||||
effectcraft_effects::migrate::upgrade_instance(spec, g, &mut effectcraft_project::build::Ids(&mut next), size);
|
||||
if composite && let Some(pr) = g.get_mut("compositeWithOriginal") {
|
||||
pr.value = effectcraft_keyframe::Value::Bool(true);
|
||||
}
|
||||
if to_effect_space {
|
||||
effectcraft_effects::migrate::to_effect_space(spec, g, size, d, &clone_d);
|
||||
}
|
||||
}
|
||||
upgrade_effect_group(g, legacy_particles, to_effect_space, size, d, &clone_d, &mut next);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1239,6 +1227,31 @@ pub fn upgrade_effects(p: &mut Project) {
|
||||
p.saved_by = effectcraft_project::APP_VERSION.to_string();
|
||||
}
|
||||
|
||||
/// Upgrade one effect group of a layer: its instance, the legacy composite flag, and (when the
|
||||
/// project predates effect space) its positions.
|
||||
fn upgrade_effect_group(
|
||||
g: &mut effectcraft_project::PropGroup,
|
||||
legacy_particles: bool,
|
||||
to_effect_space: bool,
|
||||
size: [f64; 2],
|
||||
d: [f64; 2],
|
||||
clone_d: &dyn Fn(Option<u64>) -> [f64; 2],
|
||||
next: &mut u64,
|
||||
) {
|
||||
let effectcraft_project::GroupKind::Effect { effect } = &g.kind else { return };
|
||||
let Some(spec) = effectcraft_effects::find(effect.as_str()) else { return };
|
||||
let composite = legacy_particles
|
||||
&& matches!(spec.id, "ec.sim.ccparticlesystems2" | "ec.sim.ccparticleworld")
|
||||
&& g.get("compositeWithOriginal").is_none();
|
||||
effectcraft_effects::migrate::upgrade_instance(spec, g, &mut effectcraft_project::build::Ids(next), size);
|
||||
if composite && let Some(pr) = g.get_mut("compositeWithOriginal") {
|
||||
pr.value = effectcraft_keyframe::Value::Bool(true);
|
||||
}
|
||||
if to_effect_space {
|
||||
effectcraft_effects::migrate::to_effect_space(spec, g, size, d, clone_d);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod rq_tests;
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user