Fix bugs/inconsistencies with adding child entities#4706
Fix bugs/inconsistencies with adding child entities#4706SUPERCILEX wants to merge 3 commits intobevyengine:mainfrom SUPERCILEX:children
Conversation
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
|
TODO(me): once this goes through add remove_child API. |
|
Does Bors have a command to add someone as co-author to the rollup commit? That'd be quite useful here. |
|
Since the rollup commit takes from the PR description, I made @james7132 a co-author there which should work. |
Just a small note, that email is incorrect. Use contact@jamessliu.com instead. |
# Conflicts: # crates/bevy_hierarchy/src/child_builder.rs
|
@mockersf Mind reviewing this? (You show up in a decent chunk of the blame.) @james7132 Or if #4197 is for-sure going to get merged, can I send you a patch with a few improvements from this PR? |
| if let Some(mut parent) = child.get_mut::<Parent>() { | ||
| let previous = parent.0; | ||
| *parent = Parent(new_parent); | ||
| child.insert(PreviousParent(new_parent)); |
There was a problem hiding this comment.
| child.insert(PreviousParent(new_parent)); | |
| child.insert(PreviousParent(previous)); |
shouldn't that be the previous parent?
There was a problem hiding this comment.
No. The goal is to hit this line:
bevy/crates/bevy_hierarchy/src/systems.rs
Line 34 in 86dd6f0
There was a problem hiding this comment.
I think it's wrong to set a wrong value to a component because you target a special case for a system that happens after. If you insert the PreviousParent component, it should have the correct value at the moment of insertion
There was a problem hiding this comment.
It does match, that is the correct value. PreviousParent is supposed to match Parent unless someone manually inserts a new Parent.
The RFC has been merged, so it's just the implementation PR that needs review and approval. |
K, I'll send a patch when I can and close this PR. |
|
Ok, done: #4197 (comment) |
Objective
Currently, when new children are added via commands, the old parent's children component is not updated.
Solution
This PR fixes that by partially applying changes from #4197. The ability to update relationships by adding or removing a
Parentcomponent is not changed, but bugs with updating relations from commands are fixed.Changelog
Fix inconsistencies created when adding children via commands.
Co-authored-by: James Liu contact@jamessliu.com