v0.9.1: fixed rare cases of artifacting in the shadowcaster
This commit is contained in:
parent
348acd23ac
commit
0f6c06002f
|
@ -80,9 +80,6 @@ public final class ShadowCaster {
|
||||||
int x, int y, double lSlope, double rSlope,
|
int x, int y, double lSlope, double rSlope,
|
||||||
int mX, int mY, boolean mXY){
|
int mX, int mY, boolean mXY){
|
||||||
|
|
||||||
//if we have negative space to traverse, just quit.
|
|
||||||
if (rSlope < lSlope) return;
|
|
||||||
|
|
||||||
boolean inBlocking = false;
|
boolean inBlocking = false;
|
||||||
int start, end;
|
int start, end;
|
||||||
int col;
|
int col;
|
||||||
|
@ -92,6 +89,9 @@ public final class ShadowCaster {
|
||||||
//for each row, starting with the current one
|
//for each row, starting with the current one
|
||||||
for (; row <= distance; row++){
|
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
|
//we offset by slightly less than 0.5 to account for slopes just touching a cell
|
||||||
if (lSlope == 0) start = 0;
|
if (lSlope == 0) start = 0;
|
||||||
else start = (int)Math.floor((row - 0.5) * lSlope + 0.499);
|
else start = (int)Math.floor((row - 0.5) * lSlope + 0.499);
|
||||||
|
@ -110,6 +110,13 @@ public final class ShadowCaster {
|
||||||
//for each column in this row, which
|
//for each column in this row, which
|
||||||
for (col = start; col <= end; col++){
|
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;
|
fov[cell] = true;
|
||||||
|
|
||||||
if (blocking[cell]){
|
if (blocking[cell]){
|
||||||
|
|
Loading…
Reference in New Issue
Block a user