From 8458ba0aef5372958008076746e82a961561db1e Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Sun, 8 Nov 2020 22:16:26 -0500 Subject: [PATCH] Proposal 1246: Make Path3D handles more visible. Resolves godotengine/godot-proposals#1246. It is difficult to tell the difference between the handles for adjusting curves and the points themselves when looking at a Path gizmo. This re-uses the icons used for Path2D. Unlike Path2D, this does not use a different icon for smooth vs sharp points, as using a potentially different material for each point would prevent batching the points in add_handles (and adding them out-of-order messes up other logic based on handle indices). This includes a public API change to allow specifying a texture for a handle material. This allows spatial gizmo plugins to customize the way a handle is rendered, if desired, but does not break existing behavior (as providing no texture uses the default). The path handle icons were resized as well. 16x16 is the standard icon size. These icons were 10x10 rather than 16x16, and appeared rather small in the editor. To resize, I: - Opened the original in Inkscape - Resized the document to 16x16 - Opened the transform dialog - Scaled by 160% proportionally - Used Align/Distribute to center on the page - Saved the document - Cleaned with `svgcleaner --multipass` --- doc/classes/EditorNode3DGizmoPlugin.xml | 3 +++ editor/icons/EditorCurveHandle.svg | 2 +- editor/icons/EditorPathSharpHandle.svg | 2 +- editor/icons/EditorPathSmoothHandle.svg | 2 +- editor/plugins/node_3d_editor_plugin.cpp | 6 +++--- editor/plugins/node_3d_editor_plugin.h | 2 +- editor/plugins/path_3d_editor_plugin.cpp | 6 ++++-- 7 files changed, 14 insertions(+), 9 deletions(-) diff --git a/doc/classes/EditorNode3DGizmoPlugin.xml b/doc/classes/EditorNode3DGizmoPlugin.xml index 4dea1bb645e..adaaed4f1c0 100644 --- a/doc/classes/EditorNode3DGizmoPlugin.xml +++ b/doc/classes/EditorNode3DGizmoPlugin.xml @@ -59,8 +59,11 @@ + + Creates a handle material with its variants (selected and/or editable) and adds them to the internal material list. They can then be accessed with [method get_material] and used in [method EditorNode3DGizmo.add_handles]. Should not be overridden. + You can optionally provide a texture to use instead of the default icon. diff --git a/editor/icons/EditorCurveHandle.svg b/editor/icons/EditorCurveHandle.svg index ea69f4e4ccc..e0f32568074 100644 --- a/editor/icons/EditorCurveHandle.svg +++ b/editor/icons/EditorCurveHandle.svg @@ -1 +1 @@ - + diff --git a/editor/icons/EditorPathSharpHandle.svg b/editor/icons/EditorPathSharpHandle.svg index 328dc04677d..5166930cca2 100644 --- a/editor/icons/EditorPathSharpHandle.svg +++ b/editor/icons/EditorPathSharpHandle.svg @@ -1 +1 @@ - + diff --git a/editor/icons/EditorPathSmoothHandle.svg b/editor/icons/EditorPathSmoothHandle.svg index b498345d5a2..2ab4f3a96ac 100644 --- a/editor/icons/EditorPathSmoothHandle.svg +++ b/editor/icons/EditorPathSmoothHandle.svg @@ -1 +1 @@ - + diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index cc26caa5a35..2bc4e4fbb05 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -6718,12 +6718,12 @@ void EditorNode3DGizmoPlugin::create_icon_material(const String &p_name, const R materials[p_name] = icons; } -void EditorNode3DGizmoPlugin::create_handle_material(const String &p_name, bool p_billboard) { +void EditorNode3DGizmoPlugin::create_handle_material(const String &p_name, bool p_billboard, const Ref &p_icon) { Ref handle_material = Ref(memnew(StandardMaterial3D)); handle_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); handle_material->set_flag(StandardMaterial3D::FLAG_USE_POINT_SIZE, true); - Ref handle_t = Node3DEditor::get_singleton()->get_theme_icon("Editor3DHandle", "EditorIcons"); + Ref handle_t = p_icon != nullptr ? p_icon : Node3DEditor::get_singleton()->get_theme_icon("Editor3DHandle", "EditorIcons"); handle_material->set_point_size(handle_t->get_width()); handle_material->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, handle_t); handle_material->set_albedo(Color(1, 1, 1)); @@ -6807,7 +6807,7 @@ void EditorNode3DGizmoPlugin::_bind_methods() { ClassDB::bind_method(D_METHOD("create_material", "name", "color", "billboard", "on_top", "use_vertex_color"), &EditorNode3DGizmoPlugin::create_material, DEFVAL(false), DEFVAL(false), DEFVAL(false)); ClassDB::bind_method(D_METHOD("create_icon_material", "name", "texture", "on_top", "color"), &EditorNode3DGizmoPlugin::create_icon_material, DEFVAL(false), DEFVAL(Color(1, 1, 1, 1))); - ClassDB::bind_method(D_METHOD("create_handle_material", "name", "billboard"), &EditorNode3DGizmoPlugin::create_handle_material, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("create_handle_material", "name", "billboard", "texture"), &EditorNode3DGizmoPlugin::create_handle_material, DEFVAL(false), DEFVAL(Variant())); ClassDB::bind_method(D_METHOD("add_material", "name", "material"), &EditorNode3DGizmoPlugin::add_material); ClassDB::bind_method(D_METHOD("get_material", "name", "gizmo"), &EditorNode3DGizmoPlugin::get_material); //, DEFVAL(Ref())); diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h index e4a384449bd..d0723904ae6 100644 --- a/editor/plugins/node_3d_editor_plugin.h +++ b/editor/plugins/node_3d_editor_plugin.h @@ -864,7 +864,7 @@ protected: public: void create_material(const String &p_name, const Color &p_color, bool p_billboard = false, bool p_on_top = false, bool p_use_vertex_color = false); void create_icon_material(const String &p_name, const Ref &p_texture, bool p_on_top = false, const Color &p_albedo = Color(1, 1, 1, 1)); - void create_handle_material(const String &p_name, bool p_billboard = false); + void create_handle_material(const String &p_name, bool p_billboard = false, const Ref &p_texture = nullptr); void add_material(const String &p_name, Ref p_material); Ref get_material(const String &p_name, const Ref &p_gizmo = Ref()); diff --git a/editor/plugins/path_3d_editor_plugin.cpp b/editor/plugins/path_3d_editor_plugin.cpp index f53130c24d5..280f6fafd8a 100644 --- a/editor/plugins/path_3d_editor_plugin.cpp +++ b/editor/plugins/path_3d_editor_plugin.cpp @@ -224,6 +224,7 @@ void Path3DGizmo::redraw() { Ref path_material = gizmo_plugin->get_material("path_material", this); Ref path_thin_material = gizmo_plugin->get_material("path_thin_material", this); Ref handles_material = gizmo_plugin->get_material("handles"); + Ref sec_handles_material = gizmo_plugin->get_material("sec_handles"); Ref c = path->get_curve(); if (c.is_null()) { @@ -281,7 +282,7 @@ void Path3DGizmo::redraw() { add_handles(handles, handles_material); } if (sec_handles.size()) { - add_handles(sec_handles, handles_material, false, true); + add_handles(sec_handles, sec_handles_material, false, true); } } } @@ -641,5 +642,6 @@ Path3DGizmoPlugin::Path3DGizmoPlugin() { Color path_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/path", Color(0.5, 0.5, 1.0, 0.8)); create_material("path_material", path_color); create_material("path_thin_material", Color(0.5, 0.5, 0.5)); - create_handle_material("handles"); + create_handle_material("handles", false, Node3DEditor::get_singleton()->get_theme_icon("EditorPathSmoothHandle", "EditorIcons")); + create_handle_material("sec_handles", false, Node3DEditor::get_singleton()->get_theme_icon("EditorCurveHandle", "EditorIcons")); }