#783: Object Matte tool in the Composition viewer
Problem: Object Matte could only be applied through the objectMatte.apply command; After Effects 26.2 picks the object directly in the viewer (click it, or drag a box around it). Fix: an Object Matte tool (with Roto Brush & Refine Edge in the Alt+W slot, icon drawn in code). In the Composition viewer a click sets a point prompt and a drag a box prompt (its centre the point) on the footage, solid or comp layer under the pointer, converted to layer pixels through the layer's transform. The layer's Object Matte (the selected one, else its last) is re-prompted; Shift adds another. Everything goes through objectMatte.apply, which gained `effect` to re-prompt an instance (point, box or no box, reference frame; the reach kept unless given), so each prompt is one undo step; the effect is then selected, so its point controls show in the viewer. Hover draws a crosshair and the outline of the layer that would get the matte (a live matte preview would need a segmentation per pointer move). Automation ids: viewer.objectMatte.crosshair / .target / .box, tools.ObjectMatte. Tests: ui-egui ui_object_matte (hover, click, drag box re-prompts the same effect, Shift-click adds one, undo steps); engine tests_roto::object_matte_reprompt_updates_the_instance. Checked with the headless snapshot example (hover crosshair, box drag isolating a disk). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
4fc7b52351
commit
0c695cff77
@@ -426,3 +426,42 @@ fn object_matte_from_a_click() {
|
||||
let g = s.active_comp().unwrap().layer(clip).unwrap().props.find_group(r["effect"].as_u64().unwrap()).unwrap().clone();
|
||||
assert_eq!(g.name, "Object Matte 2");
|
||||
}
|
||||
|
||||
/// `objectMatte.apply` with `effect` re-prompts that instance in one undo step: the new point and
|
||||
/// box, the box dropped when none is given, the reach kept unless given.
|
||||
#[test]
|
||||
fn object_matte_reprompt_updates_the_instance() {
|
||||
let (mut s, clip, solid) = setup(|f| draw(center(f)));
|
||||
let cid = s.active_comp_id().unwrap();
|
||||
s.edit("remove solid", None, |p, _| {
|
||||
p.comp_mut(cid).unwrap().layers.retain(|l| l.id != solid);
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
let c = center(0);
|
||||
let r = s
|
||||
.execute_checked(
|
||||
"objectMatte.apply",
|
||||
json!({"layer": clip.0, "point": c, "box": [c[0] - 50.0, c[1] - 50.0, c[0] + 50.0, c[1] + 50.0], "after": 6, "frame": 0}),
|
||||
)
|
||||
.unwrap();
|
||||
let uid = r["effect"].as_u64().unwrap();
|
||||
let count = |s: &Session| s.active_comp().unwrap().layer(clip).unwrap().effects().unwrap().groups().count();
|
||||
let ps = |s: &Session| crate::roto::params_static(s.active_comp().unwrap().layer(clip).unwrap().props.find_group(uid).unwrap());
|
||||
let undo0 = s.history.undo.len();
|
||||
let r = s.execute_checked("objectMatte.apply", json!({"layer": clip.0, "effect": uid, "point": [c[0] + 4.0, c[1]], "frame": 2})).unwrap();
|
||||
assert_eq!((r["effect"].as_u64(), r["updated"].as_bool()), (Some(uid), Some(true)));
|
||||
assert_eq!(r["span"], json!([-28, 8]));
|
||||
assert_eq!(count(&s), 1);
|
||||
assert_eq!(s.history.undo.len(), undo0 + 1);
|
||||
let p = ps(&s);
|
||||
assert_eq!(p.get("objectPoint"), Some(&effectcraft_keyframe::Value::Vec2([c[0] + 4.0, c[1]])));
|
||||
assert_eq!(p.get("useBox"), Some(&effectcraft_keyframe::Value::Bool(false)));
|
||||
assert_eq!(effectcraft_effects::object_matte::reference_frame(&p), 2);
|
||||
assert_eq!(effectcraft_effects::object_matte::reach(&p), [30, 6]);
|
||||
// Undo restores the first prompt.
|
||||
s.execute("edit.undo", json!({})).unwrap();
|
||||
assert_eq!(ps(&s).get("useBox"), Some(&effectcraft_keyframe::Value::Bool(true)));
|
||||
// An unknown or non-Object Matte effect is refused.
|
||||
assert!(s.execute_checked("objectMatte.apply", json!({"layer": clip.0, "effect": 999_999, "point": c})).is_err());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user