fix(primitives): fix polygon gizmo rendering bug (#11699)

This is just a minor fix extracted from #11697

A logic error. We tried to close the polygon shape, if the user
specifies an
unclosed polygon. The closing linestring previously didn't close the
polygon
though, but instead added a zero length line at the last coordinate.

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
This commit is contained in:
Robert Walter 2024-02-05 15:09:49 +00:00 committed by GitHub
parent 56076b7b0c
commit 381f3d3fa5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -467,9 +467,9 @@ impl<'w, 's, const N: usize, T: GizmoConfigGroup> GizmoPrimitive2d<Polygon<N>>
// Check if the polygon needs a closing point
let closing_point = {
let last = primitive.vertices.last();
(primitive.vertices.first() != last)
.then_some(last)
let first = primitive.vertices.first();
(primitive.vertices.last() != first)
.then_some(first)
.flatten()
.cloned()
};
@ -503,9 +503,9 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive2d<BoxedPolygon> for Gizmos<'w,
}
let closing_point = {
let last = primitive.vertices.last();
(primitive.vertices.first() != last)
.then_some(last)
let first = primitive.vertices.first();
(primitive.vertices.last() != first)
.then_some(first)
.flatten()
.cloned()
};