-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Description
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
or Children
(like Clone
or Copy
), like in #15574. If we can ever swap or set the value of Parent
or Children
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 on World
that returns the removed value
Potential solutions
- Wait for Entity-entity relations 🌈 #3742.
- Implement Use component lifecycle hooks to make
Parent
+Children
hierarchy code simpler and more robust #12235 in an airtight way. - Make
bevy_transform
fully safe and eat the performance hit and correctness problems if people break their hierarchy by mistake. - Add more, niche, high complexity features to absolutely forbid mutable access to some component types. Somehow.
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).