compute reflections #2

Closed
noteuclid wants to merge 19 commits from two-way into qt-ui
Showing only changes of commit 93c8652116 - Show all commits

View File

@ -120,10 +120,12 @@ pub struct Hit {
impl Scene { impl Scene {
pub fn trace_ray(&self, ray: Ray) -> Option<Hit> { pub fn trace_ray(&self, ray: Ray) -> Option<Hit> {
const EPS: f32 = -1e-3;
let hit = self let hit = self
.objects .objects
.iter() .iter()
.filter_map(|obj| obj.trace_ray(ray)) .filter_map(|obj| obj.trace_ray(ray))
.filter(|h| h.dist >= EPS)
.min_by(|a, b| f32::total_cmp(&a.dist, &b.dist))?; .min_by(|a, b| f32::total_cmp(&a.dist, &b.dist))?;
Some(Hit { Some(Hit {
incident: Ray { incident: Ray {