Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed

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 Parent-child entity hierarchies 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Hierarchy Parent-child entity hierarchies 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