aboutsummaryrefslogtreecommitdiff
path: root/src/player.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/player.zig')
-rw-r--r--src/player.zig11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/player.zig b/src/player.zig
index c8fc4df..8fe0002 100644
--- a/src/player.zig
+++ b/src/player.zig
@@ -383,13 +383,16 @@ pub fn Player(PlaneWidth: f32, PlaneHeight: f32) type {
if (draw_lower) {
// which texture index?
const t_lower_off = cell.lower_texture * td;
- // now we have what we need to draw the face, and
- // update the z-buffer
- const constrained_top = std.math.min(top_of_floor, lowest_drawn);
+ // Note the bizarre rounding we have to do to avoid artifacts
+ const constrained_top = std.math.min(std.math.floor(top_of_floor), std.math.ceil(lowest_drawn));
+ const stop = @floatToInt(i32, highest_drawn);
var zb_y = @floatToInt(i32, constrained_top);
var pix_y = @floatToInt(usize, std.math.ceil(std.math.max(PlaneHeight - constrained_top, 0)));
var texel_y = (top_of_floor - constrained_top) / nominal_length;
- while (zb_y > @floatToInt(i32, highest_drawn)) : ({
+
+ // now we have what we need to draw the face,
+ // and update the z-buffer
+ while (zb_y > stop) : ({
zb_y -= 1;
pix_y += 1;
texel_y += inv_nom_len;