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.
This commit is contained in:
Stepan Koltsov 2023-12-12 21:40:33 +00:00 committed by GitHub
parent a7a5d17ae1
commit ff7497cb9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -50,6 +50,8 @@ impl From<RegularPolygon> for Mesh {
let mut indices = Vec::with_capacity((sides - 2) * 3); let mut indices = Vec::with_capacity((sides - 2) * 3);
for i in 1..(sides as u32 - 1) { 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]); indices.extend_from_slice(&[0, i + 1, i]);
} }