Rename OutlinePlane to OutlineDepth.

This commit is contained in:
Robin KAY 2022-11-17 22:15:13 +00:00
parent e1c845c434
commit 55dd3a07a8
4 changed files with 21 additions and 21 deletions

View File

@ -83,7 +83,7 @@ fn setup(
},
..default()
})
.insert(InheritOutlinePlane);
.insert(InheritOutlineDepth);
parent
.spawn_bundle(PbrBundle {
mesh: meshes.add(
@ -108,7 +108,7 @@ fn setup(
},
..default()
})
.insert(InheritOutlinePlane);
.insert(InheritOutlineDepth);
});
// Add plane, light source, and camera

View File

@ -1,27 +1,27 @@
use bevy::prelude::*;
/// A component for storing the computed plane on which the outline lies.
/// A component for storing the computed depth at which the outline lies.
#[derive(Clone, Component, Default)]
pub struct ComputedOutlinePlane {
pub struct ComputedOutlineDepth {
pub(crate) plane: Vec3,
}
/// A component which specifies that this entity lies on the same plane as its parent.
/// A component which specifies that this entity lies at the same depth as its parent.
#[derive(Clone, Component, Default)]
pub struct InheritOutlinePlane;
pub struct InheritOutlineDepth;
#[allow(clippy::type_complexity)]
pub(crate) fn compute_outline_plane(
pub(crate) fn compute_outline_depth(
mut root_query: Query<
(
&mut ComputedOutlinePlane,
&mut ComputedOutlineDepth,
&GlobalTransform,
Changed<GlobalTransform>,
Option<(&Children, Changed<Children>)>,
),
Without<InheritOutlinePlane>,
Without<InheritOutlineDepth>,
>,
mut computed_query: Query<(&mut ComputedOutlinePlane, Changed<InheritOutlinePlane>)>,
mut computed_query: Query<(&mut ComputedOutlineDepth, Changed<InheritOutlineDepth>)>,
child_query: Query<(&Children, Changed<Children>)>,
) {
for (mut computed, transform, changed_transform, children) in root_query.iter_mut() {
@ -32,7 +32,7 @@ pub(crate) fn compute_outline_plane(
if let Some((cs, changed_children)) = children {
let changed2 = changed_children || changed_transform;
for child in cs.iter() {
propagate_outline_planes(
propagate_outline_depth(
&computed,
changed2,
*child,
@ -44,11 +44,11 @@ pub(crate) fn compute_outline_plane(
}
}
fn propagate_outline_planes(
root_computed: &ComputedOutlinePlane,
fn propagate_outline_depth(
root_computed: &ComputedOutlineDepth,
changed: bool,
entity: Entity,
computed_query: &mut Query<(&mut ComputedOutlinePlane, Changed<InheritOutlinePlane>)>,
computed_query: &mut Query<(&mut ComputedOutlineDepth, Changed<InheritOutlineDepth>)>,
child_query: &Query<(&Children, Changed<Children>)>,
) {
if let Ok((mut computed, changed_inherit)) = computed_query.get_mut(entity) {
@ -58,7 +58,7 @@ fn propagate_outline_planes(
if let Ok((cs, changed_children)) = child_query.get(entity) {
let changed2 = changed_children || changed_inherit || changed;
for child in cs.iter() {
propagate_outline_planes(
propagate_outline_depth(
root_computed,
changed2,
*child,

View File

@ -94,14 +94,14 @@ pub struct Outline {
pub struct OutlineBundle {
pub outline: Outline,
pub stencil: OutlineStencil,
pub plane: ComputedOutlinePlane,
pub plane: ComputedOutlineDepth,
}
/// A bundle for stenciling meshes in the outlining pass.
#[derive(Bundle, Clone, Default)]
pub struct OutlineStencilBundle {
pub stencil: OutlineStencil,
pub plane: ComputedOutlinePlane,
pub plane: ComputedOutlineDepth,
}
/// Adds support for rendering outlines.
@ -130,7 +130,7 @@ impl Plugin for OutlinePlugin {
.add_plugin(UniformComponentPlugin::<OutlineViewUniform>::default())
.add_system_to_stage(
CoreStage::PostUpdate,
compute_outline_plane.after(TransformSystem::TransformPropagate),
compute_outline_depth.after(TransformSystem::TransformPropagate),
)
.sub_app_mut(RenderApp)
.init_resource::<DrawFunctions<StencilOutline>>()

View File

@ -13,7 +13,7 @@ use bevy::{
},
};
use crate::{pipeline::OutlinePipeline, ComputedOutlinePlane, Outline, OutlineStencil};
use crate::{pipeline::OutlinePipeline, ComputedOutlineDepth, Outline, OutlineStencil};
#[derive(Clone, Component, ShaderType)]
pub struct OutlineStencilUniform {
@ -44,7 +44,7 @@ pub struct OutlineBindGroup {
pub fn extract_outline_stencil_uniforms(
mut commands: Commands,
query: Extract<Query<(Entity, &ComputedOutlinePlane), With<OutlineStencil>>>,
query: Extract<Query<(Entity, &ComputedOutlineDepth), With<OutlineStencil>>>,
) {
for (entity, computed) in query.iter() {
commands.get_or_spawn(entity).insert(OutlineStencilUniform {
@ -55,7 +55,7 @@ pub fn extract_outline_stencil_uniforms(
pub fn extract_outline_uniforms(
mut commands: Commands,
query: Extract<Query<(Entity, &Outline, &ComputedOutlinePlane)>>,
query: Extract<Query<(Entity, &Outline, &ComputedOutlineDepth)>>,
) {
for (entity, outline, computed) in query.iter() {
if !outline.visible || outline.colour.a() == 0.0 {