Skip to content

Add curve 'Smooth Curve' button to Path3D and Path2D to automatically smooth Paths in the editor#116392

Open
Christakou wants to merge 43 commits into
godotengine:masterfrom
Christakou:add_curve_smooth_button
Open

Add curve 'Smooth Curve' button to Path3D and Path2D to automatically smooth Paths in the editor#116392
Christakou wants to merge 43 commits into
godotengine:masterfrom
Christakou:add_curve_smooth_button

Conversation

@Christakou
Copy link
Copy Markdown

@Christakou Christakou commented Feb 17, 2026

PR following from this proposal

Implements a tool on the Path3D and Path2D editor tool bar to automatically smooth the Curve using the Catmull-Rom inspired technique

Rearranges the layout of the buttons and places some of them under the options menu (Clear all points and Apply Auto Tangent to All points)

Screen.Recording.2026-06-01.at.14.53.51.mov

@TokageItLab
Copy link
Copy Markdown
Member

Since similar functionality already exists in BezierTrackEditor, I assume it would be better to unify the terms to Auto Tangent.
#64647

@Christakou
Copy link
Copy Markdown
Author

Christakou commented Feb 18, 2026

Since similar functionality already exists in BezierTrackEditor, I assume it would be better to unify the terms to Auto Tangent. #64647

When you say unify the terms, do you mean just change the nomenclature from 'Smooth Points' to 'Auto Tangent' or something similar? @TokageItLab

@SamInTheShell
Copy link
Copy Markdown

Path3D is a pretty good node to use for reference to build some shapes, I could see this being useful to quickly get curves added to the entire path when you know you need them.

@Christakou
Copy link
Copy Markdown
Author

Implemented the equivalent functionality for Path2D also, with the caveat that currently the 'closed' curves in Path3D behave a bit differently to Path3D so I might tweak the algorithm to handle the way Path2D closed curves work

@TokageItLab
Copy link
Copy Markdown
Member

TokageItLab commented Feb 19, 2026

When you say unify the terms, do you mean just change the nomenclature from 'Smooth Points' to 'Auto Tangent' or something similar? @TokageItLab

Exactly.

However, since what you're implementing isn't a toggle function but rather an option that wouldn't be triggered very frequently, I believe it should be called from the "Options" dropdown menu.

@Christakou
Copy link
Copy Markdown
Author

However, since what you're implementing isn't a toggle function but rather an option that wouldn't be triggered very frequently, I believe it should be called from the "Options" dropdown menu.

It's not a toggle function but it's a button that can be pressed multiple times once you've modified the curve, so I think it would be nice to not have it hidden away behind options, as I found I end up pressing it quite often when defining my curves.

Regarding the name I think auto-tangent is a bit too opaque a name, and I think since it's operating on a totally different node and underlying object (curve3d and curve2d) , I don't see the need to keep it consistent with what is implemented for BezierTrackEditor

I do think 'smooth points' is a bit of a misnomer, how would you feel about having it named 'Smooth Curve' and keep it as a button on the hotbar?

@TokageItLab
Copy link
Copy Markdown
Member

TokageItLab commented Feb 21, 2026

There's no need for it to be a button when it might be pressed multiple times. You can use a shortcut instead. However, considering that other options like CloseCurve and ClearPoints are similarly one-shot options, having it as a button might be “temporarily” acceptable. But in any case, there are too many buttons in CurveEditorTools, so I think it should be organized into a pull-down menu in a later follow-up PR.

“Smooth Curve” is odd since the path is a polygon unless you extend the curve handles, situations arise where you apply it to something that can't be called a curve.

Also, if pressing multiple times provides an effect where the corner radius progressively increases with each press, similar to a blur, then using the term “smoothing” is somewhat appropriate. However, when providing a single deterministic result from the current point, "smoothing" is never a more appropriate term than "Auto Tangent".

Especially the case for users who have already obtained a smooth curve, applying this option could result in overwriting and potentially making it less smooth than before. Therefore, it is better to indicate that this is merely an automatic calculation rather than applying smoothing to the current state.

@Christakou
Copy link
Copy Markdown
Author

Christakou commented Feb 21, 2026

There's no need for it to be a button when it might be pressed multiple times. You can use a shortcut instead. However, considering that other options like CloseCurve and ClearPoints are similarly one-shot options, having it as a button might be “temporarily” acceptable. But in any case, there are too many buttons in CurveEditorTools, so I think it should be organized into a pull-down menu in a later follow-up PR.

  • Okay that sounds good to me, i'll make it a button for now and maybe we can work together in future to organize things better in this sense

“Smooth Curve” is odd since the path is a polygon unless you extend the curve handles, situations arise where you apply it to something that can't be called a curve.

  • I see what you mean partially, but as soon as you press the button, it stops being a polygon and becomes a smooth curve, which in my view makes a lot of sense from a users perspective

But I see your point and I'm happy to go with auto-tangent, although I feel it's a bit less intuitive in some cases

@Christakou
Copy link
Copy Markdown
Author

Christakou commented Feb 21, 2026

Changed all the nomenclature to 'Auto Tangent' ,
corrected the behaviour for closed curves in Path2D
and added a reasonable attempt at an icon

I believe it should be ready for review now

Recording.2026-02-21.160845.mp4

@Christakou Christakou marked this pull request as ready for review February 21, 2026 16:09
@Christakou
Copy link
Copy Markdown
Author

Christakou commented May 17, 2026

Finally got some time to work on this again

@TokageItLab I've implemented your suggestions and refactored the code appropriately.

  • Clear all points and 'Apply Autotangent to All Points' are now in the dropdown.
  • The autotangent toggle works in the same way as the delete toggle.
  • Works for open and closed curves in 2D and 3D respecting their different representations of open/closed curves
  • If you have a point selection in 3D that is respected when applying autotangent to all points
  • Users can specify the torsion parameter to fine tune and control the tool
  • All the undo/redo actions work as expected

Hope this satisfies your concerns I believe we should be good to go now :)

@KoBeWi
Copy link
Copy Markdown
Member

KoBeWi commented May 26, 2026

I think the auto-tangent mode should be before the Close Curve button.

image

And you could put a separator between the two, to separate toggleable mode buttons from actions.

If you have a point selection in 3D that is respected when applying autotangent to all points

It would be nice if the menu option conveyed that, either by updating its text depending on selection, or just being renamed to "Apply Auto Tangent to All/Selected Points".

Other than that it seems fine, based on the comments before. Although the new menu options are missing shortcuts.

Comment thread editor/scene/2d/path_2d_editor_plugin.cpp
Comment thread editor/scene/2d/path_2d_editor_plugin.h Outdated
Comment thread editor/scene/2d/path_2d_editor_plugin.cpp Outdated
Comment thread editor/scene/3d/path_3d_editor_plugin.cpp Outdated
Comment thread editor/scene/3d/path_3d_editor_plugin.h Outdated
Comment thread editor/scene/2d/path_2d_editor_plugin.h Outdated
Comment thread editor/scene/2d/path_2d_editor_plugin.cpp
Comment thread editor/scene/2d/path_2d_editor_plugin.h Outdated
Comment thread editor/scene/2d/path_2d_editor_plugin.cpp
auto_tangent_torsion->set_step(0.05);
auto_tangent_torsion->set_h_size_flags(Control::SIZE_EXPAND);
auto_tangent_torsion->set_custom_minimum_size(Size2(65 * EDSCALE, 0));
auto_tangent_torsion->set_focus_mode(Control::FOCUS_ACCESSIBILITY);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to produce warnings

  WARNING: C:\godot_source\scene/gui/control.cpp:3000 - This control can grab focus only when screen reader is active. Use set_focus_mode() and set_focus_behavior_recursive() to allow a control to get focus. Use get_tree().is_accessibility_enabled() to check screen-reader state.

Comment thread editor/scene/2d/path_2d_editor_plugin.cpp Outdated
Button *curve_edit = nullptr;
Button *curve_edit_curve = nullptr;
Button *curve_auto_tangent_toggle = nullptr;
VSeparator *v_separator = nullptr;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The v_separator can be a local variable.

Comment thread editor/scene/2d/path_2d_editor_plugin.cpp Outdated
menu->add_check_item(TTR("Mirror Handle Lengths"));
menu->set_item_checked(HANDLE_OPTION_LENGTH, mirror_handle_length);
menu->add_separator();
menu->add_shortcut(ED_SHORTCUT("path_editor/apply_auto_tangent_to_all_points", TTRC("Apply Auto Tangent to All Points"), KeyModifierMask::CMD_OR_CTRL | Key::T), HANDLE_OPTION_AUTO_TANGENT);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot that this shortcut is supposed to be used in two editors. You can't use ED_SHORTCUT this way, because it defines a shortcut. While it does work, defining a shortcut in multiple places can lead to inconsistency.

You should use ED_GET_SHORTCUT("path_editor/apply_auto_tangent_to_all_points") instead. For now you can leave ED_SHORTCUT in the Path3DEditor, because it's registered first, but this is rather fragile, so it should be moved to a better place eventually (not sure where yet).

Comment thread editor/scene/3d/path_3d_editor_plugin.cpp Outdated
Christakou and others added 3 commits June 2, 2026 10:20
Co-authored-by: Tomasz Chabora <kobewi4e@gmail.com>
Co-authored-by: Tomasz Chabora <kobewi4e@gmail.com>
Co-authored-by: Tomasz Chabora <kobewi4e@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Pending, No consensus

Development

Successfully merging this pull request may close these issues.

8 participants