diff --git a/voxygen/src/render/mod.rs b/voxygen/src/render/mod.rs index e794bf2e07..17edd052a4 100644 --- a/voxygen/src/render/mod.rs +++ b/voxygen/src/render/mod.rs @@ -30,8 +30,8 @@ pub use self::{ Locals as TerrainLocals, }, ui::{ - push_quad_to_mesh as push_ui_quad_to_mesh, - push_tri_to_mesh as push_ui_tri_to_mesh, + create_quad as create_ui_quad, + create_tri as create_ui_tri, Mode as UiMode, UiPipeline, }, diff --git a/voxygen/src/render/pipelines/ui.rs b/voxygen/src/render/pipelines/ui.rs index 7a1c72fb5d..bd88dbe69b 100644 --- a/voxygen/src/render/pipelines/ui.rs +++ b/voxygen/src/render/pipelines/ui.rs @@ -66,7 +66,7 @@ impl Mode { } } -pub fn push_quad_to_mesh(mesh: &mut Mesh, rect: Aabr, uv_rect: Aabr, color: [f32; 4], mode: Mode) { +pub fn create_quad(rect: Aabr, uv_rect: Aabr, color: [f32; 4], mode: Mode) -> Quad { let mode_val = mode.value(); let v = |pos, uv| { Vertex { @@ -83,15 +83,15 @@ pub fn push_quad_to_mesh(mesh: &mut Mesh, rect: Aabr, uv_rect: let (l, b, r, t) = aabr_to_lbrt(rect); let (uv_l, uv_b, uv_r, uv_t) = aabr_to_lbrt(uv_rect); - mesh.push_quad(Quad::new( + Quad::new( v([r, t], [uv_r, uv_t]), v([l, t], [uv_l, uv_t]), v([l, b], [uv_l, uv_b]), v([r, b], [uv_r, uv_b]), - )); + ) } -pub fn push_tri_to_mesh(mesh: &mut Mesh, tri: [[f32; 2]; 3], uv_tri: [[f32; 2]; 3], color: [f32; 4], mode: Mode) { +pub fn create_tri(tri: [[f32; 2]; 3], uv_tri: [[f32; 2]; 3], color: [f32; 4], mode: Mode) -> Tri { let mode_val = mode.value(); let v = |pos, uv| { Vertex { @@ -101,9 +101,9 @@ pub fn push_tri_to_mesh(mesh: &mut Mesh, tri: [[f32; 2]; 3], uv_tri: mode: mode_val, } }; - mesh.push_tri(Tri::new( + Tri::new( v([tri[0][0], tri[0][1]], [uv_tri[0][0], uv_tri[0][1]]), v([tri[1][0], tri[1][1]], [uv_tri[1][0], uv_tri[1][1]]), v([tri[2][0], tri[2][1]], [uv_tri[2][0], uv_tri[2][1]]), - )); + ) } diff --git a/voxygen/src/ui/mod.rs b/voxygen/src/ui/mod.rs index d7101e86f9..8cd9cc92b0 100644 --- a/voxygen/src/ui/mod.rs +++ b/voxygen/src/ui/mod.rs @@ -29,8 +29,8 @@ use crate::{ Texture, UiPipeline, UiMode, - push_ui_quad_to_mesh, - push_ui_tri_to_mesh, + create_ui_quad, + create_ui_tri, }, window::Window, }; @@ -412,13 +412,12 @@ impl Ui { min: Vec2::new(uv_l, uv_b), max: Vec2::new(uv_r, uv_t), }; - push_ui_quad_to_mesh( - &mut mesh, + mesh.push_quad(create_ui_quad( gl_aabr(rect), uv, color, UiMode::Image, - ); + )); } PrimitiveKind::Text { color, text, font_id } => { @@ -463,13 +462,12 @@ impl Ui { (screen_rect.min.y as f32 / screen_h - 0.5) * -2.0, ), }; - push_ui_quad_to_mesh( - &mut mesh, + mesh.push_quad(create_ui_quad( rect, uv, color, UiMode::Text, - ); + )); } } } @@ -483,8 +481,7 @@ impl Ui { switch_to_plain_state!(); - push_ui_quad_to_mesh( - &mut mesh, + mesh.push_quad(create_ui_quad( gl_aabr(rect), Aabr { min: Vec2::new(0.0, 0.0), @@ -492,7 +489,7 @@ impl Ui { }, color, UiMode::Geometry, - ); + )); } PrimitiveKind::TrianglesSingleColor { color, triangles } => { // Don't draw transparent triangle or switch state if there are actually no triangles @@ -518,13 +515,12 @@ impl Ui { p1.into_array(), p3.into_array(), ]}; - push_ui_tri_to_mesh( - &mut mesh, + mesh.push_tri(create_ui_tri( triangle, [[0.0; 2]; 3], color, UiMode::Geometry, - ); + )); } }