Don't assume all flat polygons face up #60895
Open
+153
−29
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
QgsTessellator
uses a shortcut and considers all 2D polygons and 3D flat (all vertices having the same Z) polygons to be facing up, returning a positive normal and counter clockwise triangles, regardless of the original geometry's winding order. This was also unaffected if theinvertNormals
parameter was set totrue
, leading to more confusion.With this PR, the flat polygons' winding order is taken into account, producing counter clockwise triangles and positive normals for counter clockwise polygons, and clockwise triangles and negative normals for clockwise polygons.
If
invertNormals == true
then both the normals and the triangle winding order is reversed.Edit: However, there are polygons that are not made to be rendered in 3d but rather are just used as footprints for extrusion. Their data provider might even force a winding order, like the buildings shapefile in the test suite. So when we have flat polygons that are extruded, we always treat them as up-facing, regardless of their winding order or the
invertNormals
parameter.Fixes: #52832