diff options
author | salaaad2 <arthurdurant263@gmail.com> | 2020-03-11 18:59:58 +0100 |
---|---|---|
committer | salaaad2 <arthurdurant263@gmail.com> | 2020-03-11 18:59:58 +0100 |
commit | b6388b5101d8187f746f91c89842e932a1d01cb6 (patch) | |
tree | 70bd9ba7012f5906db01b485ec8f58f5a4697240 /src/ft_floor_cast.c | |
parent | close but no cigar (diff) | |
parent | ca tue (diff) | |
download | 42-cub3d-b6388b5101d8187f746f91c89842e932a1d01cb6.tar.gz 42-cub3d-b6388b5101d8187f746f91c89842e932a1d01cb6.tar.bz2 42-cub3d-b6388b5101d8187f746f91c89842e932a1d01cb6.tar.xz 42-cub3d-b6388b5101d8187f746f91c89842e932a1d01cb6.tar.zst 42-cub3d-b6388b5101d8187f746f91c89842e932a1d01cb6.zip |
get merged
Diffstat (limited to 'src/ft_floor_cast.c')
-rw-r--r-- | src/ft_floor_cast.c | 52 |
1 files changed, 20 insertions, 32 deletions
diff --git a/src/ft_floor_cast.c b/src/ft_floor_cast.c index 384f699..2eda9d8 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> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ @@ -16,23 +16,15 @@ static void ft_draw_plain_horizontal(t_rgb rgb, t_cub *cl, int32_t y, int32_t x) { - if (cl->mlist.darklvl > 0) - { - *(int*)(cl->img.ptr + - (x * 4 + (y * cl->img.sizeline))) = ft_darken(rgb, cl); - } - else - { - *(int*)(cl->img.ptr + - (x * 4 + (y * cl->img.sizeline))) = ft_rgb_to_hex(rgb); - } + *(int*)(cl->img.ptr + + (x * 4 + (y * cl->img.sizeline))) = ft_darken(rgb, cl); } static void ft_draw_extra_tex(uint8_t tid, uint16_t y, uint16_t x, t_cub *cl) { - float dist; - float calc; + float dist; + float calc; if ((dist = cl->rlist.row_dist) <= 0) dist = 0.0001; @@ -78,8 +70,6 @@ static void { ft_set_tex_xy(7, rl, cl); } - rl->x_floor += cl->mlist.x_floor_step; - rl->y_floor += cl->mlist.y_floor_step; if (cl->mlist.isftex) ft_draw_extra_tex(6, y, x, cl); else @@ -91,28 +81,26 @@ static void } void - ft_floor_cast(uint16_t y, t_cub *cl) + ft_floor_cast(t_cub *cl) { t_ray *rl; uint16_t x; + uint16_t y; rl = &cl->rlist; - 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; - x = 0; - while (++x < cl->wlist.x_size) + y = (cl->wlist.y_size / 2) + 1; + while (++y < cl->wlist.y_size) { - ft_floor_cast_loop(y, x, rl, cl); + ft_floor_cast_inits(y, rl, cl); + x = -1; + while (++x < cl->wlist.x_size) + { + if (cl->rlist.wall_bz[x] <= y) + { + ft_floor_cast_loop(y, x, rl, cl); + } + rl->x_floor += cl->mlist.x_floor_step; + rl->y_floor += cl->mlist.y_floor_step; + } } } |