-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Implement numeric blender-style transforms. #58389
Conversation
@@ -2057,6 +2051,7 @@ void Node3DEditorViewport::_sinput(const Ref<InputEvent> &p_event) { | |||
|
|||
if (k->get_keycode() == Key::SPACE) { | |||
if (!k->is_pressed()) { | |||
// TODO: Is this unreachable? |
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 noticed this while trying to add a SPACE keybind. If !k->is_pressed()
, we already return early above, so I don't think it is reachable, or know what it is supposed to do.
update_transform_numeric(); | ||
} else if (code == Key::PERIOD && _edit.numeric_next_decimal == 0) { | ||
_edit.numeric_next_decimal = -1; | ||
} else if (code == Key::SPACE || code == Key::ENTER) { |
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.
Is it better to use exact keycodes or the ui_accept
and ui_select
actions?
Dunno if you've seen this one. Would be awesome to have this. |
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.
Tested locally (without rebasing), it mostly works as expected. This is a feature I'm eager to see, great work so far 🙂
There are two significant issues I noticed on a Linux + AZERTY setup:
- Numpad keys can't be used to enter numbers, regardless of Num Lock status. This also applies to the minus symbol to invert the operation (which works in Blender on my end).
- Number row keys can be entered without pressing Shift (like on QWERTY), while AZERTY normally requires this. This is inconsistent with Blender's behavior on the same setup (tested on Blender 3.5).
- Blender does not allow pressing 6 without Shift to invert the operation though (this maps to - on AZERTY). I think we should support that on AZERTY 🙂
For this PR to be most usable as a daily driver, I think both issues need to be fixed before it's merged.
I switched to using I noticed something odd about scaling. If you scale an object to half size (using either blender-style or normal gizmo operations), the Godot UI says you've scaled it by |
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.
Tested locally, it works better now, but some keys still don't work correctly:
- All numpad keys work, except Numpad Minus which doesn't add a
-
symbol before the transformation. - Only these top row keys work when holding Shift:
2
,6
(inverts transformation while it should insert6
instead),7
,9
,0
. When you don't hold Shift, all these keys work too, which is not expected on AZERTY. The.
symbol on the main keyboard (i.e. not on the numpad) doesn't work either to add a decimal.
Oops! I noticed some numbers not working but just figured my keyboard wasn't set up correctly. I also noticed "-" wouldn't work if you pressed it before any numbers, so I fixed that. |
Ah, conflicts again. I'll try to fix those tonight. |
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.
AZERTY keys now work as expected 🙂
However, I noticed two other issues. I'm not sure if they were by today's changes, I may have started noticing them just now.
- When you press - to reverse the direction, it applies to future transforms as well. This means that if you use
GX-2
then useGY2
, the node will be moved downwards by units because it's actually translating on the Y axis by-2
, not2
. I'd expect it to only affect the current transform operation. - When you press - to reverse the direction, it doesn't display a minus symbol in the rotate text in the bottom-left corner. This does not occur with mouse-induced rotation, or with the translate/scale numeric transforms. This is purely a label issue – it doesn't affect how the rotate numeric transform actually behaves.
Thanks again! I've fixed the labeling and the lingering |
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 works great now! Thanks again for contributing this feature 🙂
e18c4ff
to
b7ea61b
Compare
Thanks for all the careful review! I've applied all the comment suggestions. |
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.
Looks good from a code style perspective (also checked overall of code complexity / architecture). Further feature/implementation assessment still welcome from the editor team.
When you type something and press Escape, the transform operation stops, but gizmos are no longer usable. godot.windows.editor.dev.x86_64_D3niIExq7b.mp4EDIT: |
This allows the user to input numbers during an "instant" (blender style) transform operation to specify exactly how far to transform the object. For example: g2.5xx: Translate 2.5 units along the local x-axis ry-45: Rotate -45 degrees around the y-axis s.25Z: Scale by a factor of .25 on the xy plane Some shared code between the traslate/rotate/scale branches of update_transform was refactored into apply_transform so numeric transforms could reuse it. This removes any "{X,Y,Z}-Axis Transform" messages. These prevented the "Transforming: (x,y,z)" messages from showing, and the latter are more useful, as they tell you the actual units. This also rearranges finish_transform to clear _edit before updating the axis rendering, so an axis doesn't remain highlighted. Co-authored-by: Rémi Verschelde <[email protected]>
Thanks @KoBeWi, I've fixed both of the issues you mentioned. |
b7ea61b
to
d6a83a6
Compare
Thanks! |
For anyone confused on how to test those, the shortcuts Some issues (as of v4.2) and suggestions for this feature:
IMO it would be much more intuitive if some actual text input field was shown during the operation. E.g.: If feature 4 would cause incompatible behavior with current implementation (e.g. pressing |
Implement numeric blender-style transforms.
This allows the user to input numbers during an "instant" (blender
style) transform operation to specify exactly how far to transform the
object. For example:
g2.5xx
: Translate 2.5 units along the local x-axisry-45
: Rotate -45 degrees around the y-axiss.25Z
: Scale by a factor of .25 on the xy planeThis removes any "{X,Y,Z}-Axis Transform" messages. These prevented the
"Transforming: (x,y,z)" messages from showing, and the latter are more
useful, as they tell you the actual units.
This also rearranges
finish_transform
to clear_edit
before updatingthe axis rendering, so an axis doesn't remain highlighted.
This is separated into two commits for ease of review, I'll squash before merging.
09bb986a38b2ffa3ace868f2cc4d2306229b47e2 refactors some common code for reuse.017be8045469e4f1c68c1fe299caa4be1acbf10b implements numeric transforms leveraging that shared code.EDIT: These have now been squashed.