-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
GlobalTransform Rework #5125
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
GlobalTransform Rework #5125
Conversation
This might be in conflict with #4379. |
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 haven't fully read through the exact changes, but there's still the std::mem::swap
loophole of mutating GlobalTransform
. Otherwise this seems to be a shut case on preventing users from arbitrarily changing the transforms of everything.
@james7132 The objective is mainly to remove redundancy and to avoid accidental misuse of But maybe we do want to allow the users to edit the |
Initial thoughts:
|
I find this strange, as the local Edit: If changing the
Maybe it's too soon for that |
This change requires that |
My preference is for #4379 over this PR at this point :) |
This MR only removes code duplication and confusion on the two transform types. |
The PR converts Doing this is the opposite of what I'd like to see, which is using types to avoid confusing different transforms, for example |
I convert to the inner type so that extraction stages no longer store a This MR only does this:
I don't think making I'm closing this for now. I don't want this PR to shift focus from #4379 |
Objective
Currently,
GlobalTransform
andTransform
are absolutely identical, with duplicate fields, duplicate methods and constructors.Removing the redundancy and making
Transform
the internal value ofGlobalTransform
would remove the duplicate code and restrictGlobalTransform
to be a hierarchy component.Solution
GlobalTransform
is now a tuple struct with an innerTransform
value. It implementsDeref
towars its inner type allowing the use for the entireTransform
API.The inner type is not public, meaning that only
bevy_transform
can edit it. Enforcing the tacit no touch rule on that component.Notes
GlobalTransform
from every bundle and add it to entities through a system going throughAdded<Transform>
artifacts.global_vs_local_transform
example can no longer work so I removed it (See Remove global vs local translation example #5139 )