Went through mdr ed, and made as much parameters references as I could.

This commit is contained in:
Relintai 2022-04-14 17:13:07 +02:00
parent 3406a11f5c
commit 0d6c6230fc
12 changed files with 67 additions and 67 deletions

View File

@ -38,7 +38,7 @@ void MDIEd::set_plugin(MDIEdPlugin *plugin) {
_plugin = plugin;
uv_editor->set_plugin(plugin);
}
void MDIEd::set_mesh_data_resource(Ref<MeshDataResource> a) {
void MDIEd::set_mesh_data_resource(const Ref<MeshDataResource> &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<InputEventKey> event) {
void MDIEd::_unhandled_key_input(const Ref<InputEventKey> &event) {
if (event->is_echo()) {
return;
}

View File

@ -39,9 +39,9 @@ class MDIEd : public PanelContainer {
public:
void set_plugin(MDIEdPlugin *plugin);
void set_mesh_data_resource(Ref<MeshDataResource> a);
void set_mesh_data_resource(const Ref<MeshDataResource> &a);
void set_mesh_data_instance(MeshDataInstance *a);
void _unhandled_key_input(Ref<InputEventKey> event);
void _unhandled_key_input(const Ref<InputEventKey> &event);
//Edit modes
void set_edit_mode_translate();

View File

@ -239,7 +239,7 @@ bool MDIGizmo::selection_click(int index, Camera *camera, const Ref<InputEventMo
return false;
}
bool MDIGizmo::is_point_visible(Vector3 point_orig, Vector3 camera_pos, Transform gt) {
bool MDIGizmo::is_point_visible(const Vector3 &point_orig, const Vector3 &camera_pos, const Transform &gt) {
Vector3 point = gt.xform(point_orig);
// go from the given point to the origin (camera_pos -> camera)
@ -638,7 +638,7 @@ bool MDIGizmo::forward_spatial_gui_input(int index, Camera *camera, const Ref<In
return false;
}
void MDIGizmo::add_to_all_selected(Vector3 ofs) {
void MDIGizmo::add_to_all_selected(const Vector3 &ofs) {
for (int i = 0; i < _selected_points.size(); ++i) {
int indx = _selected_points[i];
Vector3 v = _handle_points[indx];
@ -654,7 +654,7 @@ void MDIGizmo::add_to_all_selected(Vector3 ofs) {
}
}
void MDIGizmo::mul_all_selected_with_basis(Basis b) {
void MDIGizmo::mul_all_selected_with_basis(const Basis &b) {
for (int i = 0; i < _selected_points.size(); ++i) {
int indx = _selected_points[i];
Vector3 v = _handle_points[indx];
@ -669,7 +669,7 @@ void MDIGizmo::mul_all_selected_with_basis(Basis b) {
_vertices.set(indx, v);
}
}
void MDIGizmo::mul_all_selected_with_transform(Transform t) {
void MDIGizmo::mul_all_selected_with_transform(const Transform &t) {
for (int i = 0; i < _selected_points.size(); ++i) {
int indx = _selected_points[i];
Vector3 v = _handle_points[indx];
@ -684,7 +684,7 @@ void MDIGizmo::mul_all_selected_with_transform(Transform t) {
_vertices.set(indx, v);
}
}
void MDIGizmo::mul_all_selected_with_transform_acc(Transform t) {
void MDIGizmo::mul_all_selected_with_transform_acc(const Transform &t) {
for (int i = 0; i < _selected_points.size(); ++i) {
int indx = _selected_points[i];
Vector3 v = _handle_points[indx];
@ -890,10 +890,10 @@ void MDIGizmo::add_quad() {
}
}
bool MDIGizmo::is_verts_equal(Vector3 v0, Vector3 v1) {
bool MDIGizmo::is_verts_equal(const Vector3 &v0, const Vector3 &v1) {
return Math::is_equal_approx(v0.x, v1.x) && Math::is_equal_approx(v0.y, v1.y) && Math::is_equal_approx(v0.z, v1.z);
}
Vector3 MDIGizmo::find_other_vertex_for_edge(int edge, Vector3 v0) {
Vector3 MDIGizmo::find_other_vertex_for_edge(const int edge, const Vector3 &v0) {
PoolIntArray ps = _handle_to_vertex_map[edge];
Vector3 vert;
@ -908,7 +908,7 @@ Vector3 MDIGizmo::find_other_vertex_for_edge(int edge, Vector3 v0) {
return v0;
}
Vector<PoolIntArray> MDIGizmo::split_edge_indices(int edge) {
Vector<PoolIntArray> MDIGizmo::split_edge_indices(const int edge) {
PoolIntArray ps = _handle_to_vertex_map[edge];
if (ps.size() == 0) {
@ -937,7 +937,7 @@ Vector<PoolIntArray> 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<MeshDataResource> mdr, Array arr) {
void MDIGizmo::apply_mesh_change(Ref<MeshDataResource> mdr, const Array &arr) {
if (!mdr.is_valid()) {
return;
}
mdr->set_array(copy_arrays(arr));
}
void MDIGizmo::apply_vertex_array(Ref<MeshDataResource> mdr, PoolVector3Array verts) {
void MDIGizmo::apply_vertex_array(Ref<MeshDataResource> mdr, const PoolVector3Array &verts) {
if (!mdr.is_valid()) {
return;
}
@ -2024,10 +2024,10 @@ void MDIGizmo::apply_vertex_array(Ref<MeshDataResource> 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();

View File

@ -84,7 +84,7 @@ public:
void select_all();
bool selection_click(int index, Camera *camera, const Ref<InputEventMouse> &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 &gt);
bool selection_click_select_front_or_back(int index, Camera *camera, const Ref<InputEventMouse> &event);
bool selection_click_select_through(int index, Camera *camera, const Ref<InputEventMouse> &event);
@ -92,20 +92,20 @@ public:
void selection_drag_rect_select_front_back(int index, Camera *camera, const Ref<InputEventMouse> &event);
void selection_drag_rect_select_through(int index, Camera *camera, const Ref<InputEventMouse> &event);
bool forward_spatial_gui_input(int index, Camera *camera, const Ref<InputEvent> &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<MeshDataResource> 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<PoolIntArray> 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<PoolIntArray> 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<PoolIntArray> split_face_indices(int face);
int find_first_triangle_index_for_face(int face);
Vector<PoolIntArray> 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<MeshDataResource> mdr, Array arr);
void apply_vertex_array(Ref<MeshDataResource> mdr, PoolVector3Array verts);
void apply_mesh_change(Ref<MeshDataResource> mdr, const Array &arr);
void apply_vertex_array(Ref<MeshDataResource> 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<MDIGizmo> &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();

View File

@ -26,7 +26,7 @@ SOFTWARE.
#include "../../nodes/mesh_data_instance.h"
#include "scene/resources/texture.h"
void MDREdUVPreviewer::set_mesh_data_resource(Ref<MeshDataResource> a) {
void MDREdUVPreviewer::set_mesh_data_resource(const Ref<MeshDataResource> &a) {
if (mesh_data_resource.is_valid()) {
mesh_data_resource->disconnect("changed", this, "on_mdr_changed");
}

View File

@ -35,7 +35,7 @@ class MDREdUVPreviewer : public Control {
GDCLASS(MDREdUVPreviewer, Control);
public:
void set_mesh_data_resource(Ref<MeshDataResource> a);
void set_mesh_data_resource(const Ref<MeshDataResource> &a);
void set_mesh_data_instance(MeshDataInstance *a);
void on_mdr_changed();
void _draw();

View File

@ -39,7 +39,7 @@ void MDRUVRectEditor::set_plugin(MDIEdPlugin *plugin) {
uv_rect_view->set_plugin(plugin);
}
void MDRUVRectEditor::set_mesh_data_resource(Ref<MeshDataResource> a) {
void MDRUVRectEditor::set_mesh_data_resource(const Ref<MeshDataResource> &a) {
uv_rect_view->set_mesh_data_resource(a);
}
void MDRUVRectEditor::set_mesh_data_instance(MeshDataInstance *a) {

View File

@ -38,7 +38,7 @@ class MDRUVRectEditor : public PanelContainer {
public:
void set_plugin(MDIEdPlugin *plugin);
void set_mesh_data_resource(Ref<MeshDataResource> a);
void set_mesh_data_resource(const Ref<MeshDataResource> &a);
void set_mesh_data_instance(MeshDataInstance *a);
void ok_pressed();
void cancel_pressed();

View File

@ -34,7 +34,7 @@ void MDRUVRectView::set_plugin(EditorPlugin *plugin) {
_undo_redo = EditorNode::get_undo_redo();
}
void MDRUVRectView::set_mesh_data_resource(Ref<MeshDataResource> a) {
void MDRUVRectView::set_mesh_data_resource(const Ref<MeshDataResource> &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<MeshDataResource> mdr) {
PoolVector2Array MDRUVRectView::get_uvs(const Ref<MeshDataResource> &mdr) {
if (!_mdr.is_valid()) {
return PoolVector2Array();
}
@ -93,7 +93,7 @@ PoolVector2Array MDRUVRectView::get_uvs(Ref<MeshDataResource> mdr) {
return arrays[ArrayMesh::ARRAY_TEX_UV];
}
void MDRUVRectView::apply_uvs(Ref<MeshDataResource> mdr, PoolVector2Array stored_uvs) {
void MDRUVRectView::apply_uvs(Ref<MeshDataResource> mdr, const PoolVector2Array &stored_uvs) {
if (!_mdr.is_valid()) {
return;
}

View File

@ -43,13 +43,13 @@ class MDRUVRectView : public Control {
public:
void set_plugin(EditorPlugin *plugin);
void set_mesh_data_resource(Ref<MeshDataResource> a);
void set_mesh_data_resource(const Ref<MeshDataResource> &a);
void set_mesh_data_instance(MeshDataInstance *a);
void set_selected(MDRUVRectViewNode *node);
void store_uvs();
PoolVector2Array get_uvs(Ref<MeshDataResource> mdr);
void apply_uvs(Ref<MeshDataResource> mdr, PoolVector2Array stored_uvs);
PoolVector2Array get_uvs(const Ref<MeshDataResource> &mdr);
void apply_uvs(Ref<MeshDataResource> mdr, const PoolVector2Array &stored_uvs);
void refresh();
void clear();

View File

@ -26,7 +26,7 @@ SOFTWARE.
#include "mdr_uv_rect_view.h"
#include "scene/resources/mesh.h"
void MDRUVRectViewNode::set_edited_resource(Ref<MeshDataResource> mdr, PoolIntArray indices) {
void MDRUVRectViewNode::set_edited_resource(const Ref<MeshDataResource> &mdr, const PoolIntArray &indices) {
_mdr = mdr;
_indices = indices;
_uvs.resize(0);
@ -481,7 +481,7 @@ void MDRUVRectViewNode::_gui_input(const Ref<InputEvent> &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");

View File

@ -45,7 +45,7 @@ public:
DRAG_RESIZE_LEFT = 1 << 4
};
void set_edited_resource(Ref<MeshDataResource> mdr, PoolIntArray indices);
void set_edited_resource(const Ref<MeshDataResource> &mdr, const PoolIntArray &indices);
void mirror_horizontal();
void mirror_vertical();
@ -64,7 +64,7 @@ public:
void _draw();
void _gui_input(const Ref<InputEvent> &p_event);
int _drag_hit_test(Vector2 pos);
int _drag_hit_test(const Vector2 &pos);
MDRUVRectViewNode();
~MDRUVRectViewNode();