From 93c8652116586c10daaa8d61d3d1af047058eb25 Mon Sep 17 00:00:00 2001 From: numzero Date: Thu, 20 Nov 2025 13:23:04 +0300 Subject: [PATCH] =?UTF-8?q?ensure=20rays=20don=E2=80=99t=20propagate=20bac?= =?UTF-8?q?kwards?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/trace.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/trace.rs b/src/trace.rs index baa2633..984f9d9 100644 --- a/src/trace.rs +++ b/src/trace.rs @@ -120,10 +120,12 @@ pub struct Hit { impl Scene { pub fn trace_ray(&self, ray: Ray) -> Option { + const EPS: f32 = -1e-3; let hit = self .objects .iter() .filter_map(|obj| obj.trace_ray(ray)) + .filter(|h| h.dist >= EPS) .min_by(|a, b| f32::total_cmp(&a.dist, &b.dist))?; Some(Hit { incident: Ray {