1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
use number_traits::Float; use mat32; use specs::{VecStorage, Component}; pub struct InnerTransform2D<T: 'static + Sync + Send + Copy + Float> { pub position: [T; 2], pub scale: [T; 2], pub rotation: T, } impl<T: 'static + Sync + Send + Copy + Float> Component for InnerTransform2D<T> { type Storage = VecStorage<Self>; } impl<T: 'static + Sync + Send + Copy + Float> Default for InnerTransform2D<T> { #[inline(always)] fn default() -> Self { InnerTransform2D { position: [T::zero(); 2], scale: [T::one(); 2], rotation: T::zero(), } } } impl<T: 'static + Sync + Send + Copy + Float> InnerTransform2D<T> { #[inline(always)] pub fn new() -> Self { Self::default() } #[inline] pub fn matrix(&self) -> [T; 6] { let mut matrix = mat32::new_identity(); mat32::compose(&mut matrix, &self.position, &self.scale, self.rotation); matrix } }