summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-10-30 19:45:58 +0100
committerHampusM <hampus@hampusmat.com>2023-10-30 19:45:58 +0100
commit5b0d859d0fbfb84ec143d894e023dcbd90980ad1 (patch)
tree39f8ac5e8abbd232e62f481890c5093e68561987 /engine
parent4c9fe4e4cf8b9b2358bdbb08766fef46dc9ba82b (diff)
feat(engine): add Vec3 scalar Sub & Add impls
Diffstat (limited to 'engine')
-rw-r--r--engine/src/vector.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/engine/src/vector.rs b/engine/src/vector.rs
index 00b2ea5..e5947d5 100644
--- a/engine/src/vector.rs
+++ b/engine/src/vector.rs
@@ -144,6 +144,38 @@ where
}
}
+impl<Value> Add<Value> for Vec3<Value>
+where
+ Value: Add<Value, Output = Value> + Clone,
+{
+ type Output = Self;
+
+ fn add(mut self, rhs: Value) -> Self::Output
+ {
+ self.x = self.x + rhs.clone();
+ self.y = self.y + rhs.clone();
+ self.z = self.z + rhs.clone();
+
+ self
+ }
+}
+
+impl<Value> Sub<Value> for Vec3<Value>
+where
+ Value: Sub<Value, Output = Value> + Clone,
+{
+ type Output = Self;
+
+ fn sub(mut self, rhs: Value) -> Self::Output
+ {
+ self.x = self.x - rhs.clone();
+ self.y = self.y - rhs.clone();
+ self.z = self.z - rhs.clone();
+
+ self
+ }
+}
+
impl<Value> Mul<Value> for Vec3<Value>
where
Value: Mul<Value, Output = Value> + Clone,