diff --git a/crates/bevy_render/src/mesh/primitives/dim2.rs b/crates/bevy_render/src/mesh/primitives/dim2.rs index 6050aadeb0..03e8165f54 100644 --- a/crates/bevy_render/src/mesh/primitives/dim2.rs +++ b/crates/bevy_render/src/mesh/primitives/dim2.rs @@ -213,6 +213,25 @@ impl MeshBuilder for CircularSectorMeshBuilder { } } +impl Extrudable for CircularSectorMeshBuilder { + fn perimeter(&self) -> Vec { + let resolution = self.resolution as u32; + let (sin, cos) = self.sector.arc.half_angle.sin_cos(); + let first_normal = Vec2::new(sin, cos); + let last_normal = Vec2::new(-sin, cos); + vec![ + PerimeterSegment::Flat { + indices: vec![resolution, 0, 1], + }, + PerimeterSegment::Smooth { + first_normal, + last_normal, + indices: (1..=resolution).collect(), + }, + ] + } +} + impl Meshable for CircularSector { type Output = CircularSectorMeshBuilder; @@ -340,6 +359,25 @@ impl MeshBuilder for CircularSegmentMeshBuilder { } } +impl Extrudable for CircularSegmentMeshBuilder { + fn perimeter(&self) -> Vec { + let resolution = self.resolution as u32; + let (sin, cos) = self.segment.arc.half_angle.sin_cos(); + let first_normal = Vec2::new(sin, cos); + let last_normal = Vec2::new(-sin, cos); + vec![ + PerimeterSegment::Flat { + indices: vec![resolution, 0, 1], + }, + PerimeterSegment::Smooth { + first_normal, + last_normal, + indices: (1..=resolution).collect(), + }, + ] + } +} + impl Meshable for CircularSegment { type Output = CircularSegmentMeshBuilder; @@ -662,6 +700,14 @@ impl MeshBuilder for RhombusMeshBuilder { } } +impl Extrudable for RhombusMeshBuilder { + fn perimeter(&self) -> Vec { + vec![PerimeterSegment::Flat { + indices: vec![0, 2, 1, 3, 0], + }] + } +} + impl Meshable for Rhombus { type Output = RhombusMeshBuilder;