Repository: godotengine/godot
File: editor/import/3d/resource_importer_scene.cpp (C++)

Code before:
		return nullptr;
	}

	{
		//make sure this is unique
		node_settings = node_settings.duplicate(true);
		//fill node settings for this node with default values
		List<ImportOption> iopts;
		if (Object::cast_to<ImporterMeshInstance3D>(p_node)) {
			get_internal_import_options(INTERNAL_IMPORT_CATEGORY_MESH_3D_NODE, &iopts);
		} else if (Object::cast_to<AnimationPlayer>(p_node)) {
			get_internal_import_options(INTERNAL_IMPORT_CATEGORY_ANIMATION_NODE, &iopts);
		} else if (Object::cast_to<Skeleton3D>(p_node)) {
			get_internal_import_options(INTERNAL_IMPORT_CATEGORY_SKELETON_3D_NODE, &iopts);
		} else {
			get_internal_import_options(INTERNAL_IMPORT_CATEGORY_NODE, &iopts);
		}
		for (const ImportOption &E : iopts) {
			if (!node_settings.has(E.option.name)) {
				node_settings[E.option.name] = E.default_value;
			}
		}
	}

	{
		ObjectID node_id = p_node->get_instance_id();
		for (int i = 0; i < post_importer_plugins.size(); i++) {
			post_importer_plugins.write[i]->internal_process(EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_NODE, p_root, p_node, Ref<Resource>(), node_settings);
			if (ObjectDB::get_instance(node_id) == nullptr) { //may have been erased, so do not continue
				break;
			}
		}
	}

	if (Object::cast_to<ImporterMeshInstance3D>(p_node)) {
		ObjectID node_id = p_node->get_instance_id();
		for (int i = 0; i < post_importer_plugins.size(); i++) {
			post_importer_plugins.write[i]->internal_process(EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_MESH_3D_NODE, p_root, p_node, Ref<Resource>(), node_settings);
			if (ObjectDB::get_instance(node_id) == nullptr) { //may have been erased, so do not continue
				break;
			}
		}
	}

	if (Object::cast_to<Skeleton3D>(p_node)) {
		ObjectID node_id = p_node->get_instance_id();
		for (int i = 0; i < post_importer_plugins.size(); i++) {
			post_importer_plugins.write[i]->internal_process(EditorScenePostImportPlugin::INTERNAL_IMPORT_CATEGORY_SKELETON_3D_NODE, p_root, p_node, Ref<Resource>(), node_settings);
			if (ObjectDB::get_instance(node_id) == nullptr) { //may have been erased, so do not continue
				break;
			}

Review comment (suggestion):
```suggestion
					if (skeleton_bone == StringName()) {
```

Code after:
				}
			} else if (int(node_settings["rest_pose/load_pose"]) == 2) {
				Object *external_object = node_settings.get("rest_pose/external_animation_library", Variant());
				rest_animation = external_object;
				if (rest_animation.is_null()) {
					Ref<AnimationLibrary> library(external_object);
					if (library.is_valid()) {
						List<StringName> anim_list;
						library->get_animation_list(&anim_list);
						if (anim_list.size() == 1) {
							selected_animation_name = String(anim_list[0]);
						}
						rest_animation = library->get_animation(selected_animation_name);
					}
				}
			}
			rest_animation_timestamp = double(node_settings.get("rest_pose/selected_timestamp", 0.0));
			if (rest_animation.is_valid()) {
				for (int track_i = 0; track_i < rest_animation->get_track_count(); track_i++) {
					NodePath path = rest_animation->track_get_path(track_i);
					StringName node_path = path.get_concatenated_names();
					if (String(node_path).begins_with("%")) {
						continue; // Unique node names are commonly used with retargeted animations, which we do not want to use.
					}
					StringName skeleton_bone = path.get_concatenated_subnames();
					if (skeleton_bone == StringName()) {
						continue;
					}
					int bone_idx = skeleton->find_bone(skeleton_bone);
					if (bone_idx == -1) {
						continue;
					}
					switch (rest_animation->track_get_type(track_i)) {
						case Animation::TYPE_POSITION_3D: {
							Vector3 bone_position = rest_animation->position_track_interpolate(track_i, rest_animation_timestamp);
							skeleton->set_bone_rest(bone_idx, Transform3D(skeleton->get_bone_rest(bone_idx).basis, bone_position));
						} break;
						case Animation::TYPE_ROTATION_3D: {
							Quaternion bone_rotation = rest_animation->rotation_track_interpolate(track_i, rest_animation_timestamp);
							Transform3D current_rest = skeleton->get_bone_rest(bone_idx);
							skeleton->set_bone_rest(bone_idx, Transform3D(Basis(bone_rotation).scaled(current_rest.basis.get_scale()), current_rest.origin));
						} break;
						default:
							break;
					}
				}
			}
		}

		ObjectID node_id = p_node->get_instance_id();
		for (int i = 0; i < post_importer_plugins.size(); i++) {