-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Transform hierarchy split #2789
Transform hierarchy split #2789
Conversation
What do I do about the failing CI check? As far as I can tell, the failure isn't my code's fault. |
Carts response from another PR:
|
Thanks! |
TBH,
This doesn't surprise me; our integration testing is very weak right now. See #1057 for some of the challenges there.
This is a sensible choice; better to keep the changes small.
Looks solid, thanks! |
@@ -0,0 +1,3 @@ | |||
# Bevy Hierarchy | |||
|
|||
Provides the ability to work with a parent-child hierarchy of entities. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be expanded somewhat to describe how it propagates transforms down the tree.
@@ -1,3 +1,5 @@ | |||
# Bevy Transform | |||
|
|||
This crate is largely a 1:1 port from [legion_transform](https://github.com/AThilenius/legion_transform) (ecs: legion, math: nalgebra) to bevy (ecs: bevy_ecs, math: glam) | |||
This crate was largely a 1:1 port from [legion_transform](https://github.com/AThilenius/legion_transform) (ecs: legion, math: nalgebra) to bevy (ecs: bevy_ecs, math: glam) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this line is just fully obsolete at this point; we've changed the data structures around since then.
@@ -191,3 +192,104 @@ mod test { | |||
); | |||
} | |||
} | |||
|
|||
#[cfg(test)] | |||
mod test2 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have a more descriptive name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was moved from another file, where it was just named "test". I honestly didn't check what it's actually testing!
@@ -16,6 +16,7 @@ crates=( | |||
bevy_audio | |||
bevy_core | |||
bevy_diagnostic | |||
bevy_hierarchy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is interesting; I wonder if this would publish a not-very-useful standalone bevy_hierarchy
0.5...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how this works; I was just following the advice in CONTRIBUTING.md
. That advice told me to add it, but I don't know if I did something wrong.
But that would force Also, crates like |
This seems like the correct behavior: for more generalized parent-child-like behavior, we need something along the lines of relations to allow users to create their own hierarchies (or other graphs) without risking mangling. Reusing the |
Have you seen the comment where I explained my motivation for this pull? I wouldn't call this "trying to use them outside of a transform-updating context". But even so, this comment is starting to make me rethink whether I want to make this pull request at all! When I wrote the issue and pull, I was working under the belief that transform and hierarchy were mostly independent concerns. They'd interact, but not that strongly. But you're saying that they should be much more closely tied than that. And if that's true, this pull doesn't make much sense. I guess what I'd like to know is if Bevy's other main contributors agree with your stance here. If so, I'll probably cancel the pull request.
A possibility that occurred to me: What if the types were parameterized, like Even if this is a good idea, though, it should probably be a separate issue. |
Aha, thanks for calling this out: that's an interesting use case! The most elegant solution for your design would be something like a
FWIW, I would like them to be much more independent than they are, which is why I'm generally supportive of this split. But without a way to construct variants of the hierarchy (so then we can keep the hierarchy maintenance and commands bits without the transform propagation) we're kind of stuck. To me, this is effectively ground-work for that decoupling.
Yep, this is a solid idea! This is the fundamental driver behind the relations project; where we're attempting to explore how to represent these parametrically typed graphs within the ECS :) Trees are an important special case of this. |
So maybe I should close this, and open a general "Support user-defined Transform types" issue?
I have to admit, I don't really understand your reasoning here. But since you still care about this split, and I don't anymore, is there some way for me to "give you" this pull request? |
That sounds reasonable. I think a Discussion or RFC is probably more appropriate at this stage, as #1680 already exists and we either need to chat about strategies to get there or to present a concrete design.
I think the split can probably wait, so I'll just close this out for now. We can revive it by forking your branch if it's relevant in the future. |
# Objective - Hierarchy tools are not just used for `Transform`: they are also used for scenes. - In the future there's interest in using them for other features, such as visiibility inheritance. - The fact that these tools are found in `bevy_transform` causes a great deal of user and developer confusion - Fixes #2758. ## Solution - Split `bevy_transform` into two! - Make everything work again. Note that this is a very tightly scoped PR: I *know* there are code quality and docs issues that existed in bevy_transform that I've just moved around. We should fix those in a seperate PR and try to merge this ASAP to reduce the bitrot involved in splitting an entire crate. ## Frustrations The API around `GlobalTransform` is a mess: we have massive code and docs duplication, no link between the two types and no clear way to extend this to other forms of inheritance. In the medium-term, I feel pretty strongly that `GlobalTransform` should be replaced by something like `Inherited<Transform>`, which lives in `bevy_hierarchy`: - avoids code duplication - makes the inheritance pattern extensible - links the types at the type-level - allows us to remove all references to inheritance from `bevy_transform`, making it more useful as a standalone crate and cleaning up its docs ## Additional context - double-blessed by @cart in #4141 (comment) and #2758 (comment) - preparation for more advanced / cleaner hierarchy tools: go read bevyengine/rfcs#53 ! - originally attempted by @finegeometer in #2789. It was a great idea, just needed more discussion! Co-authored-by: Carter Anderson <mcanders1@gmail.com>
# Objective - Hierarchy tools are not just used for `Transform`: they are also used for scenes. - In the future there's interest in using them for other features, such as visiibility inheritance. - The fact that these tools are found in `bevy_transform` causes a great deal of user and developer confusion - Fixes bevyengine#2758. ## Solution - Split `bevy_transform` into two! - Make everything work again. Note that this is a very tightly scoped PR: I *know* there are code quality and docs issues that existed in bevy_transform that I've just moved around. We should fix those in a seperate PR and try to merge this ASAP to reduce the bitrot involved in splitting an entire crate. ## Frustrations The API around `GlobalTransform` is a mess: we have massive code and docs duplication, no link between the two types and no clear way to extend this to other forms of inheritance. In the medium-term, I feel pretty strongly that `GlobalTransform` should be replaced by something like `Inherited<Transform>`, which lives in `bevy_hierarchy`: - avoids code duplication - makes the inheritance pattern extensible - links the types at the type-level - allows us to remove all references to inheritance from `bevy_transform`, making it more useful as a standalone crate and cleaning up its docs ## Additional context - double-blessed by @cart in bevyengine#4141 (comment) and bevyengine#2758 (comment) - preparation for more advanced / cleaner hierarchy tools: go read bevyengine/rfcs#53 ! - originally attempted by @finegeometer in bevyengine#2789. It was a great idea, just needed more discussion! Co-authored-by: Carter Anderson <mcanders1@gmail.com>
# Objective - Hierarchy tools are not just used for `Transform`: they are also used for scenes. - In the future there's interest in using them for other features, such as visiibility inheritance. - The fact that these tools are found in `bevy_transform` causes a great deal of user and developer confusion - Fixes bevyengine#2758. ## Solution - Split `bevy_transform` into two! - Make everything work again. Note that this is a very tightly scoped PR: I *know* there are code quality and docs issues that existed in bevy_transform that I've just moved around. We should fix those in a seperate PR and try to merge this ASAP to reduce the bitrot involved in splitting an entire crate. ## Frustrations The API around `GlobalTransform` is a mess: we have massive code and docs duplication, no link between the two types and no clear way to extend this to other forms of inheritance. In the medium-term, I feel pretty strongly that `GlobalTransform` should be replaced by something like `Inherited<Transform>`, which lives in `bevy_hierarchy`: - avoids code duplication - makes the inheritance pattern extensible - links the types at the type-level - allows us to remove all references to inheritance from `bevy_transform`, making it more useful as a standalone crate and cleaning up its docs ## Additional context - double-blessed by @cart in bevyengine#4141 (comment) and bevyengine#2758 (comment) - preparation for more advanced / cleaner hierarchy tools: go read bevyengine/rfcs#53 ! - originally attempted by @finegeometer in bevyengine#2789. It was a great idea, just needed more discussion! Co-authored-by: Carter Anderson <mcanders1@gmail.com>
Fixes #2758.
As well as the changes described in the original issue, I split out a
HierarchyPlugin
fromTransformPlugin
. I had missed that detail when I first wrote the issue.Notes
I don't like that
bevy_transform
depends onbevy_hierarchy
, but the latter is necessary fortransform_propagate_system
.It would be nice if
transform_propagate_system
could somehow default to just settingGlobalTransform = Transform
in the case where there is no hierarchy.When I forgot to make
HierarchyPlugin
a default plugin, there were no test or CI failures (as tested by the instructions inCONTRIBUTING.md
).When I split the crate, I kept the original module structure. I didn't check whether it makes sense to move modules around as a result of the split.
This is my first pull request — did I do anything wrong?