diff options
author | HampusM <hampus@hampusmat.com> | 2025-01-14 13:32:02 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2025-01-14 13:32:02 +0100 |
commit | 5fa358a465d32d1420a8cdfd23dd1a88ca4ae797 (patch) | |
tree | 8ae7c9cd7886bb81479ea2937f928b6a452d9654 /engine/src/data_types | |
parent | 3e509487b6f241f60c77bf3eb62c79a8aafa1143 (diff) |
feat(engine): add simple collision
Diffstat (limited to 'engine/src/data_types')
-rw-r--r-- | engine/src/data_types/vector.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/engine/src/data_types/vector.rs b/engine/src/data_types/vector.rs index 17953f4..6746b76 100644 --- a/engine/src/data_types/vector.rs +++ b/engine/src/data_types/vector.rs @@ -85,6 +85,11 @@ pub struct Vec3<Value> impl Vec3<f32> { + pub const BACK: Self = Self { x: 0.0, y: 1.0, z: -1.0 }; + pub const DOWN: Self = Self { x: 0.0, y: -1.0, z: 0.0 }; + pub const FRONT: Self = Self { x: 0.0, y: 1.0, z: 1.0 }; + pub const LEFT: Self = Self { x: -1.0, y: 0.0, z: 0.0 }; + pub const RIGHT: Self = Self { x: 1.0, y: 0.0, z: 0.0 }; pub const UP: Self = Self { x: 0.0, y: 1.0, z: 0.0 }; /// Returns the length of the vector. @@ -209,6 +214,22 @@ where } } +impl<Value> Mul for Vec3<Value> +where + Value: Mul<Value, Output = Value>, +{ + type Output = Self; + + fn mul(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>, |