Skip to content

rust: Port libobs/graphics/math-extra.c to obs-graphics #351

Closed

Description

@nathan-v

Unit

libobs/graphics/math-extra.c to obs-graphics.

Phase and position

Phase 5, last graphics-math unit in docs/rust-port/testing-policy.md (after bounds.c, #344). Tracking issue #45.

Dependencies and existing tests

Depends on vec2 and vec3, which are already ported. No cmocka characterization test exists; it lands first in this port. vec3_rand calls rand_float.

Notes

get_percentage and get_percentagei are header-inline and stay C. No new public struct, so there is no layout test.

polar_to_cart, and cart_to_polar when the length is outside EPSILON, copy an uninitialized w (vec3_copy of a local that never writes w). polar_to_norm does not write w. vec3_close is one-sided (component < epsilon, not an absolute difference), so calc_torque treats some far-apart pairs as equal. rand_float draws from the C library rand. No SIMD.

Activity

  1. nathan-v commented on Oct 12, 2026

    @nathan-v
    ContributorAuthor

    Claiming: libobs/graphics/math-extra.c

    1. Characterization commit: test/cmocka/test_math_extra.c pins the current exports. Header-inline get_percentage and get_percentagei stay C. The test does not read w after polar_to_cart or a non-zero cart_to_polar (that lane is uninitialized in C).
    2. RED: Tier 1 tests against empty stubs (zero vectors and 0.0).
    3. GREEN: safe core, C shims, Tier 3 parity against obs-c-oracle, ENABLE_RUST_LIBOBS drops graphics/math-extra.c, export fragment libobs/cmake/rust-exports.d/obs-graphics-math_extra.txt. Remove the oracle's unrenamed rand_float host so the Rust shim provides it for vec3_rand.

    First PR today, after this comment. Please add the claimed label; I cannot.

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