mirror of
https://github.com/storytold/filmcraft.git
synced 2026-10-29 12:38:06 -06:00
Problem: a Final Cut 7 XML whose Basic Motion filter sets only `scale` makes the importer add the Motion effect with its defaults, where `position` and `anchor` are the NaN "auto" sentinel. Placing a clip resolves those with `resolve_auto_points`; the interchange import did not (any format: the clips are built with the effect defaults). serde_json writes NaN as `null`, and the reader then refused the file: "project file is damaged: invalid type: null, expected f64". The project could be saved but never opened again. Solution: - project: a point parameter's value (`ParamValue::Vec2`) reads a `null` coordinate back as NaN, so "auto" survives a save. Only there: `Vec2` itself is unchanged, and a `null` in a mask vertex or any other point is still a damaged file. - project: `Project::resolve_placed_auto_points` resolves the points of the clips in chosen sequences. Points measured in the frame use the sequence size. `anchor` is measured in the clip's source (`Project::source_size`, a subclip through its parent, as the renderer resolves it) and is resolved only for sources the caller says have their final size. - engine: the import resolves in the edits it already makes, so the undo steps are what they were. In "Import ...": everything but the anchors of file media, whose size is only what the document says so far (an EDL says nothing and the importer assumes the sequence size). In each "Link Media": the anchors of that file's clips, from the probed size. A clip whose file is not found keeps an "auto" anchor, which the renderer centres in whatever size the media has, as before this change. - engine: a later Link Media (relink.rs `apply`, behind `media.relink` and `media.autoRelink`) resolves those waiting anchors in its own undo step, when it has read the file. Nothing else resolves them: a file that merely comes back at its old path, or a forced relink that does not read the file, leaves the anchor "auto" (still rendered centred). Why no schema step and no repair on load: the file's shape is not changed. Files with `null` points were written by every build before this one, at the current schema version, so a migration (keyed on the version) cannot select them, and a bump would only make every new project unreadable to those builds. They open now and their points are "auto", exactly as in the session that wrote them; resolving them on load would mean guessing the size of media that was never linked. docs/project-files.md describes `null` points. Tests: project `point_params_keep_auto_through_json_and_no_other_point_reads_null` and `placed_auto_points_resolve_once_the_source_size_is_final`; format `auto_points_written_as_null_open_again`; engine (interchange_auto_points_tests.rs): import with the media missing, save, reopen, undo, redo; a linked file whose real size differs from the declared and the sequence size (undo of Link Media and of the import, redo); an EDL clip smaller than its sequence; import with the media missing, save, reopen, relink (anchor becomes a number, undo, redo, a second relink leaves it). All fail without the change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>