Skip to content

[Merged by Bors] - Add methods to Query<&Children> and Query<&Parent> to iterate over descendants and ancestors#6185

Closed
tim-blackbird wants to merge 10 commits intobevyengine:mainfrom
tim-blackbird:hierarchy-query-stuff
Closed

[Merged by Bors] - Add methods to Query<&Children> and Query<&Parent> to iterate over descendants and ancestors#6185
tim-blackbird wants to merge 10 commits intobevyengine:mainfrom
tim-blackbird:hierarchy-query-stuff

Conversation

@tim-blackbird
Copy link
Contributor

@tim-blackbird tim-blackbird commented Oct 6, 2022

Objective

Add methods to Query<&Children> and Query<&Parent> to iterate over descendants and ancestors, respectively.

Changelog

  • Added extension trait for Query in bevy_hierarchy, HierarchyQueryExt
  • Added method iter_descendants to Query<&Children> via HierarchyQueryExt for iterating over the descendants of an entity.
  • Added method iter_ancestors to Query<&Parent> via HierarchyQueryExt for iterating over the ancestors of an entity.

@alice-i-cecile alice-i-cecile added C-Usability A targeted quality-of-life change that makes Bevy easier to use A-Hierarchy labels Oct 10, 2022
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very useful and well made. Can you add a couple of tests for these methods and link to them from the [Parent] and [Children] docs?

bors bot pushed a commit that referenced this pull request Oct 12, 2022
# Objective

- make it easier to build dynamic scenes

## Solution

- add a builder to create a dynamic scene from a world. it can extract an entity or an iterator of entities
- alternative to #6013, leaving the "hierarchy iteration" part to #6185 which does it better
- alternative to #6004 
- using a builder makes it easier to chain several extractions
@alice-i-cecile alice-i-cecile added this to the Bevy 0.9 milestone Oct 12, 2022
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent, thanks!

james7132 pushed a commit to james7132/bevy that referenced this pull request Oct 19, 2022
# Objective

- make it easier to build dynamic scenes

## Solution

- add a builder to create a dynamic scene from a world. it can extract an entity or an iterator of entities
- alternative to bevyengine#6013, leaving the "hierarchy iteration" part to bevyengine#6185 which does it better
- alternative to bevyengine#6004 
- using a builder makes it easier to chain several extractions
@james7132 james7132 self-requested a review October 20, 2022 06:59
james7132 pushed a commit to james7132/bevy that referenced this pull request Oct 28, 2022
# Objective

- make it easier to build dynamic scenes

## Solution

- add a builder to create a dynamic scene from a world. it can extract an entity or an iterator of entities
- alternative to bevyengine#6013, leaving the "hierarchy iteration" part to bevyengine#6185 which does it better
- alternative to bevyengine#6004 
- using a builder makes it easier to chain several extractions
@alice-i-cecile
Copy link
Member

Why was the last commit needed?

@tim-blackbird
Copy link
Contributor Author

tim-blackbird commented Oct 30, 2022

Just code-quality :)
The commit is named 'yuck' because I realized EntityMut does not have add_child -_-

@mockersf mockersf added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Oct 30, 2022
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bors r+

bors bot pushed a commit that referenced this pull request Oct 31, 2022
…r descendants and ancestors (#6185)

# Objective
Add methods to `Query<&Children>` and `Query<&Parent>` to iterate over descendants and ancestors, respectively.

## Changelog

* Added extension trait for `Query` in `bevy_hierarchy`, `HierarchyQueryExt`
* Added method `iter_descendants` to `Query<&Children>` via `HierarchyQueryExt` for iterating over the descendants of an entity.
* Added method `iter_ancestors` to `Query<&Parent>` via `HierarchyQueryExt` for iterating over the ancestors of an entity.

Co-authored-by: devil-ira <justthecooldude@gmail.com>
@bors bors bot changed the title Add methods to Query<&Children> and Query<&Parent> to iterate over descendants and ancestors [Merged by Bors] - Add methods to Query<&Children> and Query<&Parent> to iterate over descendants and ancestors Oct 31, 2022
@bors bors bot closed this Oct 31, 2022
Pietrek14 pushed a commit to Pietrek14/bevy that referenced this pull request Dec 17, 2022
# Objective

- make it easier to build dynamic scenes

## Solution

- add a builder to create a dynamic scene from a world. it can extract an entity or an iterator of entities
- alternative to bevyengine#6013, leaving the "hierarchy iteration" part to bevyengine#6185 which does it better
- alternative to bevyengine#6004 
- using a builder makes it easier to chain several extractions
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
# Objective

- make it easier to build dynamic scenes

## Solution

- add a builder to create a dynamic scene from a world. it can extract an entity or an iterator of entities
- alternative to bevyengine#6013, leaving the "hierarchy iteration" part to bevyengine#6185 which does it better
- alternative to bevyengine#6004 
- using a builder makes it easier to chain several extractions
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
…r descendants and ancestors (bevyengine#6185)

# Objective
Add methods to `Query<&Children>` and `Query<&Parent>` to iterate over descendants and ancestors, respectively.

## Changelog

* Added extension trait for `Query` in `bevy_hierarchy`, `HierarchyQueryExt`
* Added method `iter_descendants` to `Query<&Children>` via `HierarchyQueryExt` for iterating over the descendants of an entity.
* Added method `iter_ancestors` to `Query<&Parent>` via `HierarchyQueryExt` for iterating over the ancestors of an entity.

Co-authored-by: devil-ira <justthecooldude@gmail.com>
@tim-blackbird tim-blackbird deleted the hierarchy-query-stuff branch March 13, 2023 16:12
@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events and removed A-Hierarchy labels Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants