From 25ff0b253f99f401e79ad7e009fd09cd8b5a4314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Tue, 18 Mar 2014 17:57:09 +0100 Subject: merge vec2 and Coordinate --- include/llmr/map/vector_tile.hpp | 19 +------------------ include/llmr/renderer/fill_bucket.hpp | 1 - include/llmr/renderer/line_bucket.hpp | 1 - include/llmr/renderer/point_bucket.hpp | 1 - include/llmr/renderer/text_bucket.hpp | 1 - include/llmr/util/vec.hpp | 15 +++++++++++++++ 6 files changed, 16 insertions(+), 22 deletions(-) diff --git a/include/llmr/map/vector_tile.hpp b/include/llmr/map/vector_tile.hpp index 98f2a1ca38..67207563e3 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 4c82b7b315..633ae8c2fd 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 8b03fc5ad4..16f7dac989 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 e48e4ceaae..d65435d68b 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 5a19ebeda7..21c00cbdea 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 445160f15d..0191e3868d 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 -- cgit v1.2.1