changed all equations of wall height calculation to resolve pixelisation, but dead axis rays re-appeared
This commit is contained in:
@@ -30,36 +30,23 @@
|
||||
}
|
||||
// tmp end
|
||||
|
||||
static void wall_length(t_rcast *rcast)
|
||||
static void wall_height(t_rcast *rcast)
|
||||
{
|
||||
int len;
|
||||
int height;
|
||||
int delta;
|
||||
|
||||
rcast->wall.start.x = rcast->ray_nb;
|
||||
rcast->wall.end.x = rcast->ray_nb;
|
||||
if (rcast->is_x == 1)
|
||||
{
|
||||
len = rcast->next_x - rcast->ray_step_x;
|
||||
if (rcast->slope_y)
|
||||
len /= rcast->slope_y;
|
||||
len = rcast->screen_dist * len / rcast->slope_x;
|
||||
}
|
||||
delta = rcast->next_x - rcast->ray_step_x;
|
||||
else if (rcast->is_x == 0)
|
||||
{
|
||||
len = rcast->next_y - rcast->ray_step_y;
|
||||
if (rcast->slope_x)
|
||||
len /= rcast->slope_x;
|
||||
len = rcast->screen_dist * len / rcast->slope_y;
|
||||
}
|
||||
rcast->ray_len = ft_abs(len);
|
||||
}
|
||||
|
||||
static void wall_height(t_rcast *rcast)
|
||||
{
|
||||
int height;
|
||||
|
||||
delta = rcast->next_y - rcast->ray_step_y;
|
||||
height = rcast->screen_height * rcast->cell;
|
||||
if (rcast->ray_len)
|
||||
height /= rcast->ray_len;
|
||||
height *= rcast->slope_y * rcast->slope_x;
|
||||
if (delta && rcast->screen_dist)
|
||||
height /= (delta * rcast->screen_dist);
|
||||
|
||||
height = ft_abs(height);
|
||||
if (height < 0)
|
||||
height = 0;
|
||||
if (height > rcast->screen_height)
|
||||
@@ -107,7 +94,6 @@ void raycast(t_game *game, t_rcast *rcast)
|
||||
draw_line(&game->map_img, &ray, 0x00FF00FF);
|
||||
// tmp end
|
||||
|
||||
wall_length(rcast);
|
||||
wall_height(rcast);
|
||||
draw_column(game, rcast);
|
||||
(rcast->ray_nb)++;
|
||||
|
||||
Reference in New Issue
Block a user