Browse Source

Small fixes, mostly dupicated code

(cherry picked from commit 856a8226a5306632f5dd4d9e9c916d89e3e21495)
qarmin 6 years ago
parent
commit
3b703d6707

+ 0 - 1
drivers/gles2/rasterizer_scene_gles2.cpp

@@ -480,7 +480,6 @@ RID RasterizerSceneGLES2::reflection_probe_instance_create(RID p_probe) {
 	rpi->current_resolution = 0;
 	rpi->dirty = true;
 
-	rpi->last_pass = 0;
 	rpi->index = 0;
 
 	for (int i = 0; i < 6; i++) {

+ 5 - 6
drivers/gles3/rasterizer_scene_gles3.cpp

@@ -1061,12 +1061,11 @@ void RasterizerSceneGLES3::gi_probe_instance_set_light_data(RID p_probe, RID p_b
 	if (p_data.is_valid()) {
 		RasterizerStorageGLES3::GIProbeData *gipd = storage->gi_probe_data_owner.getornull(p_data);
 		ERR_FAIL_COND(!gipd);
-		if (gipd) {
-			gipi->tex_cache = gipd->tex_id;
-			gipi->cell_size_cache.x = 1.0 / gipd->width;
-			gipi->cell_size_cache.y = 1.0 / gipd->height;
-			gipi->cell_size_cache.z = 1.0 / gipd->depth;
-		}
+
+		gipi->tex_cache = gipd->tex_id;
+		gipi->cell_size_cache.x = 1.0 / gipd->width;
+		gipi->cell_size_cache.y = 1.0 / gipd->height;
+		gipi->cell_size_cache.z = 1.0 / gipd->depth;
 	}
 }
 void RasterizerSceneGLES3::gi_probe_instance_set_transform_to_data(RID p_probe, const Transform &p_xform) {

+ 1 - 2
editor/collada/collada.cpp

@@ -2255,8 +2255,7 @@ void Collada::_merge_skeletons2(VisualScene *p_vscene) {
 
 			Node *node = state.scene_map[name];
 			ERR_CONTINUE(node->type != Node::TYPE_JOINT);
-			if (node->type != Node::TYPE_JOINT)
-				continue;
+
 			NodeSkeleton *sk = NULL;
 
 			while (node && !sk) {

+ 0 - 2
editor/import/editor_import_collada.cpp

@@ -1614,8 +1614,6 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
 					continue;
 				}
 
-				ERR_CONTINUE(xform_idx == -1);
-
 				Vector<float> data = at.get_value_at_time(snapshots[i]);
 				ERR_CONTINUE(data.empty());
 

+ 1 - 2
editor/inspector_dock.cpp

@@ -130,8 +130,7 @@ void InspectorDock::_menu_option(int p_option) {
 				ERR_FAIL_INDEX(idx, methods.size());
 				String name = methods[idx].name;
 
-				if (current)
-					current->call(name);
+				current->call(name);
 			}
 		}
 	}

+ 1 - 1
editor/plugins/animation_tree_player_editor_plugin.cpp

@@ -835,7 +835,7 @@ void AnimationTreePlayerEditor::_gui_input(Ref<InputEvent> p_event) {
 			click_motion = Point2(mm->get_position().x, mm->get_position().y);
 			update();
 		}
-		if ((mm->get_button_mask() & 4 || Input::get_singleton()->is_key_pressed(KEY_SPACE))) {
+		if (mm->get_button_mask() & 4 || Input::get_singleton()->is_key_pressed(KEY_SPACE)) {
 
 			h_scroll->set_value(h_scroll->get_value() - mm->get_relative().x);
 			v_scroll->set_value(v_scroll->get_value() - mm->get_relative().y);

+ 1 - 1
editor/plugins/canvas_item_editor_plugin.cpp

@@ -1858,7 +1858,7 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) {
 		}
 
 		// Confirm the move (only if it was moved)
-		if (b.is_valid() && !b->is_pressed() && b->get_button_index() == BUTTON_LEFT && (drag_type == DRAG_MOVE)) {
+		if (b.is_valid() && !b->is_pressed() && b->get_button_index() == BUTTON_LEFT) {
 			if (transform.affine_inverse().xform(b->get_position()) != drag_from) {
 				_commit_canvas_item_state(drag_selection, TTR("Move CanvasItem"), true);
 			}

+ 2 - 4
editor/scene_tree_dock.cpp

@@ -811,10 +811,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
 			List<Node *>::Element *e = selection.front();
 			if (e) {
 				Node *node = e->get();
-				if (node) {
-					if (node && node->get_scene_inherited_state().is_valid()) {
-						scene_tree->emit_signal("open", node->get_scene_inherited_state()->get_path());
-					}
+				if (node && node->get_scene_inherited_state().is_valid()) {
+					scene_tree->emit_signal("open", node->get_scene_inherited_state()->get_path());
 				}
 			}
 		} break;

+ 0 - 1
editor/spatial_editor_gizmos.cpp

@@ -324,7 +324,6 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref
 
 	ERR_FAIL_COND(!spatial_node);
 
-	ERR_FAIL_COND(!spatial_node);
 	Instance ins;
 
 	Ref<ArrayMesh> mesh = memnew(ArrayMesh);

+ 1 - 1
modules/gdnative/videodecoder/video_stream_gdnative.cpp

@@ -61,8 +61,8 @@ int64_t GDAPI godot_videodecoder_file_seek(void *ptr, int64_t pos, int whence) {
 	// file
 	FileAccess *file = reinterpret_cast<FileAccess *>(ptr);
 
-	size_t len = file->get_len();
 	if (file) {
+		size_t len = file->get_len();
 		switch (whence) {
 			case SEEK_SET: {
 				// Just for explicitness

+ 1 - 1
modules/gdscript/gdscript_editor.cpp

@@ -3006,8 +3006,8 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
 							}
 						}
 					}
+					base_type = base_type.class_type->base_type;
 				}
-				base_type = base_type.class_type->base_type;
 			} break;
 			case GDScriptParser::DataType::SCRIPT:
 			case GDScriptParser::DataType::GDSCRIPT: {

+ 1 - 1
modules/gdscript/gdscript_tokenizer.cpp

@@ -895,7 +895,7 @@ void GDScriptTokenizerText::_advance() {
 							}
 							hexa_found = true;
 						} else if (!hexa_found && GETCHAR(i) == 'e') {
-							if (hexa_found || exponent_found) {
+							if (exponent_found) {
 								_make_error("Invalid numeric constant at 'e'");
 								return;
 							}

+ 1 - 3
modules/recast/navigation_mesh_editor_plugin.cpp

@@ -67,9 +67,7 @@ void NavigationMeshEditor::_bake_pressed() {
 	NavigationMeshGenerator::clear(node->get_navigation_mesh());
 	NavigationMeshGenerator::bake(node->get_navigation_mesh(), node);
 
-	if (node) {
-		node->update_gizmo();
-	}
+	node->update_gizmo();
 }
 
 void NavigationMeshEditor::_clear_pressed() {

+ 0 - 4
platform/android/export/export.cpp

@@ -1923,10 +1923,6 @@ public:
 		zipClose(final_apk, NULL);
 		unzClose(tmp_unaligned);
 
-		if (err) {
-			return err;
-		}
-
 		return OK;
 	}
 

+ 1 - 1
platform/x11/os_x11.cpp

@@ -1165,7 +1165,7 @@ int OS_X11::get_screen_dpi(int p_screen) const {
 	int height_mm = DisplayHeightMM(x11_display, p_screen);
 	double xdpi = (width_mm ? sc.width / (double)width_mm * 25.4 : 0);
 	double ydpi = (height_mm ? sc.height / (double)height_mm * 25.4 : 0);
-	if (xdpi || xdpi)
+	if (xdpi || ydpi)
 		return (xdpi + ydpi) / (xdpi && ydpi ? 2 : 1);
 
 	//could not get dpi

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

@@ -1275,9 +1275,6 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const
 
 			if (collided) {
 				found_collision = true;
-			}
-
-			if (collided) {
 
 				colliders.push_back(collision);
 				motion = collision.remainder;

+ 0 - 3
scene/3d/physics_body.cpp

@@ -1203,9 +1203,6 @@ Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Ve
 
 			if (collided) {
 				found_collision = true;
-			}
-
-			if (collided) {
 
 				colliders.push_back(collision);
 				motion = collision.remainder;

+ 1 - 1
scene/gui/base_button.cpp

@@ -59,7 +59,7 @@ void BaseButton::_gui_input(Ref<InputEvent> p_event) {
 	Ref<InputEventMouseButton> b = p_event;
 
 	if (b.is_valid()) {
-		if (status.disabled || ((1 << (b->get_button_index() - 1)) & button_mask) == 0)
+		if (((1 << (b->get_button_index() - 1)) & button_mask) == 0)
 			return;
 
 		if (status.pressing_button)

+ 1 - 1
scene/gui/popup_menu.cpp

@@ -239,7 +239,7 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
 
 		for (int i = search_from; i >= 0; i--) {
 
-			if (i < 0 || i >= items.size())
+			if (i >= items.size())
 				continue;
 
 			if (!items[i].separator && !items[i].disabled) {

+ 1 - 1
scene/gui/rich_text_label.cpp

@@ -2004,7 +2004,7 @@ bool RichTextLabel::search(const String &p_string, bool p_from_selection, bool p
 	Item *it = main;
 	int charidx = 0;
 
-	if (p_from_selection && selection.active && selection.enabled) {
+	if (p_from_selection && selection.active) {
 		it = selection.to;
 		charidx = selection.to_char + 1;
 	}

+ 0 - 1
scene/gui/tree.cpp

@@ -3930,7 +3930,6 @@ Tree::Tree() {
 	cache.click_item = NULL;
 	cache.click_column = 0;
 	cache.hover_cell = -1;
-	cache.hover_index = -1;
 	last_keypress = 0;
 	focus_in_id = 0;
 

+ 1 - 1
scene/main/http_request.cpp

@@ -286,7 +286,7 @@ bool HTTPRequest::_update_connection() {
 					call_deferred("_request_done", RESULT_SUCCESS, response_code, response_headers, PoolByteArray());
 					return true;
 				}
-				if (got_response && body_len < 0) {
+				if (body_len < 0) {
 					// Chunked transfer is done
 					call_deferred("_request_done", RESULT_SUCCESS, response_code, response_headers, body);
 					return true;

+ 1 - 1
scene/resources/curve.cpp

@@ -268,7 +268,7 @@ void Curve::update_auto_tangents(int i) {
 	}
 
 	if (i + 1 < _points.size()) {
-		if (p.right_mode == TANGENT_LINEAR && i + 1 < _points.size()) {
+		if (p.right_mode == TANGENT_LINEAR) {
 			Vector2 v = (_points[i + 1].pos - p.pos).normalized();
 			p.right_tangent = v.y / v.x;
 		}

+ 2 - 4
servers/audio/audio_rb_resampler.cpp

@@ -201,10 +201,8 @@ void AudioRBResampler::clear() {
 		return;
 
 	//should be stopped at this point but just in case
-	if (rb) {
-		memdelete_arr(rb);
-		memdelete_arr(read_buf);
-	}
+	memdelete_arr(rb);
+	memdelete_arr(read_buf);
 	rb = NULL;
 	offset = 0;
 	rb_read_pos = 0;

+ 1 - 1
servers/audio/effects/audio_effect_record.cpp

@@ -66,7 +66,7 @@ void AudioEffectRecordInstance::_io_thread_process() {
 
 	while (is_recording) {
 		//Check: The current recording has been requested to stop
-		if (is_recording && !base->recording_active) {
+		if (!base->recording_active) {
 			is_recording = false;
 		}
 

+ 2 - 4
servers/physics/space_sw.cpp

@@ -351,10 +351,8 @@ bool PhysicsDirectSpaceStateSW::collide_shape(RID p_shape, const Transform &p_sh
 	CollisionSolverSW::CallbackResult cbkres = NULL;
 
 	PhysicsServerSW::CollCbkData *cbkptr = NULL;
-	if (p_result_max > 0) {
-		cbkptr = &cbk;
-		cbkres = PhysicsServerSW::_shape_col_cbk;
-	}
+	cbkptr = &cbk;
+	cbkres = PhysicsServerSW::_shape_col_cbk;
 
 	for (int i = 0; i < amount; i++) {
 

+ 1 - 1
servers/physics_2d/shape_2d_sw.cpp

@@ -586,7 +586,7 @@ bool ConvexPolygonShape2DSW::contains_point(const Vector2 &p_point) const {
 			in = true;
 	}
 
-	return (in && !out) || (!in && out);
+	return in != out;
 }
 
 bool ConvexPolygonShape2DSW::intersect_segment(const Vector2 &p_begin, const Vector2 &p_end, Vector2 &r_point, Vector2 &r_normal) const {

+ 3 - 5
servers/physics_2d/space_2d_sw.cpp

@@ -333,10 +333,8 @@ bool Physics2DDirectSpaceStateSW::collide_shape(RID p_shape, const Transform2D &
 	CollisionSolver2DSW::CallbackResult cbkres = NULL;
 
 	Physics2DServerSW::CollCbkData *cbkptr = NULL;
-	if (p_result_max > 0) {
-		cbkptr = &cbk;
-		cbkres = Physics2DServerSW::_shape_col_cbk;
-	}
+	cbkptr = &cbk;
+	cbkres = Physics2DServerSW::_shape_col_cbk;
 
 	for (int i = 0; i < amount; i++) {
 
@@ -353,7 +351,7 @@ bool Physics2DDirectSpaceStateSW::collide_shape(RID p_shape, const Transform2D &
 		cbk.valid_depth = 0;
 
 		if (CollisionSolver2DSW::solve(shape, p_shape_xform, p_motion, col_obj->get_shape(shape_idx), col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), Vector2(), cbkres, cbkptr, NULL, p_margin)) {
-			collided = p_result_max == 0 || cbk.amount > 0;
+			collided = cbk.amount > 0;
 		}
 	}
 

+ 2 - 2
servers/visual/visual_server_scene.cpp

@@ -1864,7 +1864,7 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca
 			//failure
 		} else if (ins->base_type == VS::INSTANCE_LIGHT && ins->visible) {
 
-			if (ins->visible && light_cull_count < MAX_LIGHTS_CULLED) {
+			if (light_cull_count < MAX_LIGHTS_CULLED) {
 
 				InstanceLightData *light = static_cast<InstanceLightData *>(ins->base_data);
 
@@ -1881,7 +1881,7 @@ void VisualServerScene::_prepare_scene(const Transform p_cam_transform, const Ca
 			}
 		} else if (ins->base_type == VS::INSTANCE_REFLECTION_PROBE && ins->visible) {
 
-			if (ins->visible && reflection_probe_cull_count < MAX_REFLECTION_PROBES_CULLED) {
+			if (reflection_probe_cull_count < MAX_REFLECTION_PROBES_CULLED) {
 
 				InstanceReflectionProbeData *reflection_probe = static_cast<InstanceReflectionProbeData *>(ins->base_data);