-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Image Node Rotation #19340
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
base: main
Are you sure you want to change the base?
Image Node Rotation #19340
Conversation
The generated |
.map(|pos| (*transform * (pos * rect_size).extend(1.)).xyz()); | ||
let positions = QUAD_VERTEX_POSITIONS.map(|pos| { | ||
(*transform | ||
* Mat4::from_rotation_z(*rotation) |
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.
Should the rotation be flipped in flip_y
is true?
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 misses what I was trying to do with #6688 and #9341 (to be fair part of the reason I gave up on those mostly because a lot of the reviewers misunderstood it too). We can already rotate UI content using Transform::from_rotation(Quat::from_rotation_z(angle))
.
The problem though is that after rotation the content no longer fits inside the node's bounds. Those two PR's also recomputed the node's content size so the content would still fit inside the layout.
The main objections to those PRs were that:
- They didn't support arbitrary rotations, only right angles.
- The API was confusing using unfamiliar terms from group theory.
I don't disagree with them (the other reason I didn't update those PRs), but the UI renderer currently only supports clipping axis-aligned elements atm and you get confusing visual artifacts with clipping and rotation otherwise and I felt that support for axis-aligned transformations was better than nothing.
Maybe it's okay to support arbitrary rotations though and fix clipping later.
To be useful this needs to update the content sizes and image extraction would need to use the size of the image and not the size of the node.
Probably one of two things:
|
IIRC I did on the leaf... |
IIRC both of those PRs rotated the image by swapping around the UV coords which avoids any problems with clipping but only supports 90 degree rotations. I did implement clipping of rotated elements for a bevy 0.13 fork for work but the implementation was a bit limited and slow so I didn't upstream it. I've got an improved very WIP version that might be ready for 0.17. |
Objective
Adopt #6688
Allow rotation of
ImageNode
sSolution
Replace
ImageNode::flip_x
forrotation
,ImageNode::flip_y
remains intactTesting
testbed_full_ui
,ui_texture_slice_flip_and_tile
and newimage_node_rotation
examplesShowcase
Deliberate Rendering change
There have been changed to the
testbed_full_iu
exampleTODO