aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_floor_cast.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/ft_floor_cast.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/src/ft_floor_cast.c b/src/ft_floor_cast.c
index 180f401..aa89f99 100644
--- a/src/ft_floor_cast.c
+++ b/src/ft_floor_cast.c
@@ -18,7 +18,8 @@ static void
{
float dist;
- dist = (cl->rlist.row_dist > 0) ? (cl->rlist.row_dist) : (0.0001);
+ if ((dist = cl->rlist.row_dist_tab[y]) <= 0)
+ dist = 0.0001;
*(int*)(cl->img.ptr +
(x * 4 + (y * cl->img.sizeline))) = ft_rgb_to_hex(dist, rgb, cl);
}
@@ -29,7 +30,8 @@ static void
float dist;
t_rgb rgb;
- dist = (cl->rlist.row_dist > 0) ? (cl->rlist.row_dist) : (0.0001);
+ if ((dist = cl->rlist.row_dist_tab[y]) <= 0)
+ dist = 0.0001;
rgb.b = (uint8_t)cl->tlist[tid].ptr[cl->tlist[tid].tex_x
* 4 + 4 * cl->tlist[tid].img_h * cl->tlist[tid].tex_y];
rgb.g = (uint8_t)cl->tlist[tid].ptr[cl->tlist[tid].tex_x
@@ -41,33 +43,30 @@ static void
}
static void
- ft_set_tex_xy(uint8_t tid, t_ray *rl, t_cub *cl)
+ ft_set_tex_xy(uint8_t tid, uint16_t x, t_ray *rl, t_cub *cl)
{
- cl->tlist[tid].tex_y = (int32_t)(cl->tlist[tid].img_w
- * (rl->x_floor - rl->x_cell));
+ const int32_t x_cell = (int32_t)(rl->x_floor_tab[x]);
+ const int32_t y_cell = (int32_t)(rl->y_floor_tab[x]);
+
cl->tlist[tid].tex_x = (int32_t)(cl->tlist[tid].img_h
- * (rl->y_floor - rl->y_cell));
- cl->tlist[tid].tex_x = (cl->tlist[tid].tex_x > 0)
- ? (cl->tlist[tid].tex_x) : (-cl->tlist[tid].tex_x);
- cl->tlist[tid].tex_y = (cl->tlist[tid].tex_y > 0)
- ? (cl->tlist[tid].tex_y) : (-cl->tlist[tid].tex_y);
+ * (rl->y_floor_tab[x] - y_cell));
+ cl->tlist[tid].tex_y = (int32_t)(cl->tlist[tid].img_w
+ * (rl->x_floor_tab[x] - x_cell));
}
static void
ft_floor_cast_loop(uint16_t y, uint16_t x, t_ray *rl, t_cub *cl)
{
- rl->x_cell = (int32_t)(rl->x_floor);
- rl->y_cell = (int32_t)(rl->y_floor);
if (cl->mlist.isftex)
{
- ft_set_tex_xy(6, rl, cl);
+ ft_set_tex_xy(6, x, rl, cl);
ft_draw_extra_tex(6, y, x, cl);
}
else
ft_draw_plain_horizontal(cl->f_rgb, cl, y, x);
if (cl->mlist.isctex && !cl->mlist.isskybox)
{
- ft_set_tex_xy(7, rl, cl);
+ ft_set_tex_xy(7, x, rl, cl);
ft_draw_extra_tex(7, cl->wlist.y_size - y - 1, x, cl);
}
else if (!cl->mlist.isctex && !cl->mlist.isskybox)
@@ -85,14 +84,11 @@ void
y = (cl->wlist.y_size / 2);
while (y < cl->wlist.y_size)
{
- ft_floor_cast_inits(y, &cl->rlist, cl);
x = 0;
while (x < cl->wlist.x_size)
{
if (cl->rlist.wall_bz[x] <= y)
ft_floor_cast_loop(y, x, &cl->rlist, cl);
- cl->rlist.x_floor += cl->mlist.x_floor_step;
- cl->rlist.y_floor += cl->mlist.y_floor_step;
x++;
}
y++;