/* * Copyright (c) Contributors to the Open 3D Engine Project. * For complete copyright and license terms please see the LICENSE at the root of this distribution. * * SPDX-License-Identifier: Apache-2.0 OR MIT * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include AssetImporterDocument::AssetImporterDocument() { } bool AssetImporterDocument::LoadScene(const AZStd::string& sceneFullPath) { AZ_PROFILE_FUNCTION(Editor); namespace SceneEvents = AZ::SceneAPI::Events; SceneEvents::SceneSerializationBus::BroadcastResult(m_scene, &SceneEvents::SceneSerializationBus::Events::LoadScene, sceneFullPath, AZ::Uuid::CreateNull()); return !!m_scene; } void AssetImporterDocument::SaveScene(AZStd::shared_ptr& output, AZ::SaveCompleteCallback onSaveComplete) { if (!m_scene) { if (output) { output->AddError("No scene file was loaded."); } if (onSaveComplete) { onSaveComplete(false); } return; } m_saveRunner = AZStd::make_shared(); // Add a no-op saver to put the FBX into source control. The benefit of doing it this way // rather than invoking the SourceControlCommands bus directly is that we enable ourselves // to have a single callback point for fbx & the manifest. auto fbxNoOpSaver = m_saveRunner->GenerateController(); fbxNoOpSaver->AddSaveOperation(m_scene->GetSourceFilename(), nullptr); // Save the manifest SaveManifest(); m_saveRunner->Run(output, [this, onSaveComplete](bool success) { if (onSaveComplete) { onSaveComplete(success); } m_saveRunner = nullptr; }, AZ::AsyncSaveRunner::ControllerOrder::Sequential); } void AssetImporterDocument::ClearScene() { m_scene.reset(); } void AssetImporterDocument::SaveManifest() { // Create the save controller and add the save operation for the manifest job to it AZStd::shared_ptr saveController = m_saveRunner->GenerateController(); saveController->AddSaveOperation(m_scene->GetManifestFilename(), [this](const AZStd::string& fullPath, const AZStd::shared_ptr& actionOutput) -> bool { AZ_UNUSED(actionOutput); return m_scene->GetManifest().SaveToFile(fullPath.c_str()); }); } AZStd::shared_ptr& AssetImporterDocument::GetScene() { return m_scene; }