Skip to main content
← PSoXide SDK guides and examples · SDK f2fec1c301f1 · All Cargo features enabled; check feature gates before use.

crossing_fraction_q16_i32

Function crossing_fraction_q16_i32 

Source
pub fn crossing_fraction_q16_i32(
    first_distance: i32,
    second_distance: i32,
) -> u32
Expand description

Exact Q16 crossing fraction of an edge from its two signed plane distances.

(first << 16) / (first - second), clamped to 0..=65536, computed with 32-bit operations only: the R3000A has no 64-bit divide, and the earlier i64 form of this function was the last 64-bit division helper linked into the PXBSP world path. The magnitude runs through the hardware divide when first << 16 fits, and through div_u64_by_u32 otherwise; both are exact, so the result equals the wide form bit for bit.