#[cfg(feature = "serde-derives")]
use serde::Serialize;
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde-derives", derive(Serialize))]
pub struct Vector3f {
pub x: f32,
pub y: f32,
pub z: f32,
}
impl Vector3f {
pub const fn new(x: f32, y: f32, z: f32) -> Self {
Self { x, y, z }
}
}
impl From<[f32; 3]> for Vector3f {
fn from(val: [f32; 3]) -> Self {
Vector3f {
x: val[0],
y: val[1],
z: val[2],
}
}
}
impl From<Vector3f> for [f32; 3] {
fn from(v: Vector3f) -> [f32; 3] {
[v.x, v.y, v.z]
}
}
#[derive(Debug)]
#[cfg_attr(feature = "serde-derives", derive(Serialize))]
pub struct Quaternion {
pub x: f32,
pub y: f32,
pub z: f32,
pub w: f32,
}
impl Quaternion {
pub const fn new(x: f32, y: f32, z: f32, w: f32) -> Self {
Self { x, y, z, w }
}
}
#[derive(Debug)]
#[cfg_attr(feature = "serde-derives", derive(Serialize))]
pub struct Placement3D {
pub pos: Vector3f,
pub rot: Quaternion,
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[repr(transparent)]
#[cfg_attr(feature = "serde-derives", derive(Serialize))]
pub struct WorldID(u32);
impl WorldID {
pub const fn new(value: u32) -> Self {
Self(value)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[repr(transparent)]
#[cfg_attr(feature = "serde-derives", derive(Serialize))]
pub struct ObjectTemplate(u32);
impl ObjectTemplate {
pub const fn new(value: u32) -> Self {
Self(value)
}
}
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde-derives", derive(Serialize))]
pub struct ObjectID {
pub scope: u32,
pub id: u32,
}
impl ObjectID {
pub fn new(scope: u32, id: u32) -> Self {
Self { scope, id }
}
}