From: Lukas Jiriste Date: Sat, 23 Nov 2024 12:07:09 +0000 (+0100) Subject: Fix some minor bugs in the RT calculations X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=88d4c81dcd323fcdb361189f9b07b1586226310d;p=42%2FminiRT.git Fix some minor bugs in the RT calculations --- diff --git a/src/scene.c b/src/scene.c index 196ef43..841af39 100644 --- a/src/scene.c +++ b/src/scene.c @@ -18,7 +18,7 @@ static int is_bounded(const t_object *object) enum e_object_type type; type = object->type; - return (type == PLANE); + return (type != PLANE); } double get_cylinder_circumsphere_radius(const t_cylinder *cylinder) @@ -36,10 +36,10 @@ double dist_point_from_line(const t_ray *ray, t_vec3 point) t_vec3 start; t_vec3 projection; - start = vec_diff(point, ray->start); + start = vec_diff(ray->start, point); projection = vec_real_mul(ray->direction, vec_scalar_mul(ray->direction, start)); - return (vec_norm(projection)); + return (vec_norm(vec_diff(start, projection))); } int is_behind_ray(const t_ray *ray, t_vec3 point) @@ -240,6 +240,7 @@ t_color get_object_color(const t_ray *ray, const t_object *object, t_ray new_ray; const t_object *obstruction; + result = (t_color){.x = 0, .y = 0, .z = 0}; i = 0; while (i < scene->lights.size) {