diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-10-29 18:59:07 +0300 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-10-31 16:53:07 +0200 |
commit | 384f1a1960c9a21039642afe9bd1df58a93fddfc (patch) | |
tree | cd4a383d82ee78a8bb38f87703a19b61171c5f1d /src/mbgl/renderer/fill_bucket.cpp | |
parent | 38f536049a8ed8f4bdf7706f4afcbbaf06c974c9 (diff) | |
download | qtlocation-mapboxgl-384f1a1960c9a21039642afe9bd1df58a93fddfc.tar.gz |
[core] Use numeric_limits<>::max() for checking element groups
Diffstat (limited to 'src/mbgl/renderer/fill_bucket.cpp')
-rw-r--r-- | src/mbgl/renderer/fill_bucket.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/mbgl/renderer/fill_bucket.cpp b/src/mbgl/renderer/fill_bucket.cpp index 2c69524c0d..86b3946f64 100644 --- a/src/mbgl/renderer/fill_bucket.cpp +++ b/src/mbgl/renderer/fill_bucket.cpp @@ -39,7 +39,7 @@ void FillBucket::addGeometry(const GeometryCollection& geometry) { for (const auto& ring : polygon) { totalVertices += ring.size(); - if (totalVertices > 65535) + if (totalVertices > std::numeric_limits<uint16_t>::max()) throw GeometryTooLongException(); } @@ -51,21 +51,20 @@ void FillBucket::addGeometry(const GeometryCollection& geometry) { if (nVertices == 0) continue; - if (lineSegments.empty() || lineSegments.back().vertexLength + nVertices > 65535) { + if (lineSegments.back().vertexLength + nVertices > std::numeric_limits<uint16_t>::max()) { lineSegments.emplace_back(vertices.size(), lines.size()); } auto& lineSegment = lineSegments.back(); + assert(lineSegment.vertexLength <= std::numeric_limits<uint16_t>::max()); uint16_t lineIndex = lineSegment.vertexLength; vertices.emplace_back(ring[0].x, ring[0].y); - lines.emplace_back(static_cast<uint16_t>(lineIndex + nVertices - 1), - static_cast<uint16_t>(lineIndex)); + lines.emplace_back(lineIndex + nVertices - 1, lineIndex); for (uint32_t i = 1; i < nVertices; i++) { vertices.emplace_back(ring[i].x, ring[i].y); - lines.emplace_back(static_cast<uint16_t>(lineIndex + i - 1), - static_cast<uint16_t>(lineIndex + i)); + lines.emplace_back(lineIndex + i - 1, lineIndex + i); } lineSegment.vertexLength += nVertices; @@ -77,17 +76,18 @@ void FillBucket::addGeometry(const GeometryCollection& geometry) { std::size_t nIndicies = indices.size(); assert(nIndicies % 3 == 0); - if (triangleSegments.empty() || triangleSegments.back().vertexLength + totalVertices > 65535) { + if (triangleSegments.back().vertexLength + totalVertices > std::numeric_limits<uint16_t>::max()) { triangleSegments.emplace_back(startVertices, triangles.size()); } auto& triangleSegment = triangleSegments.back(); + assert(triangleSegment.vertexLength <= std::numeric_limits<uint16_t>::max()); uint16_t triangleIndex = triangleSegment.vertexLength; for (uint32_t i = 0; i < nIndicies; i += 3) { - triangles.emplace_back(static_cast<uint16_t>(triangleIndex + indices[i]), - static_cast<uint16_t>(triangleIndex + indices[i + 1]), - static_cast<uint16_t>(triangleIndex + indices[i + 2])); + triangles.emplace_back(triangleIndex + indices[i], + triangleIndex + indices[i + 1], + triangleIndex + indices[i + 2]); } triangleSegment.vertexLength += totalVertices; |