aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_raycasting.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-24 00:25:18 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-24 00:25:18 +0100
commita2dc982a92d8f1745831f0ded8e082c445030ff0 (patch)
treee1e79ff1bfb45959701f4ba548a8b5a988bd4f11 /src/ft_raycasting.c
parentgot work to do (diff)
download42-cub3d-a2dc982a92d8f1745831f0ded8e082c445030ff0.tar.gz
42-cub3d-a2dc982a92d8f1745831f0ded8e082c445030ff0.tar.bz2
42-cub3d-a2dc982a92d8f1745831f0ded8e082c445030ff0.tar.xz
42-cub3d-a2dc982a92d8f1745831f0ded8e082c445030ff0.tar.zst
42-cub3d-a2dc982a92d8f1745831f0ded8e082c445030ff0.zip
Doesn't look too bad
Diffstat (limited to 'src/ft_raycasting.c')
-rw-r--r--src/ft_raycasting.c39
1 files changed, 33 insertions, 6 deletions
diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c
index 89cc61f..73aaf30 100644
--- a/src/ft_raycasting.c
+++ b/src/ft_raycasting.c
@@ -91,7 +91,8 @@ void
ft_castray(t_cub *cl)
{
pthread_t tid[2];
- uint16_t i;
+ uint16_t y;
+ uint16_t x;
if (!(cl->rlist.wall_dist_tab = (float*)malloc(cl->wlist.x_size *
sizeof(float))) ||
@@ -104,13 +105,36 @@ void
!(cl->rlist.wall_t_tab = (int16_t*)malloc(cl->wlist.x_size *
sizeof(int16_t))) ||
!(cl->rlist.tex_x_tab = (int32_t*)malloc(cl->wlist.x_size *
- sizeof(int32_t))))
+ sizeof(int32_t))) ||
+ !(cl->rlist.y_floor_tab = (float*)malloc(cl->wlist.x_size *
+ sizeof(float))) ||
+ !(cl->rlist.x_floor_tab = (float*)malloc(cl->wlist.x_size *
+ sizeof(float))) ||
+ !(cl->rlist.row_dist_tab = (float*)malloc(cl->wlist.y_size *
+ sizeof(float))))
return ;
- i = 0;
- while (i < cl->wlist.x_size)
+ x = 0;
+ while (x < cl->wlist.x_size)
+ {
+ ft_castray_loop(x, &cl->wlist, cl);
+ x++;
+ }
+ y = cl->wlist.y_size / 2;
+ while (y < cl->wlist.y_size)
{
- ft_castray_loop(i, &cl->wlist, cl);
- i++;
+ x = 0;
+ ft_floor_cast_inits(y, &cl->rlist, cl);
+ while (x < cl->wlist.x_size)
+ {
+ cl->rlist.x_floor += cl->mlist.x_floor_step;
+ cl->rlist.y_floor += cl->mlist.y_floor_step;
+ cl->rlist.x_floor_tab[x] = cl->rlist.x_floor;
+ cl->rlist.y_floor_tab[x] = cl->rlist.y_floor;
+ x++;
+ }
+ cl->rlist.row_dist_tab[y] = cl->rlist.row_dist;
+ cl->rlist.row_dist_tab[cl->wlist.y_size - y] = cl->rlist.row_dist;
+ y++;
}
pthread_create(&tid[0], 0x0, ft_wall_cast, (void*)cl);
pthread_create(&tid[1], 0x0, ft_floor_cast, (void*)cl);
@@ -123,6 +147,9 @@ void
if (cl->plist.handles_weapon > -1)
ft_draw_handweap(cl);
ft_memdel((void*)&cl->rlist.tex_x_tab);
+ ft_memdel((void*)&cl->rlist.y_floor_tab);
+ ft_memdel((void*)&cl->rlist.x_floor_tab);
+ ft_memdel((void*)&cl->rlist.row_dist_tab);
ft_memdel((void*)&cl->rlist.wall_t_tab);
ft_memdel((void*)&cl->rlist.w_side_tab);
ft_memdel((void*)&cl->rlist.line_h_tab);