From 2d900248f0d5196e7afd679f32400ec3a7d42be8 Mon Sep 17 00:00:00 2001 From: Robin KAY Date: Sat, 14 Jan 2023 23:51:44 +0000 Subject: [PATCH] Change to use RenderLayers if OutlineRenderLayers not present. --- src/draw.rs | 10 ++++------ src/lib.rs | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/draw.rs b/src/draw.rs index 7b9f947..f72ce84 100644 --- a/src/draw.rs +++ b/src/draw.rs @@ -36,7 +36,7 @@ pub(crate) fn queue_outline_stencil_mesh( &Handle, &OutlineStencilUniform, &OutlineStencilFlags, - Option<&OutlineRenderLayers>, + &OutlineRenderLayers, )>, mut views: Query<( &ExtractedView, @@ -59,8 +59,7 @@ pub(crate) fn queue_outline_stencil_mesh( for (entity, mesh_handle, stencil_uniform, stencil_flags, outline_mask) in material_meshes.iter() { - let outline_mask = outline_mask.copied().unwrap_or_default(); - if !view_mask.intersects(&outline_mask) { + if !view_mask.intersects(outline_mask) { continue; } if let Some(mesh) = render_meshes.get(mesh_handle) { @@ -108,7 +107,7 @@ pub(crate) fn queue_outline_volume_mesh( &OutlineVolumeUniform, &OutlineVolumeFlags, &OutlineFragmentUniform, - Option<&OutlineRenderLayers>, + &OutlineRenderLayers, )>, mut views: Query<( &ExtractedView, @@ -134,8 +133,7 @@ pub(crate) fn queue_outline_volume_mesh( for (entity, mesh_handle, volume_uniform, volume_flags, fragment_uniform, outline_mask) in material_meshes.iter() { - let outline_mask = outline_mask.copied().unwrap_or_default(); - if !view_mask.intersects(&outline_mask) { + if !view_mask.intersects(outline_mask) { continue; } if let Some(mesh) = render_meshes.get(mesh_handle) { diff --git a/src/lib.rs b/src/lib.rs index 99c01ae..d5c5ce6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -138,11 +138,19 @@ impl Lerp for OutlineVolume { pub struct OutlineRenderLayers(pub RenderLayers); impl ExtractComponent for OutlineRenderLayers { - type Query = &'static OutlineRenderLayers; - type Filter = (); + type Query = ( + Option<&'static OutlineRenderLayers>, + Option<&'static RenderLayers>, + ); + type Filter = Or<(With, With)>; - fn extract_component(item: &OutlineRenderLayers) -> Self { - *item + fn extract_component( + (outline_mask, object_mask): (Option<&OutlineRenderLayers>, Option<&RenderLayers>), + ) -> Self { + outline_mask + .copied() + .or_else(|| object_mask.copied().map(OutlineRenderLayers)) + .unwrap_or_default() } }