#3087: an expression on Orientation is imported with its value or keys

An Orientation with an expression was reported as "not decoded" and lost its
value and keys too. The expression is stored in the otst's tdbs like on any
property, so it now arrives with the stored value or keys.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
arnav-hiwarkar
2026-11-11 16:45:55 +05:30
co-authored by Claude Opus 5.5
parent b55226320b
commit 1f38431faf
3 changed files with 57 additions and 9 deletions
+12 -6
View File
@@ -231,15 +231,21 @@ pub(crate) fn import_transform(
}
import_expression(&node, prop, col);
}
if let Some(PropNode::Other(_)) = group.get("ADBE Orientation") {
if let Some(PropNode::Other(otst)) = group.get("ADBE Orientation") {
match (layer.orientation(), target.get_mut("orientation")) {
(Some(o), Some(prop)) if !o.animated && !o.has_expression && sane(&Value::Vec3(o.degrees)) => prop.value = Value::Vec3(o.degrees),
(Some(o), Some(prop)) if o.animated || sane(&Value::Vec3(o.degrees)) => {
if o.animated {
import_orientation_keys(layer, layer_name, tm, prop, col);
} else {
prop.value = Value::Vec3(o.degrees);
}
// The expression is stored in the `otst`'s `tdbs` as on any property (#3087).
if let Some(node) = otst.child_list(b"tdbs").and_then(AepProp::from_chunk) {
import_expression(&node, prop, col);
}
}
// A layer without an orientation (an ambient light) loses nothing with the default.
(Some(o), None) if !o.animated && !o.has_expression && o.degrees == [0.0; 3] => {}
(Some(o), Some(prop)) if o.animated && !o.has_expression => import_orientation_keys(layer, layer_name, tm, prop, col),
(Some(o), Some(_)) if o.has_expression => {
col.lose(LossCategory::TransformProperties, format!("{layer_name}: ADBE Orientation expression (not decoded)"));
}
_ => col.lose(LossCategory::TransformProperties, format!("{layer_name}: ADBE Orientation")),
}
}
+42
View File
@@ -842,3 +842,45 @@ fn a_default_state_colour_record_holds_the_value() {
assert_eq!(colour(&default_state), colour(&written));
assert_ne!(colour(&default_state), colour(&unchanged), "the recorded colour, not the default");
}
/// #3087: an expression on Orientation arrives with the stored value, as on any property; it was
/// dropped together with the value and reported as "not decoded".
#[test]
fn an_orientation_expression_is_imported_with_its_value() {
let bytes = mutate(&mut |c| {
if !c.is_list(b"otst") {
return;
}
for child in c.children_mut() {
if child.is_list(b"tdbs") {
let Body::List { children, .. } = &mut child.body else { continue };
for k in children.iter_mut() {
if k.is(b"tdsb") {
set_data(k, 0, &1u32.to_be_bytes());
} else if k.is(b"tdb4") {
set_data(k, 120, &[1]);
}
}
children.push(Chunk::data(*b"Utf8", b"[0, time * 90, 0]".to_vec()));
} else if child.is_list(b"otky") {
for k in child.children_mut() {
let degrees: Vec<u8> = [10.0f64, 20.0, 30.0].iter().flat_map(|d| d.to_be_bytes()).collect();
set_data(k, 0, &degrees);
}
}
}
});
let (p, r) = run(&bytes, true);
assert_eq!(losses(&r.unwrap(), LossCategory::TransformProperties), Vec::<String>::new());
let mut seen = 0;
for item in p.items.values() {
let ItemKind::Comp(c) = &item.kind else { continue };
for layer in &c.layers {
let Some(o) = layer.transform().and_then(|t| t.prop("orientation")).filter(|o| o.expr.is_some()) else { continue };
assert_eq!(o.value, effectcraft_keyframe::Value::Vec3([10.0, 20.0, 30.0]), "{}", layer.name);
assert_eq!(o.expr.as_ref().map(|e| (e.text.as_str(), e.enabled)), Some(("[0, time * 90, 0]", true)), "{}", layer.name);
seen += 1;
}
}
assert!(seen > 0);
}
+3 -3
View File
File diff suppressed because one or more lines are too long