-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Add relative position reporting to UI picking #17681
Add relative position reporting to UI picking #17681
Conversation
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
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.
Works fine, added
.observe(|trigger: Trigger<Pointer<Click>>| {
let hit_pos = trigger.event.hit.position.expect("no position");
info!("{}", hit_pos);
});
to the interactable node in the relative_cursor_position
example and the position reported by info!
matches the position reported by the example's position text.
I think not repurposing the normal
field is a good decision as it's potentially confusing.
@bytemunch I think I didn't resolve the merge conflicts quite correctly. Can you take a quick look and ping me once CI is passing again? |
No worries, I think it was a change in how UI nodes now have target cameras, |
Head branch was pushed to by a user without write access
@alice-i-cecile CI ping :) |
|
This seems really confusing with docs |
Good point, I overlooked that! Perhaps docs could say something along the lines of I guess I was thinking solely of my own use-case for having position data in relative local space, and knowing that the pointer position is accessible elsewhere in an observer trigger opted for this space. |
This would be ideal :) |
Objective
Add position reporting to
HitData
sent from the UI picking backend.Solution
Add the computed normalized relative cursor position to
hit_data
alongside theEntity
.The position reported in
HitData
is normalized relative to the node, with(0.,0.,0.)
at the top left and(1., 1., 0.)
in the bottom right. Coordinates are relative to the entire node, not just the visible region.HitData
needs aVec3
so I just extended with 0.0. I considered inserting thedepth
here but thought it would be redundant.I also considered putting the screen space position in the
normal
field ofHitData
, but that would require renaming of the field or a separate data structure.Testing
Tested with mouse on X11 with entities that have
Node
components.Showcase