diff --git a/app/src/main/java/com/kylecorry/trail_sense/shared/canvas/LineClipper.kt b/app/src/main/java/com/kylecorry/trail_sense/shared/canvas/LineClipper.kt index a84c0815e..bacbbb6a1 100644 --- a/app/src/main/java/com/kylecorry/trail_sense/shared/canvas/LineClipper.kt +++ b/app/src/main/java/com/kylecorry/trail_sense/shared/canvas/LineClipper.kt @@ -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 || diff --git a/app/src/main/java/com/kylecorry/trail_sense/shared/extensions/AndromedaExtensions.kt b/app/src/main/java/com/kylecorry/trail_sense/shared/extensions/AndromedaExtensions.kt index 0fcf02303..a81272493 100644 --- a/app/src/main/java/com/kylecorry/trail_sense/shared/extensions/AndromedaExtensions.kt +++ b/app/src/main/java/com/kylecorry/trail_sense/shared/extensions/AndromedaExtensions.kt @@ -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() }