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,14 +194,16 @@ fn build_line_mesh(
} }
indices_set += 1; indices_set += 1;
} }
// Handle the connection between start and end points: if indices_set > 0 {
// - For cyclic lines: connect last segment back to first // Handle the connection between start and end points:
// - For non-cyclic lines: add caps at both ends // - For cyclic lines: connect last segment back to first
if line.cyclic { // - For non-cyclic lines: add caps at both ends
vertex_indices.extend(cyclic_indices(start_set, indices_set - 1)); if line.cyclic {
} else { vertex_indices.extend(cyclic_indices(start_set, indices_set - 1));
vertex_indices.extend(cap_indices(start_set, false)); } else {
vertex_indices.extend(cap_indices(indices_set - 1, true)); vertex_indices.extend(cap_indices(start_set, false));
vertex_indices.extend(cap_indices(indices_set - 1, true));
}
} }
} }
let mut mesh = Mesh::new( let mut mesh = Mesh::new(