From ff7497cb9a67b11caf633348680fc0969c009c7b Mon Sep 17 00:00:00 2001 From: Stepan Koltsov Date: Tue, 12 Dec 2023 21:40:33 +0000 Subject: [PATCH] Explain how RegularPolygon mesh is generated (#10927) I didn't notice minus where vertices are generated, so could not understand the order there. Adding a comment to help the next person who is going to understand Bevy by reading its code. --- crates/bevy_render/src/mesh/shape/regular_polygon.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/bevy_render/src/mesh/shape/regular_polygon.rs b/crates/bevy_render/src/mesh/shape/regular_polygon.rs index c2e86368b15f3..879c59fabd11e 100644 --- a/crates/bevy_render/src/mesh/shape/regular_polygon.rs +++ b/crates/bevy_render/src/mesh/shape/regular_polygon.rs @@ -50,6 +50,8 @@ impl From for Mesh { let mut indices = Vec::with_capacity((sides - 2) * 3); for i in 1..(sides as u32 - 1) { + // Vertices are generated in CW order above, hence the reversed indices here + // to emit triangle vertices in CCW order. indices.extend_from_slice(&[0, i + 1, i]); }