#[expect(
clippy::cast_possible_truncation,
reason = "C truncation as in Recast; saturating on out-of-range values"
)]
pub(crate) fn trunc_i32(x: f32) -> i32 {
x as i32
}
#[expect(
clippy::cast_possible_truncation,
reason = "C truncation of an integral value as in Recast; saturating on out-of-range values"
)]
pub(crate) fn floor_i32(x: f32) -> i32 {
x.floor() as i32
}
#[expect(
clippy::cast_possible_truncation,
reason = "C truncation of an integral value as in Recast; saturating on out-of-range values"
)]
pub(crate) fn ceil_i32(x: f32) -> i32 {
x.ceil() as i32
}
#[expect(
clippy::cast_precision_loss,
reason = "C int to float conversion; values above 2^24 round as in C"
)]
pub(crate) fn i32_to_f32(i: i32) -> f32 {
i as f32
}
#[expect(
clippy::cast_possible_truncation,
clippy::cast_sign_loss,
reason = "C truncation as in Detour; saturating on out-of-range values"
)]
pub(crate) fn trunc_u16(x: f32) -> u16 {
x as u16
}
#[expect(
clippy::cast_possible_truncation,
clippy::cast_sign_loss,
reason = "C truncation as in Detour; saturating on out-of-range values"
)]
pub(crate) fn trunc_u8(x: f32) -> u8 {
x as u8
}
#[expect(
clippy::cast_possible_truncation,
clippy::cast_sign_loss,
reason = "wrapping as in the C code (spec 6.4): negative heights become large unsigned values"
)]
pub(crate) fn wrap_u32(x: f32) -> u32 {
(x as i64) as u32
}