pub fn build_parent_map(
main: &mut World,
) -> (HashMap<Entity, Entity>, HashMap<Entity, u32>)Expand description
Returns (parent_map, document_order_map) used by every extract fn to compute PaintOrder consistently.
parent_map:child -> parentfor every entity carryingbevy_ecs::hierarchy::ChildOf.document_order_map: entity ->PaintOrder, assigned by a pre-order DFS over the hierarchy forest. Parents rank before their children; siblings rank inChildren-list order (bevy keeps the list in insertion order, which matches markup order for static spawns and reconcile order for runtime<if>/<for>clones). Entity-id allocation order plays no part, so entities spawned out of document order (children before parents, reconciler respawns) still paint in tree order andExtractedClipBoxranges bracket exactly the descendant set.
Ranks are multiplied by 2 (see PaintOrder) so extract_shadows can place shadows at
order - 1 without colliding with the preceding leaf. Consume the maps via paint_order_of.
Subtrees rooted at an OverlayLayer entity are excluded from the normal-band DFS and
re-ranked into the top-layer band (>= OVERLAY_ORDER_BASE), stacked among themselves by
OverlayOpenOrder stamp (later-opened on top), each keeping contiguous internal pre-order
ranks. Idempotent within a frame: repeated calls (one per extract fn) see the same visibility
state and hand out the same ranks.