ronantakizawa/codereview-bench huggingface dataset:
Repository: godotengine/godot
File: core/math/geometry_2d.cpp (C++)

Code before:
		}

		idx++;
	}

	return decomp;
}

struct _AtlasWorkRect {
	Size2i s;
	Point2i p;
	int idx;
	_FORCE_INLINE_ bool operator<(const _AtlasWorkRect &p_r) const { return s.width > p_r.s.width; };
};

struct _AtlasWorkRectResult {
	Vector<_AtlasWorkRect> result;
	int max_w;
	int max_h;
};

void Geometry2D::make_atlas(const Vector<Size2i> &p_rects, Vector<Point2i> &r_result, Size2i &r_size) {
	// Super simple, almost brute force scanline stacking fitter.
	// It's pretty basic for now, but it tries to make sure that the aspect ratio of the
	// resulting atlas is somehow square. This is necessary because video cards have limits.
	// On texture size (usually 2048 or 4096), so the more square a texture, the more chances.
	// It will work in every hardware.
	// For example, it will prioritize a 1024x1024 atlas (works everywhere) instead of a
	// 256x8192 atlas (won't work anywhere).

	ERR_FAIL_COND(p_rects.size() == 0);
	for (int i = 0; i < p_rects.size(); i++) {
		ERR_FAIL_COND(p_rects[i].width <= 0);
		ERR_FAIL_COND(p_rects[i].height <= 0);
	}

	Vector<_AtlasWorkRect> wrects;
	wrects.resize(p_rects.size());
	for (int i = 0; i < p_rects.size(); i++) {
		wrects.write[i].s = p_rects[i];
		wrects.write[i].idx = i;
	}
	wrects.sort();
	int widest = wrects[0].s.width;

	Vector<_AtlasWorkRectResult> results;

	for (int i = 0; i <= 12; i++) {
		int w = 1 << i;
		int max_h = 0;
		int max_w = 0;

Review comment (suggestion):
The construct is "the more... the more...", so while "squarer" is correct, the second part should stay "the more chances ..." no?
https://www.macmillandictionary.com/dictionary/british/the-more-the-more-less

Code after:
		}

		idx++;
	}

	return decomp;
}

struct _AtlasWorkRect {
	Size2i s;
	Point2i p;
	int idx;
	_FORCE_INLINE_ bool operator<(const _AtlasWorkRect &p_r) const { return s.width > p_r.s.width; };
};

struct _AtlasWorkRectResult {
	Vector<_AtlasWorkRect> result;
	int max_w;
	int max_h;
};

void Geometry2D::make_atlas(const Vector<Size2i> &p_rects, Vector<Point2i> &r_result, Size2i &r_size) {
	// Super simple, almost brute force scanline stacking fitter.
	// It's pretty basic for now, but it tries to make sure that the aspect ratio of the
	// resulting atlas is somehow square. This is necessary because video cards have limits
	// on texture size (usually 2048 or 4096), so the squarer a texture, the more the chances
	// that it will work in every hardware.
	// For example, it will prioritize a 1024x1024 atlas (works everywhere) instead of a
	// 256x8192 atlas (won't work anywhere).

	ERR_FAIL_COND(p_rects.size() == 0);
	for (int i = 0; i < p_rects.size(); i++) {
		ERR_FAIL_COND(p_rects[i].width <= 0);
		ERR_FAIL_COND(p_rects[i].height <= 0);
	}

	Vector<_AtlasWorkRect> wrects;
	wrects.resize(p_rects.size());
	for (int i = 0; i < p_rects.size(); i++) {
		wrects.write[i].s = p_rects[i];
		wrects.write[i].idx = i;
	}
	wrects.sort();
	int widest = wrects[0].s.width;

	Vector<_AtlasWorkRectResult> results;

	for (int i = 0; i <= 12; i++) {
		int w = 1 << i;
		int max_h = 0;
		int max_w = 0;
Repository: godotengine/godot
File: editor/project_settings_editor.cpp (C++)

Code before:

	presets.insert("bptc");
	presets.insert("s3tc");
	presets.insert("etc");
	presets.insert("etc2");
	presets.insert("pvrtc");
	presets.insert("debug");
	presets.insert("release");
	presets.insert("editor");
	presets.insert("standalone");
	presets.insert("32");
	presets.insert("64");
	presets.insert("Server"); // Not available as an export platform yet, so it needs to be added manually

	EditorExport *ee = EditorExport::get_singleton();

	for (int i = 0; i < ee->get_export_platform_count(); i++) {
		List<String> p;
		ee->get_export_platform(i)->get_platform_features(&p);
		for (const String &E : p) {
			presets.insert(E);
		}
	}

	for (int i = 0; i < ee->get_export_preset_count(); i++) {
		List<String> p;
		ee->get_export_preset(i)->get_platform()->get_preset_features(ee->get_export_preset(i), &p);
		for (const String &E : p) {
			presets.insert(E);
		}

		String custom = ee->get_export_preset(i)->get_custom_features();
		Vector<String> custom_list = custom.split(",");
		for (int j = 0; j < custom_list.size(); j++) {
			String f = custom_list[j].strip_edges();
			if (f != String()) {
				presets.insert(f);
			}
		}
	}

	feature_box->clear();
	feature_box->add_item(TTR("(All)"), 0); // So it is always on top.
	int id = 1;
	for (Set<String>::Element *E = presets.front(); E; E = E->next()) {
		feature_box->add_item(E->get(), id++);
	}
}

void ProjectSettingsEditor::_editor_restart() {
	ProjectSettings::get_singleton()->save();

Review comment (suggestion):
This comes from the platform preset, no? So would `x11` even be present in the first place? I don't think this kind of compatibility code is needed here.

Code after:

	presets.insert("bptc");
	presets.insert("s3tc");
	presets.insert("etc");
	presets.insert("etc2");
	presets.insert("pvrtc");
	presets.insert("debug");
	presets.insert("release");
	presets.insert("editor");
	presets.insert("standalone");
	presets.insert("32");
	presets.insert("64");

	EditorExport *ee = EditorExport::get_singleton();

	for (int i = 0; i < ee->get_export_platform_count(); i++) {
		List<String> p;
		ee->get_export_platform(i)->get_platform_features(&p);
		for (const String &E : p) {
			presets.insert(E);
		}
	}

	for (int i = 0; i < ee->get_export_preset_count(); i++) {
		List<String> p;
		ee->get_export_preset(i)->get_platform()->get_preset_features(ee->get_export_preset(i), &p);
		for (const String &E : p) {
			presets.insert(E);
		}

		String custom = ee->get_export_preset(i)->get_custom_features();
		Vector<String> custom_list = custom.split(",");
		for (int j = 0; j < custom_list.size(); j++) {
			String f = custom_list[j].strip_edges();
			if (f != String()) {
				presets.insert(f);
			}
		}
	}

	feature_box->clear();
	feature_box->add_item(TTR("(All)"), 0); // So it is always on top.
	int id = 1;
	for (Set<String>::Element *E = presets.front(); E; E = E->next()) {
		feature_box->add_item(E->get(), id++);
	}
}

void ProjectSettingsEditor::_editor_restart() {
	ProjectSettings::get_singleton()->save();
	EditorNode::get_singleton()->save_all_scenes();
Repository: godotengine/godot
File: scene/gui/tree.cpp (C++)

Code before:
								icon_size_x = icon->get_width();
							} else {
								icon_size_x = icon_region.size.width;
							}
						}
						// Icon is treated as if it is outside of the rect so that double clicking on it will emit the item_double_clicked signal.
						if (rtl) {
							mpos.x = get_size().width - (mpos.x + icon_size_x);
						} else {
							mpos.x -= icon_size_x;
						}
						if (rect.has_point(mpos)) {
							if (!edit_selected()) {
								emit_signal(SNAME("item_double_clicked"));
							}
						} else {
							emit_signal(SNAME("item_double_clicked"));
						}
					}
					pressing_for_editor = false;
				}

				if (cache.click_type == Cache::CLICK_BUTTON && cache.click_item != nullptr) {
					// make sure in case of wrong reference after reconstructing whole TreeItems
					cache.click_item = get_item_at_position(cache.click_pos);
					emit_signal(SNAME("button_pressed"), cache.click_item, cache.click_column, cache.click_id);
				}
				cache.click_type = Cache::CLICK_NONE;
				cache.click_index = -1;
				cache.click_id = -1;
				cache.click_item = nullptr;
				cache.click_column = 0;

				if (drag_touching) {
					if (drag_speed == 0) {
						drag_touching_deaccel = false;
						drag_touching = false;
						set_physics_process_internal(false);
					} else {
						drag_touching_deaccel = true;
					}
				}
				update();
			}
			return;
		}

		if (range_drag_enabled) {
			return;
		}


Review comment (bug):
```suggestion
				// Make sure in case of wrong reference after reconstructing whole TreeItems.
```
(also the sentence is a bit unclear. Make sure what?)

Code after:
							mpos.x -= icon_size_x;
						}
						if (rect.has_point(mpos)) {
							if (!edit_selected()) {
								emit_signal(SNAME("item_double_clicked"));
							}
						} else {
							emit_signal(SNAME("item_double_clicked"));
						}
					}
					pressing_for_editor = false;
				}

				if (drag_touching) {
					if (drag_speed == 0) {
						drag_touching_deaccel = false;
						drag_touching = false;
						set_physics_process_internal(false);
					} else {
						drag_touching_deaccel = true;
					}
				}
			}

			if (cache.click_type == Cache::CLICK_BUTTON && cache.click_item != nullptr) {
				// make sure in case of wrong reference after reconstructing whole TreeItems
				cache.click_item = get_item_at_position(cache.click_pos);
				emit_signal("button_clicked", cache.click_item, cache.click_column, cache.click_id, mb->get_button_index());
			}

			cache.click_type = Cache::CLICK_NONE;
			cache.click_index = -1;
			cache.click_id = -1;
			cache.click_item = nullptr;
			cache.click_column = 0;
			update();
			return;
		}

		if (range_drag_enabled) {
			return;
		}

		switch (mb->get_button_index()) {
			case MouseButton::RIGHT:
			case MouseButton::LEFT: {
				Ref<StyleBox> bg = cache.bg;

				Point2 pos = mb->get_position();
				if (rtl) {
					pos.x = get_size().width - pos.x;
Repository: godotengine/godot
File: scene/gui/tree.cpp (C++)

Code before:
	}

	return ti;
}

TreeItem *Tree::get_root() const {
	return root;
}

TreeItem *Tree::get_last_item() const {
	TreeItem *last = root;

	while (last) {
		if (last->next) {
			last = last->next;
		} else if (last->first_child) {
			last = last->first_child;
		} else {
			break;
		}
	}

	return last;
}

void Tree::item_edited(int p_column, TreeItem *p_item, bool p_lmb) {
	edited_item = p_item;
	edited_col = p_column;
	if (p_item != nullptr && p_column >= 0 && p_column < p_item->cells.size()) {
		edited_item->cells.write[p_column].dirty = true;
	}
	if (p_lmb) {
		emit_signal(SNAME("item_edited"));
	} else {
		emit_signal(SNAME("item_rmb_edited"));
	}
}

void Tree::item_changed(int p_column, TreeItem *p_item) {
	if (p_item != nullptr && p_column >= 0 && p_column < p_item->cells.size()) {
		p_item->cells.write[p_column].dirty = true;
	}
	update();
}

void Tree::item_selected(int p_column, TreeItem *p_item) {
	if (select_mode == SELECT_MULTI) {
		if (!p_item->cells[p_column].selectable) {
			return;
		}


Review comment (suggestion):
From the old code it seems like both signals were for mouse clicks, `p_lmb` was just for the left click. It's ok to divide it like that, but the method doesn't properly get the mouse buttons (e.g. clicking a checkable item doesn't emit the mouse clicked signal, because it calls `item_edited()` without the last argument).

Code after:
	TreeItem *last = root;

	while (last) {
		if (last->next) {
			last = last->next;
		} else if (last->first_child) {
			last = last->first_child;
		} else {
			break;
		}
	}

	return last;
}

void Tree::item_edited(int p_column, TreeItem *p_item, MouseButton p_mouse_index) {
	edited_item = p_item;
	edited_col = p_column;
	if (p_item != nullptr && p_column >= 0 && p_column < p_item->cells.size()) {
		edited_item->cells.write[p_column].dirty = true;
	}
	if (p_mouse_index == MouseButton::NONE) {
		emit_signal(SNAME("item_edited"));
	} else {
		emit_signal(SNAME("custom_item_clicked"), p_mouse_index);
	}
}

void Tree::item_changed(int p_column, TreeItem *p_item) {
	if (p_item != nullptr && p_column >= 0 && p_column < p_item->cells.size()) {
		p_item->cells.write[p_column].dirty = true;
	}
	update();
}

void Tree::item_selected(int p_column, TreeItem *p_item) {
	if (select_mode == SELECT_MULTI) {
		if (!p_item->cells[p_column].selectable) {
			return;
		}

		p_item->cells.write[p_column].selected = true;
		//emit_signal(SNAME("multi_selected"),p_item,p_column,true); - NO this is for TreeItem::select

		selected_col = p_column;
		if (!selected_item) {
			selected_item = p_item;
		}
	} else {
		select_single_item(p_item, root, p_column);
	}
Repository: godotengine/godot
File: modules/visual_script/visual_script_editor.cpp (C++)

Code before:
	script->add_function(p_function, fn_id);
	script->add_node(fn_id, func);

	_update_members();
	_update_graph();

	_center_on_node(script->get_function_node_id(p_function));
}

bool VisualScriptEditor::show_members_overview() {
	return false;
}

void VisualScriptEditor::update_settings() {
	_update_graph();
}

void VisualScriptEditor::set_debugger_active(bool p_active) {
	if (!p_active) {
		error_line = -1;
		_update_graph(); //clear line break
	}
}

void VisualScriptEditor::set_tooltip_request_func(String p_method, Object *p_obj) {
}

Control *VisualScriptEditor::get_edit_menu() {
	return edit_menu;
}

void VisualScriptEditor::_change_base_type() {
	select_base_type->popup_create(true, true);
}

void VisualScriptEditor::_toggle_tool_script() {
	script->set_tool_enabled(!script->is_tool());
}

void VisualScriptEditor::clear_edit_menu() {
	memdelete(edit_menu);
	memdelete(members_section);
}

void VisualScriptEditor::_change_base_type_callback() {
	String bt = select_base_type->get_selected_type();

	ERR_FAIL_COND(bt == String());
	undo_redo->create_action(TTR("Change Base Type"));
	undo_redo->add_do_method(script.ptr(), "set_instance_base_type", bt);
	undo_redo->add_undo_method(script.ptr(), "set_instance_base_type", script->get_instance_base_type());

Review comment (suggestion):
Compiler require to override this but I never touch `Visual Script` before, so I don't know what to return.

Code after:
	script->add_function(p_function, fn_id);
	script->add_node(fn_id, func);

	_update_members();
	_update_graph();

	_center_on_node(script->get_function_node_id(p_function));
}

bool VisualScriptEditor::show_members_overview() {
	return false;
}

void VisualScriptEditor::update_settings() {
	_update_graph();
}

void VisualScriptEditor::set_debugger_active(bool p_active) {
	if (!p_active) {
		error_line = -1;
		_update_graph(); //clear line break
	}
}

Control *VisualScriptEditor::get_base_editor() const {
	return graph;
}

void VisualScriptEditor::set_tooltip_request_func(String p_method, Object *p_obj) {
}

Control *VisualScriptEditor::get_edit_menu() {
	return edit_menu;
}

void VisualScriptEditor::_change_base_type() {
	select_base_type->popup_create(true, true);
}

void VisualScriptEditor::_toggle_tool_script() {
	script->set_tool_enabled(!script->is_tool());
}

void VisualScriptEditor::clear_edit_menu() {
	memdelete(edit_menu);
	memdelete(members_section);
}

void VisualScriptEditor::_change_base_type_callback() {
	String bt = select_base_type->get_selected_type();
Repository: godotengine/godot
File: editor/plugins/material_editor_plugin.cpp (C++)

Code before:
				layout_2d->hide();
				layout_3d->show();
				vc->show();
				sphere_instance->set_material_override(material);
				box_instance->set_material_override(material);
				break;
			default:
				break;
		}
	} else {
		hide();
	}
}

void MaterialEditor::_button_pressed(Node *p_button) {
	if (p_button == light_1_switch) {
		light1->set_visible(!light_1_switch->is_pressed());
	}

	if (p_button == light_2_switch) {
		light2->set_visible(!light_2_switch->is_pressed());
	}

	if (p_button == box_switch) {
		box_instance->show();
		sphere_instance->hide();
		box_switch->set_pressed(true);
		sphere_switch->set_pressed(false);
		EditorSettings::get_singleton()->set_project_metadata("inspector_options", "material_preview_on_sphere", false);
	}

	if (p_button == sphere_switch) {
		box_instance->hide();
		sphere_instance->show();
		box_switch->set_pressed(false);
		sphere_switch->set_pressed(true);
		EditorSettings::get_singleton()->set_project_metadata("inspector_options", "material_preview_on_sphere", true);
	}
}

void MaterialEditor::_bind_methods() {
}

MaterialEditor::MaterialEditor() {
	// canvas item

	layout_2d = memnew(HBoxContainer);
	layout_2d->set_alignment(BoxContainer::ALIGNMENT_CENTER);
	add_child(layout_2d);
	layout_2d->set_anchors_and_offsets_preset(PRESET_FULL_RECT);


Review comment (suggestion):
I don't understand the purpose of these lines. I replaced all 18 of these lines with just this, and it works perfectly fine:

```suggestion
	box_instance->set_transform(Transform3D(Basis() * 0.25));
	sphere_instance->set_transform(Transform3D(Basis() * 0.375));
```

Also, I opened #49638, if that gets merged then we can shorten this further to `Transform3D() * 0.375` etc.

Code after:
void MaterialEditor::_update_rotation() {
	Transform3D t;
	t.basis.rotate(Vector3(0, 1, 0), -rot.y);
	t.basis.rotate(Vector3(1, 0, 0), -rot.x);
	rotation->set_transform(t);
}

void MaterialEditor::edit(Ref<Material> p_material, const Ref<Environment> &p_env) {
	material = p_material;
	camera->set_environment(p_env);
	if (!material.is_null()) {
		Shader::Mode mode = p_material->get_shader_mode();
		switch (mode) {
			case Shader::MODE_CANVAS_ITEM:
				layout_3d->hide();
				layout_2d->show();
				vc->hide();
				rect_instance->set_material(material);
				break;
			case Shader::MODE_SPATIAL:
				layout_2d->hide();
				layout_3d->show();
				vc->show();
				sphere_instance->set_material_override(material);
				box_instance->set_material_override(material);
				break;
			default:
				break;
		}
	} else {
		hide();
	}

	rot.x = Math::deg_to_rad(-15.0);
	rot.y = Math::deg_to_rad(30.0);
	_update_rotation();
}

void MaterialEditor::_button_pressed(Node *p_button) {
	if (p_button == light_1_switch) {
		light1->set_visible(!light_1_switch->is_pressed());
	}

	if (p_button == light_2_switch) {
		light2->set_visible(!light_2_switch->is_pressed());
	}

	if (p_button == box_switch) {
		box_instance->show();
		sphere_instance->hide();
		box_switch->set_pressed(true);
Repository: godotengine/godot
File: editor/plugins/material_editor_plugin.cpp (C++)

Code before:

void MaterialEditor::_button_pressed(Node *p_button) {
	if (p_button == light_1_switch) {
		light1->set_visible(!light_1_switch->is_pressed());
	}

	if (p_button == light_2_switch) {
		light2->set_visible(!light_2_switch->is_pressed());
	}

	if (p_button == box_switch) {
		box_instance->show();
		sphere_instance->hide();
		box_switch->set_pressed(true);
		sphere_switch->set_pressed(false);
		EditorSettings::get_singleton()->set_project_metadata("inspector_options", "material_preview_on_sphere", false);
	}

	if (p_button == sphere_switch) {
		box_instance->hide();
		sphere_instance->show();
		box_switch->set_pressed(false);
		sphere_switch->set_pressed(true);
		EditorSettings::get_singleton()->set_project_metadata("inspector_options", "material_preview_on_sphere", true);
	}
}

void MaterialEditor::_bind_methods() {
}

MaterialEditor::MaterialEditor() {
	// canvas item

	layout_2d = memnew(HBoxContainer);
	layout_2d->set_alignment(BoxContainer::ALIGNMENT_CENTER);
	add_child(layout_2d);
	layout_2d->set_anchors_and_offsets_preset(PRESET_FULL_RECT);

	rect_instance = memnew(ColorRect);
	layout_2d->add_child(rect_instance);
	rect_instance->set_custom_minimum_size(Size2(150, 150) * EDSCALE);

	layout_2d->set_visible(false);

	// spatial

	vc = memnew(SubViewportContainer);
	vc->set_stretch(true);
	add_child(vc);
	vc->set_anchors_and_offsets_preset(PRESET_FULL_RECT);
	viewport = memnew(SubViewport);

Review comment (suggestion):
Move these two lines to where `Transform3D box_xform;` is in the constructor, and remove box_xform. These only need to be set once, so we should put them in the constructor, and they make all the box_xform code irrelevant since these lines override it.

Code after:
			case Shader::MODE_CANVAS_ITEM:
				layout_3d->hide();
				layout_2d->show();
				vc->hide();
				rect_instance->set_material(material);
				break;
			case Shader::MODE_SPATIAL:
				layout_2d->hide();
				layout_3d->show();
				vc->show();
				sphere_instance->set_material_override(material);
				box_instance->set_material_override(material);
				break;
			default:
				break;
		}
	} else {
		hide();
	}

	rot.x = Math::deg_to_rad(-15.0);
	rot.y = Math::deg_to_rad(30.0);
	_update_rotation();
}

void MaterialEditor::_button_pressed(Node *p_button) {
	if (p_button == light_1_switch) {
		light1->set_visible(!light_1_switch->is_pressed());
	}

	if (p_button == light_2_switch) {
		light2->set_visible(!light_2_switch->is_pressed());
	}

	if (p_button == box_switch) {
		box_instance->show();
		sphere_instance->hide();
		box_switch->set_pressed(true);
		sphere_switch->set_pressed(false);
		EditorSettings::get_singleton()->set_project_metadata("inspector_options", "material_preview_on_sphere", false);
	}

	if (p_button == sphere_switch) {
		box_instance->hide();
		sphere_instance->show();
		box_switch->set_pressed(false);
		sphere_switch->set_pressed(true);
		EditorSettings::get_singleton()->set_project_metadata("inspector_options", "material_preview_on_sphere", true);
	}
}
Repository: godotengine/godot
File: modules/visual_script/visual_script_editor.cpp (C++)

Code before:
		undo_redo->commit_action();
		return;
	}

	Ref<VisualScriptNode> vnode;
	Ref<VisualScriptPropertySet> script_prop_set;

	if (p_category == String("method")) {
		Ref<VisualScriptFunctionCall> n;
		n.instantiate();
		vnode = n;
	} else if (p_category == String("set")) {
		Ref<VisualScriptPropertySet> n;
		n.instantiate();
		vnode = n;
		script_prop_set = n;
	} else if (p_category == String("get")) {
		Ref<VisualScriptPropertyGet> n;
		n.instantiate();
		n->set_property(p_text);
		vnode = n;
	}

	if (p_category == String("action")) {
		if (p_text == "VisualScriptCondition") {
			Ref<VisualScriptCondition> n;
			n.instantiate();
			vnode = n;
		}
		if (p_text == "VisualScriptSwitch") {
			Ref<VisualScriptSwitch> n;
			n.instantiate();
			vnode = n;
		} else if (p_text == "VisualScriptSequence") {
			Ref<VisualScriptSequence> n;
			n.instantiate();
			vnode = n;
		} else if (p_text == "VisualScriptIterator") {
			Ref<VisualScriptIterator> n;
			n.instantiate();
			vnode = n;
		} else if (p_text == "VisualScriptWhile") {
			Ref<VisualScriptWhile> n;
			n.instantiate();
			vnode = n;
		} else if (p_text == "VisualScriptReturn") {
			Ref<VisualScriptReturn> n;
			n.instantiate();
			vnode = n;
		}
	}

Review comment (bug):
Minor:

`NULL` usage is inconsistent with `nullptr`.

Code after:
			}
		}
		vnode = n;
		script_prop_set = n;
	} else if (p_category == String("get")) {
		Ref<VisualScriptPropertyGet> n;
		n.instantiate();
		n->set_property(p_text);
		if (!drop_path.is_empty()) {
			if (drop_path == ".") {
				n->set_call_mode(VisualScriptPropertyGet::CALL_MODE_SELF);
			} else {
				n->set_call_mode(VisualScriptPropertyGet::CALL_MODE_NODE_PATH);
				n->set_base_path(drop_path);
			}
		}
		if (drop_node) {
			n->set_base_type(drop_node->get_class());
			if (drop_node->get_script_instance()) {
				n->set_base_script(drop_node->get_script_instance()->get_script()->get_path());
			}
		}
		vnode = n;
	}
	drop_path = String();
	drop_node = nullptr;

	if (p_category == String("action")) {
		if (p_text == "VisualScriptCondition") {
			Ref<VisualScriptCondition> n;
			n.instantiate();
			vnode = n;
		}
		if (p_text == "VisualScriptSwitch") {
			Ref<VisualScriptSwitch> n;
			n.instantiate();
			vnode = n;
		} else if (p_text == "VisualScriptSequence") {
			Ref<VisualScriptSequence> n;
			n.instantiate();
			vnode = n;
		} else if (p_text == "VisualScriptIterator") {
			Ref<VisualScriptIterator> n;
			n.instantiate();
			vnode = n;
		} else if (p_text == "VisualScriptWhile") {
			Ref<VisualScriptWhile> n;
			n.instantiate();
			vnode = n;
		} else if (p_text == "VisualScriptReturn") {
			Ref<VisualScriptReturn> n;