Skip to content

Commit

Permalink
Extract common wireframe filters in type alias (bevyengine#10080)
Browse files Browse the repository at this point in the history
# Objective

- The filter type on the `apply_global_wireframe_material` system had
duplicate filter code and the `clippy::type_complexity` attribute.

## Solution

- Extract the common part of the filter into a type alias
  • Loading branch information
nicopap authored Oct 11, 2023
1 parent f8cbc73 commit be8ff5d
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions crates/bevy_pbr/src/wireframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,29 +108,14 @@ fn apply_wireframe_material(
commands.insert_or_spawn_batch(wireframes_to_spawn);
}

type WireframeFilter = (With<Handle<Mesh>>, Without<Wireframe>, Without<NoWireframe>);

/// Applies or removes a wireframe material on any mesh without a [`Wireframe`] component.
#[allow(clippy::type_complexity)]
fn apply_global_wireframe_material(
mut commands: Commands,
config: Res<WireframeConfig>,
meshes_without_material: Query<
Entity,
(
With<Handle<Mesh>>,
Without<Wireframe>,
Without<NoWireframe>,
Without<Handle<WireframeMaterial>>,
),
>,
meshes_with_global_material: Query<
Entity,
(
With<Handle<Mesh>>,
Without<Wireframe>,
Without<NoWireframe>,
With<Handle<WireframeMaterial>>,
),
>,
meshes_without_material: Query<Entity, (WireframeFilter, Without<Handle<WireframeMaterial>>)>,
meshes_with_global_material: Query<Entity, (WireframeFilter, With<Handle<WireframeMaterial>>)>,
global_material: Res<GlobalWireframeMaterial>,
) {
if !config.is_changed() {
Expand Down

0 comments on commit be8ff5d

Please sign in to comment.