diff options
Diffstat (limited to 'engine/src/vector.rs')
-rw-r--r-- | engine/src/vector.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/engine/src/vector.rs b/engine/src/vector.rs index 00d6a6f..a5ef911 100644 --- a/engine/src/vector.rs +++ b/engine/src/vector.rs @@ -1,5 +1,7 @@ use std::ops::{Add, AddAssign, Mul, Neg, Sub, SubAssign}; +use crate::color::Color; + #[derive(Debug, Default, Clone)] pub struct Vec2<Value> { @@ -64,6 +66,14 @@ impl Vec3<f32> } } +impl<Value> Vec3<Value> +{ + pub fn as_ptr(&self) -> *const Value + { + &self.x + } +} + impl<Value> Sub for Vec3<Value> where Value: Sub<Value, Output = Value>, @@ -215,3 +225,15 @@ where self.z -= rhs.z; } } + +impl<Value> From<Color<Value>> for Vec3<Value> +{ + fn from(color: Color<Value>) -> Self + { + Self { + x: color.red, + y: color.green, + z: color.blue, + } + } +} |