summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-10-26 19:31:13 +0200
committerHampusM <hampus@hampusmat.com>2023-10-26 19:31:13 +0200
commita0a7610bc1381b5c26c1677bb7679d022b168499 (patch)
tree19c540e3de22c29c4a75811b3d9d2ffd7cb569d7 /engine
parentbfad46444cbdccc46666ac796aff1d06ac684b30 (diff)
feat(engine): add Vec3 AddAssign & SubAssign impls
Diffstat (limited to 'engine')
-rw-r--r--engine/src/vector.rs26
1 files changed, 25 insertions, 1 deletions
diff --git a/engine/src/vector.rs b/engine/src/vector.rs
index ab80aac..e8d51d2 100644
--- a/engine/src/vector.rs
+++ b/engine/src/vector.rs
@@ -1,4 +1,4 @@
-use std::ops::{Add, Mul, Neg, Sub};
+use std::ops::{Add, AddAssign, Mul, Neg, Sub, SubAssign};
#[derive(Debug)]
pub struct Vec2<Value>
@@ -163,3 +163,27 @@ where
self
}
}
+
+impl<Value> AddAssign for Vec3<Value>
+where
+ Value: AddAssign<Value>,
+{
+ fn add_assign(&mut self, rhs: Self)
+ {
+ self.x += rhs.x;
+ self.y += rhs.y;
+ self.z += rhs.z;
+ }
+}
+
+impl<Value> SubAssign for Vec3<Value>
+where
+ Value: SubAssign<Value>,
+{
+ fn sub_assign(&mut self, rhs: Self)
+ {
+ self.x -= rhs.x;
+ self.y -= rhs.y;
+ self.z -= rhs.z;
+ }
+}