diff options
author | Stephan Schmid <stephan.s.schmid@daimler.com> | 2018-12-10 16:36:32 +0100 |
---|---|---|
committer | Stephan Schmid <stephan.s.schmid@daimler.com> | 2019-02-24 23:09:14 +0100 |
commit | 3c4dd4ab749f756f89ad12bf0b4435e58aa2e662 (patch) | |
tree | 078f6a88da33e606000c38da50fdf649512bd563 | |
parent | 36e63603ec54d25f6f0843c89bb436db1e8997fa (diff) | |
download | qtlocation-mapboxgl-3c4dd4ab749f756f89ad12bf0b4435e58aa2e662.tar.gz |
Extrusions: Do not try to triangulate non-polygon type featuresupstream/friedbunny-external-13531
Trying to triangulate the area of a feature without area (e.g.
GeoJSON LineStrings) just creates invalid excess triangles,
yielding visual artifacts
-rw-r--r-- | src/mbgl/renderer/buckets/fill_extrusion_bucket.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/mbgl/renderer/buckets/fill_extrusion_bucket.cpp b/src/mbgl/renderer/buckets/fill_extrusion_bucket.cpp index e640cf504d..6ab129ebe3 100644 --- a/src/mbgl/renderer/buckets/fill_extrusion_bucket.cpp +++ b/src/mbgl/renderer/buckets/fill_extrusion_bucket.cpp @@ -139,20 +139,21 @@ void FillExtrusionBucket::addFeature(const GeometryTileFeature& feature, } } } + //only triangulate and draw the area of the feature if it is a polygon since other features (e.g. LineString) do not have a base area + if(feature.getType() == FeatureType::Polygon) { + std::vector<uint32_t> indices = mapbox::earcut(polygon); - std::vector<uint32_t> indices = mapbox::earcut(polygon); + std::size_t nIndices = indices.size(); + assert(nIndices % 3 == 0); - std::size_t nIndices = indices.size(); - assert(nIndices % 3 == 0); - - for (uint32_t i = 0; i < nIndices; i += 3) { - // Counter-Clockwise winding order. - triangles.emplace_back(flatIndices[indices[i]], flatIndices[indices[i + 2]], - flatIndices[indices[i + 1]]); + for (uint32_t i = 0; i < nIndices; i += 3) { + // Counter-Clockwise winding order. + triangles.emplace_back(flatIndices[indices[i]], flatIndices[indices[i + 2]], + flatIndices[indices[i + 1]]); + } + triangleSegment.indexLength += nIndices; } - triangleSegment.vertexLength += totalVertices; - triangleSegment.indexLength += nIndices; } for (auto& pair : paintPropertyBinders) { |