mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
Remove unnecessary parens (#11075)
# Objective - Increase readability. ## Solution - Remove unnecessary parens.
This commit is contained in:
parent
42b737878f
commit
7b8305e5b4
17 changed files with 83 additions and 83 deletions
|
@ -141,14 +141,14 @@ impl AssetSourceBuilder {
|
|||
watch: bool,
|
||||
watch_processed: bool,
|
||||
) -> Option<AssetSource> {
|
||||
let reader = (self.reader.as_mut()?)();
|
||||
let writer = self.writer.as_mut().and_then(|w| (w)());
|
||||
let processed_writer = self.processed_writer.as_mut().and_then(|w| (w)());
|
||||
let reader = self.reader.as_mut()?();
|
||||
let writer = self.writer.as_mut().and_then(|w| w());
|
||||
let processed_writer = self.processed_writer.as_mut().and_then(|w| w());
|
||||
let mut source = AssetSource {
|
||||
id: id.clone(),
|
||||
reader,
|
||||
writer,
|
||||
processed_reader: self.processed_reader.as_mut().map(|r| (r)()),
|
||||
processed_reader: self.processed_reader.as_mut().map(|r| r()),
|
||||
processed_writer,
|
||||
event_receiver: None,
|
||||
watcher: None,
|
||||
|
@ -158,7 +158,7 @@ impl AssetSourceBuilder {
|
|||
|
||||
if watch {
|
||||
let (sender, receiver) = crossbeam_channel::unbounded();
|
||||
match self.watcher.as_mut().and_then(|w| (w)(sender)) {
|
||||
match self.watcher.as_mut().and_then(|w| w(sender)) {
|
||||
Some(w) => {
|
||||
source.watcher = Some(w);
|
||||
source.event_receiver = Some(receiver);
|
||||
|
@ -173,7 +173,7 @@ impl AssetSourceBuilder {
|
|||
|
||||
if watch_processed {
|
||||
let (sender, receiver) = crossbeam_channel::unbounded();
|
||||
match self.processed_watcher.as_mut().and_then(|w| (w)(sender)) {
|
||||
match self.processed_watcher.as_mut().and_then(|w| w(sender)) {
|
||||
Some(w) => {
|
||||
source.processed_watcher = Some(w);
|
||||
source.processed_event_receiver = Some(receiver);
|
||||
|
|
|
@ -878,11 +878,11 @@ impl AssetProcessor {
|
|||
state_is_valid = false;
|
||||
};
|
||||
let Ok(source) = self.get_source(path.source()) else {
|
||||
(unrecoverable_err)(&"AssetSource does not exist");
|
||||
unrecoverable_err(&"AssetSource does not exist");
|
||||
continue;
|
||||
};
|
||||
let Ok(processed_writer) = source.processed_writer() else {
|
||||
(unrecoverable_err)(&"AssetSource does not have a processed AssetWriter registered");
|
||||
unrecoverable_err(&"AssetSource does not have a processed AssetWriter registered");
|
||||
continue;
|
||||
};
|
||||
|
||||
|
@ -891,7 +891,7 @@ impl AssetProcessor {
|
|||
AssetWriterError::Io(err) => {
|
||||
// any error but NotFound means we could be in a bad state
|
||||
if err.kind() != ErrorKind::NotFound {
|
||||
(unrecoverable_err)(&err);
|
||||
unrecoverable_err(&err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -901,7 +901,7 @@ impl AssetProcessor {
|
|||
AssetWriterError::Io(err) => {
|
||||
// any error but NotFound means we could be in a bad state
|
||||
if err.kind() != ErrorKind::NotFound {
|
||||
(unrecoverable_err)(&err);
|
||||
unrecoverable_err(&err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,8 +77,8 @@ impl<'w, 's> EarPositions<'w, 's> {
|
|||
.unwrap_or_else(|| {
|
||||
let settings = SpatialListener::default();
|
||||
(
|
||||
(settings.left_ear_offset * self.scale.0),
|
||||
(settings.right_ear_offset * self.scale.0),
|
||||
settings.left_ear_offset * self.scale.0,
|
||||
settings.right_ear_offset * self.scale.0,
|
||||
)
|
||||
});
|
||||
|
||||
|
|
|
@ -1717,12 +1717,12 @@ mod tests {
|
|||
let mut sched = Schedule::default();
|
||||
sched.add_systems(
|
||||
(
|
||||
(|mut res: ResMut<C>| {
|
||||
|mut res: ResMut<C>| {
|
||||
res.0 += 1;
|
||||
}),
|
||||
(|mut res: ResMut<C>| {
|
||||
},
|
||||
|mut res: ResMut<C>| {
|
||||
res.0 += 2;
|
||||
}),
|
||||
},
|
||||
)
|
||||
.distributive_run_if(resource_exists::<A>().or_else(resource_exists::<B>())),
|
||||
);
|
||||
|
|
|
@ -88,7 +88,7 @@ impl Drop for Arc2dBuilder<'_, '_> {
|
|||
};
|
||||
|
||||
let positions = arc_inner(self.direction_angle, self.arc_angle, self.radius, segments)
|
||||
.map(|vec2| (vec2 + self.position));
|
||||
.map(|vec2| vec2 + self.position);
|
||||
self.gizmos.linestrip_2d(positions, self.color);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ impl Drop for CircleBuilder<'_, '_> {
|
|||
fn drop(&mut self) {
|
||||
let rotation = Quat::from_rotation_arc(Vec3::Z, self.normal);
|
||||
let positions = circle_inner(self.radius, self.segments)
|
||||
.map(|vec2| (self.position + rotation * vec2.extend(0.)));
|
||||
.map(|vec2| self.position + rotation * vec2.extend(0.));
|
||||
self.gizmos.linestrip(positions, self.color);
|
||||
}
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ impl Circle2dBuilder<'_, '_> {
|
|||
|
||||
impl Drop for Circle2dBuilder<'_, '_> {
|
||||
fn drop(&mut self) {
|
||||
let positions = circle_inner(self.radius, self.segments).map(|vec2| (vec2 + self.position));
|
||||
let positions = circle_inner(self.radius, self.segments).map(|vec2| vec2 + self.position);
|
||||
self.gizmos.linestrip_2d(positions, self.color);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ pub fn derive_label(
|
|||
})
|
||||
.unwrap(),
|
||||
);
|
||||
(quote! {
|
||||
quote! {
|
||||
impl #impl_generics #trait_path for #ident #ty_generics #where_clause {
|
||||
fn dyn_clone(&self) -> ::std::boxed::Box<dyn #trait_path> {
|
||||
::std::boxed::Box::new(::std::clone::Clone::clone(self))
|
||||
|
@ -95,6 +95,6 @@ pub fn derive_label(
|
|||
::std::hash::Hash::hash(self, &mut state);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
|
|
@ -549,27 +549,27 @@ bitflags::bitflags! {
|
|||
/// This is accessible in the shader in the [`StandardMaterialUniform`]
|
||||
#[repr(transparent)]
|
||||
pub struct StandardMaterialFlags: u32 {
|
||||
const BASE_COLOR_TEXTURE = (1 << 0);
|
||||
const EMISSIVE_TEXTURE = (1 << 1);
|
||||
const METALLIC_ROUGHNESS_TEXTURE = (1 << 2);
|
||||
const OCCLUSION_TEXTURE = (1 << 3);
|
||||
const DOUBLE_SIDED = (1 << 4);
|
||||
const UNLIT = (1 << 5);
|
||||
const TWO_COMPONENT_NORMAL_MAP = (1 << 6);
|
||||
const FLIP_NORMAL_MAP_Y = (1 << 7);
|
||||
const FOG_ENABLED = (1 << 8);
|
||||
const DEPTH_MAP = (1 << 9); // Used for parallax mapping
|
||||
const SPECULAR_TRANSMISSION_TEXTURE = (1 << 10);
|
||||
const THICKNESS_TEXTURE = (1 << 11);
|
||||
const DIFFUSE_TRANSMISSION_TEXTURE = (1 << 12);
|
||||
const ATTENUATION_ENABLED = (1 << 13);
|
||||
const ALPHA_MODE_RESERVED_BITS = (Self::ALPHA_MODE_MASK_BITS << Self::ALPHA_MODE_SHIFT_BITS); // ← Bitmask reserving bits for the `AlphaMode`
|
||||
const ALPHA_MODE_OPAQUE = (0 << Self::ALPHA_MODE_SHIFT_BITS); // ← Values are just sequential values bitshifted into
|
||||
const ALPHA_MODE_MASK = (1 << Self::ALPHA_MODE_SHIFT_BITS); // the bitmask, and can range from 0 to 7.
|
||||
const ALPHA_MODE_BLEND = (2 << Self::ALPHA_MODE_SHIFT_BITS); //
|
||||
const ALPHA_MODE_PREMULTIPLIED = (3 << Self::ALPHA_MODE_SHIFT_BITS); //
|
||||
const ALPHA_MODE_ADD = (4 << Self::ALPHA_MODE_SHIFT_BITS); // Right now only values 0–5 are used, which still gives
|
||||
const ALPHA_MODE_MULTIPLY = (5 << Self::ALPHA_MODE_SHIFT_BITS); // ← us "room" for two more modes without adding more bits
|
||||
const BASE_COLOR_TEXTURE = 1 << 0;
|
||||
const EMISSIVE_TEXTURE = 1 << 1;
|
||||
const METALLIC_ROUGHNESS_TEXTURE = 1 << 2;
|
||||
const OCCLUSION_TEXTURE = 1 << 3;
|
||||
const DOUBLE_SIDED = 1 << 4;
|
||||
const UNLIT = 1 << 5;
|
||||
const TWO_COMPONENT_NORMAL_MAP = 1 << 6;
|
||||
const FLIP_NORMAL_MAP_Y = 1 << 7;
|
||||
const FOG_ENABLED = 1 << 8;
|
||||
const DEPTH_MAP = 1 << 9; // Used for parallax mapping
|
||||
const SPECULAR_TRANSMISSION_TEXTURE = 1 << 10;
|
||||
const THICKNESS_TEXTURE = 1 << 11;
|
||||
const DIFFUSE_TRANSMISSION_TEXTURE = 1 << 12;
|
||||
const ATTENUATION_ENABLED = 1 << 13;
|
||||
const ALPHA_MODE_RESERVED_BITS = Self::ALPHA_MODE_MASK_BITS << Self::ALPHA_MODE_SHIFT_BITS; // ← Bitmask reserving bits for the `AlphaMode`
|
||||
const ALPHA_MODE_OPAQUE = 0 << Self::ALPHA_MODE_SHIFT_BITS; // ← Values are just sequential values bitshifted into
|
||||
const ALPHA_MODE_MASK = 1 << Self::ALPHA_MODE_SHIFT_BITS; // the bitmask, and can range from 0 to 7.
|
||||
const ALPHA_MODE_BLEND = 2 << Self::ALPHA_MODE_SHIFT_BITS; //
|
||||
const ALPHA_MODE_PREMULTIPLIED = 3 << Self::ALPHA_MODE_SHIFT_BITS; //
|
||||
const ALPHA_MODE_ADD = 4 << Self::ALPHA_MODE_SHIFT_BITS; // Right now only values 0–5 are used, which still gives
|
||||
const ALPHA_MODE_MULTIPLY = 5 << Self::ALPHA_MODE_SHIFT_BITS; // ← us "room" for two more modes without adding more bits
|
||||
const NONE = 0;
|
||||
const UNINITIALIZED = 0xFFFF;
|
||||
}
|
||||
|
|
|
@ -145,8 +145,8 @@ impl GpuPointLights {
|
|||
bitflags::bitflags! {
|
||||
#[repr(transparent)]
|
||||
struct PointLightFlags: u32 {
|
||||
const SHADOWS_ENABLED = (1 << 0);
|
||||
const SPOT_LIGHT_Y_NEGATIVE = (1 << 1);
|
||||
const SHADOWS_ENABLED = 1 << 0;
|
||||
const SPOT_LIGHT_Y_NEGATIVE = 1 << 1;
|
||||
const NONE = 0;
|
||||
const UNINITIALIZED = 0xFFFF;
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ pub struct GpuDirectionalLight {
|
|||
bitflags::bitflags! {
|
||||
#[repr(transparent)]
|
||||
struct DirectionalLightFlags: u32 {
|
||||
const SHADOWS_ENABLED = (1 << 0);
|
||||
const SHADOWS_ENABLED = 1 << 0;
|
||||
const NONE = 0;
|
||||
const UNINITIALIZED = 0xFFFF;
|
||||
}
|
||||
|
|
|
@ -222,11 +222,11 @@ impl From<&MeshTransforms> for MeshUniform {
|
|||
bitflags::bitflags! {
|
||||
#[repr(transparent)]
|
||||
pub struct MeshFlags: u32 {
|
||||
const SHADOW_RECEIVER = (1 << 0);
|
||||
const TRANSMITTED_SHADOW_RECEIVER = (1 << 1);
|
||||
const SHADOW_RECEIVER = 1 << 0;
|
||||
const TRANSMITTED_SHADOW_RECEIVER = 1 << 1;
|
||||
// Indicates the sign of the determinant of the 3x3 model matrix. If the sign is positive,
|
||||
// then the flag should be set, else it should not be set.
|
||||
const SIGN_DETERMINANT_MODEL_3X3 = (1 << 31);
|
||||
const SIGN_DETERMINANT_MODEL_3X3 = 1 << 31;
|
||||
const NONE = 0;
|
||||
const UNINITIALIZED = 0xFFFF;
|
||||
}
|
||||
|
@ -477,25 +477,25 @@ bitflags::bitflags! {
|
|||
/// MSAA uses the highest 3 bits for the MSAA log2(sample count) to support up to 128x MSAA.
|
||||
pub struct MeshPipelineKey: u32 {
|
||||
const NONE = 0;
|
||||
const HDR = (1 << 0);
|
||||
const TONEMAP_IN_SHADER = (1 << 1);
|
||||
const DEBAND_DITHER = (1 << 2);
|
||||
const DEPTH_PREPASS = (1 << 3);
|
||||
const NORMAL_PREPASS = (1 << 4);
|
||||
const DEFERRED_PREPASS = (1 << 5);
|
||||
const MOTION_VECTOR_PREPASS = (1 << 6);
|
||||
const MAY_DISCARD = (1 << 7); // Guards shader codepaths that may discard, allowing early depth tests in most cases
|
||||
const HDR = 1 << 0;
|
||||
const TONEMAP_IN_SHADER = 1 << 1;
|
||||
const DEBAND_DITHER = 1 << 2;
|
||||
const DEPTH_PREPASS = 1 << 3;
|
||||
const NORMAL_PREPASS = 1 << 4;
|
||||
const DEFERRED_PREPASS = 1 << 5;
|
||||
const MOTION_VECTOR_PREPASS = 1 << 6;
|
||||
const MAY_DISCARD = 1 << 7; // Guards shader codepaths that may discard, allowing early depth tests in most cases
|
||||
// See: https://www.khronos.org/opengl/wiki/Early_Fragment_Test
|
||||
const ENVIRONMENT_MAP = (1 << 8);
|
||||
const SCREEN_SPACE_AMBIENT_OCCLUSION = (1 << 9);
|
||||
const DEPTH_CLAMP_ORTHO = (1 << 10);
|
||||
const TEMPORAL_JITTER = (1 << 11);
|
||||
const MORPH_TARGETS = (1 << 12);
|
||||
const ENVIRONMENT_MAP = 1 << 8;
|
||||
const SCREEN_SPACE_AMBIENT_OCCLUSION = 1 << 9;
|
||||
const DEPTH_CLAMP_ORTHO = 1 << 10;
|
||||
const TEMPORAL_JITTER = 1 << 11;
|
||||
const MORPH_TARGETS = 1 << 12;
|
||||
const BLEND_RESERVED_BITS = Self::BLEND_MASK_BITS << Self::BLEND_SHIFT_BITS; // ← Bitmask reserving bits for the blend state
|
||||
const BLEND_OPAQUE = (0 << Self::BLEND_SHIFT_BITS); // ← Values are just sequential within the mask, and can range from 0 to 3
|
||||
const BLEND_PREMULTIPLIED_ALPHA = (1 << Self::BLEND_SHIFT_BITS); //
|
||||
const BLEND_MULTIPLY = (2 << Self::BLEND_SHIFT_BITS); // ← We still have room for one more value without adding more bits
|
||||
const BLEND_ALPHA = (3 << Self::BLEND_SHIFT_BITS);
|
||||
const BLEND_OPAQUE = 0 << Self::BLEND_SHIFT_BITS; // ← Values are just sequential within the mask, and can range from 0 to 3
|
||||
const BLEND_PREMULTIPLIED_ALPHA = 1 << Self::BLEND_SHIFT_BITS; //
|
||||
const BLEND_MULTIPLY = 2 << Self::BLEND_SHIFT_BITS; // ← We still have room for one more value without adding more bits
|
||||
const BLEND_ALPHA = 3 << Self::BLEND_SHIFT_BITS;
|
||||
const MSAA_RESERVED_BITS = Self::MSAA_MASK_BITS << Self::MSAA_SHIFT_BITS;
|
||||
const PRIMITIVE_TOPOLOGY_RESERVED_BITS = Self::PRIMITIVE_TOPOLOGY_MASK_BITS << Self::PRIMITIVE_TOPOLOGY_SHIFT_BITS;
|
||||
const TONEMAP_METHOD_RESERVED_BITS = Self::TONEMAP_METHOD_MASK_BITS << Self::TONEMAP_METHOD_SHIFT_BITS;
|
||||
|
|
|
@ -49,11 +49,11 @@ bitflags::bitflags! {
|
|||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
#[repr(transparent)]
|
||||
pub struct MeshPipelineViewLayoutKey: u32 {
|
||||
const MULTISAMPLED = (1 << 0);
|
||||
const DEPTH_PREPASS = (1 << 1);
|
||||
const NORMAL_PREPASS = (1 << 2);
|
||||
const MOTION_VECTOR_PREPASS = (1 << 3);
|
||||
const DEFERRED_PREPASS = (1 << 4);
|
||||
const MULTISAMPLED = 1 << 0;
|
||||
const DEPTH_PREPASS = 1 << 1;
|
||||
const NORMAL_PREPASS = 1 << 2;
|
||||
const MOTION_VECTOR_PREPASS = 1 << 3;
|
||||
const DEFERRED_PREPASS = 1 << 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -859,9 +859,9 @@ bitflags::bitflags! {
|
|||
#[repr(transparent)]
|
||||
pub struct CompressedImageFormats: u32 {
|
||||
const NONE = 0;
|
||||
const ASTC_LDR = (1 << 0);
|
||||
const BC = (1 << 1);
|
||||
const ETC2 = (1 << 2);
|
||||
const ASTC_LDR = 1 << 0;
|
||||
const BC = 1 << 1;
|
||||
const ETC2 = 1 << 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ impl From<Handle<Image>> for ColorMaterial {
|
|||
bitflags::bitflags! {
|
||||
#[repr(transparent)]
|
||||
pub struct ColorMaterialFlags: u32 {
|
||||
const TEXTURE = (1 << 0);
|
||||
const TEXTURE = 1 << 0;
|
||||
const NONE = 0;
|
||||
const UNINITIALIZED = 0xFFFF;
|
||||
}
|
||||
|
|
|
@ -369,9 +369,9 @@ bitflags::bitflags! {
|
|||
// FIXME: make normals optional?
|
||||
pub struct Mesh2dPipelineKey: u32 {
|
||||
const NONE = 0;
|
||||
const HDR = (1 << 0);
|
||||
const TONEMAP_IN_SHADER = (1 << 1);
|
||||
const DEBAND_DITHER = (1 << 2);
|
||||
const HDR = 1 << 0;
|
||||
const TONEMAP_IN_SHADER = 1 << 1;
|
||||
const DEBAND_DITHER = 1 << 2;
|
||||
const MSAA_RESERVED_BITS = Self::MSAA_MASK_BITS << Self::MSAA_SHIFT_BITS;
|
||||
const PRIMITIVE_TOPOLOGY_RESERVED_BITS = Self::PRIMITIVE_TOPOLOGY_MASK_BITS << Self::PRIMITIVE_TOPOLOGY_SHIFT_BITS;
|
||||
const TONEMAP_METHOD_RESERVED_BITS = Self::TONEMAP_METHOD_MASK_BITS << Self::TONEMAP_METHOD_SHIFT_BITS;
|
||||
|
|
|
@ -121,10 +121,10 @@ bitflags::bitflags! {
|
|||
// MSAA uses the highest 3 bits for the MSAA log2(sample count) to support up to 128x MSAA.
|
||||
pub struct SpritePipelineKey: u32 {
|
||||
const NONE = 0;
|
||||
const COLORED = (1 << 0);
|
||||
const HDR = (1 << 1);
|
||||
const TONEMAP_IN_SHADER = (1 << 2);
|
||||
const DEBAND_DITHER = (1 << 3);
|
||||
const COLORED = 1 << 0;
|
||||
const HDR = 1 << 1;
|
||||
const TONEMAP_IN_SHADER = 1 << 2;
|
||||
const DEBAND_DITHER = 1 << 3;
|
||||
const MSAA_RESERVED_BITS = Self::MSAA_MASK_BITS << Self::MSAA_SHIFT_BITS;
|
||||
const TONEMAP_METHOD_RESERVED_BITS = Self::TONEMAP_METHOD_MASK_BITS << Self::TONEMAP_METHOD_SHIFT_BITS;
|
||||
const TONEMAP_METHOD_NONE = 0 << Self::TONEMAP_METHOD_SHIFT_BITS;
|
||||
|
|
|
@ -115,7 +115,7 @@ fn generate_bodies(
|
|||
),
|
||||
material: materials.add(StandardMaterial {
|
||||
base_color: Color::ORANGE_RED,
|
||||
emissive: (Color::ORANGE_RED * 2.),
|
||||
emissive: Color::ORANGE_RED * 2.,
|
||||
..default()
|
||||
}),
|
||||
..default()
|
||||
|
|
|
@ -483,7 +483,7 @@ fn movement_system(
|
|||
|
||||
fn handle_collision(half_extents: Vec2, translation: &Vec3, velocity: &mut Vec3) {
|
||||
if (velocity.x > 0. && translation.x + HALF_BIRD_SIZE > half_extents.x)
|
||||
|| (velocity.x <= 0. && translation.x - HALF_BIRD_SIZE < -(half_extents.x))
|
||||
|| (velocity.x <= 0. && translation.x - HALF_BIRD_SIZE < -half_extents.x)
|
||||
{
|
||||
velocity.x = -velocity.x;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue