diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2018-09-10 10:59:27 +0300 |
---|---|---|
committer | Ander Conselvan de Oliveira <ander.deoliveira@mapbox.com> | 2018-09-13 08:42:36 +0300 |
commit | 5b1925d521b77e27318912619cfcd3a7f2f2cd42 (patch) | |
tree | f658454256218a177b54e906c6e7cbcfe4a4f128 /src | |
parent | 05a7b78aa866720245022805410aae92bb887fa6 (diff) | |
download | qtlocation-mapboxgl-5b1925d521b77e27318912619cfcd3a7f2f2cd42.tar.gz |
[core] Enable face culling for fill extrusion layers
Use face culling for fill extrusion layers. Winding order is changed to
ensure correct rendering.
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/renderer/buckets/fill_extrusion_bucket.cpp | 12 | ||||
-rw-r--r-- | src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp | 2 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/mbgl/renderer/buckets/fill_extrusion_bucket.cpp b/src/mbgl/renderer/buckets/fill_extrusion_bucket.cpp index fe742828b8..fb491e0db2 100644 --- a/src/mbgl/renderer/buckets/fill_extrusion_bucket.cpp +++ b/src/mbgl/renderer/buckets/fill_extrusion_bucket.cpp @@ -126,7 +126,12 @@ void FillExtrusionBucket::addFeature(const GeometryTileFeature& feature, vertices.emplace_back( FillExtrusionProgram::layoutVertex(p2, perp.x, perp.y, 0, 1, edgeDistance)); - triangles.emplace_back(triangleIndex, triangleIndex + 1, triangleIndex + 2); + // ┌──────┐ + // │ 0 1 │ Counter-Clockwise winding order. + // │ │ Triangle 1: 0 => 2 => 1 + // │ 2 3 │ Triangle 2: 1 => 2 => 3 + // └──────┘ + triangles.emplace_back(triangleIndex, triangleIndex + 2, triangleIndex + 1); triangles.emplace_back(triangleIndex + 1, triangleIndex + 2, triangleIndex + 3); triangleIndex += 4; triangleSegment.vertexLength += 4; @@ -141,8 +146,9 @@ void FillExtrusionBucket::addFeature(const GeometryTileFeature& feature, assert(nIndices % 3 == 0); for (uint32_t i = 0; i < nIndices; i += 3) { - triangles.emplace_back(flatIndices[indices[i]], flatIndices[indices[i + 1]], - flatIndices[indices[i + 2]]); + // Counter-Clockwise winding order. + triangles.emplace_back(flatIndices[indices[i]], flatIndices[indices[i + 2]], + flatIndices[indices[i + 1]]); } triangleSegment.vertexLength += totalVertices; diff --git a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp index 0b5c05759c..717408fbd1 100644 --- a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp +++ b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp @@ -109,7 +109,7 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters, RenderSource* parameters.depthModeFor3D(gl::DepthMode::ReadWrite), gl::StencilMode::disabled(), parameters.colorModeForRenderPass(), - gl::CullFaceMode::disabled(), + gl::CullFaceMode::backCCW(), *tileBucket.indexBuffer, tileBucket.triangleSegments, allUniformValues, |