diff options
Diffstat (limited to 'src/ft_floor_cast_inits.c')
-rw-r--r-- | src/ft_floor_cast_inits.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/ft_floor_cast_inits.c b/src/ft_floor_cast_inits.c index 591eb24..d1f2811 100644 --- a/src/ft_floor_cast_inits.c +++ b/src/ft_floor_cast_inits.c @@ -14,6 +14,20 @@ #include <stdint.h> void + ft_set_fc_tex_xy(uint8_t tid, uint16_t x, uint16_t y, t_cub *cl) +{ + const int32_t x_cell = (int32_t)(cl->rlist.x_floor); + const int32_t y_cell = (int32_t)(cl->rlist.y_floor); + + cl->tlist[tid].tex_x = (int32_t)(cl->tlist[tid].img_h + * (cl->rlist.y_floor - y_cell)); + cl->tlist[tid].tex_y = (int32_t)(cl->tlist[tid].img_w + * (cl->rlist.x_floor - x_cell)); + cl->rlist.fc_tex_x_tab[tid - 6][y][x] = cl->tlist[tid].tex_x; + cl->rlist.fc_tex_y_tab[tid - 6][y][x] = cl->tlist[tid].tex_y; +} + +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; @@ -30,3 +44,27 @@ void 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; } + +void + ft_floor_loop(uint16_t y, t_cub *cl) +{ + uint16_t x; + + x = 0; + ft_floor_cast_inits(y, &cl->rlist, cl); + while (x < cl->wlist.x_size) + { + if (cl->rlist.wall_b_tab[x] <= y) + { + if (cl->mlist.isftex) + ft_set_fc_tex_xy(6, x, y, cl); + if (cl->mlist.isctex && !cl->mlist.isskybox) + ft_set_fc_tex_xy(7, x, cl->wlist.y_size - y - 1, cl); + } + cl->rlist.x_floor += cl->mlist.x_floor_step; + cl->rlist.y_floor += cl->mlist.y_floor_step; + 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; +} |