From bfad46444cbdccc46666ac796aff1d06ac684b30 Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 26 Oct 2023 00:57:44 +0200 Subject: feat(engine): add scalar multiply impl for Vec3 --- engine/src/vector.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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 @@ -147,3 +147,19 @@ where self } } + +impl Mul for Vec3 +where + Value: Mul + 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 + } +} -- cgit v1.2.3-18-g5258