shapes: fix translation handling in intersection test.
This commit is contained in:
parent
e419994fae
commit
fc5ef09cc3
@ -261,9 +261,10 @@ impl Shape {
|
||||
/// assert_eq!(xs[0].object, &p);
|
||||
/// ```
|
||||
pub fn intersect<'s>(shape: &'s Shape, ray: &Ray) -> Intersections<'s> {
|
||||
let local_ray = ray.transform(shape.inverse_transform);
|
||||
match shape.geometry {
|
||||
Geometry::Sphere => sphere::intersect(shape, ray),
|
||||
Geometry::Plane => plane::intersect(shape, ray),
|
||||
Geometry::Sphere => sphere::intersect(shape, &local_ray),
|
||||
Geometry::Plane => plane::intersect(shape, &local_ray),
|
||||
}
|
||||
}
|
||||
|
||||
@ -275,7 +276,6 @@ mod sphere {
|
||||
tuples::{dot, Tuple},
|
||||
};
|
||||
pub fn intersect<'s>(shape: &'s Shape, ray: &Ray) -> Intersections<'s> {
|
||||
let ray = ray.transform(shape.inverse_transform);
|
||||
let sphere_to_ray = ray.origin - Tuple::point(0., 0., 0.);
|
||||
let a = dot(ray.direction, ray.direction);
|
||||
let b = 2. * dot(ray.direction, sphere_to_ray);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user