fix(lines): add a check to prevent a crash

Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
Schmarni
2025-08-31 05:42:07 +02:00
parent 2b9ba2b957
commit bf85140b65

View File

@@ -194,6 +194,7 @@ fn build_line_mesh(
} }
indices_set += 1; indices_set += 1;
} }
if indices_set > 0 {
// Handle the connection between start and end points: // Handle the connection between start and end points:
// - For cyclic lines: connect last segment back to first // - For cyclic lines: connect last segment back to first
// - For non-cyclic lines: add caps at both ends // - For non-cyclic lines: add caps at both ends
@@ -204,6 +205,7 @@ fn build_line_mesh(
vertex_indices.extend(cap_indices(indices_set - 1, true)); vertex_indices.extend(cap_indices(indices_set - 1, true));
} }
} }
}
let mut mesh = Mesh::new( let mut mesh = Mesh::new(
PrimitiveTopology::TriangleList, PrimitiveTopology::TriangleList,
RenderAssetUsages::RENDER_WORLD, RenderAssetUsages::RENDER_WORLD,