diff options
author | HampusM <hampus@hampusmat.com> | 2023-10-26 00:57:44 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2023-10-26 00:57:44 +0200 |
commit | bfad46444cbdccc46666ac796aff1d06ac684b30 (patch) | |
tree | 22b074446bfba5b7f69be8e99640f01056910ed6 | |
parent | f94c1c531a1f9874e4303fb702f22b7e953c2a29 (diff) |
feat(engine): add scalar multiply impl for Vec3
-rw-r--r-- | engine/src/vector.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/engine/src/vector.rs b/engine/src/vector.rs index 0a2f88b..ab80aac 100644 --- a/engine/src/vector.rs +++ b/engine/src/vector.rs @@ -1,4 +1,4 @@ -use std::ops::{Add, Neg, Sub}; +use std::ops::{Add, Mul, Neg, Sub}; #[derive(Debug)] pub struct Vec2<Value> @@ -147,3 +147,19 @@ where self } } + +impl<Value> Mul<Value> for Vec3<Value> +where + Value: Mul<Value, Output = Value> + Clone, +{ + type Output = Self; + + fn mul(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 + } +} |