From a793960a1092764a81f240726e58bf34e06d7767 Mon Sep 17 00:00:00 2001 From: Markus Sauermann <6299227+Sauermann@users.noreply.github.com> Date: Thu, 28 Apr 2022 11:35:39 +0200 Subject: [PATCH] Fix cppcheck const parameters Convert method signature parameters to const where it is possible # Conflicts: # drivers/gles3/rasterizer_canvas_gles3.cpp # drivers/gles3/rasterizer_canvas_gles3.h # editor/plugins/animation_state_machine_editor.cpp # editor/plugins/animation_state_machine_editor.h --- drivers/gles3/rasterizer_canvas_gles3.cpp | 2 +- drivers/gles3/rasterizer_canvas_gles3.h | 2 +- editor/import/collada.cpp | 2 +- editor/import/collada.h | 2 +- editor/plugins/node_3d_editor_gizmos.cpp | 2 +- editor/plugins/node_3d_editor_gizmos.h | 2 +- modules/gdscript/gdscript_editor.cpp | 2 +- modules/openxr/openxr_api.cpp | 4 ++-- modules/openxr/openxr_api.h | 4 ++-- scene/3d/skeleton_ik_3d.cpp | 2 +- scene/3d/skeleton_ik_3d.h | 2 +- scene/resources/gradient.cpp | 2 +- scene/resources/gradient.h | 2 +- servers/navigation_server_2d.cpp | 4 ++-- 14 files changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index ebf538351eb..b9fd50eeadc 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -823,7 +823,7 @@ void RasterizerCanvasGLES3::_render_batch(uint32_t &r_index) { } // TODO maybe dont use -void RasterizerCanvasGLES3::_end_batch(uint32_t p_index) { +void RasterizerCanvasGLES3::_end_batch(const uint32_t p_index) { for (int i = 0; i < 4; i++) { state.instance_data_array[p_index].modulation[i] = 0.0; state.instance_data_array[p_index].ninepatch_margins[i] = 0.0; diff --git a/drivers/gles3/rasterizer_canvas_gles3.h b/drivers/gles3/rasterizer_canvas_gles3.h index 99b079b8bbe..c50c7e4d830 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.h +++ b/drivers/gles3/rasterizer_canvas_gles3.h @@ -270,7 +270,7 @@ public: void _render_items(RID p_to_render_target, int p_item_count, const Transform2D &p_canvas_transform_inverse, Light *p_lights, bool p_to_backbuffer = false); void _render_item(RID p_render_target, const Item *p_item, const Transform2D &p_canvas_transform_inverse, Item *¤t_clip, Light *p_lights, uint32_t &r_index); void _render_batch(uint32_t &p_max_index); - void _end_batch(uint32_t p_index); + void _end_batch(const uint32_t p_index); void _allocate_instance_data_buffer(); void initialize(); diff --git a/editor/import/collada.cpp b/editor/import/collada.cpp index f8c99ff7d4d..af91ced5704 100644 --- a/editor/import/collada.cpp +++ b/editor/import/collada.cpp @@ -122,7 +122,7 @@ static Transform3D _read_transform_from_array(const Vector &array, int of /* STRUCTURES */ -Transform3D Collada::Node::compute_transform(Collada &state) const { +Transform3D Collada::Node::compute_transform(const Collada &state) const { Transform3D xform; for (int i = 0; i < xform_list.size(); i++) { diff --git a/editor/import/collada.h b/editor/import/collada.h index 85735e93acc..df2b7890812 100644 --- a/editor/import/collada.h +++ b/editor/import/collada.h @@ -348,7 +348,7 @@ public: Node *parent = nullptr; - Transform3D compute_transform(Collada &state) const; + Transform3D compute_transform(const Collada &state) const; Transform3D get_global_transform() const; Transform3D get_transform() const; diff --git a/editor/plugins/node_3d_editor_gizmos.cpp b/editor/plugins/node_3d_editor_gizmos.cpp index 179f78325c4..47c8c66c57f 100644 --- a/editor/plugins/node_3d_editor_gizmos.cpp +++ b/editor/plugins/node_3d_editor_gizmos.cpp @@ -476,7 +476,7 @@ void EditorNode3DGizmo::add_handles(const Vector &p_handles, const Ref< } } -void EditorNode3DGizmo::add_solid_box(Ref &p_material, Vector3 p_size, Vector3 p_position, const Transform3D &p_xform) { +void EditorNode3DGizmo::add_solid_box(const Ref &p_material, Vector3 p_size, Vector3 p_position, const Transform3D &p_xform) { ERR_FAIL_COND(!spatial_node); BoxMesh box_mesh; diff --git a/editor/plugins/node_3d_editor_gizmos.h b/editor/plugins/node_3d_editor_gizmos.h index 8adb753a51d..f859ceda3b8 100644 --- a/editor/plugins/node_3d_editor_gizmos.h +++ b/editor/plugins/node_3d_editor_gizmos.h @@ -99,7 +99,7 @@ public: void add_collision_triangles(const Ref &p_tmesh); void add_unscaled_billboard(const Ref &p_material, real_t p_scale = 1, const Color &p_modulate = Color(1, 1, 1)); void add_handles(const Vector &p_handles, const Ref &p_material, const Vector &p_ids = Vector(), bool p_billboard = false, bool p_secondary = false); - void add_solid_box(Ref &p_material, Vector3 p_size, Vector3 p_position = Vector3(), const Transform3D &p_xform = Transform3D()); + void add_solid_box(const Ref &p_material, Vector3 p_size, Vector3 p_position = Vector3(), const Transform3D &p_xform = Transform3D()); virtual bool is_handle_highlighted(int p_id, bool p_secondary) const; virtual String get_handle_name(int p_id, bool p_secondary) const; diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index 718df7a0a60..b3f9914b7d8 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -1140,7 +1140,7 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base } } -static void _find_identifiers(GDScriptParser::CompletionContext &p_context, bool p_only_functions, Map &r_result, int p_recursion_depth) { +static void _find_identifiers(const GDScriptParser::CompletionContext &p_context, bool p_only_functions, Map &r_result, int p_recursion_depth) { if (!p_only_functions && p_context.current_suite) { // This includes function parameters, since they are also locals. _find_identifiers_in_suite(p_context.current_suite, r_result); diff --git a/modules/openxr/openxr_api.cpp b/modules/openxr/openxr_api.cpp index ae3617938ea..2e9be48f010 100644 --- a/modules/openxr/openxr_api.cpp +++ b/modules/openxr/openxr_api.cpp @@ -1096,7 +1096,7 @@ Size2 OpenXRAPI::get_recommended_target_size() { return target_size; } -XRPose::TrackingConfidence OpenXRAPI::get_head_center(Transform3D &r_transform, Vector3 &r_linear_velocity, Vector3 &r_angular_velocity) { +XRPose::TrackingConfidence OpenXRAPI::get_head_center(Transform3D &r_transform, Vector3 &r_linear_velocity, const Vector3 &r_angular_velocity) { XrResult result; ERR_FAIL_COND_V(!running, XRPose::XR_TRACKING_CONFIDENCE_NONE); @@ -2297,7 +2297,7 @@ Vector2 OpenXRAPI::get_action_vector2(RID p_action, RID p_tracker) { return result_state.isActive ? Vector2(result_state.currentState.x, result_state.currentState.y) : Vector2(); } -XRPose::TrackingConfidence OpenXRAPI::get_action_pose(RID p_action, RID p_tracker, Transform3D &r_transform, Vector3 &r_linear_velocity, Vector3 &r_angular_velocity) { +XRPose::TrackingConfidence OpenXRAPI::get_action_pose(RID p_action, RID p_tracker, Transform3D &r_transform, Vector3 &r_linear_velocity, const Vector3 &r_angular_velocity) { ERR_FAIL_COND_V(session == XR_NULL_HANDLE, XRPose::XR_TRACKING_CONFIDENCE_NONE); Action *action = action_owner.get_or_null(p_action); ERR_FAIL_NULL_V(action, XRPose::XR_TRACKING_CONFIDENCE_NONE); diff --git a/modules/openxr/openxr_api.h b/modules/openxr/openxr_api.h index 7baf581a054..57475944c0e 100644 --- a/modules/openxr/openxr_api.h +++ b/modules/openxr/openxr_api.h @@ -247,7 +247,7 @@ public: bool can_render() { return instance != XR_NULL_HANDLE && session != XR_NULL_HANDLE && running && view_pose_valid && frame_state.shouldRender; }; Size2 get_recommended_target_size(); - XRPose::TrackingConfidence get_head_center(Transform3D &r_transform, Vector3 &r_linear_velocity, Vector3 &r_angular_velocity); + XRPose::TrackingConfidence get_head_center(Transform3D &r_transform, Vector3 &r_linear_velocity, const Vector3 &r_angular_velocity); bool get_view_transform(uint32_t p_view, Transform3D &r_transform); bool get_view_projection(uint32_t p_view, double p_z_near, double p_z_far, CameraMatrix &p_camera_matrix); bool process(); @@ -285,7 +285,7 @@ public: bool get_action_bool(RID p_action, RID p_tracker); float get_action_float(RID p_action, RID p_tracker); Vector2 get_action_vector2(RID p_action, RID p_tracker); - XRPose::TrackingConfidence get_action_pose(RID p_action, RID p_tracker, Transform3D &r_transform, Vector3 &r_linear_velocity, Vector3 &r_angular_velocity); + XRPose::TrackingConfidence get_action_pose(RID p_action, RID p_tracker, Transform3D &r_transform, Vector3 &r_linear_velocity, const Vector3 &r_angular_velocity); bool trigger_haptic_pulse(RID p_action, RID p_tracker, float p_frequency, float p_amplitude, XrDuration p_duration_ns); OpenXRAPI(); diff --git a/scene/3d/skeleton_ik_3d.cpp b/scene/3d/skeleton_ik_3d.cpp index f29b0600699..5e1f9d047f2 100644 --- a/scene/3d/skeleton_ik_3d.cpp +++ b/scene/3d/skeleton_ik_3d.cpp @@ -140,7 +140,7 @@ void FabrikInverseKinematic::solve_simple(Task *p_task, bool p_solve_magnet, Vec } } -void FabrikInverseKinematic::solve_simple_backwards(Chain &r_chain, bool p_solve_magnet) { +void FabrikInverseKinematic::solve_simple_backwards(const Chain &r_chain, bool p_solve_magnet) { if (p_solve_magnet && !r_chain.middle_chain_item) { return; } diff --git a/scene/3d/skeleton_ik_3d.h b/scene/3d/skeleton_ik_3d.h index 3ced5c49d35..0f656187deb 100644 --- a/scene/3d/skeleton_ik_3d.h +++ b/scene/3d/skeleton_ik_3d.h @@ -103,7 +103,7 @@ private: static void solve_simple(Task *p_task, bool p_solve_magnet, Vector3 p_origin_pos); /// Special solvers that solve only chains with one end effector - static void solve_simple_backwards(Chain &r_chain, bool p_solve_magnet); + static void solve_simple_backwards(const Chain &r_chain, bool p_solve_magnet); static void solve_simple_forwards(Chain &r_chain, bool p_solve_magnet, Vector3 p_origin_pos); public: diff --git a/scene/resources/gradient.cpp b/scene/resources/gradient.cpp index caaa3d8628c..a9c44dc6bfc 100644 --- a/scene/resources/gradient.cpp +++ b/scene/resources/gradient.cpp @@ -157,7 +157,7 @@ void Gradient::reverse() { emit_signal(CoreStringNames::get_singleton()->changed); } -void Gradient::set_points(Vector &p_points) { +void Gradient::set_points(const Vector &p_points) { points = p_points; is_sorted = false; emit_signal(CoreStringNames::get_singleton()->changed); diff --git a/scene/resources/gradient.h b/scene/resources/gradient.h index c2085b3a13c..a3d34490990 100644 --- a/scene/resources/gradient.h +++ b/scene/resources/gradient.h @@ -73,7 +73,7 @@ public: void add_point(float p_offset, const Color &p_color); void remove_point(int p_index); - void set_points(Vector &p_points); + void set_points(const Vector &p_points); Vector &get_points(); void reverse(); diff --git a/servers/navigation_server_2d.cpp b/servers/navigation_server_2d.cpp index 0fef416680c..a92fe8c79ab 100644 --- a/servers/navigation_server_2d.cpp +++ b/servers/navigation_server_2d.cpp @@ -138,11 +138,11 @@ static Object *obj_to_obj(Object *d) { return d; } -static StringName sn_to_sn(StringName &d) { +static StringName sn_to_sn(const StringName &d) { return d; } -static Variant var_to_var(Variant &d) { +static Variant var_to_var(const Variant &d) { return d; }