Skip to content

Commit 381f3d3

Browse files
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 <[email protected]>
1 parent 56076b7 commit 381f3d3

File tree

1 file changed

+6
-6
lines changed
  • crates/bevy_gizmos/src/primitives

1 file changed

+6
-6
lines changed

crates/bevy_gizmos/src/primitives/dim2.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -467,9 +467,9 @@ impl<'w, 's, const N: usize, T: GizmoConfigGroup> GizmoPrimitive2d<Polygon<N>>
467467

468468
// Check if the polygon needs a closing point
469469
let closing_point = {
470-
let last = primitive.vertices.last();
471-
(primitive.vertices.first() != last)
472-
.then_some(last)
470+
let first = primitive.vertices.first();
471+
(primitive.vertices.last() != first)
472+
.then_some(first)
473473
.flatten()
474474
.cloned()
475475
};
@@ -503,9 +503,9 @@ impl<'w, 's, T: GizmoConfigGroup> GizmoPrimitive2d<BoxedPolygon> for Gizmos<'w,
503503
}
504504

505505
let closing_point = {
506-
let last = primitive.vertices.last();
507-
(primitive.vertices.first() != last)
508-
.then_some(last)
506+
let first = primitive.vertices.first();
507+
(primitive.vertices.last() != first)
508+
.then_some(first)
509509
.flatten()
510510
.cloned()
511511
};

0 commit comments

Comments
 (0)