aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-11 01:17:41 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-11 01:17:41 +0100
commit154ccbc0546018554982f9170d32b7858a8c33aa (patch)
treeb6ec684e090782d1ed80f3eb0cb393a4db2b5bfa
parentStupid me (diff)
download42-cub3d-154ccbc0546018554982f9170d32b7858a8c33aa.tar.gz
42-cub3d-154ccbc0546018554982f9170d32b7858a8c33aa.tar.bz2
42-cub3d-154ccbc0546018554982f9170d32b7858a8c33aa.tar.xz
42-cub3d-154ccbc0546018554982f9170d32b7858a8c33aa.tar.zst
42-cub3d-154ccbc0546018554982f9170d32b7858a8c33aa.zip
Norme
Diffstat (limited to '')
-rw-r--r--Makefile1
-rw-r--r--inc/cub3d.h1
-rw-r--r--src/ft_floor_cast.c16
-rw-r--r--src/ft_floor_cast_inits.c32
4 files changed, 36 insertions, 14 deletions
diff --git a/Makefile b/Makefile
index de7a863..348c37a 100644
--- a/Makefile
+++ b/Makefile
@@ -81,6 +81,7 @@ SRCS_NAME += ft_treat_args.c
SRCS_NAME += ft_init_funptr.c
SRCS_NAME += ft_init_bmp.c
SRCS_NAME += ft_floor_cast.c
+SRCS_NAME += ft_floor_cast_inits.c
#--------------------------------------------------------------------------------------------------#
SRCS = $(addprefix ${SRCS_DIR},${SRCS_NAME})
#--------------------------------------------------------------------------------------------------#
diff --git a/inc/cub3d.h b/inc/cub3d.h
index 2a9d66e..a7b649d 100644
--- a/inc/cub3d.h
+++ b/inc/cub3d.h
@@ -131,6 +131,7 @@ uint8_t ft_use_args(int argc, const char *argv[],
void ft_castray(t_cub *cl);
void ft_detect(t_cub *cl);
void ft_floor_cast(t_cub *cl);
+void ft_floor_cast_inits(uint16_t y, t_ray *rl, t_cub *cl);
/*
** ====== OTHER ======
diff --git a/src/ft_floor_cast.c b/src/ft_floor_cast.c
index 36c759f..b6c7e72 100644
--- a/src/ft_floor_cast.c
+++ b/src/ft_floor_cast.c
@@ -1,7 +1,7 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
-/* ft_raycasting.c :+: :+: :+: */
+/* ft_floor_cast.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
@@ -91,19 +91,7 @@ void
y = (cl->wlist.y_size / 2) + 1;
while (++y < cl->wlist.y_size)
{
- rl->x_f_ray_dir = cl->plist.dir_x - cl->plist.plane_x;
- rl->y_f_ray_dir = cl->plist.dir_y - cl->plist.plane_y;
- rl->x_f_ray_dir_bis = cl->plist.dir_x + cl->plist.plane_x;
- rl->y_f_ray_dir_bis = cl->plist.dir_y + cl->plist.plane_y;
- rl->p = y - cl->wlist.y_size / 2;
- cl->plist.pos_z = 0.5 * cl->wlist.y_size;
- rl->row_dist = cl->plist.pos_z / rl->p;
- cl->mlist.x_floor_step = rl->row_dist *
- (rl->x_f_ray_dir_bis - rl->x_f_ray_dir) / cl->wlist.x_size;
- cl->mlist.y_floor_step = rl->row_dist *
- (rl->y_f_ray_dir_bis - rl->y_f_ray_dir) / cl->wlist.x_size;
- rl->x_floor = cl->plist.pos_y + rl->row_dist * rl->x_f_ray_dir;
- rl->y_floor = cl->plist.pos_x + rl->row_dist * rl->y_f_ray_dir;
+ ft_floor_cast_inits(y, rl, cl);
x = -1;
while (++x < cl->wlist.x_size)
{
diff --git a/src/ft_floor_cast_inits.c b/src/ft_floor_cast_inits.c
new file mode 100644
index 0000000..591eb24
--- /dev/null
+++ b/src/ft_floor_cast_inits.c
@@ -0,0 +1,32 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_floor_cast_inits.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/02/14 17:22:57 by rbousset #+# #+# */
+/* Updated: 2020/02/14 17:23:42 by rbousset ### ########lyon.fr */
+/* */
+/* ************************************************************************** */
+
+#include <cub3d.h>
+#include <stdint.h>
+
+void
+ ft_floor_cast_inits(uint16_t y, t_ray *rl, t_cub *cl)
+{
+ rl->x_f_ray_dir = cl->plist.dir_x - cl->plist.plane_x;
+ rl->y_f_ray_dir = cl->plist.dir_y - cl->plist.plane_y;
+ rl->x_f_ray_dir_bis = cl->plist.dir_x + cl->plist.plane_x;
+ rl->y_f_ray_dir_bis = cl->plist.dir_y + cl->plist.plane_y;
+ rl->p = y - cl->wlist.y_size / 2;
+ cl->plist.pos_z = 0.5 * cl->wlist.y_size;
+ rl->row_dist = cl->plist.pos_z / rl->p;
+ cl->mlist.x_floor_step = rl->row_dist *
+ (rl->x_f_ray_dir_bis - rl->x_f_ray_dir) / cl->wlist.x_size;
+ cl->mlist.y_floor_step = rl->row_dist *
+ (rl->y_f_ray_dir_bis - rl->y_f_ray_dir) / cl->wlist.x_size;
+ rl->x_floor = cl->plist.pos_y + rl->row_dist * rl->x_f_ray_dir;
+ rl->y_floor = cl->plist.pos_x + rl->row_dist * rl->y_f_ray_dir;
+}