diff options
author | HampusM <hampus@hampusmat.com> | 2024-04-14 12:34:52 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2024-04-14 12:35:28 +0200 |
commit | 101b455e51f9b702da5517cabe2c3b1086fcb2e7 (patch) | |
tree | 470e28acd7a3777dbb4be0208f9cd3177bba52a9 /engine/src/transform.rs | |
parent | ef7b76ff39d501028852835649f618fcbe17a003 (diff) |
feat(engine): use ECS architecture
Diffstat (limited to 'engine/src/transform.rs')
-rw-r--r-- | engine/src/transform.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/engine/src/transform.rs b/engine/src/transform.rs index a9d9980..f55f44e 100644 --- a/engine/src/transform.rs +++ b/engine/src/transform.rs @@ -1,7 +1,9 @@ +use ecs::Component; + use crate::matrix::Matrix; use crate::vector::Vec3; -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Component)] pub struct Transform { position: Vec3<f32>, @@ -10,6 +12,7 @@ pub struct Transform impl Transform { + #[must_use] pub fn new() -> Self { Self { @@ -18,6 +21,7 @@ impl Transform } } + #[must_use] pub fn position(&self) -> &Vec3<f32> { &self.position @@ -33,7 +37,7 @@ impl Transform self.scale = scale; } - pub fn as_matrix(&self) -> Matrix<f32, 4, 4> + pub(crate) fn as_matrix(&self) -> Matrix<f32, 4, 4> { let mut matrix = Matrix::new_identity(); @@ -44,3 +48,11 @@ impl Transform matrix } } + +impl Default for Transform +{ + fn default() -> Self + { + Self::new() + } +} |