ft: 10: metals

This commit is contained in:
djaidjai committed 2026-04-16 14:04:55 +02:00
1 parent e8f84b590b
commit b756cc394a
12 files changed
+199 -41

No files matched your search

+19 -3
View File
@@ -1,14 +1,26 @@
use crate::{objects::traits::Hittable, ray::Ray, vec3::Vec3};
use std::sync::Arc;
use crate::{
objects::{materials::traits::Material, traits::Hittable},
ray::Ray,
vec3::Vec3,
};
pub struct Hit {
t: f32,
p: Vec3,
n: Vec3,
mat: Arc<dyn Material>,
}
impl Hit {
pub fn new(t: f32, p: Vec3, n: Vec3) -> Hit {
Hit { t: t, p: p, n: n }
pub fn new(t: f32, p: Vec3, n: Vec3, mat: Arc<dyn Material>) -> Self {
Self {
t: t,
p: p,
n: n,
mat: mat,
}
}
pub fn t(&self) -> &f32 {
@@ -23,6 +35,10 @@ impl Hit {
&self.n
}
pub fn mat(&self) -> Arc<dyn Material> {
self.mat.clone()
}
pub fn hit_list<T: Hittable>(hittables: &Vec<T>, r: &Ray) -> Option<Hit> {
let mut closest: Option<Hit> = None;
for hittable in hittables {
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.