Add curve 'Smooth Curve' button to Path3D and Path2D to automatically smooth Paths in the editor#116392
Add curve 'Smooth Curve' button to Path3D and Path2D to automatically smooth Paths in the editor#116392Christakou wants to merge 43 commits into
Conversation
…ints to avoid kinks
|
Since similar functionality already exists in BezierTrackEditor, I assume it would be better to unify the terms to Auto Tangent. |
When you say unify the terms, do you mean just change the nomenclature from 'Smooth Points' to 'Auto Tangent' or something similar? @TokageItLab |
|
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. |
|
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 |
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. |
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? |
|
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. |
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 |
|
Changed all the nomenclature to 'Auto Tangent' , I believe it should be ready for review now Recording.2026-02-21.160845.mp4 |
|
Finally got some time to work on this again @TokageItLab I've implemented your suggestions and refactored the code appropriately.
Hope this satisfies your concerns I believe we should be good to go now :) |
| 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); |
There was a problem hiding this comment.
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.
| Button *curve_edit = nullptr; | ||
| Button *curve_edit_curve = nullptr; | ||
| Button *curve_auto_tangent_toggle = nullptr; | ||
| VSeparator *v_separator = nullptr; |
There was a problem hiding this comment.
The v_separator can be a local variable.
| 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); |
There was a problem hiding this comment.
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).
Co-authored-by: Tomasz Chabora <kobewi4e@gmail.com>
Co-authored-by: Tomasz Chabora <kobewi4e@gmail.com>
Co-authored-by: Tomasz Chabora <kobewi4e@gmail.com>

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