summaryrefslogtreecommitdiff
path: root/engine/src/transform.rs
diff options
context:
space:
mode:
Diffstat (limited to 'engine/src/transform.rs')
-rw-r--r--engine/src/transform.rs82
1 files changed, 19 insertions, 63 deletions
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<f32>,
- pub scale: Vec3<f32>,
- }
-);
+#[derive(Debug, Clone, Component, Reflection)]
+#[non_exhaustive]
+pub struct Transform
+{
+ pub position: Vec3<f32>,
+ pub scale: Dimens3<f32>,
+}
impl Transform
{
- pub fn builder() -> Builder
+ pub fn position(mut self, position: Vec3<f32>) -> Self
{
- Builder::default()
+ self.position = position;
+ self
+ }
+
+ pub fn scale(mut self, scale: Dimens3<f32>) -> Self
+ {
+ self.scale = scale;
+ self
}
pub fn to_matrix(&self) -> Matrix<f32, 4, 4>
@@ -37,57 +41,9 @@ 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<f32>,
-}
-
-impl From<Vec3<f32>> for WorldPosition
-{
- fn from(position: Vec3<f32>) -> Self
- {
- Self { position }
- }
-}
-
-/// Scaling of a 3D object.
-#[derive(Debug, Clone, Copy, Component, Reflection)]
-pub struct Scale
-{
- pub scale: Vec3<f32>,
-}
-
-impl From<Vec3<f32>> for Scale
-{
- fn from(scale: Vec3<f32>) -> 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 },
}
}
}