diff --git a/libraries/AP_Math/polygon.cpp b/libraries/AP_Math/polygon.cpp index 0e78e6d4e3..a5e9fd3261 100644 --- a/libraries/AP_Math/polygon.cpp +++ b/libraries/AP_Math/polygon.cpp @@ -59,16 +59,32 @@ bool Polygon_outside(const Vector2 &P, const Vector2 *V, unsigned n) outside = !outside; } else if (m1 < m2) { continue; - } else if ( dx1 * (int64_t)dy2 > dx2 * (int64_t)dy1 ) { - outside = !outside; + } else { + if (std::is_floating_point::value) { + if ( dx1 * dy2 > dx2 * dy1 ) { + outside = !outside; + } + } else { + if ( dx1 * (int64_t)dy2 > dx2 * (int64_t)dy1 ) { + outside = !outside; + } + } } } else { if (m1 < m2) { outside = !outside; } else if (m1 > m2) { continue; - } else if ( dx1 * (int64_t)dy2 < dx2 * (int64_t)dy1 ) { - outside = !outside; + } else { + if (std::is_floating_point::value) { + if ( dx1 * dy2 < dx2 * dy1 ) { + outside = !outside; + } + } else { + if ( dx1 * (int64_t)dy2 < dx2 * (int64_t)dy1 ) { + outside = !outside; + } + } } } }