Fix UI borders (#10078)

# Objective

Fixes #10069

## Solution

Extracted UI nodes were previously stored in a `SparseSet` and had a
predictable iteration order. UI borders and outlines relied on this. Now
they are stored in a HashMap and that is no longer true.

This adds `entity.index()` to the sort key for `TransparentUi` so that
the iteration order is predictable and the "border entities" that get
spawned during extraction are guaranteed to get drawn after their
respective container nodes again.

I **think** that everything still works for overlapping ui nodes etc,
because the z value / primary sort is still controlled by the "ui
stack."

Text above is just my current understanding. A rendering expert should
check this out.

I will do some more testing when I can.
This commit is contained in:
Rob Parrett 2023-10-13 10:17:16 -07:00 committed by GitHub
parent 4a61f894b7
commit 26ecfcff43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View file

@ -759,7 +759,10 @@ pub fn queue_uinodes(
draw_function,
pipeline,
entity: *entity,
sort_key: FloatOrd(extracted_uinode.stack_index as f32),
sort_key: (
FloatOrd(extracted_uinode.stack_index as f32),
entity.index(),
),
// batch_range will be calculated in prepare_uinodes
batch_range: 0..0,
dynamic_offset: None,

View file

@ -88,7 +88,7 @@ impl Node for UiPassNode {
}
pub struct TransparentUi {
pub sort_key: FloatOrd,
pub sort_key: (FloatOrd, u32),
pub entity: Entity,
pub pipeline: CachedRenderPipelineId,
pub draw_function: DrawFunctionId,
@ -97,7 +97,7 @@ pub struct TransparentUi {
}
impl PhaseItem for TransparentUi {
type SortKey = FloatOrd;
type SortKey = (FloatOrd, u32);
#[inline]
fn entity(&self) -> Entity {