ecs: implement component for some glam types
This commit is contained in:
parent
544aee4a31
commit
acfd238274
|
@ -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
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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);
|
Loading…
Reference in New Issue