From 0f6c06002fad439c5d5a72f9078a7aab3a5b280f Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 16 Nov 2020 19:50:31 -0500 Subject: [PATCH] v0.9.1: fixed rare cases of artifacting in the shadowcaster --- .../mechanics/ShadowCaster.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/mechanics/ShadowCaster.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/mechanics/ShadowCaster.java index 212c9e18a..6fda87361 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/mechanics/ShadowCaster.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/mechanics/ShadowCaster.java @@ -80,9 +80,6 @@ public final class ShadowCaster { int x, int y, double lSlope, double rSlope, int mX, int mY, boolean mXY){ - //if we have negative space to traverse, just quit. - if (rSlope < lSlope) return; - boolean inBlocking = false; int start, end; int col; @@ -91,6 +88,9 @@ public final class ShadowCaster { //for each row, starting with the current one for (; row <= distance; row++){ + + //if we have negative space to traverse, just quit. + if (rSlope < lSlope) return; //we offset by slightly less than 0.5 to account for slopes just touching a cell if (lSlope == 0) start = 0; @@ -109,6 +109,13 @@ public final class ShadowCaster { //for each column in this row, which for (col = start; col <= end; col++){ + + + //handles the error case of the slope value at the end of a cell being 1 farther + // along then at the beginning of the cell, and that earlier cell is vision blocking + if (col == end && inBlocking && (int)Math.ceil((row - 0.5) * rSlope - 0.499) != end){ + break; + } fov[cell] = true;