From af604f845e186ca9545bc1adee8ae56539870843 Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 25 Jan 2022 14:47:18 +0100 Subject: [PATCH] Added handle selection types to mdi ed's sidebar, and set up events for them. --- .../addons/mesh_data_resource_editor/MDIEd.gd | 9 ++ .../mesh_data_resource_editor/MDIEd.tscn | 96 +++++++++++++++---- .../mesh_data_resource_editor/MIDGizmo.gd | 20 +++- .../handle_selection_typen_group.tres | 3 + .../mesh_data_resource_editor/plugin.gd | 13 ++- 5 files changed, 119 insertions(+), 22 deletions(-) create mode 100644 game/addons/mesh_data_resource_editor/button_groups/handle_selection_typen_group.tres diff --git a/game/addons/mesh_data_resource_editor/MDIEd.gd b/game/addons/mesh_data_resource_editor/MDIEd.gd index 4ad4fdee..92fdff98 100644 --- a/game/addons/mesh_data_resource_editor/MDIEd.gd +++ b/game/addons/mesh_data_resource_editor/MDIEd.gd @@ -235,3 +235,12 @@ func on_visual_indicator_handle_toggled(on : bool): func _on_select_all_pressed(): _plugin.select_all() + +func onhandle_selection_type_front_toggled(on : bool): + _plugin.handle_selection_type_front() + +func onhandle_selection_type_back_toggled(on : bool): + _plugin.handle_selection_type_back() + +func onhandle_selection_type_all_toggled(on : bool): + _plugin.handle_selection_type_all() diff --git a/game/addons/mesh_data_resource_editor/MDIEd.tscn b/game/addons/mesh_data_resource_editor/MDIEd.tscn index 336bdc11..04d80656 100644 --- a/game/addons/mesh_data_resource_editor/MDIEd.tscn +++ b/game/addons/mesh_data_resource_editor/MDIEd.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=8 format=2] +[gd_scene load_steps=9 format=2] [ext_resource path="res://addons/mesh_data_resource_editor/MDIEd.gd" type="Script" id=1] [ext_resource path="res://addons/mesh_data_resource_editor/button_groups/vertex_position_operation_bg.tres" type="ButtonGroup" id=2] @@ -7,6 +7,7 @@ [ext_resource path="res://addons/mesh_data_resource_editor/button_groups/edit_mode_button_group.tres" type="ButtonGroup" id=5] [ext_resource path="res://addons/mesh_data_resource_editor/uv_editor/UVEditorPopup.gd" type="Script" id=6] [ext_resource path="res://addons/mesh_data_resource_editor/button_groups/pivot_button_group.tres" type="ButtonGroup" id=7] +[ext_resource path="res://addons/mesh_data_resource_editor/button_groups/handle_selection_typen_group.tres" type="ButtonGroup" id=8] [node name="MDIEd" type="PanelContainer"] anchor_right = 1.0 @@ -205,10 +206,62 @@ margin_right = 998.0 margin_bottom = 666.0 size_flags_horizontal = 3 -[node name="HBoxContainer4" type="HBoxContainer" parent="VBoxContainer/ScrollContainer/VBoxContainer2"] +[node name="HBoxContainer6" type="HBoxContainer" parent="VBoxContainer/ScrollContainer/VBoxContainer2"] margin_right = 998.0 margin_bottom = 20.0 +[node name="Label4" type="Label" parent="VBoxContainer/ScrollContainer/VBoxContainer2/HBoxContainer6"] +margin_right = 10.0 +margin_bottom = 20.0 +hint_tooltip = "Handle Selection type." +mouse_filter = 0 +size_flags_vertical = 7 +text = "H" +align = 1 +valign = 1 + +[node name="Front" type="Button" parent="VBoxContainer/ScrollContainer/VBoxContainer2/HBoxContainer6"] +margin_left = 14.0 +margin_right = 339.0 +margin_bottom = 20.0 +rect_min_size = Vector2( 25, 20 ) +hint_tooltip = " +" +size_flags_horizontal = 3 +toggle_mode = true +pressed = true +group = ExtResource( 8 ) +text = "F" + +[node name="Back" type="Button" parent="VBoxContainer/ScrollContainer/VBoxContainer2/HBoxContainer6"] +margin_left = 343.0 +margin_right = 668.0 +margin_bottom = 20.0 +rect_min_size = Vector2( 25, 20 ) +hint_tooltip = "Only select handles that face away +the camera." +size_flags_horizontal = 3 +toggle_mode = true +group = ExtResource( 8 ) +text = "B" + +[node name="All" type="Button" parent="VBoxContainer/ScrollContainer/VBoxContainer2/HBoxContainer6"] +margin_left = 672.0 +margin_right = 998.0 +margin_bottom = 20.0 +rect_min_size = Vector2( 25, 20 ) +hint_tooltip = "Ignore camera facing when selecting handles. +" +size_flags_horizontal = 3 +toggle_mode = true +group = ExtResource( 8 ) +text = "A" + +[node name="HBoxContainer4" type="HBoxContainer" parent="VBoxContainer/ScrollContainer/VBoxContainer2"] +margin_top = 24.0 +margin_right = 998.0 +margin_bottom = 44.0 + [node name="Label4" type="Label" parent="VBoxContainer/ScrollContainer/VBoxContainer2/HBoxContainer4"] margin_right = 8.0 margin_bottom = 20.0 @@ -254,9 +307,9 @@ group = ExtResource( 7 ) text = "w" [node name="HBoxContainer5" type="HBoxContainer" parent="VBoxContainer/ScrollContainer/VBoxContainer2"] -margin_top = 24.0 +margin_top = 48.0 margin_right = 998.0 -margin_bottom = 44.0 +margin_bottom = 68.0 [node name="Label4" type="Label" parent="VBoxContainer/ScrollContainer/VBoxContainer2/HBoxContainer5"] margin_right = 8.0 @@ -302,23 +355,23 @@ pressed = true text = "H" [node name="HSeparator" type="HSeparator" parent="VBoxContainer/ScrollContainer/VBoxContainer2"] -margin_top = 48.0 +margin_top = 72.0 margin_right = 998.0 -margin_bottom = 52.0 +margin_bottom = 76.0 __meta__ = { "_edit_use_anchors_": false } [node name="Select All" type="Button" parent="VBoxContainer/ScrollContainer/VBoxContainer2"] -margin_top = 56.0 +margin_top = 80.0 margin_right = 998.0 -margin_bottom = 76.0 +margin_bottom = 100.0 text = "Select All" [node name="VertexOps" type="VBoxContainer" parent="VBoxContainer/ScrollContainer/VBoxContainer2"] -margin_top = 80.0 +margin_top = 104.0 margin_right = 998.0 -margin_bottom = 184.0 +margin_bottom = 208.0 [node name="OperationsLabel" type="Label" parent="VBoxContainer/ScrollContainer/VBoxContainer2/VertexOps"] margin_right = 998.0 @@ -480,14 +533,14 @@ margin_bottom = 20.0 text = "Delete" [node name="HSeparator4" type="HSeparator" parent="VBoxContainer/ScrollContainer/VBoxContainer2"] -margin_top = 188.0 +margin_top = 212.0 margin_right = 998.0 -margin_bottom = 192.0 +margin_bottom = 216.0 [node name="Operations" type="VBoxContainer" parent="VBoxContainer/ScrollContainer/VBoxContainer2"] -margin_top = 196.0 +margin_top = 220.0 margin_right = 998.0 -margin_bottom = 560.0 +margin_bottom = 584.0 [node name="OperationsLabel" type="Label" parent="VBoxContainer/ScrollContainer/VBoxContainer2/Operations"] margin_right = 998.0 @@ -581,14 +634,14 @@ margin_bottom = 346.0 text = "Unwrap" [node name="HSeparator3" type="HSeparator" parent="VBoxContainer/ScrollContainer/VBoxContainer2"] -margin_top = 564.0 +margin_top = 588.0 margin_right = 998.0 -margin_bottom = 568.0 +margin_bottom = 592.0 [node name="Add" type="VBoxContainer" parent="VBoxContainer/ScrollContainer/VBoxContainer2"] -margin_top = 572.0 +margin_top = 596.0 margin_right = 998.0 -margin_bottom = 658.0 +margin_bottom = 682.0 [node name="AddLabel" type="Label" parent="VBoxContainer/ScrollContainer/VBoxContainer2/Add"] margin_right = 998.0 @@ -622,9 +675,9 @@ size_flags_horizontal = 3 text = "Quad" [node name="HSeparator2" type="HSeparator" parent="VBoxContainer/ScrollContainer/VBoxContainer2"] -margin_top = 662.0 +margin_top = 686.0 margin_right = 998.0 -margin_bottom = 666.0 +margin_bottom = 690.0 [node name="Popups" type="Control" parent="."] margin_left = 7.0 @@ -668,6 +721,9 @@ size_flags_vertical = 3 [connection signal="toggled" from="VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer3/Edge" to="VBoxContainer/ScrollContainer/VBoxContainer2/EdgeOps" method="set_visible"] [connection signal="toggled" from="VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer3/Face" to="." method="on_selection_mode_face_toggled"] [connection signal="toggled" from="VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer3/Face" to="VBoxContainer/ScrollContainer/VBoxContainer2/FaceOps" method="set_visible"] +[connection signal="toggled" from="VBoxContainer/ScrollContainer/VBoxContainer2/HBoxContainer6/Front" to="." method="onhandle_selection_type_front_toggled"] +[connection signal="toggled" from="VBoxContainer/ScrollContainer/VBoxContainer2/HBoxContainer6/Back" to="." method="onhandle_selection_type_back_toggled"] +[connection signal="toggled" from="VBoxContainer/ScrollContainer/VBoxContainer2/HBoxContainer6/All" to="." method="onhandle_selection_type_all_toggled"] [connection signal="toggled" from="VBoxContainer/ScrollContainer/VBoxContainer2/HBoxContainer4/Average" to="." method="on_pivot_average_toggled"] [connection signal="toggled" from="VBoxContainer/ScrollContainer/VBoxContainer2/HBoxContainer4/MDIOrigin" to="." method="on_pivot_mdi_origin_toggled"] [connection signal="toggled" from="VBoxContainer/ScrollContainer/VBoxContainer2/HBoxContainer4/WorldOrigin" to="." method="on_pivot_world_origin_toggled"] diff --git a/game/addons/mesh_data_resource_editor/MIDGizmo.gd b/game/addons/mesh_data_resource_editor/MIDGizmo.gd index b5c0316d..3fbc192e 100644 --- a/game/addons/mesh_data_resource_editor/MIDGizmo.gd +++ b/game/addons/mesh_data_resource_editor/MIDGizmo.gd @@ -30,12 +30,19 @@ enum PivotTypes { PIVOT_TYPE_WORLD_ORIGIN = 2, } +enum HandleSelectionType { + HANDLE_SELECTION_TYPE_FRONT = 0, + HANDLE_SELECTION_TYPE_BACK = 1, + HANDLE_SELECTION_TYPE_ALL = 2, +} + var gizmo_size = 3.0 var edit_mode : int = EditMode.EDIT_MODE_TRANSLATE var pivot_type : int = PivotTypes.PIVOT_TYPE_AVERAGED var axis_constraint : int = AxisConstraint.X | AxisConstraint.Y | AxisConstraint.Z var selection_mode : int = SelectionMode.SELECTION_MODE_VERTEX +var handle_selection_type : int = HandleSelectionType.HANDLE_SELECTION_TYPE_FRONT var visual_indicator_outline : bool = true var visual_indicator_seam : bool= true var visual_indicator_handle : bool = true @@ -482,7 +489,7 @@ func recalculate_handle_points() -> void: arr.resize(ArrayMesh.ARRAY_MAX) arr[ArrayMesh.ARRAY_VERTEX] = mdr_arr[ArrayMesh.ARRAY_VERTEX] arr[ArrayMesh.ARRAY_INDEX] = mdr_arr[ArrayMesh.ARRAY_INDEX] - + if selection_mode == SelectionMode.SELECTION_MODE_VERTEX: var merged_arrays : Array = MeshUtils.merge_mesh_array(arr) _handle_points = merged_arrays[ArrayMesh.ARRAY_VERTEX] @@ -1352,6 +1359,7 @@ func transfer_state_from(other) -> void: pivot_type = other.pivot_type axis_constraint = other.axis_constraint selection_mode = other.selection_mode + handle_selection_type = other.handle_selection_type visual_indicator_outline = other.visual_indicator_outline visual_indicator_seam = other.visual_indicator_seam @@ -1368,3 +1376,13 @@ func visual_indicator_seam_set(on : bool): func visual_indicator_handle_set(on : bool): visual_indicator_handle = on redraw() + +func handle_selection_type_front(): + handle_selection_type = HandleSelectionType.HANDLE_SELECTION_TYPE_FRONT + +func handle_selection_type_back(): + handle_selection_type = HandleSelectionType.HANDLE_SELECTION_TYPE_BACK + +func handle_selection_type_all(): + handle_selection_type = HandleSelectionType.HANDLE_SELECTION_TYPE_ALL + diff --git a/game/addons/mesh_data_resource_editor/button_groups/handle_selection_typen_group.tres b/game/addons/mesh_data_resource_editor/button_groups/handle_selection_typen_group.tres new file mode 100644 index 00000000..0e55d740 --- /dev/null +++ b/game/addons/mesh_data_resource_editor/button_groups/handle_selection_typen_group.tres @@ -0,0 +1,3 @@ +[gd_resource type="ButtonGroup" format=2] + +[resource] diff --git a/game/addons/mesh_data_resource_editor/plugin.gd b/game/addons/mesh_data_resource_editor/plugin.gd index 1db3cc4f..36dada6f 100644 --- a/game/addons/mesh_data_resource_editor/plugin.gd +++ b/game/addons/mesh_data_resource_editor/plugin.gd @@ -260,4 +260,15 @@ func visual_indicator_handle_set(on : bool): func select_all(): if current_mesh_data_instance && current_mesh_data_instance.gizmo: current_mesh_data_instance.gizmo.select_all() - + +func handle_selection_type_front(): + if current_mesh_data_instance && current_mesh_data_instance.gizmo: + current_mesh_data_instance.gizmo.handle_selection_type_front() + +func handle_selection_type_back(): + if current_mesh_data_instance && current_mesh_data_instance.gizmo: + current_mesh_data_instance.gizmo.handle_selection_type_back() + +func handle_selection_type_all(): + if current_mesh_data_instance && current_mesh_data_instance.gizmo: + current_mesh_data_instance.gizmo.handle_selection_type_all()