From 9240e7e9bee1e8389987b822a289545ff9d7ab87 Mon Sep 17 00:00:00 2001 From: "Alexis \"spectria\" Horizon" Date: Wed, 14 Feb 2024 21:22:18 -0500 Subject: [PATCH] Rename CircularShapeUvMode to CircularMeshUvMode. --- .../bevy_render/src/mesh/primitives/dim2.rs | 22 +++++++++---------- examples/2d/2d_shapes.rs | 15 +++++-------- examples/2d/mesh2d_circular.rs | 6 ++--- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/crates/bevy_render/src/mesh/primitives/dim2.rs b/crates/bevy_render/src/mesh/primitives/dim2.rs index ba6590710644d..2e0bc1fa90cb6 100644 --- a/crates/bevy_render/src/mesh/primitives/dim2.rs +++ b/crates/bevy_render/src/mesh/primitives/dim2.rs @@ -84,7 +84,7 @@ impl From for Mesh { /// Specifies how to generate UV-mappings for [`CircularSector`] and [`CircularSegment`] shapes. #[derive(Copy, Clone, Debug, PartialEq)] -pub enum CircularShapeUvMode { +pub enum CircularMeshUvMode { /// Treats the shape as a mask over a circle of equal size and radius, /// with the center of the circle at the center of the texture. Mask { @@ -93,9 +93,9 @@ pub enum CircularShapeUvMode { }, } -impl Default for CircularShapeUvMode { +impl Default for CircularMeshUvMode { fn default() -> Self { - CircularShapeUvMode::Mask { angle: 0.0 } + CircularMeshUvMode::Mask { angle: 0.0 } } } @@ -112,7 +112,7 @@ pub struct CircularSectorMeshBuilder { #[doc(alias = "vertices")] pub resolution: usize, /// The UV mapping mode - pub uv_mode: CircularShapeUvMode, + pub uv_mode: CircularMeshUvMode, } impl Default for CircularSectorMeshBuilder { @@ -120,7 +120,7 @@ impl Default for CircularSectorMeshBuilder { Self { sector: CircularSector::default(), resolution: 32, - uv_mode: CircularShapeUvMode::default(), + uv_mode: CircularMeshUvMode::default(), } } } @@ -145,7 +145,7 @@ impl CircularSectorMeshBuilder { /// Sets the uv mode used for the sector mesh #[inline] - pub const fn uv_mode(mut self, uv_mode: CircularShapeUvMode) -> Self { + pub const fn uv_mode(mut self, uv_mode: CircularMeshUvMode) -> Self { self.uv_mode = uv_mode; self } @@ -157,7 +157,7 @@ impl CircularSectorMeshBuilder { let normals = vec![[0.0, 0.0, 1.0]; self.resolution + 1]; let mut uvs = Vec::with_capacity(self.resolution + 1); - let CircularShapeUvMode::Mask { angle: uv_angle } = self.uv_mode; + let CircularMeshUvMode::Mask { angle: uv_angle } = self.uv_mode; // Push the center of the circle. positions.push([0.0; 3]); @@ -235,7 +235,7 @@ pub struct CircularSegmentMeshBuilder { #[doc(alias = "vertices")] pub resolution: usize, /// The UV mapping mode - pub uv_mode: CircularShapeUvMode, + pub uv_mode: CircularMeshUvMode, } impl Default for CircularSegmentMeshBuilder { @@ -243,7 +243,7 @@ impl Default for CircularSegmentMeshBuilder { Self { segment: CircularSegment::default(), resolution: 32, - uv_mode: CircularShapeUvMode::default(), + uv_mode: CircularMeshUvMode::default(), } } } @@ -268,7 +268,7 @@ impl CircularSegmentMeshBuilder { /// Sets the uv mode used for the segment mesh #[inline] - pub const fn uv_mode(mut self, uv_mode: CircularShapeUvMode) -> Self { + pub const fn uv_mode(mut self, uv_mode: CircularMeshUvMode) -> Self { self.uv_mode = uv_mode; self } @@ -280,7 +280,7 @@ impl CircularSegmentMeshBuilder { let normals = vec![[0.0, 0.0, 1.0]; self.resolution + 1]; let mut uvs = Vec::with_capacity(self.resolution + 1); - let CircularShapeUvMode::Mask { angle: uv_angle } = self.uv_mode; + let CircularMeshUvMode::Mask { angle: uv_angle } = self.uv_mode; // Push the center of the chord. let midpoint_vertex = self.segment.chord_midpoint(); diff --git a/examples/2d/2d_shapes.rs b/examples/2d/2d_shapes.rs index 3ef4c5a89faa6..4da1321e59210 100644 --- a/examples/2d/2d_shapes.rs +++ b/examples/2d/2d_shapes.rs @@ -41,15 +41,12 @@ fn setup( let shapes = [ Shape::from(meshes.add(Circle { radius: 50.0 })), - { - let sector = CircularSector::from_radians(50.0, 5.0); - Shape::new( - meshes.add(sector), - // A sector is drawn symmetrically from the top. - // To make it face right, we must rotate it to the left by 90 degrees. - Transform::from_rotation(Quat::from_rotation_z(PI / 2.0)), - ) - }, + Shape::new( + meshes.add(CircularSector::from_radians(50.0, 5.0)), + // A sector is drawn symmetrically from the top. + // To make it face right, we must rotate it to the left by 90 degrees. + Transform::from_rotation(Quat::from_rotation_z(PI / 2.0)), + ), { let segment = CircularSegment::from_degrees(50.0, 135.0); Shape::new( diff --git a/examples/2d/mesh2d_circular.rs b/examples/2d/mesh2d_circular.rs index b8e35d2312d79..1ae4c047fad41 100644 --- a/examples/2d/mesh2d_circular.rs +++ b/examples/2d/mesh2d_circular.rs @@ -4,7 +4,7 @@ use std::f32::consts::PI; use bevy::{prelude::*, sprite::MaterialMesh2dBundle}; use bevy_internal::render::mesh::{ - CircularSectorMeshBuilder, CircularSegmentMeshBuilder, CircularShapeUvMode, + CircularMeshUvMode, CircularSectorMeshBuilder, CircularSegmentMeshBuilder, }; fn main() { @@ -46,7 +46,7 @@ fn setup( // We must rotate it both in the Transform and in the mesh's UV mappings. let sector_angle = -sector.half_angle(); let sector_mesh = - CircularSectorMeshBuilder::new(sector).uv_mode(CircularShapeUvMode::Mask { + CircularSectorMeshBuilder::new(sector).uv_mode(CircularMeshUvMode::Mask { angle: sector_angle, }); commands.spawn(MaterialMesh2dBundle { @@ -70,7 +70,7 @@ fn setup( // so it is the negative of what you might otherwise expect. let segment_angle = -PI / 2.0; let segment_mesh = - CircularSegmentMeshBuilder::new(segment).uv_mode(CircularShapeUvMode::Mask { + CircularSegmentMeshBuilder::new(segment).uv_mode(CircularMeshUvMode::Mask { angle: -segment_angle, }); commands.spawn(MaterialMesh2dBundle {