+= and /= for vectors

This commit is contained in:
wires 2025-05-27 22:22:32 -04:00
parent bfaf3c2cb6
commit e862a86fe6
Signed by: wires
SSH key fingerprint: SHA256:9GtP+M3O2IivPDlw1UY872UPUuJH2gI0yG6ExBxaaiM

View file

@ -1,6 +1,6 @@
use std::{
fmt,
ops::{Add, Deref, Div, Mul, Sub},
ops::{Add, AddAssign, Deref, Div, DivAssign, Mul, Sub},
};
pub mod shapes;
@ -94,6 +94,12 @@ impl Div<f32> for Vector {
}
}
impl DivAssign<f32> for Vector {
fn div_assign(&mut self, rhs: f32) {
*self = *self / rhs;
}
}
impl Add for Vector {
type Output = Self;
@ -102,6 +108,12 @@ impl Add for Vector {
}
}
impl AddAssign for Vector {
fn add_assign(&mut self, rhs: Self) {
*self = *self + rhs;
}
}
#[repr(transparent)]
#[derive(Clone, Copy)]
pub struct Point(glam::Vec3A);