aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_raycasting.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-03-11 00:00:07 +0100
committerJozanLeClerc <bousset.rudy@gmail.com>2020-03-11 00:00:07 +0100
commit25247ca1f3ffc9485b02686f616c41a52f8eb82a (patch)
tree38897a8228b34f4b77a3b506c278ced62514ff68 /src/ft_raycasting.c
parentFreed multiple leaks (diff)
download42-cub3d-25247ca1f3ffc9485b02686f616c41a52f8eb82a.tar.gz
42-cub3d-25247ca1f3ffc9485b02686f616c41a52f8eb82a.tar.bz2
42-cub3d-25247ca1f3ffc9485b02686f616c41a52f8eb82a.tar.xz
42-cub3d-25247ca1f3ffc9485b02686f616c41a52f8eb82a.tar.zst
42-cub3d-25247ca1f3ffc9485b02686f616c41a52f8eb82a.zip
Pas trop ecole opti memoire mais ok
Diffstat (limited to 'src/ft_raycasting.c')
-rw-r--r--src/ft_raycasting.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/ft_raycasting.c b/src/ft_raycasting.c
index baa71af..5c57044 100644
--- a/src/ft_raycasting.c
+++ b/src/ft_raycasting.c
@@ -76,24 +76,25 @@ static void
if (cl->rlist.wall_t < 0)
cl->rlist.wall_t = 0;
cl->rlist.wall_b = cl->rlist.line_h / 2 + wl->y_size / 2;
- if (cl->rlist.wall_b >= (float)wl->y_size)
+ if (cl->rlist.wall_b >= (int16_t)wl->y_size)
cl->rlist.wall_b = wl->y_size - 1;
+ cl->rlist.wall_bz[i] = cl->rlist.wall_b;
}
void
ft_castray(t_cub *cl)
{
- uint16_t i;
- t_win *wl;
+ uint16_t i;
+ t_win *wl;
ft_memdel((void**)&cl->rlist.wall_dist_tab);
wl = &cl->wlist;
- i = (wl->y_size / 2) + 1;
- while (++i < wl->y_size)
- ft_floor_cast(i, cl);
if (!(cl->rlist.wall_dist_tab =
(float*)malloc(sizeof(float) * cl->wlist.x_size)))
return ;
+ if (!(cl->rlist.wall_bz =
+ (int16_t*)malloc(cl->wlist.x_size * sizeof(int16_t))))
+ return ;
i = 0;
while (i < wl->x_size)
{
@@ -104,4 +105,7 @@ void
cl->rlist.wall_dist_tab[i] = cl->rlist.wall_dist;
i++;
}
+ ft_floor_cast(cl);
+ i = 0;
+ ft_memdel((void**)&cl->rlist.wall_bz);
}