bevy/crates/bevy_scene/src
Carter Anderson d8fa57bd7b
Switch ChildOf back to tuple struct (#18672)
# Objective

In #17905 we swapped to a named field on `ChildOf` to help resolve
variable naming ambiguity of child vs parent (ex: `child_of.parent`
clearly reads as "I am accessing the parent of the child_of
relationship", whereas `child_of.0` is less clear).

Unfortunately this has the side effect of making initialization less
ideal. `ChildOf { parent }` reads just as well as `ChildOf(parent)`, but
`ChildOf { parent: root }` doesn't read nearly as well as
`ChildOf(root)`.

## Solution

Move back to `ChildOf(pub Entity)` but add a `child_of.parent()`
function and use it for all accesses. The downside here is that users
are no longer "forced" to access the parent field with `parent`
nomenclature, but I think this strikes the right balance.

Take a look at the diff. I think the results provide strong evidence for
this change. Initialization has the benefit of reading much better _and_
of taking up significantly less space, as many lines go from 3 to 1, and
we're cutting out a bunch of syntax in some cases.

Sadly I do think this should land in 0.16 as the cost of doing this
_after_ the relationships migration is high.
2025-04-02 00:10:10 +00:00
..
components.rs bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
dynamic_scene_builder.rs FilteredResource returns a Result instead of a simple Option (#18265) 2025-03-17 18:54:13 +00:00
dynamic_scene.rs Switch ChildOf back to tuple struct (#18672) 2025-04-02 00:10:10 +00:00
lib.rs Properly gate imports in bevy_scene (#18482) 2025-03-22 12:22:20 +00:00
reflect_utils.rs bevy_reflect: Deprecate PartialReflect::clone_value (#18284) 2025-03-14 19:33:57 +00:00
scene_filter.rs Move hashbrown and foldhash out of bevy_utils (#17460) 2025-01-23 16:46:08 +00:00
scene_loader.rs Properly gate imports in bevy_scene (#18482) 2025-03-22 12:22:20 +00:00
scene_spawner.rs Switch ChildOf back to tuple struct (#18672) 2025-04-02 00:10:10 +00:00
scene.rs reexport entity set collections in entity module (#18413) 2025-03-30 03:51:14 +00:00
serde.rs reexport entity set collections in entity module (#18413) 2025-03-30 03:51:14 +00:00