From 0d6c6230fc0c2d8ad722cf2acc811e8dbdab20f1 Mon Sep 17 00:00:00 2001 From: Relintai Date: Thu, 14 Apr 2022 17:13:07 +0200 Subject: [PATCH] Went through mdr ed, and made as much parameters references as I could. --- modules/mesh_data_resource/editor/mdi_ed.cpp | 4 +- modules/mesh_data_resource/editor/mdi_ed.h | 4 +- .../mesh_data_resource/editor/mdi_gizmo.cpp | 32 ++++----- modules/mesh_data_resource/editor/mdi_gizmo.h | 66 +++++++++---------- .../editor/uv_editor/mdr_ed_uv_previewer.cpp | 2 +- .../editor/uv_editor/mdr_ed_uv_previewer.h | 2 +- .../editor/uv_editor/mdr_uv_rect_editor.cpp | 2 +- .../editor/uv_editor/mdr_uv_rect_editor.h | 2 +- .../editor/uv_editor/mdr_uv_rect_view.cpp | 6 +- .../editor/uv_editor/mdr_uv_rect_view.h | 6 +- .../uv_editor/mdr_uv_rect_view_node.cpp | 4 +- .../editor/uv_editor/mdr_uv_rect_view_node.h | 4 +- 12 files changed, 67 insertions(+), 67 deletions(-) diff --git a/modules/mesh_data_resource/editor/mdi_ed.cpp b/modules/mesh_data_resource/editor/mdi_ed.cpp index 63a22f6c2..bd3727df4 100644 --- a/modules/mesh_data_resource/editor/mdi_ed.cpp +++ b/modules/mesh_data_resource/editor/mdi_ed.cpp @@ -38,7 +38,7 @@ void MDIEd::set_plugin(MDIEdPlugin *plugin) { _plugin = plugin; uv_editor->set_plugin(plugin); } -void MDIEd::set_mesh_data_resource(Ref a) { +void MDIEd::set_mesh_data_resource(const Ref &a) { uv_preview->set_mesh_data_resource(a); uv_editor->get_editor()->set_mesh_data_resource(a); } @@ -46,7 +46,7 @@ void MDIEd::set_mesh_data_instance(MeshDataInstance *a) { uv_preview->set_mesh_data_instance(a); uv_editor->get_editor()->set_mesh_data_instance(a); } -void MDIEd::_unhandled_key_input(Ref event) { +void MDIEd::_unhandled_key_input(const Ref &event) { if (event->is_echo()) { return; } diff --git a/modules/mesh_data_resource/editor/mdi_ed.h b/modules/mesh_data_resource/editor/mdi_ed.h index f5af97495..a72abaaea 100644 --- a/modules/mesh_data_resource/editor/mdi_ed.h +++ b/modules/mesh_data_resource/editor/mdi_ed.h @@ -39,9 +39,9 @@ class MDIEd : public PanelContainer { public: void set_plugin(MDIEdPlugin *plugin); - void set_mesh_data_resource(Ref a); + void set_mesh_data_resource(const Ref &a); void set_mesh_data_instance(MeshDataInstance *a); - void _unhandled_key_input(Ref event); + void _unhandled_key_input(const Ref &event); //Edit modes void set_edit_mode_translate(); diff --git a/modules/mesh_data_resource/editor/mdi_gizmo.cpp b/modules/mesh_data_resource/editor/mdi_gizmo.cpp index 381171690..babc67c96 100644 --- a/modules/mesh_data_resource/editor/mdi_gizmo.cpp +++ b/modules/mesh_data_resource/editor/mdi_gizmo.cpp @@ -239,7 +239,7 @@ bool MDIGizmo::selection_click(int index, Camera *camera, const Ref camera) @@ -638,7 +638,7 @@ bool MDIGizmo::forward_spatial_gui_input(int index, Camera *camera, const Ref MDIGizmo::split_edge_indices(int edge) { +Vector MDIGizmo::split_edge_indices(const int edge) { PoolIntArray ps = _handle_to_vertex_map[edge]; if (ps.size() == 0) { @@ -937,7 +937,7 @@ Vector MDIGizmo::split_edge_indices(int edge) { return arr; } -bool MDIGizmo::pool_int_arr_contains(PoolIntArray arr, int val) { +bool MDIGizmo::pool_int_arr_contains(const PoolIntArray &arr, const int val) { PoolIntArray::Read r = arr.read(); for (int i = 0; i < arr.size(); ++i) { @@ -1982,14 +1982,14 @@ void MDIGizmo::flip_selected_faces() { } } -void MDIGizmo::add_mesh_change_undo_redo(Array orig_arr, Array new_arr, String action_name) { +void MDIGizmo::add_mesh_change_undo_redo(const Array &orig_arr, const Array &new_arr, const String &action_name) { _undo_redo->create_action(action_name); Array nac = copy_arrays(new_arr); _undo_redo->add_do_method(this, "apply_mesh_change", _mdr, nac); _undo_redo->add_undo_method(this, "apply_mesh_change", _mdr, orig_arr); _undo_redo->commit_action(); } -void MDIGizmo::add_mesh_seam_change_undo_redo(Array orig_arr, PoolIntArray orig_seams, Array new_arr, PoolIntArray new_seams, String action_name) { +void MDIGizmo::add_mesh_seam_change_undo_redo(const Array &orig_arr, const PoolIntArray &orig_seams, const Array &new_arr, const PoolIntArray &new_seams, const String &action_name) { _undo_redo->create_action(action_name); Array nac = copy_arrays(new_arr); @@ -2002,14 +2002,14 @@ void MDIGizmo::add_mesh_seam_change_undo_redo(Array orig_arr, PoolIntArray orig_ _undo_redo->commit_action(); } -void MDIGizmo::apply_mesh_change(Ref mdr, Array arr) { +void MDIGizmo::apply_mesh_change(Ref mdr, const Array &arr) { if (!mdr.is_valid()) { return; } mdr->set_array(copy_arrays(arr)); } -void MDIGizmo::apply_vertex_array(Ref mdr, PoolVector3Array verts) { +void MDIGizmo::apply_vertex_array(Ref mdr, const PoolVector3Array &verts) { if (!mdr.is_valid()) { return; } @@ -2024,10 +2024,10 @@ void MDIGizmo::apply_vertex_array(Ref mdr, PoolVector3Array ve mdr->set_array(mdr_arr); } -Array MDIGizmo::copy_arrays(Array arr) { +Array MDIGizmo::copy_arrays(const Array &arr) { return arr.duplicate(true); } -PoolIntArray MDIGizmo::copy_pool_int_array(PoolIntArray pia) { +PoolIntArray MDIGizmo::copy_pool_int_array(const PoolIntArray &pia) { PoolIntArray ret; ret.resize(pia.size()); @@ -2107,7 +2107,7 @@ Vector3 MDIGizmo::get_drag_op_pivot() { return Vector3(); } -void MDIGizmo::select_handle_points(PoolVector3Array points) { +void MDIGizmo::select_handle_points(const PoolVector3Array &points) { _selected_points.resize(0); PoolVector3Array::Read r = points.read(); diff --git a/modules/mesh_data_resource/editor/mdi_gizmo.h b/modules/mesh_data_resource/editor/mdi_gizmo.h index 5b0072666..a2c67cf2b 100644 --- a/modules/mesh_data_resource/editor/mdi_gizmo.h +++ b/modules/mesh_data_resource/editor/mdi_gizmo.h @@ -84,7 +84,7 @@ public: void select_all(); bool selection_click(int index, Camera *camera, const Ref &event); - bool is_point_visible(Vector3 point_orig, Vector3 camera_pos, Transform gt); + bool is_point_visible(const Vector3 &point_orig, const Vector3 &camera_pos, const Transform >); bool selection_click_select_front_or_back(int index, Camera *camera, const Ref &event); bool selection_click_select_through(int index, Camera *camera, const Ref &event); @@ -92,20 +92,20 @@ public: void selection_drag_rect_select_front_back(int index, Camera *camera, const Ref &event); void selection_drag_rect_select_through(int index, Camera *camera, const Ref &event); bool forward_spatial_gui_input(int index, Camera *camera, const Ref &event); - void add_to_all_selected(Vector3 ofs); + void add_to_all_selected(const Vector3 &ofs); - void mul_all_selected_with_basis(Basis b); - void mul_all_selected_with_transform(Transform t); - void mul_all_selected_with_transform_acc(Transform t); + void mul_all_selected_with_basis(const Basis &b); + void mul_all_selected_with_transform(const Transform &t); + void mul_all_selected_with_transform_acc(const Transform &t); void set_translate(); void set_scale(); void set_rotate(); - void set_edit_mode(int em); + void set_edit_mode(const int em); - void set_axis_x(bool on); - void set_axis_y(bool on); - void set_axis_z(bool on); + void set_axis_x(const bool on); + void set_axis_y(const bool on); + void set_axis_z(const bool on); void set_selection_mode_vertex(); void set_selection_mode_edge(); @@ -115,18 +115,18 @@ public: void on_mesh_data_resource_changed(Ref mdr); void on_mdr_changed(); void disable_change_event(); - void enable_change_event(bool update = true); + void enable_change_event(const bool update = true); void add_triangle(); void add_quad(); - bool is_verts_equal(Vector3 v0, Vector3 v1); - Vector3 find_other_vertex_for_edge(int edge, Vector3 v0); - Vector split_edge_indices(int edge); - bool pool_int_arr_contains(PoolIntArray arr, int val); - PoolIntArray find_triangles_for_edge(int edge); - int find_first_triangle_for_edge(int edge); - void add_triangle_to_edge(int edge); - void add_quad_to_edge(int edge); + bool is_verts_equal(const Vector3 &v0, const Vector3 &v1); + Vector3 find_other_vertex_for_edge(const int edge, const Vector3 &v0); + Vector split_edge_indices(const int edge); + bool pool_int_arr_contains(const PoolIntArray &arr, const int val); + PoolIntArray find_triangles_for_edge(const int edge); + int find_first_triangle_for_edge(const int edge); + void add_triangle_to_edge(const int edge); + void add_quad_to_edge(const int edge); void add_triangle_at(); void add_quad_at(); @@ -134,12 +134,12 @@ public: void add_box(); void split(); void disconnect_action(); - int get_first_triangle_index_for_vertex(int indx); + int get_first_triangle_index_for_vertex(const int indx); void create_face(); - Vector split_face_indices(int face); - int find_first_triangle_index_for_face(int face); + Vector split_face_indices(const int face); + int find_first_triangle_index_for_face(const int face); void delete_selected(); void generate_normals(); @@ -151,8 +151,8 @@ public: void connect_to_avg(); void connect_to_last_selected(); - PoolIntArray get_first_index_pair_for_edge(int edge); - PoolIntArray get_all_index_pairs_for_edge(int edge); + PoolIntArray get_first_index_pair_for_edge(const int edge); + PoolIntArray get_all_index_pairs_for_edge(const int edge); void mark_seam(); void unmark_seam(); @@ -164,20 +164,20 @@ public: void uv_unwrap(); void flip_selected_faces(); - void add_mesh_change_undo_redo(Array orig_arr, Array new_arr, String action_name); - void add_mesh_seam_change_undo_redo(Array orig_arr, PoolIntArray orig_seams, Array new_arr, PoolIntArray new_seams, String action_name); + void add_mesh_change_undo_redo(const Array &orig_arr, const Array &new_arr, const String &action_name); + void add_mesh_seam_change_undo_redo(const Array &orig_arr, const PoolIntArray &orig_seams, const Array &new_arr, const PoolIntArray &new_seams, const String &action_name); - void apply_mesh_change(Ref mdr, Array arr); - void apply_vertex_array(Ref mdr, PoolVector3Array verts); + void apply_mesh_change(Ref mdr, const Array &arr); + void apply_vertex_array(Ref mdr, const PoolVector3Array &verts); - Array copy_arrays(Array arr); - PoolIntArray copy_pool_int_array(PoolIntArray pia); + Array copy_arrays(const Array &arr); + PoolIntArray copy_pool_int_array(const PoolIntArray &pia); PoolVector3Array copy_mdr_verts_array(); void setup_op_drag_indices(); Vector3 get_drag_op_pivot(); - void select_handle_points(PoolVector3Array points); + void select_handle_points(const PoolVector3Array &points); void set_pivot_averaged(); void set_pivot_mdi_origin(); @@ -185,9 +185,9 @@ public: void transfer_state_from(const Ref &other); - void visual_indicator_outline_set(bool on); - void visual_indicator_seam_set(bool on); - void visual_indicator_handle_set(bool on); + void visual_indicator_outline_set(const bool on); + void visual_indicator_seam_set(const bool on); + void visual_indicator_handle_set(const bool on); void handle_selection_type_front(); void handle_selection_type_back(); diff --git a/modules/mesh_data_resource/editor/uv_editor/mdr_ed_uv_previewer.cpp b/modules/mesh_data_resource/editor/uv_editor/mdr_ed_uv_previewer.cpp index c7be9407c..7f98516f1 100644 --- a/modules/mesh_data_resource/editor/uv_editor/mdr_ed_uv_previewer.cpp +++ b/modules/mesh_data_resource/editor/uv_editor/mdr_ed_uv_previewer.cpp @@ -26,7 +26,7 @@ SOFTWARE. #include "../../nodes/mesh_data_instance.h" #include "scene/resources/texture.h" -void MDREdUVPreviewer::set_mesh_data_resource(Ref a) { +void MDREdUVPreviewer::set_mesh_data_resource(const Ref &a) { if (mesh_data_resource.is_valid()) { mesh_data_resource->disconnect("changed", this, "on_mdr_changed"); } diff --git a/modules/mesh_data_resource/editor/uv_editor/mdr_ed_uv_previewer.h b/modules/mesh_data_resource/editor/uv_editor/mdr_ed_uv_previewer.h index 1337f0d06..4f0c3e055 100644 --- a/modules/mesh_data_resource/editor/uv_editor/mdr_ed_uv_previewer.h +++ b/modules/mesh_data_resource/editor/uv_editor/mdr_ed_uv_previewer.h @@ -35,7 +35,7 @@ class MDREdUVPreviewer : public Control { GDCLASS(MDREdUVPreviewer, Control); public: - void set_mesh_data_resource(Ref a); + void set_mesh_data_resource(const Ref &a); void set_mesh_data_instance(MeshDataInstance *a); void on_mdr_changed(); void _draw(); diff --git a/modules/mesh_data_resource/editor/uv_editor/mdr_uv_rect_editor.cpp b/modules/mesh_data_resource/editor/uv_editor/mdr_uv_rect_editor.cpp index 05608cd98..e71cb720e 100644 --- a/modules/mesh_data_resource/editor/uv_editor/mdr_uv_rect_editor.cpp +++ b/modules/mesh_data_resource/editor/uv_editor/mdr_uv_rect_editor.cpp @@ -39,7 +39,7 @@ void MDRUVRectEditor::set_plugin(MDIEdPlugin *plugin) { uv_rect_view->set_plugin(plugin); } -void MDRUVRectEditor::set_mesh_data_resource(Ref a) { +void MDRUVRectEditor::set_mesh_data_resource(const Ref &a) { uv_rect_view->set_mesh_data_resource(a); } void MDRUVRectEditor::set_mesh_data_instance(MeshDataInstance *a) { diff --git a/modules/mesh_data_resource/editor/uv_editor/mdr_uv_rect_editor.h b/modules/mesh_data_resource/editor/uv_editor/mdr_uv_rect_editor.h index fd54a5a66..92fc1fb08 100644 --- a/modules/mesh_data_resource/editor/uv_editor/mdr_uv_rect_editor.h +++ b/modules/mesh_data_resource/editor/uv_editor/mdr_uv_rect_editor.h @@ -38,7 +38,7 @@ class MDRUVRectEditor : public PanelContainer { public: void set_plugin(MDIEdPlugin *plugin); - void set_mesh_data_resource(Ref a); + void set_mesh_data_resource(const Ref &a); void set_mesh_data_instance(MeshDataInstance *a); void ok_pressed(); void cancel_pressed(); diff --git a/modules/mesh_data_resource/editor/uv_editor/mdr_uv_rect_view.cpp b/modules/mesh_data_resource/editor/uv_editor/mdr_uv_rect_view.cpp index d77efbc7b..43c65e8a8 100644 --- a/modules/mesh_data_resource/editor/uv_editor/mdr_uv_rect_view.cpp +++ b/modules/mesh_data_resource/editor/uv_editor/mdr_uv_rect_view.cpp @@ -34,7 +34,7 @@ void MDRUVRectView::set_plugin(EditorPlugin *plugin) { _undo_redo = EditorNode::get_undo_redo(); } -void MDRUVRectView::set_mesh_data_resource(Ref a) { +void MDRUVRectView::set_mesh_data_resource(const Ref &a) { _mdr = a; } void MDRUVRectView::set_mesh_data_instance(MeshDataInstance *a) { @@ -76,7 +76,7 @@ void MDRUVRectView::store_uvs() { // Make sure it gets copied _stored_uvs.append_array(arrays[ArrayMesh::ARRAY_TEX_UV]); } -PoolVector2Array MDRUVRectView::get_uvs(Ref mdr) { +PoolVector2Array MDRUVRectView::get_uvs(const Ref &mdr) { if (!_mdr.is_valid()) { return PoolVector2Array(); } @@ -93,7 +93,7 @@ PoolVector2Array MDRUVRectView::get_uvs(Ref mdr) { return arrays[ArrayMesh::ARRAY_TEX_UV]; } -void MDRUVRectView::apply_uvs(Ref mdr, PoolVector2Array stored_uvs) { +void MDRUVRectView::apply_uvs(Ref mdr, const PoolVector2Array &stored_uvs) { if (!_mdr.is_valid()) { return; } diff --git a/modules/mesh_data_resource/editor/uv_editor/mdr_uv_rect_view.h b/modules/mesh_data_resource/editor/uv_editor/mdr_uv_rect_view.h index 2e2363729..9b17c997e 100644 --- a/modules/mesh_data_resource/editor/uv_editor/mdr_uv_rect_view.h +++ b/modules/mesh_data_resource/editor/uv_editor/mdr_uv_rect_view.h @@ -43,13 +43,13 @@ class MDRUVRectView : public Control { public: void set_plugin(EditorPlugin *plugin); - void set_mesh_data_resource(Ref a); + void set_mesh_data_resource(const Ref &a); void set_mesh_data_instance(MeshDataInstance *a); void set_selected(MDRUVRectViewNode *node); void store_uvs(); - PoolVector2Array get_uvs(Ref mdr); - void apply_uvs(Ref mdr, PoolVector2Array stored_uvs); + PoolVector2Array get_uvs(const Ref &mdr); + void apply_uvs(Ref mdr, const PoolVector2Array &stored_uvs); void refresh(); void clear(); diff --git a/modules/mesh_data_resource/editor/uv_editor/mdr_uv_rect_view_node.cpp b/modules/mesh_data_resource/editor/uv_editor/mdr_uv_rect_view_node.cpp index 21838b200..0f154d650 100644 --- a/modules/mesh_data_resource/editor/uv_editor/mdr_uv_rect_view_node.cpp +++ b/modules/mesh_data_resource/editor/uv_editor/mdr_uv_rect_view_node.cpp @@ -26,7 +26,7 @@ SOFTWARE. #include "mdr_uv_rect_view.h" #include "scene/resources/mesh.h" -void MDRUVRectViewNode::set_edited_resource(Ref mdr, PoolIntArray indices) { +void MDRUVRectViewNode::set_edited_resource(const Ref &mdr, const PoolIntArray &indices) { _mdr = mdr; _indices = indices; _uvs.resize(0); @@ -481,7 +481,7 @@ void MDRUVRectViewNode::_gui_input(const Ref &p_event) { } //based on / ported from engine/scene/gui/dialogs.h and .cpp -int MDRUVRectViewNode::_drag_hit_test(Vector2 pos) { +int MDRUVRectViewNode::_drag_hit_test(const Vector2 &pos) { int drag_type = DragType::DRAG_NONE; int scaleborder_size = get_constant("scaleborder_size", "WindowDialog"); diff --git a/modules/mesh_data_resource/editor/uv_editor/mdr_uv_rect_view_node.h b/modules/mesh_data_resource/editor/uv_editor/mdr_uv_rect_view_node.h index e70c79c9e..292da8fbc 100644 --- a/modules/mesh_data_resource/editor/uv_editor/mdr_uv_rect_view_node.h +++ b/modules/mesh_data_resource/editor/uv_editor/mdr_uv_rect_view_node.h @@ -45,7 +45,7 @@ public: DRAG_RESIZE_LEFT = 1 << 4 }; - void set_edited_resource(Ref mdr, PoolIntArray indices); + void set_edited_resource(const Ref &mdr, const PoolIntArray &indices); void mirror_horizontal(); void mirror_vertical(); @@ -64,7 +64,7 @@ public: void _draw(); void _gui_input(const Ref &p_event); - int _drag_hit_test(Vector2 pos); + int _drag_hit_test(const Vector2 &pos); MDRUVRectViewNode(); ~MDRUVRectViewNode();