From 3c4dd4ab749f756f89ad12bf0b4435e58aa2e662 Mon Sep 17 00:00:00 2001 From: Stephan Schmid Date: Mon, 10 Dec 2018 16:36:32 +0100 Subject: Extrusions: Do not try to triangulate non-polygon type features Trying to triangulate the area of a feature without area (e.g. GeoJSON LineStrings) just creates invalid excess triangles, yielding visual artifacts --- src/mbgl/renderer/buckets/fill_extrusion_bucket.cpp | 21 +++++++++++---------- 1 file 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 indices = mapbox::earcut(polygon); - std::vector 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) { -- cgit v1.2.1