X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=support%2Fvec3.rs;h=a515bde2a2ffe4fd50e0f8046db33f00f06d6c33;hb=8f5b525e37e82d260601e7052a49a6515b6100d8;hp=85d3cc34a79c98e0274befc0681884edbcae0463;hpb=b1f47d18bd76c1d1475f992f021e714289f4b79a;p=mandelwow.git diff --git a/support/vec3.rs b/support/vec3.rs index 85d3cc3..a515bde 100644 --- a/support/vec3.rs +++ b/support/vec3.rs @@ -4,10 +4,11 @@ use std::f32; use std::ops::Add; use std::ops::AddAssign; use std::ops::Sub; +use std::ops::SubAssign; use std::ops::Mul; #[derive(Default, PartialEq, Debug, Clone, Copy)] -pub struct Vec3 (pub f32, pub f32, pub f32); +pub struct Vec3(pub f32, pub f32, pub f32); impl Add for Vec3 { type Output = Vec3; @@ -29,6 +30,12 @@ impl Sub for Vec3 { } } +impl SubAssign for Vec3 { + fn sub_assign(&mut self, other: Vec3) { + *self = Vec3(self.0 - other.0, self.1 - other.1, self.2 - other.2) + } +} + impl Mul for Vec3 { type Output = Vec3; fn mul(self, f: f32) -> Vec3 {