2
0
Эх сурвалжийг харах

Merge pull request #24993 from YeldhamDev/cppcheck_warns_scene_fix

Appease some CppCheck warns for files in the "scene" directory
Rémi Verschelde 6 жил өмнө
parent
commit
9f2d98c055

+ 0 - 3
scene/2d/polygon_2d.cpp

@@ -224,15 +224,12 @@ void Polygon2D::_notification(int p_what) {
 				for (int i = 0; i < bone_weights.size(); i++) {
 					if (bone_weights[i].weights.size() != points.size()) {
 						continue; //different number of vertices, sorry not using.
-						print_line("wrong weight size");
 					}
 					if (!skeleton_node->has_node(bone_weights[i].path)) {
-						print_line("no node");
 						continue; //node does not exist
 					}
 					Bone2D *bone = Object::cast_to<Bone2D>(skeleton_node->get_node(bone_weights[i].path));
 					if (!bone) {
-						print_line("no bone");
 						continue;
 					}
 

+ 2 - 3
scene/2d/tile_map.cpp

@@ -377,13 +377,12 @@ void TileMap::update_dirty_quadrants() {
 				r.size = tile_set->autotile_get_size(c.id);
 				r.position += (r.size + Vector2(spacing, spacing)) * Vector2(c.autotile_coord_x, c.autotile_coord_y);
 			}
-			Size2 s = tex->get_size();
 
+			Size2 s;
 			if (r == Rect2())
 				s = tex->get_size();
-			else {
+			else
 				s = r.size;
-			}
 
 			Rect2 rect;
 			rect.position = offset.floor();

+ 3 - 8
scene/3d/cpu_particles.cpp

@@ -605,19 +605,14 @@ void CPUParticles::_particles_process(float p_delta) {
 			p.hue_rot_rand = Math::randf();
 			p.anim_offset_rand = Math::randf();
 
-			float angle1_rad;
-			float angle2_rad;
-
 			if (flags[FLAG_DISABLE_Z]) {
-
-				angle1_rad = (Math::randf() * 2.0 - 1.0) * Math_PI * spread / 180.0;
+				float angle1_rad = (Math::randf() * 2.0 - 1.0) * Math_PI * spread / 180.0;
 				Vector3 rot = Vector3(Math::cos(angle1_rad), Math::sin(angle1_rad), 0.0);
 				p.velocity = rot * parameters[PARAM_INITIAL_LINEAR_VELOCITY] * Math::lerp(1.0f, float(Math::randf()), randomness[PARAM_INITIAL_LINEAR_VELOCITY]);
-
 			} else {
 				//initiate velocity spread in 3D
-				angle1_rad = (Math::randf() * 2.0 - 1.0) * Math_PI * spread / 180.0;
-				angle2_rad = (Math::randf() * 2.0 - 1.0) * (1.0 - flatness) * Math_PI * spread / 180.0;
+				float angle1_rad = (Math::randf() * 2.0 - 1.0) * Math_PI * spread / 180.0;
+				float angle2_rad = (Math::randf() * 2.0 - 1.0) * (1.0 - flatness) * Math_PI * spread / 180.0;
 
 				Vector3 direction_xz = Vector3(Math::sin(angle1_rad), 0, Math::cos(angle1_rad));
 				Vector3 direction_yz = Vector3(0, Math::sin(angle2_rad), Math::cos(angle2_rad));

+ 0 - 1
scene/3d/voxel_light_baker.cpp

@@ -1931,7 +1931,6 @@ Error VoxelLightBaker::make_lightmap(const Transform &p_xform, Ref<Mesh> &p_mesh
 
 		//add directional light (do this after blur)
 		{
-			LightMap *lightmap_ptr = lightmap.ptrw();
 			const Cell *cells = bake_cells.ptr();
 			const Light *light = bake_light.ptr();
 #ifdef _OPENMP

+ 1 - 3
scene/gui/line_edit.cpp

@@ -1290,13 +1290,11 @@ int LineEdit::get_max_length() const {
 
 void LineEdit::selection_fill_at_cursor() {
 
-	int aux;
-
 	selection.begin = cursor_pos;
 	selection.end = selection.cursor_start;
 
 	if (selection.end < selection.begin) {
-		aux = selection.end;
+		int aux = selection.end;
 		selection.end = selection.begin;
 		selection.begin = aux;
 	}

+ 0 - 1
scene/gui/scroll_container.cpp

@@ -271,7 +271,6 @@ void ScrollContainer::_notification(int p_what) {
 			}
 			if (!scroll_v || (!v_scroll->is_visible_in_tree() && c->get_v_size_flags() & SIZE_EXPAND)) {
 				r.position.y = 0;
-				r.size.height = size.height;
 				if (c->get_v_size_flags() & SIZE_EXPAND)
 					r.size.height = MAX(size.height, minsize.height);
 				else

+ 0 - 1
scene/gui/text_edit.cpp

@@ -3811,7 +3811,6 @@ Vector<String> TextEdit::get_wrap_rows_text(int p_line) const {
 			if (indent_ofs + word_px > wrap_at) {
 				// not enough space; add it anyway
 				wrap_substring += word_str;
-				px += word_px;
 				word_str = "";
 				word_px = 0;
 			}

+ 1 - 2
scene/main/http_request.cpp

@@ -220,13 +220,12 @@ bool HTTPRequest::_handle_response(bool *ret_value) {
 			Error err;
 			if (new_request.begins_with("http")) {
 				// New url, request all again
-				err = _parse_url(new_request);
+				_parse_url(new_request);
 			} else {
 				request_string = new_request;
 			}
 
 			err = _request();
-
 			if (err == OK) {
 				request_sent = false;
 				got_response = false;

+ 1 - 1
scene/resources/animation.cpp

@@ -2332,7 +2332,7 @@ float Animation::bezier_track_interpolate(int p_track, float p_time) const {
 	float duration = bt->values[idx + 1].time - bt->values[idx].time; // time duration between our two keyframes
 	float low = 0; // 0% of the current animation segment
 	float high = 1; // 100% of the current animation segment
-	float middle = 0;
+	float middle;
 
 	Vector2 start(0, bt->values[idx].value.value);
 	Vector2 start_out = start + bt->values[idx].value.out_handle;

+ 16 - 16
scene/resources/curve.cpp

@@ -761,8 +761,8 @@ Vector2 Curve2D::interpolate_baked(float p_offset, bool p_cubic) const {
 	//validate//
 	int pc = baked_point_cache.size();
 	if (pc == 0) {
-		ERR_EXPLAIN("No points in Curve2D");
-		ERR_FAIL_COND_V(pc == 0, Vector2());
+		ERR_EXPLAIN("No points in Curve2D.");
+		ERR_FAIL_V(Vector2());
 	}
 
 	if (pc == 1)
@@ -826,8 +826,8 @@ Vector2 Curve2D::get_closest_point(const Vector2 &p_to_point) const {
 	//validate//
 	int pc = baked_point_cache.size();
 	if (pc == 0) {
-		ERR_EXPLAIN("No points in Curve2D");
-		ERR_FAIL_COND_V(pc == 0, Vector2());
+		ERR_EXPLAIN("No points in Curve2D.");
+		ERR_FAIL_V(Vector2());
 	}
 
 	if (pc == 1)
@@ -865,8 +865,8 @@ float Curve2D::get_closest_offset(const Vector2 &p_to_point) const {
 	//validate//
 	int pc = baked_point_cache.size();
 	if (pc == 0) {
-		ERR_EXPLAIN("No points in Curve2D");
-		ERR_FAIL_COND_V(pc == 0, 0.0f);
+		ERR_EXPLAIN("No points in Curve2D.");
+		ERR_FAIL_V(0.0f);
 	}
 
 	if (pc == 1)
@@ -1331,8 +1331,8 @@ Vector3 Curve3D::interpolate_baked(float p_offset, bool p_cubic) const {
 	//validate//
 	int pc = baked_point_cache.size();
 	if (pc == 0) {
-		ERR_EXPLAIN("No points in Curve3D");
-		ERR_FAIL_COND_V(pc == 0, Vector3());
+		ERR_EXPLAIN("No points in Curve3D.");
+		ERR_FAIL_V(Vector3());
 	}
 
 	if (pc == 1)
@@ -1375,8 +1375,8 @@ float Curve3D::interpolate_baked_tilt(float p_offset) const {
 	//validate//
 	int pc = baked_tilt_cache.size();
 	if (pc == 0) {
-		ERR_EXPLAIN("No tilts in Curve3D");
-		ERR_FAIL_COND_V(pc == 0, 0);
+		ERR_EXPLAIN("No tilts in Curve3D.");
+		ERR_FAIL_V(0);
 	}
 
 	if (pc == 1)
@@ -1413,8 +1413,8 @@ Vector3 Curve3D::interpolate_baked_up_vector(float p_offset, bool p_apply_tilt)
 	// curve may not have baked up vectors
 	int count = baked_up_vector_cache.size();
 	if (count == 0) {
-		ERR_EXPLAIN("No up vectors in Curve3D");
-		ERR_FAIL_COND_V(count == 0, Vector3(0, 1, 0));
+		ERR_EXPLAIN("No up vectors in Curve3D.");
+		ERR_FAIL_V(Vector3(0, 1, 0));
 	}
 
 	if (count == 1)
@@ -1484,8 +1484,8 @@ Vector3 Curve3D::get_closest_point(const Vector3 &p_to_point) const {
 	//validate//
 	int pc = baked_point_cache.size();
 	if (pc == 0) {
-		ERR_EXPLAIN("No points in Curve3D");
-		ERR_FAIL_COND_V(pc == 0, Vector3());
+		ERR_EXPLAIN("No points in Curve3D.");
+		ERR_FAIL_V(Vector3());
 	}
 
 	if (pc == 1)
@@ -1523,8 +1523,8 @@ float Curve3D::get_closest_offset(const Vector3 &p_to_point) const {
 	//validate//
 	int pc = baked_point_cache.size();
 	if (pc == 0) {
-		ERR_EXPLAIN("No points in Curve3D");
-		ERR_FAIL_COND_V(pc == 0, 0.0f);
+		ERR_EXPLAIN("No points in Curve3D.");
+		ERR_FAIL_V(0.0f);
 	}
 
 	if (pc == 1)