-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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 despawn_children #2903
Closed
TheRawMeatball
wants to merge
3
commits into
bevyengine:main
from
TheRawMeatball:despawn-children-recursive
Closed
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I like the terseness of this name, it goes against the pattern we've already established:
despawn
: only despawns the entitydespawn_recursive
: despawns the entity and its descendantsIf we apply the "despawn" action to children, that should only remove the children, not their descendants. According to the current naming conventions, this should be something like
despawn_children_recursive
.That being said, there are already some issues prior to this pr, such as the docs for
despawn_recursive
being wrong: "despawns the provided entity and its children" is not the actual behavior ofdespawn_recursive
. It despawns the entity and its descendants.Happy to discuss the best way to resolve this situation. Some random thoughts:
despawn
, then we can use the terser name here. Recursive despawns are the default in godot, which sort of makes sense to me, especially given that "scenes" are spawned as node trees in a hierarchy in godot, and we do the same thing in bevy. I expect that generally people despawning an entity would want the descendants to go with it. I'm not actually convinced yet that this is a good idea for bevy, but its worth discussing. It would require adding implicit per-component behaviors to the normal despawn action (either directly or as a "reaction").despawn_children
todespawn_children_recursive
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like making recursive the default, it's probably what people want to use anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I think option 1 is the ideal option, it's definitely not actionable for this PR. As for between option two or three, I'd personally prefer to keep the PR as is, but any clear cut answer would be great. The fourth implied option would be to not add this functionality until we have the ideal api, but that's not very appealing either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. No sense in blocking a useful feature on a big overhaul. I would prefer consistency here in the short term. Can you change this to
despawn_children_recursive
and fix the documentation to properly describe the recursive behavior for both despawn_recursive and despawn_children_recursive?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about
despawn_descendants
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dig it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's too cryptic IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but it forces the user to contend with the realities of the situation, so I think I still prefer it.
despawn_children_recursive
also requires a bit of brain work to understand exactly what it does.despawn_children
has the aforementioned consistency issues.despawn_descendants
does what it says on the tin and uses standard tree terminology. If we ever change thedespawn
semantics, we can move back to the less crypticdespawn_children
naming.