Removing Parent
/ Children
from the world and then reinserting them can break hierarchies
#15575
Labels
A-ECS
Entities, components, systems, and events
A-Hierarchy
Parent-child entity hierarchies
A-Transform
Translations, rotations and scales
C-Bug
An unexpected or incorrect behavior
D-Complex
Quite challenging from either a design or technical perspective. Ask for help!
S-Needs-Design
This issue requires design work to think about how it would best be accomplished
X-Controversial
There is active debate or serious implications around merging this PR
Problem
Within the internals of the transform propagation systems, we rely on hierarchies being well-formed (via #4197) for soundness, and panic if they are not in this line. This was added in #4775.
This is why we haven't added simple constructors or mutable access to
Parent
orChildren
(likeClone
orCopy
), like in #15574. If we can ever swap or set the value ofParent
orChildren
directly, it becomes very easy to break the hierarchy. Unfortunately, this isn't the only way to get that problem.Path 1: get mutable access to two different components via Query::get_many_mut or the like, and then
mem_swap
them.Path 2: remove
Parent
/Children
from an entity via a method onWorld
that returns the removed valuePotential solutions
Parent
+Children
hierarchy code simpler and more robust #12235 in an airtight way.bevy_transform
fully safe and eat the performance hit and correctness problems if people break their hierarchy by mistake.I prefer 2, and would be opposed to both 3 and 4.
Additional context
Because this is actually guarded against by an assert, I think that merging #15574's successor is actually fine (cc @atornity, sorry).
The text was updated successfully, but these errors were encountered: