diff --git a/crates/engine/src/cmd/layer/parent.rs b/crates/engine/src/cmd/layer/parent.rs index dd4c842a2..8b345a95f 100644 --- a/crates/engine/src/cmd/layer/parent.rs +++ b/crates/engine/src/cmd/layer/parent.rs @@ -317,8 +317,12 @@ fn reexpress_orientation(correction: effectcraft_geom::Mat4, pr: &mut effectcraf // and the authored ones still to come) count against the cap. let budget = BAKE_MAX_KEYS.saturating_sub(keys.len() + authored.keys.len() - i); bake_between(correction, &authored, (key.time, converted[i]), (next.time, converted[i + 1]), BAKE_MAX_DEPTH, budget, &mut between); + // With the cap reached the segment can't be checked or subdivided: it keeps its authored easing between + // the converted keys, rather than becoming a straight blend that was never checked against the original. + if between.len() >= budget { + between.clear(); // An eased segment, or one that gained keys, becomes a run of straight blends. - if !between.is_empty() || key.out_interp != Interp::Linear || next.in_interp != Interp::Linear { + } else if !between.is_empty() || key.out_interp != Interp::Linear || next.in_interp != Interp::Linear { k.out_interp = Interp::Linear; k.out_ease.clear(); k.auto_bezier = false; diff --git a/crates/engine/src/tests/rig3d.rs b/crates/engine/src/tests/rig3d.rs index 0fef2434c..4c7c4edab 100644 --- a/crates/engine/src/tests/rig3d.rs +++ b/crates/engine/src/tests/rig3d.rs @@ -370,6 +370,11 @@ fn baked_orientation_keys_are_capped_across_the_whole_property() { s.execute("layer.setParent", json!({"layers": [light], "parent": nul})).unwrap(); let n = layer_in(&s, cid(&s), light).props.prop("transform/orientation").unwrap().keys.len(); assert!(n <= 4096, "{n} keys: the cap is for the property, not per segment"); + // the segments the cap left unchecked keep their authored easing instead of turning into straight blends + let orientation = layer_in(&s, cid(&s), light); + let keys = &orientation.props.prop("transform/orientation").unwrap().keys; + let last = keys.iter().rev().nth(1).expect("the penultimate key"); + assert_ne!(last.out_interp, effectcraft_keyframe::Interp::Linear, "the last segment keeps its authored easing"); } // ---------------------------------------------------------------- from 3D model