1
0
Fork 0

Adjust limits for line intersection calculation to catch points

slightly past the end of a line segment. This is to catch situations
where the cliff line has been chopped at a bucket edge and the
two candidate points are on the edge.
This commit is contained in:
James.Hester 2018-12-30 10:05:35 +11:00
parent a7af59b61f
commit 62359aede2

View file

@ -121,11 +121,11 @@ for line 1 = p + t r, line 2 = q + u s
double crossx = nx1-x1; double crossy = ny1-y1; double crossx = nx1-x1; double crossy = ny1-y1;
double t = (crossx*nydif - crossy*nxdif)/denom; double t = (crossx*nydif - crossy*nxdif)/denom;
double u = -1*(xdif*crossy - ydif*crossx)/denom; double u = -1*(xdif*crossy - ydif*crossx)/denom;
// We consider that an intersection at the edge of the line have // We consider that an intersection at the edge of the line has
// not crossed // crossed
// over, that is, they lie on the same side, so we do not // over, that is, they lie on opposite sides. This way we capture
// include equality in the comparisons // places where the chopper has clipped a cliff on the tile edge
if (t > 0.0 && t < 1.0 && u > 0.0 && u < 1.0) intersect_ct++; if (t > -0.0001 && t < 1.0001 && u > -0.0001 && u < 1.0001) intersect_ct++;
} }
} }
} }