Time: synced comp times reach the final partial frame too

Synchronize Time of All Related Items clamped each related comp's time
with its own duration-minus-one-frame rule, so a nested comp whose
duration is off the frame grid could not reach its final partial frame.
Use comp_frame_at, as direct moves and restored times do.
This commit is contained in:
nazar-gavrylyk
2026-11-11 10:19:45 +01:00
parent c344ff8c23
commit 5f1c5ad404
2 changed files with 16 additions and 3 deletions
+3 -3
View File
@@ -147,8 +147,8 @@ impl Session {
/// Sets the time of every comp related to `comp` through precomp layers: down into the comps
/// it nests (through each layer's timing) and up into the comps nesting it. A seen-set keeps
/// cycles and diamonds finite; each found time is clamped to its comp's last frame, snapped to
/// the nearest frame and stored in `state.times`. The caller owns the text-editor boundary.
/// cycles and diamonds finite; each found time goes through [`comp_frame_at`] (as a direct move
/// does) and is stored in `state.times`. The caller owns the text-editor boundary.
fn sync_related_times_inner(&mut self, comp: ItemId, t: Tick) {
let mut seen = std::collections::BTreeSet::from([comp]);
let mut todo = vec![(comp, t)];
@@ -178,7 +178,7 @@ impl Session {
}
for (cid, ct) in found {
if let Some(c) = self.project.comp(cid) {
let ct = c.frame_rate.snap_nearest(ct.clamp(Tick::ZERO, (c.duration - c.frame_duration()).max(Tick::ZERO)));
let ct = comp_frame_at(c, ct);
self.state.times.insert(cid, ct);
}
}
+13
View File
@@ -490,6 +490,19 @@ fn fitted_layers_in_the_final_partial_frame_get_the_playhead() {
assert_eq!(s.time(), effectcraft_time::Tick::from_seconds_f64(2.0));
}
/// Synchronize Time of All Related Items reaches a nested comp's final partial frame as a direct
/// move does: the inner comp is 2.01 s (set at 100 fps, then 24 fps), the outer sits at 2.0 s.
#[test]
fn synced_time_reaches_a_nested_final_partial_frame() {
let mut s = Session::default();
let inner = s.execute("comp.new", json!({"name": "Inner", "duration": 2.01, "frameRate": 100, "open": false})).unwrap()["comp"].as_u64().unwrap();
s.execute("comp.settings", json!({"comp": inner, "frameRate": 24})).unwrap();
s.execute("comp.new", json!({"name": "Outer", "duration": 4, "frameRate": 24})).unwrap();
s.execute("layer.addItem", json!({"item": inner, "time": 0})).unwrap();
s.set_time(effectcraft_time::Tick::from_seconds_f64(2.0));
assert_eq!(s.time_of(effectcraft_project::ItemId(inner)), effectcraft_time::Tick::from_seconds_f64(2.0));
}
#[test]
fn default_spatial_interpolation_linear() {
let mut s = session_with_comp();