From 5b0d859d0fbfb84ec143d894e023dcbd90980ad1 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 30 Oct 2023 19:45:58 +0100 Subject: feat(engine): add Vec3 scalar Sub & Add impls --- engine/src/vector.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'engine/src') 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 Add for Vec3 +where + Value: Add + 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 Sub for Vec3 +where + Value: Sub + 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 Mul for Vec3 where Value: Mul + Clone, -- cgit v1.2.3-18-g5258