Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d1a98e03d4 | |||
| 00372efcc9 | |||
| b5ea2bc794 | |||
| fb27cad32e | |||
| 01b852210b | |||
| e14bdb0918 | |||
| 9dc326eaf1 | |||
| 6d3aa4ade8 | |||
| 99ee589515 | |||
| 4966d0681a |
@@ -1 +1,23 @@
|
||||
# better_ray_tracer
|
||||
RayTracer est un projet qui consiste à créer un programme de lancer de rayons (ray tracing) capable de générer des images photoréalistes en simulant le trajet de la lumière. L'objectif principal est de développer un moteur de rendu qui calcule les interactions de la lumière avec des objets virtuels pour produire des images en deux dimensions.
|
||||
Voici quelques caractéristiques clés de RayTracer :
|
||||
|
||||
|
||||
Lancer de Rayons : Implémentation de l'algorithme de lancer de rayons pour simuler le trajet de la lumière et calculer les couleurs des pixels en fonction des objets et des sources de lumière dans la scène.
|
||||
|
||||
|
||||
Géométrie 3D : Définition et gestion d'objets géométriques en trois dimensions, tels que des sphères, des plans et des cylindres, qui composent la scène à rendre.
|
||||
|
||||
|
||||
Sources de Lumière : Configuration de différentes sources de lumière pour éclairer la scène, en simulant les ombres et les reflets pour un rendu réaliste.
|
||||
|
||||
|
||||
Matériaux et Textures : Application de différents matériaux et textures aux objets pour simuler diverses propriétés de surface, telles que la réflexion, la réfraction et la diffusion.
|
||||
|
||||
|
||||
Caméra Virtuelle : Implémentation d'une caméra virtuelle pour définir le point de vue à partir duquel la scène est rendue, permettant ainsi de contrôler la perspective et la composition de l'image.
|
||||
|
||||
|
||||
Optimisation : Recherche et application de techniques d'optimisation pour améliorer les performances du moteur de rendu, telles que l'accélération des calculs d'intersection et l'utilisation de structures de données efficaces.
|
||||
|
||||
|
||||
Ce projet offre une excellente opportunité d'explorer les concepts de la synthèse d'images et d'approfondir la compréhension des algorithmes de rendu graphique et de la modélisation 3D.
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/14 18:28:42 by yantoine #+# #+# */
|
||||
/* Updated: 2025/02/25 01:44:31 by yantoine ### ########.fr */
|
||||
/* Updated: 2025/03/05 16:18:05 by yantoine ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -24,3 +24,20 @@ int check_if_max(t_scene scene, const int to_test, const int max)
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
|
||||
int check_nb_element(t_scene scene)
|
||||
{
|
||||
if (scene.num_spheres > MAX_SPHERES)
|
||||
return (0);
|
||||
if (scene.num_planes > MAX_PLANES)
|
||||
return (0);
|
||||
if (scene.num_cylinders > MAX_CYLINDERS)
|
||||
return (0);
|
||||
if (scene.num_lights > MAX_LIGHTS)
|
||||
return (0);
|
||||
if (scene.num_ambient > MAX_AMBIENT)
|
||||
return (0);
|
||||
if (scene.num_camera > MAX_CAMERA)
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/14 01:41:17 by yantoine #+# #+# */
|
||||
/* Updated: 2025/02/25 19:36:04 by yantoine ### ########.fr */
|
||||
/* Updated: 2025/03/17 16:03:35 by yantoine ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -34,32 +34,58 @@ static inline t_scene parsing_line(char *line, t_scene scene)
|
||||
return (scene);
|
||||
}
|
||||
|
||||
static t_calc init_calc(void)
|
||||
{
|
||||
t_calc init;
|
||||
|
||||
init.count = 0;
|
||||
init.line = NULL;
|
||||
init.data = ft_calloc(1, 1);
|
||||
return (init);
|
||||
}
|
||||
|
||||
static char **get_all_file(int fd)
|
||||
{
|
||||
char *join;
|
||||
char *line;
|
||||
char *data;
|
||||
char **splited;
|
||||
int first;
|
||||
t_calc calc;
|
||||
|
||||
first = 1;
|
||||
line = NULL;
|
||||
data = ft_calloc(1, 1);
|
||||
calc = init_calc();
|
||||
while (1)
|
||||
{
|
||||
if (!first)
|
||||
data = join;
|
||||
line = get_next_line(fd);
|
||||
if (!line)
|
||||
if (calc.count > MAX_SPHERES + MAX_PLANES \
|
||||
+ MAX_CYLINDERS + MAX_LIGHTS + MAX_AMBIENT + MAX_CAMERA)
|
||||
{
|
||||
free(calc.join);
|
||||
ft_putstr_fd("Erreur:\n max element reached\n", 2);
|
||||
close(fd);
|
||||
exit(1);
|
||||
}
|
||||
if (calc.count != 0)
|
||||
calc.data = calc.join;
|
||||
calc.line = get_next_line(fd);
|
||||
if (!calc.line)
|
||||
break ;
|
||||
join = ft_strjoin(data, line);
|
||||
free(line);
|
||||
free(data);
|
||||
first = 0;
|
||||
calc.join = ft_strjoin(calc.data, calc.line);
|
||||
free(calc.line);
|
||||
free(calc.data);
|
||||
calc.count++;
|
||||
}
|
||||
splited = ft_split(join, '\n');
|
||||
free(data);
|
||||
return (splited);
|
||||
calc.splited = ft_split(calc.join, '\n');
|
||||
return (free(calc.data), calc.splited);
|
||||
}
|
||||
|
||||
static t_scene initialisation(int fd, const char *filename)
|
||||
{
|
||||
t_scene scene;
|
||||
|
||||
scene = create_scene();
|
||||
if (fd <= 0 || !have_extension(filename))
|
||||
{
|
||||
printf("Erreur : impossible d'ouvrir %s\n", filename);
|
||||
scene.no = 1;
|
||||
return (scene);
|
||||
}
|
||||
scene.fd_if_exit = fd;
|
||||
return (scene);
|
||||
}
|
||||
|
||||
// ----- Parsing du fichier de configuration -----
|
||||
@@ -70,14 +96,10 @@ t_scene load_config(const char *filename)
|
||||
char *line;
|
||||
t_scene scene;
|
||||
|
||||
scene = create_scene();
|
||||
fd = open(filename, O_RDONLY);
|
||||
if (fd <= 0 || !have_extension(filename))
|
||||
{
|
||||
printf("Erreur : impossible d'ouvrir %s\n", filename);
|
||||
scene = initialisation(fd, filename);
|
||||
if (scene.no == 1)
|
||||
return (scene);
|
||||
}
|
||||
scene.fd_if_exit = fd;
|
||||
scene.all_file = get_all_file(fd);
|
||||
i = -1;
|
||||
while (scene.all_file[++i])
|
||||
@@ -85,8 +107,13 @@ t_scene load_config(const char *filename)
|
||||
line = scene.all_file[i];
|
||||
if (!line)
|
||||
break ;
|
||||
if (!check_nb_element(scene))
|
||||
{
|
||||
ft_free_array(scene.all_file);
|
||||
ft_putstr_fd("Error\n Bad number element\n", 1);
|
||||
exit(1);
|
||||
}
|
||||
scene = parsing_line(line, scene);
|
||||
}
|
||||
ft_free_array(scene.all_file);
|
||||
return (scene);
|
||||
return (ft_free_array(scene.all_file), scene);
|
||||
}
|
||||
|
||||
+4
-4
@@ -6,7 +6,7 @@
|
||||
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/19 16:07:55 by yantoine #+# #+# */
|
||||
/* Updated: 2025/02/19 16:47:28 by yantoine ### ########.fr */
|
||||
/* Updated: 2025/03/05 14:19:33 by yantoine ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -25,7 +25,7 @@ static bool intersect_spheres(const t_ray ray, t_hit *hit, t_sphere *spheres,
|
||||
while (i < num_spheres)
|
||||
{
|
||||
t = intersect_sphere(ray, spheres[i], &n);
|
||||
if (t > 1e-3f && t < hit->t)
|
||||
if (t > 0.001f && t < hit->t)
|
||||
{
|
||||
hit->t = t;
|
||||
hit->normal = n;
|
||||
@@ -50,7 +50,7 @@ static bool intersect_planes(const t_ray ray, t_hit *hit, t_plane *planes,
|
||||
while (i < num_planes)
|
||||
{
|
||||
t = intersect_plane(ray, planes[i], &n);
|
||||
if (t > 1e-3f && t < hit->t)
|
||||
if (t > 0.001f && t < hit->t)
|
||||
{
|
||||
hit->t = t;
|
||||
hit->normal = n;
|
||||
@@ -75,7 +75,7 @@ static bool intersect_cylinders(const t_ray ray, t_hit *hit,
|
||||
while (i < num_cylinders)
|
||||
{
|
||||
t = intersect_cylinder(ray, cylinders[i], &n);
|
||||
if (t > 1e-3f && t < hit->t)
|
||||
if (t > 0.001f && t < hit->t)
|
||||
{
|
||||
hit->t = t;
|
||||
hit->normal = n;
|
||||
|
||||
+1
-1
Submodule libft updated: 17b5a6fdc0...1d92a61957
@@ -6,7 +6,7 @@
|
||||
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/17 19:54:03 by yantoine #+# #+# */
|
||||
/* Updated: 2025/02/25 14:52:51 by yantoine ### ########.fr */
|
||||
/* Updated: 2025/03/17 16:53:05 by yantoine ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -17,10 +17,12 @@ static int init_app_config(t_app *app, int argc, char **argv)
|
||||
t_scene scene;
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
scene = load_config(argv[1]);
|
||||
app->win_width = WIDTH;
|
||||
app->win_height = HEIGHT;
|
||||
app->scene = scene;
|
||||
app->win_width = WIDTH;
|
||||
app->win_height = HEIGHT;
|
||||
app->scene = scene;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -69,7 +71,10 @@ int main(int argc, char **argv)
|
||||
if (!check_number(app.scene) || \
|
||||
app.scene.num_camera == 0 \
|
||||
|| init_mlx_and_image(&app))
|
||||
{
|
||||
ft_putstr_fd("Erreur: \n", 2);
|
||||
return (1);
|
||||
}
|
||||
update_camera(&app);
|
||||
render_scene(&app);
|
||||
mlx_hook(app.win, 2, 1L << 0, key_press, &app);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/13 20:02:36 by yantoine #+# #+# */
|
||||
/* Updated: 2025/02/25 19:21:06 by yantoine ### ########.fr */
|
||||
/* Updated: 2025/03/17 16:04:57 by yantoine ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -125,6 +125,7 @@ typedef struct s_scene
|
||||
t_camera camera;
|
||||
t_ray ray;
|
||||
int problem;
|
||||
int no;
|
||||
int num_spheres;
|
||||
int num_planes;
|
||||
int num_cylinders;
|
||||
@@ -164,6 +165,10 @@ typedef struct s_app
|
||||
// ----- Calcul
|
||||
typedef struct s_calc
|
||||
{
|
||||
char *join;
|
||||
char *line;
|
||||
char *data;
|
||||
char **splited;
|
||||
t_vec3 oc;
|
||||
float a;
|
||||
float b;
|
||||
@@ -206,6 +211,7 @@ typedef struct s_calc
|
||||
t_vec3 view_dir;
|
||||
t_vec3 half_dir;
|
||||
float spec;
|
||||
int count;
|
||||
|
||||
} t_calc;
|
||||
|
||||
@@ -241,6 +247,7 @@ int check_tokens(char **tokens, int expected);
|
||||
int isdigit_token(char **tokens);
|
||||
int have_extension(const char *line);
|
||||
int check_if_max(t_scene scene, const int to_test, const int max);
|
||||
int check_nb_element(t_scene scene);
|
||||
|
||||
// Intersection
|
||||
float intersect_cylinder(t_ray ray, t_cylinder cy, t_vec3 *hitNormal);
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@
|
||||
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/14 20:05:49 by yantoine #+# #+# */
|
||||
/* Updated: 2025/02/25 19:38:13 by yantoine ### ########.fr */
|
||||
/* Updated: 2025/03/07 16:11:53 by yantoine ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -36,7 +36,7 @@ t_vec3 parse_color(const char *token, t_scene scene)
|
||||
{
|
||||
ft_free_array(token_color);
|
||||
ft_free_array(scene.token_if_exit);
|
||||
ft_putendl_fd("error", 2);
|
||||
ft_putendl_fd("Error\nToken or range are bad\n", 2);
|
||||
ft_free_array(scene.all_file);
|
||||
close(scene.fd_if_exit);
|
||||
exit(1);
|
||||
|
||||
+10
-10
@@ -6,7 +6,7 @@
|
||||
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/17 18:54:45 by yantoine #+# #+# */
|
||||
/* Updated: 2025/02/19 16:59:10 by yantoine ### ########.fr */
|
||||
/* Updated: 2025/03/05 14:23:21 by yantoine ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -40,13 +40,13 @@ int init_intersection(t_ray ray, t_cylinder cy, t_calc *calc)
|
||||
void compute_side_intersection(t_cylinder cy, t_calc *calc)
|
||||
{
|
||||
calc->t_side = -1;
|
||||
if (calc->t0 > 1e-3f)
|
||||
if (calc->t0 > 0.001f)
|
||||
{
|
||||
calc->y = calc->oc_dot_v + calc->t0 * calc->d_dot_v;
|
||||
if (fabs(calc->y) <= cy.height / 2.0f)
|
||||
calc->t_side = calc->t0;
|
||||
}
|
||||
if (calc->t_side < 0 && calc->t1 > 1e-3f)
|
||||
if (calc->t_side < 0 && calc->t1 > 0.001f)
|
||||
{
|
||||
calc->y = calc->oc_dot_v + calc->t1 * calc->d_dot_v;
|
||||
if (fabs(calc->y) <= cy.height / 2.0f)
|
||||
@@ -59,10 +59,10 @@ void compute_side_intersection(t_cylinder cy, t_calc *calc)
|
||||
void compute_cap_intersection(t_ray ray, t_cylinder cy, t_calc *calc)
|
||||
{
|
||||
calc->t_cap = -1;
|
||||
if (fabs(calc->d_dot_v) > 1e-6f)
|
||||
if (fabs(calc->d_dot_v) > 0.001f)
|
||||
{
|
||||
calc->t_bot = ((-cy.height / 2.0f) - calc->oc_dot_v) / calc->d_dot_v;
|
||||
if (calc->t_bot > 1e-3f)
|
||||
if (calc->t_bot > 0.001f)
|
||||
{
|
||||
calc->p = vec3_add(ray.origin, vec3_scale(calc->d, calc->t_bot));
|
||||
calc->cp = vec3_sub(calc->p, cy.center);
|
||||
@@ -72,7 +72,7 @@ void compute_cap_intersection(t_ray ray, t_cylinder cy, t_calc *calc)
|
||||
calc->t_cap = calc->t_bot;
|
||||
}
|
||||
calc->t_top = ((cy.height / 2.0f) - calc->oc_dot_v) / calc->d_dot_v;
|
||||
if (calc->t_top > 1e-3f)
|
||||
if (calc->t_top > 0.001f)
|
||||
{
|
||||
calc->p = vec3_add(ray.origin, vec3_scale(calc->d, calc->t_top));
|
||||
calc->cp = vec3_sub(calc->p, cy.center);
|
||||
@@ -89,18 +89,18 @@ void compute_cap_intersection(t_ray ray, t_cylinder cy, t_calc *calc)
|
||||
//proche entre la surface latérale et les capuchons
|
||||
float select_final_intersection(t_calc *calc)
|
||||
{
|
||||
if (calc->t_side > 1e-3f && calc->t_cap > 1e-3f)
|
||||
if (calc->t_side > 0.001f && calc->t_cap > 0.001f)
|
||||
{
|
||||
if (calc->t_side < calc->t_cap)
|
||||
calc->t_final = calc->t_side;
|
||||
else
|
||||
calc->t_final = calc->t_cap;
|
||||
}
|
||||
else if (calc->t_side > 1e-3f)
|
||||
else if (calc->t_side > 0.001f)
|
||||
calc->t_final = calc->t_side;
|
||||
else
|
||||
calc->t_final = calc->t_cap;
|
||||
if (calc->t_final > 1e-3f)
|
||||
if (calc->t_final > 0.001f)
|
||||
return (calc->t_final);
|
||||
return (-1);
|
||||
}
|
||||
@@ -112,7 +112,7 @@ void compute_hit_normal(t_ray ray, t_cylinder cy, t_calc *calc,
|
||||
calc->hit_point = vec3_add(ray.origin, vec3_scale(calc->d, calc->t_final));
|
||||
calc->cp = vec3_sub(calc->hit_point, cy.center);
|
||||
calc->proj = vec3_dot(calc->cp, calc->v);
|
||||
if (fabs(calc->proj) < cy.height / 2.0f - 1e-3f)
|
||||
if (fabs(calc->proj) < cy.height / 2.0f - 0.001f)
|
||||
{
|
||||
calc->n = vec3_sub(calc->cp, vec3_scale(calc->v, calc->proj));
|
||||
*hitNormal = vec3_normalize(calc->n);
|
||||
|
||||
+3
-3
@@ -6,7 +6,7 @@
|
||||
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/15 19:49:41 by yantoine #+# #+# */
|
||||
/* Updated: 2025/02/19 16:50:10 by yantoine ### ########.fr */
|
||||
/* Updated: 2025/03/05 14:24:37 by yantoine ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -33,10 +33,10 @@ float intersect_plane(t_ray ray, t_plane p, t_vec3 *hitNormal)
|
||||
float t;
|
||||
|
||||
denom = vec3_dot(p.normal, ray.dir);
|
||||
if (fabs(denom) < 1e-6f)
|
||||
if (fabs(denom) < 0.000001f)
|
||||
return (-1);
|
||||
t = vec3_dot(vec3_sub(p.point, ray.origin), p.normal) / denom;
|
||||
if (t < 1e-3f)
|
||||
if (t < 0.001f)
|
||||
return (-1);
|
||||
*hitNormal = p.normal;
|
||||
return (t);
|
||||
|
||||
+3
-3
@@ -6,7 +6,7 @@
|
||||
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/15 19:46:16 by yantoine #+# #+# */
|
||||
/* Updated: 2025/02/19 16:59:34 by yantoine ### ########.fr */
|
||||
/* Updated: 2025/03/05 14:25:32 by yantoine ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -40,11 +40,11 @@ float intersect_sphere(t_ray ray, t_sphere s, t_vec3 *hitNormal)
|
||||
calc.sqrt_disc = sqrtf(calc.disc);
|
||||
calc.t0 = (-calc.b - calc.sqrt_disc) / (2 * calc.a);
|
||||
calc.t1 = (-calc.b + calc.sqrt_disc) / (2 * calc.a);
|
||||
if (calc.t0 > 1e-3f)
|
||||
if (calc.t0 > 0.001f)
|
||||
calc.t = calc.t0;
|
||||
else
|
||||
calc.t = calc.t1;
|
||||
if (calc.t < 1e-3f)
|
||||
if (calc.t < 0.001f)
|
||||
return (-1);
|
||||
calc.hit_point = vec3_add(ray.origin, vec3_scale(ray.dir, calc.t));
|
||||
*hitNormal = vec3_normalize(vec3_sub(calc.hit_point, s.center));
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@
|
||||
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/14 20:23:21 by yantoine #+# #+# */
|
||||
/* Updated: 2025/02/25 19:37:18 by yantoine ### ########.fr */
|
||||
/* Updated: 2025/03/07 16:12:25 by yantoine ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -22,7 +22,7 @@ char **get_tokens_secure(t_scene scene, const int numObject,
|
||||
if (!check_tokens(tokens, supposed_nb_token) || !isdigit_token(tokens + 1))
|
||||
{
|
||||
ft_free_array(tokens);
|
||||
ft_putendl_fd("error", 2);
|
||||
ft_putendl_fd("Error\nTokens are bad\n", 2);
|
||||
ft_free_array(scene.all_file);
|
||||
close(scene.fd_if_exit);
|
||||
exit(1);
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@
|
||||
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/15 19:16:01 by yantoine #+# #+# */
|
||||
/* Updated: 2025/02/25 19:37:48 by yantoine ### ########.fr */
|
||||
/* Updated: 2025/03/07 16:12:57 by yantoine ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -37,7 +37,7 @@ t_vec3 parse_vector(const char *token, t_scene scene)
|
||||
{
|
||||
ft_free_array(token_vector);
|
||||
ft_free_array(scene.token_if_exit);
|
||||
ft_putendl_fd("error", 2);
|
||||
ft_putendl_fd("Error\nBad Tokens", 2);
|
||||
ft_free_array(scene.all_file);
|
||||
close(scene.fd_if_exit);
|
||||
exit(1);
|
||||
|
||||
+1
-4
@@ -6,7 +6,7 @@
|
||||
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/17 19:22:27 by yantoine #+# #+# */
|
||||
/* Updated: 2025/02/25 19:06:52 by yantoine ### ########.fr */
|
||||
/* Updated: 2025/02/25 19:40:54 by yantoine ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -22,7 +22,6 @@ int key_press(int keycode, t_app *app)
|
||||
mlx_destroy_window(app->mlx, app->win);
|
||||
mlx_destroy_display(app->mlx);
|
||||
free(app->mlx);
|
||||
free(app->scene.all_file);
|
||||
exit(0);
|
||||
}
|
||||
return (0);
|
||||
@@ -36,8 +35,6 @@ int handle_close(void *param)
|
||||
mlx_destroy_image(app->mlx, app->img);
|
||||
mlx_destroy_window(app->mlx, app->win);
|
||||
mlx_destroy_display(app->mlx);
|
||||
ft_free_array(app->scene.all_file);
|
||||
free(app->scene.all_file);
|
||||
free(app->mlx);
|
||||
exit(0);
|
||||
return (0);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
A 0 255,255,255
|
||||
|
||||
C 4444444444444444444444444,1111111111111111111111111,9999999999999999999999999999 0,0,-1 70
|
||||
C 444444444444444444444444444444444444444444444,1111111111111111111111111,9999999999999999999999999999 0,0,-1 70
|
||||
|
||||
L 11,40,50 1 255,255,255
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -6,7 +6,7 @@
|
||||
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/17 18:58:42 by yantoine #+# #+# */
|
||||
/* Updated: 2025/02/19 16:50:54 by yantoine ### ########.fr */
|
||||
/* Updated: 2025/03/05 14:26:08 by yantoine ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
static bool check_shadow_sphere(const t_ray shadow_ray, float max_t,
|
||||
t_scene scene)
|
||||
{
|
||||
const float epsilon = 1e-3f;
|
||||
const float epsilon = 0.001f;
|
||||
int i;
|
||||
t_vec3 dummy;
|
||||
float t;
|
||||
@@ -36,7 +36,7 @@ static bool check_shadow_sphere(const t_ray shadow_ray, float max_t,
|
||||
static bool check_shadow_plane(const t_ray shadow_ray, float max_t,
|
||||
t_scene scene)
|
||||
{
|
||||
const float epsilon = 1e-3f;
|
||||
const float epsilon = 0.001f;
|
||||
int i;
|
||||
t_vec3 dummy;
|
||||
float t;
|
||||
@@ -56,7 +56,7 @@ static bool check_shadow_plane(const t_ray shadow_ray, float max_t,
|
||||
static bool check_shadow_cylinder(const t_ray shadow_ray, float max_t,
|
||||
t_scene scene)
|
||||
{
|
||||
const float epsilon = 1e-3f;
|
||||
const float epsilon = 0.001f;
|
||||
int i;
|
||||
t_vec3 dummy;
|
||||
float t;
|
||||
@@ -75,7 +75,7 @@ static bool check_shadow_cylinder(const t_ray shadow_ray, float max_t,
|
||||
// Fonction principale qui détermine si le point est dans l'ombre
|
||||
bool is_in_shadow(t_vec3 hitPoint, t_vec3 lightPos, t_scene scene)
|
||||
{
|
||||
const float epsilon = 1e-3f;
|
||||
const float epsilon = 0.001f;
|
||||
t_vec3 to_light;
|
||||
float max_t;
|
||||
t_vec3 l;
|
||||
|
||||
Reference in New Issue
Block a user