Browse Source

Merge pull request #59937 from Sauermann/cppcheck-cost-parameter

Rémi Verschelde 3 years ago
parent
commit
3e1b824c05

+ 1 - 1
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;

+ 1 - 1
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 *&current_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();

+ 1 - 1
editor/import/collada.cpp

@@ -122,7 +122,7 @@ static Transform3D _read_transform_from_array(const Vector<float> &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++) {

+ 1 - 1
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;
 

+ 1 - 1
editor/plugins/node_3d_editor_gizmos.cpp

@@ -476,7 +476,7 @@ void EditorNode3DGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref<
 	}
 }
 
-void EditorNode3DGizmo::add_solid_box(Ref<Material> &p_material, Vector3 p_size, Vector3 p_position, const Transform3D &p_xform) {
+void EditorNode3DGizmo::add_solid_box(const Ref<Material> &p_material, Vector3 p_size, Vector3 p_position, const Transform3D &p_xform) {
 	ERR_FAIL_COND(!spatial_node);
 
 	BoxMesh box_mesh;

+ 1 - 1
editor/plugins/node_3d_editor_gizmos.h

@@ -99,7 +99,7 @@ public:
 	void add_collision_triangles(const Ref<TriangleMesh> &p_tmesh);
 	void add_unscaled_billboard(const Ref<Material> &p_material, real_t p_scale = 1, const Color &p_modulate = Color(1, 1, 1));
 	void add_handles(const Vector<Vector3> &p_handles, const Ref<Material> &p_material, const Vector<int> &p_ids = Vector<int>(), bool p_billboard = false, bool p_secondary = false);
-	void add_solid_box(Ref<Material> &p_material, Vector3 p_size, Vector3 p_position = Vector3(), const Transform3D &p_xform = Transform3D());
+	void add_solid_box(const Ref<Material> &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;

+ 1 - 1
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<String, ScriptLanguage::CodeCompletionOption> &r_result, int p_recursion_depth) {
+static void _find_identifiers(const GDScriptParser::CompletionContext &p_context, bool p_only_functions, Map<String, ScriptLanguage::CodeCompletionOption> &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);

+ 2 - 2
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);

+ 2 - 2
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();

+ 1 - 1
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;
 	}

+ 1 - 1
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:

+ 1 - 1
scene/resources/gradient.cpp

@@ -157,7 +157,7 @@ void Gradient::reverse() {
 	emit_signal(CoreStringNames::get_singleton()->changed);
 }
 
-void Gradient::set_points(Vector<Gradient::Point> &p_points) {
+void Gradient::set_points(const Vector<Gradient::Point> &p_points) {
 	points = p_points;
 	is_sorted = false;
 	emit_signal(CoreStringNames::get_singleton()->changed);

+ 1 - 1
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<Point> &p_points);
+	void set_points(const Vector<Point> &p_points);
 	Vector<Point> &get_points();
 	void reverse();
 

+ 2 - 2
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;
 }