Open
Description
What problem does this solve or what need does it fill?
Following the introduction of #15341, some users have expressed concerns around difficulties migrating to account for ghost nodes in their hierarchies.
This is a great opportunity to add more tools for traversing hierarchies in the spirit of iter_descendants
.
What solution would you like?
There are two stages to this:
- Add more methods to
HierarchyQueryExt
to capture other common tasks. - Add a ghost-node aware version of this trait, which lives in
bevy_ui
and takes aHas<GhostNode>
argument as well. These methods should be namediter_node_descendants
and so on.
In theory these can be done in either order, or in a single PR. Your choice!
In terms of additional tasks to cover:
root_parent
: the entity that is highest up the hierarchy tree, if any.leaf_children
: an iterator over the children that have no children of their own.siblings
: other entities that are in direct children of the same parent.parent
: a convenience method that looks for the parent (much more useful when working with ghost nodes).children
: as above, but for children.
What alternative(s) have you considered?
One day (🥺), this will get rolled into #3742. It's nice to ship helpful APIs to users sooner though, and these methods will be easier to migrate since they have semantic meaning.