Skip to content

Commit

Permalink
Fix crash when drawing line gizmo with less than 2 vertices (bevyengi…
Browse files Browse the repository at this point in the history
…ne#9101)

# Objective

Fix bevyengine#9089

## Solution

Don't try to draw lines with less than 2 vertices. These would not be
visible either way.

---------

Co-authored-by: François <[email protected]>
  • Loading branch information
tim-blackbird and mockersf committed Aug 15, 2023
1 parent 632ef0c commit cfa3303
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/bevy_gizmos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,10 @@ impl<P: PhaseItem> RenderCommand<P> for DrawLineGizmo {
return RenderCommandResult::Failure;
};

if line_gizmo.vertex_count < 2 {
return RenderCommandResult::Success;
}

let instances = if line_gizmo.strip {
let item_size = VertexFormat::Float32x3.size();
let buffer_size = line_gizmo.position_buffer.size() - item_size;
Expand Down

0 comments on commit cfa3303

Please sign in to comment.