Skip to content

Commit a0d9d2c

Browse files
author
Loic Mohin
committed
forgot one file
1 parent d73f945 commit a0d9d2c

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

inters/ray_sphere.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,25 @@
66
/* By: TheTerror <jfaye@student.42lyon.fr> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2023/08/23 20:19:01 by TheTerror #+# #+# */
9-
/* Updated: 2023/09/08 16:21:52 by TheTerror ### ########lyon.fr */
9+
/* Updated: 2024/01/25 23:21:38 by lmohin ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

1313
#include "inters.h"
1414

1515
double ft_ray_inter_sp_op(t_vars *v, t_sp *sp);
1616

17-
t_bool ft_ray_inter_sp(t_vars *v, t_sp *sp)
17+
t_bool ft_ray_inter_sp(t_vars *v, t_sp *sp, int x)
1818
{
1919
double s;
2020

2121
s = ft_ray_inter_sp_op(v, sp);
2222
if (ft_assess_color(v, s))
23+
{
24+
v->obj.type = 2;
25+
v->obj.index = x;
2326
return (v->ray.color = ft_color(&sp->rgb), __TRUE);
27+
}
2428
return (__FALSE);
2529
}
2630

@@ -64,13 +68,18 @@ double ft_ray_inter_sp_op(t_vars *v, t_sp *sp)
6468
delta = ft_sq(b) - (4 * a * c);
6569
if (delta < 0)
6670
return (delta);
71+
/* printf("dir: %f %f %f\n", v->ray.dir.x, v->ray.dir.y, v->ray.dir.z);
72+
printf("origin: %f %f %f\n", v->ray.o.x, v->ray.o.y, v->ray.o.z);
73+
printf("sp: %f %f %f\n", sp->o.x, sp->o.y, sp->o.z);*/
6774
s1 = (-b - sqrt(delta)) / (2 * a);
6875
s2 = (-b + sqrt(delta)) / (2 * a);
6976
return (ft_assessthesolution(s1, s2));
7077
}
7178

7279
double ft_assessthesolution(double s1, double s2)
7380
{
81+
// printf("dist: %f %f\n", s1, s2);
82+
// exit(0);
7483
if (s1 >= 0 && s2 >= 0)
7584
{
7685
if (s1 < s2)

0 commit comments

Comments
 (0)