diff --git a/include/llmr/map/vector_tile.hpp b/include/llmr/map/vector_tile.hpp index 14b497709..cf3fbdc24 100644 --- a/include/llmr/map/vector_tile.hpp +++ b/include/llmr/map/vector_tile.hpp @@ -15,8 +15,11 @@ class VectorTileLayer; struct pbf; struct Coordinate { + struct null {}; + Coordinate() : x(0), y(0) {} Coordinate(int16_t x, int16_t y) : x(x), y(y) {} + Coordinate(null) : x(std::numeric_limits::min()), y(std::numeric_limits::min()) {} int16_t x; int16_t y; @@ -25,10 +28,8 @@ struct Coordinate { } inline operator bool() const { - return *this == null; + return x != std::numeric_limits::min() && y != std::numeric_limits::min(); } - - static const Coordinate null; }; /* diff --git a/include/llmr/util/vec.hpp b/include/llmr/util/vec.hpp index 8ef938faa..760b66753 100644 --- a/include/llmr/util/vec.hpp +++ b/include/llmr/util/vec.hpp @@ -22,7 +22,7 @@ struct vec2 { template::has_quiet_NaN, int>::type = 0> inline operator bool() const { - return isnan(x) || isnan(y); + return !isnan(x) && !isnan(y); } }; diff --git a/src/map/vector_tile.cpp b/src/map/vector_tile.cpp index df9043ac1..b6011bd10 100644 --- a/src/map/vector_tile.cpp +++ b/src/map/vector_tile.cpp @@ -4,11 +4,6 @@ using namespace llmr; -const Coordinate Coordinate::null( - std::numeric_limits::min(), - std::numeric_limits::min() -); - VectorTile::VectorTile() {} VectorTile::VectorTile(pbf tile) { diff --git a/src/renderer/line_bucket.cpp b/src/renderer/line_bucket.cpp index f3052242d..96c654f75 100644 --- a/src/renderer/line_bucket.cpp +++ b/src/renderer/line_bucket.cpp @@ -73,9 +73,9 @@ void LineBucket::addGeometry(const std::vector& vertices, const Buck CapType beginCap = cap; CapType endCap = closed ? CapType::Butt : cap; - Coordinate currentVertex = Coordinate::null, - prevVertex = Coordinate::null, - nextVertex = Coordinate::null; + Coordinate currentVertex = Coordinate::null(), + prevVertex = Coordinate::null(), + nextVertex = Coordinate::null(); vec2 prevNormal = vec2::null(), nextNormal = vec2::null(); @@ -102,7 +102,7 @@ void LineBucket::addGeometry(const std::vector& vertices, const Buck if (i + 1 < vertices.size()) { nextVertex = vertices[i + 1]; } else { - nextVertex = Coordinate::null; + nextVertex = Coordinate::null(); } bool segment = false; @@ -180,7 +180,7 @@ void LineBucket::addGeometry(const std::vector& vertices, const Buck buffer->addDegenerate(); } - if (join == JoinType::Round) prevVertex = Coordinate::null; + if (join == JoinType::Round) prevVertex = Coordinate::null(); prevNormal = { -nextNormal.x, -nextNormal.y }; flip = 1; diff --git a/src/renderer/painter.cpp b/src/renderer/painter.cpp index 2e391b031..0605839ba 100644 --- a/src/renderer/painter.cpp +++ b/src/renderer/painter.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include