Skip to content

Commit

Permalink
cargo-fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
sarkahn committed Aug 24, 2021
1 parent 9cf6b99 commit ad81fbc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
8 changes: 4 additions & 4 deletions crates/bevy_render/src/mesh/mesh/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
//! ```
use crate::mesh::VertexAttributeValues;
use bevy_math::{Vec2, Vec3, Vec4};
use bevy_utils::EnumVariantMeta;
use std::convert::TryFrom;
use thiserror::Error;
use bevy_math::{Vec3, Vec2, Vec4};
#[derive(Debug, Clone, Error)]
#[error("cannot convert VertexAttributeValues::{variant} to {into}")]
pub struct FromVertexAttributeError {
Expand Down Expand Up @@ -128,19 +128,19 @@ impl From<Vec<[u8; 4]>> for VertexAttributeValues {

impl From<Vec<Vec4>> for VertexAttributeValues {
fn from(vec: Vec<Vec4>) -> Self {
VertexAttributeValues::Float32x4(bytemuck::allocation::cast_vec(vec) )
VertexAttributeValues::Float32x4(bytemuck::allocation::cast_vec(vec))
}
}

impl From<Vec<Vec3>> for VertexAttributeValues {
fn from(vec: Vec<Vec3>) -> Self {
VertexAttributeValues::Float32x3(bytemuck::allocation::cast_vec(vec) )
VertexAttributeValues::Float32x3(bytemuck::allocation::cast_vec(vec))
}
}

impl From<Vec<Vec2>> for VertexAttributeValues {
fn from(vec: Vec<Vec2>) -> Self {
VertexAttributeValues::Float32x2(bytemuck::allocation::cast_vec(vec) )
VertexAttributeValues::Float32x2(bytemuck::allocation::cast_vec(vec))
}
}

Expand Down
22 changes: 6 additions & 16 deletions examples/3d/custom_mesh.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bevy::render::mesh::Indices;
use bevy::prelude::*;
use bevy::render::mesh::Indices;
use bevy::render::pipeline::PrimitiveTopology;

fn main() {
Expand All @@ -20,26 +20,16 @@ fn setup(
let right = Vec3::new(1.0, 0.0, 0.0);
let up = Vec3::new(0.0, 1.0, 0.0);

let positions = vec![
origin + up,
origin + up + right,
origin,
origin + right,
];
let positions = vec![origin + up, origin + up + right, origin, origin + right];

let origin = Vec2::new(0.0, 0.0);
let right = Vec2::new(1.0, 0.0);
let up = Vec2::new(0.0, 1.0);

let uvs = vec![
origin + up,
origin + up + right,
origin,
origin + right,
];
let uvs = vec![origin + up, origin + up + right, origin, origin + right];

let normals = vec![ [0.0, 0.0, 1.0]; 4 ];
let indices = Indices::U32(vec![0,1,2,3,2,1]);
let normals = vec![[0.0, 0.0, 1.0]; 4];
let indices = Indices::U32(vec![0, 1, 2, 3, 2, 1]);

let mut mesh = Mesh::new(PrimitiveTopology::TriangleList);
mesh.set_indices(Some(indices));
Expand All @@ -53,7 +43,7 @@ fn setup(
material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()),
..Default::default()
});

// light
commands.spawn_bundle(PointLightBundle {
transform: Transform::from_xyz(4.0, 8.0, 4.0),
Expand Down

0 comments on commit ad81fbc

Please sign in to comment.