summaryrefslogtreecommitdiff
path: root/engine/src/transform.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-11-13 19:04:05 +0100
committerHampusM <hampus@hampusmat.com>2023-11-13 19:04:05 +0100
commit347b5374fb344507b57f4c5eecd28785a9f00961 (patch)
tree7c27da6168e461e3ce45477527e34844e31362b3 /engine/src/transform.rs
parent04e778802c0d9fd84ffd68ba7f7b9a26ea7640b8 (diff)
fix(engine): make object translate function add to current pos
Diffstat (limited to 'engine/src/transform.rs')
-rw-r--r--engine/src/transform.rs24
1 files changed, 12 insertions, 12 deletions
diff --git a/engine/src/transform.rs b/engine/src/transform.rs
index b01e3c1..a9d9980 100644
--- a/engine/src/transform.rs
+++ b/engine/src/transform.rs
@@ -4,8 +4,8 @@ use crate::vector::Vec3;
#[derive(Debug, Clone)]
pub struct Transform
{
- translation: Vec3<f32>,
- scaling: Vec3<f32>,
+ position: Vec3<f32>,
+ scale: Vec3<f32>,
}
impl Transform
@@ -13,33 +13,33 @@ impl Transform
pub fn new() -> Self
{
Self {
- translation: Vec3::default(),
- scaling: Vec3 { x: 1.0, y: 1.0, z: 1.0 },
+ position: Vec3::default(),
+ scale: Vec3 { x: 1.0, y: 1.0, z: 1.0 },
}
}
- pub fn translation(&self) -> &Vec3<f32>
+ pub fn position(&self) -> &Vec3<f32>
{
- &self.translation
+ &self.position
}
- pub fn set_translation(&mut self, translation: Vec3<f32>)
+ pub fn set_position(&mut self, position: Vec3<f32>)
{
- self.translation = translation;
+ self.position = position;
}
- pub fn set_scaling(&mut self, scaling: Vec3<f32>)
+ pub fn set_scale(&mut self, scale: Vec3<f32>)
{
- self.scaling = scaling;
+ self.scale = scale;
}
pub fn as_matrix(&self) -> Matrix<f32, 4, 4>
{
let mut matrix = Matrix::new_identity();
- matrix.translate(&self.translation);
+ matrix.translate(&self.position);
- matrix.scale(&self.scaling);
+ matrix.scale(&self.scale);
matrix
}