Meshable extrusions - Part 2 (#13676)

# Objective

- Implement `Extrudable` for all meshbuilders of shapes that have been
added after #13478 was created

## Solution

- Implemented meshing for extrusions of `CircularSector`,
`CircularSegment` and `Rhombus`

## Testing

- The correctness of these was confirmed visually.

## Additional information

Here is an image of what they look like :)

![Screenshot 2024-06-04
230633](https://github.com/bevyengine/bevy/assets/62256001/d9cca0ba-30ea-4c48-8ae2-007b469739d7)

Co-authored-by: Lynn Büttgenbach <62256001+solis-lumine-vorago@users.noreply.github.com>
This commit is contained in:
Lynn 2024-06-04 23:53:06 +02:00 committed by GitHub
parent 1fdddf8992
commit 8e4e840a19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -213,6 +213,25 @@ impl MeshBuilder for CircularSectorMeshBuilder {
}
}
impl Extrudable for CircularSectorMeshBuilder {
fn perimeter(&self) -> Vec<PerimeterSegment> {
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<PerimeterSegment> {
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<PerimeterSegment> {
vec![PerimeterSegment::Flat {
indices: vec![0, 2, 1, 3, 0],
}]
}
}
impl Meshable for Rhombus {
type Output = RhombusMeshBuilder;