From: Lukas Jiriste Date: Sat, 4 Jan 2025 12:36:28 +0000 (+0100) Subject: Fix not rendering the inside of objects correctly X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=71d73f569cee651b91c5ac794c6c36a02ef02130;p=42%2FminiRT.git 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. --- 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);