From ccfbcb490dd47cc814a64e8be00c148e2e2206a3 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 17 Aug 2026 15:52:01 +0200 Subject: feat(engine): replace WorldPosition & Scale components with Transform --- engine/src/transform.rs | 82 ++++++++++++------------------------------------- 1 file changed, 19 insertions(+), 63 deletions(-) (limited to 'engine/src/transform.rs') diff --git a/engine/src/transform.rs b/engine/src/transform.rs index 3b1c041..8e768a6 100644 --- a/engine/src/transform.rs +++ b/engine/src/transform.rs @@ -1,25 +1,29 @@ -use crate::builder; +use crate::data_types::dimens::Dimens3; use crate::ecs::Component; use crate::matrix::Matrix; use crate::reflection::Reflection; use crate::vector::Vec3; -builder!( - #[builder(name = Builder, derives=(Debug))] - #[derive(Debug)] - #[non_exhaustive] - pub struct Transform - { - pub position: Vec3, - pub scale: Vec3, - } -); +#[derive(Debug, Clone, Component, Reflection)] +#[non_exhaustive] +pub struct Transform +{ + pub position: Vec3, + pub scale: Dimens3, +} impl Transform { - pub fn builder() -> Builder + pub fn position(mut self, position: Vec3) -> Self { - Builder::default() + self.position = position; + self + } + + pub fn scale(mut self, scale: Dimens3) -> Self + { + self.scale = scale; + self } pub fn to_matrix(&self) -> Matrix @@ -34,60 +38,12 @@ impl Transform } impl Default for Transform -{ - fn default() -> Self - { - Self::builder().build() - } -} - -impl Default for Builder -{ - fn default() -> Self - { - Self { - position: Vec3::from(0.0), - scale: Vec3::from(1.0), - } - } -} - -/// A position in world space. -#[derive(Debug, Default, Clone, Copy, Component, Reflection)] -pub struct WorldPosition -{ - pub position: Vec3, -} - -impl From> for WorldPosition -{ - fn from(position: Vec3) -> Self - { - Self { position } - } -} - -/// Scaling of a 3D object. -#[derive(Debug, Clone, Copy, Component, Reflection)] -pub struct Scale -{ - pub scale: Vec3, -} - -impl From> for Scale -{ - fn from(scale: Vec3) -> Self - { - Self { scale } - } -} - -impl Default for Scale { fn default() -> Self { Self { - scale: Vec3 { x: 1.0, y: 1.0, z: 1.0 }, + position: Vec3 { x: 0.0, y: 0.0, z: 0.0 }, + scale: Dimens3 { width: 1.0, height: 1.0, depth: 1.0 }, } } } -- cgit v1.2.3-18-g5258