Skip to content

Commit

Permalink
fix(primitives): fix polygon gizmo rendering bug (#11699)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
RobWalt and alice-i-cecile committed Feb 5, 2024
1 parent 56076b7 commit 381f3d3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions crates/bevy_gizmos/src/primitives/dim2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
};
Expand Down Expand Up @@ -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()
};
Expand Down

0 comments on commit 381f3d3

Please sign in to comment.