aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2021-02-06 17:27:42 +0100
committerJulian T <julian@jtle.dk>2021-02-06 17:27:42 +0100
commit0d5e6bd9363d5ed5c4f28174819fc0f5fd9aa586 (patch)
treef9ecafe7350ad616486e509ed55904295f505f83 /src/core
parent1e83ea211055eb234b89c69b5d03602e3fcb98fb (diff)
Reorganized scene module, and fixed bug in sphere intersect
Diffstat (limited to 'src/core')
-rw-r--r--src/core/vector3.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/core/vector3.rs b/src/core/vector3.rs
index 6f4d6ab..10de647 100644
--- a/src/core/vector3.rs
+++ b/src/core/vector3.rs
@@ -2,7 +2,7 @@
//!
//! Also add more 3d math things needed for shading and 3d calculations.
use crate::{Float, Number};
-use std::ops::{Mul, Sub, Add, DivAssign};
+use std::ops::{Mul, Sub, Add, DivAssign, Neg};
use std::fmt;
#[derive(Clone, Copy)]
@@ -61,6 +61,18 @@ impl<T: Number> Mul<T> for Vector3<T> {
}
}
+impl<T: Number> Neg for Vector3<T> {
+ type Output = Self;
+
+ fn neg(self) -> Self::Output {
+ Self::Output::new_xyz(
+ -self.x,
+ -self.y,
+ -self.z,
+ )
+ }
+}
+
impl<T: Number> DivAssign<T> for Vector3<T> {
fn div_assign(&mut self, op: T) {
self.x /= op;