diff --git a/include/llmr/map/vector_tile.hpp b/include/llmr/map/vector_tile.hpp index 98f2a1ca3..67207563e 100644 --- a/include/llmr/map/vector_tile.hpp +++ b/include/llmr/map/vector_tile.hpp @@ -2,6 +2,7 @@ #define LLMR_MAP_VECTOR_TILE #include +#include #include #include #include @@ -15,24 +16,6 @@ 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; - - inline bool operator==(const Coordinate& other) const { - return x == other.x && y == other.y; - } - - inline operator bool() const { - return x != std::numeric_limits::min() && y != std::numeric_limits::min(); - } -}; - enum class FeatureType { Unknown = 0, Point = 1, diff --git a/include/llmr/renderer/fill_bucket.hpp b/include/llmr/renderer/fill_bucket.hpp index 4c82b7b31..633ae8c2f 100644 --- a/include/llmr/renderer/fill_bucket.hpp +++ b/include/llmr/renderer/fill_bucket.hpp @@ -26,7 +26,6 @@ class BucketDescription; class OutlineShader; class PlainShader; class PatternShader; -struct Coordinate; struct pbf; class FillBucket : public Bucket { diff --git a/include/llmr/renderer/line_bucket.hpp b/include/llmr/renderer/line_bucket.hpp index 8b03fc5ad..16f7dac98 100644 --- a/include/llmr/renderer/line_bucket.hpp +++ b/include/llmr/renderer/line_bucket.hpp @@ -15,7 +15,6 @@ class LineVertexBuffer; class TriangleElementsBuffer; class LineShader; class LinejoinShader; -struct Coordinate; struct pbf; class LineBucket : public Bucket { diff --git a/include/llmr/renderer/point_bucket.hpp b/include/llmr/renderer/point_bucket.hpp index e48e4ceaa..d65435d68 100644 --- a/include/llmr/renderer/point_bucket.hpp +++ b/include/llmr/renderer/point_bucket.hpp @@ -19,7 +19,6 @@ class Style; class PointVertexBuffer; class BucketDescription; class PointShader; -struct Coordinate; struct pbf; class PointBucket : public Bucket { diff --git a/include/llmr/renderer/text_bucket.hpp b/include/llmr/renderer/text_bucket.hpp index 5a19ebeda..21c00cbde 100644 --- a/include/llmr/renderer/text_bucket.hpp +++ b/include/llmr/renderer/text_bucket.hpp @@ -18,7 +18,6 @@ class TextShader; class VectorTileFeature; class VectorTileFace; class VectorTilePlacement; -struct Coordinate; struct pbf; class TextBucket : public Bucket { diff --git a/include/llmr/util/vec.hpp b/include/llmr/util/vec.hpp index 445160f15..0191e3868 100644 --- a/include/llmr/util/vec.hpp +++ b/include/llmr/util/vec.hpp @@ -4,6 +4,7 @@ #include #include #include +#include namespace llmr { @@ -15,10 +16,17 @@ struct vec2 { T x, y; inline vec2() {} + + template::has_quiet_NaN, int>::type = 0> inline vec2(null) : x(std::numeric_limits::quiet_NaN()), y(std::numeric_limits::quiet_NaN()) {} + template::has_quiet_NaN, int>::type = 0> + inline vec2(null) : x(std::numeric_limits::min()), y(std::numeric_limits::min()) {} + inline vec2(const vec2& o) : x(o.x), y(o.y) {} + inline vec2(T x, T y) : x(x), y(y) {} + inline bool operator==(const vec2& rhs) const { return x == rhs.x && y == rhs.y; } @@ -27,6 +35,11 @@ struct vec2 { inline operator bool() const { return !isnan(x) && !isnan(y); } + + template::has_quiet_NaN, int>::type = 0> + inline operator bool() const { + return x != std::numeric_limits::min() && y != std::numeric_limits::min(); + } }; template @@ -59,6 +72,8 @@ struct box { vec2 center; }; +typedef vec2 Coordinate; + } #endif