Repository: godotengine/godot
File: editor/plugins/mesh_instance_3d_editor_plugin.cpp (C++)

Code before:
#include "scene/3d/navigation_region_3d.h"
#include "scene/3d/physics/collision_shape_3d.h"
#include "scene/3d/physics/physics_body_3d.h"
#include "scene/3d/physics/static_body_3d.h"
#include "scene/gui/box_container.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/menu_button.h"
#include "scene/gui/spin_box.h"
#include "scene/resources/3d/concave_polygon_shape_3d.h"
#include "scene/resources/3d/convex_polygon_shape_3d.h"
#include "scene/resources/3d/primitive_meshes.h"
#include "scene/scene_string_names.h"

void MeshInstance3DEditor::_node_removed(Node *p_node) {
	if (p_node == node) {
		node = nullptr;
		options->hide();
	}
}

void MeshInstance3DEditor::edit(MeshInstance3D *p_mesh) {
	node = p_mesh;
}

void MeshInstance3DEditor::_menu_option(int p_option) {
	Ref<Mesh> mesh = node->get_mesh();
	if (mesh.is_null()) {
		err_dialog->set_text(TTR("Mesh is empty!"));
		err_dialog->popup_centered();
		return;
	}

	switch (p_option) {
		case MENU_OPTION_CREATE_STATIC_TRIMESH_BODY: {
			EditorSelection *editor_selection = EditorNode::get_singleton()->get_editor_selection();
			EditorUndoRedoManager *ur = EditorUndoRedoManager::get_singleton();

			List<Node *> selection = editor_selection->get_selected_node_list();

			if (selection.is_empty()) {
				Ref<ConcavePolygonShape3D> shape = mesh->create_trimesh_shape();
				if (shape.is_null()) {
					err_dialog->set_text(TTR("Couldn't create a Trimesh collision shape."));
					err_dialog->popup_centered();
					return;
				}

				CollisionShape3D *cshape = memnew(CollisionShape3D);
				cshape->set_shape(shape);
				StaticBody3D *body = memnew(StaticBody3D);
				body->add_child(cshape, true);

Review comment (suggestion):
```suggestion
	Vector<Ref<Shape3D>> shapes;
```
Redundant 

Code after:
#include "scene/3d/navigation_region_3d.h"
#include "scene/3d/physics/collision_shape_3d.h"
#include "scene/3d/physics/physics_body_3d.h"
#include "scene/3d/physics/static_body_3d.h"
#include "scene/gui/box_container.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/menu_button.h"
#include "scene/gui/spin_box.h"
#include "scene/resources/3d/concave_polygon_shape_3d.h"
#include "scene/resources/3d/convex_polygon_shape_3d.h"
#include "scene/resources/3d/primitive_meshes.h"
#include "scene/scene_string_names.h"

void MeshInstance3DEditor::_node_removed(Node *p_node) {
	if (p_node == node) {
		node = nullptr;
		options->hide();
	}
}

void MeshInstance3DEditor::edit(MeshInstance3D *p_mesh) {
	node = p_mesh;
}

Vector<Ref<Shape3D>> MeshInstance3DEditor::create_shape_from_mesh(Ref<Mesh> p_mesh, int p_option, bool p_verbose) {
	Vector<Ref<Shape3D>> shapes;
	switch (p_option) {
		case SHAPE_TYPE_TRIMESH: {
			shapes.push_back(p_mesh->create_trimesh_shape());

			if (p_verbose && shapes.is_empty()) {
				err_dialog->set_text(TTR("Couldn't create a Trimesh collision shape."));
				err_dialog->popup_centered();
			}
		} break;

		case SHAPE_TYPE_SINGLE_CONVEX: {
			shapes.push_back(p_mesh->create_convex_shape(true, false));

			if (p_verbose && shapes.is_empty()) {
				err_dialog->set_text(TTR("Couldn't create a single collision shape."));
				err_dialog->popup_centered();
			}
		} break;

		case SHAPE_TYPE_SIMPLIFIED_CONVEX: {
			shapes.push_back(p_mesh->create_convex_shape(true, true));

			if (p_verbose && shapes.is_empty()) {
				err_dialog->set_text(TTR("Couldn't create a simplified collision shape."));
				err_dialog->popup_centered();