mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
Miscellaneous code-quality improvements. (#5860)
Does what it do. Co-authored-by: devil-ira <justthecooldude@gmail.com>
This commit is contained in:
parent
7a29c707bf
commit
76ae6f4c6e
11 changed files with 66 additions and 81 deletions
|
@ -1,4 +1,4 @@
|
|||
use bevy_ecs::{event::Events, prelude::*};
|
||||
use bevy_ecs::prelude::*;
|
||||
|
||||
// In this example a system sends a custom event with a 50/50 chance during any frame.
|
||||
// If an event was send, it will be printed by the console in a receiving system.
|
||||
|
|
|
@ -207,9 +207,8 @@ impl<'w, 's, E: Event> EventReader<'w, 's, E> {
|
|||
&mut self,
|
||||
) -> impl DoubleEndedIterator<Item = (&E, EventId<E>)> + ExactSizeIterator<Item = (&E, EventId<E>)>
|
||||
{
|
||||
self.reader.iter_with_id(&self.events).map(|r @ (_, id)| {
|
||||
self.reader.iter_with_id(&self.events).inspect(|(_, id)| {
|
||||
trace!("EventReader::iter() -> {}", id);
|
||||
r
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -313,7 +312,7 @@ impl<'w, 's, E: Event> EventWriter<'w, 's, E> {
|
|||
self.events.send(event);
|
||||
}
|
||||
|
||||
pub fn send_batch(&mut self, events: impl Iterator<Item = E>) {
|
||||
pub fn send_batch(&mut self, events: impl IntoIterator<Item = E>) {
|
||||
self.events.extend(events);
|
||||
}
|
||||
|
||||
|
|
|
@ -615,35 +615,35 @@ impl VertexAttributeValues {
|
|||
/// mesh, all of the [`VertexAttributeValues`] must have the same length.
|
||||
#[allow(clippy::match_same_arms)]
|
||||
pub fn len(&self) -> usize {
|
||||
match *self {
|
||||
VertexAttributeValues::Float32(ref values) => values.len(),
|
||||
VertexAttributeValues::Sint32(ref values) => values.len(),
|
||||
VertexAttributeValues::Uint32(ref values) => values.len(),
|
||||
VertexAttributeValues::Float32x2(ref values) => values.len(),
|
||||
VertexAttributeValues::Sint32x2(ref values) => values.len(),
|
||||
VertexAttributeValues::Uint32x2(ref values) => values.len(),
|
||||
VertexAttributeValues::Float32x3(ref values) => values.len(),
|
||||
VertexAttributeValues::Sint32x3(ref values) => values.len(),
|
||||
VertexAttributeValues::Uint32x3(ref values) => values.len(),
|
||||
VertexAttributeValues::Float32x4(ref values) => values.len(),
|
||||
VertexAttributeValues::Sint32x4(ref values) => values.len(),
|
||||
VertexAttributeValues::Uint32x4(ref values) => values.len(),
|
||||
VertexAttributeValues::Sint16x2(ref values) => values.len(),
|
||||
VertexAttributeValues::Snorm16x2(ref values) => values.len(),
|
||||
VertexAttributeValues::Uint16x2(ref values) => values.len(),
|
||||
VertexAttributeValues::Unorm16x2(ref values) => values.len(),
|
||||
VertexAttributeValues::Sint16x4(ref values) => values.len(),
|
||||
VertexAttributeValues::Snorm16x4(ref values) => values.len(),
|
||||
VertexAttributeValues::Uint16x4(ref values) => values.len(),
|
||||
VertexAttributeValues::Unorm16x4(ref values) => values.len(),
|
||||
VertexAttributeValues::Sint8x2(ref values) => values.len(),
|
||||
VertexAttributeValues::Snorm8x2(ref values) => values.len(),
|
||||
VertexAttributeValues::Uint8x2(ref values) => values.len(),
|
||||
VertexAttributeValues::Unorm8x2(ref values) => values.len(),
|
||||
VertexAttributeValues::Sint8x4(ref values) => values.len(),
|
||||
VertexAttributeValues::Snorm8x4(ref values) => values.len(),
|
||||
VertexAttributeValues::Uint8x4(ref values) => values.len(),
|
||||
VertexAttributeValues::Unorm8x4(ref values) => values.len(),
|
||||
match self {
|
||||
VertexAttributeValues::Float32(values) => values.len(),
|
||||
VertexAttributeValues::Sint32(values) => values.len(),
|
||||
VertexAttributeValues::Uint32(values) => values.len(),
|
||||
VertexAttributeValues::Float32x2(values) => values.len(),
|
||||
VertexAttributeValues::Sint32x2(values) => values.len(),
|
||||
VertexAttributeValues::Uint32x2(values) => values.len(),
|
||||
VertexAttributeValues::Float32x3(values) => values.len(),
|
||||
VertexAttributeValues::Sint32x3(values) => values.len(),
|
||||
VertexAttributeValues::Uint32x3(values) => values.len(),
|
||||
VertexAttributeValues::Float32x4(values) => values.len(),
|
||||
VertexAttributeValues::Sint32x4(values) => values.len(),
|
||||
VertexAttributeValues::Uint32x4(values) => values.len(),
|
||||
VertexAttributeValues::Sint16x2(values) => values.len(),
|
||||
VertexAttributeValues::Snorm16x2(values) => values.len(),
|
||||
VertexAttributeValues::Uint16x2(values) => values.len(),
|
||||
VertexAttributeValues::Unorm16x2(values) => values.len(),
|
||||
VertexAttributeValues::Sint16x4(values) => values.len(),
|
||||
VertexAttributeValues::Snorm16x4(values) => values.len(),
|
||||
VertexAttributeValues::Uint16x4(values) => values.len(),
|
||||
VertexAttributeValues::Unorm16x4(values) => values.len(),
|
||||
VertexAttributeValues::Sint8x2(values) => values.len(),
|
||||
VertexAttributeValues::Snorm8x2(values) => values.len(),
|
||||
VertexAttributeValues::Uint8x2(values) => values.len(),
|
||||
VertexAttributeValues::Unorm8x2(values) => values.len(),
|
||||
VertexAttributeValues::Sint8x4(values) => values.len(),
|
||||
VertexAttributeValues::Snorm8x4(values) => values.len(),
|
||||
VertexAttributeValues::Uint8x4(values) => values.len(),
|
||||
VertexAttributeValues::Unorm8x4(values) => values.len(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -666,34 +666,34 @@ impl VertexAttributeValues {
|
|||
#[allow(clippy::match_same_arms)]
|
||||
pub fn get_bytes(&self) -> &[u8] {
|
||||
match self {
|
||||
VertexAttributeValues::Float32(values) => cast_slice(&values[..]),
|
||||
VertexAttributeValues::Sint32(values) => cast_slice(&values[..]),
|
||||
VertexAttributeValues::Uint32(values) => cast_slice(&values[..]),
|
||||
VertexAttributeValues::Float32x2(values) => cast_slice(&values[..]),
|
||||
VertexAttributeValues::Sint32x2(values) => cast_slice(&values[..]),
|
||||
VertexAttributeValues::Uint32x2(values) => cast_slice(&values[..]),
|
||||
VertexAttributeValues::Float32x3(values) => cast_slice(&values[..]),
|
||||
VertexAttributeValues::Sint32x3(values) => cast_slice(&values[..]),
|
||||
VertexAttributeValues::Uint32x3(values) => cast_slice(&values[..]),
|
||||
VertexAttributeValues::Float32x4(values) => cast_slice(&values[..]),
|
||||
VertexAttributeValues::Sint32x4(values) => cast_slice(&values[..]),
|
||||
VertexAttributeValues::Uint32x4(values) => cast_slice(&values[..]),
|
||||
VertexAttributeValues::Sint16x2(values) => cast_slice(&values[..]),
|
||||
VertexAttributeValues::Snorm16x2(values) => cast_slice(&values[..]),
|
||||
VertexAttributeValues::Uint16x2(values) => cast_slice(&values[..]),
|
||||
VertexAttributeValues::Unorm16x2(values) => cast_slice(&values[..]),
|
||||
VertexAttributeValues::Sint16x4(values) => cast_slice(&values[..]),
|
||||
VertexAttributeValues::Snorm16x4(values) => cast_slice(&values[..]),
|
||||
VertexAttributeValues::Uint16x4(values) => cast_slice(&values[..]),
|
||||
VertexAttributeValues::Unorm16x4(values) => cast_slice(&values[..]),
|
||||
VertexAttributeValues::Sint8x2(values) => cast_slice(&values[..]),
|
||||
VertexAttributeValues::Snorm8x2(values) => cast_slice(&values[..]),
|
||||
VertexAttributeValues::Uint8x2(values) => cast_slice(&values[..]),
|
||||
VertexAttributeValues::Unorm8x2(values) => cast_slice(&values[..]),
|
||||
VertexAttributeValues::Sint8x4(values) => cast_slice(&values[..]),
|
||||
VertexAttributeValues::Snorm8x4(values) => cast_slice(&values[..]),
|
||||
VertexAttributeValues::Uint8x4(values) => cast_slice(&values[..]),
|
||||
VertexAttributeValues::Unorm8x4(values) => cast_slice(&values[..]),
|
||||
VertexAttributeValues::Float32(values) => cast_slice(values),
|
||||
VertexAttributeValues::Sint32(values) => cast_slice(values),
|
||||
VertexAttributeValues::Uint32(values) => cast_slice(values),
|
||||
VertexAttributeValues::Float32x2(values) => cast_slice(values),
|
||||
VertexAttributeValues::Sint32x2(values) => cast_slice(values),
|
||||
VertexAttributeValues::Uint32x2(values) => cast_slice(values),
|
||||
VertexAttributeValues::Float32x3(values) => cast_slice(values),
|
||||
VertexAttributeValues::Sint32x3(values) => cast_slice(values),
|
||||
VertexAttributeValues::Uint32x3(values) => cast_slice(values),
|
||||
VertexAttributeValues::Float32x4(values) => cast_slice(values),
|
||||
VertexAttributeValues::Sint32x4(values) => cast_slice(values),
|
||||
VertexAttributeValues::Uint32x4(values) => cast_slice(values),
|
||||
VertexAttributeValues::Sint16x2(values) => cast_slice(values),
|
||||
VertexAttributeValues::Snorm16x2(values) => cast_slice(values),
|
||||
VertexAttributeValues::Uint16x2(values) => cast_slice(values),
|
||||
VertexAttributeValues::Unorm16x2(values) => cast_slice(values),
|
||||
VertexAttributeValues::Sint16x4(values) => cast_slice(values),
|
||||
VertexAttributeValues::Snorm16x4(values) => cast_slice(values),
|
||||
VertexAttributeValues::Uint16x4(values) => cast_slice(values),
|
||||
VertexAttributeValues::Unorm16x4(values) => cast_slice(values),
|
||||
VertexAttributeValues::Sint8x2(values) => cast_slice(values),
|
||||
VertexAttributeValues::Snorm8x2(values) => cast_slice(values),
|
||||
VertexAttributeValues::Uint8x2(values) => cast_slice(values),
|
||||
VertexAttributeValues::Unorm8x2(values) => cast_slice(values),
|
||||
VertexAttributeValues::Sint8x4(values) => cast_slice(values),
|
||||
VertexAttributeValues::Snorm8x4(values) => cast_slice(values),
|
||||
VertexAttributeValues::Uint8x4(values) => cast_slice(values),
|
||||
VertexAttributeValues::Unorm8x4(values) => cast_slice(values),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,10 +12,7 @@
|
|||
//!
|
||||
//! For more details on the `WorldQuery` derive macro, see the trait documentation.
|
||||
|
||||
use bevy::{
|
||||
ecs::{component::Component, query::WorldQuery},
|
||||
prelude::*,
|
||||
};
|
||||
use bevy::{ecs::query::WorldQuery, prelude::*};
|
||||
use std::fmt::Debug;
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//! Shows how to iterate over combinations of query results.
|
||||
|
||||
use bevy::{pbr::AmbientLight, prelude::*, render::camera::Camera, time::FixedTimestep};
|
||||
use bevy::{pbr::AmbientLight, prelude::*, time::FixedTimestep};
|
||||
use rand::{thread_rng, Rng};
|
||||
|
||||
#[derive(Debug, Hash, PartialEq, Eq, Clone, StageLabel)]
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
//! Demonstrates handling a key press/release.
|
||||
|
||||
use bevy::{
|
||||
input::{keyboard::KeyCode, Input},
|
||||
prelude::*,
|
||||
};
|
||||
use bevy::prelude::*;
|
||||
|
||||
fn main() {
|
||||
App::new()
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
//! Demonstrates using key modifiers (ctrl, shift).
|
||||
|
||||
use bevy::{
|
||||
input::{keyboard::KeyCode, Input},
|
||||
prelude::*,
|
||||
};
|
||||
use bevy::prelude::*;
|
||||
|
||||
fn main() {
|
||||
App::new()
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
use bevy::{
|
||||
input::mouse::{MouseButtonInput, MouseMotion, MouseWheel},
|
||||
prelude::*,
|
||||
window::CursorMoved,
|
||||
};
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
use bevy::{
|
||||
core_pipeline::core_3d::Transparent3d,
|
||||
ecs::system::{lifetimeless::*, SystemParamItem},
|
||||
math::prelude::*,
|
||||
pbr::{MeshPipeline, MeshPipelineKey, MeshUniform, SetMeshBindGroup, SetMeshViewBindGroup},
|
||||
prelude::*,
|
||||
render::{
|
||||
|
@ -16,7 +15,7 @@ use bevy::{
|
|||
},
|
||||
render_resource::*,
|
||||
renderer::RenderDevice,
|
||||
view::{ComputedVisibility, ExtractedView, Msaa, NoFrustumCulling, Visibility},
|
||||
view::{ExtractedView, NoFrustumCulling},
|
||||
RenderApp, RenderStage,
|
||||
},
|
||||
};
|
||||
|
|
|
@ -9,9 +9,7 @@
|
|||
|
||||
use bevy::{
|
||||
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
|
||||
math::Quat,
|
||||
prelude::*,
|
||||
render::camera::Camera,
|
||||
window::PresentMode,
|
||||
};
|
||||
|
||||
|
|
|
@ -3,10 +3,9 @@
|
|||
//! This is useful for making desktop applications, or any other program that doesn't need to be
|
||||
//! running the event loop non-stop.
|
||||
|
||||
use std::time::Duration;
|
||||
|
||||
use bevy::{
|
||||
prelude::*,
|
||||
utils::Duration,
|
||||
window::{PresentMode, RequestRedraw},
|
||||
winit::WinitSettings,
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue