Skip to content

rust: Port libobs/graphics/bounds.c to obs-graphics #343

Closed

Description

@nathan-v

Unit

libobs/graphics/bounds.c to obs-graphics.

Phase and position

Phase 5 graphics math. Policy order: quat.c, matrix3.c, matrix4.c, plane.c, bounds.c, axisang.c, math-extra.c. quat, matrix3, matrix4, and axisang are already on master. plane.c is open PR #338 and is not a dependency of this file. Tracking issue #45.

Dependencies and existing tests

Depends on vec3 (add, mul, min, max, abs, len, dot, transform, transform3x4, plane distance), matrix4_inv, and matrix3_transpose. It does not call any function in plane.c. struct plane is already in obs-graphics.

No cmocka test covers bounds.c. The characterization test lands first in the port PR.

Notes

Header-inline helpers (bounds_zero, bounds_copy, bounds_inside, bounds_vec3_inside, bounds_intersects_ray, bounds_intersects_line) stay C.

bounds_plane_test is declared bool and returns BOUNDS_OUTSIDE (1), BOUNDS_INSIDE (2), or BOUNDS_PARTIAL (3). The near and far corners leave w uninitialized, and vec3_plane_dist dots that lane. bounds_under_plane also leaves w uninitialized and dots it. bounds_intersects_obb calls matrix4_inv into an uninitialized matrix and, when |det| < 0.0005, C writes nothing.

The Rust core will define those three paths (w = 0, and a zero matrix when the inverse is rejected) and record them as intentional differences. Parity will not compare the uninitialized-w paths, and it will skip singular bounds_intersects_obb inputs.

Activity

  1. nathan-v commented on Oct 12, 2026

    @nathan-v
    ContributorAuthor

    Claiming: libobs/graphics/bounds.c

    1. Characterization commit: test/cmocka/test_bounds.c pins the current exports. Header-inline helpers stay C. bounds_plane_test and bounds_under_plane read an uninitialized w, and bounds_intersects_obb reads an uninitialized inverse when |det| < 0.0005, so those paths are not asserted from cmocka.
    2. RED commit: Tier 1 Rust tests against empty stubs (0 / false / None), and the failing test name recorded in the PR.
    3. GREEN commit: safe core, C shims, layout test, and a 256-case proptest against obs-c-oracle. bounds_under_plane sets w to 0. A rejected matrix4_inv uses a zero matrix. Both are intentional differences, excluded from parity, and named in rust/README.md. bounds_plane_test's safe API returns the 1/2/3 code; the exported byte matches whatever this compiler's bool conversion of that return actually stores.
    4. One PR, branch port/bounds, base master. I expect to open it today.

    Please add the claimed label. I cannot apply labels on an existing issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions