order rhombus vertices in "hull-order" #21621
Open
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.
Objective
Most Mesh2d primitives order their vertices in what I'll call "hull order", which is to say, in an sequential outline of the shape.
A Rectangle, for example, is:
The Rhombus does not follow this pattern, instead using "right, left, top, bottom" order for the vertex buffer.
This isn't a general issue, but there is definitely a pattern to the way the shapes are laid out, and Rhombus doesn't follow it.
This means you can use the vertex buffer alone to define a hull for most 2d shapes (regular polygons, lines, circles, capsules, etc), except the rhombus (also not valid for annulus/ring afaik)
Solution
Re-order the indices and vertices for Rhombus, resulting in the same output, but enabling the vertex buffer to be used to define a "hull" directly, without the index buffer.
Testing
Run the 2d_shapes demo, see wireframe is as expected.
Showcase
In a 2d visibility mesh demo I was building, this caused an issue when trying to directly use the vertex buffer to define the outer "hull" shape.
old rhombus on left, new rhombus on right.