Skip to content
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 EditorNode3DGizmoPlugin to get initial handle value #5669

Closed
timothyqiu opened this issue Oct 28, 2022 · 2 comments · Fixed by godotengine/godot#71092
Closed

Allow EditorNode3DGizmoPlugin to get initial handle value #5669

timothyqiu opened this issue Oct 28, 2022 · 2 comments · Fixed by godotengine/godot#71092

Comments

@timothyqiu
Copy link
Member

Describe the project you are working on

Playing around with the built-in gizmo plugins.

Describe the problem or limitation you are having in your project

The current EditorNode3DGizmoPlugin workflow is like this:

  • When _set_handle() is called, the plugin updates the Node3D according to the handle value.
  • When _commit_handle() is called:
    • If canceled, the plugin resets the Node3D with the provided initial handle value.
    • If not canceled, the plugin creates an undo-redo entry for the initial & current value.

The initial handle value is fetched by EditorNode3DPlugin when clicking the handle.

Not knowing the initial value makes it hard to switch modes when dragging the handle. For example, when dragging a rectangle CollisionShape2D, it allows you to switch between changing size only and changing both size and position. This is not possible in 3D as you lost the original node translation once dragged.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

With the original value available, properties can be updated in _set_handle() by relative value instead of absolute value.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Provide a way to get the initial handle value.

  • Add a parameter in _set_handle(), or
  • Add a method on EditorNode3DGizmo to provide the initial value, or
  • Add a _prepare_handle() method to let the user record it.

If this enhancement will not be used often, can it be worked around with a few lines of script?

  • Create a custom EditorNode3DGizmo and add a initial_value property.
  • In _set_handle(), check if initial_value is ever set. Save the current handle value when not.
  • In _commit_handle(), clear initial_value.

This is hacky I think because it relies on _commit_handle() always being called, so a "begin" state can be detected.

Is there a reason why this should be core and not an add-on in the asset library?

It needs to modify how 3D gizmo plugin works.

@KoBeWi
Copy link
Member

KoBeWi commented May 15, 2023

godotengine/godot#71092 implements begin_handle_action(), called just when clicking the handle and you can use get_handle_value() to get a reliable initial value. Does this resolve the proposal?

@timothyqiu
Copy link
Member Author

Does this resolve the proposal?

Yes, that solves the problem 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants