diff options
author | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2017-10-31 13:10:01 +0200 |
---|---|---|
committer | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2017-11-01 18:06:36 +0200 |
commit | 688540a44d7977208b606b02376edc7d87854db8 (patch) | |
tree | 51a4335ccbd182263e8d7b5793703cf69ce74d1e /deps | |
parent | 90a7cf87a32f6787e57e3852ac9d3015d8112621 (diff) | |
download | qtlocation-mapboxgl-688540a44d7977208b606b02376edc7d87854db8.tar.gz |
Bump Mapbox GL Native
mapbox-gl-native @ 0ef7b7154f6d4498077a83db5c486c61bc34938c
Diffstat (limited to 'deps')
-rw-r--r-- | deps/earcut/0.12.4/LICENSE (renamed from deps/earcut/0.12.3/LICENSE) | 0 | ||||
-rw-r--r-- | deps/earcut/0.12.4/include/mapbox/earcut.hpp (renamed from deps/earcut/0.12.3/include/mapbox/earcut.hpp) | 53 |
2 files changed, 26 insertions, 27 deletions
diff --git a/deps/earcut/0.12.3/LICENSE b/deps/earcut/0.12.4/LICENSE index 8bafb57730..8bafb57730 100644 --- a/deps/earcut/0.12.3/LICENSE +++ b/deps/earcut/0.12.4/LICENSE diff --git a/deps/earcut/0.12.3/include/mapbox/earcut.hpp b/deps/earcut/0.12.4/include/mapbox/earcut.hpp index 1f14b9f723..a916c1d254 100644 --- a/deps/earcut/0.12.3/include/mapbox/earcut.hpp +++ b/deps/earcut/0.12.4/include/mapbox/earcut.hpp @@ -23,7 +23,7 @@ template <typename N = uint32_t> class Earcut { public: std::vector<N> indices; - N vertices = 0; + std::size_t vertices = 0; template <typename Polygon> void operator()(const Polygon& points); @@ -78,13 +78,13 @@ private: bool locallyInside(const Node* a, const Node* b); bool middleInside(const Node* a, const Node* b); Node* splitPolygon(Node* a, Node* b); - template <typename Point> Node* insertNode(N i, const Point& p, Node* last); + template <typename Point> Node* insertNode(std::size_t i, const Point& p, Node* last); void removeNode(Node* p); bool hashing; double minX, maxX; double minY, maxY; - double size; + double inv_size = 0; template <typename T, typename Alloc = std::allocator<T>> class ObjectPool { @@ -135,7 +135,6 @@ void Earcut<N>::operator()(const Polygon& points) { double x; double y; - size = 0; int threshold = 80; std::size_t len = 0; @@ -162,15 +161,16 @@ void Earcut<N>::operator()(const Polygon& points) { do { x = p->x; y = p->y; - minX = (std::min)(minX, x); - minY = (std::min)(minY, y); - maxX = (std::max)(maxX, x); - maxY = (std::max)(maxY, y); + minX = std::min<double>(minX, x); + minY = std::min<double>(minY, y); + maxX = std::max<double>(maxX, x); + maxY = std::max<double>(maxY, y); p = p->next; } while (p != outerNode); // minX, minY and size are later used to transform coords into integers for z-order calculation - size = (std::max)(maxX - minX, maxY - minY); + inv_size = std::max<double>(maxX - minX, maxY - minY); + inv_size = inv_size != .0 ? (1. / inv_size) : .0; } earcutLinked(outerNode); @@ -184,15 +184,14 @@ typename Earcut<N>::Node* Earcut<N>::linkedList(const Ring& points, const bool clockwise) { using Point = typename Ring::value_type; double sum = 0; - const int len = static_cast<int>(points.size()); - int i, j; - Point p1, p2; + const std::size_t len = points.size(); + std::size_t i, j; Node* last = nullptr; // calculate original winding order of a polygon ring - for (i = 0, j = len - 1; i < len; j = i++) { - p1 = points[i]; - p2 = points[j]; + for (i = 0, j = len > 0 ? len - 1 : 0; i < len; j = i++) { + const auto& p1 = points[i]; + const auto& p2 = points[j]; const double p20 = util::nth<0, Point>::get(p2); const double p10 = util::nth<0, Point>::get(p1); const double p11 = util::nth<1, Point>::get(p1); @@ -204,7 +203,7 @@ Earcut<N>::linkedList(const Ring& points, const bool clockwise) { if (clockwise == (sum > 0)) { for (i = 0; i < len; i++) last = insertNode(vertices + i, points[i], last); } else { - for (i = len - 1; i >= 0; i--) last = insertNode(vertices + i, points[i], last); + for (i = len; i-- > 0;) last = insertNode(vertices + i, points[i], last); } if (last && equals(last, last->next)) { @@ -232,7 +231,7 @@ Earcut<N>::filterPoints(Node* start, Node* end) { removeNode(p); p = end = p->prev; - if (p == p->next) return nullptr; + if (p == p->next) break; again = true; } else { @@ -328,10 +327,10 @@ bool Earcut<N>::isEarHashed(Node* ear) { if (area(a, b, c) >= 0) return false; // reflex, can't be an ear // triangle bbox; min & max are calculated like this for speed - const double minTX = (std::min)(a->x, (std::min)(b->x, c->x)); - const double minTY = (std::min)(a->y, (std::min)(b->y, c->y)); - const double maxTX = (std::max)(a->x, (std::max)(b->x, c->x)); - const double maxTY = (std::max)(a->y, (std::max)(b->y, c->y)); + const double minTX = std::min<double>(a->x, std::min<double>(b->x, c->x)); + const double minTY = std::min<double>(a->y, std::min<double>(b->y, c->y)); + const double maxTX = std::max<double>(a->x, std::max<double>(b->x, c->x)); + const double maxTY = std::max<double>(a->y, std::max<double>(b->y, c->y)); // z-order range for the current triangle bbox; const int32_t minZ = zOrder(minTX, minTY); @@ -544,7 +543,7 @@ Earcut<N>::sortLinked(Node* list) { int i, numMerges, pSize, qSize; int inSize = 1; - while (true) { + for (;;) { p = list; list = nullptr; tail = nullptr; @@ -604,8 +603,8 @@ Earcut<N>::sortLinked(Node* list) { template <typename N> int32_t Earcut<N>::zOrder(const double x_, const double y_) { // coords are transformed into non-negative 15-bit integer range - int32_t x = static_cast<int32_t>(32767.0 * (x_ - minX) / size); - int32_t y = static_cast<int32_t>(32767.0 * (y_ - minY) / size); + int32_t x = static_cast<int32_t>(32767.0 * (x_ - minX) * inv_size); + int32_t y = static_cast<int32_t>(32767.0 * (y_ - minY) * inv_size); x = (x | (x << 8)) & 0x00FF00FF; x = (x | (x << 4)) & 0x0F0F0F0F; @@ -737,8 +736,8 @@ Earcut<N>::splitPolygon(Node* a, Node* b) { // create a node and util::optionally link it with previous one (in a circular doubly linked list) template <typename N> template <typename Point> typename Earcut<N>::Node* -Earcut<N>::insertNode(N i, const Point& pt, Node* last) { - Node* p = nodes.construct(i, util::nth<0, Point>::get(pt), util::nth<1, Point>::get(pt)); +Earcut<N>::insertNode(std::size_t i, const Point& pt, Node* last) { + Node* p = nodes.construct(static_cast<N>(i), util::nth<0, Point>::get(pt), util::nth<1, Point>::get(pt)); if (!last) { p->prev = p; @@ -768,6 +767,6 @@ template <typename N = uint32_t, typename Polygon> std::vector<N> earcut(const Polygon& poly) { mapbox::detail::Earcut<N> earcut; earcut(poly); - return earcut.indices; + return std::move(earcut.indices); } } |