Skip to content

obs-scene: Port scene coordinate conversion - #1651

Merged
zackees merged 2 commits into
obs-rust:masterfrom
nathan-v:port/scene-coords
Oct 21, 2026
Merged

zackees merged 2 commits into
obs-rust:masterfrom
nathan-v:port/scene-coords

Conversation

@nathan-v

@nathan-v nathan-v commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1645

What and why

The scene coordinate conversion now lives in obs-scene::coords. Position, size, the half-pixel nudge, and the canvas scale match obs-scene-coords.c.h. The scene still reads the canvas with get_scene_dimensions. It still decides whether to nudge, and whether a group or a nested scene keeps its scale. Those wrappers stay in obs-scene.c.h.

The nine shims are not EXPORT. They are hidden the same way obs_bounds_fit_scale is. The C file moves from libobs.scene-coords to libobs.ported-scene-coords, so hybrid libobs links the Rust shims and the C reference keeps the original file.

test_scene_coords still compiles obs-scene-coords.c.h into itself. That cmocka test does not see the swap. Tier 3 does.

Kept, characterized, not endorsed: positive half-pixel ties go up, negative ties go toward zero, and the way back does not nudge. No intentional differences.

RED → GREEN

  • RED 701935691: soldr cargo test -p obs-data --test obs-tests-core scene::coords failed 8 tests. Each panicked not yet implemented (nudge_abs_rounds_to_a_half, nudge_skips_a_group, keep_scale_for_a_group_or_nested_scene, pos_to_absolute_on_a_1080p_canvas, pos_to_absolute_nudge_moves_a_quarter, pos_from_absolute_does_not_nudge, size_to_absolute_and_back, canvas_scale_follows_the_height).
  • GREEN 808361a42: those 8 passed. Tier 3 scene::coords::parity passed 3/3, including random_inputs_match_oracle over every f32 bit pattern. Dropping the nudge's + 0.5 failed cmocka_cases_match_oracle (nudge_abs: rust (0, 0.5), oracle (0.5, 1)). Reverted.
  • soldr cargo clippy -p obs-scene -p obs-c-oracle -p obs-data --all-targets -- -D warnings passed. ci/test_build_groups.py and ci/test_ported_sources.py passed. The three export_list tests in obs-util passed.
  • ./lint was not run. On this Mac it stops in pre-existing host tests. No stamp. Docker Tier 2 was not run here. PR CI runs it.
  • Real app: no behavior change.

Checklist

  • Base is master (or the description starts with a Stacked: note)
  • I claimed the issue, or no one else has an open PR for it
  • Characterization test (if the unit had none), then RED, then GREEN commits (characterization merged as test: Characterize scene coordinate conversion #1647; RED then GREEN are the two commits above)
  • User-visible change: its line in docs/features.md is added or updated (not applicable: no user-visible change)
  • (Optional) Local gate passed and the pushed head is stamped; otherwise PR CI runs the full suite
  • Warning or flag changes (-W..., ratchets): built with scripting ON (PR CI builds no OBS app: run gh workflow run ci.yml --ref <branch> for the full builds) and cross-checked with clang and MSVC (not applicable: no flag change)
  • Intentional differences from C listed in the parity test header and rust/README.md (ports): none

Tier 1 mirrors test_scene_coords. The core is todo!() until the port.
soldr cargo test -p obs-data --test obs-tests-core scene::coords
fails 8 tests, each panicking not yet implemented.
The safe core matches obs-scene-coords.c.h. The nine shims stay
hidden. The scene still reads the canvas and still decides nudge
and keep-scale. The C file moves to libobs.ported-scene-coords.

Tier 1 scene::coords is 8/8. Tier 3 parity is 3/3, including a
proptest over every f32 bit pattern. Dropping the nudge's + 0.5
failed cmocka_cases_match_oracle: rust (0, 0.5), oracle (0.5, 1).
Reverted. No intentional differences.

Fixes obs-rust#1645
@nathan-v

Copy link
Copy Markdown
Contributor Author

Rebased onto master after #1647 merged. This replaces 91f83df. The new head is 808361a (RED 7019356).

@nathan-v
nathan-v marked this pull request as ready for review October 21, 2026 20:22
@nathan-v
nathan-v requested a review from zackees as a code owner October 21, 2026 20:22
@zackees
zackees added this pull request to the merge queue Oct 21, 2026
Merged via the queue into obs-rust:master with commit 8bd52ed Oct 21, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

rust: Port the scene coordinate conversion in obs-scene.c to obs-scene

2 participants