Skip to content

Commit

Permalink
Ignore NaN pixels in line clipper
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecorry31 committed Jan 28, 2024
1 parent 64a61f4 commit 520d162
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class LineClipper {
for (idx in filteredIndices) {
val pixel = pixels[idx]
val vector = vectors[idx]
// Remove points that are NaN
if (pixel.x.isNaN() || pixel.y.isNaN()) continue
// Remove lines that cross the entire screen (because they are behind the camera)
val isLineInvalid = preventLineWrapping && previous != null &&
(pixel.x < minX && previous.x > maxX ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ fun Alerts.cancelableLoading(
}

fun PixelCoordinate.isSamePixel(other: PixelCoordinate): Boolean {
// If either contains a NaN, return false
if (x.isNaN() || y.isNaN() || other.x.isNaN() || other.y.isNaN()) {
return false
}

return x.roundToInt() == other.x.roundToInt() && y.roundToInt() == other.y.roundToInt()
}

Expand Down

0 comments on commit 520d162

Please sign in to comment.