#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct Vector2f {
pub x: f32,
pub y: f32,
}
const _: () = assert!(core::mem::size_of::<Vector2f>() == 8);
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct Vector3f {
pub x: f32,
pub y: f32,
pub z: f32,
}
const _: () = assert!(core::mem::size_of::<Vector3f>() == 12);
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct Vector4f {
pub x: f32,
pub y: f32,
pub z: f32,
pub w: f32,
}
const _: () = assert!(core::mem::size_of::<Vector4f>() == 16);
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct Quaternion {
pub x: f32,
pub y: f32,
pub z: f32,
pub w: f32,
}
const _: () = assert!(core::mem::size_of::<Quaternion>() == 16);
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct Matrix33f {
pub data: [[f32; 3]; 3],
}
const _: () = assert!(core::mem::size_of::<Matrix33f>() == 36);
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct Matrix44f {
pub data: [[f32; 4]; 4],
}
const _: () = assert!(core::mem::size_of::<Matrix44f>() == 64);
impl Vector2f {
#[inline]
pub const fn new(x: f32, y: f32) -> Self {
Self { x, y }
}
#[inline]
pub fn dot(self, other: Self) -> f32 {
self.x * other.x + self.y * other.y
}
#[inline]
pub fn length_squared(self) -> f32 {
self.dot(self)
}
#[inline]
pub fn length(self) -> f32 {
self.length_squared().sqrt()
}
}
impl core::ops::Add for Vector2f {
type Output = Self;
#[inline]
fn add(self, other: Self) -> Self {
Self {
x: self.x + other.x,
y: self.y + other.y,
}
}
}
impl core::ops::Sub for Vector2f {
type Output = Self;
#[inline]
fn sub(self, other: Self) -> Self {
Self {
x: self.x - other.x,
y: self.y - other.y,
}
}
}
impl core::ops::Mul for Vector2f {
type Output = Self;
#[inline]
fn mul(self, other: Self) -> Self {
Self {
x: self.x * other.x,
y: self.y * other.y,
}
}
}
impl core::ops::Div for Vector2f {
type Output = Self;
#[inline]
fn div(self, other: Self) -> Self {
Self {
x: self.x / other.x,
y: self.y / other.y,
}
}
}
impl core::ops::Mul<f32> for Vector2f {
type Output = Self;
#[inline]
fn mul(self, scalar: f32) -> Self {
Self {
x: self.x * scalar,
y: self.y * scalar,
}
}
}
impl core::ops::Div<f32> for Vector2f {
type Output = Self;
#[inline]
fn div(self, scalar: f32) -> Self {
let inv = 1.0f32 / scalar;
Self {
x: self.x * inv,
y: self.y * inv,
}
}
}
impl core::ops::Neg for Vector2f {
type Output = Self;
#[inline]
fn neg(self) -> Self {
Self {
x: -self.x,
y: -self.y,
}
}
}
impl Vector2f {
#[inline]
pub fn normalize(&mut self) {
unsafe { ffi::whiteout_v_Vector2f_normalize(self) }
}
#[inline]
pub fn normalized(self) -> Vector2f {
unsafe { ffi::whiteout_v_Vector2f_normalized(self) }
}
#[inline]
pub fn lerp(start: Vector2f, end: Vector2f, t: f32) -> Vector2f {
unsafe { ffi::whiteout_v_Vector2f_lerp(start, end, t) }
}
#[inline]
pub fn tcb_in_tangent(
prev: Vector2f,
current: Vector2f,
next: Vector2f,
tension: f32,
continuity: f32,
bias: f32,
) -> Vector2f {
unsafe {
ffi::whiteout_v_Vector2f_tcb_in_tangent(prev, current, next, tension, continuity, bias)
}
}
#[inline]
pub fn tcb_out_tangent(
prev: Vector2f,
current: Vector2f,
next: Vector2f,
tension: f32,
continuity: f32,
bias: f32,
) -> Vector2f {
unsafe {
ffi::whiteout_v_Vector2f_tcb_out_tangent(prev, current, next, tension, continuity, bias)
}
}
#[inline]
pub fn bezier_lerp(
start: Vector2f,
outtan: Vector2f,
intan: Vector2f,
end: Vector2f,
t: f32,
) -> Vector2f {
unsafe { ffi::whiteout_v_Vector2f_bezier_lerp(start, outtan, intan, end, t) }
}
#[inline]
pub fn hermite_lerp(
prev: Vector2f,
start: Vector2f,
end: Vector2f,
next: Vector2f,
t: f32,
) -> Vector2f {
unsafe { ffi::whiteout_v_Vector2f_hermite_lerp(prev, start, end, next, t) }
}
}
impl Vector3f {
#[inline]
pub const fn new(x: f32, y: f32, z: f32) -> Self {
Self { x, y, z }
}
#[inline]
pub fn dot(self, other: Self) -> f32 {
self.x * other.x + self.y * other.y + self.z * other.z
}
#[inline]
pub fn length_squared(self) -> f32 {
self.dot(self)
}
#[inline]
pub fn length(self) -> f32 {
self.length_squared().sqrt()
}
}
impl core::ops::Add for Vector3f {
type Output = Self;
#[inline]
fn add(self, other: Self) -> Self {
Self {
x: self.x + other.x,
y: self.y + other.y,
z: self.z + other.z,
}
}
}
impl core::ops::Sub for Vector3f {
type Output = Self;
#[inline]
fn sub(self, other: Self) -> Self {
Self {
x: self.x - other.x,
y: self.y - other.y,
z: self.z - other.z,
}
}
}
impl core::ops::Mul for Vector3f {
type Output = Self;
#[inline]
fn mul(self, other: Self) -> Self {
Self {
x: self.x * other.x,
y: self.y * other.y,
z: self.z * other.z,
}
}
}
impl core::ops::Div for Vector3f {
type Output = Self;
#[inline]
fn div(self, other: Self) -> Self {
Self {
x: self.x / other.x,
y: self.y / other.y,
z: self.z / other.z,
}
}
}
impl core::ops::Mul<f32> for Vector3f {
type Output = Self;
#[inline]
fn mul(self, scalar: f32) -> Self {
Self {
x: self.x * scalar,
y: self.y * scalar,
z: self.z * scalar,
}
}
}
impl core::ops::Div<f32> for Vector3f {
type Output = Self;
#[inline]
fn div(self, scalar: f32) -> Self {
let inv = 1.0f32 / scalar;
Self {
x: self.x * inv,
y: self.y * inv,
z: self.z * inv,
}
}
}
impl core::ops::Neg for Vector3f {
type Output = Self;
#[inline]
fn neg(self) -> Self {
Self {
x: -self.x,
y: -self.y,
z: -self.z,
}
}
}
impl Vector3f {
#[inline]
pub fn normalize(&mut self) {
unsafe { ffi::whiteout_v_Vector3f_normalize(self) }
}
#[inline]
pub fn normalized(self) -> Vector3f {
unsafe { ffi::whiteout_v_Vector3f_normalized(self) }
}
#[inline]
pub fn lerp(start: Vector3f, end: Vector3f, t: f32) -> Vector3f {
unsafe { ffi::whiteout_v_Vector3f_lerp(start, end, t) }
}
#[inline]
pub fn tcb_in_tangent(
prev: Vector3f,
current: Vector3f,
next: Vector3f,
tension: f32,
continuity: f32,
bias: f32,
) -> Vector3f {
unsafe {
ffi::whiteout_v_Vector3f_tcb_in_tangent(prev, current, next, tension, continuity, bias)
}
}
#[inline]
pub fn tcb_out_tangent(
prev: Vector3f,
current: Vector3f,
next: Vector3f,
tension: f32,
continuity: f32,
bias: f32,
) -> Vector3f {
unsafe {
ffi::whiteout_v_Vector3f_tcb_out_tangent(prev, current, next, tension, continuity, bias)
}
}
#[inline]
pub fn bezier_lerp(
start: Vector3f,
outtan: Vector3f,
intan: Vector3f,
end: Vector3f,
t: f32,
) -> Vector3f {
unsafe { ffi::whiteout_v_Vector3f_bezier_lerp(start, outtan, intan, end, t) }
}
#[inline]
pub fn hermite_lerp(
prev: Vector3f,
start: Vector3f,
end: Vector3f,
next: Vector3f,
t: f32,
) -> Vector3f {
unsafe { ffi::whiteout_v_Vector3f_hermite_lerp(prev, start, end, next, t) }
}
}
impl Vector4f {
#[inline]
pub const fn new(x: f32, y: f32, z: f32, w: f32) -> Self {
Self { x, y, z, w }
}
#[inline]
pub fn dot(self, other: Self) -> f32 {
self.x * other.x + self.y * other.y + self.z * other.z + self.w * other.w
}
#[inline]
pub fn length_squared(self) -> f32 {
self.dot(self)
}
#[inline]
pub fn length(self) -> f32 {
self.length_squared().sqrt()
}
}
impl core::ops::Add for Vector4f {
type Output = Self;
#[inline]
fn add(self, other: Self) -> Self {
Self {
x: self.x + other.x,
y: self.y + other.y,
z: self.z + other.z,
w: self.w + other.w,
}
}
}
impl core::ops::Sub for Vector4f {
type Output = Self;
#[inline]
fn sub(self, other: Self) -> Self {
Self {
x: self.x - other.x,
y: self.y - other.y,
z: self.z - other.z,
w: self.w - other.w,
}
}
}
impl core::ops::Mul for Vector4f {
type Output = Self;
#[inline]
fn mul(self, other: Self) -> Self {
Self {
x: self.x * other.x,
y: self.y * other.y,
z: self.z * other.z,
w: self.w * other.w,
}
}
}
impl core::ops::Div for Vector4f {
type Output = Self;
#[inline]
fn div(self, other: Self) -> Self {
Self {
x: self.x / other.x,
y: self.y / other.y,
z: self.z / other.z,
w: self.w / other.w,
}
}
}
impl core::ops::Mul<f32> for Vector4f {
type Output = Self;
#[inline]
fn mul(self, scalar: f32) -> Self {
Self {
x: self.x * scalar,
y: self.y * scalar,
z: self.z * scalar,
w: self.w * scalar,
}
}
}
impl core::ops::Div<f32> for Vector4f {
type Output = Self;
#[inline]
fn div(self, scalar: f32) -> Self {
let inv = 1.0f32 / scalar;
Self {
x: self.x * inv,
y: self.y * inv,
z: self.z * inv,
w: self.w * inv,
}
}
}
impl core::ops::Neg for Vector4f {
type Output = Self;
#[inline]
fn neg(self) -> Self {
Self {
x: -self.x,
y: -self.y,
z: -self.z,
w: -self.w,
}
}
}
impl Vector4f {
#[inline]
pub fn normalize(&mut self) {
unsafe { ffi::whiteout_v_Vector4f_normalize(self) }
}
#[inline]
pub fn normalized(self) -> Vector4f {
unsafe { ffi::whiteout_v_Vector4f_normalized(self) }
}
#[inline]
pub fn lerp(start: Vector4f, end: Vector4f, t: f32) -> Vector4f {
unsafe { ffi::whiteout_v_Vector4f_lerp(start, end, t) }
}
#[inline]
pub fn tcb_in_tangent(
prev: Vector4f,
current: Vector4f,
next: Vector4f,
tension: f32,
continuity: f32,
bias: f32,
) -> Vector4f {
unsafe {
ffi::whiteout_v_Vector4f_tcb_in_tangent(prev, current, next, tension, continuity, bias)
}
}
#[inline]
pub fn tcb_out_tangent(
prev: Vector4f,
current: Vector4f,
next: Vector4f,
tension: f32,
continuity: f32,
bias: f32,
) -> Vector4f {
unsafe {
ffi::whiteout_v_Vector4f_tcb_out_tangent(prev, current, next, tension, continuity, bias)
}
}
#[inline]
pub fn bezier_lerp(
start: Vector4f,
outtan: Vector4f,
intan: Vector4f,
end: Vector4f,
t: f32,
) -> Vector4f {
unsafe { ffi::whiteout_v_Vector4f_bezier_lerp(start, outtan, intan, end, t) }
}
#[inline]
pub fn hermite_lerp(
prev: Vector4f,
start: Vector4f,
end: Vector4f,
next: Vector4f,
t: f32,
) -> Vector4f {
unsafe { ffi::whiteout_v_Vector4f_hermite_lerp(prev, start, end, next, t) }
}
}
impl Quaternion {
#[inline]
pub const fn new(x: f32, y: f32, z: f32, w: f32) -> Self {
Self { x, y, z, w }
}
#[inline]
pub fn dot(self, other: Self) -> f32 {
self.x * other.x + self.y * other.y + self.z * other.z + self.w * other.w
}
#[inline]
pub fn length_squared(self) -> f32 {
self.dot(self)
}
#[inline]
pub fn length(self) -> f32 {
self.length_squared().sqrt()
}
}
impl core::ops::Add for Quaternion {
type Output = Self;
#[inline]
fn add(self, other: Self) -> Self {
Self {
x: self.x + other.x,
y: self.y + other.y,
z: self.z + other.z,
w: self.w + other.w,
}
}
}
impl core::ops::Sub for Quaternion {
type Output = Self;
#[inline]
fn sub(self, other: Self) -> Self {
Self {
x: self.x - other.x,
y: self.y - other.y,
z: self.z - other.z,
w: self.w - other.w,
}
}
}
impl core::ops::Mul<f32> for Quaternion {
type Output = Self;
#[inline]
fn mul(self, scalar: f32) -> Self {
Self {
x: self.x * scalar,
y: self.y * scalar,
z: self.z * scalar,
w: self.w * scalar,
}
}
}
impl core::ops::Div<f32> for Quaternion {
type Output = Self;
#[inline]
fn div(self, scalar: f32) -> Self {
let inv = 1.0f32 / scalar;
Self {
x: self.x * inv,
y: self.y * inv,
z: self.z * inv,
w: self.w * inv,
}
}
}
impl core::ops::Neg for Quaternion {
type Output = Self;
#[inline]
fn neg(self) -> Self {
Self {
x: -self.x,
y: -self.y,
z: -self.z,
w: -self.w,
}
}
}
impl core::ops::Mul for Quaternion {
type Output = Quaternion;
#[inline]
fn mul(self, other: Quaternion) -> Quaternion {
unsafe { ffi::whiteout_v_Quaternion_mul(self, other) }
}
}
impl Quaternion {
#[inline]
pub fn normalize(&mut self) {
unsafe { ffi::whiteout_v_Quaternion_normalize(self) }
}
#[inline]
pub fn normalized(self) -> Quaternion {
unsafe { ffi::whiteout_v_Quaternion_normalized(self) }
}
#[inline]
pub fn conjugate(self) -> Quaternion {
unsafe { ffi::whiteout_v_Quaternion_conjugate(self) }
}
#[inline]
pub fn inverse(self) -> Quaternion {
unsafe { ffi::whiteout_v_Quaternion_inverse(self) }
}
#[inline]
pub fn log(self) -> Quaternion {
unsafe { ffi::whiteout_v_Quaternion_log(self) }
}
#[inline]
pub fn exp(self) -> Quaternion {
unsafe { ffi::whiteout_v_Quaternion_exp(self) }
}
#[inline]
pub fn to_euler_angles(self) -> Vector3f {
unsafe { ffi::whiteout_v_Quaternion_to_euler_angles(self) }
}
#[inline]
pub fn rotate_vector(self, v: Vector3f) -> Vector3f {
unsafe { ffi::whiteout_v_Quaternion_rotate_vector(self, v) }
}
#[inline]
pub fn identity() -> Quaternion {
unsafe { ffi::whiteout_v_Quaternion_identity() }
}
#[inline]
pub fn from_axis_angle(axis: Vector3f, angle_rad: f32) -> Quaternion {
unsafe { ffi::whiteout_v_Quaternion_from_axis_angle(axis, angle_rad) }
}
#[inline]
pub fn from_euler_angles(euler_rad: Vector3f) -> Quaternion {
unsafe { ffi::whiteout_v_Quaternion_from_euler_angles(euler_rad) }
}
#[inline]
pub fn slerp(a: Quaternion, b: Quaternion, t: f32) -> Quaternion {
unsafe { ffi::whiteout_v_Quaternion_slerp(a, b, t) }
}
#[inline]
pub fn squad(
start: Quaternion,
outtan: Quaternion,
inttan: Quaternion,
end: Quaternion,
t: f32,
) -> Quaternion {
unsafe { ffi::whiteout_v_Quaternion_squad(start, outtan, inttan, end, t) }
}
#[inline]
pub fn ln_dif(a: Quaternion, b: Quaternion) -> Quaternion {
unsafe { ffi::whiteout_v_Quaternion_ln_dif(a, b) }
}
}
impl Matrix33f {
pub const DIM: usize = 3;
#[inline]
pub const fn from_rows(data: [[f32; 3]; 3]) -> Self {
Self { data }
}
}
impl core::ops::Index<(usize, usize)> for Matrix33f {
type Output = f32;
#[inline]
fn index(&self, (row, col): (usize, usize)) -> &f32 {
&self.data[row][col]
}
}
impl core::ops::IndexMut<(usize, usize)> for Matrix33f {
#[inline]
fn index_mut(&mut self, (row, col): (usize, usize)) -> &mut f32 {
&mut self.data[row][col]
}
}
impl core::ops::Add for Matrix33f {
type Output = Matrix33f;
#[inline]
fn add(self, other: Matrix33f) -> Matrix33f {
unsafe { ffi::whiteout_v_Matrix33f_add(self, other) }
}
}
impl core::ops::Sub for Matrix33f {
type Output = Matrix33f;
#[inline]
fn sub(self, other: Matrix33f) -> Matrix33f {
unsafe { ffi::whiteout_v_Matrix33f_sub(self, other) }
}
}
impl core::ops::Mul for Matrix33f {
type Output = Matrix33f;
#[inline]
fn mul(self, other: Matrix33f) -> Matrix33f {
unsafe { ffi::whiteout_v_Matrix33f_mul(self, other) }
}
}
impl core::ops::Mul<f32> for Matrix33f {
type Output = Matrix33f;
#[inline]
fn mul(self, scalar: f32) -> Matrix33f {
unsafe { ffi::whiteout_v_Matrix33f_mul_scalar(self, scalar) }
}
}
impl Matrix33f {
#[inline]
pub fn identity() -> Matrix33f {
unsafe { ffi::whiteout_v_Matrix33f_identity() }
}
#[inline]
pub fn zero() -> Matrix33f {
unsafe { ffi::whiteout_v_Matrix33f_zero() }
}
}
impl Matrix44f {
pub const DIM: usize = 4;
#[inline]
pub const fn from_rows(data: [[f32; 4]; 4]) -> Self {
Self { data }
}
}
impl core::ops::Index<(usize, usize)> for Matrix44f {
type Output = f32;
#[inline]
fn index(&self, (row, col): (usize, usize)) -> &f32 {
&self.data[row][col]
}
}
impl core::ops::IndexMut<(usize, usize)> for Matrix44f {
#[inline]
fn index_mut(&mut self, (row, col): (usize, usize)) -> &mut f32 {
&mut self.data[row][col]
}
}
impl core::ops::Add for Matrix44f {
type Output = Matrix44f;
#[inline]
fn add(self, other: Matrix44f) -> Matrix44f {
unsafe { ffi::whiteout_v_Matrix44f_add(self, other) }
}
}
impl core::ops::Sub for Matrix44f {
type Output = Matrix44f;
#[inline]
fn sub(self, other: Matrix44f) -> Matrix44f {
unsafe { ffi::whiteout_v_Matrix44f_sub(self, other) }
}
}
impl core::ops::Mul for Matrix44f {
type Output = Matrix44f;
#[inline]
fn mul(self, other: Matrix44f) -> Matrix44f {
unsafe { ffi::whiteout_v_Matrix44f_mul(self, other) }
}
}
impl core::ops::Mul<f32> for Matrix44f {
type Output = Matrix44f;
#[inline]
fn mul(self, scalar: f32) -> Matrix44f {
unsafe { ffi::whiteout_v_Matrix44f_mul_scalar(self, scalar) }
}
}
impl Matrix44f {
#[inline]
pub fn identity() -> Matrix44f {
unsafe { ffi::whiteout_v_Matrix44f_identity() }
}
#[inline]
pub fn zero() -> Matrix44f {
unsafe { ffi::whiteout_v_Matrix44f_zero() }
}
#[inline]
pub fn translation(t: Vector3f) -> Matrix44f {
unsafe { ffi::whiteout_v_Matrix44f_translation(t) }
}
#[inline]
pub fn rotation(q: Quaternion) -> Matrix44f {
unsafe { ffi::whiteout_v_Matrix44f_rotation(q) }
}
#[inline]
pub fn scaling(s: Vector3f) -> Matrix44f {
unsafe { ffi::whiteout_v_Matrix44f_scaling(s) }
}
#[inline]
pub fn compose(translation: Vector3f, rotation: Quaternion, scale: Vector3f) -> Matrix44f {
unsafe { ffi::whiteout_v_Matrix44f_compose(translation, rotation, scale) }
}
#[inline]
pub fn inverse(m: Matrix44f) -> Matrix44f {
unsafe { ffi::whiteout_v_Matrix44f_inverse(m) }
}
#[inline]
pub fn rotation_x(angle: f32) -> Matrix44f {
unsafe { ffi::whiteout_v_Matrix44f_rotation_x(angle) }
}
#[inline]
pub fn rotation_y(angle: f32) -> Matrix44f {
unsafe { ffi::whiteout_v_Matrix44f_rotation_y(angle) }
}
#[inline]
pub fn rotation_z(angle: f32) -> Matrix44f {
unsafe { ffi::whiteout_v_Matrix44f_rotation_z(angle) }
}
#[inline]
pub fn look_at_rh(eye: Vector3f, target: Vector3f, up: Vector3f) -> Matrix44f {
unsafe { ffi::whiteout_v_Matrix44f_look_at_rh(eye, target, up) }
}
#[inline]
pub fn look_at_lh(eye: Vector3f, target: Vector3f, up: Vector3f) -> Matrix44f {
unsafe { ffi::whiteout_v_Matrix44f_look_at_lh(eye, target, up) }
}
#[inline]
pub fn look_at_lh_sgcompat(eye: Vector3f, target: Vector3f, up: Vector3f) -> Matrix44f {
unsafe { ffi::whiteout_v_Matrix44f_look_at_lh_sgcompat(eye, target, up) }
}
#[inline]
pub fn perspective_fov_rh(fov_y: f32, aspect: f32, near_z: f32, far_z: f32) -> Matrix44f {
unsafe { ffi::whiteout_v_Matrix44f_perspective_fov_rh(fov_y, aspect, near_z, far_z) }
}
#[inline]
pub fn perspective_fov_lh(fov_y: f32, aspect: f32, near_z: f32, far_z: f32) -> Matrix44f {
unsafe { ffi::whiteout_v_Matrix44f_perspective_fov_lh(fov_y, aspect, near_z, far_z) }
}
#[inline]
pub fn perspective_diag_sgcompat(
fov_diagonal: f32,
aspect: f32,
near_z: f32,
far_z: f32,
) -> Matrix44f {
unsafe {
ffi::whiteout_v_Matrix44f_perspective_diag_sgcompat(fov_diagonal, aspect, near_z, far_z)
}
}
#[inline]
pub fn orthographic_rh(width: f32, height: f32, near_z: f32, far_z: f32) -> Matrix44f {
unsafe { ffi::whiteout_v_Matrix44f_orthographic_rh(width, height, near_z, far_z) }
}
#[inline]
pub fn transpose(self) -> Matrix44f {
unsafe { ffi::whiteout_v_Matrix44f_transpose(self) }
}
#[inline]
pub fn extract_translation(self) -> Vector3f {
unsafe { ffi::whiteout_v_Matrix44f_extract_translation(self) }
}
#[inline]
pub fn extract_rotation(self) -> Quaternion {
unsafe { ffi::whiteout_v_Matrix44f_extract_rotation(self) }
}
#[inline]
pub fn extract_scale(self) -> Vector3f {
unsafe { ffi::whiteout_v_Matrix44f_extract_scale(self) }
}
}
#[inline]
pub fn cross(a: Vector3f, b: Vector3f) -> Vector3f {
unsafe { ffi::whiteout_v_cross(a, b) }
}
#[inline]
pub fn transform_point(v: Vector3f, m: Matrix44f) -> Vector3f {
unsafe { ffi::whiteout_v_transform_point(v, m) }
}
#[inline]
pub fn transform_normal(v: Vector3f, m: Matrix44f) -> Vector3f {
unsafe { ffi::whiteout_v_transform_normal(v, m) }
}
pub fn check_abi() -> Result<(), crate::Error> {
let l = unsafe { ffi::whiteout_v_layout() };
if l.abi_version != ffi::ABI_VERSION {
return Err(crate::Error::Layout {
what: "abi_version",
expected: ffi::ABI_VERSION as usize,
actual: l.abi_version as usize,
});
}
if l.vector2f as usize != core::mem::size_of::<Vector2f>() {
return Err(crate::Error::Layout {
what: "Vector2f",
expected: core::mem::size_of::<Vector2f>(),
actual: l.vector2f as usize,
});
}
if l.vector3f as usize != core::mem::size_of::<Vector3f>() {
return Err(crate::Error::Layout {
what: "Vector3f",
expected: core::mem::size_of::<Vector3f>(),
actual: l.vector3f as usize,
});
}
if l.vector4f as usize != core::mem::size_of::<Vector4f>() {
return Err(crate::Error::Layout {
what: "Vector4f",
expected: core::mem::size_of::<Vector4f>(),
actual: l.vector4f as usize,
});
}
if l.quaternion as usize != core::mem::size_of::<Quaternion>() {
return Err(crate::Error::Layout {
what: "Quaternion",
expected: core::mem::size_of::<Quaternion>(),
actual: l.quaternion as usize,
});
}
if l.matrix33f as usize != core::mem::size_of::<Matrix33f>() {
return Err(crate::Error::Layout {
what: "Matrix33f",
expected: core::mem::size_of::<Matrix33f>(),
actual: l.matrix33f as usize,
});
}
if l.matrix44f as usize != core::mem::size_of::<Matrix44f>() {
return Err(crate::Error::Layout {
what: "Matrix44f",
expected: core::mem::size_of::<Matrix44f>(),
actual: l.matrix44f as usize,
});
}
Ok(())
}
#[doc(hidden)]
pub mod ffi {
use super::*;
pub const ABI_VERSION: u32 = 2;
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct Layout {
pub abi_version: u32,
pub vector2f: u32,
pub vector3f: u32,
pub vector4f: u32,
pub quaternion: u32,
pub matrix33f: u32,
pub matrix44f: u32,
}
extern "C" {
pub fn whiteout_v_layout() -> Layout;
pub fn whiteout_v_Vector2f_dot(self_: Vector2f, other: Vector2f) -> f32;
pub fn whiteout_v_Vector2f_length(self_: Vector2f) -> f32;
pub fn whiteout_v_Vector2f_length_squared(self_: Vector2f) -> f32;
pub fn whiteout_v_Vector2f_normalize(self_: *mut Vector2f);
pub fn whiteout_v_Vector2f_normalized(self_: Vector2f) -> Vector2f;
pub fn whiteout_v_Vector2f_add(self_: Vector2f, other: Vector2f) -> Vector2f;
pub fn whiteout_v_Vector2f_sub(self_: Vector2f, other: Vector2f) -> Vector2f;
pub fn whiteout_v_Vector2f_mul(self_: Vector2f, other: Vector2f) -> Vector2f;
pub fn whiteout_v_Vector2f_div(self_: Vector2f, other: Vector2f) -> Vector2f;
pub fn whiteout_v_Vector2f_mul_scalar(self_: Vector2f, scalar: f32) -> Vector2f;
pub fn whiteout_v_Vector2f_div_scalar(self_: Vector2f, scalar: f32) -> Vector2f;
pub fn whiteout_v_Vector2f_negate(self_: Vector2f) -> Vector2f;
pub fn whiteout_v_Vector2f_lerp(start: Vector2f, end: Vector2f, t: f32) -> Vector2f;
pub fn whiteout_v_Vector2f_tcb_in_tangent(
prev: Vector2f,
current: Vector2f,
next: Vector2f,
tension: f32,
continuity: f32,
bias: f32,
) -> Vector2f;
pub fn whiteout_v_Vector2f_tcb_out_tangent(
prev: Vector2f,
current: Vector2f,
next: Vector2f,
tension: f32,
continuity: f32,
bias: f32,
) -> Vector2f;
pub fn whiteout_v_Vector2f_bezier_lerp(
start: Vector2f,
outtan: Vector2f,
intan: Vector2f,
end: Vector2f,
t: f32,
) -> Vector2f;
pub fn whiteout_v_Vector2f_hermite_lerp(
prev: Vector2f,
start: Vector2f,
end: Vector2f,
next: Vector2f,
t: f32,
) -> Vector2f;
pub fn whiteout_v_Vector3f_dot(self_: Vector3f, other: Vector3f) -> f32;
pub fn whiteout_v_Vector3f_length(self_: Vector3f) -> f32;
pub fn whiteout_v_Vector3f_length_squared(self_: Vector3f) -> f32;
pub fn whiteout_v_Vector3f_normalize(self_: *mut Vector3f);
pub fn whiteout_v_Vector3f_normalized(self_: Vector3f) -> Vector3f;
pub fn whiteout_v_Vector3f_add(self_: Vector3f, other: Vector3f) -> Vector3f;
pub fn whiteout_v_Vector3f_sub(self_: Vector3f, other: Vector3f) -> Vector3f;
pub fn whiteout_v_Vector3f_mul(self_: Vector3f, other: Vector3f) -> Vector3f;
pub fn whiteout_v_Vector3f_div(self_: Vector3f, other: Vector3f) -> Vector3f;
pub fn whiteout_v_Vector3f_mul_scalar(self_: Vector3f, scalar: f32) -> Vector3f;
pub fn whiteout_v_Vector3f_div_scalar(self_: Vector3f, scalar: f32) -> Vector3f;
pub fn whiteout_v_Vector3f_negate(self_: Vector3f) -> Vector3f;
pub fn whiteout_v_Vector3f_lerp(start: Vector3f, end: Vector3f, t: f32) -> Vector3f;
pub fn whiteout_v_Vector3f_tcb_in_tangent(
prev: Vector3f,
current: Vector3f,
next: Vector3f,
tension: f32,
continuity: f32,
bias: f32,
) -> Vector3f;
pub fn whiteout_v_Vector3f_tcb_out_tangent(
prev: Vector3f,
current: Vector3f,
next: Vector3f,
tension: f32,
continuity: f32,
bias: f32,
) -> Vector3f;
pub fn whiteout_v_Vector3f_bezier_lerp(
start: Vector3f,
outtan: Vector3f,
intan: Vector3f,
end: Vector3f,
t: f32,
) -> Vector3f;
pub fn whiteout_v_Vector3f_hermite_lerp(
prev: Vector3f,
start: Vector3f,
end: Vector3f,
next: Vector3f,
t: f32,
) -> Vector3f;
pub fn whiteout_v_Vector4f_dot(self_: Vector4f, other: Vector4f) -> f32;
pub fn whiteout_v_Vector4f_length(self_: Vector4f) -> f32;
pub fn whiteout_v_Vector4f_length_squared(self_: Vector4f) -> f32;
pub fn whiteout_v_Vector4f_normalize(self_: *mut Vector4f);
pub fn whiteout_v_Vector4f_normalized(self_: Vector4f) -> Vector4f;
pub fn whiteout_v_Vector4f_add(self_: Vector4f, other: Vector4f) -> Vector4f;
pub fn whiteout_v_Vector4f_sub(self_: Vector4f, other: Vector4f) -> Vector4f;
pub fn whiteout_v_Vector4f_mul(self_: Vector4f, other: Vector4f) -> Vector4f;
pub fn whiteout_v_Vector4f_div(self_: Vector4f, other: Vector4f) -> Vector4f;
pub fn whiteout_v_Vector4f_mul_scalar(self_: Vector4f, scalar: f32) -> Vector4f;
pub fn whiteout_v_Vector4f_div_scalar(self_: Vector4f, scalar: f32) -> Vector4f;
pub fn whiteout_v_Vector4f_negate(self_: Vector4f) -> Vector4f;
pub fn whiteout_v_Vector4f_lerp(start: Vector4f, end: Vector4f, t: f32) -> Vector4f;
pub fn whiteout_v_Vector4f_tcb_in_tangent(
prev: Vector4f,
current: Vector4f,
next: Vector4f,
tension: f32,
continuity: f32,
bias: f32,
) -> Vector4f;
pub fn whiteout_v_Vector4f_tcb_out_tangent(
prev: Vector4f,
current: Vector4f,
next: Vector4f,
tension: f32,
continuity: f32,
bias: f32,
) -> Vector4f;
pub fn whiteout_v_Vector4f_bezier_lerp(
start: Vector4f,
outtan: Vector4f,
intan: Vector4f,
end: Vector4f,
t: f32,
) -> Vector4f;
pub fn whiteout_v_Vector4f_hermite_lerp(
prev: Vector4f,
start: Vector4f,
end: Vector4f,
next: Vector4f,
t: f32,
) -> Vector4f;
pub fn whiteout_v_Quaternion_dot(self_: Quaternion, other: Quaternion) -> f32;
pub fn whiteout_v_Quaternion_length(self_: Quaternion) -> f32;
pub fn whiteout_v_Quaternion_length_squared(self_: Quaternion) -> f32;
pub fn whiteout_v_Quaternion_normalize(self_: *mut Quaternion);
pub fn whiteout_v_Quaternion_normalized(self_: Quaternion) -> Quaternion;
pub fn whiteout_v_Quaternion_add(self_: Quaternion, other: Quaternion) -> Quaternion;
pub fn whiteout_v_Quaternion_sub(self_: Quaternion, other: Quaternion) -> Quaternion;
pub fn whiteout_v_Quaternion_mul(self_: Quaternion, other: Quaternion) -> Quaternion;
pub fn whiteout_v_Quaternion_mul_scalar(self_: Quaternion, scalar: f32) -> Quaternion;
pub fn whiteout_v_Quaternion_div_scalar(self_: Quaternion, scalar: f32) -> Quaternion;
pub fn whiteout_v_Quaternion_negate(self_: Quaternion) -> Quaternion;
pub fn whiteout_v_Quaternion_conjugate(self_: Quaternion) -> Quaternion;
pub fn whiteout_v_Quaternion_inverse(self_: Quaternion) -> Quaternion;
pub fn whiteout_v_Quaternion_log(self_: Quaternion) -> Quaternion;
pub fn whiteout_v_Quaternion_exp(self_: Quaternion) -> Quaternion;
pub fn whiteout_v_Quaternion_to_euler_angles(self_: Quaternion) -> Vector3f;
pub fn whiteout_v_Quaternion_rotate_vector(self_: Quaternion, v: Vector3f) -> Vector3f;
pub fn whiteout_v_Quaternion_identity() -> Quaternion;
pub fn whiteout_v_Quaternion_from_axis_angle(axis: Vector3f, angle_rad: f32) -> Quaternion;
pub fn whiteout_v_Quaternion_from_euler_angles(euler_rad: Vector3f) -> Quaternion;
pub fn whiteout_v_Quaternion_slerp(a: Quaternion, b: Quaternion, t: f32) -> Quaternion;
pub fn whiteout_v_Quaternion_squad(
start: Quaternion,
outtan: Quaternion,
inttan: Quaternion,
end: Quaternion,
t: f32,
) -> Quaternion;
pub fn whiteout_v_Quaternion_ln_dif(a: Quaternion, b: Quaternion) -> Quaternion;
pub fn whiteout_v_Matrix33f_add(self_: Matrix33f, other: Matrix33f) -> Matrix33f;
pub fn whiteout_v_Matrix33f_sub(self_: Matrix33f, other: Matrix33f) -> Matrix33f;
pub fn whiteout_v_Matrix33f_mul(self_: Matrix33f, other: Matrix33f) -> Matrix33f;
pub fn whiteout_v_Matrix33f_mul_scalar(self_: Matrix33f, scalar: f32) -> Matrix33f;
pub fn whiteout_v_Matrix33f_identity() -> Matrix33f;
pub fn whiteout_v_Matrix33f_zero() -> Matrix33f;
pub fn whiteout_v_Matrix44f_add(self_: Matrix44f, other: Matrix44f) -> Matrix44f;
pub fn whiteout_v_Matrix44f_sub(self_: Matrix44f, other: Matrix44f) -> Matrix44f;
pub fn whiteout_v_Matrix44f_mul(self_: Matrix44f, other: Matrix44f) -> Matrix44f;
pub fn whiteout_v_Matrix44f_mul_scalar(self_: Matrix44f, scalar: f32) -> Matrix44f;
pub fn whiteout_v_Matrix44f_identity() -> Matrix44f;
pub fn whiteout_v_Matrix44f_zero() -> Matrix44f;
pub fn whiteout_v_Matrix44f_translation(t: Vector3f) -> Matrix44f;
pub fn whiteout_v_Matrix44f_rotation(q: Quaternion) -> Matrix44f;
pub fn whiteout_v_Matrix44f_scaling(s: Vector3f) -> Matrix44f;
pub fn whiteout_v_Matrix44f_compose(
translation: Vector3f,
rotation: Quaternion,
scale: Vector3f,
) -> Matrix44f;
pub fn whiteout_v_Matrix44f_inverse(m: Matrix44f) -> Matrix44f;
pub fn whiteout_v_Matrix44f_rotation_x(angle: f32) -> Matrix44f;
pub fn whiteout_v_Matrix44f_rotation_y(angle: f32) -> Matrix44f;
pub fn whiteout_v_Matrix44f_rotation_z(angle: f32) -> Matrix44f;
pub fn whiteout_v_Matrix44f_look_at_rh(
eye: Vector3f,
target: Vector3f,
up: Vector3f,
) -> Matrix44f;
pub fn whiteout_v_Matrix44f_look_at_lh(
eye: Vector3f,
target: Vector3f,
up: Vector3f,
) -> Matrix44f;
pub fn whiteout_v_Matrix44f_look_at_lh_sgcompat(
eye: Vector3f,
target: Vector3f,
up: Vector3f,
) -> Matrix44f;
pub fn whiteout_v_Matrix44f_perspective_fov_rh(
fov_y: f32,
aspect: f32,
near_z: f32,
far_z: f32,
) -> Matrix44f;
pub fn whiteout_v_Matrix44f_perspective_fov_lh(
fov_y: f32,
aspect: f32,
near_z: f32,
far_z: f32,
) -> Matrix44f;
pub fn whiteout_v_Matrix44f_perspective_diag_sgcompat(
fov_diagonal: f32,
aspect: f32,
near_z: f32,
far_z: f32,
) -> Matrix44f;
pub fn whiteout_v_Matrix44f_orthographic_rh(
width: f32,
height: f32,
near_z: f32,
far_z: f32,
) -> Matrix44f;
pub fn whiteout_v_Matrix44f_transpose(self_: Matrix44f) -> Matrix44f;
pub fn whiteout_v_Matrix44f_extract_translation(self_: Matrix44f) -> Vector3f;
pub fn whiteout_v_Matrix44f_extract_rotation(self_: Matrix44f) -> Quaternion;
pub fn whiteout_v_Matrix44f_extract_scale(self_: Matrix44f) -> Vector3f;
pub fn whiteout_v_cross(a: Vector3f, b: Vector3f) -> Vector3f;
pub fn whiteout_v_transform_point(v: Vector3f, m: Matrix44f) -> Vector3f;
pub fn whiteout_v_transform_normal(v: Vector3f, m: Matrix44f) -> Vector3f;
}
}