Skip to content
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

Make hierarchy semi-mutable #6012

Closed
Shatur opened this issue Sep 18, 2022 · 4 comments
Closed

Make hierarchy semi-mutable #6012

Shatur opened this issue Sep 18, 2022 · 4 comments
Labels
A-Hierarchy Parent-child entity hierarchies C-Usability A targeted quality-of-life change that makes Bevy easier to use X-Controversial There is active debate or serious implications around merging this PR

Comments

@Shatur
Copy link
Contributor

Shatur commented Sep 18, 2022

What problem does this solve or what need does it fill?

After proposal bevyengine/rfcs#53 and PR #4197 hierarchy became managable through commands. While this makes usage less error prone, it introduces several inconveniences. For example, when I want to store a scene, I have to store redundantly Children and Parent components, otherwise my scene will be broken. Same for replication over the network - I had to introduce an additional component (I called it SyncParent) that, when changed, pushes children through commands. But my workaround also not perfect because of one frame delay.

What solution would you like?

What if we do something similar to Transform and GlobalTransform? I.e. let user update Parent and the change will be propagated to Children.

@Shatur Shatur added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Sep 18, 2022
@BoxyUwU
Copy link
Member

BoxyUwU commented Sep 19, 2022

The point of the rfc is that the hierarchy should never be in an invalid state. Allowing users to mutate Parent and then it getting updated some time later by a system violates that.

@Shatur
Copy link
Contributor Author

Shatur commented Sep 19, 2022

Hmm... I understand why this might be a problem.
But current solution, unfortunately, leads to the problems described above. It's not just extra bytes in the scene/network transmission. Usually when users save a scene, they don't save all entities, some of them need to be filtered out (like 3D models). And Children could reference filtered entities which will lead to a scene loading error. And we can't mutate this component.

My workaround is to create a custom Parent component that will sync the hierarchy on insertion. So this is why I basically suggested to make Parent mutable and update the hierarchy on its change. This will solve the filtering issue and allow to store only Parent component in scenes. I.e. Parent will be like Transform and Children like GlobalTransform.

@alice-i-cecile alice-i-cecile added C-Usability A targeted quality-of-life change that makes Bevy easier to use A-Hierarchy Parent-child entity hierarchies X-Controversial There is active debate or serious implications around merging this PR and removed C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Sep 19, 2022
@mockersf
Copy link
Member

mockersf commented Sep 19, 2022

Unlike Transform/GlobalTransform, Parent/Children are not on the same entities, and that can create issues if they are not updated in sync.

For example:

  • spawn entity 1
  • spawn entity 2
  • set 1 as parent of 2
  • despawn recursively 1

2 hasn't been despawned as recursion uses the Children component

@Shatur
Copy link
Contributor Author

Shatur commented Sep 19, 2022

2 hasn't been despawned as recursion uses the Children component

Yes, this is an issue. I totally understand why Children and Parent are immutable. But just introduces a different inconveniences... Probably this should be solved by something like #4141. Clothing this one since the idea isn't good.

@Shatur Shatur closed this as completed Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Hierarchy Parent-child entity hierarchies C-Usability A targeted quality-of-life change that makes Bevy easier to use X-Controversial There is active debate or serious implications around merging this PR
Projects
None yet
Development

No branches or pull requests

4 participants