-
-
Notifications
You must be signed in to change notification settings - Fork 4k
allow EntityCloner
to move components without Clone
or Reflect
#20065
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
allow EntityCloner
to move components without Clone
or Reflect
#20065
Conversation
@urben1680 requesting your review here :) |
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.
Oh I would love this landing on 0.17, thank you for implementing this. I am still not confident enough myself in these regions of the ECS.
After trying to debug where the It's also tempting to split component moving functionality into a different struct because of how many edge cases there are now, but even if we do that I think it should be done in a different PR. Now, as for cloning data on relationship components: unsurprisingly, it currently works only for the @urben1680 @alice-i-cecile, how should we proceed with this PR at this point? |
In my crate, I want to implement reversible structural changes to entities. For example when component This component tl;dr I have no use case for moving relationship components. It also seems weird that a user has a collection of entities that are not yet related, and relate them by moving the relationship components from an existing "family" instead of doing it "properly" by relating them directly.
I think we want to somehow map the custom relationship target cloning behavior to Maybe we need a |
I feel like the biggest problem with the current implementation right now is that cloning behavior has to work around component hooks, and the existence of With all that in mind, I believe the best course of action for this PR would be to disallow moving relationship components without I will look into moving |
Having extra hooks for these situations sounds like a good idea. There might be other complex hooks out there that are not relationships that make this approach here not work as intended. |
- Fix data not cloning on `RelationshipTarget` - Fix `Relationship` component disappearing when moving with `linked_cloning = true`
Alright, I think this should fix some of the current problems with the implementation of relationship cloning/moving using
Handling all the edge cases resulted in some very messy code, but at least it should behave correctly now. I'd really like to clean it up, but since I don't have a good estimate on how long that will take, I believe fixing known bugs outweighs it for now. |
…omponents-without-clone
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.
The tests with components containing vectors made me think that maybe, in the follow-up PR, we want to prefer bitwise moves over clone moves. It would also be more like what would happen if you manually take
and insert
the components.
If we clone the potentially large allocation in the vector we might needlessly waste performance.
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.
Excellent work: I'm really glad this is possible, and I appreciate the cleanup in terms of tests and docs that you've done while here.
…omponents-without-clone
Objective
Fix #18079
Solution
EntityCloner
can now move components that don't haveClone
orReflect
implementation.ComponentCloneBehavior::Ignore
will not be moved.ComponentCloneBehavior::Custom
will be cloned using their definedComponentCloneFn
and then removed from the source entity to respect theirqueue_deferred
logic.Clone
orReflect
to be movable.EntityCloner
.Testing