Repository: godotengine/godot
File: editor/import/scene_import_settings.cpp (C++)

Code before:
	mesh_tree->clear();

	//hidden roots
	material_tree->create_item();
	mesh_tree->create_item();

	_fill_scene(scene, nullptr);
}

void SceneImportSettings::_update_view_gizmos() {
	for (const KeyValue<String, NodeData> &e : node_map) {
		bool generate_collider = false;
		if (e.value.settings.has(SNAME("generate/physics"))) {
			generate_collider = e.value.settings[SNAME("generate/physics")];
		}

		MeshInstance3D *mesh_node = Object::cast_to<MeshInstance3D>(e.value.node);
		if (mesh_node == nullptr || mesh_node->get_mesh().is_null()) {
			// Nothing to do
			continue;
		}

		MeshInstance3D *collider_view = static_cast<MeshInstance3D *>(mesh_node->find_node("collider_view"));
		CRASH_COND_MSG(collider_view == nullptr, "This is unreachable, since the collider view is always created even when the collision is not used! If this is triggered there is a bug on the function `_fill_scene`.");

		collider_view->set_visible(generate_collider);
		if (generate_collider) {
			// This collider_view doesn't have a mesh so we need to generate a new one.

			// Generate the mesh collider.
			Vector<Ref<Shape3D>> shapes = ResourceImporterScene::get_collision_shapes(mesh_node->get_mesh(), e.value.settings);
			const Transform3D transform = ResourceImporterScene::get_collision_shapes_transform(e.value.settings);

			Ref<ArrayMesh> collider_view_mesh;
			collider_view_mesh.instantiate();
			for (Ref<Shape3D> shape : shapes) {
				Ref<ArrayMesh> debug_shape_mesh;
				if (shape.is_valid()) {
					debug_shape_mesh = shape->get_debug_mesh();
				}
				if (debug_shape_mesh.is_valid()) {
					collider_view_mesh->add_surface_from_arrays(
							debug_shape_mesh->surface_get_primitive_type(0),
							debug_shape_mesh->surface_get_arrays(0));

					collider_view_mesh->surface_set_material(
							collider_view_mesh->get_surface_count() - 1,
							collider_mat);
				}
			}


Review comment (suggestion):
`operator Node *()` was removed in #57205, but you can use `operator Object *()` which should work fine too.

Code after:
	mesh_tree->clear();

	//hidden roots
	material_tree->create_item();
	mesh_tree->create_item();

	_fill_scene(scene, nullptr);
}

void SceneImportSettings::_update_view_gizmos() {
	for (const KeyValue<String, NodeData> &e : node_map) {
		bool generate_collider = false;
		if (e.value.settings.has(SNAME("generate/physics"))) {
			generate_collider = e.value.settings[SNAME("generate/physics")];
		}

		MeshInstance3D *mesh_node = Object::cast_to<MeshInstance3D>(e.value.node);
		if (mesh_node == nullptr || mesh_node->get_mesh().is_null()) {
			// Nothing to do
			continue;
		}

		TypedArray<Node> descendants = mesh_node->find_nodes("collider_view", "MeshInstance3D");
		CRASH_COND_MSG(descendants.is_empty(), "This is unreachable, since the collider view is always created even when the collision is not used! If this is triggered there is a bug on the function `_fill_scene`.");

		MeshInstance3D *collider_view = static_cast<MeshInstance3D *>(descendants[0].operator Object *());
		collider_view->set_visible(generate_collider);
		if (generate_collider) {
			// This collider_view doesn't have a mesh so we need to generate a new one.

			// Generate the mesh collider.
			Vector<Ref<Shape3D>> shapes = ResourceImporterScene::get_collision_shapes(mesh_node->get_mesh(), e.value.settings);
			const Transform3D transform = ResourceImporterScene::get_collision_shapes_transform(e.value.settings);

			Ref<ArrayMesh> collider_view_mesh;
			collider_view_mesh.instantiate();
			for (Ref<Shape3D> shape : shapes) {
				Ref<ArrayMesh> debug_shape_mesh;
				if (shape.is_valid()) {
					debug_shape_mesh = shape->get_debug_mesh();
				}
				if (debug_shape_mesh.is_valid()) {
					collider_view_mesh->add_surface_from_arrays(
							debug_shape_mesh->surface_get_primitive_type(0),
							debug_shape_mesh->surface_get_arrays(0));

					collider_view_mesh->surface_set_material(
							collider_view_mesh->get_surface_count() - 1,
							collider_mat);
				}
			}