Skip to main content

extract_scene_tree

Function extract_scene_tree 

Source
pub fn extract_scene_tree(world: &GameWorld, state: &mut EditorState)
Expand description

Extracts a scene tree snapshot from the ECS world into editor state.

Assembles the tree top-down from the roots, in entity.index order at every level. The previous bottom-up pass folded each child into its parent by draining a HashMap, which made the result depend on iteration order — and HashMap re-seeds its hasher per instance, so the order differed every frame. Two symptoms followed: a grandchild whose parent had already been moved was re-inserted as a root (so three-level hierarchies lost a level at random), and siblings reordered continuously, which let a click land on a different entity than the one aimed at.