rtiow: fix bug in calculation of t in Scale hitable.

This commit is contained in:
Bill Thiede 2023-02-13 20:55:13 -08:00
parent 1076e6dcaf
commit deb46acb5a

View File

@ -11,21 +11,15 @@ where
H: Hit, H: Hit,
{ {
hitable: H, hitable: H,
scale: Vec3, scale: f32,
} }
impl<H> Scale<H> impl<H> Scale<H>
where where
H: Hit, H: Hit,
{ {
pub fn new<V>(hitable: H, scale: V) -> Scale<H> pub fn new(hitable: H, scale: f32) -> Scale<H> {
where Scale { hitable, scale }
V: Into<Vec3>,
{
Scale {
hitable,
scale: scale.into(),
}
} }
} }
@ -38,6 +32,7 @@ where
if let Some(rec) = self.hitable.hit(moved_r, t_min, t_max) { if let Some(rec) = self.hitable.hit(moved_r, t_min, t_max) {
return Some(HitRecord { return Some(HitRecord {
p: rec.p * self.scale, p: rec.p * self.scale,
t: rec.t * self.scale,
..rec ..rec
}); });
} }