mirror of
https://github.com/bevyengine/bevy
synced 2024-11-21 20:23:28 +00:00
Use stack_z_offsets
in all the cases we create a TransparentUi
(#16197)
# Objective Use same pattern when creating `TransparentUi` items where the `sort_key` is the `UiNode` stack index + some offset. ## Solution Refactored to follow same pattern. ## Testing Ran few UI examples. ## Doubts Maybe `stack_z_offsets::BACKGROUND_COLOR` should be renamed. This is used for `ExtractedUiNode`, which is not only used for "background color" it's also used to render borders, images and text (I think).
This commit is contained in:
parent
50dde9b0a7
commit
718688e791
3 changed files with 8 additions and 6 deletions
|
@ -32,7 +32,7 @@ use bevy_render::{
|
|||
use bevy_transform::prelude::GlobalTransform;
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
|
||||
use super::{QUAD_INDICES, QUAD_VERTEX_POSITIONS};
|
||||
use super::{stack_z_offsets, QUAD_INDICES, QUAD_VERTEX_POSITIONS};
|
||||
|
||||
pub const BOX_SHADOW_SHADER_HANDLE: Handle<Shader> = Handle::weak_from_u128(17717747047134343426);
|
||||
|
||||
|
@ -365,7 +365,7 @@ pub fn queue_shadows(
|
|||
pipeline,
|
||||
entity: (*entity, extracted_shadow.main_entity),
|
||||
sort_key: (
|
||||
FloatOrd(extracted_shadow.stack_index as f32 - 0.1),
|
||||
FloatOrd(extracted_shadow.stack_index as f32 + stack_z_offsets::BOX_SHADOW),
|
||||
entity.index(),
|
||||
),
|
||||
batch_range: 0..0,
|
||||
|
|
|
@ -75,7 +75,7 @@ pub mod graph {
|
|||
/// When this is _not_ possible, pick a suitably unique index unlikely to clash with other things (ex: `0.1826823` not `0.1`).
|
||||
///
|
||||
/// Offsets should be unique for a given node entity to avoid z fighting.
|
||||
/// These should pretty much _always_ be larger than -1.0 and smaller than 1.0 to avoid clipping into nodes
|
||||
/// These should pretty much _always_ be larger than -0.5 and smaller than 0.5 to avoid clipping into nodes
|
||||
/// above / below the current node in the stack.
|
||||
///
|
||||
/// A z-index of 0.0 is the baseline, which is used as the primary "background color" of the node.
|
||||
|
@ -83,7 +83,9 @@ pub mod graph {
|
|||
/// Note that nodes "stack" on each other, so a negative offset on the node above could clip _into_
|
||||
/// a positive offset on a node below.
|
||||
pub mod stack_z_offsets {
|
||||
pub const BACKGROUND_COLOR: f32 = 0.0;
|
||||
pub const BOX_SHADOW: f32 = -0.1;
|
||||
pub const TEXTURE_SLICE: f32 = 0.0;
|
||||
pub const NODE: f32 = 0.0;
|
||||
pub const MATERIAL: f32 = 0.18267;
|
||||
}
|
||||
|
||||
|
@ -861,7 +863,7 @@ pub fn queue_uinodes(
|
|||
pipeline,
|
||||
entity: (*entity, extracted_uinode.main_entity),
|
||||
sort_key: (
|
||||
FloatOrd(extracted_uinode.stack_index as f32 + stack_z_offsets::BACKGROUND_COLOR),
|
||||
FloatOrd(extracted_uinode.stack_index as f32 + stack_z_offsets::NODE),
|
||||
entity.index(),
|
||||
),
|
||||
// batch_range will be calculated in prepare_uinodes
|
||||
|
|
|
@ -365,7 +365,7 @@ pub fn queue_ui_slices(
|
|||
pipeline,
|
||||
entity: (*entity, extracted_slicer.main_entity),
|
||||
sort_key: (
|
||||
FloatOrd(extracted_slicer.stack_index as f32),
|
||||
FloatOrd(extracted_slicer.stack_index as f32 + stack_z_offsets::TEXTURE_SLICE),
|
||||
entity.index(),
|
||||
),
|
||||
batch_range: 0..0,
|
||||
|
|
Loading…
Reference in a new issue