diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-08 00:56:36 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-08 00:56:36 +0100 |
commit | d248cde2309e9aa3f14a10ce2db0019afdf9f0f1 (patch) | |
tree | 3b754dacd2e858c547f9cb95a303a797f39382c8 /src/ft_floor_cast.c | |
parent | I gotta figure out (diff) | |
download | 42-cub3d-d248cde2309e9aa3f14a10ce2db0019afdf9f0f1.tar.gz 42-cub3d-d248cde2309e9aa3f14a10ce2db0019afdf9f0f1.tar.bz2 42-cub3d-d248cde2309e9aa3f14a10ce2db0019afdf9f0f1.tar.xz 42-cub3d-d248cde2309e9aa3f14a10ce2db0019afdf9f0f1.tar.zst 42-cub3d-d248cde2309e9aa3f14a10ce2db0019afdf9f0f1.zip |
Collision fixed, still galering
Diffstat (limited to 'src/ft_floor_cast.c')
-rw-r--r-- | src/ft_floor_cast.c | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/src/ft_floor_cast.c b/src/ft_floor_cast.c index c82163a..482ee8a 100644 --- a/src/ft_floor_cast.c +++ b/src/ft_floor_cast.c @@ -18,38 +18,23 @@ static void { int16_t p; - rl->x_ray_dir = pl->dir_x - pl->plane_x; - rl->y_ray_dir = pl->dir_y - pl->plane_y; - rl->x_ray_dir_bis = pl->dir_x + pl->plane_x; - rl->y_ray_dir_bis = pl->dir_y + pl->plane_y; + rl->x_ray_dir_f = pl->dir_x - pl->plane_x; + rl->y_ray_dir_f = pl->dir_y - pl->plane_y; + rl->x_ray_dir_f_bis = pl->dir_x + pl->plane_x; + rl->y_ray_dir_f_bis = pl->dir_y + pl->plane_y; p = y - cl->wlist.y_size / 2; - pl->pos_z = 0.5 * cl->wlist.y_size; rl->row_dist = pl->pos_z / p; cl->mlist.x_floor_step = rl->row_dist * - (rl->x_ray_dir_bis - rl->x_ray_dir) / cl->wlist.x_size; + (rl->x_ray_dir_f_bis - rl->x_ray_dir_f) / cl->wlist.x_size; cl->mlist.y_floor_step = rl->row_dist * - (rl->y_ray_dir_bis - rl->y_ray_dir) / cl->wlist.x_size; - rl->floor_x = pl->pos_x + rl->row_dist * rl->x_ray_dir; - rl->floor_y = pl->pos_y + rl->row_dist * rl->y_ray_dir; + (rl->y_ray_dir_f_bis - rl->y_ray_dir_f) / cl->wlist.x_size; + rl->floor_x = pl->pos_x + rl->row_dist * rl->x_ray_dir_f; + rl->floor_y = pl->pos_y + rl->row_dist * rl->y_ray_dir_f; } void - ft_floor_cast(t_cub *cl) + ft_floor_cast(uint16_t y, t_cub *cl) { - uint16_t y; - uint16_t x; - - y = 0; - while (y < cl->wlist.y_size) - { - ft_initray(y, &cl->rlist, &cl->plist, cl); - x = 1; - while (x < cl->wlist.x_size) - { - cl->rlist.ceil_x = (int16_t)cl->rlist.floor_x; - cl->rlist.ceil_y = (int16_t)cl->rlist.floor_y; - x++; - } - y++; - } + cl->plist.pos_z = 0.5 * cl->wlist.y_size; + ft_initray(y, &cl->rlist, &cl->plist, cl); } |