Added a flip face action to mdr ed.

This commit is contained in:
Relintai 2022-02-11 17:29:37 +01:00
parent bcebec81d4
commit 7e05bda987
4 changed files with 38 additions and 0 deletions

View File

@ -250,3 +250,6 @@ func onhandle_selection_type_all_toggled(on : bool):
func _on_clean_mesh_pressed():
_plugin.clean_mesh()
func _on_flip_face_pressed():
_plugin.flip_selected_faces()

View File

@ -540,6 +540,11 @@ margin_right = 1010.0
margin_bottom = 20.0
text = "Delete"
[node name="Flip" type="Button" parent="VBoxContainer/ScrollContainer/VBoxContainer2/FaceOps/Operations"]
margin_right = 1010.0
margin_bottom = 20.0
text = "Flip"
[node name="HSeparator4" type="HSeparator" parent="VBoxContainer/ScrollContainer/VBoxContainer2"]
margin_top = 196.0
margin_right = 998.0
@ -750,6 +755,7 @@ size_flags_vertical = 3
[connection signal="pressed" from="VBoxContainer/ScrollContainer/VBoxContainer2/EdgeOps/Operations/HBoxContainer/Mark" to="." method="_on_mark_seam_pressed"]
[connection signal="pressed" from="VBoxContainer/ScrollContainer/VBoxContainer2/EdgeOps/Operations/HBoxContainer/Unmark" to="." method="_on_unmark_seam_pressed"]
[connection signal="pressed" from="VBoxContainer/ScrollContainer/VBoxContainer2/FaceOps/Operations/Delete" to="." method="_on_delete_pressed"]
[connection signal="pressed" from="VBoxContainer/ScrollContainer/VBoxContainer2/FaceOps/Operations/Flip" to="." method="_on_flip_face_pressed"]
[connection signal="pressed" from="VBoxContainer/ScrollContainer/VBoxContainer2/Operations/Operations/GenNormals" to="." method="_on_GenNormals_pressed"]
[connection signal="pressed" from="VBoxContainer/ScrollContainer/VBoxContainer2/Operations/Operations/GenTangents" to="." method="_on_GenTangents_pressed"]
[connection signal="pressed" from="VBoxContainer/ScrollContainer/VBoxContainer2/Operations/Operations/RemDoubles" to="." method="_on_RemDoubles_pressed"]

View File

@ -1637,6 +1637,31 @@ func uv_unwrap() -> void:
add_mesh_change_undo_redo(orig_arr, mdr_arr, "uv_unwrap")
enable_change_event()
func flip_selected_faces() -> void:
if !_mdr:
return
if _selected_points.size() == 0:
return
if selection_mode == SelectionMode.SELECTION_MODE_VERTEX:
pass
elif selection_mode == SelectionMode.SELECTION_MODE_EDGE:
pass
elif selection_mode == SelectionMode.SELECTION_MODE_FACE:
disable_change_event()
var orig_arr = copy_arrays(_mdr.array)
for sp in _selected_points:
var triangle_index : int = find_first_triangle_index_for_face(sp)
MDRMeshUtils.flip_triangle_ti(_mdr, triangle_index)
add_mesh_change_undo_redo(orig_arr, _mdr.array, "Flip Faces")
enable_change_event()
func add_mesh_change_undo_redo(orig_arr : Array, new_arr : Array, action_name : String) -> void:
_undo_redo.create_action(action_name)
var nac : Array = copy_arrays(new_arr)

View File

@ -280,3 +280,7 @@ func extrude():
func clean_mesh():
if current_mesh_data_instance && current_mesh_data_instance.gizmo:
current_mesh_data_instance.gizmo.clean_mesh()
func flip_selected_faces():
if current_mesh_data_instance && current_mesh_data_instance.gizmo:
current_mesh_data_instance.gizmo.flip_selected_faces()