From 71d73f569cee651b91c5ac794c6c36a02ef02130 Mon Sep 17 00:00:00 2001 From: Lukas Jiriste Date: Sat, 4 Jan 2025 13:36:28 +0100 Subject: [PATCH] Fix not rendering the inside of objects correctly The optimization of seeing whether the circumsphere would interact with a ray contains a check for whether the circumsphere CENTER is behind the ray origin instead of its furthest point. This is now rectified which fixes the rendering when inside an object. --- src/scene.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scene.c b/src/scene.c index 44fb0b5..6b35944 100644 --- a/src/scene.c +++ b/src/scene.c @@ -83,7 +83,7 @@ int intersects_circumsphere(const t_ray *ray, const t_object *object) double distance; circumsphere = get_circumsphere(object); - if (is_behind_ray(ray, circumsphere.center)) + if (is_behind_ray(ray, vec_add(circumsphere.center, vec_real_mul(ray->direction, circumsphere.radius)))) return (0); distance = dist_point_from_line(ray, circumsphere.center); return (distance < circumsphere.radius); -- 2.30.2