summaryrefslogtreecommitdiff
path: root/engine/src/vector.rs
diff options
context:
space:
mode:
Diffstat (limited to 'engine/src/vector.rs')
-rw-r--r--engine/src/vector.rs34
1 files changed, 33 insertions, 1 deletions
diff --git a/engine/src/vector.rs b/engine/src/vector.rs
index 88a8198..0a2f88b 100644
--- a/engine/src/vector.rs
+++ b/engine/src/vector.rs
@@ -1,4 +1,4 @@
-use std::ops::{Neg, Sub};
+use std::ops::{Add, Neg, Sub};
#[derive(Debug)]
pub struct Vec2<Value>
@@ -100,6 +100,38 @@ where
}
}
+impl<Value> Add for Vec3<Value>
+where
+ Value: Add<Value, Output = Value>,
+{
+ type Output = Self;
+
+ fn add(self, rhs: Self) -> Self::Output
+ {
+ Self::Output {
+ x: self.x + rhs.x,
+ y: self.y + rhs.y,
+ z: self.z + rhs.z,
+ }
+ }
+}
+
+impl<Value> Add for &Vec3<Value>
+where
+ for<'a, 'b> &'a Value: Add<&'b Value, Output = Value>,
+{
+ type Output = Vec3<Value>;
+
+ fn add(self, rhs: Self) -> Self::Output
+ {
+ Self::Output {
+ x: &self.x + &rhs.x,
+ y: &self.y + &rhs.y,
+ z: &self.z + &rhs.z,
+ }
+ }
+}
+
impl<Value> Neg for Vec3<Value>
where
Value: Neg<Output = Value>,