mirror of
https://github.com/storytold/effectcraft.git
synced 2026-11-20 09:05:51 +00:00
Merge upstream/main into cache-defaults-3298
This commit is contained in:
commit
6bea5fa6ae
66 files changed
+2992
-883
No files matched your search
@@ -2,7 +2,7 @@
|
||||
//! keyed with them. They hash derived `Debug` text, so `tests::analysis_signature` pins keys
|
||||
//! those releases saved: if a type change alters this text, write that part out here.
|
||||
|
||||
use effectcraft_project::{Footage, ItemId, ItemKind, Layer, LayerSource, Project, Uid};
|
||||
use effectcraft_project::{Footage, GroupKind, ItemId, ItemKind, Layer, LayerSource, ParamUi, Project, PropGroup, Uid};
|
||||
|
||||
use super::fnv;
|
||||
|
||||
@@ -41,12 +41,40 @@ pub(crate) fn input_key_of(mut s: String, layer: &Layer, uid: Uid) -> String {
|
||||
if g.uid == uid {
|
||||
break;
|
||||
}
|
||||
s.push_str(&format!("{g:?}"));
|
||||
s.push_str(&effect_text(g));
|
||||
}
|
||||
}
|
||||
format!("{:016x}", fnv(&s))
|
||||
}
|
||||
|
||||
/// Slider ranges as 0.22–0.24 gave them, for parameters whose range has changed since, as
|
||||
/// (effect, parameter path, [min, max, slider min, slider max], decimals). Those releases hashed
|
||||
/// each effect's UI hints into the Roto Brush Input Key, and opening a project replaces an
|
||||
/// instance's hints with the current ones, so [`effect_text`] puts these back. A range change
|
||||
/// above a Roto Brush would otherwise drop the analysis such a key kept: add a row with it.
|
||||
/// Not every range changed since 0.24.1 has its row yet (#3815).
|
||||
#[rustfmt::skip]
|
||||
const SLIDERS_0_24: &[(&str, &str, [f64; 4], u8)] = &[
|
||||
("ec.blur.gaussian", "blurriness", [0.0, 3000.0, 0.0, 50.0], 1),
|
||||
];
|
||||
|
||||
/// An effect instance as 0.22–0.24 wrote it into a Roto Brush Input Key: its derived `Debug`,
|
||||
/// with the [`SLIDERS_0_24`] ranges in place of today's.
|
||||
pub(crate) fn effect_text(g: &PropGroup) -> String {
|
||||
let GroupKind::Effect { effect } = &g.kind else { return format!("{g:?}") };
|
||||
let mut rows = SLIDERS_0_24.iter().filter(|r| r.0 == effect).peekable();
|
||||
if rows.peek().is_none() {
|
||||
return format!("{g:?}");
|
||||
}
|
||||
let mut g = g.clone();
|
||||
for &(_, path, [min, max, slider_min, slider_max], decimals) in rows {
|
||||
if let Some(p) = g.prop_mut(path).filter(|p| matches!(p.ui, ParamUi::Slider { .. })) {
|
||||
p.ui = ParamUi::Slider { min, max, slider_min, slider_max, decimals };
|
||||
}
|
||||
}
|
||||
format!("{g:?}")
|
||||
}
|
||||
|
||||
/// A footage item as 0.23–0.24 wrote it into a signature (without `placed_page` before 0.23),
|
||||
/// with `missing` in place of the item's.
|
||||
pub(crate) fn footage_text(f: &Footage, missing: bool, placed_page: bool) -> String {
|
||||
|
||||
@@ -5,7 +5,7 @@ use effectcraft_effects::camera_tracker::{TRACKS, TRACKS_KEY};
|
||||
use effectcraft_effects::roto::{FROZEN, INPUT_KEY};
|
||||
use effectcraft_effects::warp_stab::{ANALYSIS, ANALYSIS_KEY};
|
||||
use effectcraft_keyframe::Value;
|
||||
use effectcraft_project::{ItemId, LayerId, Project};
|
||||
use effectcraft_project::{GroupKind, ItemId, LayerId, ParamUi, Project};
|
||||
use serde_json::json;
|
||||
|
||||
use crate::Session;
|
||||
@@ -93,6 +93,19 @@ fn analyses_saved_by_0_24_survive_edits_that_keep_their_frames() {
|
||||
assert_eq!(saved(&s), before);
|
||||
}
|
||||
|
||||
/// 0.24 hashed each effect's UI hints into the Roto Brush's key, and opening a project takes the
|
||||
/// current ones: the legacy text puts back Gaussian Blur's 0.24 Blurriness range (#3460).
|
||||
#[test]
|
||||
fn legacy_roto_keys_hash_the_0_24_blurriness_range() {
|
||||
let s = open(ANALYSED_0_24);
|
||||
let layer = s.project.comp(COMP).unwrap().layer(CLIP).unwrap();
|
||||
let is_blur = |kind: &GroupKind| matches!(kind, GroupKind::Effect { effect } if effect == "ec.blur.gaussian");
|
||||
let blur = layer.effects().and_then(|fx| fx.groups().find(|g| is_blur(&g.kind))).expect("the fixture has a Gaussian Blur above the Roto Brush");
|
||||
let mut as_0_24 = blur.clone();
|
||||
as_0_24.get_mut("blurriness").unwrap().ui = ParamUi::Slider { min: 0.0, max: 3000.0, slider_min: 0.0, slider_max: 50.0, decimals: 1 };
|
||||
assert_eq!(crate::analysis::frames_key::legacy::effect_text(blur), format!("{as_0_24:?}"));
|
||||
}
|
||||
|
||||
/// The text keys are made from today, written field by field (#3536). It changes only when this
|
||||
/// test is changed with it: a new field of a type it writes doesn't compile until it is decided
|
||||
/// in `analysis::frames_key`, and renaming a field or variant doesn't change it.
|
||||
|
||||
@@ -60,6 +60,17 @@ const ROWS: &[(u32, &str, &str, f64, f64)] = &[
|
||||
(3471, "ec.distort.transform", "scaleHeight", -30000.0, 30000.0),
|
||||
(3471, "ec.distort.transform", "scaleWidth", -30000.0, 30000.0),
|
||||
(3470, "ec.distort.turbulentdisplace", "evolutionOptions/randomSeed", 0.0, 100000.0),
|
||||
(3464, "ec.perspective.dropshadow", "softness", 0.0, 30000.0),
|
||||
(3467, "ec.blur.radial", "amount", 0.0, 1000.0),
|
||||
(3460, "ec.blur.gaussian", "blurriness", 0.0, 30000.0),
|
||||
(3469, "ec.distort.turbulentdisplace", "amount", -10000.0, 10000.0),
|
||||
(3492, "ec.distort.ccpowerpin", "expandTop", -200.0, 1000.0),
|
||||
(3492, "ec.distort.ccpowerpin", "expandLeft", -200.0, 1000.0),
|
||||
(3492, "ec.distort.ccpowerpin", "expandRight", -200.0, 1000.0),
|
||||
(3492, "ec.distort.ccpowerpin", "expandBottom", -200.0, 1000.0),
|
||||
(3486, "ec.noise.fractal", "subSettings/subScaling", 10.0, 10000.0),
|
||||
(3486, "ec.noise.turbulent", "subSettings/subScaling", 10.0, 10000.0),
|
||||
(3466, "ec.blur.sharpen", "amount", 0.0, 4000.0),
|
||||
];
|
||||
|
||||
fn path(effect: &str, param: &str) -> String {
|
||||
@@ -161,6 +172,23 @@ fn projects_saved_with_the_narrower_ranges_open_with_the_new_ones() {
|
||||
}
|
||||
}
|
||||
|
||||
/// #3466: Sharpen Amount clamps just outside After Effects' 0..4000, and an undo after a
|
||||
/// clamped set restores the value from before it.
|
||||
#[test]
|
||||
fn sharpen_amount_clamps_outside_the_after_effects_range() {
|
||||
let (mut s, l, _) = session();
|
||||
let (e, p) = ("ec.blur.sharpen", "amount");
|
||||
for (v, want) in [(4001.0, 4000.0), (-1.0, 0.0)] {
|
||||
set(&mut s, l, e, p, 1000.0);
|
||||
assert_eq!(set(&mut s, l, e, p, v), json!(want), "{v}: prop.set reply");
|
||||
assert_eq!(read(&mut s, l, e, p), want, "{v}");
|
||||
assert!(s.undo());
|
||||
assert_eq!(read(&mut s, l, e, p), 1000.0, "{v}: undo");
|
||||
assert!(s.redo());
|
||||
assert_eq!(read(&mut s, l, e, p), want, "{v}: redo");
|
||||
}
|
||||
}
|
||||
|
||||
/// The property at `path` (`group/param`) in an effect instance.
|
||||
fn prop_mut<'a>(g: &'a mut PropGroup, path: &str) -> Option<&'a mut effectcraft_project::Property> {
|
||||
match path.split_once('/') {
|
||||
|
||||
Reference in new issue
Block a user