ft: tri support

This commit is contained in:
2026-04-30 16:28:16 +02:00
parent 388fbcbb8a
commit 27bdce5882
7 changed files with 204 additions and 12 deletions

View File

@@ -59,11 +59,7 @@ impl Vec3 {
pub fn random_unit_hemisphere(n: &Self) -> Self {
let v = Self::random_unit();
if n.dot(&v) > 0.0 {
v
} else {
-v
}
if n.dot(&v) > 0.0 { v } else { -v }
}
pub fn x(&self) -> &f32 {
@@ -190,6 +186,18 @@ impl Neg for Vec3 {
}
}
impl Add<&Vec3> for &Vec3 {
type Output = Vec3;
fn add(self, rhs: &Vec3) -> Vec3 {
Vec3 {
x: self.x + rhs.x,
y: self.y + rhs.y,
z: self.z + rhs.z,
}
}
}
impl Add<Vec3> for Vec3 {
type Output = Self;
@@ -202,6 +210,19 @@ impl Add<Vec3> for Vec3 {
}
}
impl Add<f32> for &Vec3 {
type Output = Vec3;
fn add(self, f: f32) -> Vec3 {
Vec3 {
x: self.x + f,
y: self.y + f,
z: self.z + f,
}
}
}
impl Add<f32> for Vec3 {
type Output = Self;
@@ -360,7 +381,6 @@ impl Mul<Vec3> for &f32 {
z: rhs.z * self,
}
}
}
impl MulAssign<Vec3> for Vec3 {