ecs: implement component for some glam types

This commit is contained in:
SeanOMik 2024-01-12 14:09:29 -05:00
parent 544aee4a31
commit acfd238274
Signed by: SeanOMik
GPG Key ID: FEC9E2FC15235964
3 changed files with 27 additions and 0 deletions

View File

@ -5,10 +5,14 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
math = ["dep:glam"]
[dependencies]
lyra-ecs-derive = { path = "./lyra-ecs-derive" }
anyhow = "1.0.75"
thiserror = "1.0.50"
glam = { version = "0.24.0", optional = true }
[dev-dependencies]
rand = "0.8.5" # used for tests

View File

@ -34,6 +34,10 @@ pub mod system;
pub mod tick;
pub use tick::*;
/// Implements Component for glam math types
#[cfg(feature = "math")]
pub mod math;
pub use lyra_ecs_derive::*;
#[cfg(test)]

19
lyra-ecs/src/math.rs Normal file
View File

@ -0,0 +1,19 @@
use crate::Component;
use glam::{Vec3, Quat, Vec2, Vec4, Mat4};
macro_rules! impl_component_math {
($type: ident) => {
impl Component for $type {
fn name() -> &'static str {
stringify!($type)
}
}
};
}
impl_component_math!(Vec2);
impl_component_math!(Vec3);
impl_component_math!(Vec4);
impl_component_math!(Mat4);
impl_component_math!(Quat);