aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_floor_cast.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ft_floor_cast.c')
-rw-r--r--src/ft_floor_cast.c46
1 files changed, 27 insertions, 19 deletions
diff --git a/src/ft_floor_cast.c b/src/ft_floor_cast.c
index 384f699..d2c6046 100644
--- a/src/ft_floor_cast.c
+++ b/src/ft_floor_cast.c
@@ -78,8 +78,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 +89,38 @@ 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);
+ 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 = -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;
+ }
}
}