summaryrefslogtreecommitdiffstats
path: root/graphics/src/layer/mesh.rs
diff options
context:
space:
mode:
authorLibravatar Bingus <shankern@protonmail.com>2023-07-12 12:23:18 -0700
committerLibravatar Bingus <shankern@protonmail.com>2023-07-12 12:23:18 -0700
commit633f405f3f78bc7f82d2b2061491b0e011137451 (patch)
tree5ebfc1f45d216a5c14a90492563599e6969eab4d /graphics/src/layer/mesh.rs
parent41836dd80d0534608e7aedfbf2319c540a23de1a (diff)
parent21bd51426d900e271206f314e0c915dd41065521 (diff)
downloadiced-633f405f3f78bc7f82d2b2061491b0e011137451.tar.gz
iced-633f405f3f78bc7f82d2b2061491b0e011137451.tar.bz2
iced-633f405f3f78bc7f82d2b2061491b0e011137451.zip
Merge remote-tracking branch 'origin/master' into feat/multi-window-support
# Conflicts: # Cargo.toml # core/src/window/icon.rs # core/src/window/id.rs # core/src/window/position.rs # core/src/window/settings.rs # examples/integration/src/main.rs # examples/integration_opengl/src/main.rs # glutin/src/application.rs # native/src/subscription.rs # native/src/window.rs # runtime/src/window/action.rs # src/lib.rs # src/window.rs # winit/Cargo.toml # winit/src/application.rs # winit/src/icon.rs # winit/src/settings.rs # winit/src/window.rs
Diffstat (limited to 'graphics/src/layer/mesh.rs')
-rw-r--r--graphics/src/layer/mesh.rs93
1 files changed, 0 insertions, 93 deletions
diff --git a/graphics/src/layer/mesh.rs b/graphics/src/layer/mesh.rs
deleted file mode 100644
index 7661c5c9..00000000
--- a/graphics/src/layer/mesh.rs
+++ /dev/null
@@ -1,93 +0,0 @@
-//! A collection of triangle primitives.
-use crate::triangle;
-use crate::{Gradient, Point, Rectangle};
-
-/// A mesh of triangles.
-#[derive(Debug, Clone, Copy)]
-pub enum Mesh<'a> {
- /// A mesh of triangles with a solid color.
- Solid {
- /// The origin of the vertices of the [`Mesh`].
- origin: Point,
-
- /// The vertex and index buffers of the [`Mesh`].
- buffers: &'a triangle::Mesh2D<triangle::ColoredVertex2D>,
-
- /// The clipping bounds of the [`Mesh`].
- clip_bounds: Rectangle<f32>,
- },
- /// A mesh of triangles with a gradient color.
- Gradient {
- /// The origin of the vertices of the [`Mesh`].
- origin: Point,
-
- /// The vertex and index buffers of the [`Mesh`].
- buffers: &'a triangle::Mesh2D<triangle::Vertex2D>,
-
- /// The clipping bounds of the [`Mesh`].
- clip_bounds: Rectangle<f32>,
-
- /// The gradient to apply to the [`Mesh`].
- gradient: &'a Gradient,
- },
-}
-
-impl Mesh<'_> {
- /// Returns the origin of the [`Mesh`].
- pub fn origin(&self) -> Point {
- match self {
- Self::Solid { origin, .. } | Self::Gradient { origin, .. } => {
- *origin
- }
- }
- }
-
- /// Returns the indices of the [`Mesh`].
- pub fn indices(&self) -> &[u32] {
- match self {
- Self::Solid { buffers, .. } => &buffers.indices,
- Self::Gradient { buffers, .. } => &buffers.indices,
- }
- }
-
- /// Returns the clip bounds of the [`Mesh`].
- pub fn clip_bounds(&self) -> Rectangle<f32> {
- match self {
- Self::Solid { clip_bounds, .. }
- | Self::Gradient { clip_bounds, .. } => *clip_bounds,
- }
- }
-}
-
-/// The result of counting the attributes of a set of meshes.
-#[derive(Debug, Clone, Copy, Default)]
-pub struct AttributeCount {
- /// The total amount of solid vertices.
- pub solid_vertices: usize,
-
- /// The total amount of gradient vertices.
- pub gradient_vertices: usize,
-
- /// The total amount of indices.
- pub indices: usize,
-}
-
-/// Returns the number of total vertices & total indices of all [`Mesh`]es.
-pub fn attribute_count_of<'a>(meshes: &'a [Mesh<'a>]) -> AttributeCount {
- meshes
- .iter()
- .fold(AttributeCount::default(), |mut count, mesh| {
- match mesh {
- Mesh::Solid { buffers, .. } => {
- count.solid_vertices += buffers.vertices.len();
- count.indices += buffers.indices.len();
- }
- Mesh::Gradient { buffers, .. } => {
- count.gradient_vertices += buffers.vertices.len();
- count.indices += buffers.indices.len();
- }
- }
-
- count
- })
-}