summaryrefslogtreecommitdiff
path: root/engine/src/vector.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-11-12 22:38:52 +0100
committerHampusM <hampus@hampusmat.com>2023-11-12 22:57:19 +0100
commit8d821588cd4f51d4ae9c4ef52d45c0af0e1ce9e5 (patch)
treeed1b0dd30e801b9a70537b9806a445e4212978b3 /engine/src/vector.rs
parent67023d6a095f457a2579367d59d13c6c804e7108 (diff)
feat(engine): add basic flat lighting
Diffstat (limited to 'engine/src/vector.rs')
-rw-r--r--engine/src/vector.rs22
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,
+ }
+ }
+}