pub use glam::*;
pub type Vector2 = Vec2;
pub type Vector3 = Vec3;
pub type Vector4 = Vec4;
pub type Quaternion = Quat;
pub type Matrix4x4 = Mat4;
pub type Matrix3x3 = Mat3;
pub type Matrix2x2 = Mat2;
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Color {
pub r: f32,
pub g: f32,
pub b: f32,
pub a: f32,
}
impl Color {
pub const fn new(r: f32, g: f32, b: f32, a: f32) -> Self {
Self { r, g, b, a }
}
pub const WHITE: Self = Self::new(1.0, 1.0, 1.0, 1.0);
pub const BLACK: Self = Self::new(0.0, 0.0, 0.0, 1.0);
pub const RED: Self = Self::new(1.0, 0.0, 0.0, 1.0);
pub const GREEN: Self = Self::new(0.0, 1.0, 0.0, 1.0);
pub const BLUE: Self = Self::new(0.0, 0.0, 1.0, 1.0);
pub const YELLOW: Self = Self::new(1.0, 1.0, 0.0, 1.0);
pub const CYAN: Self = Self::new(0.0, 1.0, 1.0, 1.0);
pub const MAGENTA: Self = Self::new(1.0, 0.0, 1.0, 1.0);
pub const TRANSPARENT: Self = Self::new(0.0, 0.0, 0.0, 0.0);
}
impl From<Vec4> for Color {
fn from(v: Vec4) -> Self {
Self::new(v.x, v.y, v.z, v.w)
}
}
impl From<Color> for Vec4 {
fn from(c: Color) -> Self {
Vec4::new(c.r, c.g, c.b, c.a)
}
}
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Bounds {
pub center: Vector3,
pub extents: Vector3,
}
impl Default for Bounds {
fn default() -> Self {
Self {
center: Vector3::ZERO,
extents: Vector3::ZERO,
}
}
}
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Ray {
pub origin: Vector3,
pub direction: Vector3,
}
impl Default for Ray {
fn default() -> Self {
Self {
origin: Vector3::ZERO,
direction: Vector3::ZERO,
}
}
}
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Rect {
pub x: f32,
pub y: f32,
pub width: f32,
pub height: f32,
}
impl Default for Rect {
fn default() -> Self {
Self {
x: 0.0,
y: 0.0,
width: 0.0,
height: 0.0,
}
}
}
impl Rect {
pub fn new(x: f32, y: f32, width: f32, height: f32) -> Self {
Self {
x,
y,
width,
height,
}
}
}
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Plane {
pub normal: Vector3,
pub distance: f32,
}
impl Default for Plane {
fn default() -> Self {
Self {
normal: Vector3::ZERO,
distance: 0.0,
}
}
}
impl Plane {
pub fn new(normal: Vector3, distance: f32) -> Self {
Self { normal, distance }
}
}
use std::ffi::c_void;
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct RaycastHit {
pub point: Vector3,
pub normal: Vector3,
pub barycentric_coordinate: Vector3,
pub distance: f32,
pub triangle_index: i32,
pub texture_coord: Vector2,
pub texture_coord2: Vector2,
pub lightmap_coord: Vector2,
pub collider: *mut c_void,
pub rigidbody: *mut c_void,
pub articulation_body: *mut c_void,
pub transform: *mut c_void,
pub collider_entity_id: u32,
}
impl Default for RaycastHit {
fn default() -> Self {
Self {
point: Vector3::ZERO,
normal: Vector3::ZERO,
barycentric_coordinate: Vector3::ZERO,
distance: 0.0,
triangle_index: 0,
texture_coord: Vector2::ZERO,
texture_coord2: Vector2::ZERO,
lightmap_coord: Vector2::ZERO,
collider: std::ptr::null_mut(),
rigidbody: std::ptr::null_mut(),
articulation_body: std::ptr::null_mut(),
transform: std::ptr::null_mut(),
collider_entity_id: 0,
}
}
}