ensure rays don’t propagate backwards
This commit is contained in:
parent
91473f08ae
commit
93c8652116
|
|
@ -120,10 +120,12 @@ pub struct Hit {
|
|||
|
||||
impl Scene {
|
||||
pub fn trace_ray(&self, ray: Ray) -> Option<Hit> {
|
||||
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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user