const t_object *obstruction;
t_vec3 normal;
double angle_multiplier;
+ double distance;
new_ray.start = point;
new_ray.direction = vec_diff(light->position, new_ray.start);
+ distance = vec_norm(new_ray.direction);
+ new_ray.direction = vec_real_mul(new_ray.direction, 1 / distance);
obstruction = find_nearest_object(&new_ray, &scene->objects, object);
normal = get_object_normal(object, point);
angle_multiplier = vec_scalar_mul(normal, new_ray.direction)
if (object->type == PLANE)
angle_multiplier = fabs(angle_multiplier);
if (angle_multiplier > 0 && (!obstruction
- || 1 < get_intersection_arg(&new_ray, obstruction)
+ || distance < get_intersection_arg(&new_ray, obstruction)
|| get_intersection_arg(&new_ray, obstruction) < 0))
return (vec_real_mul(
vec_elwise_mul(light->color, object->object.plane.color),