resolve floating point exception when wliding through walls
This commit is contained in:
@@ -36,13 +36,11 @@ static void wall_length(t_rcast *rcast)
|
||||
|
||||
rcast->wall.start.x = rcast->ray_nb;
|
||||
rcast->wall.end.x = rcast->ray_nb;
|
||||
// len = sqrt(pow(ray->end.x - ray->start.x, 2) + pow(ray->end.y - ray->start.y, 2));
|
||||
if (rcast->is_x == 1)
|
||||
{
|
||||
len = rcast->next_x - rcast->ray_step_x;
|
||||
if (rcast->slope_y)
|
||||
len /= ft_abs(rcast->slope_y);
|
||||
// len = (double)len * (double)rcast->screen_dist.end.y / (double)rcast->slope_x;
|
||||
len = rcast->screen_dist * len / (rcast->slope_x);
|
||||
}
|
||||
else if (rcast->is_x == 0)
|
||||
@@ -50,7 +48,6 @@ static void wall_length(t_rcast *rcast)
|
||||
len = rcast->next_y - rcast->ray_step_y;
|
||||
if (rcast->slope_x)
|
||||
len /= ft_abs(rcast->slope_x);
|
||||
// len = (double)len * (double)rcast->screen_dist.end.y / (double)rcast->slope_y;
|
||||
len = rcast->screen_dist * len / (rcast->slope_y);
|
||||
}
|
||||
rcast->ray_len = ft_abs(len);
|
||||
@@ -110,7 +107,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);
|
||||
|
||||
Reference in New Issue
Block a user