From 8ed29d5a0c8cabee74184b1d7075f439f12c85c9 Mon Sep 17 00:00:00 2001 From: Jeremy Ong Date: Mon, 25 Oct 2021 12:17:28 -0600 Subject: [PATCH 01/70] Enable lifetime tethering of the AP by default After this change, the AssetProcessor process will be torn down by default after its parent process shuts down (if it was spawned by a parent process). Signed-off-by: Jeremy Ong --- .../AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp b/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp index a3782ae081..2e2014df10 100644 --- a/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp +++ b/Code/Framework/AzFramework/Platform/Windows/AzFramework/Asset/AssetSystemComponentHelper_Windows.cpp @@ -14,7 +14,7 @@ #include -AZ_CVAR(bool, ap_tether_lifetime, false, nullptr, AZ::ConsoleFunctorFlags::Null, +AZ_CVAR(bool, ap_tether_lifetime, true, nullptr, AZ::ConsoleFunctorFlags::Null, "If enabled, a parent process that launches the AP will terminate the AP on exit"); namespace AzFramework::AssetSystem::Platform From 15237af23c6637514ebc378bba4fcef7bde6bca5 Mon Sep 17 00:00:00 2001 From: nggieber <52797929+AMZN-nggieber@users.noreply.github.com> Date: Mon, 6 Dec 2021 09:22:03 -0800 Subject: [PATCH 02/70] Refactored ProjectManagerSettings, added tests, changed project built successful to be tracked by project path, added project ids, changed project settings path to use project id and name Signed-off-by: nggieber <52797929+AMZN-nggieber@users.noreply.github.com> --- AutomatedTesting/project.json | 6 +- Code/Tools/ProjectManager/CMakeLists.txt | 3 + .../Source/ExternalLinkDialog.cpp | 10 +- .../Source/GemCatalog/GemInfo.h | 1 - .../ProjectManager/Source/LinkWidget.cpp | 8 +- .../Source/NewProjectSettingsScreen.cpp | 14 +- .../Source/NewProjectSettingsScreen.h | 1 + .../Source/ProjectBuilderController.cpp | 26 +- .../ProjectManager/Source/ProjectInfo.cpp | 10 +- .../Tools/ProjectManager/Source/ProjectInfo.h | 3 +- .../Source/ProjectManagerSettings.cpp | 257 +++++++++++++++--- .../Source/ProjectManagerSettings.h | 27 +- .../Source/ProjectSettingsScreen.cpp | 27 +- .../Source/ProjectSettingsScreen.h | 3 + .../ProjectManager/Source/ProjectsScreen.cpp | 8 +- .../ProjectManager/Source/PythonBindings.cpp | 22 +- .../Source/UpdateProjectCtrl.cpp | 16 +- .../Source/UpdateProjectSettingsScreen.cpp | 4 +- .../project_manager_tests_files.cmake | 3 +- .../tests/ProjectManagerSettingsTests.cpp | 176 ++++++++++++ .../DefaultProject/Template/project.json | 1 + .../MinimalProject/Template/project.json | 1 + q | 48 ++++ scripts/o3de/o3de/engine_template.py | 22 +- scripts/o3de/o3de/project_properties.py | 13 +- scripts/o3de/o3de/register.py | 2 +- scripts/o3de/o3de/validation.py | 17 +- .../tests/unit_test_project_properties.py | 25 +- 28 files changed, 622 insertions(+), 132 deletions(-) create mode 100644 Code/Tools/ProjectManager/tests/ProjectManagerSettingsTests.cpp create mode 100644 q diff --git a/AutomatedTesting/project.json b/AutomatedTesting/project.json index 5ee4ee68f8..9222777ef3 100644 --- a/AutomatedTesting/project.json +++ b/AutomatedTesting/project.json @@ -10,5 +10,7 @@ "version_name": "1.0.0.0", "orientation": "landscape" }, - "engine": "o3de" -} \ No newline at end of file + "engine": "o3de", + "display_name": "AutomatedTesting", + "icon_path": "preview.png" +} diff --git a/Code/Tools/ProjectManager/CMakeLists.txt b/Code/Tools/ProjectManager/CMakeLists.txt index 9974125ffb..b0e7ee9697 100644 --- a/Code/Tools/ProjectManager/CMakeLists.txt +++ b/Code/Tools/ProjectManager/CMakeLists.txt @@ -89,6 +89,9 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED) 3rdParty::Qt::Widgets 3rdParty::Python 3rdParty::pybind11 + AZ::AzCore + AZ::AzCoreTestCommon + AZ::AzTestShared AZ::AzTest AZ::AzFramework AZ::AzFrameworkTestShared diff --git a/Code/Tools/ProjectManager/Source/ExternalLinkDialog.cpp b/Code/Tools/ProjectManager/Source/ExternalLinkDialog.cpp index 122a5cbf5a..2f3d615863 100644 --- a/Code/Tools/ProjectManager/Source/ExternalLinkDialog.cpp +++ b/Code/Tools/ProjectManager/Source/ExternalLinkDialog.cpp @@ -10,8 +10,6 @@ #include #include -#include - #include #include #include @@ -87,12 +85,6 @@ namespace O3DE::ProjectManager void ExternalLinkDialog::SetSkipDialogSetting(bool state) { - auto settingsRegistry = AZ::SettingsRegistry::Get(); - if (settingsRegistry) - { - QString settingsKey = GetExternalLinkWarningKey(); - settingsRegistry->Set(settingsKey.toStdString().c_str(), state); - SaveProjectManagerSettings(); - } + PMSettings::SetProjectManagerKey(PMSettings::GetExternalLinkWarningKey(), state); } } // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/GemCatalog/GemInfo.h b/Code/Tools/ProjectManager/Source/GemCatalog/GemInfo.h index 23e95cf487..264971428a 100644 --- a/Code/Tools/ProjectManager/Source/GemCatalog/GemInfo.h +++ b/Code/Tools/ProjectManager/Source/GemCatalog/GemInfo.h @@ -9,7 +9,6 @@ #pragma once #if !defined(Q_MOC_RUN) -#include #include #include #include diff --git a/Code/Tools/ProjectManager/Source/LinkWidget.cpp b/Code/Tools/ProjectManager/Source/LinkWidget.cpp index f25e38db67..87ccdb9aed 100644 --- a/Code/Tools/ProjectManager/Source/LinkWidget.cpp +++ b/Code/Tools/ProjectManager/Source/LinkWidget.cpp @@ -33,13 +33,7 @@ namespace O3DE::ProjectManager { // Check if user request not to be shown external link warning dialog bool skipDialog = false; - auto settingsRegistry = AZ::SettingsRegistry::Get(); - - if (settingsRegistry) - { - QString settingsKey = GetExternalLinkWarningKey(); - settingsRegistry->Get(skipDialog, settingsKey.toStdString().c_str()); - } + PMSettings::GetProjectManagerKey(skipDialog, PMSettings::GetExternalLinkWarningKey()); if (!skipDialog) { diff --git a/Code/Tools/ProjectManager/Source/NewProjectSettingsScreen.cpp b/Code/Tools/ProjectManager/Source/NewProjectSettingsScreen.cpp index 4febb65782..4c306fc715 100644 --- a/Code/Tools/ProjectManager/Source/NewProjectSettingsScreen.cpp +++ b/Code/Tools/ProjectManager/Source/NewProjectSettingsScreen.cpp @@ -16,6 +16,8 @@ #include #include #include + +#include #include #include @@ -41,9 +43,11 @@ namespace O3DE::ProjectManager { const QString defaultName = GetDefaultProjectName(); const QString defaultPath = QDir::toNativeSeparators(GetDefaultProjectPath() + "/" + defaultName); + const QString randomUuid = GenerateNewProjectId(); m_projectName->lineEdit()->setText(defaultName); m_projectPath->lineEdit()->setText(defaultPath); + m_projectId->lineEdit()->setText(randomUuid); // if we don't use a QFrame we cannot "contain" the widgets inside and move them around // as a group @@ -173,6 +177,14 @@ namespace O3DE::ProjectManager return QDir::toNativeSeparators(GetDefaultProjectPath() + "/" + projectName); } + QString NewProjectSettingsScreen::GenerateNewProjectId() + { + AZStd::string uuid; + AZ::Uuid::CreateRandom().ToString(uuid); + + return QString(uuid.c_str()); + } + ProjectManagerScreen NewProjectSettingsScreen::GetScreenEnum() { return ProjectManagerScreen::NewProjectSettings; @@ -225,7 +237,7 @@ namespace O3DE::ProjectManager moreGemsLabel->setObjectName("moreGems"); templateDetailsLayout->addWidget(moreGemsLabel); - QLabel* browseCatalogLabel = new QLabel(tr("Browse the Gems Catalog to further customize your project."), this); + QLabel* browseCatalogLabel = new QLabel(tr("Browse the Gems Catalog to further customize your project."), this); browseCatalogLabel->setObjectName("browseCatalog"); browseCatalogLabel->setWordWrap(true); templateDetailsLayout->addWidget(browseCatalogLabel); diff --git a/Code/Tools/ProjectManager/Source/NewProjectSettingsScreen.h b/Code/Tools/ProjectManager/Source/NewProjectSettingsScreen.h index 42c47cb1ff..cfb215ba0c 100644 --- a/Code/Tools/ProjectManager/Source/NewProjectSettingsScreen.h +++ b/Code/Tools/ProjectManager/Source/NewProjectSettingsScreen.h @@ -47,6 +47,7 @@ namespace O3DE::ProjectManager private: QString GetDefaultProjectName(); QString GetDefaultProjectPath(); + QString GenerateNewProjectId(); QString GetProjectAutoPath(); QFrame* CreateTemplateDetails(int margin); void UpdateTemplateDetails(const ProjectTemplateInfo& templateInfo); diff --git a/Code/Tools/ProjectManager/Source/ProjectBuilderController.cpp b/Code/Tools/ProjectManager/Source/ProjectBuilderController.cpp index ecb125ae4e..4fc188b289 100644 --- a/Code/Tools/ProjectManager/Source/ProjectBuilderController.cpp +++ b/Code/Tools/ProjectManager/Source/ProjectBuilderController.cpp @@ -29,14 +29,8 @@ namespace O3DE::ProjectManager m_worker = new ProjectBuilderWorker(m_projectInfo); m_worker->moveToThread(&m_workerThread); - auto settingsRegistry = AZ::SettingsRegistry::Get(); - if (settingsRegistry) - { - // Remove key here in case Project Manager crashing while building that causes HandleResults to not be called - QString settingsKey = GetProjectBuiltSuccessfullyKey(m_projectInfo.m_projectName); - settingsRegistry->Remove(settingsKey.toStdString().c_str()); - SaveProjectManagerSettings(); - } + // Remove key here in case Project Manager crashing while building that causes HandleResults to not be called + PMSettings::SetProjectBuiltSuccessfully(m_projectInfo, false); connect(&m_workerThread, &QThread::finished, m_worker, &ProjectBuilderWorker::deleteLater); connect(&m_workerThread, &QThread::started, m_worker, &ProjectBuilderWorker::BuildProject); @@ -91,8 +85,6 @@ namespace O3DE::ProjectManager void ProjectBuilderController::HandleResults(const QString& result) { - QString settingsKey = GetProjectBuiltSuccessfullyKey(m_projectInfo.m_projectName); - if (!result.isEmpty()) { if (result.contains(tr("log"))) @@ -122,12 +114,7 @@ namespace O3DE::ProjectManager emit NotifyBuildProject(m_projectInfo); } - auto settingsRegistry = AZ::SettingsRegistry::Get(); - if (settingsRegistry) - { - settingsRegistry->Remove(settingsKey.toStdString().c_str()); - SaveProjectManagerSettings(); - } + PMSettings::SetProjectBuiltSuccessfully(m_projectInfo, false); emit Done(false); return; @@ -136,12 +123,7 @@ namespace O3DE::ProjectManager { m_projectInfo.m_buildFailed = false; - auto settingsRegistry = AZ::SettingsRegistry::Get(); - if (settingsRegistry) - { - settingsRegistry->Set(settingsKey.toStdString().c_str(), true); - SaveProjectManagerSettings(); - } + PMSettings::SetProjectBuiltSuccessfully(m_projectInfo, true); } emit Done(true); diff --git a/Code/Tools/ProjectManager/Source/ProjectInfo.cpp b/Code/Tools/ProjectManager/Source/ProjectInfo.cpp index b4a1e84831..0d19fff74a 100644 --- a/Code/Tools/ProjectManager/Source/ProjectInfo.cpp +++ b/Code/Tools/ProjectManager/Source/ProjectInfo.cpp @@ -9,14 +9,13 @@ #include #include -#include - namespace O3DE::ProjectManager { ProjectInfo::ProjectInfo( const QString& path, const QString& projectName, const QString& displayName, + const QString& id, const QString& origin, const QString& summary, const QString& iconPath, @@ -26,6 +25,7 @@ namespace O3DE::ProjectManager : m_path(path) , m_projectName(projectName) , m_displayName(displayName) + , m_id(id) , m_origin(origin) , m_summary(summary) , m_iconPath(iconPath) @@ -49,6 +49,10 @@ namespace O3DE::ProjectManager { return false; } + if (m_id != rhs.m_id) + { + return false; + } if (m_origin != rhs.m_origin) { return false; @@ -80,7 +84,7 @@ namespace O3DE::ProjectManager bool ProjectInfo::IsValid() const { - return !m_path.isEmpty() && !m_projectName.isEmpty(); + return !m_path.isEmpty() && !m_projectName.isEmpty() && !m_id.isEmpty(); } const QString& ProjectInfo::GetProjectDisplayName() const diff --git a/Code/Tools/ProjectManager/Source/ProjectInfo.h b/Code/Tools/ProjectManager/Source/ProjectInfo.h index 2ce1e8c491..4dcb21aa24 100644 --- a/Code/Tools/ProjectManager/Source/ProjectInfo.h +++ b/Code/Tools/ProjectManager/Source/ProjectInfo.h @@ -9,7 +9,6 @@ #pragma once #if !defined(Q_MOC_RUN) -#include #include #include #include @@ -26,6 +25,7 @@ namespace O3DE::ProjectManager const QString& path, const QString& projectName, const QString& displayName, + const QString& id, const QString& origin, const QString& summary, const QString& iconPath, @@ -45,6 +45,7 @@ namespace O3DE::ProjectManager // From project.json QString m_projectName; QString m_displayName; + QString m_id; QString m_origin; QString m_summary; QString m_iconPath; diff --git a/Code/Tools/ProjectManager/Source/ProjectManagerSettings.cpp b/Code/Tools/ProjectManager/Source/ProjectManagerSettings.cpp index 66480aab3e..12dd569ad5 100644 --- a/Code/Tools/ProjectManager/Source/ProjectManagerSettings.cpp +++ b/Code/Tools/ProjectManager/Source/ProjectManagerSettings.cpp @@ -14,46 +14,235 @@ namespace O3DE::ProjectManager { - void SaveProjectManagerSettings() + namespace PMSettings { - auto settingsRegistry = AZ::SettingsRegistry::Get(); - AZ::SettingsRegistryMergeUtils::DumperSettings dumperSettings; - dumperSettings.m_prettifyOutput = true; - dumperSettings.m_jsonPointerPrefix = ProjectManagerKeyPrefix; - - AZStd::string stringBuffer; - AZ::IO::ByteContainerStream stringStream(&stringBuffer); - if (!AZ::SettingsRegistryMergeUtils::DumpSettingsRegistryToStream( - *settingsRegistry, ProjectManagerKeyPrefix, stringStream, dumperSettings)) + bool SaveProjectManagerSettings() { - AZ_Warning("ProjectManager", false, "Could not save Project Manager settings to stream"); - return; + auto settingsRegistry = AZ::SettingsRegistry::Get(); + AZ::SettingsRegistryMergeUtils::DumperSettings dumperSettings; + dumperSettings.m_prettifyOutput = true; + dumperSettings.m_jsonPointerPrefix = ProjectManagerKeyPrefix; + + AZStd::string stringBuffer; + AZ::IO::ByteContainerStream stringStream(&stringBuffer); + if (!AZ::SettingsRegistryMergeUtils::DumpSettingsRegistryToStream( + *settingsRegistry, ProjectManagerKeyPrefix, stringStream, dumperSettings)) + { + AZ_Warning("ProjectManager", false, "Could not save Project Manager settings to stream"); + return false; + } + + AZ::IO::FixedMaxPath o3deUserPath = AZ::Utils::GetO3deManifestDirectory(); + o3deUserPath /= AZ::SettingsRegistryInterface::RegistryFolder; + o3deUserPath /= "ProjectManager.setreg"; + + bool saved = false; + constexpr auto configurationMode = + AZ::IO::SystemFile::SF_OPEN_CREATE | AZ::IO::SystemFile::SF_OPEN_CREATE_PATH | AZ::IO::SystemFile::SF_OPEN_WRITE_ONLY; + + AZ::IO::SystemFile outputFile; + if (outputFile.Open(o3deUserPath.c_str(), configurationMode)) + { + saved = outputFile.Write(stringBuffer.data(), stringBuffer.size()) == stringBuffer.size(); + } + + AZ_Warning("ProjectManager", saved, "Unable to save Project Manager registry file to path: %s", o3deUserPath.c_str()); + return saved; } - AZ::IO::FixedMaxPath o3deUserPath = AZ::Utils::GetO3deManifestDirectory(); - o3deUserPath /= AZ::SettingsRegistryInterface::RegistryFolder; - o3deUserPath /= "ProjectManager.setreg"; - - bool saved = false; - constexpr auto configurationMode = - AZ::IO::SystemFile::SF_OPEN_CREATE | AZ::IO::SystemFile::SF_OPEN_CREATE_PATH | AZ::IO::SystemFile::SF_OPEN_WRITE_ONLY; - - AZ::IO::SystemFile outputFile; - if (outputFile.Open(o3deUserPath.c_str(), configurationMode)) + bool GetProjectManagerKey(QString& result, const QString& settingsKey) { - saved = outputFile.Write(stringBuffer.data(), stringBuffer.size()) == stringBuffer.size(); + bool success = false; + auto settingsRegistry = AZ::SettingsRegistry::Get(); + if (settingsRegistry) + { + AZStd::string settingsValue; + success = settingsRegistry->Get(settingsValue, settingsKey.toStdString().c_str()); + + result = settingsValue.c_str(); + } + + return success; } - AZ_Warning("ProjectManager", saved, "Unable to save Project Manager registry file to path: %s", o3deUserPath.c_str()); - } + bool GetProjectManagerKey(bool& result, const QString& settingsKey) + { + bool success = false; + auto settingsRegistry = AZ::SettingsRegistry::Get(); + if (settingsRegistry) + { + success = settingsRegistry->Get(result, settingsKey.toStdString().c_str()); + } - QString GetProjectBuiltSuccessfullyKey(const QString& projectName) - { - return QString("%1/Projects/%2/BuiltSuccessfully").arg(ProjectManagerKeyPrefix).arg(projectName); - } + return success; + } - QString GetExternalLinkWarningKey() - { - return QString("%1/SkipExternalLinkWarning").arg(ProjectManagerKeyPrefix); - } -} + bool SetProjectManagerKey(const QString& settingsKey, const QString& settingsValue, bool saveToDisk) + { + bool success = false; + auto settingsRegistry = AZ::SettingsRegistry::Get(); + if (settingsRegistry) + { + success = settingsRegistry->Set(settingsKey.toStdString().c_str(), settingsValue.toStdString().c_str()); + + if (saveToDisk) + { + SaveProjectManagerSettings(); + } + } + + return success; + } + + bool SetProjectManagerKey(const QString& settingsKey, bool settingsValue, bool saveToDisk) + { + bool success = false; + auto settingsRegistry = AZ::SettingsRegistry::Get(); + if (settingsRegistry) + { + success = settingsRegistry->Set(settingsKey.toStdString().c_str(), settingsValue); + + if (saveToDisk) + { + SaveProjectManagerSettings(); + } + } + + return success; + } + + bool RemoveProjectManagerKey(const QString& settingsKey, bool saveToDisk) + { + bool success = false; + auto settingsRegistry = AZ::SettingsRegistry::Get(); + if (settingsRegistry) + { + success = settingsRegistry->Remove(settingsKey.toStdString().c_str()); + + if (saveToDisk) + { + SaveProjectManagerSettings(); + } + } + + return success; + } + + bool CopyProjectManagerKeyString(const QString& settingsKeyOrig, const QString& settingsKeyDest, bool removeOrig, bool saveToDisk) + { + bool success = false; + auto settingsRegistry = AZ::SettingsRegistry::Get(); + if (settingsRegistry) + { + AZStd::string settingsValue; + success = settingsRegistry->Get(settingsValue, settingsKeyOrig.toStdString().c_str()); + + if (success) + { + success = settingsRegistry->Set(settingsKeyDest.toStdString().c_str(), settingsValue); + if (success) + { + if (removeOrig) + { + success = settingsRegistry->Remove(settingsKeyOrig.toStdString().c_str()); + } + + if (saveToDisk) + { + SaveProjectManagerSettings(); + } + } + } + } + + return success; + } + + QString GetProjectKey(const ProjectInfo& projectInfo) + { + return QString("%1/Projects/%2/%3").arg(ProjectManagerKeyPrefix, projectInfo.m_id, projectInfo.m_projectName); + } + + QString GetExternalLinkWarningKey() + { + return QString("%1/SkipExternalLinkWarning").arg(ProjectManagerKeyPrefix); + } + + QString GetProjectsBuiltSuccessfullyKey() + { + return QString("%1/SuccessfulBuildPaths").arg(ProjectManagerKeyPrefix); + } + + bool GetBuiltSuccessfullyPaths(AZStd::set& result) + { + bool success = false; + auto settingsRegistry = AZ::SettingsRegistry::Get(); + if (settingsRegistry) + { + QString builtKey = GetProjectsBuiltSuccessfullyKey(); + success = settingsRegistry->GetObject>(result, builtKey.toStdString().c_str()); + } + + return success; + } + + bool GetProjectBuiltSuccessfully(bool& result, const ProjectInfo& projectInfo) + { + AZStd::set builtPathsResult; + bool success = GetBuiltSuccessfullyPaths(builtPathsResult); + if (success) + { + // Check if buildPath is listed as successfully built + AZStd::string projectPath = projectInfo.m_path.toStdString().c_str(); + if (builtPathsResult.contains(projectPath)) + { + result = true; + } + } + // No project built statuses known + else + { + result = false; + } + + return success; + } + + bool SetProjectBuiltSuccessfully(const ProjectInfo& projectInfo, bool successfullyBuilt, bool saveToDisk) + { + AZStd::set builtPathsResult; + bool success = GetBuiltSuccessfullyPaths(builtPathsResult); + + AZStd::string projectPath = projectInfo.m_path.toStdString().c_str(); + if (successfullyBuilt) + { + //Add successfully built path to set + builtPathsResult.insert(projectPath); + } + else + { + // Remove unsuccessfully built path from set + builtPathsResult.erase(projectPath); + } + + auto settingsRegistry = AZ::SettingsRegistry::Get(); + if (settingsRegistry) + { + QString builtKey = GetProjectsBuiltSuccessfullyKey(); + success = settingsRegistry->SetObject>(builtKey.toStdString().c_str(), builtPathsResult); + + if (saveToDisk) + { + SaveProjectManagerSettings(); + } + } + else + { + success = false; + } + + return success; + } + + } // namespace PMSettings +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/ProjectManagerSettings.h b/Code/Tools/ProjectManager/Source/ProjectManagerSettings.h index 93cfbc5ceb..2a92fcab0f 100644 --- a/Code/Tools/ProjectManager/Source/ProjectManagerSettings.h +++ b/Code/Tools/ProjectManager/Source/ProjectManagerSettings.h @@ -9,14 +9,29 @@ #pragma once #if !defined(Q_MOC_RUN) -#include +#include +#include #endif namespace O3DE::ProjectManager { - static constexpr char ProjectManagerKeyPrefix[] = "/O3DE/ProjectManager"; + namespace PMSettings + { + static constexpr char ProjectManagerKeyPrefix[] = "/O3DE/ProjectManager"; - void SaveProjectManagerSettings(); - QString GetProjectBuiltSuccessfullyKey(const QString& projectName); - QString GetExternalLinkWarningKey(); -} + bool SaveProjectManagerSettings(); + bool GetProjectManagerKey(QString& result, const QString& settingsKey); + bool GetProjectManagerKey(bool& result, const QString& settingsKey); + bool SetProjectManagerKey(const QString& settingsKey, const QString& settingsValue, bool saveToDisk = true); + bool SetProjectManagerKey(const QString& settingsKey, bool settingsValue, bool saveToDisk = true); + bool RemoveProjectManagerKey(const QString& settingsKey, bool saveToDisk = true); + bool CopyProjectManagerKeyString( + const QString& settingsKeyOrig, const QString& settingsKeyDest, bool removeOrig = false, bool saveToDisk = true); + + QString GetProjectKey(const ProjectInfo& projectInfo); + QString GetExternalLinkWarningKey(); + + bool GetProjectBuiltSuccessfully(bool& result, const ProjectInfo& projectInfo); + bool SetProjectBuiltSuccessfully(const ProjectInfo& projectInfo, bool successfullyBuilt, bool saveToDisk = true); + } // namespace PMSettings +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/ProjectSettingsScreen.cpp b/Code/Tools/ProjectManager/Source/ProjectSettingsScreen.cpp index d4ac43d655..cf15cb5bbc 100644 --- a/Code/Tools/ProjectManager/Source/ProjectSettingsScreen.cpp +++ b/Code/Tools/ProjectManager/Source/ProjectSettingsScreen.cpp @@ -60,6 +60,10 @@ namespace O3DE::ProjectManager connect(m_projectPath->lineEdit(), &QLineEdit::textChanged, this, &ProjectSettingsScreen::OnProjectPathUpdated); m_verticalLayout->addWidget(m_projectPath); + m_projectId = new FormLineEditWidget(tr("Project ID"), "", this); + connect(m_projectId->lineEdit(), &QLineEdit::textChanged, this, &ProjectSettingsScreen::OnProjectIdUpdated); + m_verticalLayout->addWidget(m_projectId); + projectSettingsFrame->setLayout(m_verticalLayout); m_horizontalLayout->addWidget(projectSettingsFrame); @@ -94,6 +98,7 @@ namespace O3DE::ProjectManager // currently we don't have separate fields for changing the project name and display name projectInfo.m_displayName = projectInfo.m_projectName; projectInfo.m_path = m_projectPath->lineEdit()->text(); + projectInfo.m_id = m_projectId->lineEdit()->text(); return projectInfo; } @@ -142,6 +147,19 @@ namespace O3DE::ProjectManager return projectPathIsValid; } + bool ProjectSettingsScreen::ValidateProjectId() + { + bool projectIdIsValid = true; + if (m_projectId->lineEdit()->text().isEmpty()) + { + projectIdIsValid = false; + m_projectId->setErrorLabelText(tr("Project ID cannot be empty.")); + } + + m_projectId->setErrorLabelVisible(!projectIdIsValid); + return projectIdIsValid; + } + void ProjectSettingsScreen::OnProjectNameUpdated() { ValidateProjectName(); @@ -149,11 +167,16 @@ namespace O3DE::ProjectManager void ProjectSettingsScreen::OnProjectPathUpdated() { - Validate(); + ValidateProjectName() && ValidateProjectPath(); + } + + void ProjectSettingsScreen::OnProjectIdUpdated() + { + ValidateProjectId(); } bool ProjectSettingsScreen::Validate() { - return ValidateProjectName() && ValidateProjectPath(); + return ValidateProjectName() && ValidateProjectPath() && ValidateProjectId(); } } // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/ProjectSettingsScreen.h b/Code/Tools/ProjectManager/Source/ProjectSettingsScreen.h index 752e286ce1..928cde833e 100644 --- a/Code/Tools/ProjectManager/Source/ProjectSettingsScreen.h +++ b/Code/Tools/ProjectManager/Source/ProjectSettingsScreen.h @@ -35,10 +35,12 @@ namespace O3DE::ProjectManager protected slots: virtual void OnProjectNameUpdated(); virtual void OnProjectPathUpdated(); + virtual void OnProjectIdUpdated(); protected: bool ValidateProjectName(); virtual bool ValidateProjectPath(); + bool ValidateProjectId(); QString GetDefaultProjectPath(); @@ -46,6 +48,7 @@ namespace O3DE::ProjectManager QVBoxLayout* m_verticalLayout; FormLineEditWidget* m_projectName; FormBrowseEditWidget* m_projectPath; + FormLineEditWidget* m_projectId; }; } // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/ProjectsScreen.cpp b/Code/Tools/ProjectManager/Source/ProjectsScreen.cpp index acd753a1cb..9816595548 100644 --- a/Code/Tools/ProjectManager/Source/ProjectsScreen.cpp +++ b/Code/Tools/ProjectManager/Source/ProjectsScreen.cpp @@ -291,13 +291,9 @@ namespace O3DE::ProjectManager // Check whether project manager has successfully built the project if (currentButton) { - auto settingsRegistry = AZ::SettingsRegistry::Get(); bool projectBuiltSuccessfully = false; - if (settingsRegistry) - { - QString settingsKey = GetProjectBuiltSuccessfullyKey(project.m_projectName); - settingsRegistry->Get(projectBuiltSuccessfully, settingsKey.toStdString().c_str()); - } + PMSettings::GetProjectBuiltSuccessfully(projectBuiltSuccessfully, project); + if (!projectBuiltSuccessfully) { currentButton->ShowBuildRequired(); diff --git a/Code/Tools/ProjectManager/Source/PythonBindings.cpp b/Code/Tools/ProjectManager/Source/PythonBindings.cpp index 12f97e6d2e..8d11028af6 100644 --- a/Code/Tools/ProjectManager/Source/PythonBindings.cpp +++ b/Code/Tools/ProjectManager/Source/PythonBindings.cpp @@ -687,8 +687,24 @@ namespace O3DE::ProjectManager auto createProjectResult = m_engineTemplate.attr("create_project")( projectPath, - QString_To_Py_String(projectInfo.m_projectName), - QString_To_Py_Path(projectTemplatePath) + QString_To_Py_String(projectInfo.m_projectName), // project_path + QString_To_Py_Path(projectTemplatePath), // template_path + pybind11::none(), // template_name + pybind11::none(), // project_restricted_path + pybind11::none(), // project_restricted_name + pybind11::none(), // template_restricted_path + pybind11::none(), // template_restricted_name + pybind11::none(), // project_restricted_platform_relative_path + pybind11::none(), // template_restricted_platform_relative_path + pybind11::none(), // keep_restricted_in_project + pybind11::none(), // keep_license_text + pybind11::none(), // replace + pybind11::none(), // force + pybind11::none(), // no_register + pybind11::none(), // system_component_class_id + pybind11::none(), // editor_system_component_class_id + pybind11::none(), // module_id + QString_To_Py_String(projectInfo.m_id) // project_id ); if (createProjectResult.cast() == 0) { @@ -822,6 +838,7 @@ namespace O3DE::ProjectManager { projectInfo.m_projectName = Py_To_String(projectData["project_name"]); projectInfo.m_displayName = Py_To_String_Optional(projectData, "display_name", projectInfo.m_projectName); + projectInfo.m_id = Py_To_String_Optional(projectData, "project_id", projectInfo.m_id); projectInfo.m_origin = Py_To_String_Optional(projectData, "origin", projectInfo.m_origin); projectInfo.m_summary = Py_To_String_Optional(projectData, "summary", projectInfo.m_summary); projectInfo.m_iconPath = Py_To_String_Optional(projectData, "icon", ProjectPreviewImagePath); @@ -926,6 +943,7 @@ namespace O3DE::ProjectManager QString_To_Py_Path(projectInfo.m_path), pybind11::none(), // proj_name not used QString_To_Py_String(projectInfo.m_projectName), + QString_To_Py_String(projectInfo.m_id), QString_To_Py_String(projectInfo.m_origin), QString_To_Py_String(projectInfo.m_displayName), QString_To_Py_String(projectInfo.m_summary), diff --git a/Code/Tools/ProjectManager/Source/UpdateProjectCtrl.cpp b/Code/Tools/ProjectManager/Source/UpdateProjectCtrl.cpp index 36d78ed2ac..71dae91a81 100644 --- a/Code/Tools/ProjectManager/Source/UpdateProjectCtrl.cpp +++ b/Code/Tools/ProjectManager/Source/UpdateProjectCtrl.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include @@ -306,17 +305,10 @@ namespace O3DE::ProjectManager if (newProjectSettings.m_projectName != m_projectInfo.m_projectName) { - // update reg key - QString oldSettingsKey = GetProjectBuiltSuccessfullyKey(m_projectInfo.m_projectName); - QString newSettingsKey = GetProjectBuiltSuccessfullyKey(newProjectSettings.m_projectName); - - auto settingsRegistry = AZ::SettingsRegistry::Get(); - bool projectBuiltSuccessfully = false; - if (settingsRegistry && settingsRegistry->Get(projectBuiltSuccessfully, oldSettingsKey.toStdString().c_str())) - { - settingsRegistry->Set(newSettingsKey.toStdString().c_str(), projectBuiltSuccessfully); - SaveProjectManagerSettings(); - } + // Remove project build successfully paths for both old and new project names + // because a full rebuild is required when moving projects + PMSettings::SetProjectBuiltSuccessfully(m_projectInfo, false); + PMSettings::SetProjectBuiltSuccessfully(newProjectSettings, false); } if (!newProjectSettings.m_newPreviewImagePath.isEmpty()) diff --git a/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.cpp b/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.cpp index a430102c27..7c8f981f59 100644 --- a/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.cpp +++ b/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.cpp @@ -56,6 +56,7 @@ namespace O3DE::ProjectManager { m_projectInfo.m_displayName = m_projectName->lineEdit()->text(); m_projectInfo.m_path = m_projectPath->lineEdit()->text(); + m_projectInfo.m_id = m_projectId->lineEdit()->text(); if (m_userChangedPreview) { @@ -70,8 +71,9 @@ namespace O3DE::ProjectManager m_projectInfo = projectInfo; m_projectName->lineEdit()->setText(projectInfo.GetProjectDisplayName()); - m_projectPath->lineEdit()->setText(projectInfo.m_path); + m_projectId->lineEdit()->setText(projectInfo.m_id); + UpdateProjectPreviewPath(); } diff --git a/Code/Tools/ProjectManager/project_manager_tests_files.cmake b/Code/Tools/ProjectManager/project_manager_tests_files.cmake index 2bfe343038..df9a0070a1 100644 --- a/Code/Tools/ProjectManager/project_manager_tests_files.cmake +++ b/Code/Tools/ProjectManager/project_manager_tests_files.cmake @@ -10,8 +10,9 @@ set(FILES Resources/ProjectManager.qrc Resources/ProjectManager.qss tests/ApplicationTests.cpp - tests/PythonBindingsTests.cpp tests/GemCatalogTests.cpp + tests/ProjectManagerSettingsTests.cpp + tests/PythonBindingsTests.cpp tests/main.cpp tests/UtilsTests.cpp ) diff --git a/Code/Tools/ProjectManager/tests/ProjectManagerSettingsTests.cpp b/Code/Tools/ProjectManager/tests/ProjectManagerSettingsTests.cpp new file mode 100644 index 0000000000..7ab93f798c --- /dev/null +++ b/Code/Tools/ProjectManager/tests/ProjectManagerSettingsTests.cpp @@ -0,0 +1,176 @@ +/* + * 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 + +namespace O3DE::ProjectManager +{ + class ProjectManagerSettingsTests + : public ::UnitTest::ScopedAllocatorSetupFixture + { + public: + ~ProjectManagerSettingsTests() override = default; + void SetUp() override + { + UnitTest::ScopedAllocatorSetupFixture::SetUp(); + + m_registry = AZStd::make_unique(); + // Store off the old global settings registry to restore after each test + m_oldSettingsRegistry = AZ::SettingsRegistry::Get(); + if (m_oldSettingsRegistry != nullptr) + { + AZ::SettingsRegistry::Unregister(m_oldSettingsRegistry); + } + AZ::SettingsRegistry::Register(m_registry.get()); + + m_serializeContext = AZStd::make_unique(); + m_registrationContext = AZStd::make_unique(); + + m_registry->SetContext(m_serializeContext.get()); + m_registry->SetContext(m_registrationContext.get()); + + m_projectInfo.m_path = "Z:/ProjectTestPath"; + } + + void TearDown() override + { + m_registrationContext.reset(); + m_serializeContext.reset(); + + // Restore the old global settings registry + AZ::SettingsRegistry::Unregister(m_registry.get()); + if (m_oldSettingsRegistry != nullptr) + { + AZ::SettingsRegistry::Register(m_oldSettingsRegistry); + m_oldSettingsRegistry = nullptr; + } + m_registry.reset(); + + UnitTest::ScopedAllocatorSetupFixture::TearDown(); + } + + protected: + const QString m_settingsPath = "/Testing/TestKey"; + const QString m_newSettingsPath = "/Testing/NewTestKey"; + ProjectInfo m_projectInfo; + + private: + AZ::SettingsRegistryInterface* m_oldSettingsRegistry = nullptr; + AZStd::unique_ptr m_registry; + AZStd::unique_ptr m_serializeContext; + AZStd::unique_ptr m_registrationContext; + }; + + TEST_F(ProjectManagerSettingsTests, PMSettings_GetUnsetPathBool_ReturnsFalse) + { + bool settingsResult = false; + EXPECT_FALSE(PMSettings::GetProjectManagerKey(settingsResult, m_settingsPath)); + EXPECT_FALSE(settingsResult); + } + + TEST_F(ProjectManagerSettingsTests, PMSettings_SetAndGetValueBool_Success) + { + bool settingsResult = false; + EXPECT_FALSE(PMSettings::GetProjectManagerKey(settingsResult, m_settingsPath)); + + // Don't save to disk in test + EXPECT_TRUE(PMSettings::SetProjectManagerKey(m_settingsPath, true, /*saveToDisk*/ false)); + + settingsResult = false; + EXPECT_TRUE(PMSettings::GetProjectManagerKey(settingsResult, m_settingsPath)); + EXPECT_TRUE(settingsResult); + } + + TEST_F(ProjectManagerSettingsTests, PMSettings_GetUnsetPathString_ReturnsFalse) + { + QString settingsResult; + EXPECT_FALSE(PMSettings::GetProjectManagerKey(settingsResult, m_settingsPath)); + EXPECT_TRUE(settingsResult.isEmpty()); + } + + TEST_F(ProjectManagerSettingsTests, PMSettings_SetAndGetValueString_Success) + { + QString settingsResult; + EXPECT_FALSE(PMSettings::GetProjectManagerKey(settingsResult, m_settingsPath)); + + QString settingsValue = "TestValue"; + + // Don't save to disk in test + EXPECT_TRUE(PMSettings::SetProjectManagerKey(m_settingsPath, settingsValue, /*saveToDisk*/ false)); + + EXPECT_TRUE(PMSettings::GetProjectManagerKey(settingsResult, m_settingsPath)); + EXPECT_TRUE(settingsResult == settingsValue); + } + + TEST_F(ProjectManagerSettingsTests, PMSettings_CopyStringRemoveOriginal_SuccessAndRemovesOriginal) + { + QString settingsResult; + EXPECT_FALSE(PMSettings::GetProjectManagerKey(settingsResult, m_newSettingsPath)); + + QString settingsValue = "TestValue"; + + // Don't save to disk in test + EXPECT_TRUE(PMSettings::SetProjectManagerKey(m_settingsPath, settingsValue, /*saveToDisk*/ false)); + + EXPECT_TRUE(PMSettings::CopyProjectManagerKeyString(m_settingsPath, m_newSettingsPath, /*removeOrig*/ true, /*saveToDisk*/ false)); + + // Check that old path value is removed + EXPECT_FALSE(PMSettings::GetProjectManagerKey(settingsResult, m_settingsPath)); + + EXPECT_TRUE(PMSettings::GetProjectManagerKey(settingsResult, m_newSettingsPath)); + EXPECT_TRUE(settingsResult == settingsValue); + } + + TEST_F(ProjectManagerSettingsTests, PMSettings_RemoveProjectManagerKey_RemovesKey) + { + QString settingsResult; + EXPECT_FALSE(PMSettings::GetProjectManagerKey(settingsResult, m_settingsPath)); + + QString settingsValue = "TestValue"; + + // Don't save to disk in test + EXPECT_TRUE(PMSettings::SetProjectManagerKey(m_settingsPath, settingsValue, /*saveToDisk*/ false)); + EXPECT_TRUE(PMSettings::GetProjectManagerKey(settingsResult, m_settingsPath)); + + EXPECT_TRUE(PMSettings::RemoveProjectManagerKey(m_settingsPath, /*saveToDisk*/ false)); + EXPECT_FALSE(PMSettings::GetProjectManagerKey(settingsResult, m_settingsPath)); + } + + TEST_F(ProjectManagerSettingsTests, PMSettings_GetUnsetBuildPath_ReturnsFalse) + { + bool buildResult = true; + EXPECT_FALSE(PMSettings::GetProjectBuiltSuccessfully(buildResult, m_projectInfo)); + EXPECT_FALSE(buildResult); + } + + TEST_F(ProjectManagerSettingsTests, PMSettings_SetProjectBuiltSuccessfully_ReturnsTrue) + { + // Don't save to disk in test + EXPECT_TRUE(PMSettings::SetProjectBuiltSuccessfully(m_projectInfo, true, /*saveToDisk*/ false)); + + bool buildResult = false; + EXPECT_TRUE(PMSettings::GetProjectBuiltSuccessfully(buildResult, m_projectInfo)); + EXPECT_TRUE(buildResult); + } + + TEST_F(ProjectManagerSettingsTests, PMSettings_SetProjectBuiltUnsuccessfully_ReturnsFalse) + { + // Don't save to disk in test + EXPECT_TRUE(PMSettings::SetProjectBuiltSuccessfully(m_projectInfo, true, /*saveToDisk*/ false)); + + bool buildResult = true; + EXPECT_TRUE(PMSettings::GetProjectBuiltSuccessfully(buildResult, m_projectInfo)); + EXPECT_FALSE(buildResult); + } +} diff --git a/Templates/DefaultProject/Template/project.json b/Templates/DefaultProject/Template/project.json index b52b0baf27..f8d4643ce9 100644 --- a/Templates/DefaultProject/Template/project.json +++ b/Templates/DefaultProject/Template/project.json @@ -1,5 +1,6 @@ { "project_name": "${Name}", + "project_id": "${ProjectId}", "origin": "The primary repo for ${Name} goes here: i.e. http://www.mydomain.com", "license": "What license ${Name} uses goes here: i.e. https://opensource.org/licenses/MIT", "display_name": "${Name}", diff --git a/Templates/MinimalProject/Template/project.json b/Templates/MinimalProject/Template/project.json index b52b0baf27..f8d4643ce9 100644 --- a/Templates/MinimalProject/Template/project.json +++ b/Templates/MinimalProject/Template/project.json @@ -1,5 +1,6 @@ { "project_name": "${Name}", + "project_id": "${ProjectId}", "origin": "The primary repo for ${Name} goes here: i.e. http://www.mydomain.com", "license": "What license ${Name} uses goes here: i.e. https://opensource.org/licenses/MIT", "display_name": "${Name}", diff --git a/q b/q new file mode 100644 index 0000000000..fc1c268aef --- /dev/null +++ b/q @@ -0,0 +1,48 @@ + Prism/AddEditGemsButton + Prism/AddLicenseToGemCatalog + Prism/AddRemoveRepoWorkingUI + Prism/AddRepoDialog +* Prism/CmakeVariablesPerProject + Prism/CreateRepositoryScreen + Prism/CustomBuildParameters + Prism/CustomTabWidgetForEngine + Prism/DeleteUpdateGemsUI + Prism/DisplayAddGemInfo + Prism/EnterInFileDialog + Prism/ExternalLinkWarning + Prism/FasterBuildTimes + Prism/FixGemCart + Prism/FixGemCatalogHyperlinks + Prism/FixGemSelectedFilter + Prism/FixRemovedProjectStillShown + Prism/FixTabOverlayOnStartup + Prism/GemCatalogMenu + Prism/GemCatalogTests + Prism/GemCatalogWithoutProject + Prism/GemRepoInspector + Prism/RefreshAfterDownload + Prism/RefreshGemRepos + Prism/RefreshOnDownload + Prism/RefreshRepoButtonDisablesRepo + Prism/RemoteGemWarning + Prism/RemoveTabFocus + Prism/ResetBuildAndCacheAfterProjectMove + Prism/SearchForGemsFromTags + Prism/ShowGemDownloadStatus + Prism/ShowGemPreview + Prism/ShowGemRepoGems + Prism/ShowGemsInRepo + Prism/ShowRepoGems + Prism/ShowRepoList + Prism/UpdateTemplatePics + Prism/UseGemDisplayNames + Prism/VS2019InstallInstructions + Prism/WarnExternalLink + Prism/WarnVSNotInstalled + Prism/cherry-pick-gem-catalog-fix + Prism/gitRepos + development + new-feature + racoonteurs + stabilization/2110 + stabilization/2111RTE diff --git a/scripts/o3de/o3de/engine_template.py b/scripts/o3de/o3de/engine_template.py index e93f972301..963ee3eb84 100755 --- a/scripts/o3de/o3de/engine_template.py +++ b/scripts/o3de/o3de/engine_template.py @@ -1113,7 +1113,7 @@ def create_from_template(destination_path: pathlib.Path, try: template_json_data = json.load(s) except KeyError as e: - logger.error(f'Could read template json {template_json}: {str(e)}.') + logger.error(f'Could not read template json {template_json}: {str(e)}.') return 1 # read template name from the json @@ -1338,7 +1338,8 @@ def create_project(project_path: pathlib.Path, no_register: bool = False, system_component_class_id: str = None, editor_system_component_class_id: str = None, - module_id: str = None) -> int: + module_id: str = None, + project_id: str = None) -> int: """ Template instantiation specialization that makes all default assumptions for a Project template instantiation, reducing the effort needed in instancing a project @@ -1366,6 +1367,7 @@ def create_project(project_path: pathlib.Path, :param editor_system_component_class_id: optionally specify a uuid for the editor system component class, default is random uuid :param module_id: optionally specify a uuid for the module class, default is random uuid + :param project_id: optionally specify a str for the project id, default is random uuid :return: 0 for success or non 0 failure code """ if template_name and template_path: @@ -1405,7 +1407,7 @@ def create_project(project_path: pathlib.Path, try: template_json_data = json.load(s) except json.JSONDecodeError as e: - logger.error(f'Could read template json {template_json}: {str(e)}.') + logger.error(f'Could not read template json {template_json}: {str(e)}.') return 1 # read template name from the json @@ -1577,6 +1579,12 @@ def create_project(project_path: pathlib.Path, replacements.append(("${NameLower}", project_name.lower())) replacements.append(("${SanitizedCppName}", sanitized_cpp_name)) + # was a project id specified + if project_id: + replacements.append(("${ProjectId}", project_id)) + else: + replacements.append(("${ProjectId}", '{' + str(uuid.uuid4()) + '}')) + # module id is a uuid with { and - if module_id: replacements.append(("${ModuleClassId}", module_id)) @@ -1784,7 +1792,7 @@ def create_gem(gem_path: pathlib.Path, try: template_json_data = json.load(s) except json.JSONDecodeError as e: - logger.error(f'Could read template json {template_json}: {str(e)}.') + logger.error(f'Could not read template json {template_json}: {str(e)}.') return 1 # read template name from the json @@ -2123,7 +2131,8 @@ def _run_create_project(args: argparse) -> int: args.no_register, args.system_component_class_id, args.editor_system_component_class_id, - args.module_id) + args.module_id, + args.project_id) def _run_create_gem(args: argparse) -> int: @@ -2404,6 +2413,9 @@ def add_args(subparsers) -> None: create_project_subparser.add_argument('--module-id', type=uuid.UUID, required=False, help='The uuid you want to associate with the module, default is a random' ' uuid Ex. {b60c92eb-3139-454b-a917-a9d3c5819594}') + create_project_subparser.add_argument('--project-id', type=str, required=False, + help='The str id you want to associate with the project, default is a random uuid' + ' Ex. {b60c92eb-3139-454b-a917-a9d3c5819594}') create_project_subparser.add_argument('-f', '--force', action='store_true', default=False, help='Copies over instantiated template directory even if it exist.') create_project_subparser.add_argument('--no-register', action='store_true', default=False, diff --git a/scripts/o3de/o3de/project_properties.py b/scripts/o3de/o3de/project_properties.py index 04731ad3de..88c05537e9 100644 --- a/scripts/o3de/o3de/project_properties.py +++ b/scripts/o3de/o3de/project_properties.py @@ -29,6 +29,7 @@ def get_project_props(name: str = None, path: pathlib.Path = None) -> dict: def edit_project_props(proj_path: pathlib.Path = None, proj_name: str = None, new_name: str = None, + new_id: str = None, new_origin: str = None, new_display: str = None, new_summary: str = None, @@ -40,14 +41,15 @@ def edit_project_props(proj_path: pathlib.Path = None, if not proj_json: return 1 - - if new_origin: - proj_json['origin'] = new_origin if new_name: if not utils.validate_identifier(new_name): logger.error(f'Project name must be fewer than 64 characters, contain only alphanumeric, "_" or "-" characters, and start with a letter. {new_name}') return 1 - proj_json['project_name'] = new_name + proj_json['project_name'] = new_name + if new_id: + proj_json['project_id'] = new_id + if new_origin: + proj_json['origin'] = new_origin if new_display: proj_json['display_name'] = new_display if new_summary: @@ -78,6 +80,7 @@ def _edit_project_props(args: argparse) -> int: return edit_project_props(args.project_path, args.project_name, args.project_new_name, + args.project_id, args.project_origin, args.project_display, args.project_summary, @@ -95,6 +98,8 @@ def add_parser_args(parser): group = parser.add_argument_group('properties', 'arguments for modifying individual project properties.') group.add_argument('-pnn', '--project-new-name', type=str, required=False, help='Sets the name for the project.') + group.add_argument('-pid', '--project-id', type=str, required=False, + help='Sets the ID for the project.') group.add_argument('-po', '--project-origin', type=str, required=False, help='Sets description or url for project origin (such as project host, repository, owner...etc).') group.add_argument('-pd', '--project-display', type=str, required=False, diff --git a/scripts/o3de/o3de/register.py b/scripts/o3de/o3de/register.py index 2500df1568..aaadfb5709 100644 --- a/scripts/o3de/o3de/register.py +++ b/scripts/o3de/o3de/register.py @@ -570,7 +570,7 @@ def remove_invalid_o3de_projects(manifest_path: pathlib.Path = None) -> int: result = 0 for project in json_data.get('projects', []): - if not validation.valid_o3de_project_json(pathlib.Path(project).resolve() / 'project.json'): + if not validation.valid_o3de_project_json(pathlib.Path(project).resolve() / 'project.json', generate_uuid=True): logger.warning(f"Project path {project} is invalid.") # Attempt to unregister all invalid projects even if previous projects failed to unregister # but combine the result codes of each command. diff --git a/scripts/o3de/o3de/validation.py b/scripts/o3de/o3de/validation.py index 5c683f0667..a671e88edf 100644 --- a/scripts/o3de/o3de/validation.py +++ b/scripts/o3de/o3de/validation.py @@ -10,6 +10,7 @@ This file validating o3de object json files """ import json import pathlib +import uuid def valid_o3de_json_dict(json_data: dict, key: str) -> bool: return key in json_data @@ -44,7 +45,7 @@ def valid_o3de_engine_json(file_name: str or pathlib.Path) -> bool: return True -def valid_o3de_project_json(file_name: str or pathlib.Path) -> bool: +def valid_o3de_project_json(file_name: str or pathlib.Path, generate_uuid: bool = True) -> bool: file_name = pathlib.Path(file_name).resolve() if not file_name.is_file(): return False @@ -53,8 +54,22 @@ def valid_o3de_project_json(file_name: str or pathlib.Path) -> bool: try: json_data = json.load(f) test = json_data['project_name'] + + if not generate_uuid: + test = json_data['project_id'] + else: + test = json_data.get('project_id', 'No ID') + generate_new_id = test == 'No ID' + except (json.JSONDecodeError, KeyError) as e: return False + + # Generate a random uuid for the project json if it is missing instead of failing if generate_uuid is true + if generate_uuid and generate_new_id: + with file_name.open('w') as f: + new_uuid = '{' + str(uuid.uuid4()) + '}' + json_data.update({'project_id': new_uuid}) + f.write(json.dumps(json_data, indent=4) + '\n') return True diff --git a/scripts/o3de/tests/unit_test_project_properties.py b/scripts/o3de/tests/unit_test_project_properties.py index 0236e6cf90..1bcc6dcef3 100644 --- a/scripts/o3de/tests/unit_test_project_properties.py +++ b/scripts/o3de/tests/unit_test_project_properties.py @@ -16,6 +16,7 @@ from o3de import project_properties TEST_PROJECT_JSON_PAYLOAD = ''' { "project_name": "TestProject", + "project_id": "{24114e69-306d-4de6-b3b4-4cb1a3eca58e}" "origin": "The primary repo for TestProject goes here: i.e. http://www.mydomain.com", "license": "What license TestProject uses goes here: i.e. https://opensource.org/licenses/MIT", "display_name": "TestProject", @@ -45,20 +46,20 @@ def init_project_json_data(request): @pytest.mark.usefixtures('init_project_json_data') class TestEditProjectProperties: - @pytest.mark.parametrize("project_path, project_name, project_new_name, project_origin, project_display,\ - project_summary, project_icon, add_tags, delete_tags,\ - replace_tags, expected_result", [ + @pytest.mark.parametrize("project_path, project_name, project_new_name, project_id, project_origin,\ + project_display, project_summary, project_icon,\ + add_tags, delete_tags, replace_tags, expected_result", [ pytest.param(pathlib.PurePath('E:/TestProject'), - 'test', 'test', 'editing by pytest', 'Unit Test', 'pyTest project', 'pytest.bmp', 'A B C', + 'test', 'test', 'editing by pytest', 'ID', 'Unit Test', 'pyTest project', 'pytest.bmp', 'A B C', 'B', 'D E F', 0), pytest.param('', - 'test', 'test', 'editing by pytest', 'Unit Test', 'pyTest project', 'pytest.bmp', 'A B C', + 'test', 'test', 'editing by pytest', 'ID', 'Unit Test', 'pyTest project', 'pytest.bmp', 'A B C', 'B', 'D E F', 1) ] ) - def test_edit_project_properties(self, project_path, project_name, project_new_name, project_origin, project_display, - project_summary, project_icon, add_tags, delete_tags, - replace_tags, expected_result): + def test_edit_project_properties(self, project_path, project_name, project_new_name, project_origin, project_id, + project_display,project_summary, project_icon, add_tags, + delete_tags, replace_tags, expected_result): def get_project_json_data(project_name: str, project_path) -> dict: if not project_path: @@ -72,12 +73,14 @@ class TestEditProjectProperties: with patch('o3de.manifest.get_project_json_data', side_effect=get_project_json_data) as get_project_json_data_patch, \ patch('o3de.manifest.save_o3de_manifest', side_effect=save_o3de_manifest) as save_o3de_manifest_patch: - result = project_properties.edit_project_props(project_path, project_name, project_new_name, project_origin, - project_display, project_summary, project_icon, - add_tags, delete_tags, replace_tags) + result = project_properties.edit_project_props(project_path, project_name, project_new_name, project_id, + project_origin, project_display, project_summary, project_icon, + add_tags, delete_tags, replace_tags) assert result == expected_result if project_path: assert self.project_json.data + assert self.project_json.data.get('project_name', '') == project_new_name + assert self.project_json.data.get('project_id', '') == project_id assert self.project_json.data.get('origin', '') == project_origin assert self.project_json.data.get('display_name', '') == project_display assert self.project_json.data.get('summary', '') == project_summary From 1348b6e8258aa02302f1cc872a1f46629c023819 Mon Sep 17 00:00:00 2001 From: nggieber <52797929+AMZN-nggieber@users.noreply.github.com> Date: Mon, 6 Dec 2021 09:52:52 -0800 Subject: [PATCH 03/70] Removed q file Signed-off-by: nggieber <52797929+AMZN-nggieber@users.noreply.github.com> --- Code/Tools/ProjectManager/CMakeLists.txt | 2 - q | 48 ------------------------ 2 files changed, 50 deletions(-) delete mode 100644 q diff --git a/Code/Tools/ProjectManager/CMakeLists.txt b/Code/Tools/ProjectManager/CMakeLists.txt index b0e7ee9697..e76547ab5d 100644 --- a/Code/Tools/ProjectManager/CMakeLists.txt +++ b/Code/Tools/ProjectManager/CMakeLists.txt @@ -90,8 +90,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED) 3rdParty::Python 3rdParty::pybind11 AZ::AzCore - AZ::AzCoreTestCommon - AZ::AzTestShared AZ::AzTest AZ::AzFramework AZ::AzFrameworkTestShared diff --git a/q b/q deleted file mode 100644 index fc1c268aef..0000000000 --- a/q +++ /dev/null @@ -1,48 +0,0 @@ - Prism/AddEditGemsButton - Prism/AddLicenseToGemCatalog - Prism/AddRemoveRepoWorkingUI - Prism/AddRepoDialog -* Prism/CmakeVariablesPerProject - Prism/CreateRepositoryScreen - Prism/CustomBuildParameters - Prism/CustomTabWidgetForEngine - Prism/DeleteUpdateGemsUI - Prism/DisplayAddGemInfo - Prism/EnterInFileDialog - Prism/ExternalLinkWarning - Prism/FasterBuildTimes - Prism/FixGemCart - Prism/FixGemCatalogHyperlinks - Prism/FixGemSelectedFilter - Prism/FixRemovedProjectStillShown - Prism/FixTabOverlayOnStartup - Prism/GemCatalogMenu - Prism/GemCatalogTests - Prism/GemCatalogWithoutProject - Prism/GemRepoInspector - Prism/RefreshAfterDownload - Prism/RefreshGemRepos - Prism/RefreshOnDownload - Prism/RefreshRepoButtonDisablesRepo - Prism/RemoteGemWarning - Prism/RemoveTabFocus - Prism/ResetBuildAndCacheAfterProjectMove - Prism/SearchForGemsFromTags - Prism/ShowGemDownloadStatus - Prism/ShowGemPreview - Prism/ShowGemRepoGems - Prism/ShowGemsInRepo - Prism/ShowRepoGems - Prism/ShowRepoList - Prism/UpdateTemplatePics - Prism/UseGemDisplayNames - Prism/VS2019InstallInstructions - Prism/WarnExternalLink - Prism/WarnVSNotInstalled - Prism/cherry-pick-gem-catalog-fix - Prism/gitRepos - development - new-feature - racoonteurs - stabilization/2110 - stabilization/2111RTE From a2fec5c367eb2f047493e5a504fcd1512a502660 Mon Sep 17 00:00:00 2001 From: Tobias Alexander Franke Date: Tue, 26 Oct 2021 09:48:50 +0800 Subject: [PATCH 04/70] keyword bug fixed Signed-off-by: T.J. McGrath-Daly --- .../ComponentEntityEditorPlugin/UI/Outliner/OutlinerWidget.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Code/Editor/Plugins/ComponentEntityEditorPlugin/UI/Outliner/OutlinerWidget.cpp b/Code/Editor/Plugins/ComponentEntityEditorPlugin/UI/Outliner/OutlinerWidget.cpp index af58ac4b6b..15bdfa9bf2 100644 --- a/Code/Editor/Plugins/ComponentEntityEditorPlugin/UI/Outliner/OutlinerWidget.cpp +++ b/Code/Editor/Plugins/ComponentEntityEditorPlugin/UI/Outliner/OutlinerWidget.cpp @@ -1281,6 +1281,8 @@ void OutlinerWidget::OnSearchTextChanged(const QString& activeTextFilter) m_listModel->SearchStringChanged(filterString); m_proxyModel->UpdateFilter(); + + m_gui->m_objectTree->expandAll(); } void OutlinerWidget::OnFilterChanged(const AzQtComponents::SearchTypeFilterList& activeTypeFilters) From 28e5e8b217b4f59fcb4791800e1c59adb4f6cbcc Mon Sep 17 00:00:00 2001 From: nggieber <52797929+AMZN-nggieber@users.noreply.github.com> Date: Wed, 8 Dec 2021 05:43:10 -0800 Subject: [PATCH 05/70] Fix Project Built Tests Signed-off-by: nggieber <52797929+AMZN-nggieber@users.noreply.github.com> --- .../tests/ProjectManagerSettingsTests.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Code/Tools/ProjectManager/tests/ProjectManagerSettingsTests.cpp b/Code/Tools/ProjectManager/tests/ProjectManagerSettingsTests.cpp index 7ab93f798c..ba0cebd035 100644 --- a/Code/Tools/ProjectManager/tests/ProjectManagerSettingsTests.cpp +++ b/Code/Tools/ProjectManager/tests/ProjectManagerSettingsTests.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -40,11 +41,19 @@ namespace O3DE::ProjectManager m_registry->SetContext(m_serializeContext.get()); m_registry->SetContext(m_registrationContext.get()); + AZ::JsonSystemComponent::Reflect(m_registrationContext.get()); + + m_serializeContext->RegisterGenericType>(); + m_projectInfo.m_path = "Z:/ProjectTestPath"; } void TearDown() override { + m_registrationContext->EnableRemoveReflection(); + AZ::JsonSystemComponent::Reflect(m_registrationContext.get()); + m_registrationContext->DisableRemoveReflection(); + m_registrationContext.reset(); m_serializeContext.reset(); @@ -167,9 +176,9 @@ namespace O3DE::ProjectManager TEST_F(ProjectManagerSettingsTests, PMSettings_SetProjectBuiltUnsuccessfully_ReturnsFalse) { // Don't save to disk in test - EXPECT_TRUE(PMSettings::SetProjectBuiltSuccessfully(m_projectInfo, true, /*saveToDisk*/ false)); + EXPECT_TRUE(PMSettings::SetProjectBuiltSuccessfully(m_projectInfo, false, /*saveToDisk*/ false)); - bool buildResult = true; + bool buildResult = false; EXPECT_TRUE(PMSettings::GetProjectBuiltSuccessfully(buildResult, m_projectInfo)); EXPECT_FALSE(buildResult); } From c7893e0386179b49c0011fe0f96492817cad016f Mon Sep 17 00:00:00 2001 From: nggieber <52797929+AMZN-nggieber@users.noreply.github.com> Date: Wed, 8 Dec 2021 05:54:41 -0800 Subject: [PATCH 06/70] Remove unecessary change to CMakeLists.txt Signed-off-by: nggieber <52797929+AMZN-nggieber@users.noreply.github.com> --- Code/Tools/ProjectManager/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/Code/Tools/ProjectManager/CMakeLists.txt b/Code/Tools/ProjectManager/CMakeLists.txt index e76547ab5d..9974125ffb 100644 --- a/Code/Tools/ProjectManager/CMakeLists.txt +++ b/Code/Tools/ProjectManager/CMakeLists.txt @@ -89,7 +89,6 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED) 3rdParty::Qt::Widgets 3rdParty::Python 3rdParty::pybind11 - AZ::AzCore AZ::AzTest AZ::AzFramework AZ::AzFrameworkTestShared From 7f9ba0d0b62fa2a6211dbaea1900fbdd177b17f6 Mon Sep 17 00:00:00 2001 From: nwidmaie Date: Wed, 8 Dec 2021 12:43:38 -0800 Subject: [PATCH 07/70] Converting PbrMaterialChart to prefab, and moving to AutomatedTesting project Signed-off-by: nwidmaie --- .../PbrMaterialChart/PbrMaterialChart.prefab | 5361 +++++++++++++++++ .../PbrMaterialChart/materials/basic.material | 32 + .../materials/basic_m00_r00.material | 13 + .../materials/basic_m00_r01.material | 13 + .../materials/basic_m00_r02.material | 13 + .../materials/basic_m00_r03.material | 13 + .../materials/basic_m00_r04.material | 13 + .../materials/basic_m00_r05.material | 13 + .../materials/basic_m00_r06.material | 13 + .../materials/basic_m00_r07.material | 13 + .../materials/basic_m00_r08.material | 13 + .../materials/basic_m00_r09.material | 13 + .../materials/basic_m00_r10.material | 13 + .../materials/basic_m10_r00.material | 13 + .../materials/basic_m10_r01.material | 13 + .../materials/basic_m10_r02.material | 13 + .../materials/basic_m10_r03.material | 13 + .../materials/basic_m10_r04.material | 13 + .../materials/basic_m10_r05.material | 13 + .../materials/basic_m10_r06.material | 13 + .../materials/basic_m10_r07.material | 13 + .../materials/basic_m10_r08.material | 13 + .../materials/basic_m10_r09.material | 13 + .../materials/basic_m10_r10.material | 13 + .../Levels/PbrMaterialChart/tags.txt | 12 + AutomatedTesting/Objects/sphere.fbx | 3 + 26 files changed, 5694 insertions(+) create mode 100644 AutomatedTesting/Levels/PbrMaterialChart/PbrMaterialChart.prefab create mode 100644 AutomatedTesting/Levels/PbrMaterialChart/materials/basic.material create mode 100644 AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r00.material create mode 100644 AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r01.material create mode 100644 AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r02.material create mode 100644 AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r03.material create mode 100644 AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r04.material create mode 100644 AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r05.material create mode 100644 AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r06.material create mode 100644 AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r07.material create mode 100644 AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r08.material create mode 100644 AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r09.material create mode 100644 AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r10.material create mode 100644 AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r00.material create mode 100644 AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r01.material create mode 100644 AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r02.material create mode 100644 AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r03.material create mode 100644 AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r04.material create mode 100644 AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r05.material create mode 100644 AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r06.material create mode 100644 AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r07.material create mode 100644 AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r08.material create mode 100644 AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r09.material create mode 100644 AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r10.material create mode 100644 AutomatedTesting/Levels/PbrMaterialChart/tags.txt create mode 100644 AutomatedTesting/Objects/sphere.fbx diff --git a/AutomatedTesting/Levels/PbrMaterialChart/PbrMaterialChart.prefab b/AutomatedTesting/Levels/PbrMaterialChart/PbrMaterialChart.prefab new file mode 100644 index 0000000000..faa93597de --- /dev/null +++ b/AutomatedTesting/Levels/PbrMaterialChart/PbrMaterialChart.prefab @@ -0,0 +1,5361 @@ +{ + "ContainerEntity": { + "Id": "ContainerEntity", + "Name": "PbrMaterialChart", + "Components": { + "Component_[10182366347512475253]": { + "$type": "EditorPrefabComponent", + "Id": 10182366347512475253 + }, + "Component_[12917798267488243668]": { + "$type": "EditorPendingCompositionComponent", + "Id": 12917798267488243668 + }, + "Component_[3261249813163778338]": { + "$type": "EditorOnlyEntityComponent", + "Id": 3261249813163778338 + }, + "Component_[3837204912784440039]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 3837204912784440039 + }, + "Component_[4272963378099646759]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 4272963378099646759, + "Parent Entity": "" + }, + "Component_[4848458548047175816]": { + "$type": "EditorVisibilityComponent", + "Id": 4848458548047175816 + }, + "Component_[5787060997243919943]": { + "$type": "EditorInspectorComponent", + "Id": 5787060997243919943 + }, + "Component_[7804170251266531779]": { + "$type": "EditorLockComponent", + "Id": 7804170251266531779 + }, + "Component_[7874177159288365422]": { + "$type": "EditorEntitySortComponent", + "Id": 7874177159288365422 + }, + "Component_[8018146290632383969]": { + "$type": "EditorEntityIconComponent", + "Id": 8018146290632383969 + }, + "Component_[8452360690590857075]": { + "$type": "SelectionComponent", + "Id": 8452360690590857075 + } + } + }, + "Entities": { + "Entity_[1579029125278]": { + "Id": "Entity_[1579029125278]", + "Name": "PointLights", + "Components": { + "Component_[12510478104502833762]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 12510478104502833762 + }, + "Component_[13423580362045259926]": { + "$type": "EditorOnlyEntityComponent", + "Id": 13423580362045259926 + }, + "Component_[13763004328692227859]": { + "$type": "EditorEntityIconComponent", + "Id": 13763004328692227859 + }, + "Component_[2520589158620366474]": { + "$type": "EditorInspectorComponent", + "Id": 2520589158620366474, + "ComponentOrderEntryArray": [ + { + "ComponentId": 534931914642899990 + } + ] + }, + "Component_[534931914642899990]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 534931914642899990, + "Parent Entity": "Entity_[311518247264]", + "Transform Data": { + "Translate": [ + -0.02220340073108673, + 0.013456299901008606, + -0.00310519989579916 + ] + } + }, + "Component_[5737862213737495371]": { + "$type": "EditorEntitySortComponent", + "Id": 5737862213737495371, + "Child Entity Order": [ + "Entity_[1656338536606]", + "Entity_[1660633503902]", + "Entity_[1664928471198]", + "Entity_[1669223438494]", + "Entity_[1673518405790]", + "Entity_[1677813373086]", + "Entity_[1686403307678]", + "Entity_[1690698274974]", + "Entity_[1694993242270]", + "Entity_[1699288209566]", + "Entity_[1703583176862]", + "Entity_[1707878144158]", + "Entity_[1712173111454]", + "Entity_[1716468078750]", + "Entity_[464906102212]", + "Entity_[494970873284]", + "Entity_[460611134916]", + "Entity_[490675905988]", + "Entity_[456316167620]", + "Entity_[486380938692]", + "Entity_[452021200324]", + "Entity_[482085971396]", + "Entity_[447726233028]", + "Entity_[477791004100]", + "Entity_[443431265732]", + "Entity_[473496036804]", + "Entity_[439136298436]", + "Entity_[469201069508]" + ] + }, + "Component_[5835050117930709038]": { + "$type": "EditorLockComponent", + "Id": 5835050117930709038 + }, + "Component_[6088690331735476148]": { + "$type": "EditorVisibilityComponent", + "Id": 6088690331735476148 + }, + "Component_[749445421357843144]": { + "$type": "EditorPendingCompositionComponent", + "Id": 749445421357843144 + }, + "Component_[7514335123333124112]": { + "$type": "SelectionComponent", + "Id": 7514335123333124112 + } + } + }, + "Entity_[1656338536606]": { + "Id": "Entity_[1656338536606]", + "Name": "Light", + "Components": { + "Component_[12284008075844705430]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 12284008075844705430, + "Parent Entity": "Entity_[1579029125278]", + "Transform Data": { + "Translate": [ + 7.999998569488525, + 0.0, + 6.0 + ] + } + }, + "Component_[13457184847449496840]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 13457184847449496840 + }, + "Component_[14431842353830635996]": { + "$type": "EditorLockComponent", + "Id": 14431842353830635996 + }, + "Component_[1473579476469110229]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1473579476469110229 + }, + "Component_[17008596888127953988]": { + "$type": "EditorEntitySortComponent", + "Id": 17008596888127953988 + }, + "Component_[17246196475221723560]": { + "$type": "EditorInspectorComponent", + "Id": 17246196475221723560, + "ComponentOrderEntryArray": [ + { + "ComponentId": 12284008075844705430 + }, + { + "ComponentId": 7864910209001174169, + "SortIndex": 1 + } + ] + }, + "Component_[18388752482036682870]": { + "$type": "EditorOnlyEntityComponent", + "Id": 18388752482036682870 + }, + "Component_[3917765902796274739]": { + "$type": "EditorEntityIconComponent", + "Id": 3917765902796274739 + }, + "Component_[4143676462074671972]": { + "$type": "AZ::Render::EditorAreaLightComponent", + "Id": 4143676462074671972, + "Controller": { + "Configuration": { + "LightType": 1, + "IntensityMode": 1, + "Intensity": 50.0, + "AttenuationRadius": 79.26654815673828 + } + } + }, + "Component_[4863305662794796025]": { + "$type": "EditorVisibilityComponent", + "Id": 4863305662794796025 + }, + "Component_[5730069629780503964]": { + "$type": "EditorSphereShapeComponent", + "Id": 5730069629780503964, + "ShapeColor": [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + "SphereShape": { + "Configuration": { + "Radius": 0.05000000074505806 + } + } + }, + "Component_[5902189275159544426]": { + "$type": "SelectionComponent", + "Id": 5902189275159544426 + } + } + }, + "Entity_[1660633503902]": { + "Id": "Entity_[1660633503902]", + "Name": "Light", + "Components": { + "Component_[12284008075844705430]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 12284008075844705430, + "Parent Entity": "Entity_[1579029125278]", + "Transform Data": { + "Translate": [ + 7.999998569488525, + 12.0, + 6.0 + ] + } + }, + "Component_[12938187889472820644]": { + "$type": "EditorSphereShapeComponent", + "Id": 12938187889472820644, + "ShapeColor": [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + "SphereShape": { + "Configuration": { + "Radius": 0.05000000074505806 + } + } + }, + "Component_[13457184847449496840]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 13457184847449496840 + }, + "Component_[14431842353830635996]": { + "$type": "EditorLockComponent", + "Id": 14431842353830635996 + }, + "Component_[1473579476469110229]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1473579476469110229 + }, + "Component_[17008596888127953988]": { + "$type": "EditorEntitySortComponent", + "Id": 17008596888127953988 + }, + "Component_[17246196475221723560]": { + "$type": "EditorInspectorComponent", + "Id": 17246196475221723560, + "ComponentOrderEntryArray": [ + { + "ComponentId": 12284008075844705430 + }, + { + "ComponentId": 7864910209001174169, + "SortIndex": 1 + } + ] + }, + "Component_[18388752482036682870]": { + "$type": "EditorOnlyEntityComponent", + "Id": 18388752482036682870 + }, + "Component_[3917765902796274739]": { + "$type": "EditorEntityIconComponent", + "Id": 3917765902796274739 + }, + "Component_[4143676462074671972]": { + "$type": "AZ::Render::EditorAreaLightComponent", + "Id": 4143676462074671972, + "Controller": { + "Configuration": { + "LightType": 1, + "IntensityMode": 1, + "Intensity": 50.0, + "AttenuationRadius": 79.26654815673828 + } + } + }, + "Component_[4863305662794796025]": { + "$type": "EditorVisibilityComponent", + "Id": 4863305662794796025 + }, + "Component_[5902189275159544426]": { + "$type": "SelectionComponent", + "Id": 5902189275159544426 + } + } + }, + "Entity_[1664928471198]": { + "Id": "Entity_[1664928471198]", + "Name": "Light", + "Components": { + "Component_[12284008075844705430]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 12284008075844705430, + "Parent Entity": "Entity_[1579029125278]", + "Transform Data": { + "Translate": [ + 7.999998569488525, + -10.0, + 6.0 + ] + } + }, + "Component_[13457184847449496840]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 13457184847449496840 + }, + "Component_[14431842353830635996]": { + "$type": "EditorLockComponent", + "Id": 14431842353830635996 + }, + "Component_[1473579476469110229]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1473579476469110229 + }, + "Component_[15916755507523201463]": { + "$type": "EditorSphereShapeComponent", + "Id": 15916755507523201463, + "ShapeColor": [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + "SphereShape": { + "Configuration": { + "Radius": 0.05000000074505806 + } + } + }, + "Component_[17008596888127953988]": { + "$type": "EditorEntitySortComponent", + "Id": 17008596888127953988 + }, + "Component_[17246196475221723560]": { + "$type": "EditorInspectorComponent", + "Id": 17246196475221723560, + "ComponentOrderEntryArray": [ + { + "ComponentId": 12284008075844705430 + }, + { + "ComponentId": 7864910209001174169, + "SortIndex": 1 + } + ] + }, + "Component_[18388752482036682870]": { + "$type": "EditorOnlyEntityComponent", + "Id": 18388752482036682870 + }, + "Component_[3917765902796274739]": { + "$type": "EditorEntityIconComponent", + "Id": 3917765902796274739 + }, + "Component_[4143676462074671972]": { + "$type": "AZ::Render::EditorAreaLightComponent", + "Id": 4143676462074671972, + "Controller": { + "Configuration": { + "LightType": 1, + "IntensityMode": 1, + "Intensity": 50.0, + "AttenuationRadius": 79.26654815673828 + } + } + }, + "Component_[4863305662794796025]": { + "$type": "EditorVisibilityComponent", + "Id": 4863305662794796025 + }, + "Component_[5902189275159544426]": { + "$type": "SelectionComponent", + "Id": 5902189275159544426 + } + } + }, + "Entity_[1669223438494]": { + "Id": "Entity_[1669223438494]", + "Name": "Light", + "Components": { + "Component_[11441320324927657842]": { + "$type": "EditorSphereShapeComponent", + "Id": 11441320324927657842, + "ShapeColor": [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + "SphereShape": { + "Configuration": { + "Radius": 0.05000000074505806 + } + } + }, + "Component_[12284008075844705430]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 12284008075844705430, + "Parent Entity": "Entity_[1579029125278]", + "Transform Data": { + "Translate": [ + 7.999998092651367, + 0.0, + -6.0 + ] + } + }, + "Component_[13457184847449496840]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 13457184847449496840 + }, + "Component_[14431842353830635996]": { + "$type": "EditorLockComponent", + "Id": 14431842353830635996 + }, + "Component_[1473579476469110229]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1473579476469110229 + }, + "Component_[17008596888127953988]": { + "$type": "EditorEntitySortComponent", + "Id": 17008596888127953988 + }, + "Component_[17246196475221723560]": { + "$type": "EditorInspectorComponent", + "Id": 17246196475221723560, + "ComponentOrderEntryArray": [ + { + "ComponentId": 12284008075844705430 + }, + { + "ComponentId": 7864910209001174169, + "SortIndex": 1 + } + ] + }, + "Component_[18388752482036682870]": { + "$type": "EditorOnlyEntityComponent", + "Id": 18388752482036682870 + }, + "Component_[3917765902796274739]": { + "$type": "EditorEntityIconComponent", + "Id": 3917765902796274739 + }, + "Component_[4143676462074671972]": { + "$type": "AZ::Render::EditorAreaLightComponent", + "Id": 4143676462074671972, + "Controller": { + "Configuration": { + "LightType": 1, + "IntensityMode": 1, + "Intensity": 50.0, + "AttenuationRadius": 79.26654815673828 + } + } + }, + "Component_[4863305662794796025]": { + "$type": "EditorVisibilityComponent", + "Id": 4863305662794796025 + }, + "Component_[5902189275159544426]": { + "$type": "SelectionComponent", + "Id": 5902189275159544426 + } + } + }, + "Entity_[1673518405790]": { + "Id": "Entity_[1673518405790]", + "Name": "Light", + "Components": { + "Component_[12284008075844705430]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 12284008075844705430, + "Parent Entity": "Entity_[1579029125278]", + "Transform Data": { + "Translate": [ + 7.999998092651367, + 12.0, + -6.0 + ] + } + }, + "Component_[13457184847449496840]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 13457184847449496840 + }, + "Component_[14431842353830635996]": { + "$type": "EditorLockComponent", + "Id": 14431842353830635996 + }, + "Component_[1473579476469110229]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1473579476469110229 + }, + "Component_[17008596888127953988]": { + "$type": "EditorEntitySortComponent", + "Id": 17008596888127953988 + }, + "Component_[17246196475221723560]": { + "$type": "EditorInspectorComponent", + "Id": 17246196475221723560, + "ComponentOrderEntryArray": [ + { + "ComponentId": 12284008075844705430 + }, + { + "ComponentId": 7864910209001174169, + "SortIndex": 1 + } + ] + }, + "Component_[18388752482036682870]": { + "$type": "EditorOnlyEntityComponent", + "Id": 18388752482036682870 + }, + "Component_[3917765902796274739]": { + "$type": "EditorEntityIconComponent", + "Id": 3917765902796274739 + }, + "Component_[4143676462074671972]": { + "$type": "AZ::Render::EditorAreaLightComponent", + "Id": 4143676462074671972, + "Controller": { + "Configuration": { + "LightType": 1, + "IntensityMode": 1, + "Intensity": 50.0, + "AttenuationRadius": 79.26654815673828 + } + } + }, + "Component_[4863305662794796025]": { + "$type": "EditorVisibilityComponent", + "Id": 4863305662794796025 + }, + "Component_[5078442133583813661]": { + "$type": "EditorSphereShapeComponent", + "Id": 5078442133583813661, + "ShapeColor": [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + "SphereShape": { + "Configuration": { + "Radius": 0.05000000074505806 + } + } + }, + "Component_[5902189275159544426]": { + "$type": "SelectionComponent", + "Id": 5902189275159544426 + } + } + }, + "Entity_[1677813373086]": { + "Id": "Entity_[1677813373086]", + "Name": "Light", + "Components": { + "Component_[12284008075844705430]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 12284008075844705430, + "Parent Entity": "Entity_[1579029125278]", + "Transform Data": { + "Translate": [ + 7.999998092651367, + -10.0, + -6.0 + ] + } + }, + "Component_[13457184847449496840]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 13457184847449496840 + }, + "Component_[14431842353830635996]": { + "$type": "EditorLockComponent", + "Id": 14431842353830635996 + }, + "Component_[1473579476469110229]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1473579476469110229 + }, + "Component_[17008596888127953988]": { + "$type": "EditorEntitySortComponent", + "Id": 17008596888127953988 + }, + "Component_[17246196475221723560]": { + "$type": "EditorInspectorComponent", + "Id": 17246196475221723560, + "ComponentOrderEntryArray": [ + { + "ComponentId": 12284008075844705430 + }, + { + "ComponentId": 7864910209001174169, + "SortIndex": 1 + } + ] + }, + "Component_[18388752482036682870]": { + "$type": "EditorOnlyEntityComponent", + "Id": 18388752482036682870 + }, + "Component_[3917765902796274739]": { + "$type": "EditorEntityIconComponent", + "Id": 3917765902796274739 + }, + "Component_[4143676462074671972]": { + "$type": "AZ::Render::EditorAreaLightComponent", + "Id": 4143676462074671972, + "Controller": { + "Configuration": { + "LightType": 1, + "IntensityMode": 1, + "Intensity": 50.0, + "AttenuationRadius": 79.26654815673828 + } + } + }, + "Component_[4863305662794796025]": { + "$type": "EditorVisibilityComponent", + "Id": 4863305662794796025 + }, + "Component_[5902189275159544426]": { + "$type": "SelectionComponent", + "Id": 5902189275159544426 + }, + "Component_[9989753495273560981]": { + "$type": "EditorSphereShapeComponent", + "Id": 9989753495273560981, + "ShapeColor": [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + "SphereShape": { + "Configuration": { + "Radius": 0.05000000074505806 + } + } + } + } + }, + "Entity_[1686403307678]": { + "Id": "Entity_[1686403307678]", + "Name": "Light", + "Components": { + "Component_[12284008075844705430]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 12284008075844705430, + "Parent Entity": "Entity_[1579029125278]", + "Transform Data": { + "Translate": [ + 7.999998569488525, + -5.0, + 6.0 + ] + } + }, + "Component_[13457184847449496840]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 13457184847449496840 + }, + "Component_[14431842353830635996]": { + "$type": "EditorLockComponent", + "Id": 14431842353830635996 + }, + "Component_[1473579476469110229]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1473579476469110229 + }, + "Component_[16566594251448483688]": { + "$type": "EditorSphereShapeComponent", + "Id": 16566594251448483688, + "ShapeColor": [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + "SphereShape": { + "Configuration": { + "Radius": 0.05000000074505806 + } + } + }, + "Component_[17008596888127953988]": { + "$type": "EditorEntitySortComponent", + "Id": 17008596888127953988 + }, + "Component_[17246196475221723560]": { + "$type": "EditorInspectorComponent", + "Id": 17246196475221723560, + "ComponentOrderEntryArray": [ + { + "ComponentId": 12284008075844705430 + }, + { + "ComponentId": 7864910209001174169, + "SortIndex": 1 + } + ] + }, + "Component_[18388752482036682870]": { + "$type": "EditorOnlyEntityComponent", + "Id": 18388752482036682870 + }, + "Component_[3917765902796274739]": { + "$type": "EditorEntityIconComponent", + "Id": 3917765902796274739 + }, + "Component_[4143676462074671972]": { + "$type": "AZ::Render::EditorAreaLightComponent", + "Id": 4143676462074671972, + "Controller": { + "Configuration": { + "LightType": 1, + "IntensityMode": 1, + "Intensity": 50.0, + "AttenuationRadius": 79.26654815673828 + } + } + }, + "Component_[4863305662794796025]": { + "$type": "EditorVisibilityComponent", + "Id": 4863305662794796025 + }, + "Component_[5902189275159544426]": { + "$type": "SelectionComponent", + "Id": 5902189275159544426 + } + } + }, + "Entity_[1690698274974]": { + "Id": "Entity_[1690698274974]", + "Name": "Light", + "Components": { + "Component_[12284008075844705430]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 12284008075844705430, + "Parent Entity": "Entity_[1579029125278]", + "Transform Data": { + "Translate": [ + 7.999998092651367, + -5.0, + -6.0 + ] + } + }, + "Component_[13457184847449496840]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 13457184847449496840 + }, + "Component_[14431842353830635996]": { + "$type": "EditorLockComponent", + "Id": 14431842353830635996 + }, + "Component_[1473579476469110229]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1473579476469110229 + }, + "Component_[17008596888127953988]": { + "$type": "EditorEntitySortComponent", + "Id": 17008596888127953988 + }, + "Component_[17246196475221723560]": { + "$type": "EditorInspectorComponent", + "Id": 17246196475221723560, + "ComponentOrderEntryArray": [ + { + "ComponentId": 12284008075844705430 + }, + { + "ComponentId": 7864910209001174169, + "SortIndex": 1 + } + ] + }, + "Component_[18388752482036682870]": { + "$type": "EditorOnlyEntityComponent", + "Id": 18388752482036682870 + }, + "Component_[3917765902796274739]": { + "$type": "EditorEntityIconComponent", + "Id": 3917765902796274739 + }, + "Component_[4143676462074671972]": { + "$type": "AZ::Render::EditorAreaLightComponent", + "Id": 4143676462074671972, + "Controller": { + "Configuration": { + "LightType": 1, + "IntensityMode": 1, + "Intensity": 50.0, + "AttenuationRadius": 79.26654815673828 + } + } + }, + "Component_[4863305662794796025]": { + "$type": "EditorVisibilityComponent", + "Id": 4863305662794796025 + }, + "Component_[5902189275159544426]": { + "$type": "SelectionComponent", + "Id": 5902189275159544426 + }, + "Component_[7725312483818004226]": { + "$type": "EditorSphereShapeComponent", + "Id": 7725312483818004226, + "ShapeColor": [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + "SphereShape": { + "Configuration": { + "Radius": 0.05000000074505806 + } + } + } + } + }, + "Entity_[1694993242270]": { + "Id": "Entity_[1694993242270]", + "Name": "Light", + "Components": { + "Component_[11871171122135615232]": { + "$type": "EditorSphereShapeComponent", + "Id": 11871171122135615232, + "ShapeColor": [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + "SphereShape": { + "Configuration": { + "Radius": 0.05000000074505806 + } + } + }, + "Component_[12284008075844705430]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 12284008075844705430, + "Parent Entity": "Entity_[1579029125278]", + "Transform Data": { + "Translate": [ + 7.999998569488525, + 5.0, + 6.0 + ] + } + }, + "Component_[13457184847449496840]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 13457184847449496840 + }, + "Component_[14431842353830635996]": { + "$type": "EditorLockComponent", + "Id": 14431842353830635996 + }, + "Component_[1473579476469110229]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1473579476469110229 + }, + "Component_[17008596888127953988]": { + "$type": "EditorEntitySortComponent", + "Id": 17008596888127953988 + }, + "Component_[17246196475221723560]": { + "$type": "EditorInspectorComponent", + "Id": 17246196475221723560, + "ComponentOrderEntryArray": [ + { + "ComponentId": 12284008075844705430 + }, + { + "ComponentId": 7864910209001174169, + "SortIndex": 1 + } + ] + }, + "Component_[18388752482036682870]": { + "$type": "EditorOnlyEntityComponent", + "Id": 18388752482036682870 + }, + "Component_[3917765902796274739]": { + "$type": "EditorEntityIconComponent", + "Id": 3917765902796274739 + }, + "Component_[4143676462074671972]": { + "$type": "AZ::Render::EditorAreaLightComponent", + "Id": 4143676462074671972, + "Controller": { + "Configuration": { + "LightType": 1, + "IntensityMode": 1, + "Intensity": 50.0, + "AttenuationRadius": 79.26654815673828 + } + } + }, + "Component_[4863305662794796025]": { + "$type": "EditorVisibilityComponent", + "Id": 4863305662794796025 + }, + "Component_[5902189275159544426]": { + "$type": "SelectionComponent", + "Id": 5902189275159544426 + } + } + }, + "Entity_[1699288209566]": { + "Id": "Entity_[1699288209566]", + "Name": "Light", + "Components": { + "Component_[12284008075844705430]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 12284008075844705430, + "Parent Entity": "Entity_[1579029125278]", + "Transform Data": { + "Translate": [ + 7.999998092651367, + 5.0, + -6.0 + ] + } + }, + "Component_[13457184847449496840]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 13457184847449496840 + }, + "Component_[14431842353830635996]": { + "$type": "EditorLockComponent", + "Id": 14431842353830635996 + }, + "Component_[1473579476469110229]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1473579476469110229 + }, + "Component_[17008596888127953988]": { + "$type": "EditorEntitySortComponent", + "Id": 17008596888127953988 + }, + "Component_[17246196475221723560]": { + "$type": "EditorInspectorComponent", + "Id": 17246196475221723560, + "ComponentOrderEntryArray": [ + { + "ComponentId": 12284008075844705430 + }, + { + "ComponentId": 7864910209001174169, + "SortIndex": 1 + } + ] + }, + "Component_[18388752482036682870]": { + "$type": "EditorOnlyEntityComponent", + "Id": 18388752482036682870 + }, + "Component_[3917765902796274739]": { + "$type": "EditorEntityIconComponent", + "Id": 3917765902796274739 + }, + "Component_[4143676462074671972]": { + "$type": "AZ::Render::EditorAreaLightComponent", + "Id": 4143676462074671972, + "Controller": { + "Configuration": { + "LightType": 1, + "IntensityMode": 1, + "Intensity": 50.0, + "AttenuationRadius": 79.26654815673828 + } + } + }, + "Component_[4863305662794796025]": { + "$type": "EditorVisibilityComponent", + "Id": 4863305662794796025 + }, + "Component_[5902189275159544426]": { + "$type": "SelectionComponent", + "Id": 5902189275159544426 + }, + "Component_[946758060659896190]": { + "$type": "EditorSphereShapeComponent", + "Id": 946758060659896190, + "ShapeColor": [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + "SphereShape": { + "Configuration": { + "Radius": 0.05000000074505806 + } + } + } + } + }, + "Entity_[1703583176862]": { + "Id": "Entity_[1703583176862]", + "Name": "Light", + "Components": { + "Component_[12284008075844705430]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 12284008075844705430, + "Parent Entity": "Entity_[1579029125278]", + "Transform Data": { + "Translate": [ + 7.999998092651367, + -15.0, + -6.0 + ] + } + }, + "Component_[13457184847449496840]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 13457184847449496840 + }, + "Component_[14431842353830635996]": { + "$type": "EditorLockComponent", + "Id": 14431842353830635996 + }, + "Component_[1473579476469110229]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1473579476469110229 + }, + "Component_[17008596888127953988]": { + "$type": "EditorEntitySortComponent", + "Id": 17008596888127953988 + }, + "Component_[17246196475221723560]": { + "$type": "EditorInspectorComponent", + "Id": 17246196475221723560, + "ComponentOrderEntryArray": [ + { + "ComponentId": 12284008075844705430 + }, + { + "ComponentId": 7864910209001174169, + "SortIndex": 1 + } + ] + }, + "Component_[18375465984866315036]": { + "$type": "EditorSphereShapeComponent", + "Id": 18375465984866315036, + "ShapeColor": [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + "SphereShape": { + "Configuration": { + "Radius": 0.05000000074505806 + } + } + }, + "Component_[18388752482036682870]": { + "$type": "EditorOnlyEntityComponent", + "Id": 18388752482036682870 + }, + "Component_[3917765902796274739]": { + "$type": "EditorEntityIconComponent", + "Id": 3917765902796274739 + }, + "Component_[4143676462074671972]": { + "$type": "AZ::Render::EditorAreaLightComponent", + "Id": 4143676462074671972, + "Controller": { + "Configuration": { + "LightType": 1, + "IntensityMode": 1, + "Intensity": 50.0, + "AttenuationRadius": 79.26654815673828 + } + } + }, + "Component_[4863305662794796025]": { + "$type": "EditorVisibilityComponent", + "Id": 4863305662794796025 + }, + "Component_[5902189275159544426]": { + "$type": "SelectionComponent", + "Id": 5902189275159544426 + } + } + }, + "Entity_[1707878144158]": { + "Id": "Entity_[1707878144158]", + "Name": "Light", + "Components": { + "Component_[10544885903241229342]": { + "$type": "EditorSphereShapeComponent", + "Id": 10544885903241229342, + "ShapeColor": [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + "SphereShape": { + "Configuration": { + "Radius": 0.05000000074505806 + } + } + }, + "Component_[12284008075844705430]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 12284008075844705430, + "Parent Entity": "Entity_[1579029125278]", + "Transform Data": { + "Translate": [ + 7.999998569488525, + -15.0, + 6.0 + ] + } + }, + "Component_[13457184847449496840]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 13457184847449496840 + }, + "Component_[14431842353830635996]": { + "$type": "EditorLockComponent", + "Id": 14431842353830635996 + }, + "Component_[1473579476469110229]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1473579476469110229 + }, + "Component_[17008596888127953988]": { + "$type": "EditorEntitySortComponent", + "Id": 17008596888127953988 + }, + "Component_[17246196475221723560]": { + "$type": "EditorInspectorComponent", + "Id": 17246196475221723560, + "ComponentOrderEntryArray": [ + { + "ComponentId": 12284008075844705430 + }, + { + "ComponentId": 7864910209001174169, + "SortIndex": 1 + } + ] + }, + "Component_[18388752482036682870]": { + "$type": "EditorOnlyEntityComponent", + "Id": 18388752482036682870 + }, + "Component_[3917765902796274739]": { + "$type": "EditorEntityIconComponent", + "Id": 3917765902796274739 + }, + "Component_[4143676462074671972]": { + "$type": "AZ::Render::EditorAreaLightComponent", + "Id": 4143676462074671972, + "Controller": { + "Configuration": { + "LightType": 1, + "IntensityMode": 1, + "Intensity": 50.0, + "AttenuationRadius": 79.26654815673828 + } + } + }, + "Component_[4863305662794796025]": { + "$type": "EditorVisibilityComponent", + "Id": 4863305662794796025 + }, + "Component_[5902189275159544426]": { + "$type": "SelectionComponent", + "Id": 5902189275159544426 + } + } + }, + "Entity_[1712173111454]": { + "Id": "Entity_[1712173111454]", + "Name": "Light", + "Components": { + "Component_[12284008075844705430]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 12284008075844705430, + "Parent Entity": "Entity_[1579029125278]", + "Transform Data": { + "Translate": [ + 7.999998569488525, + 15.0, + 6.0 + ] + } + }, + "Component_[13457184847449496840]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 13457184847449496840 + }, + "Component_[14431842353830635996]": { + "$type": "EditorLockComponent", + "Id": 14431842353830635996 + }, + "Component_[1473579476469110229]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1473579476469110229 + }, + "Component_[17008596888127953988]": { + "$type": "EditorEntitySortComponent", + "Id": 17008596888127953988 + }, + "Component_[17246196475221723560]": { + "$type": "EditorInspectorComponent", + "Id": 17246196475221723560, + "ComponentOrderEntryArray": [ + { + "ComponentId": 12284008075844705430 + }, + { + "ComponentId": 7864910209001174169, + "SortIndex": 1 + } + ] + }, + "Component_[18388752482036682870]": { + "$type": "EditorOnlyEntityComponent", + "Id": 18388752482036682870 + }, + "Component_[2820371548226138928]": { + "$type": "EditorSphereShapeComponent", + "Id": 2820371548226138928, + "ShapeColor": [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + "SphereShape": { + "Configuration": { + "Radius": 0.05000000074505806 + } + } + }, + "Component_[3917765902796274739]": { + "$type": "EditorEntityIconComponent", + "Id": 3917765902796274739 + }, + "Component_[4143676462074671972]": { + "$type": "AZ::Render::EditorAreaLightComponent", + "Id": 4143676462074671972, + "Controller": { + "Configuration": { + "LightType": 1, + "IntensityMode": 1, + "Intensity": 50.0, + "AttenuationRadius": 79.26654815673828 + } + } + }, + "Component_[4863305662794796025]": { + "$type": "EditorVisibilityComponent", + "Id": 4863305662794796025 + }, + "Component_[5902189275159544426]": { + "$type": "SelectionComponent", + "Id": 5902189275159544426 + } + } + }, + "Entity_[1716468078750]": { + "Id": "Entity_[1716468078750]", + "Name": "Light", + "Components": { + "Component_[12284008075844705430]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 12284008075844705430, + "Parent Entity": "Entity_[1579029125278]", + "Transform Data": { + "Translate": [ + 7.999998092651367, + 15.0, + -6.0 + ] + } + }, + "Component_[13457184847449496840]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 13457184847449496840 + }, + "Component_[14431842353830635996]": { + "$type": "EditorLockComponent", + "Id": 14431842353830635996 + }, + "Component_[1473579476469110229]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1473579476469110229 + }, + "Component_[17008596888127953988]": { + "$type": "EditorEntitySortComponent", + "Id": 17008596888127953988 + }, + "Component_[17202118748985219545]": { + "$type": "EditorSphereShapeComponent", + "Id": 17202118748985219545, + "ShapeColor": [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + "SphereShape": { + "Configuration": { + "Radius": 0.05000000074505806 + } + } + }, + "Component_[17246196475221723560]": { + "$type": "EditorInspectorComponent", + "Id": 17246196475221723560, + "ComponentOrderEntryArray": [ + { + "ComponentId": 12284008075844705430 + }, + { + "ComponentId": 7864910209001174169, + "SortIndex": 1 + } + ] + }, + "Component_[18388752482036682870]": { + "$type": "EditorOnlyEntityComponent", + "Id": 18388752482036682870 + }, + "Component_[3917765902796274739]": { + "$type": "EditorEntityIconComponent", + "Id": 3917765902796274739 + }, + "Component_[4143676462074671972]": { + "$type": "AZ::Render::EditorAreaLightComponent", + "Id": 4143676462074671972, + "Controller": { + "Configuration": { + "LightType": 1, + "IntensityMode": 1, + "Intensity": 50.0, + "AttenuationRadius": 79.26654815673828 + } + } + }, + "Component_[4863305662794796025]": { + "$type": "EditorVisibilityComponent", + "Id": 4863305662794796025 + }, + "Component_[5902189275159544426]": { + "$type": "SelectionComponent", + "Id": 5902189275159544426 + } + } + }, + "Entity_[220034968733]": { + "Id": "Entity_[220034968733]", + "Name": "Ball00", + "Components": { + "Component_[11750162722213114821]": { + "$type": "SelectionComponent", + "Id": 11750162722213114821 + }, + "Component_[12608893098077724053]": { + "$type": "EditorEntitySortComponent", + "Id": 12608893098077724053 + }, + "Component_[13797422028724928908]": { + "$type": "AZ::Render::EditorMeshComponent", + "Id": 13797422028724928908, + "Controller": { + "Configuration": { + "ModelAsset": { + "assetId": { + "guid": "{61D16161-9F39-5A29-B927-ADF58E7E573B}", + "subId": 284780167 + }, + "assetHint": "objects/sphere.azmodel" + }, + "LodOverride": 255 + } + } + }, + "Component_[1492865274047869171]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 1492865274047869171 + }, + "Component_[15252998008739701164]": { + "$type": "EditorVisibilityComponent", + "Id": 15252998008739701164 + }, + "Component_[15365333384879292339]": { + "$type": "EditorInspectorComponent", + "Id": 15365333384879292339, + "ComponentOrderEntryArray": [ + { + "ComponentId": 5985506260224649992 + }, + { + "ComponentId": 13797422028724928908, + "SortIndex": 1 + }, + { + "ComponentId": 5200514760734239788, + "SortIndex": 2 + } + ] + }, + "Component_[18296307565715962470]": { + "$type": "EditorPendingCompositionComponent", + "Id": 18296307565715962470 + }, + "Component_[1940145586700385602]": { + "$type": "EditorOnlyEntityComponent", + "Id": 1940145586700385602 + }, + "Component_[4820397163316962417]": { + "$type": "EditorEntityIconComponent", + "Id": 4820397163316962417 + }, + "Component_[5200514760734239788]": { + "$type": "EditorMaterialComponent", + "Id": 5200514760734239788, + "Controller": { + "Configuration": { + "materials": { + "{}": { + "MaterialAsset": { + "assetId": { + "guid": "{1FD47684-2E9E-5525-BBCA-251795F9033C}" + }, + "assetHint": "levels/pbrmaterialchart/materials/basic_m00_r00.azmaterial" + } + } + } + } + }, + "materialSlotsByLodEnabled": true + }, + "Component_[5985506260224649992]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 5985506260224649992, + "Parent Entity": "Entity_[267279608989]" + }, + "Component_[7650403257628455609]": { + "$type": "EditorLockComponent", + "Id": 7650403257628455609 + } + } + }, + "Entity_[224329936029]": { + "Id": "Entity_[224329936029]", + "Name": "Ball01", + "Components": { + "Component_[11750162722213114821]": { + "$type": "SelectionComponent", + "Id": 11750162722213114821 + }, + "Component_[12608893098077724053]": { + "$type": "EditorEntitySortComponent", + "Id": 12608893098077724053 + }, + "Component_[13797422028724928908]": { + "$type": "AZ::Render::EditorMeshComponent", + "Id": 13797422028724928908, + "Controller": { + "Configuration": { + "ModelAsset": { + "assetId": { + "guid": "{61D16161-9F39-5A29-B927-ADF58E7E573B}", + "subId": 284780167 + }, + "assetHint": "objects/sphere.azmodel" + }, + "LodOverride": 255 + } + } + }, + "Component_[1492865274047869171]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 1492865274047869171 + }, + "Component_[15252998008739701164]": { + "$type": "EditorVisibilityComponent", + "Id": 15252998008739701164 + }, + "Component_[15365333384879292339]": { + "$type": "EditorInspectorComponent", + "Id": 15365333384879292339, + "ComponentOrderEntryArray": [ + { + "ComponentId": 5985506260224649992 + }, + { + "ComponentId": 13797422028724928908, + "SortIndex": 1 + }, + { + "ComponentId": 5200514760734239788, + "SortIndex": 2 + } + ] + }, + "Component_[18296307565715962470]": { + "$type": "EditorPendingCompositionComponent", + "Id": 18296307565715962470 + }, + "Component_[1940145586700385602]": { + "$type": "EditorOnlyEntityComponent", + "Id": 1940145586700385602 + }, + "Component_[4820397163316962417]": { + "$type": "EditorEntityIconComponent", + "Id": 4820397163316962417 + }, + "Component_[5200514760734239788]": { + "$type": "EditorMaterialComponent", + "Id": 5200514760734239788, + "Controller": { + "Configuration": { + "materials": { + "{}": { + "MaterialAsset": { + "assetId": { + "guid": "{B5660D78-818E-5273-AF3D-EC8189E2E6CB}" + }, + "assetHint": "levels/pbrmaterialchart/materials/basic_m00_r01.azmaterial" + } + } + } + } + }, + "materialSlotsByLodEnabled": true + }, + "Component_[5985506260224649992]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 5985506260224649992, + "Parent Entity": "Entity_[267279608989]", + "Transform Data": { + "Translate": [ + 1.9999995231628418, + 0.0, + 0.0 + ] + } + }, + "Component_[7650403257628455609]": { + "$type": "EditorLockComponent", + "Id": 7650403257628455609 + } + } + }, + "Entity_[224935554679]": { + "Id": "Entity_[224935554679]", + "Name": "Readme", + "Components": { + "Component_[10181355386221924165]": { + "$type": "EditorEntitySortComponent", + "Id": 10181355386221924165 + }, + "Component_[13072143045335196472]": { + "$type": "EditorVisibilityComponent", + "Id": 13072143045335196472 + }, + "Component_[16296166970503880418]": { + "$type": "EditorLockComponent", + "Id": 16296166970503880418 + }, + "Component_[18321120872779505013]": { + "$type": "SelectionComponent", + "Id": 18321120872779505013 + }, + "Component_[1837311764425750149]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 1837311764425750149 + }, + "Component_[1974029438267401978]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1974029438267401978 + }, + "Component_[6189137928773010292]": { + "$type": "EditorCommentComponent", + "Id": 6189137928773010292, + "Configuration": "This level shows StandardPBR materials on a metallic/roughness grid. We only use metallic=0 and metallic=1 for now because we don't have material scripting yet and we don't have 121 separate material files." + }, + "Component_[6233037103326923418]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 6233037103326923418, + "Parent Entity": "Entity_[311518247264]", + "Transform Data": { + "Translate": [ + 1014.3161010742188, + 1031.1007080078125, + -12.083206176757813 + ] + } + }, + "Component_[8021470524138221046]": { + "$type": "EditorOnlyEntityComponent", + "Id": 8021470524138221046 + }, + "Component_[869896445061711038]": { + "$type": "EditorInspectorComponent", + "Id": 869896445061711038, + "ComponentOrderEntryArray": [ + { + "ComponentId": 6233037103326923418 + }, + { + "ComponentId": 6189137928773010292, + "SortIndex": 1 + } + ] + }, + "Component_[8844687677689032541]": { + "$type": "EditorEntityIconComponent", + "Id": 8844687677689032541 + } + } + }, + "Entity_[227116497304]": { + "Id": "Entity_[227116497304]", + "Name": "IBL", + "Components": { + "Component_[10348929778265892995]": { + "$type": "EditorEntityIconComponent", + "Id": 10348929778265892995 + }, + "Component_[10541730177588140472]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 10541730177588140472, + "Parent Entity": "Entity_[311518247264]", + "Transform Data": { + "Translate": [ + -3.0222034454345703, + 6.013456344604492, + -51.00310516357422 + ] + } + }, + "Component_[11641917065646729270]": { + "$type": "SelectionComponent", + "Id": 11641917065646729270 + }, + "Component_[11941991254095032209]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 11941991254095032209 + }, + "Component_[16341934394936873930]": { + "$type": "EditorPendingCompositionComponent", + "Id": 16341934394936873930 + }, + "Component_[17356140692640757864]": { + "$type": "AZ::Render::EditorImageBasedLightComponent", + "Id": 17356140692640757864, + "Controller": { + "Configuration": { + "diffuseImageAsset": { + "assetId": { + "guid": "{AA144B9D-68F6-5191-9DD1-211B8D72802C}", + "subId": 3000 + }, + "assetHint": "materialeditor/lightingpresets/konzerthaus_latlong_iblskyboxcm_ibldiffuse.exr.streamingimage" + }, + "specularImageAsset": { + "assetId": { + "guid": "{AA144B9D-68F6-5191-9DD1-211B8D72802C}", + "subId": 2000 + }, + "assetHint": "materialeditor/lightingpresets/konzerthaus_latlong_iblskyboxcm_iblspecular.exr.streamingimage" + } + } + } + }, + "Component_[1774390999207442542]": { + "$type": "EditorEntitySortComponent", + "Id": 1774390999207442542 + }, + "Component_[18079152973233625329]": { + "$type": "EditorLockComponent", + "Id": 18079152973233625329 + }, + "Component_[5784619194218092681]": { + "$type": "EditorVisibilityComponent", + "Id": 5784619194218092681 + }, + "Component_[948613077222456118]": { + "$type": "EditorOnlyEntityComponent", + "Id": 948613077222456118 + }, + "Component_[9509912405166426602]": { + "$type": "EditorInspectorComponent", + "Id": 9509912405166426602, + "ComponentOrderEntryArray": [ + { + "ComponentId": 10541730177588140472 + }, + { + "ComponentId": 17356140692640757864, + "SortIndex": 1 + } + ] + } + } + }, + "Entity_[228624903325]": { + "Id": "Entity_[228624903325]", + "Name": "Ball02", + "Components": { + "Component_[11750162722213114821]": { + "$type": "SelectionComponent", + "Id": 11750162722213114821 + }, + "Component_[12608893098077724053]": { + "$type": "EditorEntitySortComponent", + "Id": 12608893098077724053 + }, + "Component_[13797422028724928908]": { + "$type": "AZ::Render::EditorMeshComponent", + "Id": 13797422028724928908, + "Controller": { + "Configuration": { + "ModelAsset": { + "assetId": { + "guid": "{61D16161-9F39-5A29-B927-ADF58E7E573B}", + "subId": 284780167 + }, + "assetHint": "objects/sphere.azmodel" + }, + "LodOverride": 255 + } + } + }, + "Component_[1492865274047869171]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 1492865274047869171 + }, + "Component_[15252998008739701164]": { + "$type": "EditorVisibilityComponent", + "Id": 15252998008739701164 + }, + "Component_[15365333384879292339]": { + "$type": "EditorInspectorComponent", + "Id": 15365333384879292339, + "ComponentOrderEntryArray": [ + { + "ComponentId": 5985506260224649992 + }, + { + "ComponentId": 13797422028724928908, + "SortIndex": 1 + }, + { + "ComponentId": 5200514760734239788, + "SortIndex": 2 + } + ] + }, + "Component_[18296307565715962470]": { + "$type": "EditorPendingCompositionComponent", + "Id": 18296307565715962470 + }, + "Component_[1940145586700385602]": { + "$type": "EditorOnlyEntityComponent", + "Id": 1940145586700385602 + }, + "Component_[4820397163316962417]": { + "$type": "EditorEntityIconComponent", + "Id": 4820397163316962417 + }, + "Component_[5200514760734239788]": { + "$type": "EditorMaterialComponent", + "Id": 5200514760734239788, + "Controller": { + "Configuration": { + "materials": { + "{}": { + "MaterialAsset": { + "assetId": { + "guid": "{512443BD-9511-5F13-A84A-3ED5DB9E9B5A}" + }, + "assetHint": "levels/pbrmaterialchart/materials/basic_m00_r02.azmaterial" + } + } + } + } + }, + "materialSlotsByLodEnabled": true + }, + "Component_[5985506260224649992]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 5985506260224649992, + "Parent Entity": "Entity_[267279608989]", + "Transform Data": { + "Translate": [ + 3.9999992847442627, + 0.0, + 0.0 + ] + } + }, + "Component_[7650403257628455609]": { + "$type": "EditorLockComponent", + "Id": 7650403257628455609 + } + } + }, + "Entity_[232919870621]": { + "Id": "Entity_[232919870621]", + "Name": "Ball03", + "Components": { + "Component_[11750162722213114821]": { + "$type": "SelectionComponent", + "Id": 11750162722213114821 + }, + "Component_[12608893098077724053]": { + "$type": "EditorEntitySortComponent", + "Id": 12608893098077724053 + }, + "Component_[13797422028724928908]": { + "$type": "AZ::Render::EditorMeshComponent", + "Id": 13797422028724928908, + "Controller": { + "Configuration": { + "ModelAsset": { + "assetId": { + "guid": "{61D16161-9F39-5A29-B927-ADF58E7E573B}", + "subId": 284780167 + }, + "assetHint": "objects/sphere.azmodel" + }, + "LodOverride": 255 + } + } + }, + "Component_[1492865274047869171]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 1492865274047869171 + }, + "Component_[15252998008739701164]": { + "$type": "EditorVisibilityComponent", + "Id": 15252998008739701164 + }, + "Component_[15365333384879292339]": { + "$type": "EditorInspectorComponent", + "Id": 15365333384879292339, + "ComponentOrderEntryArray": [ + { + "ComponentId": 5985506260224649992 + }, + { + "ComponentId": 13797422028724928908, + "SortIndex": 1 + }, + { + "ComponentId": 5200514760734239788, + "SortIndex": 2 + } + ] + }, + "Component_[18296307565715962470]": { + "$type": "EditorPendingCompositionComponent", + "Id": 18296307565715962470 + }, + "Component_[1940145586700385602]": { + "$type": "EditorOnlyEntityComponent", + "Id": 1940145586700385602 + }, + "Component_[4820397163316962417]": { + "$type": "EditorEntityIconComponent", + "Id": 4820397163316962417 + }, + "Component_[5200514760734239788]": { + "$type": "EditorMaterialComponent", + "Id": 5200514760734239788, + "Controller": { + "Configuration": { + "materials": { + "{}": { + "MaterialAsset": { + "assetId": { + "guid": "{E28A5CC5-4B8B-5B90-877A-3D92C75DC75A}" + }, + "assetHint": "levels/pbrmaterialchart/materials/basic_m00_r03.azmaterial" + } + } + } + } + }, + "materialSlotsByLodEnabled": true + }, + "Component_[5985506260224649992]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 5985506260224649992, + "Parent Entity": "Entity_[267279608989]", + "Transform Data": { + "Translate": [ + 5.999998569488525, + 0.0, + 0.0 + ] + } + }, + "Component_[7650403257628455609]": { + "$type": "EditorLockComponent", + "Id": 7650403257628455609 + } + } + }, + "Entity_[237214837917]": { + "Id": "Entity_[237214837917]", + "Name": "Ball04", + "Components": { + "Component_[11750162722213114821]": { + "$type": "SelectionComponent", + "Id": 11750162722213114821 + }, + "Component_[12608893098077724053]": { + "$type": "EditorEntitySortComponent", + "Id": 12608893098077724053 + }, + "Component_[13797422028724928908]": { + "$type": "AZ::Render::EditorMeshComponent", + "Id": 13797422028724928908, + "Controller": { + "Configuration": { + "ModelAsset": { + "assetId": { + "guid": "{61D16161-9F39-5A29-B927-ADF58E7E573B}", + "subId": 284780167 + }, + "assetHint": "objects/sphere.azmodel" + }, + "LodOverride": 255 + } + } + }, + "Component_[1492865274047869171]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 1492865274047869171 + }, + "Component_[15252998008739701164]": { + "$type": "EditorVisibilityComponent", + "Id": 15252998008739701164 + }, + "Component_[15365333384879292339]": { + "$type": "EditorInspectorComponent", + "Id": 15365333384879292339, + "ComponentOrderEntryArray": [ + { + "ComponentId": 5985506260224649992 + }, + { + "ComponentId": 13797422028724928908, + "SortIndex": 1 + }, + { + "ComponentId": 5200514760734239788, + "SortIndex": 2 + } + ] + }, + "Component_[18296307565715962470]": { + "$type": "EditorPendingCompositionComponent", + "Id": 18296307565715962470 + }, + "Component_[1940145586700385602]": { + "$type": "EditorOnlyEntityComponent", + "Id": 1940145586700385602 + }, + "Component_[4820397163316962417]": { + "$type": "EditorEntityIconComponent", + "Id": 4820397163316962417 + }, + "Component_[5200514760734239788]": { + "$type": "EditorMaterialComponent", + "Id": 5200514760734239788, + "Controller": { + "Configuration": { + "materials": { + "{}": { + "MaterialAsset": { + "assetId": { + "guid": "{1495BCCF-3F96-5D0B-8176-228DB22CEC82}" + }, + "assetHint": "levels/pbrmaterialchart/materials/basic_m00_r04.azmaterial" + } + } + } + } + }, + "materialSlotsByLodEnabled": true + }, + "Component_[5985506260224649992]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 5985506260224649992, + "Parent Entity": "Entity_[267279608989]", + "Transform Data": { + "Translate": [ + 7.999998092651367, + 0.0, + 0.0 + ] + } + }, + "Component_[7650403257628455609]": { + "$type": "EditorLockComponent", + "Id": 7650403257628455609 + } + } + }, + "Entity_[241509805213]": { + "Id": "Entity_[241509805213]", + "Name": "Ball05", + "Components": { + "Component_[11750162722213114821]": { + "$type": "SelectionComponent", + "Id": 11750162722213114821 + }, + "Component_[12608893098077724053]": { + "$type": "EditorEntitySortComponent", + "Id": 12608893098077724053 + }, + "Component_[13797422028724928908]": { + "$type": "AZ::Render::EditorMeshComponent", + "Id": 13797422028724928908, + "Controller": { + "Configuration": { + "ModelAsset": { + "assetId": { + "guid": "{61D16161-9F39-5A29-B927-ADF58E7E573B}", + "subId": 284780167 + }, + "assetHint": "objects/sphere.azmodel" + }, + "LodOverride": 255 + } + } + }, + "Component_[1492865274047869171]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 1492865274047869171 + }, + "Component_[15252998008739701164]": { + "$type": "EditorVisibilityComponent", + "Id": 15252998008739701164 + }, + "Component_[15365333384879292339]": { + "$type": "EditorInspectorComponent", + "Id": 15365333384879292339, + "ComponentOrderEntryArray": [ + { + "ComponentId": 5985506260224649992 + }, + { + "ComponentId": 13797422028724928908, + "SortIndex": 1 + }, + { + "ComponentId": 5200514760734239788, + "SortIndex": 2 + } + ] + }, + "Component_[18296307565715962470]": { + "$type": "EditorPendingCompositionComponent", + "Id": 18296307565715962470 + }, + "Component_[1940145586700385602]": { + "$type": "EditorOnlyEntityComponent", + "Id": 1940145586700385602 + }, + "Component_[4820397163316962417]": { + "$type": "EditorEntityIconComponent", + "Id": 4820397163316962417 + }, + "Component_[5200514760734239788]": { + "$type": "EditorMaterialComponent", + "Id": 5200514760734239788, + "Controller": { + "Configuration": { + "materials": { + "{}": { + "MaterialAsset": { + "assetId": { + "guid": "{40494612-0ABF-55B5-9C56-E968763FCFDE}" + }, + "assetHint": "levels/pbrmaterialchart/materials/basic_m00_r05.azmaterial" + } + } + } + } + }, + "materialSlotsByLodEnabled": true + }, + "Component_[5985506260224649992]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 5985506260224649992, + "Parent Entity": "Entity_[267279608989]", + "Transform Data": { + "Translate": [ + 9.999998092651367, + 0.0, + 0.0 + ] + } + }, + "Component_[7650403257628455609]": { + "$type": "EditorLockComponent", + "Id": 7650403257628455609 + } + } + }, + "Entity_[245804772509]": { + "Id": "Entity_[245804772509]", + "Name": "Ball06", + "Components": { + "Component_[11750162722213114821]": { + "$type": "SelectionComponent", + "Id": 11750162722213114821 + }, + "Component_[12608893098077724053]": { + "$type": "EditorEntitySortComponent", + "Id": 12608893098077724053 + }, + "Component_[13797422028724928908]": { + "$type": "AZ::Render::EditorMeshComponent", + "Id": 13797422028724928908, + "Controller": { + "Configuration": { + "ModelAsset": { + "assetId": { + "guid": "{61D16161-9F39-5A29-B927-ADF58E7E573B}", + "subId": 284780167 + }, + "assetHint": "objects/sphere.azmodel" + }, + "LodOverride": 255 + } + } + }, + "Component_[1492865274047869171]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 1492865274047869171 + }, + "Component_[15252998008739701164]": { + "$type": "EditorVisibilityComponent", + "Id": 15252998008739701164 + }, + "Component_[15365333384879292339]": { + "$type": "EditorInspectorComponent", + "Id": 15365333384879292339, + "ComponentOrderEntryArray": [ + { + "ComponentId": 5985506260224649992 + }, + { + "ComponentId": 13797422028724928908, + "SortIndex": 1 + }, + { + "ComponentId": 5200514760734239788, + "SortIndex": 2 + } + ] + }, + "Component_[18296307565715962470]": { + "$type": "EditorPendingCompositionComponent", + "Id": 18296307565715962470 + }, + "Component_[1940145586700385602]": { + "$type": "EditorOnlyEntityComponent", + "Id": 1940145586700385602 + }, + "Component_[4820397163316962417]": { + "$type": "EditorEntityIconComponent", + "Id": 4820397163316962417 + }, + "Component_[5200514760734239788]": { + "$type": "EditorMaterialComponent", + "Id": 5200514760734239788, + "Controller": { + "Configuration": { + "materials": { + "{}": { + "MaterialAsset": { + "assetId": { + "guid": "{76CF9D4A-009F-5494-83AB-6E3D4D1B4A36}" + }, + "assetHint": "levels/pbrmaterialchart/materials/basic_m00_r06.azmaterial" + } + } + } + } + }, + "materialSlotsByLodEnabled": true + }, + "Component_[5985506260224649992]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 5985506260224649992, + "Parent Entity": "Entity_[267279608989]", + "Transform Data": { + "Translate": [ + 11.999998092651367, + 0.0, + 0.0 + ] + } + }, + "Component_[7650403257628455609]": { + "$type": "EditorLockComponent", + "Id": 7650403257628455609 + } + } + }, + "Entity_[250099739805]": { + "Id": "Entity_[250099739805]", + "Name": "Ball07", + "Components": { + "Component_[11750162722213114821]": { + "$type": "SelectionComponent", + "Id": 11750162722213114821 + }, + "Component_[12608893098077724053]": { + "$type": "EditorEntitySortComponent", + "Id": 12608893098077724053 + }, + "Component_[13797422028724928908]": { + "$type": "AZ::Render::EditorMeshComponent", + "Id": 13797422028724928908, + "Controller": { + "Configuration": { + "ModelAsset": { + "assetId": { + "guid": "{61D16161-9F39-5A29-B927-ADF58E7E573B}", + "subId": 284780167 + }, + "assetHint": "objects/sphere.azmodel" + }, + "LodOverride": 255 + } + } + }, + "Component_[1492865274047869171]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 1492865274047869171 + }, + "Component_[15252998008739701164]": { + "$type": "EditorVisibilityComponent", + "Id": 15252998008739701164 + }, + "Component_[15365333384879292339]": { + "$type": "EditorInspectorComponent", + "Id": 15365333384879292339, + "ComponentOrderEntryArray": [ + { + "ComponentId": 5985506260224649992 + }, + { + "ComponentId": 13797422028724928908, + "SortIndex": 1 + }, + { + "ComponentId": 5200514760734239788, + "SortIndex": 2 + } + ] + }, + "Component_[18296307565715962470]": { + "$type": "EditorPendingCompositionComponent", + "Id": 18296307565715962470 + }, + "Component_[1940145586700385602]": { + "$type": "EditorOnlyEntityComponent", + "Id": 1940145586700385602 + }, + "Component_[4820397163316962417]": { + "$type": "EditorEntityIconComponent", + "Id": 4820397163316962417 + }, + "Component_[5200514760734239788]": { + "$type": "EditorMaterialComponent", + "Id": 5200514760734239788, + "Controller": { + "Configuration": { + "materials": { + "{}": { + "MaterialAsset": { + "assetId": { + "guid": "{8431B792-E6CC-51DD-B82E-F3E4A12FCB4A}" + }, + "assetHint": "levels/pbrmaterialchart/materials/basic_m00_r07.azmaterial" + } + } + } + } + }, + "materialSlotsByLodEnabled": true + }, + "Component_[5985506260224649992]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 5985506260224649992, + "Parent Entity": "Entity_[267279608989]", + "Transform Data": { + "Translate": [ + 13.99999713897705, + 0.0, + 0.0 + ] + } + }, + "Component_[7650403257628455609]": { + "$type": "EditorLockComponent", + "Id": 7650403257628455609 + } + } + }, + "Entity_[254394707101]": { + "Id": "Entity_[254394707101]", + "Name": "Ball08", + "Components": { + "Component_[11750162722213114821]": { + "$type": "SelectionComponent", + "Id": 11750162722213114821 + }, + "Component_[12608893098077724053]": { + "$type": "EditorEntitySortComponent", + "Id": 12608893098077724053 + }, + "Component_[13797422028724928908]": { + "$type": "AZ::Render::EditorMeshComponent", + "Id": 13797422028724928908, + "Controller": { + "Configuration": { + "ModelAsset": { + "assetId": { + "guid": "{61D16161-9F39-5A29-B927-ADF58E7E573B}", + "subId": 284780167 + }, + "assetHint": "objects/sphere.azmodel" + }, + "LodOverride": 255 + } + } + }, + "Component_[1492865274047869171]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 1492865274047869171 + }, + "Component_[15252998008739701164]": { + "$type": "EditorVisibilityComponent", + "Id": 15252998008739701164 + }, + "Component_[15365333384879292339]": { + "$type": "EditorInspectorComponent", + "Id": 15365333384879292339, + "ComponentOrderEntryArray": [ + { + "ComponentId": 5985506260224649992 + }, + { + "ComponentId": 13797422028724928908, + "SortIndex": 1 + }, + { + "ComponentId": 5200514760734239788, + "SortIndex": 2 + } + ] + }, + "Component_[18296307565715962470]": { + "$type": "EditorPendingCompositionComponent", + "Id": 18296307565715962470 + }, + "Component_[1940145586700385602]": { + "$type": "EditorOnlyEntityComponent", + "Id": 1940145586700385602 + }, + "Component_[4820397163316962417]": { + "$type": "EditorEntityIconComponent", + "Id": 4820397163316962417 + }, + "Component_[5200514760734239788]": { + "$type": "EditorMaterialComponent", + "Id": 5200514760734239788, + "Controller": { + "Configuration": { + "materials": { + "{}": { + "MaterialAsset": { + "assetId": { + "guid": "{4B1F29FF-7971-5524-AA1B-0DC2392A33C4}" + }, + "assetHint": "levels/pbrmaterialchart/materials/basic_m00_r08.azmaterial" + } + } + } + } + }, + "materialSlotsByLodEnabled": true + }, + "Component_[5985506260224649992]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 5985506260224649992, + "Parent Entity": "Entity_[267279608989]", + "Transform Data": { + "Translate": [ + 15.99999713897705, + 0.0, + 0.0 + ] + } + }, + "Component_[7650403257628455609]": { + "$type": "EditorLockComponent", + "Id": 7650403257628455609 + } + } + }, + "Entity_[258689674397]": { + "Id": "Entity_[258689674397]", + "Name": "Ball09", + "Components": { + "Component_[11750162722213114821]": { + "$type": "SelectionComponent", + "Id": 11750162722213114821 + }, + "Component_[12608893098077724053]": { + "$type": "EditorEntitySortComponent", + "Id": 12608893098077724053 + }, + "Component_[13797422028724928908]": { + "$type": "AZ::Render::EditorMeshComponent", + "Id": 13797422028724928908, + "Controller": { + "Configuration": { + "ModelAsset": { + "assetId": { + "guid": "{61D16161-9F39-5A29-B927-ADF58E7E573B}", + "subId": 284780167 + }, + "assetHint": "objects/sphere.azmodel" + }, + "LodOverride": 255 + } + } + }, + "Component_[1492865274047869171]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 1492865274047869171 + }, + "Component_[15252998008739701164]": { + "$type": "EditorVisibilityComponent", + "Id": 15252998008739701164 + }, + "Component_[15365333384879292339]": { + "$type": "EditorInspectorComponent", + "Id": 15365333384879292339, + "ComponentOrderEntryArray": [ + { + "ComponentId": 5985506260224649992 + }, + { + "ComponentId": 13797422028724928908, + "SortIndex": 1 + }, + { + "ComponentId": 5200514760734239788, + "SortIndex": 2 + } + ] + }, + "Component_[18296307565715962470]": { + "$type": "EditorPendingCompositionComponent", + "Id": 18296307565715962470 + }, + "Component_[1940145586700385602]": { + "$type": "EditorOnlyEntityComponent", + "Id": 1940145586700385602 + }, + "Component_[4820397163316962417]": { + "$type": "EditorEntityIconComponent", + "Id": 4820397163316962417 + }, + "Component_[5200514760734239788]": { + "$type": "EditorMaterialComponent", + "Id": 5200514760734239788, + "Controller": { + "Configuration": { + "materials": { + "{}": { + "MaterialAsset": { + "assetId": { + "guid": "{785BE6DE-C0EB-5B47-9438-4F9ECFC34A96}" + }, + "assetHint": "levels/pbrmaterialchart/materials/basic_m00_r09.azmaterial" + } + } + } + } + }, + "materialSlotsByLodEnabled": true + }, + "Component_[5985506260224649992]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 5985506260224649992, + "Parent Entity": "Entity_[267279608989]", + "Transform Data": { + "Translate": [ + 17.999996185302734, + 0.0, + 0.0 + ] + } + }, + "Component_[7650403257628455609]": { + "$type": "EditorLockComponent", + "Id": 7650403257628455609 + } + } + }, + "Entity_[262984641693]": { + "Id": "Entity_[262984641693]", + "Name": "Ball10", + "Components": { + "Component_[11750162722213114821]": { + "$type": "SelectionComponent", + "Id": 11750162722213114821 + }, + "Component_[12608893098077724053]": { + "$type": "EditorEntitySortComponent", + "Id": 12608893098077724053 + }, + "Component_[13797422028724928908]": { + "$type": "AZ::Render::EditorMeshComponent", + "Id": 13797422028724928908, + "Controller": { + "Configuration": { + "ModelAsset": { + "assetId": { + "guid": "{61D16161-9F39-5A29-B927-ADF58E7E573B}", + "subId": 284780167 + }, + "assetHint": "objects/sphere.azmodel" + }, + "LodOverride": 255 + } + } + }, + "Component_[1492865274047869171]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 1492865274047869171 + }, + "Component_[15252998008739701164]": { + "$type": "EditorVisibilityComponent", + "Id": 15252998008739701164 + }, + "Component_[15365333384879292339]": { + "$type": "EditorInspectorComponent", + "Id": 15365333384879292339, + "ComponentOrderEntryArray": [ + { + "ComponentId": 5985506260224649992 + }, + { + "ComponentId": 13797422028724928908, + "SortIndex": 1 + }, + { + "ComponentId": 5200514760734239788, + "SortIndex": 2 + } + ] + }, + "Component_[18296307565715962470]": { + "$type": "EditorPendingCompositionComponent", + "Id": 18296307565715962470 + }, + "Component_[1940145586700385602]": { + "$type": "EditorOnlyEntityComponent", + "Id": 1940145586700385602 + }, + "Component_[4820397163316962417]": { + "$type": "EditorEntityIconComponent", + "Id": 4820397163316962417 + }, + "Component_[5200514760734239788]": { + "$type": "EditorMaterialComponent", + "Id": 5200514760734239788, + "Controller": { + "Configuration": { + "materials": { + "{}": { + "MaterialAsset": { + "assetId": { + "guid": "{C40DE9AE-6756-57E7-B3B4-FB0542B5CD0F}" + }, + "assetHint": "levels/pbrmaterialchart/materials/basic_m00_r10.azmaterial" + } + } + } + } + }, + "materialSlotsByLodEnabled": true + }, + "Component_[5985506260224649992]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 5985506260224649992, + "Parent Entity": "Entity_[267279608989]", + "Transform Data": { + "Translate": [ + 19.999996185302734, + 0.0, + 0.0 + ] + } + }, + "Component_[7650403257628455609]": { + "$type": "EditorLockComponent", + "Id": 7650403257628455609 + } + } + }, + "Entity_[267279608989]": { + "Id": "Entity_[267279608989]", + "Name": "Row", + "Components": { + "Component_[10431128421533587390]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 10431128421533587390 + }, + "Component_[12384319735386528488]": { + "$type": "EditorInspectorComponent", + "Id": 12384319735386528488, + "ComponentOrderEntryArray": [ + { + "ComponentId": 2138630967603263484 + } + ] + }, + "Component_[12698663999690413529]": { + "$type": "EditorVisibilityComponent", + "Id": 12698663999690413529 + }, + "Component_[13267882596040987058]": { + "$type": "EditorOnlyEntityComponent", + "Id": 13267882596040987058 + }, + "Component_[15031093406648363268]": { + "$type": "EditorLockComponent", + "Id": 15031093406648363268 + }, + "Component_[15177069797419761403]": { + "$type": "EditorEntitySortComponent", + "Id": 15177069797419761403, + "Child Entity Order": [ + "Entity_[220034968733]", + "Entity_[224329936029]", + "Entity_[228624903325]", + "Entity_[232919870621]", + "Entity_[237214837917]", + "Entity_[241509805213]", + "Entity_[245804772509]", + "Entity_[250099739805]", + "Entity_[254394707101]", + "Entity_[258689674397]", + "Entity_[262984641693]" + ] + }, + "Component_[17955329409582714617]": { + "$type": "SelectionComponent", + "Id": 17955329409582714617 + }, + "Component_[2138630967603263484]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 2138630967603263484, + "Parent Entity": "Entity_[311518247264]", + "Transform Data": { + "Translate": [ + -0.02220340073108673, + -9.986543655395508, + -1.0031051635742188 + ], + "Rotate": [ + 0.0, + 0.0, + 90.00000762939453 + ] + } + }, + "Component_[3786501212457578744]": { + "$type": "EditorEntityIconComponent", + "Id": 3786501212457578744 + }, + "Component_[6440613696530771175]": { + "$type": "EditorPendingCompositionComponent", + "Id": 6440613696530771175 + } + } + }, + "Entity_[271574576285]": { + "Id": "Entity_[271574576285]", + "Name": "Row", + "Components": { + "Component_[10431128421533587390]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 10431128421533587390 + }, + "Component_[12384319735386528488]": { + "$type": "EditorInspectorComponent", + "Id": 12384319735386528488, + "ComponentOrderEntryArray": [ + { + "ComponentId": 2138630967603263484 + } + ] + }, + "Component_[12698663999690413529]": { + "$type": "EditorVisibilityComponent", + "Id": 12698663999690413529 + }, + "Component_[13267882596040987058]": { + "$type": "EditorOnlyEntityComponent", + "Id": 13267882596040987058 + }, + "Component_[15031093406648363268]": { + "$type": "EditorLockComponent", + "Id": 15031093406648363268 + }, + "Component_[15177069797419761403]": { + "$type": "EditorEntitySortComponent", + "Id": 15177069797419761403, + "Child Entity Order": [ + "Entity_[293049412765]", + "Entity_[301639347357]", + "Entity_[310229281949]", + "Entity_[318819216541]", + "Entity_[275869543581]", + "Entity_[280164510877]", + "Entity_[284459478173]", + "Entity_[288754445469]", + "Entity_[297344380061]", + "Entity_[305934314653]", + "Entity_[314524249245]" + ] + }, + "Component_[17955329409582714617]": { + "$type": "SelectionComponent", + "Id": 17955329409582714617 + }, + "Component_[2138630967603263484]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 2138630967603263484, + "Parent Entity": "Entity_[311518247264]", + "Transform Data": { + "Translate": [ + -0.02220340073108673, + -9.986543655395508, + 0.9968947768211365 + ], + "Rotate": [ + 0.0, + 0.0, + 90.00000762939453 + ] + } + }, + "Component_[3786501212457578744]": { + "$type": "EditorEntityIconComponent", + "Id": 3786501212457578744 + }, + "Component_[6440613696530771175]": { + "$type": "EditorPendingCompositionComponent", + "Id": 6440613696530771175 + } + } + }, + "Entity_[275869543581]": { + "Id": "Entity_[275869543581]", + "Name": "Ball04", + "Components": { + "Component_[11750162722213114821]": { + "$type": "SelectionComponent", + "Id": 11750162722213114821 + }, + "Component_[12608893098077724053]": { + "$type": "EditorEntitySortComponent", + "Id": 12608893098077724053 + }, + "Component_[13797422028724928908]": { + "$type": "AZ::Render::EditorMeshComponent", + "Id": 13797422028724928908, + "Controller": { + "Configuration": { + "ModelAsset": { + "assetId": { + "guid": "{61D16161-9F39-5A29-B927-ADF58E7E573B}", + "subId": 284780167 + }, + "assetHint": "objects/sphere.azmodel" + }, + "LodOverride": 255 + } + } + }, + "Component_[1492865274047869171]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 1492865274047869171 + }, + "Component_[15252998008739701164]": { + "$type": "EditorVisibilityComponent", + "Id": 15252998008739701164 + }, + "Component_[15365333384879292339]": { + "$type": "EditorInspectorComponent", + "Id": 15365333384879292339, + "ComponentOrderEntryArray": [ + { + "ComponentId": 5985506260224649992 + }, + { + "ComponentId": 13797422028724928908, + "SortIndex": 1 + }, + { + "ComponentId": 5200514760734239788, + "SortIndex": 2 + } + ] + }, + "Component_[18296307565715962470]": { + "$type": "EditorPendingCompositionComponent", + "Id": 18296307565715962470 + }, + "Component_[1940145586700385602]": { + "$type": "EditorOnlyEntityComponent", + "Id": 1940145586700385602 + }, + "Component_[4820397163316962417]": { + "$type": "EditorEntityIconComponent", + "Id": 4820397163316962417 + }, + "Component_[5200514760734239788]": { + "$type": "EditorMaterialComponent", + "Id": 5200514760734239788, + "Controller": { + "Configuration": { + "materials": { + "{}": { + "MaterialAsset": { + "assetId": { + "guid": "{251C4C29-4ECD-5763-AF4F-20675EAC048B}" + }, + "assetHint": "levels/pbrmaterialchart/materials/basic_m10_r04.azmaterial" + } + } + } + } + }, + "materialSlotsByLodEnabled": true + }, + "Component_[5985506260224649992]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 5985506260224649992, + "Parent Entity": "Entity_[271574576285]", + "Transform Data": { + "Translate": [ + 7.999998092651367, + 0.0, + 0.0 + ] + } + }, + "Component_[7650403257628455609]": { + "$type": "EditorLockComponent", + "Id": 7650403257628455609 + } + } + }, + "Entity_[280164510877]": { + "Id": "Entity_[280164510877]", + "Name": "Ball05", + "Components": { + "Component_[11750162722213114821]": { + "$type": "SelectionComponent", + "Id": 11750162722213114821 + }, + "Component_[12608893098077724053]": { + "$type": "EditorEntitySortComponent", + "Id": 12608893098077724053 + }, + "Component_[13797422028724928908]": { + "$type": "AZ::Render::EditorMeshComponent", + "Id": 13797422028724928908, + "Controller": { + "Configuration": { + "ModelAsset": { + "assetId": { + "guid": "{61D16161-9F39-5A29-B927-ADF58E7E573B}", + "subId": 284780167 + }, + "assetHint": "objects/sphere.azmodel" + }, + "LodOverride": 255 + } + } + }, + "Component_[1492865274047869171]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 1492865274047869171 + }, + "Component_[15252998008739701164]": { + "$type": "EditorVisibilityComponent", + "Id": 15252998008739701164 + }, + "Component_[15365333384879292339]": { + "$type": "EditorInspectorComponent", + "Id": 15365333384879292339, + "ComponentOrderEntryArray": [ + { + "ComponentId": 5985506260224649992 + }, + { + "ComponentId": 13797422028724928908, + "SortIndex": 1 + }, + { + "ComponentId": 5200514760734239788, + "SortIndex": 2 + } + ] + }, + "Component_[18296307565715962470]": { + "$type": "EditorPendingCompositionComponent", + "Id": 18296307565715962470 + }, + "Component_[1940145586700385602]": { + "$type": "EditorOnlyEntityComponent", + "Id": 1940145586700385602 + }, + "Component_[4820397163316962417]": { + "$type": "EditorEntityIconComponent", + "Id": 4820397163316962417 + }, + "Component_[5200514760734239788]": { + "$type": "EditorMaterialComponent", + "Id": 5200514760734239788, + "Controller": { + "Configuration": { + "materials": { + "{}": { + "MaterialAsset": { + "assetId": { + "guid": "{02D082C4-5032-57CC-A081-BC4D8518BCF0}" + }, + "assetHint": "levels/pbrmaterialchart/materials/basic_m10_r05.azmaterial" + } + } + } + } + }, + "materialSlotsByLodEnabled": true + }, + "Component_[5985506260224649992]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 5985506260224649992, + "Parent Entity": "Entity_[271574576285]", + "Transform Data": { + "Translate": [ + 9.999998092651367, + 0.0, + 0.0 + ] + } + }, + "Component_[7650403257628455609]": { + "$type": "EditorLockComponent", + "Id": 7650403257628455609 + } + } + }, + "Entity_[284459478173]": { + "Id": "Entity_[284459478173]", + "Name": "Ball06", + "Components": { + "Component_[11750162722213114821]": { + "$type": "SelectionComponent", + "Id": 11750162722213114821 + }, + "Component_[12608893098077724053]": { + "$type": "EditorEntitySortComponent", + "Id": 12608893098077724053 + }, + "Component_[13797422028724928908]": { + "$type": "AZ::Render::EditorMeshComponent", + "Id": 13797422028724928908, + "Controller": { + "Configuration": { + "ModelAsset": { + "assetId": { + "guid": "{61D16161-9F39-5A29-B927-ADF58E7E573B}", + "subId": 284780167 + }, + "assetHint": "objects/sphere.azmodel" + }, + "LodOverride": 255 + } + } + }, + "Component_[1492865274047869171]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 1492865274047869171 + }, + "Component_[15252998008739701164]": { + "$type": "EditorVisibilityComponent", + "Id": 15252998008739701164 + }, + "Component_[15365333384879292339]": { + "$type": "EditorInspectorComponent", + "Id": 15365333384879292339, + "ComponentOrderEntryArray": [ + { + "ComponentId": 5985506260224649992 + }, + { + "ComponentId": 13797422028724928908, + "SortIndex": 1 + }, + { + "ComponentId": 5200514760734239788, + "SortIndex": 2 + } + ] + }, + "Component_[18296307565715962470]": { + "$type": "EditorPendingCompositionComponent", + "Id": 18296307565715962470 + }, + "Component_[1940145586700385602]": { + "$type": "EditorOnlyEntityComponent", + "Id": 1940145586700385602 + }, + "Component_[4820397163316962417]": { + "$type": "EditorEntityIconComponent", + "Id": 4820397163316962417 + }, + "Component_[5200514760734239788]": { + "$type": "EditorMaterialComponent", + "Id": 5200514760734239788, + "Controller": { + "Configuration": { + "materials": { + "{}": { + "MaterialAsset": { + "assetId": { + "guid": "{FA9D8842-95B2-5371-8352-CBEEEAABE676}" + }, + "assetHint": "levels/pbrmaterialchart/materials/basic_m10_r06.azmaterial" + } + } + } + } + }, + "materialSlotsByLodEnabled": true + }, + "Component_[5985506260224649992]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 5985506260224649992, + "Parent Entity": "Entity_[271574576285]", + "Transform Data": { + "Translate": [ + 11.999998092651367, + 0.0, + 0.0 + ] + } + }, + "Component_[7650403257628455609]": { + "$type": "EditorLockComponent", + "Id": 7650403257628455609 + } + } + }, + "Entity_[288754445469]": { + "Id": "Entity_[288754445469]", + "Name": "Ball07", + "Components": { + "Component_[11750162722213114821]": { + "$type": "SelectionComponent", + "Id": 11750162722213114821 + }, + "Component_[12608893098077724053]": { + "$type": "EditorEntitySortComponent", + "Id": 12608893098077724053 + }, + "Component_[13797422028724928908]": { + "$type": "AZ::Render::EditorMeshComponent", + "Id": 13797422028724928908, + "Controller": { + "Configuration": { + "ModelAsset": { + "assetId": { + "guid": "{61D16161-9F39-5A29-B927-ADF58E7E573B}", + "subId": 284780167 + }, + "assetHint": "objects/sphere.azmodel" + }, + "LodOverride": 255 + } + } + }, + "Component_[1492865274047869171]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 1492865274047869171 + }, + "Component_[15252998008739701164]": { + "$type": "EditorVisibilityComponent", + "Id": 15252998008739701164 + }, + "Component_[15365333384879292339]": { + "$type": "EditorInspectorComponent", + "Id": 15365333384879292339, + "ComponentOrderEntryArray": [ + { + "ComponentId": 5985506260224649992 + }, + { + "ComponentId": 13797422028724928908, + "SortIndex": 1 + }, + { + "ComponentId": 5200514760734239788, + "SortIndex": 2 + } + ] + }, + "Component_[18296307565715962470]": { + "$type": "EditorPendingCompositionComponent", + "Id": 18296307565715962470 + }, + "Component_[1940145586700385602]": { + "$type": "EditorOnlyEntityComponent", + "Id": 1940145586700385602 + }, + "Component_[4820397163316962417]": { + "$type": "EditorEntityIconComponent", + "Id": 4820397163316962417 + }, + "Component_[5200514760734239788]": { + "$type": "EditorMaterialComponent", + "Id": 5200514760734239788, + "Controller": { + "Configuration": { + "materials": { + "{}": { + "MaterialAsset": { + "assetId": { + "guid": "{522A9626-FF4C-561A-A44A-64B68F7274D2}" + }, + "assetHint": "levels/pbrmaterialchart/materials/basic_m10_r07.azmaterial" + } + } + } + } + }, + "materialSlotsByLodEnabled": true + }, + "Component_[5985506260224649992]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 5985506260224649992, + "Parent Entity": "Entity_[271574576285]", + "Transform Data": { + "Translate": [ + 13.99999713897705, + 0.0, + 0.0 + ] + } + }, + "Component_[7650403257628455609]": { + "$type": "EditorLockComponent", + "Id": 7650403257628455609 + } + } + }, + "Entity_[293049412765]": { + "Id": "Entity_[293049412765]", + "Name": "Ball00", + "Components": { + "Component_[11750162722213114821]": { + "$type": "SelectionComponent", + "Id": 11750162722213114821 + }, + "Component_[12608893098077724053]": { + "$type": "EditorEntitySortComponent", + "Id": 12608893098077724053 + }, + "Component_[13797422028724928908]": { + "$type": "AZ::Render::EditorMeshComponent", + "Id": 13797422028724928908, + "Controller": { + "Configuration": { + "ModelAsset": { + "assetId": { + "guid": "{61D16161-9F39-5A29-B927-ADF58E7E573B}", + "subId": 284780167 + }, + "assetHint": "objects/sphere.azmodel" + }, + "LodOverride": 255 + } + } + }, + "Component_[1492865274047869171]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 1492865274047869171 + }, + "Component_[15252998008739701164]": { + "$type": "EditorVisibilityComponent", + "Id": 15252998008739701164 + }, + "Component_[15365333384879292339]": { + "$type": "EditorInspectorComponent", + "Id": 15365333384879292339, + "ComponentOrderEntryArray": [ + { + "ComponentId": 5985506260224649992 + }, + { + "ComponentId": 13797422028724928908, + "SortIndex": 1 + }, + { + "ComponentId": 5200514760734239788, + "SortIndex": 2 + } + ] + }, + "Component_[18296307565715962470]": { + "$type": "EditorPendingCompositionComponent", + "Id": 18296307565715962470 + }, + "Component_[1940145586700385602]": { + "$type": "EditorOnlyEntityComponent", + "Id": 1940145586700385602 + }, + "Component_[4820397163316962417]": { + "$type": "EditorEntityIconComponent", + "Id": 4820397163316962417 + }, + "Component_[5200514760734239788]": { + "$type": "EditorMaterialComponent", + "Id": 5200514760734239788, + "Controller": { + "Configuration": { + "materials": { + "{}": { + "MaterialAsset": { + "assetId": { + "guid": "{06DDFD66-D7F5-5D55-8972-6D61276E88F6}" + }, + "assetHint": "levels/pbrmaterialchart/materials/basic_m10_r00.azmaterial" + } + } + } + } + }, + "materialSlotsByLodEnabled": true + }, + "Component_[5985506260224649992]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 5985506260224649992, + "Parent Entity": "Entity_[271574576285]" + }, + "Component_[7650403257628455609]": { + "$type": "EditorLockComponent", + "Id": 7650403257628455609 + } + } + }, + "Entity_[297344380061]": { + "Id": "Entity_[297344380061]", + "Name": "Ball08", + "Components": { + "Component_[11750162722213114821]": { + "$type": "SelectionComponent", + "Id": 11750162722213114821 + }, + "Component_[12608893098077724053]": { + "$type": "EditorEntitySortComponent", + "Id": 12608893098077724053 + }, + "Component_[13797422028724928908]": { + "$type": "AZ::Render::EditorMeshComponent", + "Id": 13797422028724928908, + "Controller": { + "Configuration": { + "ModelAsset": { + "assetId": { + "guid": "{61D16161-9F39-5A29-B927-ADF58E7E573B}", + "subId": 284780167 + }, + "assetHint": "objects/sphere.azmodel" + }, + "LodOverride": 255 + } + } + }, + "Component_[1492865274047869171]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 1492865274047869171 + }, + "Component_[15252998008739701164]": { + "$type": "EditorVisibilityComponent", + "Id": 15252998008739701164 + }, + "Component_[15365333384879292339]": { + "$type": "EditorInspectorComponent", + "Id": 15365333384879292339, + "ComponentOrderEntryArray": [ + { + "ComponentId": 5985506260224649992 + }, + { + "ComponentId": 13797422028724928908, + "SortIndex": 1 + }, + { + "ComponentId": 5200514760734239788, + "SortIndex": 2 + } + ] + }, + "Component_[18296307565715962470]": { + "$type": "EditorPendingCompositionComponent", + "Id": 18296307565715962470 + }, + "Component_[1940145586700385602]": { + "$type": "EditorOnlyEntityComponent", + "Id": 1940145586700385602 + }, + "Component_[4820397163316962417]": { + "$type": "EditorEntityIconComponent", + "Id": 4820397163316962417 + }, + "Component_[5200514760734239788]": { + "$type": "EditorMaterialComponent", + "Id": 5200514760734239788, + "Controller": { + "Configuration": { + "materials": { + "{}": { + "MaterialAsset": { + "assetId": { + "guid": "{060EF1B7-1029-5227-B03B-1415C74E9D65}" + }, + "assetHint": "levels/pbrmaterialchart/materials/basic_m10_r08.azmaterial" + } + } + } + } + }, + "materialSlotsByLodEnabled": true + }, + "Component_[5985506260224649992]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 5985506260224649992, + "Parent Entity": "Entity_[271574576285]", + "Transform Data": { + "Translate": [ + 15.99999713897705, + 0.0, + 0.0 + ] + } + }, + "Component_[7650403257628455609]": { + "$type": "EditorLockComponent", + "Id": 7650403257628455609 + } + } + }, + "Entity_[301639347357]": { + "Id": "Entity_[301639347357]", + "Name": "Ball01", + "Components": { + "Component_[11750162722213114821]": { + "$type": "SelectionComponent", + "Id": 11750162722213114821 + }, + "Component_[12608893098077724053]": { + "$type": "EditorEntitySortComponent", + "Id": 12608893098077724053 + }, + "Component_[13797422028724928908]": { + "$type": "AZ::Render::EditorMeshComponent", + "Id": 13797422028724928908, + "Controller": { + "Configuration": { + "ModelAsset": { + "assetId": { + "guid": "{61D16161-9F39-5A29-B927-ADF58E7E573B}", + "subId": 284780167 + }, + "assetHint": "objects/sphere.azmodel" + }, + "LodOverride": 255 + } + } + }, + "Component_[1492865274047869171]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 1492865274047869171 + }, + "Component_[15252998008739701164]": { + "$type": "EditorVisibilityComponent", + "Id": 15252998008739701164 + }, + "Component_[15365333384879292339]": { + "$type": "EditorInspectorComponent", + "Id": 15365333384879292339, + "ComponentOrderEntryArray": [ + { + "ComponentId": 5985506260224649992 + }, + { + "ComponentId": 13797422028724928908, + "SortIndex": 1 + }, + { + "ComponentId": 5200514760734239788, + "SortIndex": 2 + } + ] + }, + "Component_[18296307565715962470]": { + "$type": "EditorPendingCompositionComponent", + "Id": 18296307565715962470 + }, + "Component_[1940145586700385602]": { + "$type": "EditorOnlyEntityComponent", + "Id": 1940145586700385602 + }, + "Component_[4820397163316962417]": { + "$type": "EditorEntityIconComponent", + "Id": 4820397163316962417 + }, + "Component_[5200514760734239788]": { + "$type": "EditorMaterialComponent", + "Id": 5200514760734239788, + "Controller": { + "Configuration": { + "materials": { + "{}": { + "MaterialAsset": { + "assetId": { + "guid": "{7B7BC6F8-150A-518F-816E-2F7DBE786461}" + }, + "assetHint": "levels/pbrmaterialchart/materials/basic_m10_r01.azmaterial" + } + } + } + } + }, + "materialSlotsByLodEnabled": true + }, + "Component_[5985506260224649992]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 5985506260224649992, + "Parent Entity": "Entity_[271574576285]", + "Transform Data": { + "Translate": [ + 1.9999995231628418, + 0.0, + 0.0 + ] + } + }, + "Component_[7650403257628455609]": { + "$type": "EditorLockComponent", + "Id": 7650403257628455609 + } + } + }, + "Entity_[305934314653]": { + "Id": "Entity_[305934314653]", + "Name": "Ball09", + "Components": { + "Component_[11750162722213114821]": { + "$type": "SelectionComponent", + "Id": 11750162722213114821 + }, + "Component_[12608893098077724053]": { + "$type": "EditorEntitySortComponent", + "Id": 12608893098077724053 + }, + "Component_[13797422028724928908]": { + "$type": "AZ::Render::EditorMeshComponent", + "Id": 13797422028724928908, + "Controller": { + "Configuration": { + "ModelAsset": { + "assetId": { + "guid": "{61D16161-9F39-5A29-B927-ADF58E7E573B}", + "subId": 284780167 + }, + "assetHint": "objects/sphere.azmodel" + }, + "LodOverride": 255 + } + } + }, + "Component_[1492865274047869171]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 1492865274047869171 + }, + "Component_[15252998008739701164]": { + "$type": "EditorVisibilityComponent", + "Id": 15252998008739701164 + }, + "Component_[15365333384879292339]": { + "$type": "EditorInspectorComponent", + "Id": 15365333384879292339, + "ComponentOrderEntryArray": [ + { + "ComponentId": 5985506260224649992 + }, + { + "ComponentId": 13797422028724928908, + "SortIndex": 1 + }, + { + "ComponentId": 5200514760734239788, + "SortIndex": 2 + } + ] + }, + "Component_[18296307565715962470]": { + "$type": "EditorPendingCompositionComponent", + "Id": 18296307565715962470 + }, + "Component_[1940145586700385602]": { + "$type": "EditorOnlyEntityComponent", + "Id": 1940145586700385602 + }, + "Component_[4820397163316962417]": { + "$type": "EditorEntityIconComponent", + "Id": 4820397163316962417 + }, + "Component_[5200514760734239788]": { + "$type": "EditorMaterialComponent", + "Id": 5200514760734239788, + "Controller": { + "Configuration": { + "materials": { + "{}": { + "MaterialAsset": { + "assetId": { + "guid": "{270881B6-21E9-509D-A6CD-1046674FB0BE}" + }, + "assetHint": "levels/pbrmaterialchart/materials/basic_m10_r09.azmaterial" + } + } + } + } + }, + "materialSlotsByLodEnabled": true + }, + "Component_[5985506260224649992]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 5985506260224649992, + "Parent Entity": "Entity_[271574576285]", + "Transform Data": { + "Translate": [ + 17.999996185302734, + 0.0, + 0.0 + ] + } + }, + "Component_[7650403257628455609]": { + "$type": "EditorLockComponent", + "Id": 7650403257628455609 + } + } + }, + "Entity_[310229281949]": { + "Id": "Entity_[310229281949]", + "Name": "Ball02", + "Components": { + "Component_[11750162722213114821]": { + "$type": "SelectionComponent", + "Id": 11750162722213114821 + }, + "Component_[12608893098077724053]": { + "$type": "EditorEntitySortComponent", + "Id": 12608893098077724053 + }, + "Component_[13797422028724928908]": { + "$type": "AZ::Render::EditorMeshComponent", + "Id": 13797422028724928908, + "Controller": { + "Configuration": { + "ModelAsset": { + "assetId": { + "guid": "{61D16161-9F39-5A29-B927-ADF58E7E573B}", + "subId": 284780167 + }, + "assetHint": "objects/sphere.azmodel" + }, + "LodOverride": 255 + } + } + }, + "Component_[1492865274047869171]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 1492865274047869171 + }, + "Component_[15252998008739701164]": { + "$type": "EditorVisibilityComponent", + "Id": 15252998008739701164 + }, + "Component_[15365333384879292339]": { + "$type": "EditorInspectorComponent", + "Id": 15365333384879292339, + "ComponentOrderEntryArray": [ + { + "ComponentId": 5985506260224649992 + }, + { + "ComponentId": 13797422028724928908, + "SortIndex": 1 + }, + { + "ComponentId": 5200514760734239788, + "SortIndex": 2 + } + ] + }, + "Component_[18296307565715962470]": { + "$type": "EditorPendingCompositionComponent", + "Id": 18296307565715962470 + }, + "Component_[1940145586700385602]": { + "$type": "EditorOnlyEntityComponent", + "Id": 1940145586700385602 + }, + "Component_[4820397163316962417]": { + "$type": "EditorEntityIconComponent", + "Id": 4820397163316962417 + }, + "Component_[5200514760734239788]": { + "$type": "EditorMaterialComponent", + "Id": 5200514760734239788, + "Controller": { + "Configuration": { + "materials": { + "{}": { + "MaterialAsset": { + "assetId": { + "guid": "{C0538953-C56E-5C1A-BBE2-E6BE04764C20}" + }, + "assetHint": "levels/pbrmaterialchart/materials/basic_m10_r02.azmaterial" + } + } + } + } + }, + "materialSlotsByLodEnabled": true + }, + "Component_[5985506260224649992]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 5985506260224649992, + "Parent Entity": "Entity_[271574576285]", + "Transform Data": { + "Translate": [ + 3.9999992847442627, + 0.0, + 0.0 + ] + } + }, + "Component_[7650403257628455609]": { + "$type": "EditorLockComponent", + "Id": 7650403257628455609 + } + } + }, + "Entity_[311518247264]": { + "Id": "Entity_[311518247264]", + "Name": "PbrMaterialChart_Assets", + "Components": { + "Component_[10482364804718329021]": { + "$type": "EditorPendingCompositionComponent", + "Id": 10482364804718329021 + }, + "Component_[10942888141582930027]": { + "$type": "EditorLockComponent", + "Id": 10942888141582930027 + }, + "Component_[13540203629041536166]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 13540203629041536166, + "Parent Entity": "ContainerEntity", + "Transform Data": { + "Rotate": [ + 0.0, + 0.0, + -90.0 + ] + } + }, + "Component_[13907911826554124970]": { + "$type": "EditorEntityIconComponent", + "Id": 13907911826554124970 + }, + "Component_[14302898759905097452]": { + "$type": "EditorEntitySortComponent", + "Id": 14302898759905097452, + "Child Entity Order": [ + "Entity_[224935554679]", + "Entity_[323114183837]", + "Entity_[267279608989]", + "Entity_[271574576285]", + "Entity_[227116497304]", + "Entity_[1579029125278]" + ] + }, + "Component_[6734926751345496430]": { + "$type": "EditorOnlyEntityComponent", + "Id": 6734926751345496430 + }, + "Component_[7859927512474268451]": { + "$type": "EditorInspectorComponent", + "Id": 7859927512474268451, + "ComponentOrderEntryArray": [ + { + "ComponentId": 13540203629041536166 + } + ] + }, + "Component_[8550690899908144218]": { + "$type": "SelectionComponent", + "Id": 8550690899908144218 + }, + "Component_[9251711315131563801]": { + "$type": "EditorVisibilityComponent", + "Id": 9251711315131563801 + }, + "Component_[9755014032434689168]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 9755014032434689168 + } + } + }, + "Entity_[314524249245]": { + "Id": "Entity_[314524249245]", + "Name": "Ball10", + "Components": { + "Component_[11750162722213114821]": { + "$type": "SelectionComponent", + "Id": 11750162722213114821 + }, + "Component_[12608893098077724053]": { + "$type": "EditorEntitySortComponent", + "Id": 12608893098077724053 + }, + "Component_[13797422028724928908]": { + "$type": "AZ::Render::EditorMeshComponent", + "Id": 13797422028724928908, + "Controller": { + "Configuration": { + "ModelAsset": { + "assetId": { + "guid": "{61D16161-9F39-5A29-B927-ADF58E7E573B}", + "subId": 284780167 + }, + "assetHint": "objects/sphere.azmodel" + }, + "LodOverride": 255 + } + } + }, + "Component_[1492865274047869171]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 1492865274047869171 + }, + "Component_[15252998008739701164]": { + "$type": "EditorVisibilityComponent", + "Id": 15252998008739701164 + }, + "Component_[15365333384879292339]": { + "$type": "EditorInspectorComponent", + "Id": 15365333384879292339, + "ComponentOrderEntryArray": [ + { + "ComponentId": 5985506260224649992 + }, + { + "ComponentId": 13797422028724928908, + "SortIndex": 1 + }, + { + "ComponentId": 5200514760734239788, + "SortIndex": 2 + } + ] + }, + "Component_[18296307565715962470]": { + "$type": "EditorPendingCompositionComponent", + "Id": 18296307565715962470 + }, + "Component_[1940145586700385602]": { + "$type": "EditorOnlyEntityComponent", + "Id": 1940145586700385602 + }, + "Component_[4820397163316962417]": { + "$type": "EditorEntityIconComponent", + "Id": 4820397163316962417 + }, + "Component_[5200514760734239788]": { + "$type": "EditorMaterialComponent", + "Id": 5200514760734239788, + "Controller": { + "Configuration": { + "materials": { + "{}": { + "MaterialAsset": { + "assetId": { + "guid": "{5EA26E09-E3D6-5181-8E7A-F2E98A24247C}" + }, + "assetHint": "levels/pbrmaterialchart/materials/basic_m10_r10.azmaterial" + } + } + } + } + }, + "materialSlotsByLodEnabled": true + }, + "Component_[5985506260224649992]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 5985506260224649992, + "Parent Entity": "Entity_[271574576285]", + "Transform Data": { + "Translate": [ + 19.999996185302734, + 0.0, + 0.0 + ] + } + }, + "Component_[7650403257628455609]": { + "$type": "EditorLockComponent", + "Id": 7650403257628455609 + } + } + }, + "Entity_[318819216541]": { + "Id": "Entity_[318819216541]", + "Name": "Ball03", + "Components": { + "Component_[11750162722213114821]": { + "$type": "SelectionComponent", + "Id": 11750162722213114821 + }, + "Component_[12608893098077724053]": { + "$type": "EditorEntitySortComponent", + "Id": 12608893098077724053 + }, + "Component_[13797422028724928908]": { + "$type": "AZ::Render::EditorMeshComponent", + "Id": 13797422028724928908, + "Controller": { + "Configuration": { + "ModelAsset": { + "assetId": { + "guid": "{61D16161-9F39-5A29-B927-ADF58E7E573B}", + "subId": 284780167 + }, + "assetHint": "objects/sphere.azmodel" + }, + "LodOverride": 255 + } + } + }, + "Component_[1492865274047869171]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 1492865274047869171 + }, + "Component_[15252998008739701164]": { + "$type": "EditorVisibilityComponent", + "Id": 15252998008739701164 + }, + "Component_[15365333384879292339]": { + "$type": "EditorInspectorComponent", + "Id": 15365333384879292339, + "ComponentOrderEntryArray": [ + { + "ComponentId": 5985506260224649992 + }, + { + "ComponentId": 13797422028724928908, + "SortIndex": 1 + }, + { + "ComponentId": 5200514760734239788, + "SortIndex": 2 + } + ] + }, + "Component_[18296307565715962470]": { + "$type": "EditorPendingCompositionComponent", + "Id": 18296307565715962470 + }, + "Component_[1940145586700385602]": { + "$type": "EditorOnlyEntityComponent", + "Id": 1940145586700385602 + }, + "Component_[4820397163316962417]": { + "$type": "EditorEntityIconComponent", + "Id": 4820397163316962417 + }, + "Component_[5200514760734239788]": { + "$type": "EditorMaterialComponent", + "Id": 5200514760734239788, + "Controller": { + "Configuration": { + "materials": { + "{}": { + "MaterialAsset": { + "assetId": { + "guid": "{E1A5D708-7A49-5CCA-81C3-4CB337C47703}" + }, + "assetHint": "levels/pbrmaterialchart/materials/basic_m10_r03.azmaterial" + } + } + } + } + }, + "materialSlotsByLodEnabled": true + }, + "Component_[5985506260224649992]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 5985506260224649992, + "Parent Entity": "Entity_[271574576285]", + "Transform Data": { + "Translate": [ + 5.999998569488525, + 0.0, + 0.0 + ] + } + }, + "Component_[7650403257628455609]": { + "$type": "EditorLockComponent", + "Id": 7650403257628455609 + } + } + }, + "Entity_[323114183837]": { + "Id": "Entity_[323114183837]", + "Name": "Camera1", + "Components": { + "Component_[10006292826835803540]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 10006292826835803540 + }, + "Component_[10455519191869797]": { + "$type": "EditorVisibilityComponent", + "Id": 10455519191869797 + }, + "Component_[11437375554946967375]": { + "$type": "EditorEntitySortComponent", + "Id": 11437375554946967375 + }, + "Component_[12353408053920436955]": { + "$type": "SelectionComponent", + "Id": 12353408053920436955 + }, + "Component_[13096751172875321905]": { + "$type": "EditorEntityIconComponent", + "Id": 13096751172875321905 + }, + "Component_[14346079281461734018]": { + "$type": "EditorLockComponent", + "Id": 14346079281461734018 + }, + "Component_[14601767610059792758]": { + "$type": "EditorPendingCompositionComponent", + "Id": 14601767610059792758 + }, + "Component_[1752468310352442380]": { + "$type": "GenericComponentWrapper", + "Id": 1752468310352442380, + "m_template": { + "$type": "FlyCameraInputComponent" + } + }, + "Component_[18443771986481731838]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 18443771986481731838, + "Parent Entity": "Entity_[311518247264]", + "Transform Data": { + "Translate": [ + 49.97779846191406, + 0.013456299901008606, + -0.00310519989579916 + ], + "Rotate": [ + 0.0, + 0.0, + 90.00000762939453 + ], + "Scale": [ + 1.0, + 1.0, + 0.9999998807907104 + ] + } + }, + "Component_[646706054417436776]": { + "$type": "{CA11DA46-29FF-4083-B5F6-E02C3A8C3A3D} EditorCameraComponent", + "Id": 646706054417436776, + "Controller": { + "Configuration": { + "EditorEntityId": 323114183837 + } + } + }, + "Component_[8037556047509300929]": { + "$type": "EditorOnlyEntityComponent", + "Id": 8037556047509300929 + }, + "Component_[9357115853003317593]": { + "$type": "EditorInspectorComponent", + "Id": 9357115853003317593, + "ComponentOrderEntryArray": [ + { + "ComponentId": 18443771986481731838 + }, + { + "ComponentId": 646706054417436776, + "SortIndex": 1 + }, + { + "ComponentId": 1752468310352442380, + "SortIndex": 2 + } + ] + } + } + }, + "Entity_[439136298436]": { + "Id": "Entity_[439136298436]", + "Name": "Light", + "Components": { + "Component_[11029917022661117076]": { + "$type": "EditorSphereShapeComponent", + "Id": 11029917022661117076, + "ShapeColor": [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + "SphereShape": { + "Configuration": { + "Radius": 0.05000000074505806 + } + } + }, + "Component_[12284008075844705430]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 12284008075844705430, + "Parent Entity": "Entity_[1579029125278]", + "Transform Data": { + "Translate": [ + -7.999996662139893, + 15.0, + 6.0 + ] + } + }, + "Component_[13457184847449496840]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 13457184847449496840 + }, + "Component_[14431842353830635996]": { + "$type": "EditorLockComponent", + "Id": 14431842353830635996 + }, + "Component_[1473579476469110229]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1473579476469110229 + }, + "Component_[17008596888127953988]": { + "$type": "EditorEntitySortComponent", + "Id": 17008596888127953988 + }, + "Component_[17246196475221723560]": { + "$type": "EditorInspectorComponent", + "Id": 17246196475221723560, + "ComponentOrderEntryArray": [ + { + "ComponentId": 12284008075844705430 + }, + { + "ComponentId": 7864910209001174169, + "SortIndex": 1 + } + ] + }, + "Component_[18388752482036682870]": { + "$type": "EditorOnlyEntityComponent", + "Id": 18388752482036682870 + }, + "Component_[3917765902796274739]": { + "$type": "EditorEntityIconComponent", + "Id": 3917765902796274739 + }, + "Component_[4143676462074671972]": { + "$type": "AZ::Render::EditorAreaLightComponent", + "Id": 4143676462074671972, + "Controller": { + "Configuration": { + "LightType": 1, + "IntensityMode": 1, + "Intensity": 50.0, + "AttenuationRadius": 79.26654815673828 + } + } + }, + "Component_[4863305662794796025]": { + "$type": "EditorVisibilityComponent", + "Id": 4863305662794796025 + }, + "Component_[5902189275159544426]": { + "$type": "SelectionComponent", + "Id": 5902189275159544426 + } + } + }, + "Entity_[443431265732]": { + "Id": "Entity_[443431265732]", + "Name": "Light", + "Components": { + "Component_[12284008075844705430]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 12284008075844705430, + "Parent Entity": "Entity_[1579029125278]", + "Transform Data": { + "Translate": [ + -7.999996662139893, + -10.0, + -6.0 + ] + } + }, + "Component_[13457184847449496840]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 13457184847449496840 + }, + "Component_[14431842353830635996]": { + "$type": "EditorLockComponent", + "Id": 14431842353830635996 + }, + "Component_[1473579476469110229]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1473579476469110229 + }, + "Component_[17008596888127953988]": { + "$type": "EditorEntitySortComponent", + "Id": 17008596888127953988 + }, + "Component_[17246196475221723560]": { + "$type": "EditorInspectorComponent", + "Id": 17246196475221723560, + "ComponentOrderEntryArray": [ + { + "ComponentId": 12284008075844705430 + }, + { + "ComponentId": 7864910209001174169, + "SortIndex": 1 + } + ] + }, + "Component_[18059889152590511471]": { + "$type": "EditorSphereShapeComponent", + "Id": 18059889152590511471, + "ShapeColor": [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + "SphereShape": { + "Configuration": { + "Radius": 0.05000000074505806 + } + } + }, + "Component_[18388752482036682870]": { + "$type": "EditorOnlyEntityComponent", + "Id": 18388752482036682870 + }, + "Component_[3917765902796274739]": { + "$type": "EditorEntityIconComponent", + "Id": 3917765902796274739 + }, + "Component_[4143676462074671972]": { + "$type": "AZ::Render::EditorAreaLightComponent", + "Id": 4143676462074671972, + "Controller": { + "Configuration": { + "LightType": 1, + "IntensityMode": 1, + "Intensity": 50.0, + "AttenuationRadius": 79.26654815673828 + } + } + }, + "Component_[4863305662794796025]": { + "$type": "EditorVisibilityComponent", + "Id": 4863305662794796025 + }, + "Component_[5902189275159544426]": { + "$type": "SelectionComponent", + "Id": 5902189275159544426 + } + } + }, + "Entity_[447726233028]": { + "Id": "Entity_[447726233028]", + "Name": "Light", + "Components": { + "Component_[12284008075844705430]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 12284008075844705430, + "Parent Entity": "Entity_[1579029125278]", + "Transform Data": { + "Translate": [ + -7.999996662139893, + -15.0, + 6.0 + ] + } + }, + "Component_[13457184847449496840]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 13457184847449496840 + }, + "Component_[14431842353830635996]": { + "$type": "EditorLockComponent", + "Id": 14431842353830635996 + }, + "Component_[1473579476469110229]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1473579476469110229 + }, + "Component_[17008596888127953988]": { + "$type": "EditorEntitySortComponent", + "Id": 17008596888127953988 + }, + "Component_[17246196475221723560]": { + "$type": "EditorInspectorComponent", + "Id": 17246196475221723560, + "ComponentOrderEntryArray": [ + { + "ComponentId": 12284008075844705430 + }, + { + "ComponentId": 7864910209001174169, + "SortIndex": 1 + } + ] + }, + "Component_[18388752482036682870]": { + "$type": "EditorOnlyEntityComponent", + "Id": 18388752482036682870 + }, + "Component_[3116905989016577951]": { + "$type": "EditorSphereShapeComponent", + "Id": 3116905989016577951, + "ShapeColor": [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + "SphereShape": { + "Configuration": { + "Radius": 0.05000000074505806 + } + } + }, + "Component_[3917765902796274739]": { + "$type": "EditorEntityIconComponent", + "Id": 3917765902796274739 + }, + "Component_[4143676462074671972]": { + "$type": "AZ::Render::EditorAreaLightComponent", + "Id": 4143676462074671972, + "Controller": { + "Configuration": { + "LightType": 1, + "IntensityMode": 1, + "Intensity": 50.0, + "AttenuationRadius": 79.26654815673828 + } + } + }, + "Component_[4863305662794796025]": { + "$type": "EditorVisibilityComponent", + "Id": 4863305662794796025 + }, + "Component_[5902189275159544426]": { + "$type": "SelectionComponent", + "Id": 5902189275159544426 + } + } + }, + "Entity_[452021200324]": { + "Id": "Entity_[452021200324]", + "Name": "Light", + "Components": { + "Component_[11880996669921269387]": { + "$type": "EditorSphereShapeComponent", + "Id": 11880996669921269387, + "ShapeColor": [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + "SphereShape": { + "Configuration": { + "Radius": 0.05000000074505806 + } + } + }, + "Component_[12284008075844705430]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 12284008075844705430, + "Parent Entity": "Entity_[1579029125278]", + "Transform Data": { + "Translate": [ + -7.999996662139893, + 12.0, + -6.0 + ] + } + }, + "Component_[13457184847449496840]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 13457184847449496840 + }, + "Component_[14431842353830635996]": { + "$type": "EditorLockComponent", + "Id": 14431842353830635996 + }, + "Component_[1473579476469110229]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1473579476469110229 + }, + "Component_[17008596888127953988]": { + "$type": "EditorEntitySortComponent", + "Id": 17008596888127953988 + }, + "Component_[17246196475221723560]": { + "$type": "EditorInspectorComponent", + "Id": 17246196475221723560, + "ComponentOrderEntryArray": [ + { + "ComponentId": 12284008075844705430 + }, + { + "ComponentId": 7864910209001174169, + "SortIndex": 1 + } + ] + }, + "Component_[18388752482036682870]": { + "$type": "EditorOnlyEntityComponent", + "Id": 18388752482036682870 + }, + "Component_[3917765902796274739]": { + "$type": "EditorEntityIconComponent", + "Id": 3917765902796274739 + }, + "Component_[4143676462074671972]": { + "$type": "AZ::Render::EditorAreaLightComponent", + "Id": 4143676462074671972, + "Controller": { + "Configuration": { + "LightType": 1, + "IntensityMode": 1, + "Intensity": 50.0, + "AttenuationRadius": 79.26654815673828 + } + } + }, + "Component_[4863305662794796025]": { + "$type": "EditorVisibilityComponent", + "Id": 4863305662794796025 + }, + "Component_[5902189275159544426]": { + "$type": "SelectionComponent", + "Id": 5902189275159544426 + } + } + }, + "Entity_[456316167620]": { + "Id": "Entity_[456316167620]", + "Name": "Light", + "Components": { + "Component_[12284008075844705430]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 12284008075844705430, + "Parent Entity": "Entity_[1579029125278]", + "Transform Data": { + "Translate": [ + -7.999996662139893, + -15.0, + -6.0 + ] + } + }, + "Component_[13457184847449496840]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 13457184847449496840 + }, + "Component_[14431842353830635996]": { + "$type": "EditorLockComponent", + "Id": 14431842353830635996 + }, + "Component_[1473579476469110229]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1473579476469110229 + }, + "Component_[15861630875009954708]": { + "$type": "EditorSphereShapeComponent", + "Id": 15861630875009954708, + "ShapeColor": [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + "SphereShape": { + "Configuration": { + "Radius": 0.05000000074505806 + } + } + }, + "Component_[17008596888127953988]": { + "$type": "EditorEntitySortComponent", + "Id": 17008596888127953988 + }, + "Component_[17246196475221723560]": { + "$type": "EditorInspectorComponent", + "Id": 17246196475221723560, + "ComponentOrderEntryArray": [ + { + "ComponentId": 12284008075844705430 + }, + { + "ComponentId": 7864910209001174169, + "SortIndex": 1 + } + ] + }, + "Component_[18388752482036682870]": { + "$type": "EditorOnlyEntityComponent", + "Id": 18388752482036682870 + }, + "Component_[3917765902796274739]": { + "$type": "EditorEntityIconComponent", + "Id": 3917765902796274739 + }, + "Component_[4143676462074671972]": { + "$type": "AZ::Render::EditorAreaLightComponent", + "Id": 4143676462074671972, + "Controller": { + "Configuration": { + "LightType": 1, + "IntensityMode": 1, + "Intensity": 50.0, + "AttenuationRadius": 79.26654815673828 + } + } + }, + "Component_[4863305662794796025]": { + "$type": "EditorVisibilityComponent", + "Id": 4863305662794796025 + }, + "Component_[5902189275159544426]": { + "$type": "SelectionComponent", + "Id": 5902189275159544426 + } + } + }, + "Entity_[460611134916]": { + "Id": "Entity_[460611134916]", + "Name": "Light", + "Components": { + "Component_[12284008075844705430]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 12284008075844705430, + "Parent Entity": "Entity_[1579029125278]", + "Transform Data": { + "Translate": [ + -7.999996662139893, + 0.0, + -6.0 + ] + } + }, + "Component_[13457184847449496840]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 13457184847449496840 + }, + "Component_[14431842353830635996]": { + "$type": "EditorLockComponent", + "Id": 14431842353830635996 + }, + "Component_[1473579476469110229]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1473579476469110229 + }, + "Component_[17008596888127953988]": { + "$type": "EditorEntitySortComponent", + "Id": 17008596888127953988 + }, + "Component_[17246196475221723560]": { + "$type": "EditorInspectorComponent", + "Id": 17246196475221723560, + "ComponentOrderEntryArray": [ + { + "ComponentId": 12284008075844705430 + }, + { + "ComponentId": 7864910209001174169, + "SortIndex": 1 + } + ] + }, + "Component_[18388752482036682870]": { + "$type": "EditorOnlyEntityComponent", + "Id": 18388752482036682870 + }, + "Component_[2667740107500775267]": { + "$type": "EditorSphereShapeComponent", + "Id": 2667740107500775267, + "ShapeColor": [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + "SphereShape": { + "Configuration": { + "Radius": 0.05000000074505806 + } + } + }, + "Component_[3917765902796274739]": { + "$type": "EditorEntityIconComponent", + "Id": 3917765902796274739 + }, + "Component_[4143676462074671972]": { + "$type": "AZ::Render::EditorAreaLightComponent", + "Id": 4143676462074671972, + "Controller": { + "Configuration": { + "LightType": 1, + "IntensityMode": 1, + "Intensity": 50.0, + "AttenuationRadius": 79.26654815673828 + } + } + }, + "Component_[4863305662794796025]": { + "$type": "EditorVisibilityComponent", + "Id": 4863305662794796025 + }, + "Component_[5902189275159544426]": { + "$type": "SelectionComponent", + "Id": 5902189275159544426 + } + } + }, + "Entity_[464906102212]": { + "Id": "Entity_[464906102212]", + "Name": "Light", + "Components": { + "Component_[12284008075844705430]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 12284008075844705430, + "Parent Entity": "Entity_[1579029125278]", + "Transform Data": { + "Translate": [ + -7.999996662139893, + 5.0, + -6.0 + ] + } + }, + "Component_[13457184847449496840]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 13457184847449496840 + }, + "Component_[14431842353830635996]": { + "$type": "EditorLockComponent", + "Id": 14431842353830635996 + }, + "Component_[1473579476469110229]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1473579476469110229 + }, + "Component_[17008596888127953988]": { + "$type": "EditorEntitySortComponent", + "Id": 17008596888127953988 + }, + "Component_[17246196475221723560]": { + "$type": "EditorInspectorComponent", + "Id": 17246196475221723560, + "ComponentOrderEntryArray": [ + { + "ComponentId": 12284008075844705430 + }, + { + "ComponentId": 7864910209001174169, + "SortIndex": 1 + } + ] + }, + "Component_[18388752482036682870]": { + "$type": "EditorOnlyEntityComponent", + "Id": 18388752482036682870 + }, + "Component_[3917765902796274739]": { + "$type": "EditorEntityIconComponent", + "Id": 3917765902796274739 + }, + "Component_[4143676462074671972]": { + "$type": "AZ::Render::EditorAreaLightComponent", + "Id": 4143676462074671972, + "Controller": { + "Configuration": { + "LightType": 1, + "IntensityMode": 1, + "Intensity": 50.0, + "AttenuationRadius": 79.26654815673828 + } + } + }, + "Component_[4863305662794796025]": { + "$type": "EditorVisibilityComponent", + "Id": 4863305662794796025 + }, + "Component_[5902189275159544426]": { + "$type": "SelectionComponent", + "Id": 5902189275159544426 + }, + "Component_[9077284412210882947]": { + "$type": "EditorSphereShapeComponent", + "Id": 9077284412210882947, + "ShapeColor": [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + "SphereShape": { + "Configuration": { + "Radius": 0.05000000074505806 + } + } + } + } + }, + "Entity_[469201069508]": { + "Id": "Entity_[469201069508]", + "Name": "Light", + "Components": { + "Component_[12284008075844705430]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 12284008075844705430, + "Parent Entity": "Entity_[1579029125278]", + "Transform Data": { + "Translate": [ + -7.999996662139893, + -10.0, + 6.0 + ] + } + }, + "Component_[13457184847449496840]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 13457184847449496840 + }, + "Component_[14431842353830635996]": { + "$type": "EditorLockComponent", + "Id": 14431842353830635996 + }, + "Component_[1473579476469110229]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1473579476469110229 + }, + "Component_[17008596888127953988]": { + "$type": "EditorEntitySortComponent", + "Id": 17008596888127953988 + }, + "Component_[17246196475221723560]": { + "$type": "EditorInspectorComponent", + "Id": 17246196475221723560, + "ComponentOrderEntryArray": [ + { + "ComponentId": 12284008075844705430 + }, + { + "ComponentId": 7864910209001174169, + "SortIndex": 1 + } + ] + }, + "Component_[18388752482036682870]": { + "$type": "EditorOnlyEntityComponent", + "Id": 18388752482036682870 + }, + "Component_[2210433037075578051]": { + "$type": "EditorSphereShapeComponent", + "Id": 2210433037075578051, + "ShapeColor": [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + "SphereShape": { + "Configuration": { + "Radius": 0.05000000074505806 + } + } + }, + "Component_[3917765902796274739]": { + "$type": "EditorEntityIconComponent", + "Id": 3917765902796274739 + }, + "Component_[4143676462074671972]": { + "$type": "AZ::Render::EditorAreaLightComponent", + "Id": 4143676462074671972, + "Controller": { + "Configuration": { + "LightType": 1, + "IntensityMode": 1, + "Intensity": 50.0, + "AttenuationRadius": 79.26654815673828 + } + } + }, + "Component_[4863305662794796025]": { + "$type": "EditorVisibilityComponent", + "Id": 4863305662794796025 + }, + "Component_[5902189275159544426]": { + "$type": "SelectionComponent", + "Id": 5902189275159544426 + } + } + }, + "Entity_[473496036804]": { + "Id": "Entity_[473496036804]", + "Name": "Light", + "Components": { + "Component_[12284008075844705430]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 12284008075844705430, + "Parent Entity": "Entity_[1579029125278]", + "Transform Data": { + "Translate": [ + -7.999996662139893, + 5.0, + 6.0 + ] + } + }, + "Component_[12980894623939584115]": { + "$type": "EditorSphereShapeComponent", + "Id": 12980894623939584115, + "ShapeColor": [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + "SphereShape": { + "Configuration": { + "Radius": 0.05000000074505806 + } + } + }, + "Component_[13457184847449496840]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 13457184847449496840 + }, + "Component_[14431842353830635996]": { + "$type": "EditorLockComponent", + "Id": 14431842353830635996 + }, + "Component_[1473579476469110229]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1473579476469110229 + }, + "Component_[17008596888127953988]": { + "$type": "EditorEntitySortComponent", + "Id": 17008596888127953988 + }, + "Component_[17246196475221723560]": { + "$type": "EditorInspectorComponent", + "Id": 17246196475221723560, + "ComponentOrderEntryArray": [ + { + "ComponentId": 12284008075844705430 + }, + { + "ComponentId": 7864910209001174169, + "SortIndex": 1 + } + ] + }, + "Component_[18388752482036682870]": { + "$type": "EditorOnlyEntityComponent", + "Id": 18388752482036682870 + }, + "Component_[3917765902796274739]": { + "$type": "EditorEntityIconComponent", + "Id": 3917765902796274739 + }, + "Component_[4143676462074671972]": { + "$type": "AZ::Render::EditorAreaLightComponent", + "Id": 4143676462074671972, + "Controller": { + "Configuration": { + "LightType": 1, + "IntensityMode": 1, + "Intensity": 50.0, + "AttenuationRadius": 79.26654815673828 + } + } + }, + "Component_[4863305662794796025]": { + "$type": "EditorVisibilityComponent", + "Id": 4863305662794796025 + }, + "Component_[5902189275159544426]": { + "$type": "SelectionComponent", + "Id": 5902189275159544426 + } + } + }, + "Entity_[477791004100]": { + "Id": "Entity_[477791004100]", + "Name": "Light", + "Components": { + "Component_[12284008075844705430]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 12284008075844705430, + "Parent Entity": "Entity_[1579029125278]", + "Transform Data": { + "Translate": [ + -7.999996662139893, + 12.0, + 6.0 + ] + } + }, + "Component_[13457184847449496840]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 13457184847449496840 + }, + "Component_[14431842353830635996]": { + "$type": "EditorLockComponent", + "Id": 14431842353830635996 + }, + "Component_[1473579476469110229]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1473579476469110229 + }, + "Component_[17008596888127953988]": { + "$type": "EditorEntitySortComponent", + "Id": 17008596888127953988 + }, + "Component_[17246196475221723560]": { + "$type": "EditorInspectorComponent", + "Id": 17246196475221723560, + "ComponentOrderEntryArray": [ + { + "ComponentId": 12284008075844705430 + }, + { + "ComponentId": 7864910209001174169, + "SortIndex": 1 + } + ] + }, + "Component_[18236955021241851736]": { + "$type": "EditorSphereShapeComponent", + "Id": 18236955021241851736, + "ShapeColor": [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + "SphereShape": { + "Configuration": { + "Radius": 0.05000000074505806 + } + } + }, + "Component_[18388752482036682870]": { + "$type": "EditorOnlyEntityComponent", + "Id": 18388752482036682870 + }, + "Component_[3917765902796274739]": { + "$type": "EditorEntityIconComponent", + "Id": 3917765902796274739 + }, + "Component_[4143676462074671972]": { + "$type": "AZ::Render::EditorAreaLightComponent", + "Id": 4143676462074671972, + "Controller": { + "Configuration": { + "LightType": 1, + "IntensityMode": 1, + "Intensity": 50.0, + "AttenuationRadius": 79.26654815673828 + } + } + }, + "Component_[4863305662794796025]": { + "$type": "EditorVisibilityComponent", + "Id": 4863305662794796025 + }, + "Component_[5902189275159544426]": { + "$type": "SelectionComponent", + "Id": 5902189275159544426 + } + } + }, + "Entity_[482085971396]": { + "Id": "Entity_[482085971396]", + "Name": "Light", + "Components": { + "Component_[12284008075844705430]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 12284008075844705430, + "Parent Entity": "Entity_[1579029125278]", + "Transform Data": { + "Translate": [ + -7.999996662139893, + -5.0, + -6.0 + ] + } + }, + "Component_[13457184847449496840]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 13457184847449496840 + }, + "Component_[14431842353830635996]": { + "$type": "EditorLockComponent", + "Id": 14431842353830635996 + }, + "Component_[1473579476469110229]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1473579476469110229 + }, + "Component_[17008596888127953988]": { + "$type": "EditorEntitySortComponent", + "Id": 17008596888127953988 + }, + "Component_[17246196475221723560]": { + "$type": "EditorInspectorComponent", + "Id": 17246196475221723560, + "ComponentOrderEntryArray": [ + { + "ComponentId": 12284008075844705430 + }, + { + "ComponentId": 7864910209001174169, + "SortIndex": 1 + } + ] + }, + "Component_[18388752482036682870]": { + "$type": "EditorOnlyEntityComponent", + "Id": 18388752482036682870 + }, + "Component_[3917765902796274739]": { + "$type": "EditorEntityIconComponent", + "Id": 3917765902796274739 + }, + "Component_[4143676462074671972]": { + "$type": "AZ::Render::EditorAreaLightComponent", + "Id": 4143676462074671972, + "Controller": { + "Configuration": { + "LightType": 1, + "IntensityMode": 1, + "Intensity": 50.0, + "AttenuationRadius": 79.26654815673828 + } + } + }, + "Component_[4863305662794796025]": { + "$type": "EditorVisibilityComponent", + "Id": 4863305662794796025 + }, + "Component_[5902189275159544426]": { + "$type": "SelectionComponent", + "Id": 5902189275159544426 + }, + "Component_[868225960524074909]": { + "$type": "EditorSphereShapeComponent", + "Id": 868225960524074909, + "ShapeColor": [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + "SphereShape": { + "Configuration": { + "Radius": 0.05000000074505806 + } + } + } + } + }, + "Entity_[486380938692]": { + "Id": "Entity_[486380938692]", + "Name": "Light", + "Components": { + "Component_[12284008075844705430]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 12284008075844705430, + "Parent Entity": "Entity_[1579029125278]", + "Transform Data": { + "Translate": [ + -7.999996662139893, + 0.0, + 6.0 + ] + } + }, + "Component_[13457184847449496840]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 13457184847449496840 + }, + "Component_[14431842353830635996]": { + "$type": "EditorLockComponent", + "Id": 14431842353830635996 + }, + "Component_[1473579476469110229]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1473579476469110229 + }, + "Component_[17008596888127953988]": { + "$type": "EditorEntitySortComponent", + "Id": 17008596888127953988 + }, + "Component_[17246196475221723560]": { + "$type": "EditorInspectorComponent", + "Id": 17246196475221723560, + "ComponentOrderEntryArray": [ + { + "ComponentId": 12284008075844705430 + }, + { + "ComponentId": 7864910209001174169, + "SortIndex": 1 + } + ] + }, + "Component_[18388752482036682870]": { + "$type": "EditorOnlyEntityComponent", + "Id": 18388752482036682870 + }, + "Component_[232169833717435589]": { + "$type": "EditorSphereShapeComponent", + "Id": 232169833717435589, + "ShapeColor": [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + "SphereShape": { + "Configuration": { + "Radius": 0.05000000074505806 + } + } + }, + "Component_[3917765902796274739]": { + "$type": "EditorEntityIconComponent", + "Id": 3917765902796274739 + }, + "Component_[4143676462074671972]": { + "$type": "AZ::Render::EditorAreaLightComponent", + "Id": 4143676462074671972, + "Controller": { + "Configuration": { + "LightType": 1, + "IntensityMode": 1, + "Intensity": 50.0, + "AttenuationRadius": 79.26654815673828 + } + } + }, + "Component_[4863305662794796025]": { + "$type": "EditorVisibilityComponent", + "Id": 4863305662794796025 + }, + "Component_[5902189275159544426]": { + "$type": "SelectionComponent", + "Id": 5902189275159544426 + } + } + }, + "Entity_[490675905988]": { + "Id": "Entity_[490675905988]", + "Name": "Light", + "Components": { + "Component_[12284008075844705430]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 12284008075844705430, + "Parent Entity": "Entity_[1579029125278]", + "Transform Data": { + "Translate": [ + -7.999996662139893, + -5.0, + 6.0 + ] + } + }, + "Component_[13457184847449496840]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 13457184847449496840 + }, + "Component_[14431842353830635996]": { + "$type": "EditorLockComponent", + "Id": 14431842353830635996 + }, + "Component_[1473579476469110229]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1473579476469110229 + }, + "Component_[17008596888127953988]": { + "$type": "EditorEntitySortComponent", + "Id": 17008596888127953988 + }, + "Component_[17246196475221723560]": { + "$type": "EditorInspectorComponent", + "Id": 17246196475221723560, + "ComponentOrderEntryArray": [ + { + "ComponentId": 12284008075844705430 + }, + { + "ComponentId": 7864910209001174169, + "SortIndex": 1 + } + ] + }, + "Component_[18055528880793132775]": { + "$type": "EditorSphereShapeComponent", + "Id": 18055528880793132775, + "ShapeColor": [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + "SphereShape": { + "Configuration": { + "Radius": 0.05000000074505806 + } + } + }, + "Component_[18388752482036682870]": { + "$type": "EditorOnlyEntityComponent", + "Id": 18388752482036682870 + }, + "Component_[3917765902796274739]": { + "$type": "EditorEntityIconComponent", + "Id": 3917765902796274739 + }, + "Component_[4143676462074671972]": { + "$type": "AZ::Render::EditorAreaLightComponent", + "Id": 4143676462074671972, + "Controller": { + "Configuration": { + "LightType": 1, + "IntensityMode": 1, + "Intensity": 50.0, + "AttenuationRadius": 79.26654815673828 + } + } + }, + "Component_[4863305662794796025]": { + "$type": "EditorVisibilityComponent", + "Id": 4863305662794796025 + }, + "Component_[5902189275159544426]": { + "$type": "SelectionComponent", + "Id": 5902189275159544426 + } + } + }, + "Entity_[494970873284]": { + "Id": "Entity_[494970873284]", + "Name": "Light", + "Components": { + "Component_[12284008075844705430]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 12284008075844705430, + "Parent Entity": "Entity_[1579029125278]", + "Transform Data": { + "Translate": [ + -7.999996662139893, + 15.0, + -6.0 + ] + } + }, + "Component_[13457184847449496840]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 13457184847449496840 + }, + "Component_[14431842353830635996]": { + "$type": "EditorLockComponent", + "Id": 14431842353830635996 + }, + "Component_[1473579476469110229]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1473579476469110229 + }, + "Component_[17008596888127953988]": { + "$type": "EditorEntitySortComponent", + "Id": 17008596888127953988 + }, + "Component_[17246196475221723560]": { + "$type": "EditorInspectorComponent", + "Id": 17246196475221723560, + "ComponentOrderEntryArray": [ + { + "ComponentId": 12284008075844705430 + }, + { + "ComponentId": 7864910209001174169, + "SortIndex": 1 + } + ] + }, + "Component_[18388752482036682870]": { + "$type": "EditorOnlyEntityComponent", + "Id": 18388752482036682870 + }, + "Component_[3917765902796274739]": { + "$type": "EditorEntityIconComponent", + "Id": 3917765902796274739 + }, + "Component_[4143676462074671972]": { + "$type": "AZ::Render::EditorAreaLightComponent", + "Id": 4143676462074671972, + "Controller": { + "Configuration": { + "LightType": 1, + "IntensityMode": 1, + "Intensity": 50.0, + "AttenuationRadius": 79.26654815673828 + } + } + }, + "Component_[4863305662794796025]": { + "$type": "EditorVisibilityComponent", + "Id": 4863305662794796025 + }, + "Component_[565296772593396698]": { + "$type": "EditorSphereShapeComponent", + "Id": 565296772593396698, + "ShapeColor": [ + 1.0, + 1.0, + 1.0, + 1.0 + ], + "SphereShape": { + "Configuration": { + "Radius": 0.05000000074505806 + } + } + }, + "Component_[5902189275159544426]": { + "$type": "SelectionComponent", + "Id": 5902189275159544426 + } + } + } + } +} \ No newline at end of file diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic.material new file mode 100644 index 0000000000..32ac8dfd10 --- /dev/null +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic.material @@ -0,0 +1,32 @@ +{ + "materialType": "Materials/Types/StandardPBR.materialtype", + "propertyLayoutVersion": 1, + "properties": { + "baseColor": { + "color": [ 1.0, 1.0, 1.0 ], + "factor": 0.75, + "useTexture": false, + "textureMap": "" + }, + "metallic": { + "factor": 0.0, + "useTexture": false, + "textureMap": "" + }, + "roughness": { + "factor": 0.0, + "useTexture": false, + "textureMap": "" + }, + "specularF0": { + "factor": 0.5, + "useTexture": false, + "textureMap": "" + }, + "normal": { + "factor": 1.0, + "useTexture": false, + "textureMap": "" + } + } +} diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r00.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r00.material new file mode 100644 index 0000000000..dcadcb9bfe --- /dev/null +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r00.material @@ -0,0 +1,13 @@ +{ + "parentMaterial": "./basic.material", + "materialType": "materials/Types/StandardPBR.materialtype", + "propertyLayoutVersion": 1, + "properties": { + "metallic": { + "factor": 0.0 + }, + "roughness": { + "factor": 0.0 + } + } +} diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r01.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r01.material new file mode 100644 index 0000000000..0c2b3e62b3 --- /dev/null +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r01.material @@ -0,0 +1,13 @@ +{ + "parentMaterial": "./basic.material", + "materialType": "materials/Types/StandardPBR.materialtype", + "propertyLayoutVersion": 1, + "properties": { + "metallic": { + "factor": 0.0 + }, + "roughness": { + "factor": 0.1 + } + } +} diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r02.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r02.material new file mode 100644 index 0000000000..8d29890384 --- /dev/null +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r02.material @@ -0,0 +1,13 @@ +{ + "parentMaterial": "./basic.material", + "materialType": "materials/Types/StandardPBR.materialtype", + "propertyLayoutVersion": 1, + "properties": { + "metallic": { + "factor": 0.0 + }, + "roughness": { + "factor": 0.2 + } + } +} diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r03.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r03.material new file mode 100644 index 0000000000..bb9557241b --- /dev/null +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r03.material @@ -0,0 +1,13 @@ +{ + "parentMaterial": "./basic.material", + "materialType": "materials/Types/StandardPBR.materialtype", + "propertyLayoutVersion": 1, + "properties": { + "metallic": { + "factor": 0.0 + }, + "roughness": { + "factor": 0.3 + } + } +} diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r04.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r04.material new file mode 100644 index 0000000000..e14e2899fa --- /dev/null +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r04.material @@ -0,0 +1,13 @@ +{ + "parentMaterial": "./basic.material", + "materialType": "materials/Types/StandardPBR.materialtype", + "propertyLayoutVersion": 1, + "properties": { + "metallic": { + "factor": 0.0 + }, + "roughness": { + "factor": 0.4 + } + } +} diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r05.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r05.material new file mode 100644 index 0000000000..344ce084e5 --- /dev/null +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r05.material @@ -0,0 +1,13 @@ +{ + "parentMaterial": "./basic.material", + "materialType": "materials/Types/StandardPBR.materialtype", + "propertyLayoutVersion": 1, + "properties": { + "metallic": { + "factor": 0.0 + }, + "roughness": { + "factor": 0.5 + } + } +} diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r06.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r06.material new file mode 100644 index 0000000000..0f8195653f --- /dev/null +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r06.material @@ -0,0 +1,13 @@ +{ + "parentMaterial": "./basic.material", + "materialType": "materials/Types/StandardPBR.materialtype", + "propertyLayoutVersion": 1, + "properties": { + "metallic": { + "factor": 0.0 + }, + "roughness": { + "factor": 0.6 + } + } +} diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r07.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r07.material new file mode 100644 index 0000000000..d5d95ff285 --- /dev/null +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r07.material @@ -0,0 +1,13 @@ +{ + "parentMaterial": "./basic.material", + "materialType": "materials/Types/StandardPBR.materialtype", + "propertyLayoutVersion": 1, + "properties": { + "metallic": { + "factor": 0.0 + }, + "roughness": { + "factor": 0.7 + } + } +} diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r08.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r08.material new file mode 100644 index 0000000000..801b138831 --- /dev/null +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r08.material @@ -0,0 +1,13 @@ +{ + "parentMaterial": "./basic.material", + "materialType": "materials/Types/StandardPBR.materialtype", + "propertyLayoutVersion": 1, + "properties": { + "metallic": { + "factor": 0.0 + }, + "roughness": { + "factor": 0.8 + } + } +} diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r09.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r09.material new file mode 100644 index 0000000000..0710a320cb --- /dev/null +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r09.material @@ -0,0 +1,13 @@ +{ + "parentMaterial": "./basic.material", + "materialType": "materials/Types/StandardPBR.materialtype", + "propertyLayoutVersion": 1, + "properties": { + "metallic": { + "factor": 0.0 + }, + "roughness": { + "factor": 0.9 + } + } +} diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r10.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r10.material new file mode 100644 index 0000000000..d1cc781c61 --- /dev/null +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r10.material @@ -0,0 +1,13 @@ +{ + "parentMaterial": "./basic.material", + "materialType": "materials/Types/StandardPBR.materialtype", + "propertyLayoutVersion": 1, + "properties": { + "metallic": { + "factor": 0.0 + }, + "roughness": { + "factor": 1.0 + } + } +} diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r00.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r00.material new file mode 100644 index 0000000000..945cd1e9eb --- /dev/null +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r00.material @@ -0,0 +1,13 @@ +{ + "parentMaterial": "./basic.material", + "materialType": "materials/Types/StandardPBR.materialtype", + "propertyLayoutVersion": 1, + "properties": { + "metallic": { + "factor": 1.0 + }, + "roughness": { + "factor": 0.0 + } + } +} diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r01.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r01.material new file mode 100644 index 0000000000..85f6008782 --- /dev/null +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r01.material @@ -0,0 +1,13 @@ +{ + "parentMaterial": "./basic.material", + "materialType": "materials/Types/StandardPBR.materialtype", + "propertyLayoutVersion": 1, + "properties": { + "metallic": { + "factor": 1.0 + }, + "roughness": { + "factor": 0.1 + } + } +} diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r02.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r02.material new file mode 100644 index 0000000000..5abedc34e2 --- /dev/null +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r02.material @@ -0,0 +1,13 @@ +{ + "parentMaterial": "./basic.material", + "materialType": "materials/Types/StandardPBR.materialtype", + "propertyLayoutVersion": 1, + "properties": { + "metallic": { + "factor": 1.0 + }, + "roughness": { + "factor": 0.2 + } + } +} diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r03.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r03.material new file mode 100644 index 0000000000..50b37a647d --- /dev/null +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r03.material @@ -0,0 +1,13 @@ +{ + "parentMaterial": "./basic.material", + "materialType": "materials/Types/StandardPBR.materialtype", + "propertyLayoutVersion": 1, + "properties": { + "metallic": { + "factor": 1.0 + }, + "roughness": { + "factor": 0.3 + } + } +} diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r04.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r04.material new file mode 100644 index 0000000000..ad74ddf08b --- /dev/null +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r04.material @@ -0,0 +1,13 @@ +{ + "parentMaterial": "./basic.material", + "materialType": "materials/Types/StandardPBR.materialtype", + "propertyLayoutVersion": 1, + "properties": { + "metallic": { + "factor": 1.0 + }, + "roughness": { + "factor": 0.4 + } + } +} diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r05.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r05.material new file mode 100644 index 0000000000..f7f3260b97 --- /dev/null +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r05.material @@ -0,0 +1,13 @@ +{ + "parentMaterial": "./basic.material", + "materialType": "materials/Types/StandardPBR.materialtype", + "propertyLayoutVersion": 1, + "properties": { + "metallic": { + "factor": 1.0 + }, + "roughness": { + "factor": 0.5 + } + } +} diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r06.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r06.material new file mode 100644 index 0000000000..fc982f9c22 --- /dev/null +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r06.material @@ -0,0 +1,13 @@ +{ + "parentMaterial": "./basic.material", + "materialType": "materials/Types/StandardPBR.materialtype", + "propertyLayoutVersion": 1, + "properties": { + "metallic": { + "factor": 1.0 + }, + "roughness": { + "factor": 0.6 + } + } +} diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r07.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r07.material new file mode 100644 index 0000000000..c4526dfd2c --- /dev/null +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r07.material @@ -0,0 +1,13 @@ +{ + "parentMaterial": "./basic.material", + "materialType": "materials/Types/StandardPBR.materialtype", + "propertyLayoutVersion": 1, + "properties": { + "metallic": { + "factor": 1.0 + }, + "roughness": { + "factor": 0.7 + } + } +} diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r08.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r08.material new file mode 100644 index 0000000000..f756a36ded --- /dev/null +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r08.material @@ -0,0 +1,13 @@ +{ + "parentMaterial": "./basic.material", + "materialType": "materials/Types/StandardPBR.materialtype", + "propertyLayoutVersion": 1, + "properties": { + "metallic": { + "factor": 1.0 + }, + "roughness": { + "factor": 0.8 + } + } +} diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r09.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r09.material new file mode 100644 index 0000000000..a853979d6d --- /dev/null +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r09.material @@ -0,0 +1,13 @@ +{ + "parentMaterial": "./basic.material", + "materialType": "materials/Types/StandardPBR.materialtype", + "propertyLayoutVersion": 1, + "properties": { + "metallic": { + "factor": 1.0 + }, + "roughness": { + "factor": 0.9 + } + } +} diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r10.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r10.material new file mode 100644 index 0000000000..e4528d45fd --- /dev/null +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r10.material @@ -0,0 +1,13 @@ +{ + "parentMaterial": "./basic.material", + "materialType": "materials/Types/StandardPBR.materialtype", + "propertyLayoutVersion": 1, + "properties": { + "metallic": { + "factor": 1.0 + }, + "roughness": { + "factor": 1.0 + } + } +} diff --git a/AutomatedTesting/Levels/PbrMaterialChart/tags.txt b/AutomatedTesting/Levels/PbrMaterialChart/tags.txt new file mode 100644 index 0000000000..0d6c1880e7 --- /dev/null +++ b/AutomatedTesting/Levels/PbrMaterialChart/tags.txt @@ -0,0 +1,12 @@ +0,0,0,0,0,0 +0,0,0,0,0,0 +0,0,0,0,0,0 +0,0,0,0,0,0 +0,0,0,0,0,0 +0,0,0,0,0,0 +0,0,0,0,0,0 +0,0,0,0,0,0 +0,0,0,0,0,0 +0,0,0,0,0,0 +0,0,0,0,0,0 +0,0,0,0,0,0 diff --git a/AutomatedTesting/Objects/sphere.fbx b/AutomatedTesting/Objects/sphere.fbx new file mode 100644 index 0000000000..5c8f550c8c --- /dev/null +++ b/AutomatedTesting/Objects/sphere.fbx @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a476e99b55cf2a76fef6775c5a57dad29f8ffcb942c625bab04c89051a72a560 +size 62626 From a6b2e2cabd99ce4d0b140e3a2186d11bce1f744c Mon Sep 17 00:00:00 2001 From: lsemp3d <58790905+lsemp3d@users.noreply.github.com> Date: Wed, 8 Dec 2021 13:59:57 -0800 Subject: [PATCH 08/70] Enabled the Script Canvas Minimap. It will be tested and any performance concerns will be addressed Signed-off-by: lsemp3d <58790905+lsemp3d@users.noreply.github.com> --- .../Code/Editor/View/Windows/MainWindow.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.cpp b/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.cpp index fa13681879..4379d7ed47 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.cpp @@ -791,11 +791,7 @@ namespace ScriptCanvasEditor // View menu connect(ui->action_ViewNodePalette, &QAction::triggered, this, &MainWindow::OnViewNodePalette); - - // Disabling the Minimap since it does not play nicely with the Qt caching solution - // And causing some weird visual issues. connect(ui->action_ViewMiniMap, &QAction::triggered, this, &MainWindow::OnViewMiniMap); - ui->action_ViewMiniMap->setVisible(false); connect(ui->action_ViewProperties, &QAction::triggered, this, &MainWindow::OnViewProperties); connect(ui->action_ViewBookmarks, &QAction::triggered, this, &MainWindow::OnBookmarks); @@ -2774,14 +2770,12 @@ namespace ScriptCanvasEditor m_logPanel->hide(); } - /* Disable Mini-map until we fix rendering performance if (m_minimap) { addDockWidget(Qt::LeftDockWidgetArea, m_minimap); m_minimap->setFloating(false); - m_minimap->hide(); + m_minimap->show(); } - */ if (m_nodePalette) { @@ -2825,14 +2819,12 @@ namespace ScriptCanvasEditor m_bookmarkDockWidget->hide(); } - /* Disable mini-map until we fix rendering performance if (m_minimap) { addDockWidget(Qt::RightDockWidgetArea, m_minimap); m_minimap->setFloating(false); - m_minimap->hide(); + m_minimap->show(); } - */ resizeDocks( { m_nodePalette, m_propertyGrid }, From d7a3d634572278a35d22f466d28dff32926d417a Mon Sep 17 00:00:00 2001 From: nggieber <52797929+AMZN-nggieber@users.noreply.github.com> Date: Thu, 9 Dec 2021 09:24:01 -0800 Subject: [PATCH 09/70] Change ProjectSettings to Singleton interface Signed-off-by: nggieber <52797929+AMZN-nggieber@users.noreply.github.com> --- .../ProjectManager/Source/Application.cpp | 8 + .../Tools/ProjectManager/Source/Application.h | 2 + .../Source/ExternalLinkDialog.cpp | 5 +- .../ProjectManager/Source/LinkWidget.cpp | 7 +- .../Source/ProjectBuilderController.cpp | 10 +- .../Source/ProjectManagerSettings.cpp | 248 ------------------ .../Source/ProjectManagerSettings.h | 37 --- .../ProjectManager/Source/ProjectsScreen.cpp | 4 +- Code/Tools/ProjectManager/Source/Settings.cpp | 201 ++++++++++++++ Code/Tools/ProjectManager/Source/Settings.h | 50 ++++ .../ProjectManager/Source/SettingsInterface.h | 57 ++++ .../Source/UpdateProjectCtrl.cpp | 7 +- .../project_manager_files.cmake | 5 +- .../project_manager_tests_files.cmake | 2 +- ...gerSettingsTests.cpp => SettingsTests.cpp} | 80 +++--- 15 files changed, 383 insertions(+), 340 deletions(-) delete mode 100644 Code/Tools/ProjectManager/Source/ProjectManagerSettings.cpp delete mode 100644 Code/Tools/ProjectManager/Source/ProjectManagerSettings.h create mode 100644 Code/Tools/ProjectManager/Source/Settings.cpp create mode 100644 Code/Tools/ProjectManager/Source/Settings.h create mode 100644 Code/Tools/ProjectManager/Source/SettingsInterface.h rename Code/Tools/ProjectManager/tests/{ProjectManagerSettingsTests.cpp => SettingsTests.cpp} (57%) diff --git a/Code/Tools/ProjectManager/Source/Application.cpp b/Code/Tools/ProjectManager/Source/Application.cpp index 29e0df3c3a..8ce8075988 100644 --- a/Code/Tools/ProjectManager/Source/Application.cpp +++ b/Code/Tools/ProjectManager/Source/Application.cpp @@ -111,6 +111,14 @@ namespace O3DE::ProjectManager } } + m_settings = AZStd::make_unique(); + AZ_Assert(m_settings, "Failed to create Settings"); + + if (!m_settings->IsInitialized()) + { + return false; + } + const AZ::CommandLine* commandLine = GetCommandLine(); AZ_Assert(commandLine, "Failed to get command line"); diff --git a/Code/Tools/ProjectManager/Source/Application.h b/Code/Tools/ProjectManager/Source/Application.h index ad55694b18..e95645d500 100644 --- a/Code/Tools/ProjectManager/Source/Application.h +++ b/Code/Tools/ProjectManager/Source/Application.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #endif @@ -36,6 +37,7 @@ namespace O3DE::ProjectManager bool InitLog(const char* logName); AZStd::unique_ptr m_pythonBindings; + AZStd::unique_ptr m_settings; QSharedPointer m_app; QSharedPointer m_mainWindow; diff --git a/Code/Tools/ProjectManager/Source/ExternalLinkDialog.cpp b/Code/Tools/ProjectManager/Source/ExternalLinkDialog.cpp index 2f3d615863..eada467b6a 100644 --- a/Code/Tools/ProjectManager/Source/ExternalLinkDialog.cpp +++ b/Code/Tools/ProjectManager/Source/ExternalLinkDialog.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include @@ -85,6 +85,7 @@ namespace O3DE::ProjectManager void ExternalLinkDialog::SetSkipDialogSetting(bool state) { - PMSettings::SetProjectManagerKey(PMSettings::GetExternalLinkWarningKey(), state); + auto settings = SettingsInterface::Get(); + settings->Set(QString(settings->ExternalLinkWarningKey), state); } } // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/LinkWidget.cpp b/Code/Tools/ProjectManager/Source/LinkWidget.cpp index 87ccdb9aed..7a940e135b 100644 --- a/Code/Tools/ProjectManager/Source/LinkWidget.cpp +++ b/Code/Tools/ProjectManager/Source/LinkWidget.cpp @@ -8,9 +8,7 @@ #include #include -#include - -#include +#include #include #include @@ -33,7 +31,8 @@ namespace O3DE::ProjectManager { // Check if user request not to be shown external link warning dialog bool skipDialog = false; - PMSettings::GetProjectManagerKey(skipDialog, PMSettings::GetExternalLinkWarningKey()); + auto settings = SettingsInterface::Get(); + settings->Get(skipDialog, QString(settings->ExternalLinkWarningKey)); if (!skipDialog) { diff --git a/Code/Tools/ProjectManager/Source/ProjectBuilderController.cpp b/Code/Tools/ProjectManager/Source/ProjectBuilderController.cpp index 4fc188b289..0af3bfc503 100644 --- a/Code/Tools/ProjectManager/Source/ProjectBuilderController.cpp +++ b/Code/Tools/ProjectManager/Source/ProjectBuilderController.cpp @@ -9,9 +9,7 @@ #include #include #include -#include - -#include +#include #include #include @@ -30,7 +28,7 @@ namespace O3DE::ProjectManager m_worker->moveToThread(&m_workerThread); // Remove key here in case Project Manager crashing while building that causes HandleResults to not be called - PMSettings::SetProjectBuiltSuccessfully(m_projectInfo, false); + SettingsInterface::Get()->SetProjectBuiltSuccessfully(m_projectInfo, false); connect(&m_workerThread, &QThread::finished, m_worker, &ProjectBuilderWorker::deleteLater); connect(&m_workerThread, &QThread::started, m_worker, &ProjectBuilderWorker::BuildProject); @@ -114,7 +112,7 @@ namespace O3DE::ProjectManager emit NotifyBuildProject(m_projectInfo); } - PMSettings::SetProjectBuiltSuccessfully(m_projectInfo, false); + SettingsInterface::Get()->SetProjectBuiltSuccessfully(m_projectInfo, false); emit Done(false); return; @@ -123,7 +121,7 @@ namespace O3DE::ProjectManager { m_projectInfo.m_buildFailed = false; - PMSettings::SetProjectBuiltSuccessfully(m_projectInfo, true); + SettingsInterface::Get()->SetProjectBuiltSuccessfully(m_projectInfo, true); } emit Done(true); diff --git a/Code/Tools/ProjectManager/Source/ProjectManagerSettings.cpp b/Code/Tools/ProjectManager/Source/ProjectManagerSettings.cpp deleted file mode 100644 index 12dd569ad5..0000000000 --- a/Code/Tools/ProjectManager/Source/ProjectManagerSettings.cpp +++ /dev/null @@ -1,248 +0,0 @@ -/* - * 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 - -namespace O3DE::ProjectManager -{ - namespace PMSettings - { - bool SaveProjectManagerSettings() - { - auto settingsRegistry = AZ::SettingsRegistry::Get(); - AZ::SettingsRegistryMergeUtils::DumperSettings dumperSettings; - dumperSettings.m_prettifyOutput = true; - dumperSettings.m_jsonPointerPrefix = ProjectManagerKeyPrefix; - - AZStd::string stringBuffer; - AZ::IO::ByteContainerStream stringStream(&stringBuffer); - if (!AZ::SettingsRegistryMergeUtils::DumpSettingsRegistryToStream( - *settingsRegistry, ProjectManagerKeyPrefix, stringStream, dumperSettings)) - { - AZ_Warning("ProjectManager", false, "Could not save Project Manager settings to stream"); - return false; - } - - AZ::IO::FixedMaxPath o3deUserPath = AZ::Utils::GetO3deManifestDirectory(); - o3deUserPath /= AZ::SettingsRegistryInterface::RegistryFolder; - o3deUserPath /= "ProjectManager.setreg"; - - bool saved = false; - constexpr auto configurationMode = - AZ::IO::SystemFile::SF_OPEN_CREATE | AZ::IO::SystemFile::SF_OPEN_CREATE_PATH | AZ::IO::SystemFile::SF_OPEN_WRITE_ONLY; - - AZ::IO::SystemFile outputFile; - if (outputFile.Open(o3deUserPath.c_str(), configurationMode)) - { - saved = outputFile.Write(stringBuffer.data(), stringBuffer.size()) == stringBuffer.size(); - } - - AZ_Warning("ProjectManager", saved, "Unable to save Project Manager registry file to path: %s", o3deUserPath.c_str()); - return saved; - } - - bool GetProjectManagerKey(QString& result, const QString& settingsKey) - { - bool success = false; - auto settingsRegistry = AZ::SettingsRegistry::Get(); - if (settingsRegistry) - { - AZStd::string settingsValue; - success = settingsRegistry->Get(settingsValue, settingsKey.toStdString().c_str()); - - result = settingsValue.c_str(); - } - - return success; - } - - bool GetProjectManagerKey(bool& result, const QString& settingsKey) - { - bool success = false; - auto settingsRegistry = AZ::SettingsRegistry::Get(); - if (settingsRegistry) - { - success = settingsRegistry->Get(result, settingsKey.toStdString().c_str()); - } - - return success; - } - - bool SetProjectManagerKey(const QString& settingsKey, const QString& settingsValue, bool saveToDisk) - { - bool success = false; - auto settingsRegistry = AZ::SettingsRegistry::Get(); - if (settingsRegistry) - { - success = settingsRegistry->Set(settingsKey.toStdString().c_str(), settingsValue.toStdString().c_str()); - - if (saveToDisk) - { - SaveProjectManagerSettings(); - } - } - - return success; - } - - bool SetProjectManagerKey(const QString& settingsKey, bool settingsValue, bool saveToDisk) - { - bool success = false; - auto settingsRegistry = AZ::SettingsRegistry::Get(); - if (settingsRegistry) - { - success = settingsRegistry->Set(settingsKey.toStdString().c_str(), settingsValue); - - if (saveToDisk) - { - SaveProjectManagerSettings(); - } - } - - return success; - } - - bool RemoveProjectManagerKey(const QString& settingsKey, bool saveToDisk) - { - bool success = false; - auto settingsRegistry = AZ::SettingsRegistry::Get(); - if (settingsRegistry) - { - success = settingsRegistry->Remove(settingsKey.toStdString().c_str()); - - if (saveToDisk) - { - SaveProjectManagerSettings(); - } - } - - return success; - } - - bool CopyProjectManagerKeyString(const QString& settingsKeyOrig, const QString& settingsKeyDest, bool removeOrig, bool saveToDisk) - { - bool success = false; - auto settingsRegistry = AZ::SettingsRegistry::Get(); - if (settingsRegistry) - { - AZStd::string settingsValue; - success = settingsRegistry->Get(settingsValue, settingsKeyOrig.toStdString().c_str()); - - if (success) - { - success = settingsRegistry->Set(settingsKeyDest.toStdString().c_str(), settingsValue); - if (success) - { - if (removeOrig) - { - success = settingsRegistry->Remove(settingsKeyOrig.toStdString().c_str()); - } - - if (saveToDisk) - { - SaveProjectManagerSettings(); - } - } - } - } - - return success; - } - - QString GetProjectKey(const ProjectInfo& projectInfo) - { - return QString("%1/Projects/%2/%3").arg(ProjectManagerKeyPrefix, projectInfo.m_id, projectInfo.m_projectName); - } - - QString GetExternalLinkWarningKey() - { - return QString("%1/SkipExternalLinkWarning").arg(ProjectManagerKeyPrefix); - } - - QString GetProjectsBuiltSuccessfullyKey() - { - return QString("%1/SuccessfulBuildPaths").arg(ProjectManagerKeyPrefix); - } - - bool GetBuiltSuccessfullyPaths(AZStd::set& result) - { - bool success = false; - auto settingsRegistry = AZ::SettingsRegistry::Get(); - if (settingsRegistry) - { - QString builtKey = GetProjectsBuiltSuccessfullyKey(); - success = settingsRegistry->GetObject>(result, builtKey.toStdString().c_str()); - } - - return success; - } - - bool GetProjectBuiltSuccessfully(bool& result, const ProjectInfo& projectInfo) - { - AZStd::set builtPathsResult; - bool success = GetBuiltSuccessfullyPaths(builtPathsResult); - if (success) - { - // Check if buildPath is listed as successfully built - AZStd::string projectPath = projectInfo.m_path.toStdString().c_str(); - if (builtPathsResult.contains(projectPath)) - { - result = true; - } - } - // No project built statuses known - else - { - result = false; - } - - return success; - } - - bool SetProjectBuiltSuccessfully(const ProjectInfo& projectInfo, bool successfullyBuilt, bool saveToDisk) - { - AZStd::set builtPathsResult; - bool success = GetBuiltSuccessfullyPaths(builtPathsResult); - - AZStd::string projectPath = projectInfo.m_path.toStdString().c_str(); - if (successfullyBuilt) - { - //Add successfully built path to set - builtPathsResult.insert(projectPath); - } - else - { - // Remove unsuccessfully built path from set - builtPathsResult.erase(projectPath); - } - - auto settingsRegistry = AZ::SettingsRegistry::Get(); - if (settingsRegistry) - { - QString builtKey = GetProjectsBuiltSuccessfullyKey(); - success = settingsRegistry->SetObject>(builtKey.toStdString().c_str(), builtPathsResult); - - if (saveToDisk) - { - SaveProjectManagerSettings(); - } - } - else - { - success = false; - } - - return success; - } - - } // namespace PMSettings -} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/ProjectManagerSettings.h b/Code/Tools/ProjectManager/Source/ProjectManagerSettings.h deleted file mode 100644 index 2a92fcab0f..0000000000 --- a/Code/Tools/ProjectManager/Source/ProjectManagerSettings.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 - * - */ - -#pragma once - -#if !defined(Q_MOC_RUN) -#include -#include -#endif - -namespace O3DE::ProjectManager -{ - namespace PMSettings - { - static constexpr char ProjectManagerKeyPrefix[] = "/O3DE/ProjectManager"; - - bool SaveProjectManagerSettings(); - bool GetProjectManagerKey(QString& result, const QString& settingsKey); - bool GetProjectManagerKey(bool& result, const QString& settingsKey); - bool SetProjectManagerKey(const QString& settingsKey, const QString& settingsValue, bool saveToDisk = true); - bool SetProjectManagerKey(const QString& settingsKey, bool settingsValue, bool saveToDisk = true); - bool RemoveProjectManagerKey(const QString& settingsKey, bool saveToDisk = true); - bool CopyProjectManagerKeyString( - const QString& settingsKeyOrig, const QString& settingsKeyDest, bool removeOrig = false, bool saveToDisk = true); - - QString GetProjectKey(const ProjectInfo& projectInfo); - QString GetExternalLinkWarningKey(); - - bool GetProjectBuiltSuccessfully(bool& result, const ProjectInfo& projectInfo); - bool SetProjectBuiltSuccessfully(const ProjectInfo& projectInfo, bool successfullyBuilt, bool saveToDisk = true); - } // namespace PMSettings -} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/ProjectsScreen.cpp b/Code/Tools/ProjectManager/Source/ProjectsScreen.cpp index 9816595548..90ded37991 100644 --- a/Code/Tools/ProjectManager/Source/ProjectsScreen.cpp +++ b/Code/Tools/ProjectManager/Source/ProjectsScreen.cpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include @@ -292,7 +292,7 @@ namespace O3DE::ProjectManager if (currentButton) { bool projectBuiltSuccessfully = false; - PMSettings::GetProjectBuiltSuccessfully(projectBuiltSuccessfully, project); + SettingsInterface::Get()->GetProjectBuiltSuccessfully(projectBuiltSuccessfully, project); if (!projectBuiltSuccessfully) { diff --git a/Code/Tools/ProjectManager/Source/Settings.cpp b/Code/Tools/ProjectManager/Source/Settings.cpp new file mode 100644 index 0000000000..50081fbff3 --- /dev/null +++ b/Code/Tools/ProjectManager/Source/Settings.cpp @@ -0,0 +1,201 @@ +/* + * 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 + +namespace O3DE::ProjectManager +{ + Settings::Settings(bool saveToDisk) + : m_saveToDisk(saveToDisk) + { + m_settingsRegistry = AZ::SettingsRegistry::Get(); + + AZ_Assert(m_settingsRegistry, "Failed to create Settings"); + } + + bool Settings::IsInitialized() + { + // Settings intialized correctly if it successfuly got the SettingsRegistry + return m_settingsRegistry; + } + + bool Settings::Save() + { + AZ::SettingsRegistryMergeUtils::DumperSettings dumperSettings; + dumperSettings.m_prettifyOutput = true; + dumperSettings.m_jsonPointerPrefix = ProjectManagerKeyPrefix; + + AZStd::string stringBuffer; + AZ::IO::ByteContainerStream stringStream(&stringBuffer); + if (!AZ::SettingsRegistryMergeUtils::DumpSettingsRegistryToStream( + *m_settingsRegistry, ProjectManagerKeyPrefix, stringStream, dumperSettings)) + { + AZ_Warning("ProjectManager", false, "Could not save Project Manager settings to stream"); + return false; + } + + AZ::IO::FixedMaxPath o3deUserPath = AZ::Utils::GetO3deManifestDirectory(); + o3deUserPath /= AZ::SettingsRegistryInterface::RegistryFolder; + o3deUserPath /= "ProjectManager.setreg"; + + bool saved = false; + constexpr auto configurationMode = + AZ::IO::SystemFile::SF_OPEN_CREATE | AZ::IO::SystemFile::SF_OPEN_CREATE_PATH | AZ::IO::SystemFile::SF_OPEN_WRITE_ONLY; + + AZ::IO::SystemFile outputFile; + if (outputFile.Open(o3deUserPath.c_str(), configurationMode)) + { + saved = outputFile.Write(stringBuffer.data(), stringBuffer.size()) == stringBuffer.size(); + } + + AZ_Warning("ProjectManager", saved, "Unable to save Project Manager registry file to path: %s", o3deUserPath.c_str()); + return saved; + } + + bool Settings::Get(QString& result, const QString& settingsKey) + { + bool success = false; + + AZStd::string settingsValue; + success = m_settingsRegistry->Get(settingsValue, settingsKey.toStdString().c_str()); + + result = settingsValue.c_str(); + return success; + } + + bool Settings::Get(bool& result, const QString& settingsKey) + { + return m_settingsRegistry->Get(result, settingsKey.toStdString().c_str()); + } + + bool Settings::Set(const QString& settingsKey, const QString& settingsValue) + { + bool success = false; + + success = m_settingsRegistry->Set(settingsKey.toStdString().c_str(), settingsValue.toStdString().c_str()); + if (m_saveToDisk) + { + Save(); + } + + return success; + } + + bool Settings::Set(const QString& settingsKey, bool settingsValue) + { + bool success = false; + + success = m_settingsRegistry->Set(settingsKey.toStdString().c_str(), settingsValue); + if (m_saveToDisk) + { + Save(); + } + + return success; + } + + bool Settings::Remove(const QString& settingsKey) + { + bool success = false; + + success = m_settingsRegistry->Remove(settingsKey.toStdString().c_str()); + if (m_saveToDisk) + { + Save(); + } + + return success; + } + + bool Settings::Copy(const QString& settingsKeyOrig, const QString& settingsKeyDest, bool removeOrig) + { + bool success = false; + AZStd::string settingsValue; + + success = m_settingsRegistry->Get(settingsValue, settingsKeyOrig.toStdString().c_str()); + + if (success) + { + success = m_settingsRegistry->Set(settingsKeyDest.toStdString().c_str(), settingsValue); + if (success) + { + if (removeOrig) + { + success = m_settingsRegistry->Remove(settingsKeyOrig.toStdString().c_str()); + } + if (m_saveToDisk) + { + Save(); + } + } + } + + return success; + } + + QString Settings::GetProjectKey(const ProjectInfo& projectInfo) + { + return QString("%1/Projects/%2/%3").arg(ProjectManagerKeyPrefix, projectInfo.m_id, projectInfo.m_projectName); + } + + bool Settings::GetBuiltSuccessfullyPaths(AZStd::set& result) + { + return m_settingsRegistry->GetObject>(result, ProjectsBuiltSuccessfullyKey); + } + + bool Settings::GetProjectBuiltSuccessfully(bool& result, const ProjectInfo& projectInfo) + { + AZStd::set builtPathsResult; + bool success = GetBuiltSuccessfullyPaths(builtPathsResult); + + // Check if buildPath is listed as successfully built + AZStd::string projectPath = projectInfo.m_path.toStdString().c_str(); + if (builtPathsResult.contains(projectPath)) + { + result = true; + } + // No project built statuses known + else + { + result = false; + } + + return success; + } + + bool Settings::SetProjectBuiltSuccessfully(const ProjectInfo& projectInfo, bool successfullyBuilt) + { + AZStd::set builtPathsResult; + bool success = GetBuiltSuccessfullyPaths(builtPathsResult); + + AZStd::string projectPath = projectInfo.m_path.toStdString().c_str(); + if (successfullyBuilt) + { + //Add successfully built path to set + builtPathsResult.insert(projectPath); + } + else + { + // Remove unsuccessfully built path from set + builtPathsResult.erase(projectPath); + } + + success = m_settingsRegistry->SetObject>(ProjectsBuiltSuccessfullyKey, builtPathsResult); + if (m_saveToDisk) + { + Save(); + } + + return success; + } + +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/Settings.h b/Code/Tools/ProjectManager/Source/Settings.h new file mode 100644 index 0000000000..f30715dba9 --- /dev/null +++ b/Code/Tools/ProjectManager/Source/Settings.h @@ -0,0 +1,50 @@ +/* + * 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 + * + */ + +#pragma once + +#include + +#include + +namespace AZ +{ + class SettingsRegistryInterface; +} + +namespace O3DE::ProjectManager +{ + class Settings + : public SettingsInterface::Registrar + { + public: + Settings(bool saveToDisk = true); + + bool IsInitialized() override; + + bool Get(QString& result, const QString& settingsKey) override; + bool Get(bool& result, const QString& settingsKey) override; + bool Set(const QString& settingsKey, const QString& settingsValue) override; + bool Set(const QString& settingsKey, bool settingsValue) override; + bool Remove(const QString& settingsKey) override; + bool Copy(const QString& settingsKeyOrig, const QString& settingsKeyDest, bool removeOrig = false) override; + + QString GetProjectKey(const ProjectInfo& projectInfo) override; + + bool GetProjectBuiltSuccessfully(bool& result, const ProjectInfo& projectInfo) override; + bool SetProjectBuiltSuccessfully(const ProjectInfo& projectInfo, bool successfullyBuilt) override; + + private: + bool Save(); + + bool GetBuiltSuccessfullyPaths(AZStd::set& result); + + bool m_saveToDisk; + AZ::SettingsRegistryInterface* m_settingsRegistry = nullptr; + }; +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/SettingsInterface.h b/Code/Tools/ProjectManager/Source/SettingsInterface.h new file mode 100644 index 0000000000..a106dedefd --- /dev/null +++ b/Code/Tools/ProjectManager/Source/SettingsInterface.h @@ -0,0 +1,57 @@ +/* + * 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 + * + */ +#pragma once + +#include + +#include +#include + +namespace O3DE::ProjectManager +{ + //! Interface used to interact with the settings functions + class ISettings + { + public: + AZ_RTTI(O3DE::ProjectManager::ISettings, "{95D87D95-0E04-462F-8B0B-ED15C0A9F090}"); + AZ_DISABLE_COPY_MOVE(ISettings); + + static constexpr char ProjectManagerKeyPrefix[] = "/O3DE/ProjectManager"; + static constexpr char ExternalLinkWarningKey[] = "/O3DE/ProjectManager/SkipExternalLinkWarning"; + static constexpr char ProjectsBuiltSuccessfullyKey[] = "/O3DE/ProjectManager/SkipExternalLinkWarning"; + + ISettings() = default; + virtual ~ISettings() = default; + + /** + * This checks if Settings is in a usable state + * @return true Settings is ready to be used, false otherwise + */ + virtual bool IsInitialized() = 0; + + /** + * Get info about a Gem. + * @param path The absolute path to the Gem + * @param projectPath (Optional) The absolute path to the Gem project + * @return an outcome with GemInfo on success + */ + virtual bool Get(QString& result, const QString& settingsKey) = 0; + virtual bool Get(bool& result, const QString& settingsKey) = 0; + virtual bool Set(const QString& settingsKey, const QString& settingsValue) = 0; + virtual bool Set(const QString& settingsKey, bool settingsValue) = 0; + virtual bool Remove(const QString& settingsKey) = 0; + virtual bool Copy(const QString& settingsKeyOrig, const QString& settingsKeyDest, bool removeOrig = false) = 0; + + virtual QString GetProjectKey(const ProjectInfo& projectInfo) = 0; + + virtual bool GetProjectBuiltSuccessfully(bool& result, const ProjectInfo& projectInfo) = 0; + virtual bool SetProjectBuiltSuccessfully(const ProjectInfo& projectInfo, bool successfullyBuilt) = 0; + }; + + using SettingsInterface = AZ::Interface; +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/UpdateProjectCtrl.cpp b/Code/Tools/ProjectManager/Source/UpdateProjectCtrl.cpp index 71dae91a81..0e5f6f3ca5 100644 --- a/Code/Tools/ProjectManager/Source/UpdateProjectCtrl.cpp +++ b/Code/Tools/ProjectManager/Source/UpdateProjectCtrl.cpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include @@ -307,8 +307,9 @@ namespace O3DE::ProjectManager { // Remove project build successfully paths for both old and new project names // because a full rebuild is required when moving projects - PMSettings::SetProjectBuiltSuccessfully(m_projectInfo, false); - PMSettings::SetProjectBuiltSuccessfully(newProjectSettings, false); + auto settings = SettingsInterface::Get(); + settings->SetProjectBuiltSuccessfully(m_projectInfo, false); + settings->SetProjectBuiltSuccessfully(newProjectSettings, false); } if (!newProjectSettings.m_newPreviewImagePath.isEmpty()) diff --git a/Code/Tools/ProjectManager/project_manager_files.cmake b/Code/Tools/ProjectManager/project_manager_files.cmake index 468e8dcbc5..915b1a072f 100644 --- a/Code/Tools/ProjectManager/project_manager_files.cmake +++ b/Code/Tools/ProjectManager/project_manager_files.cmake @@ -58,8 +58,6 @@ set(FILES Source/CreateProjectCtrl.cpp Source/UpdateProjectCtrl.h Source/UpdateProjectCtrl.cpp - Source/ProjectManagerSettings.h - Source/ProjectManagerSettings.cpp Source/ProjectsScreen.h Source/ProjectsScreen.cpp Source/ProjectSettingsScreen.h @@ -72,6 +70,9 @@ set(FILES Source/ProjectButtonWidget.cpp Source/ScreenHeaderWidget.h Source/ScreenHeaderWidget.cpp + Source/Settings.h + Source/Settings.cpp + Source/SettingsInterface.h Source/LinkWidget.h Source/LinkWidget.cpp Source/TagWidget.h diff --git a/Code/Tools/ProjectManager/project_manager_tests_files.cmake b/Code/Tools/ProjectManager/project_manager_tests_files.cmake index df9a0070a1..012a27d13a 100644 --- a/Code/Tools/ProjectManager/project_manager_tests_files.cmake +++ b/Code/Tools/ProjectManager/project_manager_tests_files.cmake @@ -11,7 +11,7 @@ set(FILES Resources/ProjectManager.qss tests/ApplicationTests.cpp tests/GemCatalogTests.cpp - tests/ProjectManagerSettingsTests.cpp + tests/SettingsTests.cpp tests/PythonBindingsTests.cpp tests/main.cpp tests/UtilsTests.cpp diff --git a/Code/Tools/ProjectManager/tests/ProjectManagerSettingsTests.cpp b/Code/Tools/ProjectManager/tests/SettingsTests.cpp similarity index 57% rename from Code/Tools/ProjectManager/tests/ProjectManagerSettingsTests.cpp rename to Code/Tools/ProjectManager/tests/SettingsTests.cpp index ba0cebd035..6ced8ddc8e 100644 --- a/Code/Tools/ProjectManager/tests/ProjectManagerSettingsTests.cpp +++ b/Code/Tools/ProjectManager/tests/SettingsTests.cpp @@ -13,15 +13,15 @@ #include #include -#include +#include namespace O3DE::ProjectManager { - class ProjectManagerSettingsTests + class SettingsTests : public ::UnitTest::ScopedAllocatorSetupFixture { public: - ~ProjectManagerSettingsTests() override = default; + ~SettingsTests() override = default; void SetUp() override { UnitTest::ScopedAllocatorSetupFixture::SetUp(); @@ -45,11 +45,15 @@ namespace O3DE::ProjectManager m_serializeContext->RegisterGenericType>(); + m_settings = AZStd::make_unique(/*saveToDisk*/ false); + m_projectInfo.m_path = "Z:/ProjectTestPath"; } void TearDown() override { + m_settings.reset(); + m_registrationContext->EnableRemoveReflection(); AZ::JsonSystemComponent::Reflect(m_registrationContext.get()); m_registrationContext->DisableRemoveReflection(); @@ -70,6 +74,7 @@ namespace O3DE::ProjectManager } protected: + AZStd::unique_ptr m_settings; const QString m_settingsPath = "/Testing/TestKey"; const QString m_newSettingsPath = "/Testing/NewTestKey"; ProjectInfo m_projectInfo; @@ -81,105 +86,110 @@ namespace O3DE::ProjectManager AZStd::unique_ptr m_registrationContext; }; - TEST_F(ProjectManagerSettingsTests, PMSettings_GetUnsetPathBool_ReturnsFalse) + TEST_F(SettingsTests, Settings_IsIntialized_Success) + { + EXPECT_TRUE(m_settings->IsInitialized()); + } + + TEST_F(SettingsTests, Settings_GetUnsetPathBool_ReturnsFalse) { bool settingsResult = false; - EXPECT_FALSE(PMSettings::GetProjectManagerKey(settingsResult, m_settingsPath)); + EXPECT_FALSE(m_settings->Get(settingsResult, m_settingsPath)); EXPECT_FALSE(settingsResult); } - TEST_F(ProjectManagerSettingsTests, PMSettings_SetAndGetValueBool_Success) + TEST_F(SettingsTests, Settings_SetAndGetValueBool_Success) { bool settingsResult = false; - EXPECT_FALSE(PMSettings::GetProjectManagerKey(settingsResult, m_settingsPath)); + EXPECT_FALSE(m_settings->Get(settingsResult, m_settingsPath)); // Don't save to disk in test - EXPECT_TRUE(PMSettings::SetProjectManagerKey(m_settingsPath, true, /*saveToDisk*/ false)); + EXPECT_TRUE(m_settings->Set(m_settingsPath, true)); settingsResult = false; - EXPECT_TRUE(PMSettings::GetProjectManagerKey(settingsResult, m_settingsPath)); + EXPECT_TRUE(m_settings->Get(settingsResult, m_settingsPath)); EXPECT_TRUE(settingsResult); } - TEST_F(ProjectManagerSettingsTests, PMSettings_GetUnsetPathString_ReturnsFalse) + TEST_F(SettingsTests, Settings_GetUnsetPathString_ReturnsFalse) { QString settingsResult; - EXPECT_FALSE(PMSettings::GetProjectManagerKey(settingsResult, m_settingsPath)); + EXPECT_FALSE(m_settings->Get(settingsResult, m_settingsPath)); EXPECT_TRUE(settingsResult.isEmpty()); } - TEST_F(ProjectManagerSettingsTests, PMSettings_SetAndGetValueString_Success) + TEST_F(SettingsTests, Settings_SetAndGetValueString_Success) { QString settingsResult; - EXPECT_FALSE(PMSettings::GetProjectManagerKey(settingsResult, m_settingsPath)); + EXPECT_FALSE(m_settings->Get(settingsResult, m_settingsPath)); QString settingsValue = "TestValue"; // Don't save to disk in test - EXPECT_TRUE(PMSettings::SetProjectManagerKey(m_settingsPath, settingsValue, /*saveToDisk*/ false)); + EXPECT_TRUE(m_settings->Set(m_settingsPath, settingsValue)); - EXPECT_TRUE(PMSettings::GetProjectManagerKey(settingsResult, m_settingsPath)); + EXPECT_TRUE(m_settings->Get(settingsResult, m_settingsPath)); EXPECT_TRUE(settingsResult == settingsValue); } - TEST_F(ProjectManagerSettingsTests, PMSettings_CopyStringRemoveOriginal_SuccessAndRemovesOriginal) + TEST_F(SettingsTests, Settings_CopyStringRemoveOriginal_SuccessAndRemovesOriginal) { QString settingsResult; - EXPECT_FALSE(PMSettings::GetProjectManagerKey(settingsResult, m_newSettingsPath)); + EXPECT_FALSE(m_settings->Get(settingsResult, m_newSettingsPath)); QString settingsValue = "TestValue"; // Don't save to disk in test - EXPECT_TRUE(PMSettings::SetProjectManagerKey(m_settingsPath, settingsValue, /*saveToDisk*/ false)); + EXPECT_TRUE(m_settings->Set(m_settingsPath, settingsValue)); - EXPECT_TRUE(PMSettings::CopyProjectManagerKeyString(m_settingsPath, m_newSettingsPath, /*removeOrig*/ true, /*saveToDisk*/ false)); + EXPECT_TRUE(m_settings->Copy(m_settingsPath, m_newSettingsPath, /*removeOrig*/ true)); // Check that old path value is removed - EXPECT_FALSE(PMSettings::GetProjectManagerKey(settingsResult, m_settingsPath)); + EXPECT_FALSE(m_settings->Get(settingsResult, m_settingsPath)); - EXPECT_TRUE(PMSettings::GetProjectManagerKey(settingsResult, m_newSettingsPath)); + EXPECT_TRUE(m_settings->Get(settingsResult, m_newSettingsPath)); EXPECT_TRUE(settingsResult == settingsValue); } - TEST_F(ProjectManagerSettingsTests, PMSettings_RemoveProjectManagerKey_RemovesKey) + TEST_F(SettingsTests, Settings_RemoveProjectManagerKey_RemovesKey) { QString settingsResult; - EXPECT_FALSE(PMSettings::GetProjectManagerKey(settingsResult, m_settingsPath)); + EXPECT_FALSE(m_settings->Get(settingsResult, m_settingsPath)); QString settingsValue = "TestValue"; // Don't save to disk in test - EXPECT_TRUE(PMSettings::SetProjectManagerKey(m_settingsPath, settingsValue, /*saveToDisk*/ false)); - EXPECT_TRUE(PMSettings::GetProjectManagerKey(settingsResult, m_settingsPath)); + EXPECT_TRUE(m_settings->Set(m_settingsPath, settingsValue)); + EXPECT_TRUE(m_settings->Get(settingsResult, m_settingsPath)); - EXPECT_TRUE(PMSettings::RemoveProjectManagerKey(m_settingsPath, /*saveToDisk*/ false)); - EXPECT_FALSE(PMSettings::GetProjectManagerKey(settingsResult, m_settingsPath)); + EXPECT_TRUE(m_settings->Remove(m_settingsPath)); + EXPECT_FALSE(m_settings->Get(settingsResult, m_settingsPath)); } - TEST_F(ProjectManagerSettingsTests, PMSettings_GetUnsetBuildPath_ReturnsFalse) + TEST_F(SettingsTests, Settings_GetUnsetBuildPath_ReturnsFalse) { bool buildResult = true; - EXPECT_FALSE(PMSettings::GetProjectBuiltSuccessfully(buildResult, m_projectInfo)); + EXPECT_FALSE(m_settings->GetProjectBuiltSuccessfully(buildResult, m_projectInfo)); EXPECT_FALSE(buildResult); } - TEST_F(ProjectManagerSettingsTests, PMSettings_SetProjectBuiltSuccessfully_ReturnsTrue) + TEST_F(SettingsTests, Settings_SetProjectBuiltSuccessfully_ReturnsTrue) { // Don't save to disk in test - EXPECT_TRUE(PMSettings::SetProjectBuiltSuccessfully(m_projectInfo, true, /*saveToDisk*/ false)); + EXPECT_TRUE(m_settings->SetProjectBuiltSuccessfully(m_projectInfo, true)); bool buildResult = false; - EXPECT_TRUE(PMSettings::GetProjectBuiltSuccessfully(buildResult, m_projectInfo)); + EXPECT_TRUE(m_settings->GetProjectBuiltSuccessfully(buildResult, m_projectInfo)); EXPECT_TRUE(buildResult); } - TEST_F(ProjectManagerSettingsTests, PMSettings_SetProjectBuiltUnsuccessfully_ReturnsFalse) + TEST_F(SettingsTests, Settings_SetProjectBuiltUnsuccessfully_ReturnsFalse) { // Don't save to disk in test - EXPECT_TRUE(PMSettings::SetProjectBuiltSuccessfully(m_projectInfo, false, /*saveToDisk*/ false)); + EXPECT_TRUE(m_settings->SetProjectBuiltSuccessfully(m_projectInfo, false)); bool buildResult = false; - EXPECT_TRUE(PMSettings::GetProjectBuiltSuccessfully(buildResult, m_projectInfo)); + EXPECT_TRUE(m_settings->GetProjectBuiltSuccessfully(buildResult, m_projectInfo)); EXPECT_FALSE(buildResult); } } From c632fadb8f6fcdfa6c16ee04b43d0b4994eec7c9 Mon Sep 17 00:00:00 2001 From: nggieber <52797929+AMZN-nggieber@users.noreply.github.com> Date: Thu, 9 Dec 2021 10:25:04 -0800 Subject: [PATCH 10/70] Remove Project ID field from New Project settings Signed-off-by: nggieber <52797929+AMZN-nggieber@users.noreply.github.com> --- .../Source/NewProjectSettingsScreen.cpp | 10 ---- .../Source/NewProjectSettingsScreen.h | 1 - .../Source/ProjectSettingsScreen.cpp | 25 +------- .../Source/ProjectSettingsScreen.h | 3 - .../ProjectManager/Source/PythonBindings.cpp | 20 +------ .../ProjectManager/Source/SettingsInterface.h | 58 +++++++++++++++++-- .../Source/UpdateProjectSettingsScreen.cpp | 24 +++++++- .../Source/UpdateProjectSettingsScreen.h | 3 + 8 files changed, 83 insertions(+), 61 deletions(-) diff --git a/Code/Tools/ProjectManager/Source/NewProjectSettingsScreen.cpp b/Code/Tools/ProjectManager/Source/NewProjectSettingsScreen.cpp index 4c306fc715..f1f56993ca 100644 --- a/Code/Tools/ProjectManager/Source/NewProjectSettingsScreen.cpp +++ b/Code/Tools/ProjectManager/Source/NewProjectSettingsScreen.cpp @@ -43,11 +43,9 @@ namespace O3DE::ProjectManager { const QString defaultName = GetDefaultProjectName(); const QString defaultPath = QDir::toNativeSeparators(GetDefaultProjectPath() + "/" + defaultName); - const QString randomUuid = GenerateNewProjectId(); m_projectName->lineEdit()->setText(defaultName); m_projectPath->lineEdit()->setText(defaultPath); - m_projectId->lineEdit()->setText(randomUuid); // if we don't use a QFrame we cannot "contain" the widgets inside and move them around // as a group @@ -177,14 +175,6 @@ namespace O3DE::ProjectManager return QDir::toNativeSeparators(GetDefaultProjectPath() + "/" + projectName); } - QString NewProjectSettingsScreen::GenerateNewProjectId() - { - AZStd::string uuid; - AZ::Uuid::CreateRandom().ToString(uuid); - - return QString(uuid.c_str()); - } - ProjectManagerScreen NewProjectSettingsScreen::GetScreenEnum() { return ProjectManagerScreen::NewProjectSettings; diff --git a/Code/Tools/ProjectManager/Source/NewProjectSettingsScreen.h b/Code/Tools/ProjectManager/Source/NewProjectSettingsScreen.h index cfb215ba0c..42c47cb1ff 100644 --- a/Code/Tools/ProjectManager/Source/NewProjectSettingsScreen.h +++ b/Code/Tools/ProjectManager/Source/NewProjectSettingsScreen.h @@ -47,7 +47,6 @@ namespace O3DE::ProjectManager private: QString GetDefaultProjectName(); QString GetDefaultProjectPath(); - QString GenerateNewProjectId(); QString GetProjectAutoPath(); QFrame* CreateTemplateDetails(int margin); void UpdateTemplateDetails(const ProjectTemplateInfo& templateInfo); diff --git a/Code/Tools/ProjectManager/Source/ProjectSettingsScreen.cpp b/Code/Tools/ProjectManager/Source/ProjectSettingsScreen.cpp index cf15cb5bbc..45023d7f80 100644 --- a/Code/Tools/ProjectManager/Source/ProjectSettingsScreen.cpp +++ b/Code/Tools/ProjectManager/Source/ProjectSettingsScreen.cpp @@ -60,10 +60,6 @@ namespace O3DE::ProjectManager connect(m_projectPath->lineEdit(), &QLineEdit::textChanged, this, &ProjectSettingsScreen::OnProjectPathUpdated); m_verticalLayout->addWidget(m_projectPath); - m_projectId = new FormLineEditWidget(tr("Project ID"), "", this); - connect(m_projectId->lineEdit(), &QLineEdit::textChanged, this, &ProjectSettingsScreen::OnProjectIdUpdated); - m_verticalLayout->addWidget(m_projectId); - projectSettingsFrame->setLayout(m_verticalLayout); m_horizontalLayout->addWidget(projectSettingsFrame); @@ -98,7 +94,6 @@ namespace O3DE::ProjectManager // currently we don't have separate fields for changing the project name and display name projectInfo.m_displayName = projectInfo.m_projectName; projectInfo.m_path = m_projectPath->lineEdit()->text(); - projectInfo.m_id = m_projectId->lineEdit()->text(); return projectInfo; } @@ -147,19 +142,6 @@ namespace O3DE::ProjectManager return projectPathIsValid; } - bool ProjectSettingsScreen::ValidateProjectId() - { - bool projectIdIsValid = true; - if (m_projectId->lineEdit()->text().isEmpty()) - { - projectIdIsValid = false; - m_projectId->setErrorLabelText(tr("Project ID cannot be empty.")); - } - - m_projectId->setErrorLabelVisible(!projectIdIsValid); - return projectIdIsValid; - } - void ProjectSettingsScreen::OnProjectNameUpdated() { ValidateProjectName(); @@ -170,13 +152,8 @@ namespace O3DE::ProjectManager ValidateProjectName() && ValidateProjectPath(); } - void ProjectSettingsScreen::OnProjectIdUpdated() - { - ValidateProjectId(); - } - bool ProjectSettingsScreen::Validate() { - return ValidateProjectName() && ValidateProjectPath() && ValidateProjectId(); + return ValidateProjectName() && ValidateProjectPath(); } } // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/ProjectSettingsScreen.h b/Code/Tools/ProjectManager/Source/ProjectSettingsScreen.h index 928cde833e..752e286ce1 100644 --- a/Code/Tools/ProjectManager/Source/ProjectSettingsScreen.h +++ b/Code/Tools/ProjectManager/Source/ProjectSettingsScreen.h @@ -35,12 +35,10 @@ namespace O3DE::ProjectManager protected slots: virtual void OnProjectNameUpdated(); virtual void OnProjectPathUpdated(); - virtual void OnProjectIdUpdated(); protected: bool ValidateProjectName(); virtual bool ValidateProjectPath(); - bool ValidateProjectId(); QString GetDefaultProjectPath(); @@ -48,7 +46,6 @@ namespace O3DE::ProjectManager QVBoxLayout* m_verticalLayout; FormLineEditWidget* m_projectName; FormBrowseEditWidget* m_projectPath; - FormLineEditWidget* m_projectId; }; } // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/PythonBindings.cpp b/Code/Tools/ProjectManager/Source/PythonBindings.cpp index 8d11028af6..2ae0e3450c 100644 --- a/Code/Tools/ProjectManager/Source/PythonBindings.cpp +++ b/Code/Tools/ProjectManager/Source/PythonBindings.cpp @@ -688,24 +688,8 @@ namespace O3DE::ProjectManager auto createProjectResult = m_engineTemplate.attr("create_project")( projectPath, QString_To_Py_String(projectInfo.m_projectName), // project_path - QString_To_Py_Path(projectTemplatePath), // template_path - pybind11::none(), // template_name - pybind11::none(), // project_restricted_path - pybind11::none(), // project_restricted_name - pybind11::none(), // template_restricted_path - pybind11::none(), // template_restricted_name - pybind11::none(), // project_restricted_platform_relative_path - pybind11::none(), // template_restricted_platform_relative_path - pybind11::none(), // keep_restricted_in_project - pybind11::none(), // keep_license_text - pybind11::none(), // replace - pybind11::none(), // force - pybind11::none(), // no_register - pybind11::none(), // system_component_class_id - pybind11::none(), // editor_system_component_class_id - pybind11::none(), // module_id - QString_To_Py_String(projectInfo.m_id) // project_id - ); + QString_To_Py_Path(projectTemplatePath) // template_path + ); if (createProjectResult.cast() == 0) { createdProjectInfo = ProjectInfoFromPath(projectPath); diff --git a/Code/Tools/ProjectManager/Source/SettingsInterface.h b/Code/Tools/ProjectManager/Source/SettingsInterface.h index a106dedefd..e345886b9f 100644 --- a/Code/Tools/ProjectManager/Source/SettingsInterface.h +++ b/Code/Tools/ProjectManager/Source/SettingsInterface.h @@ -35,21 +35,71 @@ namespace O3DE::ProjectManager virtual bool IsInitialized() = 0; /** - * Get info about a Gem. - * @param path The absolute path to the Gem - * @param projectPath (Optional) The absolute path to the Gem project - * @return an outcome with GemInfo on success + * Get the value for a string settings key + * @param result Store string result in this variable + * @param settingsKey The key to get the value in + * @return true if all calls to settings registry were successful */ virtual bool Get(QString& result, const QString& settingsKey) = 0; + /** + * Get the value for a bool settings key + * @param result Store bool result in this variable + * @param settingsKey The key to get the value in + * @return true if all calls to settings registry were successful + */ virtual bool Get(bool& result, const QString& settingsKey) = 0; + + /** + * Set the value for a string settings key + * @param settingsKey The key to set the value in + * @param settingsValue String value to set key to + * @return true if all calls to settings registry were successful + */ virtual bool Set(const QString& settingsKey, const QString& settingsValue) = 0; + /** + * Set the value for a bool settings key + * @param settingsKey The key to set the value in + * @param settingsValue Bool value to set key to + * @return true if all calls to settings registry were successful + */ virtual bool Set(const QString& settingsKey, bool settingsValue) = 0; + + /** + * Remove settings key + * @param settingsKey The key to remove + * @return true if all calls to settings registry were successful + */ virtual bool Remove(const QString& settingsKey) = 0; + + /** + * Copy the string settings value from one key to another + * @param settingsKeyOrig The original key to copy from + * @param settingsKeyDest The destination key to copy to + * @param removeOrig(Optional) Delete the original key if true + * @return true if all calls to settings registry were successful + */ virtual bool Copy(const QString& settingsKeyOrig, const QString& settingsKeyDest, bool removeOrig = false) = 0; + /** + * Generate prefix for project settings key + * @param projectInfo Project for settings key + * @return QString Prefix for project specific settings key + */ virtual QString GetProjectKey(const ProjectInfo& projectInfo) = 0; + /** + * Get the build status for a project + * @param result Store bool build status in this variable + * @param projectInfo Project to check built status for + * @return true if all calls to settings registry were successful + */ virtual bool GetProjectBuiltSuccessfully(bool& result, const ProjectInfo& projectInfo) = 0; + /** + * Set the build status for a project + * @param projectInfo Project to set built status for + * @param successfullyBuilt Bool value to set build status to + * @return true if all calls to settings registry were successful + */ virtual bool SetProjectBuiltSuccessfully(const ProjectInfo& projectInfo, bool successfullyBuilt) = 0; }; diff --git a/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.cpp b/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.cpp index 7c8f981f59..8ebda6a823 100644 --- a/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.cpp +++ b/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.cpp @@ -45,6 +45,10 @@ namespace O3DE::ProjectManager previewExtrasLayout->addWidget(m_projectPreviewImage); m_verticalLayout->addLayout(previewExtrasLayout); + + m_projectId = new FormLineEditWidget(tr("Project ID"), "", this); + connect(m_projectId->lineEdit(), &QLineEdit::textChanged, this, &UpdateProjectSettingsScreen::OnProjectIdUpdated); + m_verticalLayout->addWidget(m_projectId); } ProjectManagerScreen UpdateProjectSettingsScreen::GetScreenEnum() @@ -90,7 +94,7 @@ namespace O3DE::ProjectManager bool UpdateProjectSettingsScreen::Validate() { - return ProjectSettingsScreen::Validate() && ValidateProjectPreview(); + return ProjectSettingsScreen::Validate() && ValidateProjectPreview() && ValidateProjectId(); } void UpdateProjectSettingsScreen::ResetProjectPreviewPath() @@ -108,6 +112,11 @@ namespace O3DE::ProjectManager QPixmap(m_projectPreview->lineEdit()->text()).scaled(m_projectPreviewImage->size(), Qt::KeepAspectRatioByExpanding)); } + void UpdateProjectSettingsScreen::OnProjectIdUpdated() + { + ValidateProjectId(); + } + bool UpdateProjectSettingsScreen::ValidateProjectPath() { bool projectPathIsValid = true; @@ -157,4 +166,17 @@ namespace O3DE::ProjectManager return projectPreviewIsValid; } + bool UpdateProjectSettingsScreen::ValidateProjectId() + { + bool projectIdIsValid = true; + if (m_projectId->lineEdit()->text().isEmpty()) + { + projectIdIsValid = false; + m_projectId->setErrorLabelText(tr("Project ID cannot be empty.")); + } + + m_projectId->setErrorLabelVisible(!projectIdIsValid); + return projectIdIsValid; + } + } // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.h b/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.h index 22d7794de4..ba1a0a5794 100644 --- a/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.h +++ b/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.h @@ -33,13 +33,16 @@ namespace O3DE::ProjectManager public slots: void UpdateProjectPreviewPath(); void PreviewPathChanged(); + void OnProjectIdUpdated(); protected: bool ValidateProjectPath() override; virtual bool ValidateProjectPreview(); + bool ValidateProjectId(); FormBrowseEditWidget* m_projectPreview; QLabel* m_projectPreviewImage; + FormLineEditWidget* m_projectId; ProjectInfo m_projectInfo; bool m_userChangedPreview; //! Did the user change the project preview path From c563b5427754f62ebb555984c1e6c49b1d8a38f3 Mon Sep 17 00:00:00 2001 From: lsemp3d <58790905+lsemp3d@users.noreply.github.com> Date: Thu, 9 Dec 2021 13:04:15 -0800 Subject: [PATCH 11/70] Fixed incorrect condition that led to badly named slots Signed-off-by: lsemp3d <58790905+lsemp3d@users.noreply.github.com> --- .../NodeDescriptors/EBusHandlerEventNodeDescriptorComponent.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/ScriptCanvas/Code/Editor/GraphCanvas/Components/NodeDescriptors/EBusHandlerEventNodeDescriptorComponent.cpp b/Gems/ScriptCanvas/Code/Editor/GraphCanvas/Components/NodeDescriptors/EBusHandlerEventNodeDescriptorComponent.cpp index e1450c0aa8..dd7986a212 100644 --- a/Gems/ScriptCanvas/Code/Editor/GraphCanvas/Components/NodeDescriptors/EBusHandlerEventNodeDescriptorComponent.cpp +++ b/Gems/ScriptCanvas/Code/Editor/GraphCanvas/Components/NodeDescriptors/EBusHandlerEventNodeDescriptorComponent.cpp @@ -219,7 +219,7 @@ namespace ScriptCanvasEditor if (scriptCanvasSlot && scriptCanvasSlot->IsVisible()) { - int& index = (scriptCanvasSlot->IsData() && scriptCanvasSlot->IsOutput()) ? paramIndex : outputIndex; + int& index = (scriptCanvasSlot->IsData() && scriptCanvasSlot->IsOutput()) ? outputIndex : paramIndex; auto graphCanvasSlotId = Nodes::DisplayScriptCanvasSlot(GetEntityId(), (*scriptCanvasSlot), index); From 5641bcd5f1ebddcbc0ab4536da92b1805b577dd5 Mon Sep 17 00:00:00 2001 From: nggieber <52797929+AMZN-nggieber@users.noreply.github.com> Date: Thu, 9 Dec 2021 14:56:50 -0800 Subject: [PATCH 12/70] Update Update Project Settings UI to show advanced settings and move project preview to right side panel Signed-off-by: nggieber <52797929+AMZN-nggieber@users.noreply.github.com> --- .../Resources/ProjectManager.qss | 13 +++- .../ProjectManager/Source/SettingsInterface.h | 2 +- .../Source/UpdateProjectSettingsScreen.cpp | 76 ++++++++++++++++--- .../Source/UpdateProjectSettingsScreen.h | 7 ++ 4 files changed, 85 insertions(+), 13 deletions(-) diff --git a/Code/Tools/ProjectManager/Resources/ProjectManager.qss b/Code/Tools/ProjectManager/Resources/ProjectManager.qss index 1fc808b72c..fba3a77593 100644 --- a/Code/Tools/ProjectManager/Resources/ProjectManager.qss +++ b/Code/Tools/ProjectManager/Resources/ProjectManager.qss @@ -250,9 +250,6 @@ QTabBar::tab:focus { margin-top:30px; } -#projectPreviewLabel { - margin: 10px 0 5px 0; -} #projectTemplate { margin: 25px 0 0 50px; @@ -329,6 +326,16 @@ QTabBar::tab:focus { border:none; } +#projectSettingsSectionTitle +{ + font-size:18px; +} + +#projectSmallInfoLabel +{ + font-size:10px; +} + #projectSettingsTab::tab-bar { left: 60px; } diff --git a/Code/Tools/ProjectManager/Source/SettingsInterface.h b/Code/Tools/ProjectManager/Source/SettingsInterface.h index e345886b9f..e407767424 100644 --- a/Code/Tools/ProjectManager/Source/SettingsInterface.h +++ b/Code/Tools/ProjectManager/Source/SettingsInterface.h @@ -23,7 +23,7 @@ namespace O3DE::ProjectManager static constexpr char ProjectManagerKeyPrefix[] = "/O3DE/ProjectManager"; static constexpr char ExternalLinkWarningKey[] = "/O3DE/ProjectManager/SkipExternalLinkWarning"; - static constexpr char ProjectsBuiltSuccessfullyKey[] = "/O3DE/ProjectManager/SkipExternalLinkWarning"; + static constexpr char ProjectsBuiltSuccessfullyKey[] = "/O3DE/ProjectManager/SuccessfulBuildPaths"; ISettings() = default; virtual ~ISettings() = default; diff --git a/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.cpp b/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.cpp index 8ebda6a823..e10f3a0590 100644 --- a/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.cpp +++ b/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.cpp @@ -16,6 +16,7 @@ #include #include #include +#include namespace O3DE::ProjectManager { @@ -31,12 +32,10 @@ namespace O3DE::ProjectManager m_verticalLayout->addWidget(m_projectPreview); QVBoxLayout* previewExtrasLayout = new QVBoxLayout(this); - previewExtrasLayout->setAlignment(Qt::AlignLeft); - previewExtrasLayout->setContentsMargins(50, 0, 0, 0); + previewExtrasLayout->setAlignment(Qt::AlignTop); + previewExtrasLayout->setContentsMargins(30, 45, 30, 0); - QLabel* projectPreviewLabel = new QLabel(tr("Select an image (PNG). Minimum %1 x %2 pixels.") - .arg(QString::number(ProjectPreviewImageWidth), QString::number(ProjectPreviewImageHeight))); - projectPreviewLabel->setObjectName("projectPreviewLabel"); + QLabel* projectPreviewLabel = new QLabel(tr("Project Preview")); previewExtrasLayout->addWidget(projectPreviewLabel); m_projectPreviewImage = new QLabel(this); @@ -44,11 +43,56 @@ namespace O3DE::ProjectManager m_projectPreviewImage->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); previewExtrasLayout->addWidget(m_projectPreviewImage); - m_verticalLayout->addLayout(previewExtrasLayout); + QLabel* projectPreviewInfoLabel = new QLabel(tr("Select an image (PNG). Minimum %1 x %2 pixels.") + .arg(QString::number(ProjectPreviewImageWidth), QString::number(ProjectPreviewImageHeight))); + projectPreviewInfoLabel->setObjectName("projectSmallInfoLabel"); + projectPreviewInfoLabel->setWordWrap(true); + previewExtrasLayout->addWidget(projectPreviewInfoLabel); - m_projectId = new FormLineEditWidget(tr("Project ID"), "", this); - connect(m_projectId->lineEdit(), &QLineEdit::textChanged, this, &UpdateProjectSettingsScreen::OnProjectIdUpdated); - m_verticalLayout->addWidget(m_projectId); + m_horizontalLayout->addLayout(previewExtrasLayout); + + m_verticalLayout->addSpacing(10); + + // Collapse button + QHBoxLayout* advancedCollapseLayout = new QHBoxLayout(); + advancedCollapseLayout->setContentsMargins(50, 0, 0, 0); + + m_advancedSettingsCollapseButton = new QPushButton(); + m_advancedSettingsCollapseButton->setCheckable(true); + m_advancedSettingsCollapseButton->setChecked(true); + m_advancedSettingsCollapseButton->setFlat(true); + m_advancedSettingsCollapseButton->setFocusPolicy(Qt::NoFocus); + m_advancedSettingsCollapseButton->setFixedWidth(s_collapseButtonSize); + connect(m_advancedSettingsCollapseButton, &QPushButton::clicked, this, [=]() + { + UpdateAdvancedSettingsCollapseState(); + }); + advancedCollapseLayout->addWidget(m_advancedSettingsCollapseButton); + + // Category title + QLabel* advancedLabel = new QLabel("Advanced Settings"); + advancedLabel->setObjectName("p"); + advancedCollapseLayout->addWidget(advancedLabel); + m_verticalLayout->addLayout(advancedCollapseLayout); + + m_verticalLayout->addSpacing(5); + + // Everything in the advanced settings widget will be collapsed/uncollapsed + { + m_advancedSettingWidget = new QWidget(); + m_verticalLayout->addWidget(m_advancedSettingWidget); + + QVBoxLayout* advancedSettingsLayout = new QVBoxLayout(); + advancedSettingsLayout->setMargin(0); + advancedSettingsLayout->setAlignment(Qt::AlignTop); + m_advancedSettingWidget->setLayout(advancedSettingsLayout); + + m_projectId = new FormLineEditWidget(tr("Project ID"), "", this); + connect(m_projectId->lineEdit(), &QLineEdit::textChanged, this, &UpdateProjectSettingsScreen::OnProjectIdUpdated); + advancedSettingsLayout->addWidget(m_projectId); + } + + UpdateAdvancedSettingsCollapseState(); } ProjectManagerScreen UpdateProjectSettingsScreen::GetScreenEnum() @@ -179,4 +223,18 @@ namespace O3DE::ProjectManager return projectIdIsValid; } + void UpdateProjectSettingsScreen::UpdateAdvancedSettingsCollapseState() + { + if (m_advancedSettingsCollapseButton->isChecked()) + { + m_advancedSettingsCollapseButton->setIcon(QIcon(":/ArrowDownLine.svg")); + m_advancedSettingWidget->hide(); + } + else + { + m_advancedSettingsCollapseButton->setIcon(QIcon(":/ArrowUpLine.svg")); + m_advancedSettingWidget->show(); + } + } + } // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.h b/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.h index ba1a0a5794..40d1ccb9af 100644 --- a/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.h +++ b/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.h @@ -12,6 +12,7 @@ #endif QT_FORWARD_DECLARE_CLASS(QLabel) +QT_FORWARD_DECLARE_CLASS(QPushButton) namespace O3DE::ProjectManager { @@ -39,11 +40,17 @@ namespace O3DE::ProjectManager bool ValidateProjectPath() override; virtual bool ValidateProjectPreview(); bool ValidateProjectId(); + void UpdateAdvancedSettingsCollapseState(); + + inline constexpr static int s_collapseButtonSize = 24; FormBrowseEditWidget* m_projectPreview; QLabel* m_projectPreviewImage; FormLineEditWidget* m_projectId; + QPushButton* m_advancedSettingsCollapseButton = nullptr; + QWidget* m_advancedSettingWidget = nullptr; + ProjectInfo m_projectInfo; bool m_userChangedPreview; //! Did the user change the project preview path }; From 9f4895aaeadee149c391e977460464b20da2d83e Mon Sep 17 00:00:00 2001 From: nggieber <52797929+AMZN-nggieber@users.noreply.github.com> Date: Thu, 9 Dec 2021 15:30:32 -0800 Subject: [PATCH 13/70] Addressed remaining PR feedback Signed-off-by: nggieber <52797929+AMZN-nggieber@users.noreply.github.com> --- .../Resources/ProjectManager.qss | 1 - .../ProjectManager/Source/Application.cpp | 5 --- .../Source/ExternalLinkDialog.cpp | 3 +- .../ProjectManager/Source/LinkWidget.cpp | 3 +- Code/Tools/ProjectManager/Source/Settings.cpp | 43 ++++++++----------- Code/Tools/ProjectManager/Source/Settings.h | 3 +- .../ProjectManager/Source/SettingsInterface.h | 6 --- .../Source/UpdateProjectSettingsScreen.cpp | 4 +- .../ProjectManager/tests/SettingsTests.cpp | 11 ----- 9 files changed, 22 insertions(+), 57 deletions(-) diff --git a/Code/Tools/ProjectManager/Resources/ProjectManager.qss b/Code/Tools/ProjectManager/Resources/ProjectManager.qss index fba3a77593..3d100ec170 100644 --- a/Code/Tools/ProjectManager/Resources/ProjectManager.qss +++ b/Code/Tools/ProjectManager/Resources/ProjectManager.qss @@ -250,7 +250,6 @@ QTabBar::tab:focus { margin-top:30px; } - #projectTemplate { margin: 25px 0 0 50px; } diff --git a/Code/Tools/ProjectManager/Source/Application.cpp b/Code/Tools/ProjectManager/Source/Application.cpp index 8ce8075988..49706d515a 100644 --- a/Code/Tools/ProjectManager/Source/Application.cpp +++ b/Code/Tools/ProjectManager/Source/Application.cpp @@ -114,11 +114,6 @@ namespace O3DE::ProjectManager m_settings = AZStd::make_unique(); AZ_Assert(m_settings, "Failed to create Settings"); - if (!m_settings->IsInitialized()) - { - return false; - } - const AZ::CommandLine* commandLine = GetCommandLine(); AZ_Assert(commandLine, "Failed to get command line"); diff --git a/Code/Tools/ProjectManager/Source/ExternalLinkDialog.cpp b/Code/Tools/ProjectManager/Source/ExternalLinkDialog.cpp index eada467b6a..726f4e5119 100644 --- a/Code/Tools/ProjectManager/Source/ExternalLinkDialog.cpp +++ b/Code/Tools/ProjectManager/Source/ExternalLinkDialog.cpp @@ -85,7 +85,6 @@ namespace O3DE::ProjectManager void ExternalLinkDialog::SetSkipDialogSetting(bool state) { - auto settings = SettingsInterface::Get(); - settings->Set(QString(settings->ExternalLinkWarningKey), state); + SettingsInterface::Get()->Set(QString(ISettings::ExternalLinkWarningKey), state); } } // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/LinkWidget.cpp b/Code/Tools/ProjectManager/Source/LinkWidget.cpp index 7a940e135b..1872afe4be 100644 --- a/Code/Tools/ProjectManager/Source/LinkWidget.cpp +++ b/Code/Tools/ProjectManager/Source/LinkWidget.cpp @@ -31,8 +31,7 @@ namespace O3DE::ProjectManager { // Check if user request not to be shown external link warning dialog bool skipDialog = false; - auto settings = SettingsInterface::Get(); - settings->Get(skipDialog, QString(settings->ExternalLinkWarningKey)); + SettingsInterface::Get()->Get(skipDialog, QString(ISettings::ExternalLinkWarningKey)); if (!skipDialog) { diff --git a/Code/Tools/ProjectManager/Source/Settings.cpp b/Code/Tools/ProjectManager/Source/Settings.cpp index 50081fbff3..e6adc5069c 100644 --- a/Code/Tools/ProjectManager/Source/Settings.cpp +++ b/Code/Tools/ProjectManager/Source/Settings.cpp @@ -22,12 +22,6 @@ namespace O3DE::ProjectManager AZ_Assert(m_settingsRegistry, "Failed to create Settings"); } - bool Settings::IsInitialized() - { - // Settings intialized correctly if it successfuly got the SettingsRegistry - return m_settingsRegistry; - } - bool Settings::Save() { AZ::SettingsRegistryMergeUtils::DumperSettings dumperSettings; @@ -61,6 +55,18 @@ namespace O3DE::ProjectManager return saved; } + bool Settings::OnSettingsChanged() + { + if (m_saveToDisk) + { + return Save(); + } + else + { + return true; + } + } + bool Settings::Get(QString& result, const QString& settingsKey) { bool success = false; @@ -82,10 +88,7 @@ namespace O3DE::ProjectManager bool success = false; success = m_settingsRegistry->Set(settingsKey.toStdString().c_str(), settingsValue.toStdString().c_str()); - if (m_saveToDisk) - { - Save(); - } + OnSettingsChanged(); return success; } @@ -95,10 +98,7 @@ namespace O3DE::ProjectManager bool success = false; success = m_settingsRegistry->Set(settingsKey.toStdString().c_str(), settingsValue); - if (m_saveToDisk) - { - Save(); - } + OnSettingsChanged(); return success; } @@ -108,10 +108,7 @@ namespace O3DE::ProjectManager bool success = false; success = m_settingsRegistry->Remove(settingsKey.toStdString().c_str()); - if (m_saveToDisk) - { - Save(); - } + OnSettingsChanged(); return success; } @@ -132,10 +129,7 @@ namespace O3DE::ProjectManager { success = m_settingsRegistry->Remove(settingsKeyOrig.toStdString().c_str()); } - if (m_saveToDisk) - { - Save(); - } + OnSettingsChanged(); } } @@ -190,10 +184,7 @@ namespace O3DE::ProjectManager } success = m_settingsRegistry->SetObject>(ProjectsBuiltSuccessfullyKey, builtPathsResult); - if (m_saveToDisk) - { - Save(); - } + OnSettingsChanged(); return success; } diff --git a/Code/Tools/ProjectManager/Source/Settings.h b/Code/Tools/ProjectManager/Source/Settings.h index f30715dba9..fb6087358b 100644 --- a/Code/Tools/ProjectManager/Source/Settings.h +++ b/Code/Tools/ProjectManager/Source/Settings.h @@ -25,8 +25,6 @@ namespace O3DE::ProjectManager public: Settings(bool saveToDisk = true); - bool IsInitialized() override; - bool Get(QString& result, const QString& settingsKey) override; bool Get(bool& result, const QString& settingsKey) override; bool Set(const QString& settingsKey, const QString& settingsValue) override; @@ -41,6 +39,7 @@ namespace O3DE::ProjectManager private: bool Save(); + bool OnSettingsChanged(); bool GetBuiltSuccessfullyPaths(AZStd::set& result); diff --git a/Code/Tools/ProjectManager/Source/SettingsInterface.h b/Code/Tools/ProjectManager/Source/SettingsInterface.h index e407767424..da1363dee5 100644 --- a/Code/Tools/ProjectManager/Source/SettingsInterface.h +++ b/Code/Tools/ProjectManager/Source/SettingsInterface.h @@ -28,12 +28,6 @@ namespace O3DE::ProjectManager ISettings() = default; virtual ~ISettings() = default; - /** - * This checks if Settings is in a usable state - * @return true Settings is ready to be used, false otherwise - */ - virtual bool IsInitialized() = 0; - /** * Get the value for a string settings key * @param result Store string result in this variable diff --git a/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.cpp b/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.cpp index e10f3a0590..6589ee25e6 100644 --- a/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.cpp +++ b/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.cpp @@ -70,8 +70,8 @@ namespace O3DE::ProjectManager advancedCollapseLayout->addWidget(m_advancedSettingsCollapseButton); // Category title - QLabel* advancedLabel = new QLabel("Advanced Settings"); - advancedLabel->setObjectName("p"); + QLabel* advancedLabel = new QLabel(tr("Advanced Settings")); + advancedLabel->setObjectName("projectSettingsSectionTitle"); advancedCollapseLayout->addWidget(advancedLabel); m_verticalLayout->addLayout(advancedCollapseLayout); diff --git a/Code/Tools/ProjectManager/tests/SettingsTests.cpp b/Code/Tools/ProjectManager/tests/SettingsTests.cpp index 6ced8ddc8e..d994a59737 100644 --- a/Code/Tools/ProjectManager/tests/SettingsTests.cpp +++ b/Code/Tools/ProjectManager/tests/SettingsTests.cpp @@ -86,11 +86,6 @@ namespace O3DE::ProjectManager AZStd::unique_ptr m_registrationContext; }; - TEST_F(SettingsTests, Settings_IsIntialized_Success) - { - EXPECT_TRUE(m_settings->IsInitialized()); - } - TEST_F(SettingsTests, Settings_GetUnsetPathBool_ReturnsFalse) { bool settingsResult = false; @@ -103,7 +98,6 @@ namespace O3DE::ProjectManager bool settingsResult = false; EXPECT_FALSE(m_settings->Get(settingsResult, m_settingsPath)); - // Don't save to disk in test EXPECT_TRUE(m_settings->Set(m_settingsPath, true)); settingsResult = false; @@ -125,7 +119,6 @@ namespace O3DE::ProjectManager QString settingsValue = "TestValue"; - // Don't save to disk in test EXPECT_TRUE(m_settings->Set(m_settingsPath, settingsValue)); EXPECT_TRUE(m_settings->Get(settingsResult, m_settingsPath)); @@ -139,7 +132,6 @@ namespace O3DE::ProjectManager QString settingsValue = "TestValue"; - // Don't save to disk in test EXPECT_TRUE(m_settings->Set(m_settingsPath, settingsValue)); EXPECT_TRUE(m_settings->Copy(m_settingsPath, m_newSettingsPath, /*removeOrig*/ true)); @@ -158,7 +150,6 @@ namespace O3DE::ProjectManager QString settingsValue = "TestValue"; - // Don't save to disk in test EXPECT_TRUE(m_settings->Set(m_settingsPath, settingsValue)); EXPECT_TRUE(m_settings->Get(settingsResult, m_settingsPath)); @@ -175,7 +166,6 @@ namespace O3DE::ProjectManager TEST_F(SettingsTests, Settings_SetProjectBuiltSuccessfully_ReturnsTrue) { - // Don't save to disk in test EXPECT_TRUE(m_settings->SetProjectBuiltSuccessfully(m_projectInfo, true)); bool buildResult = false; @@ -185,7 +175,6 @@ namespace O3DE::ProjectManager TEST_F(SettingsTests, Settings_SetProjectBuiltUnsuccessfully_ReturnsFalse) { - // Don't save to disk in test EXPECT_TRUE(m_settings->SetProjectBuiltSuccessfully(m_projectInfo, false)); bool buildResult = false; From 53429d838e8fd622aa2fb3d2a5bf94a5779cc45e Mon Sep 17 00:00:00 2001 From: "T.J. McGrath-Daly" Date: Mon, 15 Nov 2021 10:37:24 +0800 Subject: [PATCH 14/70] Fix: Lua script debugging loading problem Signed-off-by: T.J. McGrath-Daly --- Code/Framework/AzCore/AzCore/Script/ScriptContextDebug.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Code/Framework/AzCore/AzCore/Script/ScriptContextDebug.cpp b/Code/Framework/AzCore/AzCore/Script/ScriptContextDebug.cpp index e28a289c9e..0a8ecf2b22 100644 --- a/Code/Framework/AzCore/AzCore/Script/ScriptContextDebug.cpp +++ b/Code/Framework/AzCore/AzCore/Script/ScriptContextDebug.cpp @@ -731,7 +731,7 @@ void AZ::LuaHook(lua_State* l, lua_Debug* ar) //} } - if (doBreak) + if (doBreak && bp->m_lineNumber > 0) { context->m_luaDebug = ar; context->m_breakCallback(context, bp); From bb3821df456e4bd2473e2ba8186bfc80e9b94b09 Mon Sep 17 00:00:00 2001 From: "T.J. McGrath-Daly" Date: Sat, 27 Nov 2021 14:40:25 +0800 Subject: [PATCH 15/70] Fix: Lua breakpoint error Signed-off-by: T.J. McGrath-Daly --- Code/Framework/AzCore/AzCore/Script/ScriptContextDebug.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Code/Framework/AzCore/AzCore/Script/ScriptContextDebug.cpp b/Code/Framework/AzCore/AzCore/Script/ScriptContextDebug.cpp index e28a289c9e..b03e0279ab 100644 --- a/Code/Framework/AzCore/AzCore/Script/ScriptContextDebug.cpp +++ b/Code/Framework/AzCore/AzCore/Script/ScriptContextDebug.cpp @@ -105,6 +105,8 @@ void ScriptContextDebug::ConnectHook() void ScriptContextDebug::DisconnectHook() { lua_sethook(m_context.NativeContext(), nullptr, 0, 0); + m_currentStackLevel = -1; + m_stepStackLevel = -1; } //========================================================================= @@ -651,6 +653,11 @@ void AZ::LuaHook(lua_State* l, lua_Debug* ar) context->PopCallstack(); } context->m_currentStackLevel--; + + if (context->m_currentStackLevel == -1) + { + context->m_stepStackLevel = -1; + } } else if (ar->event == LUA_HOOKLINE) { From af9e75da66bf4742a934152aa9506ab2ce1f83fe Mon Sep 17 00:00:00 2001 From: nggieber <52797929+AMZN-nggieber@users.noreply.github.com> Date: Fri, 10 Dec 2021 06:19:28 -0800 Subject: [PATCH 16/70] Minor PR feedback changes Signed-off-by: nggieber <52797929+AMZN-nggieber@users.noreply.github.com> --- .../ProjectManager/Source/ExternalLinkDialog.cpp | 2 +- Code/Tools/ProjectManager/Source/LinkWidget.cpp | 2 +- Code/Tools/ProjectManager/Source/Settings.cpp | 13 ++++--------- Code/Tools/ProjectManager/Source/Settings.h | 4 ++-- .../Source/UpdateProjectSettingsScreen.cpp | 5 +---- .../Source/UpdateProjectSettingsScreen.h | 4 +++- 6 files changed, 12 insertions(+), 18 deletions(-) diff --git a/Code/Tools/ProjectManager/Source/ExternalLinkDialog.cpp b/Code/Tools/ProjectManager/Source/ExternalLinkDialog.cpp index 726f4e5119..2d24913b5d 100644 --- a/Code/Tools/ProjectManager/Source/ExternalLinkDialog.cpp +++ b/Code/Tools/ProjectManager/Source/ExternalLinkDialog.cpp @@ -85,6 +85,6 @@ namespace O3DE::ProjectManager void ExternalLinkDialog::SetSkipDialogSetting(bool state) { - SettingsInterface::Get()->Set(QString(ISettings::ExternalLinkWarningKey), state); + SettingsInterface::Get()->Set(ISettings::ExternalLinkWarningKey, state); } } // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/LinkWidget.cpp b/Code/Tools/ProjectManager/Source/LinkWidget.cpp index 1872afe4be..bdafec24d8 100644 --- a/Code/Tools/ProjectManager/Source/LinkWidget.cpp +++ b/Code/Tools/ProjectManager/Source/LinkWidget.cpp @@ -31,7 +31,7 @@ namespace O3DE::ProjectManager { // Check if user request not to be shown external link warning dialog bool skipDialog = false; - SettingsInterface::Get()->Get(skipDialog, QString(ISettings::ExternalLinkWarningKey)); + SettingsInterface::Get()->Get(skipDialog, ISettings::ExternalLinkWarningKey); if (!skipDialog) { diff --git a/Code/Tools/ProjectManager/Source/Settings.cpp b/Code/Tools/ProjectManager/Source/Settings.cpp index e6adc5069c..0a8b600dd9 100644 --- a/Code/Tools/ProjectManager/Source/Settings.cpp +++ b/Code/Tools/ProjectManager/Source/Settings.cpp @@ -22,7 +22,7 @@ namespace O3DE::ProjectManager AZ_Assert(m_settingsRegistry, "Failed to create Settings"); } - bool Settings::Save() + void Settings::Save() { AZ::SettingsRegistryMergeUtils::DumperSettings dumperSettings; dumperSettings.m_prettifyOutput = true; @@ -34,7 +34,7 @@ namespace O3DE::ProjectManager *m_settingsRegistry, ProjectManagerKeyPrefix, stringStream, dumperSettings)) { AZ_Warning("ProjectManager", false, "Could not save Project Manager settings to stream"); - return false; + return; } AZ::IO::FixedMaxPath o3deUserPath = AZ::Utils::GetO3deManifestDirectory(); @@ -52,18 +52,13 @@ namespace O3DE::ProjectManager } AZ_Warning("ProjectManager", saved, "Unable to save Project Manager registry file to path: %s", o3deUserPath.c_str()); - return saved; } - bool Settings::OnSettingsChanged() + void Settings::OnSettingsChanged() { if (m_saveToDisk) { - return Save(); - } - else - { - return true; + Save(); } } diff --git a/Code/Tools/ProjectManager/Source/Settings.h b/Code/Tools/ProjectManager/Source/Settings.h index fb6087358b..a3b2a7212e 100644 --- a/Code/Tools/ProjectManager/Source/Settings.h +++ b/Code/Tools/ProjectManager/Source/Settings.h @@ -38,8 +38,8 @@ namespace O3DE::ProjectManager bool SetProjectBuiltSuccessfully(const ProjectInfo& projectInfo, bool successfullyBuilt) override; private: - bool Save(); - bool OnSettingsChanged(); + void Save(); + void OnSettingsChanged(); bool GetBuiltSuccessfullyPaths(AZStd::set& result); diff --git a/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.cpp b/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.cpp index 6589ee25e6..30735dcc97 100644 --- a/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.cpp +++ b/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.cpp @@ -63,10 +63,7 @@ namespace O3DE::ProjectManager m_advancedSettingsCollapseButton->setFlat(true); m_advancedSettingsCollapseButton->setFocusPolicy(Qt::NoFocus); m_advancedSettingsCollapseButton->setFixedWidth(s_collapseButtonSize); - connect(m_advancedSettingsCollapseButton, &QPushButton::clicked, this, [=]() - { - UpdateAdvancedSettingsCollapseState(); - }); + connect(m_advancedSettingsCollapseButton, &QPushButton::clicked, this, &UpdateProjectSettingsScreen::UpdateAdvancedSettingsCollapseState); advancedCollapseLayout->addWidget(m_advancedSettingsCollapseButton); // Category title diff --git a/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.h b/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.h index 40d1ccb9af..28ea032985 100644 --- a/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.h +++ b/Code/Tools/ProjectManager/Source/UpdateProjectSettingsScreen.h @@ -40,7 +40,6 @@ namespace O3DE::ProjectManager bool ValidateProjectPath() override; virtual bool ValidateProjectPreview(); bool ValidateProjectId(); - void UpdateAdvancedSettingsCollapseState(); inline constexpr static int s_collapseButtonSize = 24; @@ -53,6 +52,9 @@ namespace O3DE::ProjectManager ProjectInfo m_projectInfo; bool m_userChangedPreview; //! Did the user change the project preview path + + protected slots: + void UpdateAdvancedSettingsCollapseState(); }; } // namespace O3DE::ProjectManager From 214716dafc6d4291a0465e58c2f172f9ff5f3520 Mon Sep 17 00:00:00 2001 From: nggieber <52797929+AMZN-nggieber@users.noreply.github.com> Date: Fri, 10 Dec 2021 07:48:41 -0800 Subject: [PATCH 17/70] Add AZStd string header for linux Signed-off-by: nggieber <52797929+AMZN-nggieber@users.noreply.github.com> --- Code/Tools/ProjectManager/Source/Settings.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Code/Tools/ProjectManager/Source/Settings.h b/Code/Tools/ProjectManager/Source/Settings.h index a3b2a7212e..416d17b53b 100644 --- a/Code/Tools/ProjectManager/Source/Settings.h +++ b/Code/Tools/ProjectManager/Source/Settings.h @@ -10,6 +10,7 @@ #include +#include #include namespace AZ From e9db0bca6ac362cf77bd247d127c1b3bc2101a4b Mon Sep 17 00:00:00 2001 From: nggieber <52797929+AMZN-nggieber@users.noreply.github.com> Date: Fri, 10 Dec 2021 11:42:18 -0800 Subject: [PATCH 18/70] Fix typo, add missing header, remove unecessary asserts Signed-off-by: nggieber <52797929+AMZN-nggieber@users.noreply.github.com> --- Code/Tools/ProjectManager/Source/Application.cpp | 3 +-- .../Tools/ProjectManager/Source/GemCatalog/GemFilterWidget.cpp | 3 +++ Code/Tools/ProjectManager/Source/ProjectBuilderController.cpp | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Code/Tools/ProjectManager/Source/Application.cpp b/Code/Tools/ProjectManager/Source/Application.cpp index abc992bd02..a9ab59a991 100644 --- a/Code/Tools/ProjectManager/Source/Application.cpp +++ b/Code/Tools/ProjectManager/Source/Application.cpp @@ -70,7 +70,7 @@ namespace O3DE::ProjectManager } m_pythonBindings = AZStd::make_unique(GetEngineRoot()); - AZ_Assert(m_pythonBindings, "Failed to create PythonBindings"); + if (!m_pythonBindings->PythonStarted()) { if (!interactive) @@ -113,7 +113,6 @@ namespace O3DE::ProjectManager } m_settings = AZStd::make_unique(); - AZ_Assert(m_settings, "Failed to create Settings"); if (!RegisterEngine(interactive)) { diff --git a/Code/Tools/ProjectManager/Source/GemCatalog/GemFilterWidget.cpp b/Code/Tools/ProjectManager/Source/GemCatalog/GemFilterWidget.cpp index acea6ce378..d960145057 100644 --- a/Code/Tools/ProjectManager/Source/GemCatalog/GemFilterWidget.cpp +++ b/Code/Tools/ProjectManager/Source/GemCatalog/GemFilterWidget.cpp @@ -7,6 +7,9 @@ */ #include + +#include + #include #include #include diff --git a/Code/Tools/ProjectManager/Source/ProjectBuilderController.cpp b/Code/Tools/ProjectManager/Source/ProjectBuilderController.cpp index 0af3bfc503..e2c54f622d 100644 --- a/Code/Tools/ProjectManager/Source/ProjectBuilderController.cpp +++ b/Code/Tools/ProjectManager/Source/ProjectBuilderController.cpp @@ -27,7 +27,7 @@ namespace O3DE::ProjectManager m_worker = new ProjectBuilderWorker(m_projectInfo); m_worker->moveToThread(&m_workerThread); - // Remove key here in case Project Manager crashing while building that causes HandleResults to not be called + // Remove key here in case Project Manager crashed while building because that causes HandleResults to not be called SettingsInterface::Get()->SetProjectBuiltSuccessfully(m_projectInfo, false); connect(&m_workerThread, &QThread::finished, m_worker, &ProjectBuilderWorker::deleteLater); From d1533914abe77a5e4f0c4035edfa17911cdb7238 Mon Sep 17 00:00:00 2001 From: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> Date: Fri, 10 Dec 2021 13:16:02 -0800 Subject: [PATCH 19/70] Disable the additional transform context menu items in the inspector. Prevent the user from reparenting entities under procprefabs using the entity picker. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> --- .../ToolsComponents/TransformComponent.cpp | 62 +++++++++++++++---- 1 file changed, 50 insertions(+), 12 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponent.cpp index 1f056729d7..eedd4bdc27 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponent.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponent.cpp @@ -26,7 +26,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -35,9 +37,8 @@ #include #include -#include - #include +#include namespace AzToolsFramework { @@ -662,7 +663,6 @@ namespace AzToolsFramework return; } - // Prevent this from parenting to its own child. Check if this entity is in the new parent's hierarchy. auto potentialParentTransformComponent = GetTransformComponent(parentId); if (potentialParentTransformComponent && potentialParentTransformComponent->IsEntityInHierarchy(GetEntityId())) @@ -670,6 +670,21 @@ namespace AzToolsFramework return; } + // Don't allow read-only entities to be re-parented at all. + // Also don't allow entities to be parented under read-only entities. + if (auto readOnlyEntityPublicInterface = AZ::Interface::Get(); + readOnlyEntityPublicInterface->IsReadOnly(GetEntityId()) || readOnlyEntityPublicInterface->IsReadOnly(parentId)) + { + return; + } + + // Don't allow entities to be parented under closed containers. + if (auto containerEntityInterface = AZ::Interface::Get(); + !containerEntityInterface->IsContainerOpen(parentId)) + { + return; + } + auto oldParentId = m_parentEntityId; bool canChangeParent = true; @@ -931,14 +946,27 @@ namespace AzToolsFramework { return AZ::Failure(AZStd::string("You cannot set an entity's parent to itself!")); } - else + + // Don't allow the change if it will result in a cycle hierarchy + auto potentialParentTransformComponent = GetTransformComponent(actualValue); + if (potentialParentTransformComponent && potentialParentTransformComponent->IsEntityInHierarchy(GetEntityId())) { - // Don't allow the change if it will result in a cycle hierarchy - auto potentialParentTransformComponent = GetTransformComponent(actualValue); - if (potentialParentTransformComponent && potentialParentTransformComponent->IsEntityInHierarchy(GetEntityId())) - { - return AZ::Failure(AZStd::string("You cannot set an entity to be a child of one of its own children!")); - } + return AZ::Failure(AZStd::string("You cannot set an entity to be a child of one of its own children!")); + } + + // Don't allow read-only entities to be re-parented at all. + // Also don't allow entities to be parented under read-only entities. + if (auto readOnlyEntityPublicInterface = AZ::Interface::Get(); + readOnlyEntityPublicInterface->IsReadOnly(GetEntityId()) || readOnlyEntityPublicInterface->IsReadOnly(actualValue)) + { + return AZ::Failure(AZStd::string("You cannot set an entity to be a child of a read-only entity!")); + } + + // Don't allow entities to be parented under closed containers. + if (auto containerEntityInterface = AZ::Interface::Get(); + !containerEntityInterface->IsContainerOpen(actualValue)) + { + return AZ::Failure(AZStd::string("You cannot set an entity to be a child of a closed container!")); } return AZ::Success(); @@ -1245,6 +1273,15 @@ namespace AzToolsFramework void TransformComponent::AddContextMenuActions(QMenu* menu) { + bool parentEntityIsReadOnly = false; + + // If the parent entity is marked as read-only, don't allow actions on this transform. + if (auto readOnlyEntityPublicInterface = AZ::Interface::Get(); + readOnlyEntityPublicInterface->IsReadOnly(GetEntityId())) + { + parentEntityIsReadOnly = true; + } + if (menu) { if (!menu->actions().empty()) @@ -1266,10 +1303,10 @@ namespace AzToolsFramework AzToolsFramework::ToolsApplicationEvents::Bus::Broadcast(&AzToolsFramework::ToolsApplicationEvents::InvalidatePropertyDisplay, AzToolsFramework::Refresh_Values); }); - resetAction->setEnabled(!m_editorTransform.m_locked); + resetAction->setEnabled(!m_editorTransform.m_locked && !parentEntityIsReadOnly); QString lockString = m_editorTransform.m_locked ? "Unlock transform values" : "Lock transform values"; - menu->addAction(lockString, [this, lockString]() + QAction* lockAction = menu->addAction(lockString, [this, lockString]() { { AzToolsFramework::ScopedUndoBatch undo(lockString.toUtf8().data()); @@ -1278,6 +1315,7 @@ namespace AzToolsFramework } AzToolsFramework::ToolsApplicationEvents::Bus::Broadcast(&AzToolsFramework::ToolsApplicationEvents::InvalidatePropertyDisplay, AzToolsFramework::Refresh_AttributesAndValues); }); + lockAction->setEnabled(!parentEntityIsReadOnly); } } } From 3cf85bb5624fdfc53fef41cc1ee8a26681402d3f Mon Sep 17 00:00:00 2001 From: nggieber <52797929+AMZN-nggieber@users.noreply.github.com> Date: Fri, 10 Dec 2021 14:12:14 -0800 Subject: [PATCH 20/70] Fix project properties test Signed-off-by: nggieber <52797929+AMZN-nggieber@users.noreply.github.com> --- engine.json | 1 - scripts/o3de/tests/unit_test_project_properties.py | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/engine.json b/engine.json index 0aa3238f49..737ac24fea 100644 --- a/engine.json +++ b/engine.json @@ -86,7 +86,6 @@ "Gems/WhiteBox" ], "projects": [ - "AtomTest", "AutomatedTesting" ], "templates": [ diff --git a/scripts/o3de/tests/unit_test_project_properties.py b/scripts/o3de/tests/unit_test_project_properties.py index 1bcc6dcef3..dcf736f016 100644 --- a/scripts/o3de/tests/unit_test_project_properties.py +++ b/scripts/o3de/tests/unit_test_project_properties.py @@ -16,7 +16,7 @@ from o3de import project_properties TEST_PROJECT_JSON_PAYLOAD = ''' { "project_name": "TestProject", - "project_id": "{24114e69-306d-4de6-b3b4-4cb1a3eca58e}" + "project_id": "{24114e69-306d-4de6-b3b4-4cb1a3eca58e}", "origin": "The primary repo for TestProject goes here: i.e. http://www.mydomain.com", "license": "What license TestProject uses goes here: i.e. https://opensource.org/licenses/MIT", "display_name": "TestProject", @@ -57,8 +57,8 @@ class TestEditProjectProperties: 'B', 'D E F', 1) ] ) - def test_edit_project_properties(self, project_path, project_name, project_new_name, project_origin, project_id, - project_display,project_summary, project_icon, add_tags, + def test_edit_project_properties(self, project_path, project_name, project_new_name, project_id, project_origin, + project_display, project_summary, project_icon, add_tags, delete_tags, replace_tags, expected_result): def get_project_json_data(project_name: str, project_path) -> dict: From c06b697c6b369d550cab719b2d36aa41604d6846 Mon Sep 17 00:00:00 2001 From: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> Date: Fri, 10 Dec 2021 15:06:55 -0800 Subject: [PATCH 21/70] Revert part of the fix as it would break unit tests. Verified the remaining code still achieves the same purpose on the UI side without impacting the backend. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> --- .../ToolsComponents/TransformComponent.cpp | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponent.cpp index eedd4bdc27..55961aa703 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponent.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponent.cpp @@ -670,21 +670,6 @@ namespace AzToolsFramework return; } - // Don't allow read-only entities to be re-parented at all. - // Also don't allow entities to be parented under read-only entities. - if (auto readOnlyEntityPublicInterface = AZ::Interface::Get(); - readOnlyEntityPublicInterface->IsReadOnly(GetEntityId()) || readOnlyEntityPublicInterface->IsReadOnly(parentId)) - { - return; - } - - // Don't allow entities to be parented under closed containers. - if (auto containerEntityInterface = AZ::Interface::Get(); - !containerEntityInterface->IsContainerOpen(parentId)) - { - return; - } - auto oldParentId = m_parentEntityId; bool canChangeParent = true; From ab859d197939e218c349b6e3cda7b60b34f25f13 Mon Sep 17 00:00:00 2001 From: rgba16f <82187279+rgba16f@users.noreply.github.com> Date: Fri, 10 Dec 2021 19:08:18 -0600 Subject: [PATCH 22/70] Change Vulkan RHI CommandList::SetStreamBuffers to not do 2 memory allocation per draw by using fixed_vector Signed-off-by: rgba16f <82187279+rgba16f@users.noreply.github.com> --- Gems/Atom/RHI/Vulkan/Code/Source/RHI/CommandList.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/CommandList.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/CommandList.cpp index ffa02ac3c4..c74b9d4d13 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/CommandList.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/CommandList.cpp @@ -6,6 +6,7 @@ * */ #include +#include #include #include #include @@ -688,8 +689,8 @@ namespace AZ if (interval != InvalidInterval) { uint32_t numBuffers = interval.m_max - interval.m_min + 1; - AZStd::vector nativeBuffers(numBuffers, VK_NULL_HANDLE); - AZStd::vector offsets(numBuffers, 0); + AZStd::fixed_vector nativeBuffers(numBuffers, VK_NULL_HANDLE); + AZStd::fixed_vector offsets(numBuffers, 0); for (uint32_t i = 0; i < numBuffers; ++i) { const RHI::StreamBufferView& bufferView = streams[i + interval.m_min]; From 497fe8eccc159cc335204fd790ca521cb80ed829 Mon Sep 17 00:00:00 2001 From: dmcdiarmid-ly <63674186+dmcdiarmid-ly@users.noreply.github.com> Date: Sun, 12 Dec 2021 18:02:25 -0700 Subject: [PATCH 23/70] Fixes for Vulkan validation warnings related to RayTracing and DiffuseGI. Signed-off-by: dmcdiarmid-ly <63674186+dmcdiarmid-ly@users.noreply.github.com> --- .../Atom/RHI.Reflect/BufferDescriptor.h | 6 +++- .../RHI/Vulkan/Code/Source/RHI/Conversion.cpp | 23 ++++++++------ .../Vulkan/Code/Source/RHI/DescriptorSet.cpp | 13 ++++---- .../RHI/Vulkan/Code/Source/RHI/Device.cpp | 17 +++++++++-- .../Vulkan/Code/Source/RHI/PhysicalDevice.cpp | 20 +++++++++++++ .../Vulkan/Code/Source/RHI/PhysicalDevice.h | 4 +++ .../Vulkan/Code/Source/RHI/RayTracingBlas.cpp | 2 +- .../Code/Source/RHI/RayTracingBufferPools.h | 1 + .../Vulkan/Code/Source/RHI/RayTracingTlas.cpp | 2 +- .../glad/2.0.0-beta/include/glad/vulkan.h | 30 +++++++++++-------- 10 files changed, 86 insertions(+), 32 deletions(-) diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/BufferDescriptor.h b/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/BufferDescriptor.h index c271045ed0..1a34cf00cd 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/BufferDescriptor.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/BufferDescriptor.h @@ -61,7 +61,11 @@ namespace AZ (RayTracingAccelerationStructure , AZ_BIT(9)), /// Supports ray tracing shader table usage. - (RayTracingShaderTable , AZ_BIT(10))); + (RayTracingShaderTable , AZ_BIT(10)), + + /// Supports ray tracing scratch buffer usage. + (RayTracingScratchBuffer, AZ_BIT(11))); + AZ_DEFINE_ENUM_BITWISE_OPERATORS(AZ::RHI::BufferBindFlags); diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/Conversion.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/Conversion.cpp index 3294b77eaa..51915ba5a6 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/Conversion.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/Conversion.cpp @@ -736,7 +736,7 @@ namespace AZ if (RHI::CheckBitsAny(bindFlags, BindFlags::RayTracingAccelerationStructure)) { - usageFlags |= VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR; + usageFlags |= VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR | VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR; } if (RHI::CheckBitsAny(bindFlags, BindFlags::RayTracingShaderTable)) @@ -756,7 +756,7 @@ namespace AZ { return RHI::CheckBitsAny( bindFlags, - RHI::BufferBindFlags::InputAssembly | RHI::BufferBindFlags::DynamicInputAssembly | RHI::BufferBindFlags::RayTracingShaderTable); + RHI::BufferBindFlags::InputAssembly | RHI::BufferBindFlags::DynamicInputAssembly | RHI::BufferBindFlags::RayTracingShaderTable | RHI::BufferBindFlags::RayTracingAccelerationStructure | RHI::BufferBindFlags::RayTracingScratchBuffer); } VkPipelineStageFlags GetSupportedPipelineStages(RHI::PipelineStateType type) @@ -1154,15 +1154,20 @@ namespace AZ return RHI::CheckBitsAny(usagesAndAccesses.front().m_access, RHI::ScopeAttachmentAccess::Write) ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL : VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; case RHI::ScopeAttachmentUsage::Shader: case RHI::ScopeAttachmentUsage::SubpassInput: - // If we are reading from a depth/stencil texture, then we use the depth/stencil read optimal layout instead of the generic shader read one. - if (RHI::CheckBitsAny(imageAspects, RHI::ImageAspectFlags::DepthStencil)) { - return RHI::CheckBitsAny(usagesAndAccesses.front().m_access, RHI::ScopeAttachmentAccess::Write) ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; + // If we are reading from a depth/stencil texture, then we use the depth/stencil read optimal layout instead of the generic shader read one. + // Note that if the Image is ShaderWrite we always set VK_IMAGE_LAYOUT_GENERAL, even in a read scope. + if (RHI::CheckBitsAny(usagesAndAccesses.front().m_access, RHI::ScopeAttachmentAccess::Write) || + RHI::CheckBitsAny(imageView->GetImage().GetDescriptor().m_bindFlags, RHI::ImageBindFlags::ShaderWrite)) + { + return VK_IMAGE_LAYOUT_GENERAL; + } + else + { + return RHI::CheckBitsAny(imageAspects, RHI::ImageAspectFlags::DepthStencil) ? + VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL : VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; + } } - else - { - return RHI::CheckBitsAny(usagesAndAccesses.front().m_access, RHI::ScopeAttachmentAccess::Write) ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; - } case RHI::ScopeAttachmentUsage::Copy: return RHI::CheckBitsAny(usagesAndAccesses.front().m_access, RHI::ScopeAttachmentAccess::Write) ? VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL : VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; default: diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/DescriptorSet.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/DescriptorSet.cpp index d70d4a01b5..c6fe233282 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/DescriptorSet.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/DescriptorSet.cpp @@ -149,16 +149,17 @@ namespace AZ { imageInfo.imageView = imageView->GetNativeImageView(); - // Depending on the access (read or readwrite) and if it's a depth/stencil image, we choose the expected layout. - switch (layout.GetDescriptorType(layoutIndex)) + // If we are reading from a depth/stencil texture, then we use the depth/stencil read optimal layout instead of the generic shader read one. + // Note that if the Image is ShaderWrite we always set VK_IMAGE_LAYOUT_GENERAL, even if the descriptor layout wants a read-only input. + if (layout.GetDescriptorType(layoutIndex) == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE || + RHI::CheckBitsAny(imageView->GetImage().GetDescriptor().m_bindFlags, RHI::ImageBindFlags::ShaderWrite)) { - case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: imageInfo.imageLayout = VK_IMAGE_LAYOUT_GENERAL; - break; - default: + } + else + { imageInfo.imageLayout = RHI::CheckBitsAny(imageView->GetImage().GetAspectFlags(), RHI::ImageAspectFlags::DepthStencil) ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL : VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; - break; } } diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/Device.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/Device.cpp index 14b6c01498..a20e7d4361 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/Device.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/Device.cpp @@ -216,11 +216,24 @@ namespace AZ float16Int8.pNext = &separateDepthStencil; robustness2.pNext = &float16Int8; - - deviceInfo.pNext = &descriptorIndexingFeatures; } + // set raytracing features if we are running Vulkan >= 1.2 + VkPhysicalDeviceAccelerationStructureFeaturesKHR accelerationStructureFeatures = {}; + VkPhysicalDeviceRayTracingPipelineFeaturesKHR rayTracingPipelineFeatures = {}; + + if (majorVersion >= 1 && minorVersion >= 2) + { + accelerationStructureFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_FEATURES_KHR; + accelerationStructureFeatures.accelerationStructure = physicalDevice.GetPhysicalDeviceAccelerationStructureFeatures().accelerationStructure; + vulkan12Features.pNext = &accelerationStructureFeatures; + + rayTracingPipelineFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_FEATURES_KHR; + rayTracingPipelineFeatures.rayTracingPipeline = physicalDevice.GetPhysicalDeviceRayTracingPipelineFeatures().rayTracingPipeline; + accelerationStructureFeatures.pNext = &rayTracingPipelineFeatures; + } + deviceInfo.flags = 0; deviceInfo.queueCreateInfoCount = static_cast(queueCreationInfo.size()); deviceInfo.pQueueCreateInfos = queueCreationInfo.data(); diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PhysicalDevice.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PhysicalDevice.cpp index cdb9bbc7bd..ee000d8259 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PhysicalDevice.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PhysicalDevice.cpp @@ -111,11 +111,21 @@ namespace AZ return m_accelerationStructureProperties; } + const VkPhysicalDeviceAccelerationStructureFeaturesKHR& PhysicalDevice::GetPhysicalDeviceAccelerationStructureFeatures() const + { + return m_accelerationStructureFeatures; + } + const VkPhysicalDeviceRayTracingPipelinePropertiesKHR& PhysicalDevice::GetPhysicalDeviceRayTracingPipelineProperties() const { return m_rayTracingPipelineProperties; } + const VkPhysicalDeviceRayTracingPipelineFeaturesKHR& PhysicalDevice::GetPhysicalDeviceRayTracingPipelineFeatures() const + { + return m_rayTracingPipelineFeatures; + } + const VkPhysicalDeviceShaderFloat16Int8FeaturesKHR& PhysicalDevice::GetPhysicalDeviceFloat16Int8Features() const { return m_float16Int8Features; @@ -349,6 +359,16 @@ namespace AZ vulkan12Features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES; separateDepthStencilFeatures.pNext = &vulkan12Features; + VkPhysicalDeviceAccelerationStructureFeaturesKHR& accelerationStructureFeatures = m_accelerationStructureFeatures; + accelerationStructureFeatures = {}; + accelerationStructureFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_FEATURES_KHR; + vulkan12Features.pNext = &accelerationStructureFeatures; + + VkPhysicalDeviceRayTracingPipelineFeaturesKHR& rayTracingPipelineFeatures = m_rayTracingPipelineFeatures; + rayTracingPipelineFeatures = {}; + rayTracingPipelineFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_FEATURES_KHR; + accelerationStructureFeatures.pNext = &rayTracingPipelineFeatures; + VkPhysicalDeviceFeatures2 deviceFeatures2 = {}; deviceFeatures2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; deviceFeatures2.pNext = &descriptorIndexingFeatures; diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PhysicalDevice.h b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PhysicalDevice.h index 320d32b6e3..8f502f703a 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PhysicalDevice.h +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PhysicalDevice.h @@ -82,7 +82,9 @@ namespace AZ const VkPhysicalDeviceVulkan12Features& GetPhysicalDeviceVulkan12Features() const; const VkPhysicalDeviceSeparateDepthStencilLayoutsFeaturesKHR& GetPhysicalDeviceSeparateDepthStencilFeatures() const; const VkPhysicalDeviceAccelerationStructurePropertiesKHR& GetPhysicalDeviceAccelerationStructureProperties() const; + const VkPhysicalDeviceAccelerationStructureFeaturesKHR& GetPhysicalDeviceAccelerationStructureFeatures() const; const VkPhysicalDeviceRayTracingPipelinePropertiesKHR& GetPhysicalDeviceRayTracingPipelineProperties() const; + const VkPhysicalDeviceRayTracingPipelineFeaturesKHR& GetPhysicalDeviceRayTracingPipelineFeatures() const; VkFormatProperties GetFormatProperties(RHI::Format format, bool raiseAsserts = true) const; StringList GetDeviceLayerNames() const; StringList GetDeviceExtensionNames(const char* layerName = nullptr) const; @@ -116,7 +118,9 @@ namespace AZ VkPhysicalDeviceBufferDeviceAddressFeaturesEXT m_bufferDeviceAddressFeatures{}; VkPhysicalDeviceSeparateDepthStencilLayoutsFeaturesKHR m_separateDepthStencilFeatures{}; VkPhysicalDeviceAccelerationStructurePropertiesKHR m_accelerationStructureProperties{}; + VkPhysicalDeviceAccelerationStructureFeaturesKHR m_accelerationStructureFeatures{}; VkPhysicalDeviceRayTracingPipelinePropertiesKHR m_rayTracingPipelineProperties{}; + VkPhysicalDeviceRayTracingPipelineFeaturesKHR m_rayTracingPipelineFeatures{}; VkPhysicalDeviceVulkan12Features m_vulkan12Features{}; }; } diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RayTracingBlas.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RayTracingBlas.cpp index 333f88f8eb..a322380fb1 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RayTracingBlas.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RayTracingBlas.cpp @@ -114,7 +114,7 @@ namespace AZ // create scratch buffer buffers.m_scratchBuffer = RHI::Factory::Get().CreateBuffer(); AZ::RHI::BufferDescriptor scratchBufferDescriptor; - scratchBufferDescriptor.m_bindFlags = RHI::BufferBindFlags::ShaderReadWrite; + scratchBufferDescriptor.m_bindFlags = RHI::BufferBindFlags::ShaderReadWrite | RHI::BufferBindFlags::RayTracingScratchBuffer; scratchBufferDescriptor.m_byteCount = buildSizesInfo.buildScratchSize; AZ::RHI::BufferInitRequest scratchBufferRequest; diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RayTracingBufferPools.h b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RayTracingBufferPools.h index a7547c7106..d818a5ea9a 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RayTracingBufferPools.h +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RayTracingBufferPools.h @@ -25,6 +25,7 @@ namespace AZ protected: virtual RHI::BufferBindFlags GetShaderTableBufferBindFlags() const override { return RHI::BufferBindFlags::CopyRead | RHI::BufferBindFlags::RayTracingShaderTable; } + virtual RHI::BufferBindFlags GetScratchBufferBindFlags() const override { return RHI::BufferBindFlags::ShaderReadWrite | RHI::BufferBindFlags::RayTracingScratchBuffer; } virtual RHI::BufferBindFlags GetTlasInstancesBufferBindFlags() const override { return RHI::BufferBindFlags::ShaderRead | RHI::BufferBindFlags::RayTracingAccelerationStructure; } private: diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RayTracingTlas.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RayTracingTlas.cpp index ff6312b059..9ea9ceccce 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RayTracingTlas.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RayTracingTlas.cpp @@ -154,7 +154,7 @@ namespace AZ // create scratch buffer buffers.m_scratchBuffer = RHI::Factory::Get().CreateBuffer(); AZ::RHI::BufferDescriptor scratchBufferDescriptor; - scratchBufferDescriptor.m_bindFlags = RHI::BufferBindFlags::ShaderReadWrite; + scratchBufferDescriptor.m_bindFlags = RHI::BufferBindFlags::ShaderReadWrite | RHI::BufferBindFlags::RayTracingScratchBuffer; scratchBufferDescriptor.m_byteCount = buildSizesInfo.buildScratchSize; AZ::RHI::BufferInitRequest scratchBufferRequest; diff --git a/Gems/Atom/RHI/Vulkan/External/glad/2.0.0-beta/include/glad/vulkan.h b/Gems/Atom/RHI/Vulkan/External/glad/2.0.0-beta/include/glad/vulkan.h index 33d4b64082..47c37e1ff7 100644 --- a/Gems/Atom/RHI/Vulkan/External/glad/2.0.0-beta/include/glad/vulkan.h +++ b/Gems/Atom/RHI/Vulkan/External/glad/2.0.0-beta/include/glad/vulkan.h @@ -8028,19 +8028,25 @@ typedef struct VkBindAccelerationStructureMemoryInfoKHR { typedef struct VkBindAccelerationStructureMemoryInfoKHR VkBindAccelerationStructureMemoryInfoNV; -typedef struct VkPhysicalDeviceRayTracingFeaturesKHR { +typedef struct VkPhysicalDeviceRayTracingPipelineFeaturesKHR { VkStructureType sType; - void * pNext; - VkBool32 rayTracing; - VkBool32 rayTracingShaderGroupHandleCaptureReplay; - VkBool32 rayTracingShaderGroupHandleCaptureReplayMixed; - VkBool32 rayTracingAccelerationStructureCaptureReplay; - VkBool32 rayTracingIndirectTraceRays; - VkBool32 rayTracingIndirectAccelerationStructureBuild; - VkBool32 rayTracingHostAccelerationStructureCommands; - VkBool32 rayQuery; - VkBool32 rayTracingPrimitiveCulling; -} VkPhysicalDeviceRayTracingFeaturesKHR; + void* pNext; + VkBool32 rayTracingPipeline; + VkBool32 rayTracingPipelineShaderGroupHandleCaptureReplay; + VkBool32 rayTracingPipelineShaderGroupHandleCaptureReplayMixed; + VkBool32 rayTracingPipelineTraceRaysIndirect; + VkBool32 rayTraversalPrimitiveCulling; +} VkPhysicalDeviceRayTracingPipelineFeaturesKHR; + +typedef struct VkPhysicalDeviceAccelerationStructureFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 accelerationStructure; + VkBool32 accelerationStructureCaptureReplay; + VkBool32 accelerationStructureIndirectBuild; + VkBool32 accelerationStructureHostCommands; + VkBool32 descriptorBindingAccelerationStructureUpdateAfterBind; +} VkPhysicalDeviceAccelerationStructureFeaturesKHR; typedef struct VkStridedBufferRegionKHR { VkBuffer buffer; From 4d187b0980e8b7bfc444975099d48cc5621e8226 Mon Sep 17 00:00:00 2001 From: dmcdiarmid-ly <63674186+dmcdiarmid-ly@users.noreply.github.com> Date: Sun, 12 Dec 2021 18:43:12 -0700 Subject: [PATCH 24/70] Minor changes to RayTracingScratchBuffer flag. Signed-off-by: dmcdiarmid-ly <63674186+dmcdiarmid-ly@users.noreply.github.com> --- Gems/Atom/RHI/Code/Include/Atom/RHI/RayTracingBufferPools.h | 2 +- Gems/Atom/RHI/DX12/Code/Source/RHI/RayTracingBlas.cpp | 2 +- Gems/Atom/RHI/DX12/Code/Source/RHI/RayTracingTlas.cpp | 2 +- Gems/Atom/RHI/Vulkan/Code/Source/RHI/RayTracingBufferPools.h | 1 - 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI/RayTracingBufferPools.h b/Gems/Atom/RHI/Code/Include/Atom/RHI/RayTracingBufferPools.h index 6cc0f2d264..288a83b4da 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI/RayTracingBufferPools.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI/RayTracingBufferPools.h @@ -44,7 +44,7 @@ namespace AZ RayTracingBufferPools() = default; virtual RHI::BufferBindFlags GetShaderTableBufferBindFlags() const { return RHI::BufferBindFlags::ShaderRead | RHI::BufferBindFlags::CopyRead | RHI::BufferBindFlags::RayTracingShaderTable; } - virtual RHI::BufferBindFlags GetScratchBufferBindFlags() const { return RHI::BufferBindFlags::ShaderReadWrite; } + virtual RHI::BufferBindFlags GetScratchBufferBindFlags() const { return RHI::BufferBindFlags::ShaderReadWrite | RHI::BufferBindFlags::RayTracingScratchBuffer; } virtual RHI::BufferBindFlags GetBlasBufferBindFlags() const { return RHI::BufferBindFlags::ShaderReadWrite | RHI::BufferBindFlags::RayTracingAccelerationStructure; } virtual RHI::BufferBindFlags GetTlasInstancesBufferBindFlags() const { return RHI::BufferBindFlags::ShaderRead; } virtual RHI::BufferBindFlags GetTlasBufferBindFlags() const { return RHI::BufferBindFlags::RayTracingAccelerationStructure; } diff --git a/Gems/Atom/RHI/DX12/Code/Source/RHI/RayTracingBlas.cpp b/Gems/Atom/RHI/DX12/Code/Source/RHI/RayTracingBlas.cpp index b5b4850470..b74ed5f236 100644 --- a/Gems/Atom/RHI/DX12/Code/Source/RHI/RayTracingBlas.cpp +++ b/Gems/Atom/RHI/DX12/Code/Source/RHI/RayTracingBlas.cpp @@ -72,7 +72,7 @@ namespace AZ // create scratch buffer buffers.m_scratchBuffer = RHI::Factory::Get().CreateBuffer(); AZ::RHI::BufferDescriptor scratchBufferDescriptor; - scratchBufferDescriptor.m_bindFlags = RHI::BufferBindFlags::ShaderReadWrite; + scratchBufferDescriptor.m_bindFlags = RHI::BufferBindFlags::ShaderReadWrite | RHI::BufferBindFlags::RayTracingScratchBuffer; scratchBufferDescriptor.m_byteCount = prebuildInfo.ScratchDataSizeInBytes; AZ::RHI::BufferInitRequest scratchBufferRequest; diff --git a/Gems/Atom/RHI/DX12/Code/Source/RHI/RayTracingTlas.cpp b/Gems/Atom/RHI/DX12/Code/Source/RHI/RayTracingTlas.cpp index 84f8daba04..c28c5e4db5 100644 --- a/Gems/Atom/RHI/DX12/Code/Source/RHI/RayTracingTlas.cpp +++ b/Gems/Atom/RHI/DX12/Code/Source/RHI/RayTracingTlas.cpp @@ -119,7 +119,7 @@ namespace AZ // create scratch buffer buffers.m_scratchBuffer = RHI::Factory::Get().CreateBuffer(); AZ::RHI::BufferDescriptor scratchBufferDescriptor; - scratchBufferDescriptor.m_bindFlags = RHI::BufferBindFlags::ShaderReadWrite; + scratchBufferDescriptor.m_bindFlags = RHI::BufferBindFlags::ShaderReadWrite | RHI::BufferBindFlags::RayTracingScratchBuffer; scratchBufferDescriptor.m_byteCount = prebuildInfo.ScratchDataSizeInBytes; AZ::RHI::BufferInitRequest scratchBufferRequest; diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RayTracingBufferPools.h b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RayTracingBufferPools.h index d818a5ea9a..a7547c7106 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RayTracingBufferPools.h +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/RayTracingBufferPools.h @@ -25,7 +25,6 @@ namespace AZ protected: virtual RHI::BufferBindFlags GetShaderTableBufferBindFlags() const override { return RHI::BufferBindFlags::CopyRead | RHI::BufferBindFlags::RayTracingShaderTable; } - virtual RHI::BufferBindFlags GetScratchBufferBindFlags() const override { return RHI::BufferBindFlags::ShaderReadWrite | RHI::BufferBindFlags::RayTracingScratchBuffer; } virtual RHI::BufferBindFlags GetTlasInstancesBufferBindFlags() const override { return RHI::BufferBindFlags::ShaderRead | RHI::BufferBindFlags::RayTracingAccelerationStructure; } private: From f941d03f9e937baf8ec71774c470d17855cc683c Mon Sep 17 00:00:00 2001 From: moraaar Date: Mon, 13 Dec 2021 14:03:00 +0000 Subject: [PATCH 25/70] Fix namespace Az for AZ in ProcessWatcher for iOS (#6382) Signed-off-by: moraaar --- .../Platform/iOS/AzFramework/Process/ProcessWatcher_iOS.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Code/Framework/AzFramework/Platform/iOS/AzFramework/Process/ProcessWatcher_iOS.cpp b/Code/Framework/AzFramework/Platform/iOS/AzFramework/Process/ProcessWatcher_iOS.cpp index c7b7513064..d637da29fe 100644 --- a/Code/Framework/AzFramework/Platform/iOS/AzFramework/Process/ProcessWatcher_iOS.cpp +++ b/Code/Framework/AzFramework/Platform/iOS/AzFramework/Process/ProcessWatcher_iOS.cpp @@ -96,7 +96,7 @@ namespace AzFramework AZStd::string operator()(const AZStd::vector& commandLineArray) const { AZStd::string commandLineResult; - Az::StringFunc::Join(commandLineResult, commandLineArray.begin(), commandLineArray.end(), " "); + AZ::StringFunc::Join(commandLineResult, commandLineArray.begin(), commandLineArray.end(), " "); return commandLineResult; } }; From f2c9a217dac88770ffdd26e32fff5e7a269415f1 Mon Sep 17 00:00:00 2001 From: Steve Pham <82231385+spham-amzn@users.noreply.github.com> Date: Mon, 13 Dec 2021 08:51:30 -0800 Subject: [PATCH 26/70] Revert previous update to ConstantsData::SetConstantArray and fix unit tests (#6351) Signed-off-by: Steve Pham <82231385+spham-amzn@users.noreply.github.com> --- Gems/Atom/RHI/Code/Source/RHI/ConstantsData.cpp | 13 +------------ .../ShaderResourceGroupConstantBufferTests.cpp | 2 +- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/Gems/Atom/RHI/Code/Source/RHI/ConstantsData.cpp b/Gems/Atom/RHI/Code/Source/RHI/ConstantsData.cpp index 1a5d793cb1..a86f278ee2 100644 --- a/Gems/Atom/RHI/Code/Source/RHI/ConstantsData.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI/ConstantsData.cpp @@ -154,20 +154,9 @@ namespace AZ bool isValidAll = true; uint32_t offset = 0; - // Rather than doing the direct validation against values directly, we have to convert the array_view - // to a raw byte array, and then check against the bytes to determine whether or not to set the - // uint32 value to 1 (true) or 0 (false). Clang when building in non-debug builds was optimizing out - // the actual 1 and 0 values, so an expression like: - // - // const uint32_t fourByteValue = values[i] ? 1 : 0; - // - // when values[0] == 205, will instead set 'fourByteValue' is assigned to '205', instead of '1'. - // In debug builds, and other microsoft compilers (debug+release), this type of optimization doesnt - // occur and we get the expected results instead - const AZ::u8* byteValues = reinterpret_cast(values.data()); for (size_t i = 0; i < values.size(); i++) { - const uint32_t fourByteValue = byteValues[i] ? 1 : 0; + const uint32_t fourByteValue = values[i] ? 1 : 0; const bool isValid = SetConstantRaw(inputIndex, &fourByteValue, offset, elementSize); isValidAll &= isValid; diff --git a/Gems/Atom/RPI/Code/Tests/ShaderResourceGroup/ShaderResourceGroupConstantBufferTests.cpp b/Gems/Atom/RPI/Code/Tests/ShaderResourceGroup/ShaderResourceGroupConstantBufferTests.cpp index 97404aafbb..0c3c82933b 100644 --- a/Gems/Atom/RPI/Code/Tests/ShaderResourceGroup/ShaderResourceGroupConstantBufferTests.cpp +++ b/Gems/Atom/RPI/Code/Tests/ShaderResourceGroup/ShaderResourceGroupConstantBufferTests.cpp @@ -265,7 +265,7 @@ namespace UnitTest EXPECT_TRUE(m_srg->SetConstantArray(inputIndex, AZStd::array({ asBools[1], asBools[2] }))); AZStd::array_view result = m_srg->GetConstantRaw(inputIndex); AZStd::array_view resultInUint = AZStd::array_view(reinterpret_cast(result.data()), 2); - ExpectEqual({ 1 /*true*/, 0 /*false*/ }, resultInUint); + EXPECT_THAT(resultInUint, testing::ElementsAre(testing::IsTrue(), testing::IsFalse())); } } From eae66b964bef841cd9afccedf364696c17e628b1 Mon Sep 17 00:00:00 2001 From: Maxim Ivanov <59574542+imginimg@users.noreply.github.com> Date: Mon, 13 Dec 2021 20:32:24 +0300 Subject: [PATCH 27/70] [AudioSystem] Allow audio engines to provide widgets for modifying connection properties. (#6303) Signed-off-by: Maxim Ivanov --- .../Code/Include/Editor/IAudioSystemEditor.h | 8 +++ .../Code/Source/Editor/ConnectionsWidget.ui | 14 +---- .../Code/Source/Editor/QConnectionsWidget.cpp | 52 +++++++++++++++++++ .../Code/Source/Editor/QConnectionsWidget.h | 3 ++ 4 files changed, 64 insertions(+), 13 deletions(-) diff --git a/Gems/AudioSystem/Code/Include/Editor/IAudioSystemEditor.h b/Gems/AudioSystem/Code/Include/Editor/IAudioSystemEditor.h index 5a9c773a32..b4dcf1df12 100644 --- a/Gems/AudioSystem/Code/Include/Editor/IAudioSystemEditor.h +++ b/Gems/AudioSystem/Code/Include/Editor/IAudioSystemEditor.h @@ -16,6 +16,8 @@ #include +class QWidget; + namespace AudioControls { class IAudioSystemEditor; @@ -150,6 +152,12 @@ namespace AudioControls //! Informs the plugin that the ACE has saved the data in case it needs to do any clean up. virtual void DataSaved() = 0; + + //! Creates a widget for modifying connection properties. + //! The widget must have a "PropertiesChanged()" signal. + //! The widget ownership transferred to the caller. + virtual QWidget* CreateConnectionPropertiesWidget([[maybe_unused]] const TConnectionPtr connection, + [[maybe_unused]] EACEControlType atlControlType) { return nullptr; } }; } // namespace AudioControls diff --git a/Gems/AudioSystem/Code/Source/Editor/ConnectionsWidget.ui b/Gems/AudioSystem/Code/Source/Editor/ConnectionsWidget.ui index 120df694bc..b536ea541a 100644 --- a/Gems/AudioSystem/Code/Source/Editor/ConnectionsWidget.ui +++ b/Gems/AudioSystem/Code/Source/Editor/ConnectionsWidget.ui @@ -16,18 +16,6 @@ 0 - - - 0 - 450 - - - - - 16777215 - 450 - - Inspector Panel @@ -104,7 +92,7 @@ QFrame::Plain - + 0 diff --git a/Gems/AudioSystem/Code/Source/Editor/QConnectionsWidget.cpp b/Gems/AudioSystem/Code/Source/Editor/QConnectionsWidget.cpp index ce7a49ae1e..d827f657b8 100644 --- a/Gems/AudioSystem/Code/Source/Editor/QConnectionsWidget.cpp +++ b/Gems/AudioSystem/Code/Source/Editor/QConnectionsWidget.cpp @@ -37,6 +37,7 @@ namespace AudioControls m_connectionList->installEventFilter(this); connect(m_connectionList, SIGNAL(customContextMenuRequested(const QPoint&)), SLOT(ShowConnectionContextMenu(const QPoint&))); + connect(m_connectionList, SIGNAL(itemSelectionChanged()), this, SLOT(SelectedConnectionChanged())); } //-------------------------------------------------------------------------------------------// @@ -100,6 +101,57 @@ namespace AudioControls contextMenu.exec(m_connectionList->mapToGlobal(pos)); } + //-------------------------------------------------------------------------------------------// + void QConnectionsWidget::SelectedConnectionChanged() + { + TConnectionPtr connection; + EACEControlType controlType = AudioControls::eACET_NUM_TYPES; + if (m_control) + { + QList selected = m_connectionList->selectedItems(); + if (selected.length() == 1) + { + QListWidgetItem* currentItem = selected[0]; + if (currentItem) + { + const CID externalId = currentItem->data(eMDR_ID).toInt(); + connection = m_control->GetConnection(externalId); + controlType = m_control->GetType(); + } + } + } + + if (m_connectionPropertiesWidget) + { + delete m_connectionPropertiesWidget; + m_connectionPropertiesWidget = nullptr; + } + + if (connection && connection->HasProperties()) + { + if (IAudioSystemEditor* audioSystemImpl = CAudioControlsEditorPlugin::GetAudioSystemEditorImpl()) + { + m_connectionPropertiesWidget = audioSystemImpl->CreateConnectionPropertiesWidget(connection, controlType); + if (m_connectionPropertiesWidget) + { + m_connectionPropertiesWidget->setParent(m_connectionPropertiesFrame); + m_connectionPropertiesLayout->addWidget(m_connectionPropertiesWidget); + + bool widgetHasChangedSignal = m_connectionPropertiesWidget->metaObject()->indexOfSignal("PropertiesChanged()") != -1; + AZ_Error( + "Audio", widgetHasChangedSignal, + "The widget created by IAudioSystemEditor::CreateConnectionPropertiesWidget() must have a \"PropertiesChanged()\" " + "signal."); + + if (widgetHasChangedSignal) + { + connect(m_connectionPropertiesWidget, SIGNAL(PropertiesChanged()), this, SLOT(CurrentConnectionModified())); + } + } + } + } + } + //-------------------------------------------------------------------------------------------// void QConnectionsWidget::MakeConnectionTo(IAudioSystemControl* middlewareControl) { diff --git a/Gems/AudioSystem/Code/Source/Editor/QConnectionsWidget.h b/Gems/AudioSystem/Code/Source/Editor/QConnectionsWidget.h index 2adb7c592d..d1181d74c2 100644 --- a/Gems/AudioSystem/Code/Source/Editor/QConnectionsWidget.h +++ b/Gems/AudioSystem/Code/Source/Editor/QConnectionsWidget.h @@ -40,6 +40,7 @@ namespace AudioControls void ShowConnectionContextMenu(const QPoint& pos); void CurrentConnectionModified(); void RemoveSelectedConnection(); + void SelectedConnectionChanged(); private: bool eventFilter(QObject* object, QEvent* event) override; @@ -50,6 +51,8 @@ namespace AudioControls CATLControl* m_control; QColor m_notFoundColor; QColor m_localizedColor; + + QWidget* m_connectionPropertiesWidget = nullptr; }; } // namespace AudioControls From 586f146a847ebfa875f70554baec9b317e4aacc0 Mon Sep 17 00:00:00 2001 From: John Jones-Steele <82226755+jjjoness@users.noreply.github.com> Date: Mon, 13 Dec 2021 17:56:46 +0000 Subject: [PATCH 28/70] Fixed nullptr error (#6386) Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com> --- .../AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp index 0b882324b5..056f16c52f 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp @@ -548,11 +548,11 @@ namespace AzToolsFramework AZ::EntityId entityId = GetEntityFromIndex(index); // Only allow renaming the entity if the UI Handler did not block it. - auto entityUiHandler = m_editorEntityUiInterface->GetHandler(entityId); + auto entityUiHandler = m_editorEntityUiInterface ? m_editorEntityUiInterface->GetHandler(entityId) : nullptr; bool canRename = !entityUiHandler || entityUiHandler->CanRename(entityId); // Disable renaming for read-only entities. - bool isReadOnly = m_readOnlyEntityPublicInterface->IsReadOnly(entityId); + bool isReadOnly = m_readOnlyEntityPublicInterface ? m_readOnlyEntityPublicInterface->IsReadOnly(entityId) : false; Qt::ItemFlags itemFlags = QAbstractItemModel::flags(index); switch (index.column()) From 0dfb8d42c42a0ce4fd67caf24da829fde541464f Mon Sep 17 00:00:00 2001 From: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> Date: Mon, 13 Dec 2021 10:10:04 -0800 Subject: [PATCH 29/70] Disable the ability to instantiate into closed prefabs, and to move the root prefab in focus mode. (#6320) * Disable "Move Up" and "Move Down" for focused prefab containers. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Disable the ability to instantiate prefabs inside closed prefab instances. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> * Minor comment fix. Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> --- .../UI/Outliner/EntityOutlinerWidget.cpp | 39 +++++--- .../UI/Outliner/EntityOutlinerWidget.hxx | 4 + .../UI/Prefab/PrefabIntegrationManager.cpp | 99 ++++++++++++------- .../UI/Prefab/PrefabIntegrationManager.h | 2 +- 4 files changed, 96 insertions(+), 48 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.cpp index 2e3955bed7..baf75eb978 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -154,9 +155,15 @@ namespace AzToolsFramework { initEntityOutlinerWidgetResources(); + AzToolsFramework::EditorEntityContextRequestBus::BroadcastResult( + m_editorEntityContextId, &AzToolsFramework::EditorEntityContextRequestBus::Events::GetEditorEntityContextId); + m_editorEntityUiInterface = AZ::Interface::Get(); AZ_Assert(m_editorEntityUiInterface != nullptr, "EntityOutlinerWidget requires a EditorEntityUiInterface instance on Initialize."); + m_focusModeInterface = AZ::Interface::Get(); + AZ_Assert(m_focusModeInterface != nullptr, "EntityOutlinerWidget requires a FocusModeInterface instance on Initialize."); + m_readOnlyEntityPublicInterface = AZ::Interface::Get(); AZ_Assert( (m_readOnlyEntityPublicInterface != nullptr), @@ -609,23 +616,27 @@ namespace AzToolsFramework { AZ::EntityId entityId = m_selectedEntityIds[0]; - AZ::EntityId parentId; - EditorEntityInfoRequestBus::EventResult(parentId, entityId, &EditorEntityInfoRequestBus::Events::GetParent); - - EntityOrderArray entityOrderArray = GetEntityChildOrder(parentId); - - if (entityOrderArray.size() > 1) + // Don't allow moving the entity if it's the focus root. + if (m_focusModeInterface->GetFocusRoot(m_editorEntityContextId) != entityId) { - if (AZStd::find(entityOrderArray.begin(), entityOrderArray.end(), entityId) != entityOrderArray.end()) - { - if (entityOrderArray.front() != entityId) - { - contextMenu->addAction(m_actionToMoveEntityUp); - } + AZ::EntityId parentId; + EditorEntityInfoRequestBus::EventResult(parentId, entityId, &EditorEntityInfoRequestBus::Events::GetParent); - if (entityOrderArray.back() != entityId) + EntityOrderArray entityOrderArray = GetEntityChildOrder(parentId); + + if (entityOrderArray.size() > 1) + { + if (AZStd::find(entityOrderArray.begin(), entityOrderArray.end(), entityId) != entityOrderArray.end()) { - contextMenu->addAction(m_actionToMoveEntityDown); + if (entityOrderArray.front() != entityId) + { + contextMenu->addAction(m_actionToMoveEntityUp); + } + + if (entityOrderArray.back() != entityId) + { + contextMenu->addAction(m_actionToMoveEntityDown); + } } } } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.hxx b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.hxx index b0925b5219..e6c42fa64e 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.hxx +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerWidget.hxx @@ -43,6 +43,7 @@ namespace AzToolsFramework class EntityOutlinerListModel; class EntityOutlinerContainerProxyModel; class EntityOutlinerSortFilterProxyModel; + class FocusModeInterface; class ReadOnlyEntityPublicInterface; namespace EntityOutliner @@ -204,7 +205,10 @@ namespace AzToolsFramework EntityOutliner::DisplaySortMode m_sortMode; bool m_sortContentQueued; + AzFramework::EntityContextId m_editorEntityContextId = AzFramework::EntityContextId::CreateNull(); + EditorEntityUiInterface* m_editorEntityUiInterface = nullptr; + FocusModeInterface* m_focusModeInterface = nullptr; ReadOnlyEntityPublicInterface* m_readOnlyEntityPublicInterface = nullptr; }; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/PrefabIntegrationManager.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/PrefabIntegrationManager.cpp index 05d9f15b77..bc65b9088b 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/PrefabIntegrationManager.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/PrefabIntegrationManager.cpp @@ -277,6 +277,26 @@ namespace AzToolsFramework } } + bool onlySelectedEntityIsFocusedPrefabContainer = false; + bool onlySelectedEntityIsClosedPrefabContainer = false; + + if (selectedEntities.size() == 1) + { + AZ::EntityId selectedEntity = selectedEntities.front(); + + if (s_prefabPublicInterface->IsInstanceContainerEntity(selectedEntity)) + { + if (s_prefabFocusPublicInterface->IsOwningPrefabBeingFocused(selectedEntity)) + { + onlySelectedEntityIsFocusedPrefabContainer = true; + } + else + { + onlySelectedEntityIsClosedPrefabContainer = true; + } + } + } + bool itemWasShown = false; // Create Prefab @@ -284,8 +304,7 @@ namespace AzToolsFramework if (!selectedEntities.empty()) { // Hide if the only selected entity is the Focused Instance Container - if (selectedEntities.size() > 1 || - selectedEntities[0] != s_prefabFocusPublicInterface->GetFocusedPrefabContainerEntityId(s_editorEntityContextId)) + if (!onlySelectedEntityIsFocusedPrefabContainer) { bool layerInSelection = false; @@ -322,7 +341,7 @@ namespace AzToolsFramework } // Instantiate Prefab - if (!readOnlyEntityInSelection) + if (selectedEntities.size() == 1 && !readOnlyEntityInSelection && !onlySelectedEntityIsClosedPrefabContainer) { QAction* instantiateAction = menu->addAction(QObject::tr("Instantiate Prefab...")); instantiateAction->setToolTip(QObject::tr("Instantiates a prefab file in the scene.")); @@ -330,17 +349,15 @@ namespace AzToolsFramework QObject::connect( instantiateAction, &QAction::triggered, instantiateAction, [] { ContextMenu_InstantiatePrefab(); }); - itemWasShown = true; - } + // Instantiate Procedural Prefab + if (AZ::Prefab::ProceduralPrefabAsset::UseProceduralPrefabs()) + { + QAction* action = menu->addAction(QObject::tr("Instantiate Procedural Prefab...")); + action->setToolTip(QObject::tr("Instantiates a procedural prefab file in a prefab.")); - // Instantiate Procedural Prefab - if (AZ::Prefab::ProceduralPrefabAsset::UseProceduralPrefabs() && !readOnlyEntityInSelection) - { - QAction* action = menu->addAction(QObject::tr("Instantiate Procedural Prefab...")); - action->setToolTip(QObject::tr("Instantiates a procedural prefab file in a prefab.")); - - QObject::connect( - action, &QAction::triggered, action, [] { ContextMenu_InstantiateProceduralPrefab(); }); + QObject::connect( + action, &QAction::triggered, action, [] { ContextMenu_InstantiateProceduralPrefab(); }); + } itemWasShown = true; } @@ -362,14 +379,34 @@ namespace AzToolsFramework { if (!s_prefabFocusPublicInterface->IsOwningPrefabBeingFocused(selectedEntity)) { - // Edit Prefab - QAction* editAction = menu->addAction(QObject::tr("Open/Edit Prefab")); - editAction->setShortcut(QKeySequence(Qt::Key_Plus)); - editAction->setToolTip(QObject::tr("Edit the prefab in focus mode.")); + if (s_prefabPublicInterface->IsOwnedByProceduralPrefabInstance(selectedEntity)) + { + // Inspect Prefab + QAction* editAction = menu->addAction(QObject::tr("Inspect Procedural Prefab")); + editAction->setShortcut(QKeySequence(Qt::Key_Plus)); + editAction->setToolTip(QObject::tr("See the procedural prefab contents in focus mode.")); - QObject::connect(editAction, &QAction::triggered, editAction, [selectedEntity] { - ContextMenu_EditPrefab(selectedEntity); - }); + QObject::connect( + editAction, &QAction::triggered, editAction, + [selectedEntity] + { + ContextMenu_EditPrefab(selectedEntity); + }); + } + else + { + // Edit Prefab + QAction* editAction = menu->addAction(QObject::tr("Open/Edit Prefab")); + editAction->setShortcut(QKeySequence(Qt::Key_Plus)); + editAction->setToolTip(QObject::tr("Edit the prefab in focus mode.")); + + QObject::connect( + editAction, &QAction::triggered, editAction, + [selectedEntity] + { + ContextMenu_EditPrefab(selectedEntity); + }); + } } else { @@ -420,21 +457,17 @@ namespace AzToolsFramework } // Detach Prefab - if (selectedEntities.size() == 1) + if (onlySelectedEntityIsClosedPrefabContainer) { - AZ::EntityId selectedEntityId = selectedEntities[0]; + AZ::EntityId selectedEntityId = selectedEntities.front(); - if (s_prefabPublicInterface->IsInstanceContainerEntity(selectedEntityId) && - selectedEntityId != s_prefabFocusPublicInterface->GetFocusedPrefabContainerEntityId(s_editorEntityContextId)) - { - QAction* detachPrefabAction = menu->addAction(QObject::tr("Detach Prefab...")); - QObject::connect( - detachPrefabAction, &QAction::triggered, detachPrefabAction, - [selectedEntityId] - { - ContextMenu_DetachPrefab(selectedEntityId); - }); - } + QAction* detachPrefabAction = menu->addAction(QObject::tr("Detach Prefab...")); + QObject::connect( + detachPrefabAction, &QAction::triggered, detachPrefabAction, + [selectedEntityId] + { + ContextMenu_DetachPrefab(selectedEntityId); + }); } } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/PrefabIntegrationManager.h b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/PrefabIntegrationManager.h index 12aa3f7c72..800873349a 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/PrefabIntegrationManager.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/PrefabIntegrationManager.h @@ -75,7 +75,7 @@ namespace AzToolsFramework void PopulateEditorGlobalContextMenu(QMenu* menu, const AZ::Vector2& point, int flags) override; // EditorEventsBus overrides ... - void OnEscape(); + void OnEscape() override; // EntityOutlinerSourceDropHandlingBus overrides ... void HandleSourceFileType(AZStd::string_view sourceFilePath, AZ::EntityId parentId, AZ::Vector3 position) const override; From da8967d570607a32d5bd6ce9381754111ff27f03 Mon Sep 17 00:00:00 2001 From: dmcdiarmid-ly <63674186+dmcdiarmid-ly@users.noreply.github.com> Date: Mon, 13 Dec 2021 12:03:40 -0700 Subject: [PATCH 30/70] Minor change to comments Signed-off-by: dmcdiarmid-ly <63674186+dmcdiarmid-ly@users.noreply.github.com> --- Gems/Atom/RHI/Vulkan/Code/Source/RHI/Conversion.cpp | 4 ++-- Gems/Atom/RHI/Vulkan/Code/Source/RHI/DescriptorSet.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/Conversion.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/Conversion.cpp index 51915ba5a6..756ed5f768 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/Conversion.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/Conversion.cpp @@ -1155,8 +1155,7 @@ namespace AZ case RHI::ScopeAttachmentUsage::Shader: case RHI::ScopeAttachmentUsage::SubpassInput: { - // If we are reading from a depth/stencil texture, then we use the depth/stencil read optimal layout instead of the generic shader read one. - // Note that if the Image is ShaderWrite we always set VK_IMAGE_LAYOUT_GENERAL, even in a read scope. + // always set VK_IMAGE_LAYOUT_GENERAL if the Image is ShaderWrite, even in a read scope if (RHI::CheckBitsAny(usagesAndAccesses.front().m_access, RHI::ScopeAttachmentAccess::Write) || RHI::CheckBitsAny(imageView->GetImage().GetDescriptor().m_bindFlags, RHI::ImageBindFlags::ShaderWrite)) { @@ -1164,6 +1163,7 @@ namespace AZ } else { + // if we are reading from a depth/stencil texture, then we use the depth/stencil read optimal layout instead of the generic shader read one return RHI::CheckBitsAny(imageAspects, RHI::ImageAspectFlags::DepthStencil) ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL : VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; } diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/DescriptorSet.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/DescriptorSet.cpp index c6fe233282..815eba086c 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/DescriptorSet.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/DescriptorSet.cpp @@ -149,8 +149,7 @@ namespace AZ { imageInfo.imageView = imageView->GetNativeImageView(); - // If we are reading from a depth/stencil texture, then we use the depth/stencil read optimal layout instead of the generic shader read one. - // Note that if the Image is ShaderWrite we always set VK_IMAGE_LAYOUT_GENERAL, even if the descriptor layout wants a read-only input. + // always set VK_IMAGE_LAYOUT_GENERAL if the Image is ShaderWrite, even if the descriptor layout wants a read-only input if (layout.GetDescriptorType(layoutIndex) == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE || RHI::CheckBitsAny(imageView->GetImage().GetDescriptor().m_bindFlags, RHI::ImageBindFlags::ShaderWrite)) { @@ -158,6 +157,7 @@ namespace AZ } else { + // if we are reading from a depth/stencil texture, then we use the depth/stencil read optimal layout instead of the generic shader read one imageInfo.imageLayout = RHI::CheckBitsAny(imageView->GetImage().GetAspectFlags(), RHI::ImageAspectFlags::DepthStencil) ? VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL : VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; } From 45abb9f88e10350bf26ef174eb55b42bc6e2a92b Mon Sep 17 00:00:00 2001 From: amzn-mike <80125227+amzn-mike@users.noreply.github.com> Date: Mon, 13 Dec 2021 13:52:03 -0600 Subject: [PATCH 31/70] Proc Prefabs: Remove feature toggle (#6348) * Disable feature flag - redirect proc prefab check to IsPrefabSystemEnabled. Procedural Prefabs are now on by default when the prefab system is enabled. Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> * Bump scene builder version to cause all procedural prefabs to rebuild Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> * Switch to lambda for ebus call Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> * Remove unused const Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> --- .../Prefab/Procedural/ProceduralPrefabAsset.cpp | 14 +++++++++----- .../Source/SceneBuilder/SceneBuilderWorker.cpp | 16 ++++++++-------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Procedural/ProceduralPrefabAsset.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Procedural/ProceduralPrefabAsset.cpp index 465d83e94b..2b85720b56 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Procedural/ProceduralPrefabAsset.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Procedural/ProceduralPrefabAsset.cpp @@ -9,12 +9,11 @@ #include #include #include +#include #include namespace AZ::Prefab { - static constexpr const char s_useProceduralPrefabsKey[] = "/O3DE/Preferences/Prefabs/UseProceduralPrefabs"; - // ProceduralPrefabAsset ProceduralPrefabAsset::ProceduralPrefabAsset(const AZ::Data::AssetId& assetId) @@ -58,9 +57,14 @@ namespace AZ::Prefab bool ProceduralPrefabAsset::UseProceduralPrefabs() { - bool useProceduralPrefabs = false; - bool result = AZ::SettingsRegistry::Get()->GetObject(useProceduralPrefabs, s_useProceduralPrefabsKey); - return result && useProceduralPrefabs; + bool prefabsEnabled = false; + AzFramework::ApplicationRequests::Bus::Broadcast( + [&prefabsEnabled](AzFramework::ApplicationRequests::Bus::Events* ebus) + { + prefabsEnabled = ebus->IsPrefabSystemEnabled(); + }); + + return prefabsEnabled; } // PrefabDomData diff --git a/Gems/SceneProcessing/Code/Source/SceneBuilder/SceneBuilderWorker.cpp b/Gems/SceneProcessing/Code/Source/SceneBuilder/SceneBuilderWorker.cpp index 1d3cd60e49..c4300fc34d 100644 --- a/Gems/SceneProcessing/Code/Source/SceneBuilder/SceneBuilderWorker.cpp +++ b/Gems/SceneProcessing/Code/Source/SceneBuilder/SceneBuilderWorker.cpp @@ -71,7 +71,7 @@ namespace SceneBuilder context->EnumerateDerived(callback, azrtti_typeid(), azrtti_typeid()); context->EnumerateDerived(callback, azrtti_typeid(), azrtti_typeid()); } - + AZ::SceneAPI::SceneBuilderDependencyBus::Broadcast(&AZ::SceneAPI::SceneBuilderDependencyRequests::AddFingerprintInfo, fragments); for (const AZStd::string& element : fragments) @@ -79,7 +79,7 @@ namespace SceneBuilder m_cachedFingerprint.append(element); } // A general catch all version fingerprint. Update this to force all FBX files to recompile. - m_cachedFingerprint.append("Version 1"); + m_cachedFingerprint.append("Version 2"); } return m_cachedFingerprint.c_str(); @@ -223,7 +223,7 @@ namespace SceneBuilder // Only used during processing to redirect trace printfs with an warning or error window to the appropriate reporting function. TraceMessageHook messageHook; - + // Load Scene graph and manifest from the provided path and then initialize them. if (m_isShuttingDown) { @@ -282,9 +282,9 @@ namespace SceneBuilder } for (const AZStd::string& pathDependency : exportProduct.m_legacyPathDependencies) { - // SceneCore doesn't have access to AssetBuilderSDK, so it doesn't have access to the + // SceneCore doesn't have access to AssetBuilderSDK, so it doesn't have access to the // ProductPathDependency type or the ProductPathDependencyType enum. Exporters registered with the - // Scene Builder should report path dependencies on source files as absolute paths, while dependencies + // Scene Builder should report path dependencies on source files as absolute paths, while dependencies // on product files should be reported as relative paths. if (AzFramework::StringFunc::Path::IsRelative(pathDependency.c_str())) { @@ -314,7 +314,7 @@ namespace SceneBuilder using namespace AZ::SceneAPI; using namespace AZ::SceneAPI::Containers; using namespace AZ::SceneAPI::Events; - + AZ_TracePrintf(Utilities::LogWindow, "Loading scene.\n"); SceneSerializationBus::BroadcastResult(result, &SceneSerializationBus::Events::LoadScene, request.m_fullPath, request.m_sourceFileUUID); @@ -331,7 +331,7 @@ namespace SceneBuilder response.m_resultCode = AssetBuilderSDK::ProcessJobResult_Success; return false; // Still return false as there's no work so should exit. } - + return true; } @@ -379,7 +379,7 @@ namespace SceneBuilder using namespace AZ::SceneAPI::SceneCore; AZ_Assert(scene, "Invalid scene passed for exporting."); - + const AZStd::string& outputFolder = request.m_tempDirPath; const char* platformIdentifier = request.m_jobDescription.GetPlatformIdentifier().c_str(); AZ_TraceContext("Output folder", outputFolder.c_str()); From 71bb200e0a67d3303005ea18067f63c0cb2a40dd Mon Sep 17 00:00:00 2001 From: amzn-mike <80125227+amzn-mike@users.noreply.github.com> Date: Mon, 13 Dec 2021 14:44:41 -0600 Subject: [PATCH 32/70] [LYN-7064] Hot Loading of Procedural Prefabs (#4923) * Prefab hotloading - load and maintain asset references Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> * Working hotloading Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> * Clean up code, add comments Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> * Add missing includes Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> * Add event for template removal. Clear ProceduralPrefabSystemComponent lookup when templates are removed. Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> * Add unit test. Fix missing include, make sure source name is set Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> * Fix missing include Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> * Fix missing include Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> * Update comments to make ebus event behavior more clear Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> * Fix missing include Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> * Fix missing includes Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> * Fix missing include Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> * Fix temp directory usage which doesn't work on linux Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> * Fix temp directory usage which doesn't work on linux Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> * Use AZ::IO::Path for comparison. Print paths on failure Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> * Fix unit test - register asset with catalog so it can be looked up later Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> --- .../AzCore/AzCore/UnitTest/UnitTest.h | 9 + .../Application/ToolsApplication.cpp | 2 + .../AzToolsFrameworkModule.cpp | 2 + .../AzToolsFramework/Prefab/PrefabLoader.cpp | 15 + .../Prefab/PrefabPublicNotificationBus.h | 8 + .../Prefab/PrefabSystemComponent.cpp | 22 +- .../Prefab/PrefabSystemComponent.h | 19 +- .../ProceduralPrefabSystemComponent.cpp | 143 +++++++++ .../Prefab/ProceduralPrefabSystemComponent.h | 47 +++ ...ProceduralPrefabSystemComponentInterface.h | 31 ++ .../aztoolsframework_files.cmake | 3 + .../ProceduralPrefabSystemComponentTests.cpp | 302 ++++++++++++++++++ .../Tests/aztoolsframeworktests_files.cmake | 1 + .../PrefabGroup/PrefabBehaviorTests.cpp | 6 + 14 files changed, 595 insertions(+), 15 deletions(-) create mode 100644 Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/ProceduralPrefabSystemComponent.cpp create mode 100644 Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/ProceduralPrefabSystemComponent.h create mode 100644 Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/ProceduralPrefabSystemComponentInterface.h create mode 100644 Code/Framework/AzToolsFramework/Tests/Prefab/ProceduralPrefabSystemComponentTests.cpp diff --git a/Code/Framework/AzCore/AzCore/UnitTest/UnitTest.h b/Code/Framework/AzCore/AzCore/UnitTest/UnitTest.h index be9199b6c4..1dae089d5c 100644 --- a/Code/Framework/AzCore/AzCore/UnitTest/UnitTest.h +++ b/Code/Framework/AzCore/AzCore/UnitTest/UnitTest.h @@ -69,6 +69,15 @@ namespace UnitTest return numAssertsFailed; } + void ResetSuppressionSettingsToDefault() + { + m_suppressErrors = true; + m_suppressWarnings = true; + m_suppressAsserts = true; + m_suppressOutput = true; + m_suppressPrintf = true; + } + bool m_isAssertTest; bool m_suppressErrors = true; bool m_suppressWarnings = true; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Application/ToolsApplication.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Application/ToolsApplication.cpp index 6c69fc04da..f9e79cb491 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Application/ToolsApplication.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Application/ToolsApplication.cpp @@ -73,6 +73,7 @@ #include #include #include +#include #include AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") // 4251: 'QFileInfo::d_ptr': class 'QSharedDataPointer' needs to have dll-interface to be used by clients of class 'QFileInfo' @@ -272,6 +273,7 @@ namespace AzToolsFramework azrtti_typeid(), azrtti_typeid(), azrtti_typeid(), + azrtti_typeid(), azrtti_typeid(), azrtti_typeid(), azrtti_typeid(), diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AzToolsFrameworkModule.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AzToolsFrameworkModule.cpp index dd1ac12a02..d1429e158f 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AzToolsFrameworkModule.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AzToolsFrameworkModule.cpp @@ -56,6 +56,7 @@ #include #include #include +#include AZ_DEFINE_BUDGET(AzToolsFramework); @@ -82,6 +83,7 @@ namespace AzToolsFramework SliceRequestComponent::CreateDescriptor(), Prefab::PrefabSystemComponent::CreateDescriptor(), Prefab::EditorPrefabComponent::CreateDescriptor(), + Prefab::ProceduralPrefabSystemComponent::CreateDescriptor(), Components::EditorEntityActionComponent::CreateDescriptor(), Components::EditorEntityIconComponent::CreateDescriptor(), Components::EditorInspectorComponent::CreateDescriptor(), diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabLoader.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabLoader.cpp index 07bda45c8a..d0b057d45b 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabLoader.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabLoader.cpp @@ -21,6 +21,7 @@ #include #include #include +#include namespace AzToolsFramework { @@ -185,6 +186,20 @@ namespace AzToolsFramework TemplateReference newTemplateReference = m_prefabSystemComponentInterface->FindTemplate(newTemplateId); Template& newTemplate = newTemplateReference->get(); + if(newTemplate.IsProcedural()) + { + auto proceduralPrefabSystemComponentInterface = AZ::Interface::Get(); + + if (!proceduralPrefabSystemComponentInterface) + { + AZ_Error("Prefab", false, "Failed to find ProceduralPrefabSystemComponentInterface. Procedural Prefab will not be tracked for hotloading."); + } + else + { + proceduralPrefabSystemComponentInterface->RegisterProceduralPrefab(relativePath.Native(), newTemplateId); + } + } + // Mark the file as being in progress. progressedFilePathsSet.emplace(relativePath); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicNotificationBus.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicNotificationBus.h index 8b0d446f51..6145068a5f 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicNotificationBus.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicNotificationBus.h @@ -26,6 +26,14 @@ namespace AzToolsFramework virtual void OnPrefabTemplateDirtyFlagUpdated( [[maybe_unused]] TemplateId templateId, [[maybe_unused]] bool status) {} + + // Sent after a single template has been removed + // Does not get sent when all templates are being removed at once. Be sure to handle OnAllTemplatesRemoved as well. + virtual void OnTemplateRemoved([[maybe_unused]] TemplateId templateId) {} + + // Sent after all templates have been removed + // Does not trigger individual OnTemplateRemoved events + virtual void OnAllTemplatesRemoved() {} }; using PrefabPublicNotificationBus = AZ::EBus; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabSystemComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabSystemComponent.cpp index ed16606413..9936e466c3 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabSystemComponent.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabSystemComponent.cpp @@ -160,7 +160,7 @@ namespace AzToolsFramework newInstance->SetTemplateId(newTemplateId); } } - + void PrefabSystemComponent::PropagateTemplateChanges(TemplateId templateId, InstanceOptionalConstReference instanceToExclude) { auto templateIdToLinkIdsIterator = m_templateToLinkIdsMap.find(templateId); @@ -442,7 +442,7 @@ namespace AzToolsFramework } m_templateFilePathToIdMap.emplace(AZStd::make_pair(filePath, newTemplateId)); - + return newTemplateId; } @@ -469,7 +469,7 @@ namespace AzToolsFramework { return; } - + m_templateFilePathToIdMap.erase(templateToChange.GetFilePath()); if (!m_templateFilePathToIdMap.try_emplace(filePath, templateId).second) { @@ -500,7 +500,7 @@ namespace AzToolsFramework return; } - + //Remove all Links owned by the Template from TemplateToLinkIdsMap. Template& templateToDelete = findTemplateResult->get(); const Template::Links& linkIdsToDelete = templateToDelete.GetLinks(); @@ -546,7 +546,7 @@ namespace AzToolsFramework templateId, templateToDelete.GetFilePath().c_str()); m_templateInstanceMapper.UnregisterTemplate(templateId); - + result = m_templateIdMap.erase(templateId) != 0; AZ_Assert(result, "Prefab - PrefabSystemComponent::RemoveTemplate - " @@ -554,7 +554,10 @@ namespace AzToolsFramework "from Template Id Map.", templateId, templateToDelete.GetFilePath().c_str()); - return; + if (!m_removingAllTemplates) + { + PrefabPublicNotificationBus::Broadcast(&PrefabPublicNotificationBus::Events::OnTemplateRemoved, templateId); + } } void PrefabSystemComponent::RemoveAllTemplates() @@ -568,10 +571,15 @@ namespace AzToolsFramework templateIds.emplace_back(id); } + m_removingAllTemplates = true; + for (auto id : templateIds) { RemoveTemplate(id); } + + m_removingAllTemplates = false; + PrefabPublicNotificationBus::Broadcast(&PrefabPublicNotificationBus::Events::OnAllTemplatesRemoved); } LinkId PrefabSystemComponent::AddLink( @@ -859,7 +867,7 @@ namespace AzToolsFramework void PrefabSystemComponent::SaveAllDirtyTemplates(TemplateId rootTemplateId) { - AZStd::set dirtyTemplatePaths = GetDirtyTemplatePaths(rootTemplateId); + AZStd::set dirtyTemplatePaths = GetDirtyTemplatePaths(rootTemplateId); for (AZ::IO::PathView dirtyTemplatePath : dirtyTemplatePaths) { diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabSystemComponent.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabSystemComponent.h index 99efaa89d6..d71065f8fc 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabSystemComponent.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabSystemComponent.h @@ -56,7 +56,7 @@ namespace AzToolsFramework public: using TargetTemplateIdToLinkIdMap = AZStd::unordered_map, bool>>; - + AZ_COMPONENT(PrefabSystemComponent, "{27203AE6-A398-4614-881B-4EEB5E9B34E9}"); PrefabSystemComponent() = default; @@ -220,7 +220,7 @@ namespace AzToolsFramework const AZStd::vector& entities, AZStd::vector>&& instancesToConsume, AZ::IO::PathView filePath, AZStd::unique_ptr containerEntity = nullptr, InstanceOptionalReference parent = AZStd::nullopt, bool shouldCreateLinks = true) override; - + PrefabDom& FindTemplateDom(TemplateId templateId) override; /** @@ -244,7 +244,7 @@ namespace AzToolsFramework private: AZ_DISABLE_COPY_MOVE(PrefabSystemComponent); - + /** * Builds a new Prefab Template out of entities and instances and returns the first instance comprised of * these entities and instances. @@ -263,14 +263,14 @@ namespace AzToolsFramework /** * Updates all the linked Instances corresponding to the linkIds in the provided queue. * Queue gets populated with more linkId lists as linked instances are updated. Updating stops when the queue is empty. - * + * * @param linkIdsQueue A queue of vector of link-Ids to update. */ void UpdateLinkedInstances(AZStd::queue& linkIdsQueue); /** * Given a vector of link ids to update, splits them into smaller lists based on the target template id of the links. - * + * * @param linkIdsToUpdate The list of link ids to update. * @param targetTemplateIdToLinkIdMap The map of target templateIds to a pair of lists of linkIds and a bool flag indicating * whether any of the instances of the target template were updated. @@ -279,9 +279,9 @@ namespace AzToolsFramework TargetTemplateIdToLinkIdMap& targetTemplateIdToLinkIdMap); /** - * Updates a single linked instance corresponding to the given link Id and adds more linkIds to the + * Updates a single linked instance corresponding to the given link Id and adds more linkIds to the * template change propagation queue(linkIdsQueue) when necessary. - * + * * @param linkIdToUpdate The id of the linked instance to update * @param targetTemplateIdToLinkIdMap The map of target templateIds to a pair of lists of linkIds and a bool flag indicating * whether any of the instances of the target template were updated. @@ -293,7 +293,7 @@ namespace AzToolsFramework /** * If all linked instances of a target template are updated and if the content of any of the linked instances changed, * this method fetches all the linked instances sourced by it and adds their corresponding ids to the LinkIdsQueue. - * + * * @param targetTemplateIdToLinkIdMap The map of target templateIds to a pair of lists of linkIds and a bool flag indicating * whether any of the instances of the target template were updated. * @param targetTemplateId The id of the template, whose linked instances we need to find if the template was updated. @@ -414,6 +414,9 @@ namespace AzToolsFramework PrefabPublicRequestHandler m_prefabPublicRequestHandler; PrefabSystemScriptingHandler m_prefabSystemScriptingHandler; + + // If true, individual template-remove messages will be suppressed + bool m_removingAllTemplates = false; }; } // namespace Prefab } // namespace AzToolsFramework diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/ProceduralPrefabSystemComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/ProceduralPrefabSystemComponent.cpp new file mode 100644 index 0000000000..8eeee4b28f --- /dev/null +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/ProceduralPrefabSystemComponent.cpp @@ -0,0 +1,143 @@ +/* + * 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 + +namespace AzToolsFramework +{ + namespace Prefab + { + void ProceduralPrefabSystemComponent::Reflect(AZ::ReflectContext* context) + { + if (auto serializationContext = azrtti_cast(context)) + { + serializationContext->Class(); + } + } + + void ProceduralPrefabSystemComponent::Activate() + { + AZ::Interface::Register(this); + AzFramework::AssetCatalogEventBus::Handler::BusConnect(); + } + + void ProceduralPrefabSystemComponent::Deactivate() + { + AzFramework::AssetCatalogEventBus::Handler::BusDisconnect(); + AZ::Interface::Unregister(this); + + AZStd::scoped_lock lock(m_lookupMutex); + m_assetIdToTemplateLookup.clear(); + } + + void ProceduralPrefabSystemComponent::OnCatalogAssetChanged(const AZ::Data::AssetId& assetId) + { + TemplateId templateId = InvalidTemplateId; + + { + AZStd::scoped_lock lock(m_lookupMutex); + auto itr = m_assetIdToTemplateLookup.find(assetId); + + if (itr != m_assetIdToTemplateLookup.end()) + { + templateId = itr->second; + } + } + + if (templateId != InvalidTemplateId) + { + auto prefabSystemComponentInterface = AZ::Interface::Get(); + + if (!prefabSystemComponentInterface) + { + AZ_Error("Prefab", false, "Failed to get PrefabSystemComponentInterface"); + return; + } + + AZStd::string assetPath; + AZ::Data::AssetCatalogRequestBus::BroadcastResult( + assetPath, &AZ::Data::AssetCatalogRequestBus::Events::GetAssetPathById, assetId); + + auto readResult = AZ::Utils::ReadFile(assetPath, AZStd::numeric_limits::max()); + if (!readResult.IsSuccess()) + { + AZ_Error( + "Prefab", false, + "ProceduralPrefabSystemComponent::OnCatalogAssetChanged - Failed to read Prefab file from '%.*s'." + "Error message: '%s'", + AZ_STRING_ARG(assetPath), readResult.GetError().c_str()); + return; + } + + AZ::Outcome readPrefabFileResult = AZ::JsonSerializationUtils::ReadJsonString(readResult.TakeValue()); + if (!readPrefabFileResult.IsSuccess()) + { + AZ_Error( + "Prefab", false, + "ProceduralPrefabSystemComponent::OnCatalogAssetChanged - Failed to read Prefab json from '%.*s'." + "Error message: '%s'", + AZ_STRING_ARG(assetPath), readPrefabFileResult.GetError().c_str()); + return; + } + + AZ::IO::Path relativePath = AZ::Interface::Get()->GenerateRelativePath(assetPath.c_str()); + PrefabDomPath sourcePath = PrefabDomPath((AZStd::string("/") + PrefabDomUtils::SourceName).c_str()); + sourcePath.Set(readPrefabFileResult.GetValue(), relativePath.Native().c_str()); + + prefabSystemComponentInterface->UpdatePrefabTemplate(templateId, readPrefabFileResult.TakeValue()); + } + } + + void ProceduralPrefabSystemComponent::OnTemplateRemoved(TemplateId removedTemplateId) + { + AZStd::scoped_lock lock(m_lookupMutex); + + for (const auto& [assetId, templateId] : m_assetIdToTemplateLookup) + { + if (templateId == removedTemplateId) + { + m_assetIdToTemplateLookup.erase(assetId); + break; + } + } + } + + void ProceduralPrefabSystemComponent::OnAllTemplatesRemoved() + { + AZStd::scoped_lock lock(m_lookupMutex); + + m_assetIdToTemplateLookup.clear(); + } + + void ProceduralPrefabSystemComponent::RegisterProceduralPrefab(const AZStd::string& prefabFilePath, TemplateId templateId) + { + AZ::Data::AssetId assetId; + AZ::Data::AssetCatalogRequestBus::BroadcastResult( + assetId, &AZ::Data::AssetCatalogRequestBus::Events::GetAssetIdByPath, prefabFilePath.c_str(), + azrtti_typeid(), false); + + if (assetId.IsValid()) + { + AZStd::scoped_lock lock(m_lookupMutex); + m_assetIdToTemplateLookup[assetId] = templateId; + } + else + { + AZ_Error("Prefab", false, "Failed to find AssetId for prefab %s", prefabFilePath.c_str()); + } + } + } // namespace Prefab +} // namespace AzToolsFramework diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/ProceduralPrefabSystemComponent.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/ProceduralPrefabSystemComponent.h new file mode 100644 index 0000000000..92c9ac0267 --- /dev/null +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/ProceduralPrefabSystemComponent.h @@ -0,0 +1,47 @@ +/* + * 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 + * + */ + +#pragma once + +#include +#include +#include +#include + +namespace AzToolsFramework +{ + namespace Prefab + { + class ProceduralPrefabSystemComponent + : public AZ::Component + , ProceduralPrefabSystemComponentInterface + , AzFramework::AssetCatalogEventBus::Handler + , PrefabPublicNotificationBus::Handler + { + public: + AZ_COMPONENT(ProceduralPrefabSystemComponent, "{81211818-088A-49E6-894B-7A11764106B1}"); + + static void Reflect(AZ::ReflectContext* context); + + protected: + void Activate() override; + void Deactivate() override; + + void OnCatalogAssetChanged(const AZ::Data::AssetId&) override; + + void OnTemplateRemoved(TemplateId templateId) override; + void OnAllTemplatesRemoved() override; + + void RegisterProceduralPrefab(const AZStd::string& prefabFilePath, TemplateId templateId) override; + + AZStd::mutex m_lookupMutex; + AZStd::unordered_map m_assetIdToTemplateLookup; + }; + } // namespace Prefab +} // namespace AzToolsFramework + diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/ProceduralPrefabSystemComponentInterface.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/ProceduralPrefabSystemComponentInterface.h new file mode 100644 index 0000000000..3c2c241261 --- /dev/null +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/ProceduralPrefabSystemComponentInterface.h @@ -0,0 +1,31 @@ +/* + * 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 + * + */ + +#pragma once + +#include +#include + +namespace AzToolsFramework +{ + namespace Prefab + { + class ProceduralPrefabSystemComponentInterface + { + public: + AZ_RTTI(ProceduralPrefabSystemComponentInterface, "{C403B89C-63DD-418C-B821-FBCBE1EF42AE}"); + + virtual ~ProceduralPrefabSystemComponentInterface() = default; + + // Registers a procedural prefab file + templateId so the system can track changes and handle updates + virtual void RegisterProceduralPrefab(const AZStd::string& prefabFilePath, TemplateId templateId) = 0; + }; + + } // namespace Prefab +} // namespace AzToolsFramework + diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake b/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake index 2744ec3951..2c25cc9222 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake @@ -670,6 +670,9 @@ set(FILES Prefab/PrefabSystemComponent.h Prefab/PrefabSystemComponent.cpp Prefab/PrefabSystemComponentInterface.h + Prefab/ProceduralPrefabSystemComponent.h + Prefab/ProceduralPrefabSystemComponent.cpp + Prefab/ProceduralPrefabSystemComponentInterface.h Prefab/PrefabSystemScriptingBus.h Prefab/PrefabSystemScriptingHandler.h Prefab/PrefabSystemScriptingHandler.cpp diff --git a/Code/Framework/AzToolsFramework/Tests/Prefab/ProceduralPrefabSystemComponentTests.cpp b/Code/Framework/AzToolsFramework/Tests/Prefab/ProceduralPrefabSystemComponentTests.cpp new file mode 100644 index 0000000000..e2c650f50b --- /dev/null +++ b/Code/Framework/AzToolsFramework/Tests/Prefab/ProceduralPrefabSystemComponentTests.cpp @@ -0,0 +1,302 @@ +/* + * 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 + +namespace UnitTest +{ + struct ProceduralPrefabSystemComponentTests + : AllocatorsTestFixture + , AZ::ComponentApplicationBus::Handler + { + void SetUp() override + { + TestRunner::Instance().m_suppressOutput = false; + TestRunner::Instance().m_suppressPrintf = false; + TestRunner::Instance().m_suppressWarnings = false; + TestRunner::Instance().m_suppressErrors = false; + TestRunner::Instance().m_suppressAsserts = false; + + AllocatorsTestFixture::SetUp(); + + AZ::ComponentApplicationBus::Handler::BusConnect(); + + ASSERT_TRUE(m_temporaryDirectory.IsValid()); + + m_localFileIo = AZStd::make_unique(); + + m_prevIoBase = AZ::IO::FileIOBase::GetInstance(); + AZ::IO::FileIOBase::SetInstance(nullptr); // Need to clear the previous instance first + AZ::IO::FileIOBase::SetInstance(m_localFileIo.get()); + + AZ::JsonSystemComponent::Reflect(&m_jsonContext); + + m_settingsRegistry = AZStd::make_unique(); + AZ::SettingsRegistry::Register(m_settingsRegistry.get()); + + m_settingsRegistry->Set(AZ::SettingsRegistryMergeUtils::FilePathKey_ProjectPath, m_temporaryDirectory.GetDirectory()); + + m_prefabSystem = PrefabSystemComponent::CreateDescriptor(); + m_procSystem = ProceduralPrefabSystemComponent::CreateDescriptor(); + + m_prefabSystem->Reflect(&m_context); + m_prefabSystem->Reflect(&m_jsonContext); + m_procSystem->Reflect(&m_context); + m_procSystem->Reflect(&m_jsonContext); + + AZ::Entity::Reflect(&m_context); + AZ::Entity::Reflect(&m_jsonContext); + AZ::IO::PathReflect(&m_context); + + m_systemEntity = AZStd::make_unique(); + m_systemEntity->CreateComponent(); + m_systemEntity->CreateComponent(); + + m_systemEntity->Init(); + m_systemEntity->Activate(); + + AZ::Data::AssetManager::Create({}); + } + + void TearDown() override + { + AZ::Data::AssetManager::Destroy(); + + m_systemEntity->Deactivate(); + m_systemEntity = nullptr; + + m_jsonContext.EnableRemoveReflection(); + AZ::JsonSystemComponent::Reflect(&m_jsonContext); + m_prefabSystem->Reflect(&m_jsonContext); + m_procSystem->Reflect(&m_jsonContext); + AZ::Entity::Reflect(&m_jsonContext); + m_jsonContext.DisableRemoveReflection(); + + AZ::IO::FileIOBase::SetInstance(nullptr); // Clear the previous instance first + AZ::IO::FileIOBase::SetInstance(m_prevIoBase); + + m_prevIoBase = nullptr; + + AZ::SettingsRegistry::Unregister(m_settingsRegistry.get()); + + AZ::ComponentApplicationBus::Handler::BusDisconnect(); + AllocatorsTestFixture::TearDown(); + + TestRunner::Instance().ResetSuppressionSettingsToDefault(); + } + + // ComponentApplicationBus + AZ::ComponentApplication* GetApplication() override + { + return nullptr; + } + + void RegisterComponentDescriptor(const AZ::ComponentDescriptor*) override { } + void UnregisterComponentDescriptor(const AZ::ComponentDescriptor*) override { } + void RegisterEntityAddedEventHandler(AZ::EntityAddedEvent::Handler&) override { } + void RegisterEntityRemovedEventHandler(AZ::EntityRemovedEvent::Handler&) override { } + void RegisterEntityActivatedEventHandler(AZ::EntityActivatedEvent::Handler&) override { } + void RegisterEntityDeactivatedEventHandler(AZ::EntityDeactivatedEvent::Handler&) override { } + void SignalEntityActivated(AZ::Entity*) override { } + void SignalEntityDeactivated(AZ::Entity*) override { } + + bool AddEntity(AZ::Entity*) override + { + return true; + } + + bool RemoveEntity(AZ::Entity*) override + { + return true; + } + + bool DeleteEntity(const AZ::EntityId&) override + { + return true; + } + + AZ::Entity* FindEntity(const AZ::EntityId&) override + { + return nullptr; + } + + AZ::SerializeContext* GetSerializeContext() override + { + return &m_context; + } + + AZ::BehaviorContext* GetBehaviorContext() override + { + return nullptr; + } + + AZ::JsonRegistrationContext* GetJsonRegistrationContext() override + { + return &m_jsonContext; + } + + const char* GetEngineRoot() const override + { + return nullptr; + } + + const char* GetExecutableFolder() const override + { + return nullptr; + } + + void EnumerateEntities(const EntityCallback& /*callback*/) override { } + void QueryApplicationType(AZ::ApplicationTypeQuery& /*appType*/) const override { } + //// + + AZ::ComponentDescriptor* m_prefabSystem{}; + AZ::ComponentDescriptor* m_procSystem{}; + AZStd::unique_ptr m_settingsRegistry; + AZ::SerializeContext m_context; + AZ::JsonRegistrationContext m_jsonContext; + AZStd::unique_ptr m_localFileIo; + ScopedTemporaryDirectory m_temporaryDirectory; + AZStd::unique_ptr m_systemEntity; + + AZ::IO::FileIOBase* m_prevIoBase{}; + }; + + struct MockCatalog : AZ::Data::AssetCatalogRequestBus::Handler + { + static const inline AZ::Data::AssetId TestId{ AZ::Uuid::CreateRandom(), 1234 }; + + MockCatalog(AZStd::string testFile) + : m_testFile(AZStd::move(testFile)) + { + BusConnect(); + } + + ~MockCatalog() override + { + BusDisconnect(); + } + + AZStd::string GetAssetPathById(const AZ::Data::AssetId& assetId) override + { + if (assetId == TestId) + { + return m_testFile; + } + + return "InvalidAssetId"; + } + + AZ::Data::AssetId GetAssetIdByPath(const char* path, const AZ::Data::AssetType&, bool) override + { + AZ::IO::PathView pathView{ AZStd::string_view(path) }; + + if (AZ::IO::PathView(m_testFile) == pathView) + { + return TestId; + } + + AZ_Error("MockCatalog", false, "Requested path %s does not match expected asset path of %s", path, m_testFile.c_str()); + ADD_FAILURE(); + + return {}; + } + + AZStd::string m_testFile; + }; + + struct PrefabPublicNotificationsListener : PrefabPublicNotificationBus::Handler + { + PrefabPublicNotificationsListener() + { + BusConnect(); + } + + ~PrefabPublicNotificationsListener() override + { + BusDisconnect(); + } + + void OnPrefabInstancePropagationBegin() override + { + m_updated = true; + } + + bool m_updated = false; + }; + + TEST_F(ProceduralPrefabSystemComponentTests, RegisteredPrefabUpdates) + { + const AZStd::string prefabFile = (AZ::IO::Path(m_temporaryDirectory.GetDirectory()) / "test.prefab").Native(); + MockCatalog catalog(prefabFile.c_str()); + + auto proceduralPrefabSystemComponentInterface = AZ::Interface::Get(); + auto prefabSystemComponentInterface = AZ::Interface::Get(); + auto prefabLoaderInterface = AZ::Interface::Get(); + + ASSERT_NE(proceduralPrefabSystemComponentInterface, nullptr); + ASSERT_NE(prefabSystemComponentInterface, nullptr); + ASSERT_NE(prefabLoaderInterface, nullptr); + + auto entity = aznew AZ::Entity(); + + AZStd::unique_ptr instance = prefabSystemComponentInterface->CreatePrefab({ entity }, {}, prefabFile.c_str()); + + ASSERT_NE(instance, nullptr); + + prefabLoaderInterface->SaveTemplateToFile(instance->GetTemplateId(), prefabFile.c_str()); + + proceduralPrefabSystemComponentInterface->RegisterProceduralPrefab(prefabFile, instance->GetTemplateId()); + + AzFramework::AssetCatalogEventBus::Broadcast(&AzFramework::AssetCatalogEventBus::Events::OnCatalogAssetChanged, MockCatalog::TestId); + + PrefabPublicNotificationsListener listener; + AZ::SystemTickBus::Broadcast(&AZ::SystemTickBus::Events::OnSystemTick); + + EXPECT_TRUE(listener.m_updated); + } + + TEST_F(ProceduralPrefabSystemComponentTests, UnregisteredPrefabDoesNotUpdate) + { + PrefabPublicNotificationsListener listener; + + const AZStd::string prefabFile = (AZ::IO::Path(m_temporaryDirectory.GetDirectory()) / "test.prefab").Native(); + MockCatalog catalog(prefabFile.c_str()); + + auto proceduralPrefabSystemComponentInterface = AZ::Interface::Get(); + auto prefabSystemComponentInterface = AZ::Interface::Get(); + auto prefabLoaderInterface = AZ::Interface::Get(); + + ASSERT_NE(proceduralPrefabSystemComponentInterface, nullptr); + ASSERT_NE(prefabSystemComponentInterface, nullptr); + ASSERT_NE(prefabLoaderInterface, nullptr); + + auto entity = aznew AZ::Entity(); + + AZStd::unique_ptr instance = prefabSystemComponentInterface->CreatePrefab({ entity }, {}, prefabFile.c_str()); + + ASSERT_NE(instance, nullptr); + + prefabLoaderInterface->SaveTemplateToFile(instance->GetTemplateId(), prefabFile.c_str()); + + AzFramework::AssetCatalogEventBus::Broadcast( + &AzFramework::AssetCatalogEventBus::Events::OnCatalogAssetChanged, MockCatalog::TestId); + + AZ::SystemTickBus::Broadcast(&AZ::SystemTickBus::Events::OnSystemTick); + + EXPECT_FALSE(listener.m_updated); + } +} diff --git a/Code/Framework/AzToolsFramework/Tests/aztoolsframeworktests_files.cmake b/Code/Framework/AzToolsFramework/Tests/aztoolsframeworktests_files.cmake index 86e07ba767..9a1f61ab56 100644 --- a/Code/Framework/AzToolsFramework/Tests/aztoolsframeworktests_files.cmake +++ b/Code/Framework/AzToolsFramework/Tests/aztoolsframeworktests_files.cmake @@ -105,6 +105,7 @@ set(FILES Prefab/SpawnableSortEntitiesTests.cpp Prefab/PrefabScriptingTests.cpp Prefab/ProceduralPrefabAssetTests.cpp + Prefab/ProceduralPrefabSystemComponentTests.cpp PropertyIntCtrlCommonTests.cpp PropertyIntCtrlCommonTests.h PropertyIntSliderCtrlTests.cpp diff --git a/Gems/Prefab/PrefabBuilder/PrefabGroup/PrefabBehaviorTests.cpp b/Gems/Prefab/PrefabBuilder/PrefabGroup/PrefabBehaviorTests.cpp index 856aba979b..6ccc82652b 100644 --- a/Gems/Prefab/PrefabBuilder/PrefabGroup/PrefabBehaviorTests.cpp +++ b/Gems/Prefab/PrefabBuilder/PrefabGroup/PrefabBehaviorTests.cpp @@ -136,6 +136,12 @@ namespace UnitTest auto jsonOutcome = AZ::JsonSerializationUtils::ReadJsonString(Data::jsonPrefab); ASSERT_TRUE(jsonOutcome); + // Register the asset to generate an AssetId in the catalog + AZ::Data::AssetId assetId; + AZ::Data::AssetCatalogRequestBus::BroadcastResult( + assetId, &AZ::Data::AssetCatalogRequestBus::Events::GetAssetIdByPath, "fake_prefab.procprefab", + azrtti_typeid(), true); + auto prefabGroup = AZStd::make_shared(); prefabGroup.get()->SetId(AZ::Uuid::CreateRandom()); prefabGroup.get()->SetName("fake_prefab"); From 7188529652d85218ad1b9c57da55ae4f03158770 Mon Sep 17 00:00:00 2001 From: Tommy Walton Date: Mon, 13 Dec 2021 13:07:04 -0800 Subject: [PATCH 33/70] Fix for GHI-4644: mesh optimization breaking skin influences (DCO fix) (#6336) * Average incoming skin influences when multiple vertices have been welded. This is one option which will average out the weights even if two welded vertices have differing boneIds, but we probably also need to add the influences earlier in the process and enforce a process where the vertices do not get welded if they have influences with differing boneIds Signed-off-by: Tommy Walton * Move skin influences from MeshBuilderSkinningInfo to the vertex attribute layers so they are considered when choosing which vertices can be welded and so they are not duplicated when compatible vertices have been welded Signed-off-by: Tommy Walton * Updating unit tests Signed-off-by: Tommy Walton * Remove unused functions Signed-off-by: Tommy Walton * Update based on feedback from burelc Signed-off-by: Tommy Walton --- .../DataTypes/GraphData/ISkinWeightData.h | 6 + .../Model/ModelAssetBuilderComponent.cpp | 6 +- .../MeshOptimizer/MeshBuilderSkinningInfo.cpp | 37 +-- .../MeshOptimizer/MeshBuilderSkinningInfo.h | 4 +- .../MeshOptimizer/MeshOptimizerComponent.cpp | 185 +++++++++------ .../MeshOptimizerComponentTests.cpp | 216 +++++++++++------- .../Tests/MeshBuilder/SkinInfluencesTests.cpp | 33 ++- 7 files changed, 299 insertions(+), 188 deletions(-) diff --git a/Code/Tools/SceneAPI/SceneCore/DataTypes/GraphData/ISkinWeightData.h b/Code/Tools/SceneAPI/SceneCore/DataTypes/GraphData/ISkinWeightData.h index 4b4cd2636f..6dacb61a5f 100644 --- a/Code/Tools/SceneAPI/SceneCore/DataTypes/GraphData/ISkinWeightData.h +++ b/Code/Tools/SceneAPI/SceneCore/DataTypes/GraphData/ISkinWeightData.h @@ -28,6 +28,12 @@ namespace AZ { int boneId; float weight; + + bool IsClose(const Link& other, float tolerance) const + { + return boneId == other.boneId && + AZ::IsClose(weight, other.weight, tolerance); + } }; virtual ~ISkinWeightData() override = default; diff --git a/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/ModelAssetBuilderComponent.cpp b/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/ModelAssetBuilderComponent.cpp index dbf0fea791..66d754c1dc 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/ModelAssetBuilderComponent.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/ModelAssetBuilderComponent.cpp @@ -948,19 +948,17 @@ namespace AZ { AZStd::vector& skinJointIndices = productMesh.m_skinJointIndices; AZStd::vector& skinWeights = productMesh.m_skinWeights; - const auto& sourceMeshData = sourceMesh.m_meshData; size_t numInfluencesAdded = 0; for (const auto& skinData : sourceMesh.m_skinData) { - const AZ::u32 controlPointIndex = sourceMeshData->GetControlPointIndex(static_cast(vertexIndex)); - const size_t numSkinInfluences = skinData->GetLinkCount(controlPointIndex); + const size_t numSkinInfluences = skinData->GetLinkCount(vertexIndex); size_t numInfluencesExcess = 0; for (size_t influenceIndex = 0; influenceIndex < numSkinInfluences; ++influenceIndex) { - const AZ::SceneAPI::DataTypes::ISkinWeightData::Link& link = skinData->GetLink(controlPointIndex, influenceIndex); + const AZ::SceneAPI::DataTypes::ISkinWeightData::Link& link = skinData->GetLink(vertexIndex, influenceIndex); const float weight = link.weight; const AZStd::string& boneName = skinData->GetBoneName(link.boneId); diff --git a/Gems/SceneProcessing/Code/Source/Generation/Components/MeshOptimizer/MeshBuilderSkinningInfo.cpp b/Gems/SceneProcessing/Code/Source/Generation/Components/MeshOptimizer/MeshBuilderSkinningInfo.cpp index 1d62489fbe..f328f1502c 100644 --- a/Gems/SceneProcessing/Code/Source/Generation/Components/MeshOptimizer/MeshBuilderSkinningInfo.cpp +++ b/Gems/SceneProcessing/Code/Source/Generation/Components/MeshOptimizer/MeshBuilderSkinningInfo.cpp @@ -68,9 +68,8 @@ namespace AZ::MeshBuilder } } - // sort influences on weights, from big to small - void MeshBuilderSkinningInfo::SortInfluences(AZStd::vector& influences) + void MeshBuilderSkinningInfo::SortInfluencesByWeight(AZStd::vector& influences) { AZStd::sort(begin(influences), end(influences), [](const auto& lhs, const auto& rhs) { @@ -78,39 +77,17 @@ namespace AZ::MeshBuilder }); } - // optimize the weight data - void MeshBuilderSkinningInfo::Optimize(AZ::u32 maxNumWeightsPerVertex, float weightThreshold) + void MeshBuilderSkinningInfo::Optimize( + AZStd::vector& influences, AZ::u32 maxNumWeightsPerVertex, float weightThreshold) { - AZStd::vector influences; - - // for all vertices - const size_t numOrgVerts = GetNumOrgVertices(); - for (size_t v = 0; v < numOrgVerts; ++v) + // gather all weights + const size_t numInfluences = influences.size(); + if (numInfluences > 0) { - // gather all weights - const size_t numInfluences = GetNumInfluences(v); - influences.resize(numInfluences); - for (size_t i = 0; i < numInfluences; ++i) - { - influences[i] = GetInfluence(v, i); - } - // optimize the weights and sort them from big to small weight OptimizeSkinningInfluences(influences, weightThreshold, maxNumWeightsPerVertex); - SortInfluences(influences); - - // remove all influences - for (size_t i = 0; i < numInfluences; ++i) - { - RemoveInfluence(v, 0); - } - - // re-add them - for (const Influence& influence : influences) - { - AddInfluence(v, influence); - } + SortInfluencesByWeight(influences); } } } // namespace AZ::MeshBuilder diff --git a/Gems/SceneProcessing/Code/Source/Generation/Components/MeshOptimizer/MeshBuilderSkinningInfo.h b/Gems/SceneProcessing/Code/Source/Generation/Components/MeshOptimizer/MeshBuilderSkinningInfo.h index dd3b715a21..743cdb14df 100644 --- a/Gems/SceneProcessing/Code/Source/Generation/Components/MeshOptimizer/MeshBuilderSkinningInfo.h +++ b/Gems/SceneProcessing/Code/Source/Generation/Components/MeshOptimizer/MeshBuilderSkinningInfo.h @@ -50,13 +50,13 @@ namespace AZ::MeshBuilder } // optimize the weight data - void Optimize(AZ::u32 maxNumWeightsPerVertex = 4, float weightThreshold = 0.0001f); + void Optimize(AZStd::vector& influences, AZ::u32 maxNumWeightsPerVertex = 4, float weightThreshold = 0.0001f); // optimize weights static void OptimizeSkinningInfluences(AZStd::vector& influences, float tolerance, size_t maxWeights); // sort the influences, starting with the biggest weight - static void SortInfluences(AZStd::vector& influences); + static void SortInfluencesByWeight(AZStd::vector& influences); private: AZStd::vector> mInfluences; diff --git a/Gems/SceneProcessing/Code/Source/Generation/Components/MeshOptimizer/MeshOptimizerComponent.cpp b/Gems/SceneProcessing/Code/Source/Generation/Components/MeshOptimizer/MeshOptimizerComponent.cpp index a410c4e6c9..edc0d728fc 100644 --- a/Gems/SceneProcessing/Code/Source/Generation/Components/MeshOptimizer/MeshOptimizerComponent.cpp +++ b/Gems/SceneProcessing/Code/Source/Generation/Components/MeshOptimizer/MeshOptimizerComponent.cpp @@ -69,6 +69,10 @@ namespace AZ::MeshBuilder { using MeshBuilderVertexAttributeLayerColor = MeshBuilderVertexAttributeLayerT; AZ_CLASS_ALLOCATOR_IMPL_TEMPLATE(MeshBuilderVertexAttributeLayerColor, AZ::SystemAllocator, 0) + + using MeshBuilderVertexAttributeLayerSkinInfluence = MeshBuilderVertexAttributeLayerT; + AZ_CLASS_ALLOCATOR_IMPL_TEMPLATE(MeshBuilderVertexAttributeLayerSkinInfluence, AZ::SystemAllocator, 0) + } // namespace AZ::MeshBuilder namespace AZ::SceneGenerationComponents @@ -205,50 +209,27 @@ namespace AZ::SceneGenerationComponents auto* serializeContext = azrtti_cast(context); if (serializeContext) { - serializeContext->Class()->Version(4); + serializeContext->Class()->Version(11); } } - template - static AZStd::unique_ptr ExtractSkinningInfo( - const MeshDataType* meshData, - const SkinWeightDataView& skinWeights, + static AZStd::vector ExtractSkinningInfo( + const AZStd::vector& skinningInfluencesLayers, + const AZ::MeshBuilder::MeshBuilderVertexLookup& vertexLookup, AZ::u32 maxWeightsPerVertex, - float weightThreshold, - const Vector3Map& positionMap) + float weightThreshold) { - if (skinWeights.empty()) + AZ::MeshBuilder::MeshBuilderSkinningInfo skinningInfo(1); + + AZStd::vector influences; + for (const auto& skinLayer : skinningInfluencesLayers) { - return {}; + const ISkinWeightData::Link& link = skinLayer->GetVertexValue(vertexLookup.mOrgVtx, vertexLookup.mDuplicateNr); + influences.push_back({ aznumeric_caster(link.boneId), link.weight }); } - const size_t usedControlPointCount = positionMap.size(); - - auto skinningInfo = AZStd::make_unique(aznumeric_cast(usedControlPointCount)); - - for (const auto& skinData : skinWeights) - { - for (size_t controlPointIndex = 0; controlPointIndex < skinData.get().GetVertexCount(); ++controlPointIndex) - { - const int usedPointIndex = meshData->GetUsedPointIndexForControlPoint(meshData->GetControlPointIndex(aznumeric_caster(controlPointIndex))); - const size_t linkCount = skinData.get().GetLinkCount(controlPointIndex); - - if (usedPointIndex < 0 || linkCount == 0) - { - continue; - } - - for (size_t linkIndex = 0; linkIndex < linkCount; ++linkIndex) - { - const ISkinWeightData::Link& link = skinData.get().GetLink(controlPointIndex, linkIndex); - skinningInfo->AddInfluence(positionMap.at(usedPointIndex), {aznumeric_caster(link.boneId), link.weight}); - } - } - } - - skinningInfo->Optimize(maxWeightsPerVertex, weightThreshold); - - return skinningInfo; + skinningInfo.Optimize(influences, maxWeightsPerVertex, weightThreshold); + return influences; } // Recurse through the SceneAPI's iterator types, extracting the real underlying iterator. @@ -467,6 +448,40 @@ namespace AZ::SceneGenerationComponents return layers; }; + template + static const AZStd::vector MakeSkinInfluenceLayers( + AZ::MeshBuilder::MeshBuilder& meshBuilder, + const SkinWeightDataView& skinWeights, + size_t vertexCount) + { + if (skinWeights.empty()) + { + return {}; + } + + size_t maxInfluenceCount = 0; + + AZStd::vector outLayers; + + // Do a pass over the skin influences, and determine the max influence count for any one vertex, + // which will be the number of influence layers we add + for (const auto& skinData : skinWeights) + { + for (size_t controlPointIndex = 0; controlPointIndex < skinData.get().GetVertexCount(); ++controlPointIndex) + { + const size_t linkCount = skinData.get().GetLinkCount(controlPointIndex); + maxInfluenceCount = AZStd::max(maxInfluenceCount, linkCount); + } + } + + // Create the influence layers + for (size_t i = 0; i < maxInfluenceCount; ++i) + { + outLayers.push_back(meshBuilder.AddLayer(vertexCount)); + } + + return outLayers; + } template AZStd::tuple< @@ -492,7 +507,7 @@ namespace AZ::SceneGenerationComponents AZ::MeshBuilder::MeshBuilder meshBuilder(vertexCount, AZStd::numeric_limits::max(), AZStd::numeric_limits::max(), /*optimizeDuplicates=*/ !hasBlendShapes); // Make the layers to hold the vertex data - auto* orgVtxLayer = meshBuilder.AddLayer(vertexCount); + auto* controlPointLayer = meshBuilder.AddLayer(vertexCount); auto* posLayer = meshBuilder.AddLayer(vertexCount, false, true); auto* normalsLayer = meshBuilder.AddLayer(vertexCount, false, true); @@ -527,6 +542,8 @@ namespace AZ::SceneGenerationComponents const AZStd::vector tangentLayers = makeLayersForData(tangents); const AZStd::vector bitangentLayers = makeLayersForData(bitangents); const AZStd::vector vertexColorLayers = makeLayersForData(vertexColors); + const AZStd::vector skinningInfluencesLayers = + MakeSkinInfluenceLayers(meshBuilder, skinWeights, vertexCount); constexpr float positionTolerance = 0.0001f; Vector3Map positionMap(meshData, hasBlendShapes, positionTolerance); @@ -539,9 +556,9 @@ namespace AZ::SceneGenerationComponents meshBuilder.BeginPolygon(baseMesh->GetFaceMaterialId(faceIndex)); for (const AZ::u32 vertexIndex : meshData->GetFaceInfo(faceIndex).vertexIndex) { - const AZ::u32 orgVertexNumber = positionMap[vertexIndex]; + const AZ::u32 controlPointVertexIndex = positionMap[vertexIndex]; - orgVtxLayer->SetCurrentVertexValue(orgVertexNumber); + controlPointLayer->SetCurrentVertexValue(controlPointVertexIndex); posLayer->SetCurrentVertexValue(meshData->GetPosition(vertexIndex)); normalsLayer->SetCurrentVertexValue(meshData->GetNormal(vertexIndex)); @@ -563,9 +580,44 @@ namespace AZ::SceneGenerationComponents { vertexColorLayer->SetCurrentVertexValue(vertexColorData.get().GetColor(vertexIndex)); } + + // Initialize skin weights to 0, 0.0 + for (auto& skinInfluenceLayer : skinningInfluencesLayers) + { + skinInfluenceLayer->SetCurrentVertexValue(ISkinWeightData::Link{ 0, 0.0f }); + } + +#if defined(AZ_ENABLE_TRACING) + bool influencesFoundForThisVertex = false; +#endif + // Set any real weights, if they exist + for (const auto& skinWeightData : skinWeights) + { + const size_t linkCount = skinWeightData.get().GetLinkCount(vertexIndex); + AZ_Assert( + linkCount <= skinningInfluencesLayers.size(), + "MeshOptimizer - The previously calculated maximum influence count is less than the current link count."); + + // Check that either the current skinWeightData doesn't have any influences for this vertex, + // or that none of the ones which came before it had any influences for this vertex. + AZ_Assert( + linkCount == 0 || influencesFoundForThisVertex == false, + "Two different skinWeightData instances in skinWeights apply to the same vertex. " + "The mesh optimizer assumes there will only ever be one skinWeightData that impacts a given vertex."); +#if defined(AZ_ENABLE_TRACING) + // Mark that at least one influence has been found for this vertex + influencesFoundForThisVertex |= linkCount > 0; +#endif + + for (size_t linkIndex = 0; linkIndex < linkCount; ++linkIndex) + { + const ISkinWeightData::Link& link = skinWeightData.get().GetLink(vertexIndex, linkIndex); + skinningInfluencesLayers[linkIndex]->SetCurrentVertexValue(link); + } + } AZ_POP_DISABLE_WARNING - meshBuilder.AddPolygonVertex(orgVertexNumber); + meshBuilder.AddPolygonVertex(controlPointVertexIndex); } meshBuilder.EndPolygon(); @@ -574,10 +626,11 @@ namespace AZ::SceneGenerationComponents const auto* skinRule = meshGroup.GetRuleContainerConst().FindFirstByType().get(); const AZ::u32 maxWeightsPerVertex = skinRule ? skinRule->GetMaxWeightsPerVertex() : 4; const float weightThreshold = skinRule ? skinRule->GetWeightThreshold() : 0.001f; - meshBuilder.SetSkinningInfo(ExtractSkinningInfo(meshData, skinWeights, maxWeightsPerVertex, weightThreshold, positionMap)); meshBuilder.GenerateSubMeshVertexOrders(); + const size_t optimizedVertexCount = meshBuilder.CalcNumVertices(); + // Create the resulting nodes struct ResultingType { @@ -594,6 +647,13 @@ namespace AZ::SceneGenerationComponents AZStd::vector> optimizedTangents = makeSceneGraphNodesForMeshBuilderLayers(tangentLayers); AZStd::vector> optimizedBitangents = makeSceneGraphNodesForMeshBuilderLayers(bitangentLayers); AZStd::vector> optimizedVertexColors = makeSceneGraphNodesForMeshBuilderLayers(vertexColorLayers); + AZStd::unique_ptr optimizedSkinWeights = nullptr; + + if (!skinningInfluencesLayers.empty()) + { + optimizedSkinWeights = AZStd::make_unique(); + optimizedSkinWeights->ResizeContainerSpace(optimizedVertexCount); + } // Copy node attributes AZStd::apply([](const auto&&... nodePairView) { @@ -613,14 +673,16 @@ namespace AZ::SceneGenerationComponents for (size_t subMeshIndex = 0; subMeshIndex < meshBuilder.GetNumSubMeshes(); ++subMeshIndex) { const AZ::MeshBuilder::MeshBuilderSubMesh* subMesh = meshBuilder.GetSubMesh(subMeshIndex); - for (size_t vertexIndex = 0; vertexIndex < subMesh->GetNumVertices(); ++vertexIndex) + for (size_t subMeshVertexIndex = 0; subMeshVertexIndex < subMesh->GetNumVertices(); ++subMeshVertexIndex) { - const AZ::MeshBuilder::MeshBuilderVertexLookup& vertexLookup = subMesh->GetVertex(vertexIndex); + const AZ::MeshBuilder::MeshBuilderVertexLookup& vertexLookup = subMesh->GetVertex(subMeshVertexIndex); optimizedMesh->AddPosition(posLayer->GetVertexValue(vertexLookup.mOrgVtx, vertexLookup.mDuplicateNr)); optimizedMesh->AddNormal(normalsLayer->GetVertexValue(vertexLookup.mOrgVtx, vertexLookup.mDuplicateNr)); + + int modelVertexIndex = optimizedMesh->GetVertexCount() - 1; optimizedMesh->SetVertexIndexToControlPointIndexMap( - aznumeric_caster(optimizedMesh->GetVertexCount() - 1), - orgVtxLayer->GetVertexValue(vertexLookup.mOrgVtx, vertexLookup.mDuplicateNr) + modelVertexIndex, + controlPointLayer->GetVertexValue(vertexLookup.mOrgVtx, vertexLookup.mDuplicateNr) ); for (auto [uvLayer, optimizedUVNode] : Containers::Views::MakePairView(uvLayers, optimizedUVs)) @@ -639,6 +701,19 @@ namespace AZ::SceneGenerationComponents { optimizedVertexColorNode->AppendColor(vertexColorLayer->GetVertexValue(vertexLookup.mOrgVtx, vertexLookup.mDuplicateNr)); } + + if (optimizedSkinWeights) + { + AZStd::vector influences = + ExtractSkinningInfo(skinningInfluencesLayers, vertexLookup, maxWeightsPerVertex, weightThreshold); + + for (const auto& influence : influences) + { + const int boneId = + optimizedSkinWeights->GetBoneId(skinWeights[0].get().GetBoneName(aznumeric_caster(influence.mNodeNr))); + optimizedSkinWeights->AppendLink(aznumeric_caster(modelVertexIndex), { boneId, influence.mWeight }); + } + } } AZStd::unordered_set usedIndexes; for (size_t polygonIndex = 0; polygonIndex < subMesh->GetNumPolygons(); ++polygonIndex) @@ -656,26 +731,6 @@ namespace AZ::SceneGenerationComponents indexOffset += static_cast(usedIndexes.size()); } - AZStd::unique_ptr optimizedSkinWeights; - if (MeshBuilder::MeshBuilderSkinningInfo* skinningInfo = meshBuilder.GetSkinningInfo()) - { - optimizedSkinWeights = AZStd::make_unique(); - - const size_t skinnedVertexCount = skinningInfo->GetNumOrgVertices(); - optimizedSkinWeights->ResizeContainerSpace(skinnedVertexCount); - - for (size_t vertex = 0; vertex < skinnedVertexCount; ++vertex) - { - const size_t boneCountAffectingThisVertex = skinningInfo->GetNumInfluences(vertex); - for (size_t influencingBone = 0; influencingBone < boneCountAffectingThisVertex; ++influencingBone) - { - const MeshBuilder::MeshBuilderSkinningInfo::Influence& influence = skinningInfo->GetInfluence(vertex, influencingBone); - const int boneId = optimizedSkinWeights->GetBoneId(skinWeights[0].get().GetBoneName(aznumeric_caster(influence.mNodeNr))); - optimizedSkinWeights->AppendLink(vertex, {boneId, influence.mWeight}); - } - } - } - return AZStd::make_tuple( AZStd::move(optimizedMesh), AZStd::move(optimizedUVs), diff --git a/Gems/SceneProcessing/Code/Tests/MeshBuilder/MeshOptimizerComponentTests.cpp b/Gems/SceneProcessing/Code/Tests/MeshBuilder/MeshOptimizerComponentTests.cpp index 81528fc3e4..d3f4383094 100644 --- a/Gems/SceneProcessing/Code/Tests/MeshBuilder/MeshOptimizerComponentTests.cpp +++ b/Gems/SceneProcessing/Code/Tests/MeshBuilder/MeshOptimizerComponentTests.cpp @@ -35,6 +35,21 @@ namespace AZ::SceneAPI::DataTypes } } +MATCHER(VectorOfLinksEq, "") +{ + return testing::ExplainMatchResult( + testing::AllOf( + testing::Field(&AZ::SceneData::GraphData::SkinWeightData::Link::boneId, testing::Eq(testing::get<0>(arg).boneId)), + testing::Field(&AZ::SceneData::GraphData::SkinWeightData::Link::weight, testing::FloatEq(testing::get<0>(arg).weight))), + testing::get<1>(arg), result_listener); +} + +MATCHER(VectorOfVectorOfLinksEq, "") +{ + return testing::ExplainMatchResult( + testing::UnorderedPointwise(VectorOfLinksEq(), testing::get<0>(arg)), testing::get<1>(arg), result_listener); +} + namespace SceneProcessing { class VertexDeduplicationFixture @@ -60,11 +75,12 @@ namespace SceneProcessing static AZStd::unique_ptr MakePlaneMesh() { // Create a simple plane with 2 triangles, 6 total vertices, 2 shared vertices - // 0 --- 1 - // | / | - // | / | - // | / | - // 2 --- 3 + // 0,5 --- 1 + // | \ | + // | \ | + // | \ | + // | \ | + // 4 --- 2,3 const AZStd::array planeVertexPositions = { AZ::Vector3{0.0f, 0.0f, 0.0f}, AZ::Vector3{0.0f, 0.0f, 1.0f}, @@ -94,7 +110,28 @@ namespace SceneProcessing return mesh; } - static AZStd::unique_ptr MakeSkinData() + static AZStd::unique_ptr MakeSkinData( + const AZStd::vector>& sourceLinks) + { + auto skinWeights = AZStd::make_unique(); + + skinWeights->ResizeContainerSpace(sourceLinks.size()); + + for (size_t vertexIndex = 0; vertexIndex < sourceLinks.size(); ++vertexIndex) + { + for (const auto& link : sourceLinks[vertexIndex]) + { + // Make sure the bone is added to the skin weights + skinWeights->GetBoneId(AZStd::to_string(link.boneId)); + + skinWeights->AppendLink(vertexIndex, link); + } + } + + return skinWeights; + } + + static AZStd::unique_ptr MakeDuplicateSkinData() { auto skinWeights = AZStd::make_unique(); @@ -104,16 +141,69 @@ namespace SceneProcessing skinWeights->GetBoneId("0"); skinWeights->GetBoneId("1"); - skinWeights->AppendLink(0, {/*.boneId=*/0, /*.weight=*/1}); - skinWeights->AppendLink(1, {/*.boneId=*/0, /*.weight=*/1}); - skinWeights->AppendLink(2, {/*.boneId=*/0, /*.weight=*/1}); - skinWeights->AppendLink(3, {/*.boneId=*/1, /*.weight=*/1}); - skinWeights->AppendLink(4, {/*.boneId=*/1, /*.weight=*/1}); - skinWeights->AppendLink(5, {/*.boneId=*/1, /*.weight=*/1}); + // Vertices 0,5 and 2,3 have duplicate skin data, in addition to duplicate positions + skinWeights->AppendLink(0, { /*.boneId=*/0, /*.weight=*/1 }); + skinWeights->AppendLink(1, { /*.boneId=*/1, /*.weight=*/1 }); + skinWeights->AppendLink(2, { /*.boneId=*/0, /*.weight=*/1 }); + skinWeights->AppendLink(3, { /*.boneId=*/0, /*.weight=*/1 }); + skinWeights->AppendLink(4, { /*.boneId=*/2, /*.weight=*/1 }); + skinWeights->AppendLink(5, { /*.boneId=*/0, /*.weight=*/1 }); return skinWeights; } + static void TestSkinDuplication( + const AZStd::shared_ptr skinData, + const AZStd::vector>& expectedLinks) + { + AZ::SceneAPI::Containers::Scene scene("testScene"); + AZ::SceneAPI::Containers::SceneGraph& graph = scene.GetGraph(); + + const auto meshNodeIndex = graph.AddChild(graph.GetRoot(), "testMesh", MakePlaneMesh()); + const auto skinDataNodeIndex = graph.AddChild(meshNodeIndex, "skinData", skinData); + graph.MakeEndPoint(skinDataNodeIndex); + + // The original source mesh should have 6 vertices + EXPECT_EQ( + AZStd::rtti_pointer_cast(graph.GetNodeContent(meshNodeIndex))->GetVertexCount(), 6); + + auto meshGroup = AZStd::make_unique(); + meshGroup->GetSceneNodeSelectionList().AddSelectedNode("testMesh"); + scene.GetManifest().AddEntry(AZStd::move(meshGroup)); + + AZ::SceneGenerationComponents::MeshOptimizerComponent component; + AZ::SceneAPI::Events::GenerateSimplificationEventContext context(scene, "pc"); + component.OptimizeMeshes(context); + + AZ::SceneAPI::Containers::SceneGraph::NodeIndex optimizedNodeIndex = + graph.Find(AZStd::string("testMesh").append(AZ::SceneAPI::Utilities::OptimizedMeshSuffix)); + ASSERT_TRUE(optimizedNodeIndex.IsValid()) << "Mesh optimizer did not add an optimized version of the mesh"; + + const auto& optimizedMesh = + AZStd::rtti_pointer_cast(graph.GetNodeContent(optimizedNodeIndex)); + ASSERT_TRUE(optimizedMesh); + + AZ::SceneAPI::Containers::SceneGraph::NodeIndex optimizedSkinDataNodeIndex = + graph.Find(AZStd::string("testMesh").append(AZ::SceneAPI::Utilities::OptimizedMeshSuffix).append(".skinWeights")); + ASSERT_TRUE(optimizedSkinDataNodeIndex.IsValid()) << "Mesh optimizer did not add an optimized version of the skin data"; + + const auto& optimizedSkinWeights = + AZStd::rtti_pointer_cast(graph.GetNodeContent(optimizedSkinDataNodeIndex)); + ASSERT_TRUE(optimizedSkinWeights); + + AZStd::vector> gotLinks(optimizedMesh->GetVertexCount()); + for (unsigned int vertexIndex = 0; vertexIndex < optimizedMesh->GetVertexCount(); ++vertexIndex) + { + for (size_t linkIndex = 0; linkIndex < optimizedSkinWeights->GetLinkCount(vertexIndex); ++linkIndex) + { + gotLinks[vertexIndex].emplace_back(optimizedSkinWeights->GetLink(vertexIndex, linkIndex)); + } + } + EXPECT_THAT(gotLinks, testing::Pointwise(VectorOfVectorOfLinksEq(), expectedLinks)); + + EXPECT_EQ(optimizedMesh->GetVertexCount(), expectedLinks.size()); + } + private: AZ::ComponentApplication m_app; AZ::Entity* m_systemEntity; @@ -147,75 +237,43 @@ namespace SceneProcessing EXPECT_EQ(optimizedMesh->GetVertexCount(), 4); } - MATCHER(VectorOfLinksEq, "") + TEST_F(VertexDeduplicationFixture, DeduplicatedVerticesKeepUniqueSkinInfluences) { - return testing::ExplainMatchResult( - testing::AllOf( - testing::Field(&AZ::SceneData::GraphData::SkinWeightData::Link::boneId, testing::Eq(testing::get<0>(arg).boneId)), - testing::Field(&AZ::SceneData::GraphData::SkinWeightData::Link::weight, testing::FloatEq(testing::get<0>(arg).weight)) - ), - testing::get<1>(arg), - result_listener - ); - } - - MATCHER(VectorOfVectorOfLinksEq, "") - { - return testing::ExplainMatchResult( - testing::UnorderedPointwise(VectorOfLinksEq(), testing::get<0>(arg)), - testing::get<1>(arg), - result_listener - ); - } - - TEST_F(VertexDeduplicationFixture, DeduplicatedVerticesRemapSkinning) - { - AZ::SceneAPI::Containers::Scene scene("testScene"); - AZ::SceneAPI::Containers::SceneGraph& graph = scene.GetGraph(); - - const auto meshNodeIndex = graph.AddChild(graph.GetRoot(), "testMesh", MakePlaneMesh()); - const auto skinDataNodeIndex = graph.AddChild(meshNodeIndex, "skinData", MakeSkinData()); - graph.MakeEndPoint(skinDataNodeIndex); - - // The original source mesh should have 6 vertices - EXPECT_EQ(AZStd::rtti_pointer_cast(graph.GetNodeContent(meshNodeIndex))->GetVertexCount(), 6); - - auto meshGroup = AZStd::make_unique(); - meshGroup->GetSceneNodeSelectionList().AddSelectedNode("testMesh"); - scene.GetManifest().AddEntry(AZStd::move(meshGroup)); - - AZ::SceneGenerationComponents::MeshOptimizerComponent component; - AZ::SceneAPI::Events::GenerateSimplificationEventContext context(scene, "pc"); - component.OptimizeMeshes(context); - - AZ::SceneAPI::Containers::SceneGraph::NodeIndex optimizedNodeIndex = graph.Find(AZStd::string("testMesh").append(AZ::SceneAPI::Utilities::OptimizedMeshSuffix)); - ASSERT_TRUE(optimizedNodeIndex.IsValid()) << "Mesh optimizer did not add an optimized version of the mesh"; - - const auto& optimizedMesh = AZStd::rtti_pointer_cast(graph.GetNodeContent(optimizedNodeIndex)); - ASSERT_TRUE(optimizedMesh); - - AZ::SceneAPI::Containers::SceneGraph::NodeIndex optimizedSkinDataNodeIndex = graph.Find(AZStd::string("testMesh").append(AZ::SceneAPI::Utilities::OptimizedMeshSuffix).append(".skinWeights")); - ASSERT_TRUE(optimizedSkinDataNodeIndex.IsValid()) << "Mesh optimizer did not add an optimized version of the skin data"; - - const auto& optimizedSkinWeights = AZStd::rtti_pointer_cast(graph.GetNodeContent(optimizedSkinDataNodeIndex)); - ASSERT_TRUE(optimizedSkinWeights); - - const AZStd::vector> expectedLinks - { - /*0*/ { {0, 0.5f}, {1, 0.5f} }, - /*1*/ { {0, 1.0f} }, - /*2*/ { {0, 0.5f}, {1, 0.5f} }, - /*3*/ { {1, 1.0f} }, + // Vertices 0,5 and 2,3 have duplicate positions, but unique links, + // so none of the vertices should be de-duplicated + // and the sourceLinks should be the same as the expected links + const AZStd::vector> sourceLinks{ + /*0*/ { { 0, 1.0f } }, + /*1*/ { { 0, 1.0f } }, + /*2*/ { { 0, 1.0f } }, + /*3*/ { { 1, 1.0f } }, + /*4*/ { { 1, 1.0f } }, + /*5*/ { { 1, 1.0f } }, }; - AZStd::vector> gotLinks(optimizedMesh->GetVertexCount()); - for (unsigned int vertexIndex = 0; vertexIndex < optimizedMesh->GetVertexCount(); ++vertexIndex) - { - for (size_t linkIndex = 0; linkIndex < optimizedSkinWeights->GetLinkCount(vertexIndex); ++linkIndex) - { - gotLinks[vertexIndex].emplace_back(optimizedSkinWeights->GetLink(vertexIndex, linkIndex)); - } - } - EXPECT_THAT(gotLinks, testing::Pointwise(VectorOfVectorOfLinksEq(), expectedLinks)); + TestSkinDuplication(MakeSkinData(sourceLinks), sourceLinks); + } + + TEST_F(VertexDeduplicationFixture, DeduplicatedVerticesDeduplicateSkinInfluences) + { + // Vertices 0,5 and 2,3 have duplicate positions, and also duplicate links, + // so they should be de-duplicated and the expected links + // should have two fewer links + const AZStd::vector> sourceLinks{ + /*0*/ { { 0, 1.0f } }, + /*1*/ { { 1, 1.0f } }, + /*2*/ { { 0, 1.0f } }, + /*3*/ { { 0, 1.0f } }, + /*4*/ { { 2, 1.0f } }, + /*5*/ { { 0, 1.0f } }, + }; + const AZStd::vector> expectedLinks{ + /*0*/ { { 0, 1.0f } }, + /*1*/ { { 1, 1.0f } }, + /*2*/ { { 0, 1.0f } }, + /*3*/ { { 2, 1.0f } }, + }; + + TestSkinDuplication(MakeSkinData(sourceLinks), expectedLinks); } } // namespace SceneProcessing diff --git a/Gems/SceneProcessing/Code/Tests/MeshBuilder/SkinInfluencesTests.cpp b/Gems/SceneProcessing/Code/Tests/MeshBuilder/SkinInfluencesTests.cpp index 5749e7ee7b..acf738a85f 100644 --- a/Gems/SceneProcessing/Code/Tests/MeshBuilder/SkinInfluencesTests.cpp +++ b/Gems/SceneProcessing/Code/Tests/MeshBuilder/SkinInfluencesTests.cpp @@ -75,14 +75,30 @@ namespace AZ::MeshBuilder return skinningInfo; } - static float CalcSkinInfluencesTotalWeight(const MeshBuilderSkinningInfo* skinInfo, size_t vtxNum) + static AZStd::vector GetInfluenceVector(const MeshBuilderSkinningInfo* skinInfo, size_t vtxNum) { const size_t numInfluence = skinInfo->GetNumInfluences(vtxNum); - float totalWeight = 0.0f; + AZStd::vector influences; + influences.reserve(numInfluence); for (size_t i = 0; i < numInfluence; ++i) { - const MeshBuilderSkinningInfo::Influence& inf = skinInfo->GetInfluence(vtxNum, i); - totalWeight += inf.mWeight; + influences.push_back(skinInfo->GetInfluence(vtxNum, i)); + } + return influences; + } + + static float CalcSkinInfluencesTotalWeight(const MeshBuilderSkinningInfo* skinInfo, size_t vtxNum) + { + AZStd::vector influences = GetInfluenceVector(skinInfo, vtxNum); + return CalcTotalWeight(influences); + } + + static float CalcTotalWeight(const AZStd::vector& influences) + { + float totalWeight = 0.0f; + for (const auto& influence : influences) + { + totalWeight += influence.mWeight; } return totalWeight; } @@ -96,12 +112,13 @@ namespace AZ::MeshBuilder MeshBuilderSkinningInfo* testSkinInfo = meshBuilder->GetSkinningInfo(); const float expectedTotalWeight = 1.0f; - testSkinInfo->Optimize(testParam.maxInfluencesAfterOptimization); for (size_t v = 0; v < testParam.numOrgVertices; ++v) { - const size_t numInfluence = testSkinInfo->GetNumInfluences(v); - EXPECT_EQ(numInfluence, testParam.maxInfluencesAfterOptimization); - const float totalWeight = CalcSkinInfluencesTotalWeight(testSkinInfo, v); + AZStd::vector influences = GetInfluenceVector(testSkinInfo, v); + + testSkinInfo->Optimize(influences, testParam.maxInfluencesAfterOptimization); + EXPECT_EQ(influences.size(), testParam.maxInfluencesAfterOptimization); + const float totalWeight = CalcTotalWeight(influences); EXPECT_NEAR(totalWeight, expectedTotalWeight, 0.00001f /* tolerance */) << "totalWeight of all influences in a vertex should be 1.0f."; } } From c5d370723e18de8d2594ebac102ddf2da12467fd Mon Sep 17 00:00:00 2001 From: carlitosan <82187351+carlitosan@users.noreply.github.com> Date: Mon, 13 Dec 2021 14:14:31 -0800 Subject: [PATCH 34/70] redcoding asset handler, holder, tracker, memory asset Signed-off-by: carlitosan <82187351+carlitosan@users.noreply.github.com> --- .../Code/Asset/EditorAssetSystemComponent.cpp | 1 - .../Builder/ScriptCanvasBuilderComponent.cpp | 1 - .../Builder/ScriptCanvasBuilderWorker.cpp | 1 - .../ScriptCanvasBuilderWorkerUtility.cpp | 40 - .../Assets/ScriptCanvasAssetHandler.cpp | 289 -------- .../Editor/Assets/ScriptCanvasAssetHolder.cpp | 207 ------ .../Editor/Assets/ScriptCanvasAssetHolder.h | 99 --- .../Assets/ScriptCanvasAssetTracker.cpp | 441 ----------- .../Editor/Assets/ScriptCanvasAssetTracker.h | 124 ---- .../Assets/ScriptCanvasAssetTrackerBus.h | 159 ---- .../ScriptCanvasAssetTrackerDefinitions.h | 28 - .../Editor/Assets/ScriptCanvasMemoryAsset.cpp | 684 ------------------ .../Editor/Assets/ScriptCanvasMemoryAsset.h | 344 --------- .../Editor/Assets/ScriptCanvasUndoHelper.cpp | 1 - .../EditorScriptCanvasComponent.cpp | 17 +- .../FunctionNodeDescriptorComponent.cpp | 10 +- .../Assets/ScriptCanvasAssetHandler.h | 81 --- .../Components/EditorDeprecationData.cpp | 28 + .../Components/EditorDeprecationData.h | 34 + .../Components/EditorScriptCanvasComponent.h | 2 - .../Code/Editor/ReflectComponent.cpp | 4 +- .../Code/Editor/SystemComponent.cpp | 4 +- .../Code/Editor/SystemComponent.h | 3 - .../Editor/Undo/ScriptCanvasGraphCommand.cpp | 1 - .../Editor/Undo/ScriptCanvasGraphCommand.h | 2 - .../Code/Editor/View/Widgets/GraphTabBar.h | 1 - .../Widgets/NodePalette/NodePaletteModel.cpp | 1 - .../ScriptCanvasNodePaletteDockWidget.cpp | 56 +- .../StatisticsDialog/NodeUsageTreeItem.cpp | 6 +- .../UnitTestPanel/UnitTestDockWidget.cpp | 28 +- .../VariablePanel/SlotTypeSelectorWidget.cpp | 1 - .../VariablePanel/VariableDockWidget.cpp | 1 - .../Code/Editor/View/Windows/MainWindow.cpp | 39 +- .../Code/Editor/View/Windows/MainWindow.h | 8 +- .../Windows/Tools/UpgradeTool/Controller.cpp | 1 - .../Windows/Tools/UpgradeTool/FileSaver.cpp | 1 - .../View/Windows/Tools/UpgradeTool/Model.cpp | 1 - .../Tools/UpgradeTool/UpgradeHelper.cpp | 1 - .../Code/scriptcanvasgem_editor_files.cmake | 12 +- .../Framework/ScriptCanvasTestUtilities.cpp | 1 - 40 files changed, 137 insertions(+), 2626 deletions(-) delete mode 100644 Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetHandler.cpp delete mode 100644 Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetHolder.cpp delete mode 100644 Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetHolder.h delete mode 100644 Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetTracker.cpp delete mode 100644 Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetTracker.h delete mode 100644 Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetTrackerBus.h delete mode 100644 Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetTrackerDefinitions.h delete mode 100644 Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasMemoryAsset.cpp delete mode 100644 Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasMemoryAsset.h delete mode 100644 Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasAssetHandler.h create mode 100644 Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorDeprecationData.cpp create mode 100644 Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorDeprecationData.h diff --git a/Gems/ScriptCanvas/Code/Asset/EditorAssetSystemComponent.cpp b/Gems/ScriptCanvas/Code/Asset/EditorAssetSystemComponent.cpp index 1f614a5a87..87a5dbf796 100644 --- a/Gems/ScriptCanvas/Code/Asset/EditorAssetSystemComponent.cpp +++ b/Gems/ScriptCanvas/Code/Asset/EditorAssetSystemComponent.cpp @@ -23,7 +23,6 @@ AZ_PUSH_DISABLE_WARNING(4251 4800 4244, "-Wunknown-warning-option") #include #include -#include #include #include AZ_POP_DISABLE_WARNING diff --git a/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderComponent.cpp b/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderComponent.cpp index 019dd4f5e3..b7e4fb4a79 100644 --- a/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderComponent.cpp +++ b/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderComponent.cpp @@ -15,7 +15,6 @@ #include #include #include -#include #include namespace ScriptCanvasBuilder diff --git a/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderWorker.cpp b/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderWorker.cpp index 6c35007987..24f9836236 100644 --- a/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderWorker.cpp +++ b/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderWorker.cpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include diff --git a/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderWorkerUtility.cpp b/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderWorkerUtility.cpp index fb7b5e7a4a..fb4bb0a386 100644 --- a/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderWorkerUtility.cpp +++ b/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderWorkerUtility.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -386,45 +385,6 @@ namespace ScriptCanvasBuilder ; } - AZ::Outcome < AZ::Data::Asset, AZStd::string> LoadEditorAsset(AZStd::string_view filePath, AZ::Data::AssetId assetId, AZ::Data::AssetFilterCB assetFilterCB) - { - AZStd::shared_ptr assetDataStream = AZStd::make_shared(); - - // Read the asset into a memory buffer, then hand ownership of the buffer to assetDataStream - { - AZ::IO::FileIOStream stream(filePath.data(), AZ::IO::OpenMode::ModeRead); - if (!AZ::IO::RetryOpenStream(stream)) - { - AZ_Warning(s_scriptCanvasBuilder, false, "CreateJobs for \"%s\" failed because the source file could not be opened.", filePath.data()); - AZ::Failure(AZStd::string::format("Failed to load ScriptCavas asset: %s", filePath.data())); - } - AZStd::vector fileBuffer(stream.GetLength()); - size_t bytesRead = stream.Read(fileBuffer.size(), fileBuffer.data()); - if (bytesRead != stream.GetLength()) - { - AZ_Warning(s_scriptCanvasBuilder, false, "CreateJobs for \"%s\" failed because the source file could not be read.", filePath.data()); - AZ::Failure(AZStd::string::format("Failed to load ScriptCavas asset: %s", filePath.data())); - } - - assetDataStream->Open(AZStd::move(fileBuffer)); - } - - ScriptCanvasEditor::ScriptCanvasAssetHandler editorAssetHandler; - - AZ::SerializeContext* context{}; - AZ::ComponentApplicationBus::BroadcastResult(context, &AZ::ComponentApplicationBus::Events::GetSerializeContext); - - AZ::Data::Asset asset; - asset.Create(assetId); - - if (editorAssetHandler.LoadAssetData(asset, assetDataStream, assetFilterCB) != AZ::Data::AssetHandler::LoadResult::LoadComplete) - { - return AZ::Failure(AZStd::string::format("Failed to load ScriptCavas asset: %s", filePath.data())); - } - - return AZ::Success(asset); - } - ScriptCanvasEditor::Graph* PrepareSourceGraph(AZ::Entity* const buildEntity) { auto sourceGraph = AZ::EntityUtils::FindFirstDerivedComponent(buildEntity); diff --git a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetHandler.cpp b/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetHandler.cpp deleted file mode 100644 index 896d285054..0000000000 --- a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetHandler.cpp +++ /dev/null @@ -1,289 +0,0 @@ -/* - * 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 - -namespace ScriptCanvasAssetHandlerCpp -{ - using namespace ScriptCanvas; - - void CollectNodes(const GraphData::NodeContainer& container, SerializationListeners& listeners) - { - for (auto& nodeEntity : container) - { - if (nodeEntity) - { - if (auto listener = azrtti_cast(AZ::EntityUtils::FindFirstDerivedComponent(nodeEntity))) - { - listeners.push_back(listener); - } - } - } - } -} - -namespace ScriptCanvasEditor -{ - ScriptCanvasAssetHandler::ScriptCanvasAssetHandler(AZ::SerializeContext* context) - { - SetSerializeContext(context); - - AZ::AssetTypeInfoBus::MultiHandler::BusConnect(GetAssetType()); - } - - ScriptCanvasAssetHandler::~ScriptCanvasAssetHandler() - { - AZ::AssetTypeInfoBus::MultiHandler::BusDisconnect(); - } - - AZ::Data::AssetPtr ScriptCanvasAssetHandler::CreateAsset(const AZ::Data::AssetId& id, const AZ::Data::AssetType& type) - { - (void)type; - auto assetData = aznew ScriptCanvasAsset(id); - - AZ::Entity* scriptCanvasEntity = aznew AZ::Entity("Script Canvas Graph"); - SystemRequestBus::Broadcast(&SystemRequests::CreateEditorComponentsOnEntity, scriptCanvasEntity, azrtti_typeid()); - - assetData->SetScriptCanvasEntity(scriptCanvasEntity); - - return assetData; - } - - // Override the stream info to force source assets to load into the Editor instead of cached, processed assets. - void ScriptCanvasAssetHandler::GetCustomAssetStreamInfoForLoad(AZ::Data::AssetStreamInfo& streamInfo) - { - //ScriptCanvas files are source assets and should be placed in a source asset directory - const char* assetPath = streamInfo.m_streamName.c_str(); - if (AzFramework::StringFunc::Path::IsRelative(assetPath)) - { - AZStd::string watchFolder; - bool sourceInfoFound{}; - AZ::Data::AssetInfo assetInfo; - AzToolsFramework::AssetSystemRequestBus::BroadcastResult(sourceInfoFound, &AzToolsFramework::AssetSystemRequestBus::Events::GetSourceInfoBySourcePath, assetPath, assetInfo, watchFolder); - if (sourceInfoFound) - { - AzFramework::StringFunc::Path::Join(watchFolder.data(), assetInfo.m_relativePath.data(), streamInfo.m_streamName); - } - } - } - - AZ::Data::AssetHandler::LoadResult ScriptCanvasAssetHandler::LoadAssetData - ( const AZ::Data::Asset& assetTarget - , AZStd::shared_ptr streamSource - , [[maybe_unused]] const AZ::Data::AssetFilterCB& assetLoadFilterCB) - { - namespace JSRU = AZ::JsonSerializationUtils; - using namespace ScriptCanvas; - - auto* scriptCanvasAssetTarget = assetTarget.GetAs(); - AZ_Assert(scriptCanvasAssetTarget, "This should be a ScriptCanvasAsset, as this is the only type we process!"); - - if (m_serializeContext - && streamSource - && scriptCanvasAssetTarget) - { - streamSource->Seek(0U, AZ::IO::GenericStream::ST_SEEK_BEGIN); - auto& scriptCanvasDataTarget = scriptCanvasAssetTarget->GetScriptCanvasData(); - AZStd::vector byteBuffer; - byteBuffer.resize_no_construct(streamSource->GetLength()); - // this duplicate stream is to allow for trying again if the JSON read fails - AZ::IO::ByteContainerStream byteStreamSource(&byteBuffer); - const size_t bytesRead = streamSource->Read(byteBuffer.size(), byteBuffer.data()); - scriptCanvasDataTarget.m_scriptCanvasEntity.reset(nullptr); - - if (bytesRead == streamSource->GetLength()) - { - byteStreamSource.Seek(0U, AZ::IO::GenericStream::ST_SEEK_BEGIN); - AZ::JsonDeserializerSettings settings; - settings.m_serializeContext = m_serializeContext; - settings.m_metadata.Create(); - // attempt JSON deserialization... - auto jsonResult = LoadDataFromJson - ( scriptCanvasDataTarget - , AZStd::string_view{ byteBuffer.begin(), byteBuffer.size() } - , *m_serializeContext); - - if (jsonResult.IsSuccess()) - { - return AZ::Data::AssetHandler::LoadResult::LoadComplete; - } -#if defined(OBJECT_STREAM_EDITOR_ASSET_LOADING_SUPPORT_ENABLED)//// - else - { - // ...if there is a failure, check if it is saved in the old format - byteStreamSource.Seek(0U, AZ::IO::GenericStream::ST_SEEK_BEGIN); - // tolerate unknown classes in the editor. Let the asset processor warn about bad nodes... - if (AZ::Utils::LoadObjectFromStreamInPlace - ( byteStreamSource - , scriptCanvasDataTarget - , m_serializeContext - , AZ::ObjectStream::FilterDescriptor(assetLoadFilterCB, AZ::ObjectStream::FILTERFLAG_IGNORE_UNKNOWN_CLASSES))) - { - AZ_Warning - ( "ScriptCanvas" - , false - , "ScriptCanvasAssetHandler::LoadAssetData failed to load graph data from JSON, %s, consider converting to JSON" - " by opening it and saving it, or running the graph update tool from the editor0" - , jsonResult.GetError().c_str()); - return AZ::Data::AssetHandler::LoadResult::LoadComplete; - } - } -#else - else - { - AZ_Warning - ( "ScriptCanvas" - , false - , "ScriptCanvasAssetHandler::LoadAssetData failed to load graph data from JSON %s" - , jsonResult.GetError().c_str()"); - } -#endif//defined(OBJECT_STREAM_EDITOR_ASSET_LOADING_SUPPORT_ENABLED) - } - } - - return AZ::Data::AssetHandler::LoadResult::Error; - } - - bool ScriptCanvasAssetHandler::SaveAssetData(const AZ::Data::Asset& asset, AZ::IO::GenericStream* stream) - { - return SaveAssetData(asset.GetAs(), stream); - } - - bool ScriptCanvasAssetHandler::SaveAssetData(const ScriptCanvasAsset* assetData, AZ::IO::GenericStream* stream) - { - return SaveAssetData(assetData, stream, AZ::DataStream::ST_XML); - } - - bool ScriptCanvasAssetHandler::SaveAssetData - ( const ScriptCanvasAsset* assetData - , AZ::IO::GenericStream* stream - , [[maybe_unused]] AZ::DataStream::StreamType streamType) - { - // #sc_editor_asset delete usage of this, and route to ScriptCanvasEditor::SaveToStream - namespace JSRU = AZ::JsonSerializationUtils; - using namespace ScriptCanvas; - - if (m_serializeContext - && stream - && assetData - && assetData->GetScriptCanvasGraph() - && assetData->GetScriptCanvasGraph()->GetGraphData()) - { - auto graphData = assetData->GetScriptCanvasGraph()->GetGraphData(); - AZ::JsonSerializerSettings settings; - settings.m_metadata.Create(); - auto listeners = settings.m_metadata.Find(); - AZ_Assert(listeners, "Failed to create SerializationListeners"); - ScriptCanvasAssetHandlerCpp::CollectNodes(graphData->m_nodes, *listeners); - settings.m_keepDefaults = false; - settings.m_serializeContext = m_serializeContext; - - for (auto listener : *listeners) - { - listener->OnSerialize(); - } - - return JSRU::SaveObjectToStream(&assetData->GetScriptCanvasData(), *stream, nullptr, &settings).IsSuccess(); - } - else - { - AZ_Error("ScriptCanvas", false, "Saving ScriptCavas assets in the handler requires a valid IO stream, " - "asset pointer, and serialize context"); - return false; - } - } - - void ScriptCanvasAssetHandler::DestroyAsset(AZ::Data::AssetPtr ptr) - { - delete ptr; - } - - AZ::SerializeContext* ScriptCanvasAssetHandler::GetSerializeContext() const - { - return m_serializeContext; - } - - void ScriptCanvasAssetHandler::SetSerializeContext(AZ::SerializeContext* context) - { - m_serializeContext = context; - - if (m_serializeContext == nullptr) - { - // use the default app serialize context - EBUS_EVENT_RESULT(m_serializeContext, AZ::ComponentApplicationBus, GetSerializeContext); - if (!m_serializeContext) - { - AZ_Error("Script Canvas", false, "ScriptCanvasAssetHandler: No serialize context provided! " - "We will not be able to process Graph Asset type"); - } - } - } - - void ScriptCanvasAssetHandler::GetHandledAssetTypes(AZStd::vector& assetTypes) - { - assetTypes.push_back(GetAssetType()); - } - - AZ::Data::AssetType ScriptCanvasAssetHandler::GetAssetType() const - { - return ScriptCanvasAssetHandler::GetAssetTypeStatic(); - } - - const char* ScriptCanvasAssetHandler::GetAssetTypeDisplayName() const - { - return "Script Canvas"; - } - - AZ::Data::AssetType ScriptCanvasAssetHandler::GetAssetTypeStatic() - { - return azrtti_typeid(); - } - - void ScriptCanvasAssetHandler::GetAssetTypeExtensions(AZStd::vector& extensions) - { - ScriptCanvasAsset::Description description; - extensions.push_back(description.GetExtensionImpl()); - } - - AZ::Uuid ScriptCanvasAssetHandler::GetComponentTypeId() const - { - return azrtti_typeid(); - } - - const char* ScriptCanvasAssetHandler::GetGroup() const - { - return ScriptCanvas::AssetDescription::GetGroup(); - } - - const char* ScriptCanvasAssetHandler::GetBrowserIcon() const - { - return ScriptCanvas::AssetDescription::GetIconPath(); - } -} diff --git a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetHolder.cpp b/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetHolder.cpp deleted file mode 100644 index f8c89ae7e5..0000000000 --- a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetHolder.cpp +++ /dev/null @@ -1,207 +0,0 @@ -/* - * 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 - -namespace ScriptCanvasEditor -{ - //========================================================================= - void ScriptCanvasAssetHolder::Reflect(AZ::ReflectContext* context) - { - if (auto serializeContext = azrtti_cast(context)) - { - serializeContext->Class() - ->Version(1) - ->Field("m_asset", &ScriptCanvasAssetHolder::m_scriptCanvasAsset) - ; - - if (AZ::EditContext* editContext = serializeContext->GetEditContext()) - { - editContext->Class("Script Canvas", "Script Canvas Asset Holder") - ->ClassElement(AZ::Edit::ClassElements::EditorData, "") - ->DataElement(AZ::Edit::UIHandlers::Default, &ScriptCanvasAssetHolder::m_scriptCanvasAsset, "Script Canvas Asset", "Script Canvas asset associated with this component") - ->Attribute(AZ::Edit::Attributes::ChangeNotify, &ScriptCanvasAssetHolder::OnScriptChanged) - ->Attribute("BrowseIcon", ":/stylesheet/img/UI20/browse-edit-select-files.svg") - ->Attribute("EditButton", "") - ->Attribute("EditDescription", "Open in Script Canvas Editor") - ->Attribute("EditCallback", &ScriptCanvasAssetHolder::LaunchScriptCanvasEditor) - ->Attribute(AZ::Edit::Attributes::ShowProductAssetFileName, false) - ; - } - } - } - - ScriptCanvasAssetHolder::~ScriptCanvasAssetHolder() - { - } - - void ScriptCanvasAssetHolder::Init(AZ::EntityId ownerId, AZ::ComponentId componentId) - { - m_ownerId = AZStd::make_pair(ownerId, componentId); - - if (!m_scriptCanvasAsset || !m_scriptCanvasAsset.IsReady()) - { - AssetTrackerNotificationBus::Handler::BusConnect(m_scriptCanvasAsset.GetId()); - - Callbacks::OnAssetReadyCallback onAssetReady = [](ScriptCanvasMemoryAsset& asset) - { - AssetHelpers::DumpAssetInfo(asset.GetFileAssetId(), "ScriptCanvasAssetHolder::Init"); - }; - AssetTrackerRequestBus::Broadcast(&AssetTrackerRequests::Load, m_scriptCanvasAsset.GetId(), azrtti_typeid(), onAssetReady); - } - } - - void ScriptCanvasAssetHolder::LaunchScriptCanvasEditor(const AZ::Data::AssetId&, const AZ::Data::AssetType&) const - { - OpenEditor(); - } - - void ScriptCanvasAssetHolder::OpenEditor() const - { - } - - ScriptCanvas::ScriptCanvasId ScriptCanvasAssetHolder::GetScriptCanvasId() const - { - ScriptCanvas::ScriptCanvasId graphId; - if (m_scriptCanvasAsset.IsReady()) - { - ScriptCanvas::SystemRequestBus::BroadcastResult(graphId, &ScriptCanvas::SystemRequests::FindScriptCanvasId, m_scriptCanvasAsset.Get()->GetScriptCanvasEntity()); - } - - return graphId; - } - - void ScriptCanvasAssetHolder::SetScriptChangedCB(const ScriptChangedCB& scriptChangedCB) - { - m_scriptNotifyCallback = scriptChangedCB; - } - - void ScriptCanvasAssetHolder::Load(AZ::Data::AssetId fileAssetId) - { - m_scriptCanvasAsset = AZ::Data::AssetManager::Instance().FindAsset(fileAssetId, AZ::Data::AssetLoadBehavior::Default); - - if (!m_scriptCanvasAsset || !m_scriptCanvasAsset.IsReady()) - { - m_scriptCanvasAsset = AZ::Data::AssetManager::Instance().GetAsset(fileAssetId, azrtti_typeid(), AZ::Data::AssetLoadBehavior::Default); - m_triggeredLoad = true; - - AZ::Data::AssetBus::Handler::BusDisconnect(); - AZ::Data::AssetBus::Handler::BusConnect(fileAssetId); - } - else if (m_memoryScriptCanvasAsset.Get() == nullptr) - { - m_triggeredLoad = false; - LoadMemoryAsset(fileAssetId); - } - } - - void ScriptCanvasAssetHolder::LoadMemoryAsset(AZ::Data::AssetId fileAssetId) - { - Callbacks::OnAssetReadyCallback onAssetReady = [this](ScriptCanvasMemoryAsset& asset) - { - m_memoryScriptCanvasAsset = asset.GetAsset(); - AssetHelpers::DumpAssetInfo(asset.GetFileAssetId(), "ScriptCanvasAssetHolder::Load onAssetReady"); - }; - - AssetTrackerRequestBus::Broadcast(&AssetTrackerRequests::Load, fileAssetId, azrtti_typeid(), onAssetReady); - } - - void ScriptCanvasAssetHolder::OnAssetReady(AZ::Data::Asset asset) - { - AZ::Data::AssetBus::Handler::BusDisconnect(); - LoadMemoryAsset(asset.GetId()); - } - - AZ::u32 ScriptCanvasAssetHolder::OnScriptChanged() - { - AssetTrackerNotificationBus::Handler::BusDisconnect(); - - if (m_scriptCanvasAsset.GetId().IsValid()) - { - AssetTrackerNotificationBus::Handler::BusConnect(m_scriptCanvasAsset.GetId()); - Load(m_scriptCanvasAsset.GetId()); - } - else - { - m_scriptCanvasAsset = {}; - m_memoryScriptCanvasAsset = {}; - } - - if (m_scriptNotifyCallback) - { - m_scriptNotifyCallback(m_scriptCanvasAsset.GetId()); - } - - return AZ::Edit::PropertyRefreshLevels::EntireTree; - } - - void ScriptCanvasAssetHolder::OnAssetReady(const ScriptCanvasMemoryAsset::pointer asset) - { - if (asset->GetFileAssetId() == m_scriptCanvasAsset.GetId()) - { - AssetTrackerNotificationBus::Handler::BusDisconnect(m_scriptCanvasAsset.GetId()); - - m_scriptCanvasAsset = AZ::Data::AssetManager::Instance().FindAsset(asset->GetFileAssetId(), AZ::Data::AssetLoadBehavior::Default); - m_memoryScriptCanvasAsset = asset->GetAsset(); - - if (m_triggeredLoad && m_scriptNotifyCallback) - { - m_triggeredLoad = false; - m_scriptNotifyCallback(m_scriptCanvasAsset.GetId()); - } - } - } - - void ScriptCanvasAssetHolder::SetAsset(AZ::Data::AssetId fileAssetId) - { - AZ::Data::AssetBus::Handler::BusDisconnect(); - AssetTrackerNotificationBus::Handler::BusDisconnect(); - - Load(fileAssetId); - - if (m_scriptCanvasAsset) - { - AssetTrackerNotificationBus::Handler::BusConnect(m_scriptCanvasAsset.GetId()); - } - } - - const AZ::Data::AssetType& ScriptCanvasAssetHolder::GetAssetType() const - { - return m_scriptCanvasAsset.GetType(); - } - - void ScriptCanvasAssetHolder::ClearAsset() - { - m_scriptCanvasAsset = {}; - m_memoryScriptCanvasAsset = {}; - } - - AZ::Data::AssetId ScriptCanvasAssetHolder::GetAssetId() const - { - return m_scriptCanvasAsset.GetId(); - } -} diff --git a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetHolder.h b/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetHolder.h deleted file mode 100644 index bc2f50144a..0000000000 --- a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetHolder.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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 - * - */ - -#pragma once - -#include -#include -#include - -#include -#include - -namespace ScriptCanvasEditor -{ - class ScriptCanvasAsset; - - /*! ScriptCanvasAssetHolder - Wraps a ScriptCanvasAsset reference and registers for the individual AssetBus events - for saving, loading and unloading the asset. - The ScriptCanvasAsset Holder contains functionality for activating the ScriptCanvasEntity stored on the reference asset - as well as attempting to open the ScriptCanvasAsset within the ScriptCanvas Editor. - It also provides the EditContext reflection for opening the asset in the ScriptCanvas Editor via a button - */ - class ScriptCanvasAssetHolder - : AssetTrackerNotificationBus::Handler - , AZ::Data::AssetBus::Handler - { - public: - AZ_RTTI(ScriptCanvasAssetHolder, "{3E80CEE3-2932-4DC1-AADF-398FDDC6DEFE}"); - AZ_CLASS_ALLOCATOR(ScriptCanvasAssetHolder, AZ::SystemAllocator, 0); - - using ScriptChangedCB = AZStd::function; - - ScriptCanvasAssetHolder() = default; - ~ScriptCanvasAssetHolder() override; - - static void Reflect(AZ::ReflectContext* context); - - void Init(AZ::EntityId ownerId = AZ::EntityId(), AZ::ComponentId componentId = AZ::ComponentId()); - - const AZ::Data::AssetType& GetAssetType() const; - void ClearAsset(); - - void SetAsset(AZ::Data::AssetId fileAssetId); - AZ::Data::AssetId GetAssetId() const; - - ScriptCanvas::ScriptCanvasId GetScriptCanvasId() const; - - void LaunchScriptCanvasEditor(const AZ::Data::AssetId&, const AZ::Data::AssetType&) const; - void OpenEditor() const; - - void SetScriptChangedCB(const ScriptChangedCB&); - void Load(AZ::Data::AssetId fileAssetId); - void LoadMemoryAsset(AZ::Data::AssetId fileAssetId); - - //! AZ::Data::AssetBus - void OnAssetReady(AZ::Data::Asset asset) override; - //// - - const AZStd::string_view GetAssetHint() const - { - if (m_scriptCanvasAsset) - { - return m_scriptCanvasAsset.GetHint().c_str(); - } - - if (m_memoryScriptCanvasAsset) - { - return m_memoryScriptCanvasAsset.GetHint().c_str(); - } - - return ""; - } - - protected: - - //===================================================================== - // AssetTrackerNotificationBus - void OnAssetReady(const ScriptCanvasMemoryAsset::pointer asset) override; - //===================================================================== - - //! Reloads the Script From the AssetData if it has changed - AZ::u32 OnScriptChanged(); - - AZ::Data::Asset m_scriptCanvasAsset; - AZ::Data::Asset m_memoryScriptCanvasAsset; - - TypeDefs::EntityComponentId m_ownerId; // Id of Entity which stores this AssetHolder object - ScriptChangedCB m_scriptNotifyCallback; - - bool m_triggeredLoad = false; - }; - -} diff --git a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetTracker.cpp b/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetTracker.cpp deleted file mode 100644 index 09b967281d..0000000000 --- a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetTracker.cpp +++ /dev/null @@ -1,441 +0,0 @@ -/* - * 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 "ScriptCanvasAssetTracker.h" - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include - -#include - -namespace ScriptCanvasEditor -{ - ///////////////// - // AssetTracker - ///////////////// - - AZ::Data::AssetId AssetTracker::Create(AZStd::string_view assetAbsolutePath, AZ::Data::AssetType assetType, Callbacks::OnAssetCreatedCallback onAssetCreatedCallback) - { - AZ::Data::AssetId newAssetId = AZ::Uuid::CreateRandom(); - - MemoryAssetMapIterator iterator = m_assetsInUse.emplace(newAssetId, AZStd::make_shared()); - - ScriptCanvasMemoryAsset::pointer memoryAsset = iterator.first->second; - - memoryAsset->Create(newAssetId, assetAbsolutePath, assetType, onAssetCreatedCallback); - - return newAssetId; - } - - bool AssetTracker::IsSaving(AZ::Data::AssetId assetId) const - { - assetId = CheckAssetId(assetId); - return m_savingAssets.find(assetId) != m_savingAssets.end(); - } - - void AssetTracker::Save(AZ::Data::AssetId assetId, Callbacks::OnSave onSaveCallback) - { - SaveAs(assetId, {}, onSaveCallback); - } - - void AssetTracker::SaveAs(AZ::Data::AssetId /*assetId*/, const AZStd::string& /*path*/, Callbacks::OnSave /*onSaveCallback*/) - { - } - - bool AssetTracker::Load(AZ::Data::AssetId fileAssetId, AZ::Data::AssetType assetType, Callbacks::OnAssetReadyCallback onAssetReadyCallback) - { - if (!fileAssetId.IsValid()) - { - return false; - } - - auto assetIter = m_assetsInUse.find(fileAssetId); - - if (assetIter != m_assetsInUse.end()) - { - if (!assetIter->second->IsSourceInError()) - { - if (onAssetReadyCallback) - { - // The asset is already loaded and tracked - AZStd::invoke(onAssetReadyCallback, *m_assetsInUse[fileAssetId]); - AssetTrackerNotificationBus::Event(fileAssetId, &AssetTrackerNotifications::OnAssetReady, m_assetsInUse[fileAssetId]); - } - - return true; - } - else - { - m_assetsInUse.erase(assetIter); - } - } - - m_assetsInUse[fileAssetId] = AZStd::make_shared(); - - m_onAssetReadyCallback = onAssetReadyCallback; - - auto onReady = [this, fileAssetId](ScriptCanvasMemoryAsset& asset) - { - m_remappedAsset[asset.GetId()] = fileAssetId; - - if (m_onAssetReadyCallback) - { - AZStd::invoke(m_onAssetReadyCallback, *m_assetsInUse[fileAssetId]); - } - }; - - // If we failed to load the asset, signal back as much - if (!m_assetsInUse[fileAssetId]->Load(fileAssetId, assetType, onReady)) - { - m_assetsInUse.erase(fileAssetId); - return false; - } - - return true; - } - - void AssetTracker::Close(AZ::Data::AssetId assetId) - { - assetId = CheckAssetId(assetId); - - if (m_assetsInUse.find(assetId) == m_assetsInUse.end()) - { - return; - } - - if (m_savingAssets.find(assetId) == m_savingAssets.end()) - { - m_assetsInUse.erase(assetId); - } - else - { - m_queuedCloses.insert(assetId); - } - } - - void AssetTracker::ClearView(AZ::Data::AssetId assetId) - { - assetId = CheckAssetId(assetId); - - if (m_assetsInUse.find(assetId) != m_assetsInUse.end()) - { - m_assetsInUse[assetId]->ClearView(); - } - } - - void AssetTracker::UntrackAsset(AZ::Data::AssetId assetId) - { - assetId = CheckAssetId(assetId); - m_assetsInUse.erase(assetId); - } - - void AssetTracker::RefreshAll() - { - for (const auto& asset : m_assetsInUse) - { - auto id = asset.second->GetScriptCanvasId(); - ScriptCanvasEditor::EditorGraphRequestBus::Event(id, &ScriptCanvasEditor::EditorGraphRequests::ClearGraphCanvasScene); - ScriptCanvasEditor::EditorGraphRequestBus::Event(id, &ScriptCanvasEditor::EditorGraphRequests::CreateGraphCanvasScene); - ScriptCanvasEditor::EditorGraphRequestBus::Event(id, &ScriptCanvasEditor::EditorGraphRequests::DisplayGraphCanvasScene); - } - } - - void AssetTracker::CreateView(AZ::Data::AssetId assetId, QWidget* parent) - { - assetId = CheckAssetId(assetId); - - if (m_assetsInUse.find(assetId) != m_assetsInUse.end()) - { - m_assetsInUse[assetId]->CreateView(parent); - } - } - - ScriptCanvasMemoryAsset::pointer AssetTracker::GetAsset(AZ::Data::AssetId assetId) - { - if (!assetId.IsValid()) - { - return nullptr; - } - - assetId = CheckAssetId(assetId); - - if (m_assetsInUse.find(assetId) == m_assetsInUse.end()) - { - auto asset = AZ::Data::AssetManager::Instance().FindAsset(assetId, AZ::Data::AssetLoadBehavior::Default); - if (asset) - { - auto insertResult = m_assetsInUse.emplace(AZStd::make_pair(assetId, AZStd::make_shared())); - - auto onReady = [this, assetId](ScriptCanvasMemoryAsset& asset) - { - m_remappedAsset[asset.GetId()] = assetId; - }; - - insertResult.first->second->Load(assetId, AZ::Data::AssetType::CreateNull(), onReady); - insertResult.first->second->ActivateAsset(); - - return insertResult.first->second; - } - - // Handle the weird case of saving out a file you can't load because of pathing issues. - for (auto assetPair : m_assetsInUse) - { - if (assetPair.second->GetFileAssetId() == assetId) - { - return assetPair.second; - } - } - - return nullptr; - } - - if (m_assetsInUse.find(assetId) != m_assetsInUse.end()) - { - return m_assetsInUse[assetId]; - } - - return nullptr; - } - - AZ::Data::AssetId AssetTracker::GetAssetId(ScriptCanvas::ScriptCanvasId scriptCanvasSceneId) - { - for (const auto& asset : m_assetsInUse) - { - if (asset.second && asset.second->GetScriptCanvasId() == scriptCanvasSceneId) - { - AZ::Data::AssetId assetId = asset.second->GetAsset().GetId(); - return assetId; - } - } - return {}; - } - - AZ::Data::AssetType AssetTracker::GetAssetType(ScriptCanvas::ScriptCanvasId scriptCanvasSceneId) - { - for (const auto& asset : m_assetsInUse) - { - if (asset.second && asset.second->GetScriptCanvasId() == scriptCanvasSceneId) - { - return asset.second->GetAssetType(); - } - } - return AZ::Data::AssetType::CreateNull(); - } - - - ScriptCanvas::ScriptCanvasId AssetTracker::GetScriptCanvasId(AZ::Data::AssetId assetId) - { - assetId = CheckAssetId(assetId); - - if (m_assetsInUse.find(assetId) != m_assetsInUse.end()) - { - return m_assetsInUse[assetId]->GetScriptCanvasId(); - } - return ScriptCanvas::ScriptCanvasId(); - } - - AZ::EntityId AssetTracker::GetGraphCanvasId(AZ::EntityId scriptCanvasEntityId) - { - if (scriptCanvasEntityId.IsValid()) - { - for (auto& asset : m_assetsInUse) - { - if (asset.second && asset.second->GetScriptCanvasId() == scriptCanvasEntityId) - { - return asset.second->GetGraphId(); - } - } - } - - return AZ::EntityId(); - } - - ScriptCanvas::ScriptCanvasId AssetTracker::GetScriptCanvasIdFromGraphId(AZ::EntityId graphId) - { - if (graphId.IsValid()) - { - for (auto& asset : m_assetsInUse) - { - if (asset.second && asset.second->GetGraphId() == graphId) - { - return asset.second->GetScriptCanvasId(); - } - } - } - return AZ::EntityId(); - } - - ScriptCanvas::ScriptCanvasId AssetTracker::GetGraphId(AZ::Data::AssetId assetId) - { - if (assetId.IsValid()) - { - assetId = CheckAssetId(assetId); - - auto assetIter = m_assetsInUse.find(assetId); - if (assetIter != m_assetsInUse.end()) - { - return assetIter->second->GetGraphId(); - } - } - - return ScriptCanvas::ScriptCanvasId(); - } - - AZStd::string AssetTracker::GetTabName(AZ::Data::AssetId assetId) - { - assetId = CheckAssetId(assetId); - - if (m_assetsInUse.find(assetId) != m_assetsInUse.end()) - { - return m_assetsInUse[assetId]->GetTabName(); - } - - return {}; - } - - ScriptCanvasEditor::Tracker::ScriptCanvasFileState AssetTracker::GetFileState(AZ::Data::AssetId assetId) - { - assetId = CheckAssetId(assetId); - - if (m_assetsInUse.find(assetId) != m_assetsInUse.end()) - { - return m_assetsInUse[assetId]->GetFileState(); - } - - return Tracker::ScriptCanvasFileState::INVALID; - } - - void AssetTracker::SignalSaveComplete(const AZ::Data::AssetId& fileAssetId) - { - size_t eraseCount = m_savingAssets.erase(fileAssetId); - - if (eraseCount > 0) - { - if (m_queuedCloses.erase(fileAssetId) > 0) - { - Close(fileAssetId); - } - } - } - - AZ::Data::AssetId AssetTracker::CheckAssetId(AZ::Data::AssetId assetId) const - { - auto remappedIter = m_remappedAsset.find(assetId); - if (remappedIter != m_remappedAsset.end()) - { - assetId = remappedIter->second; - } - return assetId; - } - - ScriptCanvasEditor::ScriptCanvasAssetHandler* AssetTracker::GetAssetHandlerForType(AZ::Data::AssetType assetType) - { - ScriptCanvasAssetHandler* assetHandler = nullptr; - - AZ::EBusAggregateResults foundAssetHandlers; - ScriptCanvas::AssetRegistryRequestBus::BroadcastResult(foundAssetHandlers, &ScriptCanvas::AssetRegistryRequests::GetAssetHandler); - - for (auto handler : foundAssetHandlers.values) - { - if (handler != nullptr) - { - ScriptCanvasAssetHandler* theHandler = azrtti_cast(handler); - if (theHandler != nullptr && theHandler->GetAssetType() == assetType) - { - assetHandler = theHandler; - break; - } - } - } - - AZ_Assert(assetHandler, "The specified asset type does not have a registered asset handler."); - return assetHandler; - } - - void AssetTracker::UpdateFileState(AZ::Data::AssetId assetId, Tracker::ScriptCanvasFileState state) - { - assetId = CheckAssetId(assetId); - - if (m_assetsInUse.find(assetId) != m_assetsInUse.end()) - { - m_assetsInUse[assetId]->SetFileState(state); - } - } - - AssetTrackerRequests::AssetList AssetTracker::GetUnsavedAssets() - { - auto pred = [](ScriptCanvasMemoryAsset::pointer asset) - { - auto fileState = asset->GetFileState(); - if (fileState == Tracker::ScriptCanvasFileState::NEW || fileState == Tracker::ScriptCanvasFileState::MODIFIED) - { - return true; - } - return false; - }; - - return GetAssetsIf(pred); - } - - AssetTrackerRequests::AssetList AssetTracker::GetAssets() - { - return GetAssetsIf([](ScriptCanvasMemoryAsset::pointer) { return true; }); - } - - AssetTrackerRequests::AssetList AssetTracker::GetAssetsIf(AZStd::function pred) - { - AZStd::vector unsavedAssets; - for (auto& assetIterator : m_assetsInUse) - { - auto testAsset = assetIterator.second; - if (AZStd::invoke(pred, testAsset) == true) - { - unsavedAssets.push_back(testAsset); - } - } - return unsavedAssets; - } - - AZ::EntityId AssetTracker::GetSceneEntityIdFromEditorEntityId(AZ::Data::AssetId assetId, AZ::EntityId editorEntityId) - { - assetId = CheckAssetId(assetId); - if (m_assetsInUse.find(assetId) != m_assetsInUse.end()) - { - return m_assetsInUse[assetId]->GetSceneEntityIdFromEditorEntityId(editorEntityId); - } - - return AZ::EntityId(); - } - - AZ::EntityId AssetTracker::GetEditorEntityIdFromSceneEntityId(AZ::Data::AssetId assetId, AZ::EntityId sceneEntityId) - { - assetId = CheckAssetId(assetId); - if (m_assetsInUse.find(assetId) != m_assetsInUse.end()) - { - return m_assetsInUse[assetId]->GetEditorEntityIdFromSceneEntityId(sceneEntityId); - } - - return AZ::EntityId(); - } - -} diff --git a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetTracker.h b/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetTracker.h deleted file mode 100644 index aa06029c98..0000000000 --- a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetTracker.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * 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 - * - */ - -#pragma once - -#include -#include -#include -#include - -#include - -#include -#include - - -namespace ScriptCanvasEditor -{ - class ScriptCanvasMemoryAsset; - - // This class tracks all things related to the assets that the Script Canvas editor - // has in play. It also provides helper functionality to quickly getting asset information - // from GraphCanvas - // - // The AssetTracker will be the ONLY allowed place to connect Script Canvas to the Asset System and any of its buses. - // - // The goal is to centralize all of the asset operations to a single place in order to simplify Script Canvas' - // interactions with the asset system as well as keeping any transient cache of information that is - // only important while Script Canvas graphs are open. - - class AssetTracker - : AssetTrackerRequestBus::Handler - , Internal::MemoryAssetSystemNotificationBus::Handler - { - public: - AssetTracker() = default; - ~AssetTracker() = default; - void Activate() - { - AssetTrackerRequestBus::Handler::BusConnect(); - Internal::MemoryAssetSystemNotificationBus::Handler::BusConnect(); - } - - void Deactivate() - { - Internal::MemoryAssetSystemNotificationBus::Handler::BusDisconnect(); - AssetTrackerRequestBus::Handler::BusDisconnect(); - } - - // AssetTrackerRequestBus - AZ::Data::AssetId Create(AZStd::string_view assetAbsolutePath, AZ::Data::AssetType assetType, Callbacks::OnAssetCreatedCallback onAssetCreatedCallback) override; - bool IsSaving(AZ::Data::AssetId assetId) const override; - void Save(AZ::Data::AssetId assetId, Callbacks::OnSave onSaveCallback) override; - void SaveAs(AZ::Data::AssetId assetId, const AZStd::string& path, Callbacks::OnSave onSaveCallback) override; - bool Load(AZ::Data::AssetId assetId, AZ::Data::AssetType assetType, Callbacks::OnAssetReadyCallback onAssetReadyCallback) override; - void Close(AZ::Data::AssetId assetId) override; - void CreateView(AZ::Data::AssetId assetId, QWidget* parent) override; - void ClearView(AZ::Data::AssetId assetId) override; - void UntrackAsset(AZ::Data::AssetId assetId) override; - void RefreshAll() override; - - // Getters - - // Given the assetId it returns a reference to the in-memory asset, returns false if the asset is not tracked - ScriptCanvasMemoryAsset::pointer GetAsset(AZ::Data::AssetId assetId) override; - - // Given a ScriptCanvas EntityId it will lookup the AssetId - AZ::Data::AssetId GetAssetId(ScriptCanvas::ScriptCanvasId scriptCanvasSceneId) override; - - // Given a ScriptCanvas EntityId it will lookup the asset's type - AZ::Data::AssetType GetAssetType(ScriptCanvas::ScriptCanvasId scriptCanvasSceneId) override; - - // Retrieves the ScriptCanvasEntity for a given asset - ScriptCanvas::ScriptCanvasId GetScriptCanvasId(AZ::Data::AssetId assetId) override; - - // Retrieves the Graph Canvas scene Id for a given asset - AZ::EntityId GetGraphCanvasId(AZ::EntityId scriptCanvasEntityId) override; - ScriptCanvas::ScriptCanvasId GetScriptCanvasIdFromGraphId(AZ::EntityId graphId) override; - ScriptCanvas::ScriptCanvasId GetGraphId(AZ::Data::AssetId assetId) override; - Tracker::ScriptCanvasFileState GetFileState(AZ::Data::AssetId assetId) override; - AZStd::string GetTabName(AZ::Data::AssetId assetId) override; - ScriptCanvasEditor::ScriptCanvasAssetHandler* GetAssetHandlerForType(AZ::Data::AssetType assetType) override; - void UpdateFileState(AZ::Data::AssetId assetId, Tracker::ScriptCanvasFileState state) override; - - AssetTrackerRequests::AssetList GetUnsavedAssets() override; - AssetTrackerRequests::AssetList GetAssets() override; - AssetTrackerRequests::AssetList GetAssetsIf(AZStd::function pred = []() { return true; }) override; - - AZ::EntityId GetSceneEntityIdFromEditorEntityId(AZ::Data::AssetId assetId, AZ::EntityId editorEntityId) override; - AZ::EntityId GetEditorEntityIdFromSceneEntityId(AZ::Data::AssetId assetId, AZ::EntityId sceneEntityId) override; - // - - private: - - void SignalSaveComplete(const AZ::Data::AssetId& fileAssetId); - - // Verifies if an asset Id has been remapped, this happens when we save a new graph because the AssetId will - // change on save, but there may be some UX elements still referring to the initial asset Id, this ensures - // we are getting the right key into m_assetsInUse - AZ::Data::AssetId CheckAssetId(AZ::Data::AssetId assetId) const; - - // Map of all the currently tracked in-memory assets - using MemoryAssetMap = AZStd::unordered_map; - using MemoryAssetMapIterator = AZStd::pair>, bool>; - - AZStd::unordered_set m_savingAssets; - AZStd::unordered_set m_queuedCloses; - - // Map of all assets being tracked - MemoryAssetMap m_assetsInUse; - - // When a graph has been saved to file, its Id will change but it may still have external references with the old Id, this maps the file Id to the in-memory Id - AZStd::unordered_map m_remappedAsset; - - // Invoked when an asset is loaded from file and becomes ready - Callbacks::OnAssetReadyCallback m_onAssetReadyCallback; - - }; -} diff --git a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetTrackerBus.h b/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetTrackerBus.h deleted file mode 100644 index 7125cb7d9b..0000000000 --- a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetTrackerBus.h +++ /dev/null @@ -1,159 +0,0 @@ -/* - * 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 - * - */ - -#pragma once - -#include -#include -#include -#include - -#include - -#include -#include -#include - -class QWidget; - -namespace AZ -{ - class EntityId; -} - -namespace ScriptCanvas -{ - class ScriptCanvasAssetBase; -} - -namespace ScriptCanvasEditor -{ - class ScriptCanvasAssetHandler; - - class AssetTrackerRequests - : public AZ::EBusTraits - { - public: - - static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single; - - //! Callback used to know when a save operation failed or succeeded - using OnSave = AZStd::function)>; - - //! Callback used when the asset has been loaded and is ready for use - using OnAssetReadyCallback = AZStd::function; - - //! Callback used when the asset is newly created - using OnAssetCreatedCallback = OnAssetReadyCallback; - - // Operations - - //! Creates a new Script Canvas asset and tracks it - virtual AZ::Data::AssetId Create([[maybe_unused]] AZStd::string_view assetAbsolutePath, [[maybe_unused]] AZ::Data::AssetType assetType, Callbacks::OnAssetCreatedCallback onAssetCreatedCallback) { return AZ::Data::AssetId(); } - - //! Saves a Script Canvas asset to a new file, once the save is complete it will use the source Id (not the Id of the in-memory asset) - virtual void SaveAs([[maybe_unused]] AZ::Data::AssetId assetId, [[maybe_unused]] const AZStd::string& path, Callbacks::OnSave onSaveCallback) {} - - //! Saves a previously loaded Script Canvas asset to file - virtual void Save([[maybe_unused]] AZ::Data::AssetId assetId, Callbacks::OnSave onSaveCallback) {} - - //! Returns whether or not the specified asset is currently saving - virtual bool IsSaving([[maybe_unused]] AZ::Data::AssetId assetId) const { return false; } - - //! Loads a Script Canvas graph - virtual bool Load([[maybe_unused]] AZ::Data::AssetId assetId, [[maybe_unused]] AZ::Data::AssetType assetType, Callbacks::OnAssetReadyCallback onAssetReadyCallback) { return false; } - - //! Closes and unloads a Script Canvas graph from the tracker - virtual void Close([[maybe_unused]] AZ::Data::AssetId assetId) {} - - //! Creates the asset's view - virtual void CreateView([[maybe_unused]] AZ::Data::AssetId assetId, [[maybe_unused]] QWidget* parent) {} - - //! Releases the asset's view - virtual void ClearView([[maybe_unused]] AZ::Data::AssetId assetId) {} - - //! Used to make sure assets that are unloaded also get removed from tracking - virtual void UntrackAsset([[maybe_unused]] AZ::Data::AssetId assetId) {} - - //! Recreates the view for all tracked assets - virtual void RefreshAll() {} - - using AssetList = AZStd::vector; - - // Accessors - virtual ScriptCanvasMemoryAsset::pointer GetAsset([[maybe_unused]] AZ::Data::AssetId assetId) { return nullptr; } - virtual ScriptCanvas::ScriptCanvasId GetScriptCanvasId([[maybe_unused]] AZ::Data::AssetId assetId) { return AZ::EntityId(); } - virtual ScriptCanvas::ScriptCanvasId GetScriptCanvasIdFromGraphId([[maybe_unused]] AZ::EntityId graphId) { return AZ::EntityId(); } - virtual ScriptCanvas::ScriptCanvasId GetGraphCanvasId(AZ::EntityId) { return AZ::EntityId(); } - virtual ScriptCanvas::ScriptCanvasId GetGraphId([[maybe_unused]] AZ::Data::AssetId assetId) { return ScriptCanvas::ScriptCanvasId(); } - virtual Tracker::ScriptCanvasFileState GetFileState([[maybe_unused]] AZ::Data::AssetId assetId) { return Tracker::ScriptCanvasFileState::INVALID; } - virtual AZ::Data::AssetId GetAssetId([[maybe_unused]] ScriptCanvas::ScriptCanvasId scriptCanvasSceneId) { return {}; } - virtual AZ::Data::AssetType GetAssetType([[maybe_unused]] ScriptCanvas::ScriptCanvasId scriptCanvasSceneId) { return {}; } - virtual AZStd::string GetTabName([[maybe_unused]] AZ::Data::AssetId assetId) { return {}; } - virtual AssetList GetUnsavedAssets() { return {}; } - virtual AssetList GetAssets() { return {}; } - virtual AssetList GetAssetsIf(AZStd::function) { return {}; } - - virtual AZ::EntityId GetSceneEntityIdFromEditorEntityId([[maybe_unused]] AZ::Data::AssetId assetId, [[maybe_unused]] AZ::EntityId editorEntityId) { return AZ::EntityId(); } - virtual AZ::EntityId GetEditorEntityIdFromSceneEntityId([[maybe_unused]] AZ::Data::AssetId assetId, [[maybe_unused]] AZ::EntityId sceneEntityId) { return AZ::EntityId(); } - - // Setters / Updates - virtual void UpdateFileState([[maybe_unused]] AZ::Data::AssetId assetId, [[maybe_unused]] Tracker::ScriptCanvasFileState state) {} - - // Helpers - virtual ScriptCanvasAssetHandler* GetAssetHandlerForType([[maybe_unused]] AZ::Data::AssetType assetType) { return nullptr; } - }; - - using AssetTrackerRequestBus = AZ::EBus; - - //! These are the notifications sent by the AssetTracker only. - //! We use these to communicate the asset status, do not use the AssetBus directly, all Script Canvas - //! assets are managed by the AssetTracker - class AssetTrackerNotifications - : public AZ::EBusTraits - { - public: - - static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple; - static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById; - using BusIdType = AZ::Data::AssetId; - - // These will be forwarded as a result of the Asset System's events - // this is deliberate in order to keep the AssetTracker as the only - // place that interacts directly with the asset bus, but allowing - // other systems to know the status of tracked assets - virtual void OnAssetReady(const ScriptCanvasMemoryAsset::pointer asset) {} - virtual void OnAssetReloaded(const ScriptCanvasMemoryAsset::pointer asset) {} - virtual void OnAssetUnloaded([[maybe_unused]] const AZ::Data::AssetId assetId, [[maybe_unused]] const AZ::Data::AssetType assetType) {} - virtual void OnAssetSaved(const ScriptCanvasMemoryAsset::pointer asset, [[maybe_unused]] bool isSuccessful) {} - virtual void OnAssetError(const ScriptCanvasMemoryAsset::pointer asset) {} - - }; - using AssetTrackerNotificationBus = AZ::EBus; - - namespace Internal - { - class MemoryAssetSystemNotifications - : public AZ::EBusTraits - { - public: - - static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single; - static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single; - - virtual void OnAssetReady([[maybe_unused]] const ScriptCanvasMemoryAsset* asset) {} - virtual void OnAssetReloaded([[maybe_unused]] const ScriptCanvasMemoryAsset* asset) {} - virtual void OnAssetSaved([[maybe_unused]] const ScriptCanvasMemoryAsset* asset, [[maybe_unused]] bool isSuccessful) {} - virtual void OnAssetError([[maybe_unused]] const ScriptCanvasMemoryAsset* asset) {} - - }; - using MemoryAssetSystemNotificationBus = AZ::EBus; - } - - ////////////////////////////////////////////////////////////////////////////////////////////////////////// -} diff --git a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetTrackerDefinitions.h b/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetTrackerDefinitions.h deleted file mode 100644 index 73507112c2..0000000000 --- a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetTrackerDefinitions.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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 - * - */ - -#pragma once - -#include -#include - -namespace ScriptCanvasEditor -{ - class ScriptCanvasMemoryAsset; - - namespace Callbacks - { - //! Callback used to know when a save operation failed or succeeded - using OnSave = AZStd::function; - - using OnAssetReadyCallback = AZStd::function; - using OnAssetCreatedCallback = OnAssetReadyCallback; - } - - -} diff --git a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasMemoryAsset.cpp b/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasMemoryAsset.cpp deleted file mode 100644 index 439f9a8383..0000000000 --- a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasMemoryAsset.cpp +++ /dev/null @@ -1,684 +0,0 @@ -/* - * 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 "ScriptCanvasMemoryAsset.h" -#include "ScriptCanvasUndoHelper.h" - -#include -#include -#include -#include -#include - -namespace ScriptCanvasEditor -{ - ScriptCanvasMemoryAsset::ScriptCanvasMemoryAsset() - : m_sourceInError(false) - { - m_undoState = AZStd::make_unique(this); - } - - ScriptCanvasMemoryAsset::~ScriptCanvasMemoryAsset() - { - AssetTrackerRequestBus::Broadcast(&AssetTrackerRequests::UntrackAsset, m_inMemoryAssetId); - AssetHelpers::PrintInfo(AZStd::string::format("ScriptCanvasMemoryAsset went out of scope and has been released and untracked: %s", m_absolutePath.c_str()).c_str()); - - if (m_inMemoryAsset.IsReady() && !m_inMemoryAsset.Release()) - { - // Something else is holding on to it - AZ_Assert(false, "Unable to release in memory asset"); - } - } - - const AZStd::string ScriptCanvasMemoryAsset::GetTabName() const - { - AZStd::string tabName; - AzFramework::StringFunc::Path::GetFileName(m_absolutePath.c_str(), tabName); - return tabName; - } - - AZ::EntityId ScriptCanvasMemoryAsset::GetGraphId() - { - if (!m_graphId.IsValid()) - { - EditorGraphRequestBus::EventResult(m_graphId, m_scriptCanvasId, &EditorGraphRequests::GetGraphCanvasGraphId); - } - - return m_graphId; - } - - Tracker::ScriptCanvasFileState ScriptCanvasMemoryAsset::GetFileState() const - { - if (m_sourceRemoved) - { - return Tracker::ScriptCanvasFileState::SOURCE_REMOVED; - } - else - { - return m_fileState; - } - } - - void ScriptCanvasMemoryAsset::SetFileState(Tracker::ScriptCanvasFileState fileState) - { - m_fileState = fileState; - - SignalFileStateChanged(); - } - - void ScriptCanvasMemoryAsset::CloneTo(ScriptCanvasMemoryAsset& memoryAsset) - { - if (m_assetType == azrtti_typeid()) - { - AZ::Data::Asset newAsset = Clone(); - memoryAsset.m_inMemoryAsset = newAsset; - } - else - { - AZ_Assert(false, "Unsupported Script Canvas Asset Type"); - } - - memoryAsset.m_sourceAsset = m_sourceAsset; - } - - void ScriptCanvasMemoryAsset::Create(AZ::Data::AssetId assetId, AZStd::string_view assetAbsolutePath, AZ::Data::AssetType assetType, Callbacks::OnAssetCreatedCallback onAssetCreatedCallback) - { - m_inMemoryAssetId = assetId; - m_absolutePath = assetAbsolutePath; - m_assetType = assetType; - m_fileState = Tracker::ScriptCanvasFileState::NEW; - - ScriptCanvasAssetHandler* assetHandler = GetAssetHandlerForType(assetType); - - AZ::Data::AssetPtr asset = nullptr; - if (assetType == azrtti_typeid()) - { - asset = assetHandler->CreateAsset(assetId, azrtti_typeid()); - } - - m_inMemoryAsset = AZ::Data::Asset(asset, AZ::Data::AssetLoadBehavior::PreLoad); - - ActivateAsset(); - - // For new assets, we directly set its status as "Ready" in order to make it usable. - ScriptCanvas::ScriptCanvasAssetBusRequestBus::Event(assetId, &ScriptCanvas::ScriptCanvasAssetBusRequests::SetAsNewAsset); - - Internal::MemoryAssetSystemNotificationBus::Broadcast(&Internal::MemoryAssetSystemNotifications::OnAssetReady, this); - - AssetHelpers::PrintInfo("Newly created Script Canvas asset is now tracked: %s", AssetHelpers::AssetIdToString(assetId).c_str()); - - if (onAssetCreatedCallback) - { - AZStd::invoke(onAssetCreatedCallback, *this); - } - } - - void ScriptCanvasMemoryAsset::Save(Callbacks::OnSave onSaveCallback) - { - if (m_fileState == Tracker::ScriptCanvasFileState::UNMODIFIED) - { - // The file hasn't changed, don't save it - return; - } - - SaveAs({}, onSaveCallback); - } - - void ScriptCanvasMemoryAsset::SaveAs(const AZStd::string& path, Callbacks::OnSave onSaveCallback) - { - if (!path.empty()) - { - m_saveAsPath = path; - } - else - { - m_saveAsPath = m_absolutePath; - } - - AZ::Data::AssetStreamInfo streamInfo; - streamInfo.m_streamFlags = AZ::IO::OpenMode::ModeWrite; - streamInfo.m_streamName = m_saveAsPath; - - if (!streamInfo.IsValid()) - { - return; - } - - bool sourceControlActive = false; - AzToolsFramework::SourceControlConnectionRequestBus::BroadcastResult(sourceControlActive, &AzToolsFramework::SourceControlConnectionRequests::IsActive); - // If Source Control is active then use it to check out the file before saving otherwise query the file info and save only if the file is not read-only - if (sourceControlActive) - { - AzToolsFramework::SourceControlCommandBus::Broadcast(&AzToolsFramework::SourceControlCommandBus::Events::RequestEdit, - streamInfo.m_streamName.c_str(), - true, - [this, streamInfo, onSaveCallback](bool success, AzToolsFramework::SourceControlFileInfo info) { FinalizeAssetSave(success, info, streamInfo, onSaveCallback); } - ); - } - else - { - AzToolsFramework::SourceControlCommandBus::Broadcast(&AzToolsFramework::SourceControlCommandBus::Events::GetFileInfo, - streamInfo.m_streamName.c_str(), - [this, streamInfo, onSaveCallback](bool success, AzToolsFramework::SourceControlFileInfo info) { FinalizeAssetSave(success, info, streamInfo, onSaveCallback); } - ); - } - } - - void ScriptCanvasMemoryAsset::Set(AZ::Data::AssetId fileAssetId) - { - Callbacks::OnAssetReadyCallback onAssetReady = [](ScriptCanvasMemoryAsset&) {}; - Load(fileAssetId, AZ::Data::AssetType::CreateNull(), onAssetReady); - - ActivateAsset(); - } - - bool ScriptCanvasMemoryAsset::Load(AZ::Data::AssetId assetId, AZ::Data::AssetType assetType, Callbacks::OnAssetReadyCallback onAssetReadyCallback) - { - AZStd::string rootPath; - AZ::Data::AssetInfo assetInfo = AssetHelpers::GetAssetInfo(assetId, rootPath); - AzFramework::StringFunc::Path::Join(rootPath.c_str(), assetInfo.m_relativePath.c_str(), m_absolutePath); - - if (assetInfo.m_assetType.IsNull()) - { - // Try to find the asset type from the source file asset - assetInfo.m_assetType = AssetHelpers::GetAssetType(AZStd::string::format("%s/%s", rootPath.c_str(), assetInfo.m_relativePath.c_str()).c_str()); - } - - if (!assetType.IsNull() && assetInfo.m_assetType.IsNull()) - { - assetInfo.m_assetType = assetType; - } - else - { - AZ_Assert(assetInfo.m_assetId.IsValid(), "Failed to get the asset info properly from the asset system"); - } - - SetFileAssetId(assetId); - - auto asset = AZ::Data::AssetManager::Instance().FindAsset(assetId, AZ::Data::AssetLoadBehavior::PreLoad); - if (!asset || !asset.IsReady()) - { - AZ::Data::AssetBus::MultiHandler::BusConnect(assetId); - } - - if (assetInfo.m_assetType == azrtti_typeid()) - { - m_inMemoryAsset = AZ::Data::AssetManager::Instance().GetAsset(assetId, AZ::Data::AssetLoadBehavior::Default); - } - - if (m_inMemoryAsset) - { - m_inMemoryAsset.BlockUntilLoadComplete(); - - m_sourceAsset = m_inMemoryAsset; - - m_assetType = m_inMemoryAsset->GetType(); - - AZ_Assert(m_inMemoryAsset.GetId() == assetId, "The asset IDs must match"); - - m_onAssetReadyCallback = onAssetReadyCallback; - - if (m_inMemoryAsset.IsReady()) - { - OnAssetReady(m_inMemoryAsset); - } - } - - return !m_inMemoryAsset.IsError(); - } - - void ScriptCanvasMemoryAsset::ActivateAsset() - { - ScriptCanvas::ScriptCanvasAssetBase* assetData = m_inMemoryAsset.Get(); - AZ_Assert(assetData, "ActivateAsset should have a valid asset of type %s", AssetHelpers::AssetIdToString(azrtti_typeid()).c_str()); - - if (assetData == nullptr) - { - return; - } - - AZ::Entity* scriptCanvasEntity = assetData->GetScriptCanvasEntity(); - AZ_Assert(scriptCanvasEntity, "ActivateAsset should have a valid ScriptCanvas Entity"); - - // Only activate the entity for assets that have been saved - if (scriptCanvasEntity->GetState() == AZ::Entity::State::Constructed) - { - scriptCanvasEntity->Init(); - } - - if (scriptCanvasEntity->GetState() == AZ::Entity::State::Init) - { - scriptCanvasEntity->Activate(); - } - - const AZStd::string& assetPath = m_absolutePath; - AZStd::string graphName; - AzFramework::StringFunc::Path::GetFileName(assetPath.c_str(), graphName); - - if (!graphName.empty()) - { - scriptCanvasEntity->SetName(graphName); - } - - Graph* editorGraph = AZ::EntityUtils::FindFirstDerivedComponent(scriptCanvasEntity); - AZ_Assert(editorGraph, "Script Canvas entity must have a Graph component"); - - if (editorGraph == nullptr) - { - return; - } - - m_scriptCanvasId = editorGraph->GetScriptCanvasId(); - - EditorGraphNotificationBus::Handler::BusDisconnect(); - EditorGraphNotificationBus::Handler::BusConnect(m_scriptCanvasId); - } - - ScriptCanvasEditor::Widget::CanvasWidget* ScriptCanvasMemoryAsset::CreateView(QWidget* /*parent*/) - { - return nullptr; - } - - void ScriptCanvasMemoryAsset::ClearView() - { - delete m_canvasWidget; - m_canvasWidget = nullptr; - } - - void ScriptCanvasMemoryAsset::UndoStackChange() - { - OnUndoStackChanged(); - } - - bool ScriptCanvasMemoryAsset::IsSourceInError() const - { - return m_sourceInError; - } - - void ScriptCanvasMemoryAsset::OnGraphCanvasSceneDisplayed() - { - // We need to wait until this event in order the get the m_graphId which represents the GraphCanvas scene Id - EditorGraphRequestBus::EventResult(m_graphId, m_scriptCanvasId, &EditorGraphRequests::GetGraphCanvasGraphId); - EditorGraphNotificationBus::Handler::BusDisconnect(); - } - - void ScriptCanvasMemoryAsset::OnAssetReady(AZ::Data::Asset asset) - { - // If we've already cloned the memory asset, we don't want to do the start-up things again. - if (m_inMemoryAsset->GetId() == m_sourceAsset.GetId()) - { - AZStd::string rootPath; - AZ::Data::AssetInfo assetInfo = AssetHelpers::GetAssetInfo(m_fileAssetId, rootPath); - - AZStd::string absolutePath; - AzFramework::StringFunc::Path::Join(rootPath.c_str(), assetInfo.m_relativePath.c_str(), absolutePath); - - m_absolutePath = absolutePath; - m_fileState = Tracker::ScriptCanvasFileState::UNMODIFIED; - m_assetType = asset.GetType(); - - // Keep the canonical asset's Id, we will need it when we want to save the asset back to file - SetFileAssetId(asset.GetId()); - - // The source file is ready, we need to make the an in-memory version of it. - AZ::Data::AssetId inMemoryAssetId = AZ::Uuid::CreateRandom(); - - m_sourceAsset = AZ::Data::AssetManager::Instance().FindAsset(m_fileAssetId, AZ::Data::AssetLoadBehavior::PreLoad); - m_inMemoryAsset = AZStd::move(CloneAssetData(inMemoryAssetId)); - - AZ_Assert(m_inMemoryAsset, "Asset should have been successfully cloned."); - AZ_Assert(m_inMemoryAsset.GetId() == inMemoryAssetId, "Asset Id should match to the newly created one"); - - m_inMemoryAssetId = m_inMemoryAsset.GetId(); - - ActivateAsset(); - - if (m_onAssetReadyCallback) - { - AZStd::invoke(m_onAssetReadyCallback, *this); - } - } - // Instead just update the source asset to the get the new asset to keep it in memory. - else - { - m_sourceAsset = AZ::Data::AssetManager::Instance().FindAsset(m_fileAssetId, AZ::Data::AssetLoadBehavior::PreLoad); - } - - if (m_fileAssetId == asset.GetId()) - { - Internal::MemoryAssetSystemNotificationBus::Broadcast(&Internal::MemoryAssetSystemNotifications::OnAssetReady, this); - } - } - - void ScriptCanvasMemoryAsset::OnAssetReloaded(AZ::Data::Asset asset) - { - if (m_fileAssetId == asset.GetId()) - { - m_sourceInError = false; - - // Update our source asset information so we keep references alive. - m_sourceAsset = AZ::Data::AssetManager::Instance().FindAsset(m_fileAssetId, AZ::Data::AssetLoadBehavior::PreLoad); - - // The source file was reloaded, but we have an in-memory version of it. - // We need to handle this. - } - else - { - Internal::MemoryAssetSystemNotificationBus::Broadcast(&Internal::MemoryAssetSystemNotifications::OnAssetReloaded, this); - } - } - - void ScriptCanvasMemoryAsset::OnAssetError(AZ::Data::Asset asset) - { - if (m_fileAssetId == asset.GetId()) - { - m_sourceInError = true; - - if (m_onAssetReadyCallback) - { - AZStd::invoke(m_onAssetReadyCallback, *this); - } - } - else - { - Internal::MemoryAssetSystemNotificationBus::Broadcast(&Internal::MemoryAssetSystemNotifications::OnAssetError, this); - } - } - - void ScriptCanvasMemoryAsset::OnAssetUnloaded(const AZ::Data::AssetId assetId, const AZ::Data::AssetType assetType) - { - if (m_fileAssetId == assetId) - { - AssetTrackerNotificationBus::Event(assetId, &AssetTrackerNotifications::OnAssetUnloaded, assetId, assetType); - } - } - - void ScriptCanvasMemoryAsset::SourceFileChanged(AZStd::string relativePath, AZStd::string scanFolder, AZ::Uuid sourceAssetId) - { - // This updates the asset Id with the canonical assetId on SourceFileChanged - - // This occurs for new ScriptCanvas assets because before the SC asset is saved to disk, the asset database - // has no asset Id associated with it, so this uses the supplied source path to find the asset Id registered - AZStd::string fullPath; - AzFramework::StringFunc::Path::Join(scanFolder.data(), relativePath.data(), fullPath); - AzFramework::ApplicationRequests::Bus::Broadcast(&AzFramework::ApplicationRequests::NormalizePath, fullPath); - - SavingComplete(fullPath, sourceAssetId); - } - - - - void ScriptCanvasMemoryAsset::SourceFileRemoved(AZStd::string relativePath, AZStd::string scanFolder, AZ::Uuid fileAssetId) - { - AZ_UNUSED(relativePath); - AZ_UNUSED(scanFolder); - - if (m_fileAssetId == fileAssetId) - { - m_sourceRemoved = true; - SignalFileStateChanged(); - } - } - - void ScriptCanvasMemoryAsset::SourceFileFailed(AZStd::string /*relativePath*/, AZStd::string /*scanFolder*/, AZ::Uuid) - { - - } - - void ScriptCanvasMemoryAsset::SavingComplete(const AZStd::string& /*streamName*/, AZ::Uuid /*sourceAssetId*/) - { - } - - void ScriptCanvasMemoryAsset::FinalizeAssetSave(bool, const AzToolsFramework::SourceControlFileInfo& fileInfo, const AZ::Data::AssetStreamInfo& saveInfo, Callbacks::OnSave onSaveCallback) - { - m_onSaveCallback = onSaveCallback; - - AZStd::string normPath = saveInfo.m_streamName; - AzFramework::ApplicationRequests::Bus::Broadcast(&AzFramework::ApplicationRequests::NormalizePath, normPath); - m_pendingSave.emplace_back(normPath); - - m_assetSaveFinalizer.Reset(); - m_assetSaveFinalizer.Start(this, fileInfo, saveInfo, onSaveCallback, AssetSaveFinalizer::OnCompleteHandler([](AZ::Data::AssetId /*assetId*/) - { - })); - } - - AZ::Data::Asset ScriptCanvasMemoryAsset::CloneAssetData(AZ::Data::AssetId newAssetId) - { - if (m_assetType == azrtti_typeid()) - { - return CloneAssetData(newAssetId); - } - - AZ_Assert(false, "The provides asset type is not supported as a valid Script Canvas memory asset"); - return AZ::Data::Asset(); - } - - void ScriptCanvasMemoryAsset::OnUndoStackChanged() - { - UndoNotificationBus::Broadcast(&UndoNotifications::OnCanUndoChanged, m_undoState->m_undoStack->CanUndo()); - UndoNotificationBus::Broadcast(&UndoNotifications::OnCanRedoChanged, m_undoState->m_undoStack->CanRedo()); - } - - void ScriptCanvasMemoryAsset::SetFileAssetId(const AZ::Data::AssetId& /*fileAssetId*/) - { - - } - - void ScriptCanvasMemoryAsset::SignalFileStateChanged() - { - } - - AZStd::string ScriptCanvasMemoryAsset::MakeTemporaryFilePathForSave(AZStd::string_view targetFilename) - { - AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance(); - AZ_Assert(fileIO, "File IO is not initialized."); - - AZStd::string tempFilename; - AzFramework::StringFunc::Path::GetFullFileName(targetFilename.data(), tempFilename); - AZStd::string tempPath = AZStd::string::format("@usercache@/scriptcanvas/%s.temp", tempFilename.data()); - - AZStd::array resolvedPath{}; - fileIO->ResolvePath(tempPath.data(), resolvedPath.data(), resolvedPath.size()); - return resolvedPath.data(); - } - - ScriptCanvasAssetHandler* ScriptCanvasMemoryAsset::GetAssetHandlerForType(AZ::Data::AssetType assetType) - { - ScriptCanvasAssetHandler* assetHandler = nullptr; - - AZ::EBusAggregateResults foundAssetHandlers; - ScriptCanvas::AssetRegistryRequestBus::BroadcastResult(foundAssetHandlers, &ScriptCanvas::AssetRegistryRequests::GetAssetHandler); - - for (auto handler : foundAssetHandlers.values) - { - if (handler != nullptr) - { - ScriptCanvasAssetHandler* theHandler = azrtti_cast(handler); - if (theHandler != nullptr && theHandler->GetAssetType() == assetType) - { - assetHandler = theHandler; - break; - } - } - } - - AZ_Assert(assetHandler, "The specified asset type does not have a registered asset handler."); - return assetHandler; - } - - AZ::EntityId ScriptCanvasMemoryAsset::GetEditorEntityIdFromSceneEntityId(AZ::EntityId sceneEntityId) - { - if (m_editorEntityIdMap.find(sceneEntityId) != m_editorEntityIdMap.end()) - { - return m_editorEntityIdMap[sceneEntityId]; - } - - return AZ::EntityId(); - } - - AZ::EntityId ScriptCanvasMemoryAsset::GetSceneEntityIdFromEditorEntityId(AZ::EntityId editorEntityId) - { - for (auto mapEntry : m_editorEntityIdMap) - { - if (mapEntry.second == editorEntityId) - { - return mapEntry.first; - } - } - - return AZ::EntityId(); - } - - // AssetSaveFinalizer - ////////////////////////////////////// - - bool AssetSaveFinalizer::ValidateStatus(const AzToolsFramework::SourceControlFileInfo& /*fileInfo*/) - { - return true; - } - - AssetSaveFinalizer::AssetSaveFinalizer() - : m_inMemoryAsset(nullptr) - , m_sourceAsset(nullptr) - , m_saving(false) - , m_fileAvailableForSave(false) - { - - } - - AssetSaveFinalizer::~AssetSaveFinalizer() - { - AZ::SystemTickBus::Handler::BusDisconnect(); - } - - void AssetSaveFinalizer::Start(ScriptCanvasMemoryAsset* sourceAsset, const AzToolsFramework::SourceControlFileInfo& fileInfo, const AZ::Data::AssetStreamInfo& saveInfo, Callbacks::OnSave onSaveCallback, OnCompleteHandler onComplete) - { - m_onCompleteHandler = onComplete; - m_onCompleteHandler.Connect(m_onComplete); - - m_saveInfo = saveInfo; - m_onSave = onSaveCallback; - m_sourceAsset = sourceAsset; - m_inMemoryAsset = sourceAsset->GetAsset().Get(); - m_assetType = sourceAsset->GetAssetType(); - - if (!ValidateStatus(fileInfo)) - { - return; - } - - auto streamer = AZ::Interface::Get(); - AZ::IO::FileRequestPtr flushRequest = streamer->FlushCache(saveInfo.m_streamName.data()); - streamer->SetRequestCompleteCallback(flushRequest, [this]([[maybe_unused]] AZ::IO::FileRequestHandle request) - { - m_fileAvailableForSave = true; - }); - streamer->QueueRequest(flushRequest); - - AZ::SystemTickBus::Handler::BusConnect(); - - m_saving = true; - } - - AZStd::string AssetSaveFinalizer::MakeTemporaryFilePathForSave(AZStd::string_view targetFilename) - { - AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance(); - AZ_Assert(fileIO, "File IO is not initialized."); - - AZStd::string tempFilename; - AzFramework::StringFunc::Path::GetFullFileName(targetFilename.data(), tempFilename); - AZStd::string tempPath = AZStd::string::format("@usercache@/scriptcanvas/%s.temp", tempFilename.data()); - - AZStd::array resolvedPath{}; - fileIO->ResolvePath(tempPath.data(), resolvedPath.data(), resolvedPath.size()); - return resolvedPath.data(); - } - - void AssetSaveFinalizer::OnSystemTick() - { - if (m_fileAvailableForSave) - { - - AZ::SystemTickBus::Handler::BusDisconnect(); - - m_fileAvailableForSave = false; - - const AZStd::string tempPath = MakeTemporaryFilePathForSave(m_saveInfo.m_streamName); - AZ::IO::FileIOStream stream(tempPath.data(), m_saveInfo.m_streamFlags); - if (stream.IsOpen()) - { - ScriptCanvasAssetHandler* assetHandler = nullptr; - AssetTrackerRequestBus::BroadcastResult(assetHandler, &AssetTrackerRequests::GetAssetHandlerForType, m_assetType); - AZ_Assert(assetHandler, "An asset handler must be found"); - - bool savedSuccess; - { - AZ_PROFILE_SCOPE(ScriptCanvas, "ScriptCanvasAssetHandler::SaveAssetData"); - - ScriptCanvasMemoryAsset cloneAsset; - m_sourceAsset->CloneTo(cloneAsset); - - savedSuccess = assetHandler->SaveAssetData(cloneAsset.GetAsset(), &stream); - } - stream.Close(); - if (savedSuccess) - { - AZ_PROFILE_SCOPE(ScriptCanvas, "AssetTracker::SaveAssetPostSourceControl : TempToTargetFileReplacement"); - - AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance(); - const bool targetFileExists = fileIO->Exists(m_saveInfo.m_streamName.data()); - - bool removedTargetFile; - { - AZ_PROFILE_SCOPE(ScriptCanvas, "AssetTracker::SaveAssetPostSourceControl : TempToTargetFileReplacement : RemoveTarget"); - removedTargetFile = fileIO->Remove(m_saveInfo.m_streamName.data()); - } - - if (targetFileExists && !removedTargetFile) - { - savedSuccess = false; - } - else - { - AZ_PROFILE_SCOPE(ScriptCanvas, "AssetTracker::SaveAssetPostSourceControl : TempToTargetFileReplacement : RenameTempFile"); - AZ::IO::Result renameResult = fileIO->Rename(tempPath.data(), m_saveInfo.m_streamName.data()); - if (!renameResult) - { - savedSuccess = false; - } - } - } - - if (savedSuccess) - { - AZ_TracePrintf("Script Canvas", "Script Canvas successfully saved as Asset \"%s\"", m_saveInfo.m_streamName.data()); - } - - m_onComplete.Signal(m_sourceAsset->GetId()); - - } - - Reset(); - - } - - } - - void AssetSaveFinalizer::Reset() - { - m_sourceAsset = nullptr; - m_fileAssetId = {}; - m_onSave = nullptr; - m_saving = false; - m_inMemoryAsset = nullptr; - m_saveInfo = {}; - } - -} diff --git a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasMemoryAsset.h b/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasMemoryAsset.h deleted file mode 100644 index f906f13433..0000000000 --- a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasMemoryAsset.h +++ /dev/null @@ -1,344 +0,0 @@ -/* - * 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 - * - */ - -#pragma once - -#include -#include - -#include - -#include -#include - -#include - -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include - - -namespace ScriptCanvasEditor -{ - - class ScriptCanvasAssetHandler; - - template - class MemoryAsset - : protected AZ::Data::AssetBus::MultiHandler - , protected AzToolsFramework::AssetSystemBus::Handler - , public AzToolsFramework::UndoSystem::IUndoNotify - { - public: - - MemoryAsset() - { - AzToolsFramework::AssetSystemBus::Handler::BusConnect(); - } - - ~MemoryAsset() - { - AZ::Data::AssetBus::MultiHandler::BusDisconnect(); - AzToolsFramework::AssetSystemBus::Handler::BusDisconnect(); - } - - using AssetType = BaseAssetType; - - virtual void Create(AZ::Data::AssetId assetId, AZStd::string_view assetAbsolutePath, AZ::Data::AssetType assetType, Callbacks::OnAssetCreatedCallback onAssetCreatedCallback) = 0; - - virtual void SaveAs(const AZStd::string& path, Callbacks::OnSave onSaveCallback) = 0; - virtual void Save(Callbacks::OnSave onSaveCallback) = 0; - - virtual bool Load(AZ::Data::AssetId assetId, AZ::Data::AssetType assetType, Callbacks::OnAssetReadyCallback onAssetReadyCallback) = 0; - }; - - class UndoHelper; - - // Saving an asset is an asynchronous process that requires several steps, this helper - // class ensures asset saving takes place correctly and reduces the complexity of - // ScriptCanvasMemoryAsset's saving requirements - class AssetSaveFinalizer - : AZ::SystemTickBus::Handler - { - public: - - using OnCompleteEvent = AZ::Event; - using OnCompleteHandler = AZ::Event::Handler; - - AssetSaveFinalizer(); - ~AssetSaveFinalizer(); - - void Start(ScriptCanvasMemoryAsset* sourceAsset, const AzToolsFramework::SourceControlFileInfo& fileInfo, const AZ::Data::AssetStreamInfo& saveInfo, Callbacks::OnSave onSaveCallback, OnCompleteHandler onComplete); - void Reset(); - - private: - - // AZ::SystemTickBus::Handler ... - void OnSystemTick() override; - /// - - bool ValidateStatus(const AzToolsFramework::SourceControlFileInfo& fileInfo); - AZStd::string MakeTemporaryFilePathForSave(AZStd::string_view targetFilename); - - OnCompleteHandler m_onCompleteHandler; - OnCompleteEvent m_onComplete; - Callbacks::OnSave m_onSave; - - bool m_saving = false; - bool m_fileAvailableForSave = false; - - AZ::Data::AssetPtr m_inMemoryAsset; - AZ::Data::AssetId m_fileAssetId; - AZ::Data::AssetStreamInfo m_saveInfo; - - ScriptCanvasMemoryAsset* m_sourceAsset; - - AZ::Data::AssetType m_assetType; - - }; - - // Script Canvas primarily works with an in-memory copy of an asset. - // There are two situations, the first is, when a new asset is created and not yet saved. - // Once saved, we will create a new asset on file, however, and this is important - // once the file is saved to file, its asset ID will be changed, if the file is to remain - // open, we need to update the source AssetId to correspond to the file asset. - // - // The other is when an asset is loaded, we clone the asset from file and use an in-memory - // version of the asset until it is time to save, at that moment we need to save to the - // source file - class ScriptCanvasMemoryAsset - : public MemoryAsset - , public AZStd::enable_shared_from_this - , EditorGraphNotificationBus::Handler - { - public: - - ScriptCanvasMemoryAsset(); - ~ScriptCanvasMemoryAsset() override; - - ScriptCanvasMemoryAsset(const ScriptCanvasMemoryAsset& rhs) = delete; - ScriptCanvasMemoryAsset& operator = (const ScriptCanvasMemoryAsset& rhs) = delete; - - using pointer = AZStd::shared_ptr; - - void Create(AZ::Data::AssetId assetId, AZStd::string_view assetAbsolutePath, AZ::Data::AssetType assetType, Callbacks::OnAssetCreatedCallback onAssetCreatedCallback) override; - void SaveAs(const AZStd::string& path, Callbacks::OnSave onSaveCallback) override; - void Save(Callbacks::OnSave onSaveCallback) override; - bool Load(AZ::Data::AssetId assetId, AZ::Data::AssetType assetType, Callbacks::OnAssetReadyCallback onAssetReadyCallback) override; - void Set(AZ::Data::AssetId assetId); - - const AZ::Data::AssetId& GetId() const { return m_inMemoryAssetId; } - const AZ::Data::AssetId& GetFileAssetId() const { return m_fileAssetId; } - - const AZ::Data::AssetType GetAssetType() const { return m_assetType; } - - AZ::Data::Asset GetAsset() { return m_inMemoryAsset; } - const AZ::Data::Asset& GetAsset() const { return m_inMemoryAsset; } - - const AZStd::string GetTabName() const; - - const AZStd::string& GetAbsolutePath() const { return m_absolutePath; } - AZ::EntityId GetScriptCanvasId() const { return m_scriptCanvasId; } - - AZ::EntityId GetGraphId(); - Tracker::ScriptCanvasFileState GetFileState() const; - - void SetFileState(Tracker::ScriptCanvasFileState fileState); - - void CloneTo(ScriptCanvasMemoryAsset& memoryAsset); - - void ActivateAsset(); - - Widget::CanvasWidget* GetView() { return m_canvasWidget; } - - Widget::CanvasWidget* CreateView(QWidget* parent); - void ClearView(); - - void UndoStackChange(); - - SceneUndoState* GetUndoState() { return m_undoState.get(); } - - bool IsSourceInError() const; - - void SavingComplete(const AZStd::string& fullPath, AZ::Uuid sourceAssetId); - - AZ::Data::AssetId GetSourceUuid() const { return m_sourceUuid; } - - private: - - template - auto Clone() - { - AZ::Data::AssetId assetId = AZ::Uuid::CreateRandom(); - - AZ::Data::Asset newAsset = m_inMemoryAsset; - newAsset = { aznew T(assetId, AZ::Data::AssetData::AssetStatus::Ready), AZ::Data::AssetLoadBehavior::Default }; - - auto serializeContext = AZ::EntityUtils::GetApplicationSerializeContext(); - serializeContext->CloneObjectInplace(newAsset.Get()->GetScriptCanvasData(), &m_inMemoryAsset.Get()->GetScriptCanvasData()); - - m_editorEntityIdMap.clear(); - - AZ::IdUtils::Remapper::GenerateNewIdsAndFixRefs(&newAsset.Get()->GetScriptCanvasData(), m_editorEntityIdMap, serializeContext); - - return newAsset; - } - - // EditorGraphNotificationBus - void OnGraphCanvasSceneDisplayed() override; - /// - - //! AZ::Data::AssetBus - void OnAssetReady(AZ::Data::Asset asset) override; - void OnAssetReloaded(AZ::Data::Asset asset) override; - void OnAssetError(AZ::Data::Asset asset) override; - void OnAssetUnloaded(const AZ::Data::AssetId assetId, const AZ::Data::AssetType assetType) override; - /////////////////////// - - // AzToolsFramework::AssetSystemBus::Handler - void SourceFileChanged(AZStd::string relativePath, AZStd::string scanFolder, AZ::Uuid fileAssetId) override; - void SourceFileRemoved(AZStd::string relativePath, AZStd::string scanFolder, AZ::Uuid fileAssetId) override; - void SourceFileFailed(AZStd::string relativePath, AZStd::string scanFolder, AZ::Uuid fileAssetId) override; - /// - - - void FinalizeAssetSave(bool, const AzToolsFramework::SourceControlFileInfo& fileInfo, const AZ::Data::AssetStreamInfo& saveInfo, Callbacks::OnSave onSaveCallback); - - template - void StartAssetLoad(AZ::Data::AssetId assetId, AZ::Data::Asset& asset) - { - asset = AZ::Data::AssetManager::Instance().GetAsset(assetId, asset.GetAutoLoadBehavior()); - } - - template - AZ::Data::Asset CloneAssetData(AZ::Data::AssetId newAssetId) - { - AssetType* assetData = aznew AssetType(newAssetId, AZ::Data::AssetData::AssetStatus::Ready); - - auto& scriptCanvasData = assetData->GetScriptCanvasData(); - - // Clone asset data into SC Editor asset - auto serializeContext = AZ::EntityUtils::GetApplicationSerializeContext(); - serializeContext->CloneObjectInplace(scriptCanvasData, &m_inMemoryAsset.Get()->GetScriptCanvasData()); - - m_editorEntityIdMap.clear(); - - AZ::IdUtils::Remapper::GenerateNewIdsAndFixRefs(&scriptCanvasData, m_editorEntityIdMap, serializeContext); - - // Upon doing this move, the canonical asset will be unloaded - m_inMemoryAsset = { AZStd::move(assetData), AZ::Data::AssetLoadBehavior::Default }; - - return m_inMemoryAsset; - } - - // Upon loading a graph, we clone the source data and we replace the loaded asset with - // a clone, this is to prevent modifications to the source data and it gives us some - // flexibility if we need to load the source asset again - AZ::Data::Asset CloneAssetData(AZ::Data::AssetId newAssetId); - - // IUndoNotify - void OnUndoStackChanged() override; - // - - private: - - void SetFileAssetId(const AZ::Data::AssetId& fileAssetId); - - void SignalFileStateChanged(); - - AZStd::string MakeTemporaryFilePathForSave(AZStd::string_view targetFilename); - - //! Finds the appropriate asset handler for the type of Script Canvas asset given - ScriptCanvasAssetHandler* GetAssetHandlerForType(AZ::Data::AssetType assetType); - - //! The asset type, we need it to make sure we call the correct factory methods - AZ::Data::AssetType m_assetType; - - //! The in-memory asset - AZ::Data::Asset m_inMemoryAsset; - - AZ::Data::Asset m_sourceAsset; - - //! Whether we are making a new asset or loading one, we should always have its absolute path - AZStd::string m_absolutePath; - - AZStd::string m_saveAsPath; - - //! The AssetId of the canonical asset on file, if the asset has never been saved to file, it is Invalid - AZ::Data::AssetId m_fileAssetId; - - //! The AssetId that represents this asset, it will always be the in-memory asset Id and never the file asset Id - AZ::Data::AssetId m_inMemoryAssetId; - - //! When a new asset is saved, we need to keep it's previous internal Ids in order for the front end to remap to the new Ids - using FormerGraphIdPair = AZStd::pair; - FormerGraphIdPair m_formerGraphIdPair; - - //! The EntityId of the ScriptCanvasEntity owned by the ScriptCanvasAsset - ScriptCanvas::ScriptCanvasId m_scriptCanvasId; - - //! The EntityId that represents the ScriptCanvas graph - AZ::EntityId m_graphId; - - //! Gives the ability to provide a lambda invoked when the asset is ready - Callbacks::OnAssetReadyCallback m_onAssetReadyCallback; - - //! The Save is officially complete after SourceFileChange is handled. - Callbacks::OnSave m_onSaveCallback; - - bool m_sourceRemoved = false; - Tracker::ScriptCanvasFileState m_fileState = Tracker::ScriptCanvasFileState::INVALID; - - //! We need to track the filename of the file being saved because we need to match it when we handle SourceFileChange (see SourceFileChange for details) - AZStd::vector m_pendingSave; - - //! Each memory asset owns its view widget - Widget::CanvasWidget* m_canvasWidget = nullptr; - - //! Utility cache of remapped entityIds - using EditorEntityIdMap = AZStd::unordered_map; - - //! Cached mapping of Scene Entity ID to Asset Id, used by the debugger - EditorEntityIdMap m_editorEntityIdMap; - - //! Each asset keeps track of its undo state - AZStd::unique_ptr m_undoState; - - //! The undo helper is an object that implements the Undo behaviors - AZStd::unique_ptr m_undoHelper; - - bool m_sourceInError; - - AZ::Data::AssetId m_sourceUuid; - - AssetSaveFinalizer m_assetSaveFinalizer; - - public: - - //! Given a scene EntityId, find the respective editor EntityId - AZ::EntityId GetEditorEntityIdFromSceneEntityId(AZ::EntityId sceneEntityId); - - //! Given an editor EntityId, find the respective scene EntityId - AZ::EntityId GetSceneEntityIdFromEditorEntityId(AZ::EntityId editorEntityId); - - //! When a new asset is saved, we need to keep it's previous internal Ids in order for the front end to remap to the new Ids - const FormerGraphIdPair& GetFormerGraphIds() const { return m_formerGraphIdPair; } - - }; - - -} diff --git a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasUndoHelper.cpp b/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasUndoHelper.cpp index f125a4cbc9..a067bf411e 100644 --- a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasUndoHelper.cpp +++ b/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasUndoHelper.cpp @@ -7,7 +7,6 @@ */ #include "ScriptCanvasUndoHelper.h" -#include "ScriptCanvasMemoryAsset.h" #include #include diff --git a/Gems/ScriptCanvas/Code/Editor/Components/EditorScriptCanvasComponent.cpp b/Gems/ScriptCanvas/Code/Editor/Components/EditorScriptCanvasComponent.cpp index 3ad2580d3c..6419525726 100644 --- a/Gems/ScriptCanvas/Code/Editor/Components/EditorScriptCanvasComponent.cpp +++ b/Gems/ScriptCanvas/Code/Editor/Components/EditorScriptCanvasComponent.cpp @@ -20,13 +20,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include #include #include @@ -66,8 +66,8 @@ namespace ScriptCanvasEditor return false; } - ScriptCanvasAssetHolder assetHolder; - assetHolder.SetAsset(scriptCanvasAsset.GetId()); + Deprecated::ScriptCanvasAssetHolder assetHolder; + assetHolder.m_scriptCanvasAsset = scriptCanvasAsset; if (!rootElement.AddElementWithData(serializeContext, "m_assetHolder", assetHolder)) { @@ -115,7 +115,7 @@ namespace ScriptCanvasEditor auto& scriptCanvasAssetHolderElement = rootElement.GetSubElement(scriptCanvasAssetHolderElementIndex); - ScriptCanvasAssetHolder assetHolder; + Deprecated::ScriptCanvasAssetHolder assetHolder; if (!scriptCanvasAssetHolderElement.GetData(assetHolder)) { AZ_Error("ScriptCanvas", false, "EditorScriptCanvasComponent conversion failed: could not retrieve old 'm_assetHolder'"); @@ -131,7 +131,7 @@ namespace ScriptCanvasEditor } ScriptCanvasBuilder::BuildVariableOverrides overrides; - overrides.m_source = SourceHandle(nullptr, assetHolder.GetAssetId().m_guid, {}); + overrides.m_source = SourceHandle(nullptr, assetHolder.m_scriptCanvasAsset.GetId().m_guid, {}); for (auto& variable : editableData.GetVariables()) { @@ -147,15 +147,15 @@ namespace ScriptCanvasEditor if (rootElement.GetVersion() < EditorScriptCanvasComponentCpp::Version::AddSourceHandle) { - ScriptCanvasAssetHolder assetHolder; + Deprecated::ScriptCanvasAssetHolder assetHolder; if (!rootElement.FindSubElementAndGetData(AZ_CRC_CE("m_assetHolder"), assetHolder)) { AZ_Error("ScriptCanvas", false, "EditorScriptCanvasComponent conversion failed: could not retrieve old 'm_assetHolder'"); return false; } - auto assetId = assetHolder.GetAssetId(); - auto path = assetHolder.GetAssetHint(); + auto assetId = assetHolder.m_scriptCanvasAsset.GetId(); + auto path = assetHolder.m_scriptCanvasAsset.GetHint(); if (!rootElement.AddElementWithData(serializeContext, "runtimeDataOverrides", SourceHandle(nullptr, assetId.m_guid, path))) { @@ -188,7 +188,6 @@ namespace ScriptCanvasEditor ->Attribute(AZ::Edit::Attributes::Icon, "Icons/ScriptCanvas/ScriptCanvas.svg") ->Attribute(AZ::Edit::Attributes::ViewportIcon, "Icons/ScriptCanvas/Viewport/ScriptCanvas.svg") ->Attribute(AZ::Edit::Attributes::AutoExpand, true) - ->Attribute(AZ::Edit::Attributes::PrimaryAssetType, ScriptCanvasAssetHandler::GetAssetTypeStatic()) ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c)) ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("UI", 0x27ff46b0)) ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Level", 0x9aeacc13)) diff --git a/Gems/ScriptCanvas/Code/Editor/GraphCanvas/Components/NodeDescriptors/FunctionNodeDescriptorComponent.cpp b/Gems/ScriptCanvas/Code/Editor/GraphCanvas/Components/NodeDescriptors/FunctionNodeDescriptorComponent.cpp index f80c6dde21..c8de1e892a 100644 --- a/Gems/ScriptCanvas/Code/Editor/GraphCanvas/Components/NodeDescriptors/FunctionNodeDescriptorComponent.cpp +++ b/Gems/ScriptCanvas/Code/Editor/GraphCanvas/Components/NodeDescriptors/FunctionNodeDescriptorComponent.cpp @@ -14,7 +14,6 @@ #include #include -#include #include #include @@ -89,16 +88,9 @@ namespace ScriptCanvasEditor bool FunctionNodeDescriptorComponent::OnMouseDoubleClick(const QGraphicsSceneMouseEvent*) { - AZ::Data::AssetInfo assetInfo = AssetHelpers::GetSourceInfoByProductId(m_assetId, azrtti_typeid< ScriptCanvas::SubgraphInterfaceAsset>()); - - if (!assetInfo.m_assetId.IsValid()) - { - return false; - } - AZ::Outcome openOutcome = AZ::Failure(AZStd::string()); GeneralRequestBus::BroadcastResult(openOutcome, &GeneralRequests::OpenScriptCanvasAsset - , SourceHandle( nullptr, assetInfo.m_assetId.m_guid, {} ), Tracker::ScriptCanvasFileState::UNMODIFIED, -1); + , SourceHandle( nullptr, m_assetId.m_guid, {} ), Tracker::ScriptCanvasFileState::UNMODIFIED, -1); return openOutcome.IsSuccess(); } diff --git a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasAssetHandler.h b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasAssetHandler.h deleted file mode 100644 index a0e00b40fd..0000000000 --- a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasAssetHandler.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 - * - */ - -#pragma once - -#include -#include -#include -#include - -namespace AZ -{ - class SerializeContext; -} - -namespace ScriptCanvasEditor -{ - /** - * Manages editor Script Canvas graph assets. - */ - class ScriptCanvasAssetHandler - : public AZ::Data::AssetHandler - , protected AZ::AssetTypeInfoBus::MultiHandler - { - public: - AZ_CLASS_ALLOCATOR(ScriptCanvasAssetHandler, AZ::SystemAllocator, 0); - AZ_RTTI(ScriptCanvasAssetHandler, "{098B86B2-2527-4155-84C9-A698A0D20068}", AZ::Data::AssetHandler); - - ScriptCanvasAssetHandler(AZ::SerializeContext* context = nullptr); - ~ScriptCanvasAssetHandler(); - - // Called by the asset database to create a new asset. - AZ::Data::AssetPtr CreateAsset(const AZ::Data::AssetId& id, const AZ::Data::AssetType& type) override; - - // Override the stream info to force source assets to load into the Editor instead of cached, processed assets. - void GetCustomAssetStreamInfoForLoad(AZ::Data::AssetStreamInfo& streamInfo) override; - - // Called by the asset database to perform actual asset load. - AZ::Data::AssetHandler::LoadResult LoadAssetData( - const AZ::Data::Asset& asset, - AZStd::shared_ptr stream, - const AZ::Data::AssetFilterCB& assetLoadFilterCB) override; - - // Called by the asset database to perform actual asset save. Returns true if successful otherwise false (default - as we don't require support save). - bool SaveAssetData(const AZ::Data::Asset& asset, AZ::IO::GenericStream* stream) override; - bool SaveAssetData(const ScriptCanvasAsset* assetData, AZ::IO::GenericStream* stream); - bool SaveAssetData(const ScriptCanvasAsset* assetData, AZ::IO::GenericStream* stream, AZ::DataStream::StreamType streamType); - - // Called by the asset database when an asset should be deleted. - void DestroyAsset(AZ::Data::AssetPtr ptr) override; - - // Called by asset database on registration. - void GetHandledAssetTypes(AZStd::vector& assetTypes) override; - - // Provides editor with information about script canvas graph assets. - AZ::Data::AssetType GetAssetType() const override; - const char* GetAssetTypeDisplayName() const override; - void GetAssetTypeExtensions(AZStd::vector& extensions) override; - - AZ::Uuid GetComponentTypeId() const override; - - AZ::SerializeContext* GetSerializeContext() const; - - void SetSerializeContext(AZ::SerializeContext* context); - - static AZ::Data::AssetType GetAssetTypeStatic(); - - // protected AZ::AssetTypeInfoBus::MultiHandler... - const char* GetGroup() const override; - const char* GetBrowserIcon() const override; - - - protected: - AZ::SerializeContext* m_serializeContext; - }; -} diff --git a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorDeprecationData.cpp b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorDeprecationData.cpp new file mode 100644 index 0000000000..635f6e09e9 --- /dev/null +++ b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorDeprecationData.cpp @@ -0,0 +1,28 @@ +/* + * 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 + +namespace ScriptCanvasEditor +{ + namespace Deprecated + { + void ScriptCanvasAssetHolder::Reflect(AZ::ReflectContext* context) + { + if (auto serializeContext = azrtti_cast(context)) + { + serializeContext->Class() + ->Field("m_asset", &ScriptCanvasAssetHolder::m_scriptCanvasAsset) + ; + } + } + } +} diff --git a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorDeprecationData.h b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorDeprecationData.h new file mode 100644 index 0000000000..a8e54f034e --- /dev/null +++ b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorDeprecationData.h @@ -0,0 +1,34 @@ +/* + * 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 + * + */ + +#pragma once + +#include +#include +#include + +class ScriptCanvasAsset; + + +namespace ScriptCanvasEditor +{ + namespace Deprecated + { + class ScriptCanvasAssetHolder + { + public: + AZ_TYPE_INFO(ScriptCanvasAssetHolder, "{3E80CEE3-2932-4DC1-AADF-398FDDC6DEFE}"); + AZ_CLASS_ALLOCATOR(ScriptCanvasAssetHolder, AZ::SystemAllocator, 0); + + ScriptCanvasAssetHolder() = default; + static void Reflect(AZ::ReflectContext* context); + + AZ::Data::Asset m_scriptCanvasAsset; + }; + } +} diff --git a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorScriptCanvasComponent.h b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorScriptCanvasComponent.h index d797f8db08..da1b0a22a6 100644 --- a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorScriptCanvasComponent.h +++ b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorScriptCanvasComponent.h @@ -13,8 +13,6 @@ #include #include #include -#include -#include #include #include #include diff --git a/Gems/ScriptCanvas/Code/Editor/ReflectComponent.cpp b/Gems/ScriptCanvas/Code/Editor/ReflectComponent.cpp index 7f2a170a4d..8990b55798 100644 --- a/Gems/ScriptCanvas/Code/Editor/ReflectComponent.cpp +++ b/Gems/ScriptCanvas/Code/Editor/ReflectComponent.cpp @@ -12,7 +12,6 @@ #include #include -#include #include #include @@ -24,6 +23,7 @@ #include #include #include +#include #include @@ -33,7 +33,7 @@ namespace ScriptCanvasEditor { SourceHandle::Reflect(context); ScriptCanvas::ScriptCanvasData::Reflect(context); - ScriptCanvasAssetHolder::Reflect(context); + Deprecated::ScriptCanvasAssetHolder::Reflect(context); EditorSettings::EditorWorkspace::Reflect(context); EditorSettings::ScriptCanvasEditorSettings::Reflect(context); LiveLoggingUserSettings::Reflect(context); diff --git a/Gems/ScriptCanvas/Code/Editor/SystemComponent.cpp b/Gems/ScriptCanvas/Code/Editor/SystemComponent.cpp index f8424b60d9..4933a31b60 100644 --- a/Gems/ScriptCanvas/Code/Editor/SystemComponent.cpp +++ b/Gems/ScriptCanvas/Code/Editor/SystemComponent.cpp @@ -37,6 +37,8 @@ #include #include #include +#include + namespace ScriptCanvasEditor { @@ -109,7 +111,6 @@ namespace ScriptCanvasEditor void SystemComponent::Activate() { - m_assetTracker.Activate(); AZ::JobManagerDesc jobDesc; for (size_t i = 0; i < cs_jobThreads; ++i) { @@ -165,7 +166,6 @@ namespace ScriptCanvasEditor m_jobContext.reset(); m_jobManager.reset(); - m_assetTracker.Deactivate(); } void SystemComponent::AddAsyncJob(AZStd::function&& jobFunc) diff --git a/Gems/ScriptCanvas/Code/Editor/SystemComponent.h b/Gems/ScriptCanvas/Code/Editor/SystemComponent.h index c2c42c5b9d..dc4175f938 100644 --- a/Gems/ScriptCanvas/Code/Editor/SystemComponent.h +++ b/Gems/ScriptCanvas/Code/Editor/SystemComponent.h @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -118,8 +117,6 @@ namespace ScriptCanvasEditor AZStd::unordered_set m_creatableTypes; - AssetTracker m_assetTracker; - AZStd::vector m_assetsThatNeedManualUpgrade; bool m_isUpgrading = false; diff --git a/Gems/ScriptCanvas/Code/Editor/Undo/ScriptCanvasGraphCommand.cpp b/Gems/ScriptCanvas/Code/Editor/Undo/ScriptCanvasGraphCommand.cpp index 944a5e667d..f497b83b08 100644 --- a/Gems/ScriptCanvas/Code/Editor/Undo/ScriptCanvasGraphCommand.cpp +++ b/Gems/ScriptCanvas/Code/Editor/Undo/ScriptCanvasGraphCommand.cpp @@ -19,7 +19,6 @@ #include #include -#include namespace ScriptCanvasEditor { diff --git a/Gems/ScriptCanvas/Code/Editor/Undo/ScriptCanvasGraphCommand.h b/Gems/ScriptCanvas/Code/Editor/Undo/ScriptCanvasGraphCommand.h index b9435d0702..9b36a7beb0 100644 --- a/Gems/ScriptCanvas/Code/Editor/Undo/ScriptCanvasGraphCommand.h +++ b/Gems/ScriptCanvas/Code/Editor/Undo/ScriptCanvasGraphCommand.h @@ -30,8 +30,6 @@ namespace ScriptCanvasEditor using GraphItemCommandNotificationBus = AZ::EBus; - class ScriptCanvasMemoryAsset; - // This command is the base URSequencePoint command from which all Script Canvas undo/redo commands derive class GraphItemCommand : public AzToolsFramework::UndoSystem::URSequencePoint diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/GraphTabBar.h b/Gems/ScriptCanvas/Code/Editor/View/Widgets/GraphTabBar.h index 939fb7c8f4..39500eb29c 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/GraphTabBar.h +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/GraphTabBar.h @@ -17,7 +17,6 @@ #include #include -#include #include #endif diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/NodePalette/NodePaletteModel.cpp b/Gems/ScriptCanvas/Code/Editor/View/Widgets/NodePalette/NodePaletteModel.cpp index c5be5cb4c6..0efdf071f5 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/NodePalette/NodePaletteModel.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/NodePalette/NodePaletteModel.cpp @@ -16,7 +16,6 @@ #include -#include #include #include #include diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/ScriptCanvasNodePaletteDockWidget.cpp b/Gems/ScriptCanvas/Code/Editor/View/Widgets/ScriptCanvasNodePaletteDockWidget.cpp index bf8482f0ca..1258842b75 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/ScriptCanvasNodePaletteDockWidget.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/ScriptCanvasNodePaletteDockWidget.cpp @@ -38,7 +38,6 @@ #include -#include #include #include #include @@ -462,32 +461,35 @@ namespace ScriptCanvasEditor return; } - AZStd::string rootPath, absolutePath; - AZ::Data::AssetInfo assetInfo = AssetHelpers::GetAssetInfo(assetId, rootPath); - AzFramework::StringFunc::Path::Join(rootPath.c_str(), assetInfo.m_relativePath.c_str(), absolutePath); - - AZStd::string normPath = absolutePath; - AzFramework::StringFunc::Path::Normalize(normPath); - - AZStd::string watchFolder; - bool sourceInfoFound{}; - AzToolsFramework::AssetSystemRequestBus::BroadcastResult(sourceInfoFound, &AzToolsFramework::AssetSystemRequestBus::Events::GetSourceInfoBySourcePath, normPath.c_str(), assetInfo, watchFolder); - - if (!sourceInfoFound) - { - return; - } - - CreateFunctionPaletteItem(asset, assetInfo); - - treePaletteIter = m_globalFunctionTreeItems.find(asset->GetId()); - - if (treePaletteIter != m_globalFunctionTreeItems.end()) - { - treePaletteIter->second->ClearError(); - } - - m_monitoredAssets.emplace(asset->GetId(), asset); + // #sc_editor_asset_redux THIS WHOLE THING NEEDS TO BE REDONE TO MAKE SURE THAT USER FUNCTIONS SHOW UP IN THE + // NODE PALETTE +// +// AZStd::string rootPath, absolutePath; +// AZ::Data::AssetInfo assetInfo = AssetHelpers::GetAssetInfo(assetId, rootPath); +// AzFramework::StringFunc::Path::Join(rootPath.c_str(), assetInfo.m_relativePath.c_str(), absolutePath); +// +// AZStd::string normPath = absolutePath; +// AzFramework::StringFunc::Path::Normalize(normPath); +// +// AZStd::string watchFolder; +// bool sourceInfoFound{}; +// AzToolsFramework::AssetSystemRequestBus::BroadcastResult(sourceInfoFound, &AzToolsFramework::AssetSystemRequestBus::Events::GetSourceInfoBySourcePath, normPath.c_str(), assetInfo, watchFolder); +// +// if (!sourceInfoFound) +// { +// return; +// } +// +// CreateFunctionPaletteItem(asset, assetInfo); +// +// treePaletteIter = m_globalFunctionTreeItems.find(asset->GetId()); +// +// if (treePaletteIter != m_globalFunctionTreeItems.end()) +// { +// treePaletteIter->second->ClearError(); +// } +// +// m_monitoredAssets.emplace(asset->GetId(), asset); } else { diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/NodeUsageTreeItem.cpp b/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/NodeUsageTreeItem.cpp index 4dce7ce384..b10a7fc314 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/NodeUsageTreeItem.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/NodeUsageTreeItem.cpp @@ -10,7 +10,6 @@ #include -#include #include #include @@ -152,8 +151,9 @@ namespace ScriptCanvasEditor m_assetType = assetType; - auto onAssetReady = [](ScriptCanvasMemoryAsset&) {}; - AssetTrackerRequestBus::Broadcast(&AssetTrackerRequests::Load, m_assetId, m_assetType, onAssetReady); + // #sc-editor-asset-redux fix up + // auto onAssetReady = [](ScriptCanvasMemoryAsset&) {}; + // AssetTrackerRequestBus::Broadcast(&AssetTrackerRequests::Load, m_assetId, m_assetType, onAssetReady); } const AZ::Data::AssetId& ScriptCanvasAssetNodeUsageTreeItem::GetAssetId() const diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/UnitTestPanel/UnitTestDockWidget.cpp b/Gems/ScriptCanvas/Code/Editor/View/Widgets/UnitTestPanel/UnitTestDockWidget.cpp index f319a166df..d3661a4ef3 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/UnitTestPanel/UnitTestDockWidget.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/UnitTestPanel/UnitTestDockWidget.cpp @@ -35,7 +35,6 @@ #include #include -#include #include #include #include @@ -48,12 +47,11 @@ #include #include -#include #include #include #include #include - +#include #include namespace ScriptCanvasEditor @@ -522,16 +520,20 @@ namespace ScriptCanvasEditor continue; } - AZ::Data::AssetInfo assetInfo; - if (AssetHelpers::GetAssetInfo(sourceBrowserEntry->GetFullPath(), assetInfo)) - { - auto asset = AZ::Data::AssetManager::Instance().GetAsset(assetInfo.m_assetId, azrtti_typeid(), AZ::Data::AssetLoadBehavior::PreLoad); - asset.BlockUntilLoadComplete(); - if (asset.IsReady()) - { - RunTestGraph(asset, mode); - } - } + ScriptCanvasEditor::SourceHandle source(nullptr, scriptUuid, ""); + ScriptCanvasEditor::CompleteDescriptionInPlace(source); + + // #sc_editor_asset_redux +// AZ::Data::AssetInfo assetInfo; +// if (AssetHelpers::GetAssetInfo(sourceBrowserEntry->GetFullPath(), assetInfo)) +// { +// auto asset = AZ::Data::AssetManager::Instance().GetAsset(assetInfo.m_assetId, azrtti_typeid(), AZ::Data::AssetLoadBehavior::PreLoad); +// asset.BlockUntilLoadComplete(); +// if (asset.IsReady()) +// { +// RunTestGraph(asset, mode); +// } +// } } } } diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/VariablePanel/SlotTypeSelectorWidget.cpp b/Gems/ScriptCanvas/Code/Editor/View/Widgets/VariablePanel/SlotTypeSelectorWidget.cpp index fe3a59d28a..a632b7719e 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/VariablePanel/SlotTypeSelectorWidget.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/VariablePanel/SlotTypeSelectorWidget.cpp @@ -37,7 +37,6 @@ #include -#include #include #include #include diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/VariablePanel/VariableDockWidget.cpp b/Gems/ScriptCanvas/Code/Editor/View/Widgets/VariablePanel/VariableDockWidget.cpp index 68176d6b95..2222f4d2aa 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/VariablePanel/VariableDockWidget.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/VariablePanel/VariableDockWidget.cpp @@ -37,7 +37,6 @@ #include -#include #include #include #include diff --git a/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.cpp b/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.cpp index 306068bd5c..c40c126dd1 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.cpp @@ -97,7 +97,6 @@ #include #include #include -#include #include #include @@ -145,9 +144,6 @@ //// #include -#include -#include - #include #include #include @@ -358,21 +354,6 @@ namespace ScriptCanvasEditor } } - void Workspace::OnAssetReady(const ScriptCanvasMemoryAsset::pointer memoryAsset) - { - // open the file in the main window -// const ScriptCanvasEditor::SourceHandle& fileAssetId = memoryAsset->GetFileAssetId(); -// -// if (AssetTrackerNotificationBus::MultiHandler::BusIsConnectedId(fileAssetId)) -// { -// AssetTrackerNotificationBus::MultiHandler::BusDisconnect(fileAssetId); -// -// m_mainWindow->OpenScriptCanvasAsset(*memoryAsset); -// -// SignalAssetComplete(fileAssetId); -// } - } - void Workspace::SignalAssetComplete(const ScriptCanvasEditor::SourceHandle& /*fileAssetId*/) { // When we are done loading all assets we can safely set the focus to the recorded asset @@ -3513,19 +3494,23 @@ namespace ScriptCanvasEditor return findChild(elementName); } - AZ::EntityId MainWindow::FindEditorNodeIdByAssetNodeId(const ScriptCanvasEditor::SourceHandle& assetId, AZ::EntityId assetNodeId) const + AZ::EntityId MainWindow::FindEditorNodeIdByAssetNodeId([[maybe_unused]] const ScriptCanvasEditor::SourceHandle& assetId + , [[maybe_unused]] AZ::EntityId assetNodeId) const { - AZ::EntityId editorEntityId; - AssetTrackerRequestBus::BroadcastResult - ( editorEntityId, &AssetTrackerRequests::GetEditorEntityIdFromSceneEntityId, assetId.Id(), assetNodeId); + AZ::EntityId editorEntityId{}; +// AssetTrackerRequestBus::BroadcastResult +// ( editorEntityId, &AssetTrackerRequests::GetEditorEntityIdFromSceneEntityId, assetId.Id(), assetNodeId); + // #sc_editor_asset_redux fix logger return editorEntityId; } - AZ::EntityId MainWindow::FindAssetNodeIdByEditorNodeId(const ScriptCanvasEditor::SourceHandle& assetId, AZ::EntityId editorNodeId) const + AZ::EntityId MainWindow::FindAssetNodeIdByEditorNodeId([[maybe_unused]] const ScriptCanvasEditor::SourceHandle& assetId + , [[maybe_unused]] AZ::EntityId editorNodeId) const { - AZ::EntityId sceneEntityId; - AssetTrackerRequestBus::BroadcastResult - ( sceneEntityId, &AssetTrackerRequests::GetSceneEntityIdFromEditorEntityId, assetId.Id(), editorNodeId); + AZ::EntityId sceneEntityId{}; + // AssetTrackerRequestBus::BroadcastResult + // ( sceneEntityId, &AssetTrackerRequests::GetSceneEntityIdFromEditorEntityId, assetId.Id(), editorNodeId); + // #sc_editor_asset_redux fix logger return sceneEntityId; } diff --git a/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.h b/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.h index fed4f28f4f..4ff5cf094b 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.h +++ b/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.h @@ -43,11 +43,11 @@ #include #include #include -#include #include #include #include #include +#include #include @@ -58,9 +58,6 @@ #include #endif -#include -#include - #include #endif @@ -155,7 +152,6 @@ namespace ScriptCanvasEditor //! Manages the Save/Restore operations of the user's last opened and focused graphs class Workspace - : AssetTrackerNotificationBus::MultiHandler { public: @@ -174,7 +170,6 @@ namespace ScriptCanvasEditor private: - void OnAssetReady(const ScriptCanvasMemoryAsset::pointer asset) override; void SignalAssetComplete(const ScriptCanvasEditor::SourceHandle& fileAssetId); ScriptCanvasEditor::SourceHandle GetSourceAssetId(const ScriptCanvasEditor::SourceHandle& memoryAssetId) const; @@ -329,7 +324,6 @@ namespace ScriptCanvasEditor bool OnFileSaveAs(); bool OnFileSaveCaller(){return OnFileSave();}; bool OnFileSaveAsCaller(){return OnFileSaveAs();}; - bool SaveAssetImpl_OLD(const ScriptCanvasEditor::SourceHandle& assetId, const Callbacks::OnSave& saveCB); enum class Save { InPlace, diff --git a/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/Controller.cpp b/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/Controller.cpp index ce8a8e9821..39cd6f565e 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/Controller.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/Controller.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include diff --git a/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/FileSaver.cpp b/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/FileSaver.cpp index 49a35eac8a..f703bb17b1 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/FileSaver.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/FileSaver.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include namespace ScriptCanvasEditor diff --git a/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/Model.cpp b/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/Model.cpp index 5df1e32c8f..70ff7a92ca 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/Model.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/Model.cpp @@ -8,7 +8,6 @@ #include #include -#include #include #include #include diff --git a/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/UpgradeHelper.cpp b/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/UpgradeHelper.cpp index c557a83f0c..0678aee013 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/UpgradeHelper.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/UpgradeHelper.cpp @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include diff --git a/Gems/ScriptCanvas/Code/scriptcanvasgem_editor_files.cmake b/Gems/ScriptCanvas/Code/scriptcanvasgem_editor_files.cmake index 77ccf7fda9..897539db7b 100644 --- a/Gems/ScriptCanvas/Code/scriptcanvasgem_editor_files.cmake +++ b/Gems/ScriptCanvas/Code/scriptcanvasgem_editor_files.cmake @@ -15,12 +15,8 @@ set(FILES Editor/SystemComponent.h Editor/SystemComponent.cpp Editor/QtMetaTypes.h - Editor/Assets/ScriptCanvasAssetTracker.cpp - Editor/Assets/ScriptCanvasAssetTracker.h - Editor/Assets/ScriptCanvasAssetTrackerBus.h Editor/Assets/ScriptCanvasAssetHelpers.h Editor/Assets/ScriptCanvasAssetHelpers.cpp - Editor/Assets/ScriptCanvasAssetTrackerDefinitions.h Editor/Include/ScriptCanvas/Assets/ScriptCanvasBaseAssetData.h Editor/Include/ScriptCanvas/Assets/ScriptCanvasBaseAssetData.cpp Editor/Include/ScriptCanvas/Assets/ScriptCanvasAsset.h @@ -28,13 +24,7 @@ set(FILES Editor/Include/ScriptCanvas/Assets/ScriptCanvasAssetBus.h Editor/Include/ScriptCanvas/Assets/ScriptCanvasAssetTypes.h Editor/Include/ScriptCanvas/Assets/ScriptCanvasFileHandling.h - Editor/Include/ScriptCanvas/Assets/ScriptCanvasAssetHandler.h Editor/Assets/ScriptCanvasFileHandling.cpp - Editor/Assets/ScriptCanvasAssetHandler.cpp - Editor/Assets/ScriptCanvasAssetHolder.h - Editor/Assets/ScriptCanvasAssetHolder.cpp - Editor/Assets/ScriptCanvasMemoryAsset.h - Editor/Assets/ScriptCanvasMemoryAsset.cpp Editor/Assets/ScriptCanvasUndoHelper.h Editor/Assets/ScriptCanvasUndoHelper.cpp Editor/Include/ScriptCanvas/Bus/RequestBus.h @@ -56,6 +46,8 @@ set(FILES Editor/Include/ScriptCanvas/Components/EditorGraphVariableManagerComponent.h Editor/Components/EditorGraphVariableManagerComponent.cpp Editor/Include/ScriptCanvas/Components/EditorScriptCanvasComponent.h + Editor/Include/ScriptCanvas/Components/EditorDeprecationData.h + Editor/Include/ScriptCanvas/Components/EditorDeprecationData.cpp Editor/Components/EditorScriptCanvasComponent.cpp Editor/Include/ScriptCanvas/Components/EditorScriptCanvasComponentSerializer.h Editor/Include/ScriptCanvas/Components/EditorScriptCanvasComponentSerializer.cpp diff --git a/Gems/ScriptCanvasTesting/Code/Source/Framework/ScriptCanvasTestUtilities.cpp b/Gems/ScriptCanvasTesting/Code/Source/Framework/ScriptCanvasTestUtilities.cpp index f4abbea7b2..d7f6ac7e88 100644 --- a/Gems/ScriptCanvasTesting/Code/Source/Framework/ScriptCanvasTestUtilities.cpp +++ b/Gems/ScriptCanvasTesting/Code/Source/Framework/ScriptCanvasTestUtilities.cpp @@ -6,7 +6,6 @@ * */ -#include #include #include #include From d9f0a3012d13f739e2df261f176afdb7cecc44fb Mon Sep 17 00:00:00 2001 From: Qing Tao <55564570+VickyAtAZ@users.noreply.github.com> Date: Mon, 13 Dec 2021 14:30:53 -0800 Subject: [PATCH 35/70] LYN-8837 o3de Material Editor - Texture Settings Editor - Hangs when converting texture (#6359) Fixed a editor hanging issue when preview texture with astc format (starts multiple job threads inside a job thread) Fixed an issue of changing texture setting didn't trigger image re-process. Fixed an issue with image asset which has texture setting may have dependency with wrong preset Added a EIF_HDR for source image in hdr format. Fixed astc compression issue which may wrongly compress image to HDR astc format Signed-off-by: Qing Tao <55564570+VickyAtAZ@users.noreply.github.com> --- .../Config/AlbedoWithGenericAlpha.preset | 2 +- .../Atom/ImageProcessing/PixelFormats.h | 1 + .../Source/Compressors/ASTCCompressor.cpp | 76 ++++++++++++++----- .../Code/Source/ImageBuilderComponent.cpp | 16 ++-- .../Code/Source/ImageLoader/ImageLoaders.cpp | 19 ++++- .../Code/Source/Processing/ImageFlags.h | 2 +- .../Source/Processing/PixelFormatInfo.cpp | 18 +++++ 7 files changed, 101 insertions(+), 33 deletions(-) diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/AlbedoWithGenericAlpha.preset b/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/AlbedoWithGenericAlpha.preset index c315ede21c..3340fd39e4 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/AlbedoWithGenericAlpha.preset +++ b/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/AlbedoWithGenericAlpha.preset @@ -7,7 +7,7 @@ "UUID": "{5D9ECB52-4CD9-4CB8-80E3-10CAE5EFB8A2}", "Name": "AlbedoWithGenericAlpha", "RGB_Weight": "CIEXYZ", - "PixelFormat": "ASTC_4x4", + "PixelFormat": "BC3", "MipMapSetting": { "MipGenType": "Box" } diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Include/Atom/ImageProcessing/PixelFormats.h b/Gems/Atom/Asset/ImageProcessingAtom/Code/Include/Atom/ImageProcessing/PixelFormats.h index 4da996dbde..1d11a05c17 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Include/Atom/ImageProcessing/PixelFormats.h +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Include/Atom/ImageProcessing/PixelFormats.h @@ -79,6 +79,7 @@ namespace ImageProcessingAtom }; bool IsASTCFormat(EPixelFormat fmt); + bool IsHDRFormat(EPixelFormat fmt); } // namespace ImageProcessingAtom namespace AZ diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Compressors/ASTCCompressor.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Compressors/ASTCCompressor.cpp index 4ef47c043d..91829bb5be 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Compressors/ASTCCompressor.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Compressors/ASTCCompressor.cpp @@ -78,7 +78,7 @@ namespace ImageProcessingAtom return true; } - astcenc_profile GetAstcProfile(bool isSrgb, EPixelFormat pixelFormat) + astcenc_profile GetAstcProfile(bool isSrgb, bool isHDR) { // select profile depends on LDR or HDR, SRGB or Linear // ASTCENC_PRF_LDR @@ -86,8 +86,6 @@ namespace ImageProcessingAtom // ASTCENC_PRF_HDR_RGB_LDR_A // ASTCENC_PRF_HDR - auto formatInfo = CPixelFormats::GetInstance().GetPixelFormatInfo(pixelFormat); - bool isHDR = formatInfo->eSampleType == ESampleType::eSampleType_Half || formatInfo->eSampleType == ESampleType::eSampleType_Float; astcenc_profile profile; if (isHDR) { @@ -170,7 +168,7 @@ namespace ImageProcessingAtom auto dstFormatInfo = CPixelFormats::GetInstance().GetPixelFormatInfo(fmtDst); const float quality = GetAstcCompressQuality(compressOption->compressQuality); - const astcenc_profile profile = GetAstcProfile(srcImage->HasImageFlags(EIF_SRGBRead), fmtSrc); + const astcenc_profile profile = GetAstcProfile(srcImage->HasImageFlags(EIF_SRGBRead), srcImage->HasImageFlags(EIF_HDR)); astcenc_config config; astcenc_error status; @@ -182,10 +180,12 @@ namespace ImageProcessingAtom // Create a context based on the configuration astcenc_context* context; AZ::u32 blockCount = ((srcImage->GetWidth(0)+ dstFormatInfo->blockWidth-1)/dstFormatInfo->blockWidth) * ((srcImage->GetHeight(0) + dstFormatInfo->blockHeight-1)/dstFormatInfo->blockHeight); - AZ::u32 threadCount = AZStd::min(AZStd::thread::hardware_concurrency(), blockCount); + AZ::u32 threadCount = AZStd::min(AZStd::thread::hardware_concurrency()/2, blockCount); status = astcenc_context_alloc(&config, threadCount, &context); AZ_Assert( status == ASTCENC_SUCCESS, "ERROR: Codec context alloc failed: %s\n", astcenc_get_error_string(status)); + AZ::Job* currentJob = AZ::JobContext::GetGlobalContext()->GetJobManager().GetCurrentJob(); + const astcenc_type dataType =GetAstcDataType(fmtSrc); // Compress the image for each mips @@ -209,29 +209,65 @@ namespace ImageProcessingAtom dstImage->GetImagePointer(mip, dstMem, dstPitch); AZ::u32 dataSize = dstImage->GetMipBufSize(mip); - // Create jobs for each compression thread - auto completionJob = aznew AZ::JobCompletion(); - for (AZ::u32 threadIdx = 0; threadIdx < threadCount; threadIdx++) + if (threadCount == 1) { - const auto jobLambda = [&status, context, &image, &swizzle, dstMem, dataSize, threadIdx]() + astcenc_error error = astcenc_compress_image(context, &image, &swizzle, dstMem, dataSize, 0); + if (error != ASTCENC_SUCCESS) { + status = error; + } + } + else + { + AZ::JobCompletion* completionJob = nullptr; + if (!currentJob) + { + completionJob = aznew AZ::JobCompletion(); + } + // Create jobs for each compression thread + for (AZ::u32 threadIdx = 0; threadIdx < threadCount; threadIdx++) + { + const auto jobLambda = [&status, context, &image, &swizzle, dstMem, dataSize, threadIdx]() + { + astcenc_error error = astcenc_compress_image(context, &image, &swizzle, dstMem, dataSize, threadIdx); + if (error != ASTCENC_SUCCESS) + { + status = error; + } + }; + + AZ::Job* simulationJob = AZ::CreateJobFunction(AZStd::move(jobLambda), true, nullptr); //auto-deletes + + // adds this job as child to current job if there is a current job + // otherwise adds it as a dependent for the complete job + if (currentJob) + { + currentJob->StartAsChild(simulationJob); + } + else + { + simulationJob->SetDependent(completionJob); + simulationJob->Start(); + } + astcenc_error error = astcenc_compress_image(context, &image, &swizzle, dstMem, dataSize, threadIdx); if (error != ASTCENC_SUCCESS) { status = error; } - }; + } + + if (currentJob) + { + currentJob->WaitForChildren(); + } - AZ::Job* simulationJob = AZ::CreateJobFunction(AZStd::move(jobLambda), true, nullptr); //auto-deletes - simulationJob->SetDependent(completionJob); - simulationJob->Start(); - } - - if (completionJob) - { - completionJob->StartAndWaitForCompletion(); - delete completionJob; - completionJob = nullptr; + if (completionJob) + { + completionJob->StartAndWaitForCompletion(); + delete completionJob; + completionJob = nullptr; + } } if (status != ASTCENC_SUCCESS) diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/ImageBuilderComponent.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/ImageBuilderComponent.cpp index 57596f4a71..c44cb39452 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/ImageBuilderComponent.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/ImageBuilderComponent.cpp @@ -221,18 +221,19 @@ namespace ImageProcessingAtom m_isShuttingDown = true; } - PresetName GetImagePreset(const AZStd::string& filepath) + PresetName GetImagePreset(const AZStd::string& imageFileFullPath) { // first let preset from asset info TextureSettings textureSettings; - StringOutcome output = TextureSettings::LoadTextureSetting(filepath, textureSettings); + AZStd::string settingFilePath = imageFileFullPath + TextureSettings::ExtensionName; + TextureSettings::LoadTextureSetting(settingFilePath, textureSettings); if (!textureSettings.m_preset.IsEmpty()) { return textureSettings.m_preset; } - return BuilderSettingManager::Instance()->GetSuggestedPreset(filepath); + return BuilderSettingManager::Instance()->GetSuggestedPreset(imageFileFullPath); } void HandlePresetDependency(PresetName presetName, AZStd::vector& sourceDependencyList) @@ -305,13 +306,14 @@ namespace ImageProcessingAtom // add source dependency for .assetinfo file AssetBuilderSDK::SourceFileDependency sourceFileDependency; sourceFileDependency.m_sourceDependencyType = AssetBuilderSDK::SourceFileDependency::SourceFileDependencyType::Absolute; - sourceFileDependency.m_sourceFileDependencyPath = request.m_sourceFile; - AZ::StringFunc::Path::ReplaceExtension(sourceFileDependency.m_sourceFileDependencyPath, TextureSettings::ExtensionName); + sourceFileDependency.m_sourceFileDependencyPath = request.m_sourceFile + TextureSettings::ExtensionName; response.m_sourceFileDependencyList.push_back(sourceFileDependency); // add source dependencies for .preset files - // Get the preset for this file - auto presetName = GetImagePreset(request.m_sourceFile); + // Get the preset for this file + AZ::IO::FixedMaxPath fullPath(request.m_watchFolder); + fullPath /= request.m_sourceFile; + auto presetName = GetImagePreset(fullPath.c_str()); HandlePresetDependency(presetName, response.m_sourceFileDependencyList); response.m_result = AssetBuilderSDK::CreateJobsResultCode::Success; diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/ImageLoader/ImageLoaders.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/ImageLoader/ImageLoaders.cpp index e756174810..74517f5b18 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/ImageLoader/ImageLoaders.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/ImageLoader/ImageLoaders.cpp @@ -8,6 +8,7 @@ #include +#include #include // warning C4251: class QT_Type needs to have dll-interface to be used by clients of class 'QT_Type' AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") @@ -26,21 +27,31 @@ namespace ImageProcessingAtom return nullptr; } + IImageObject* loadedImage = nullptr; if (TIFFLoader::IsExtensionSupported(ext.toUtf8())) { - return TIFFLoader::LoadImageFromTIFF(filename); + loadedImage = TIFFLoader::LoadImageFromTIFF(filename); } else if (DdsLoader::IsExtensionSupported(ext.toUtf8())) { - return DdsLoader::LoadImageFromFile(filename); + loadedImage = DdsLoader::LoadImageFromFile(filename); } else if (QtImageLoader::IsExtensionSupported(ext.toUtf8())) { - return QtImageLoader::LoadImageFromFile(filename); + loadedImage = QtImageLoader::LoadImageFromFile(filename); } else if (ExrLoader::IsExtensionSupported(ext.toUtf8())) { - return ExrLoader::LoadImageFromFile(filename); + loadedImage = ExrLoader::LoadImageFromFile(filename); + } + + if (loadedImage) + { + if (IsHDRFormat(loadedImage->GetPixelFormat())) + { + loadedImage->AddImageFlags(EIF_HDR); + } + return loadedImage; } AZ_Warning("ImageProcessing", false, "No proper image loader to load file: %s", filename.c_str()); diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageFlags.h b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageFlags.h index d25533cccd..cefd315448 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageFlags.h +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageFlags.h @@ -19,7 +19,7 @@ namespace ImageProcessingAtom const static AZ::u32 EIF_Decal = 0x4; // this is usually set through the preset const static AZ::u32 EIF_Greyscale = 0x8; // hint for the engine (e.g. greyscale light beams can be applied to shadow mask), can be for DXT1 because compression artfacts don't count as color const static AZ::u32 EIF_SupressEngineReduce = 0x10; // info for the engine: don't reduce texture resolution on this texture - const static AZ::u32 EIF_UNUSED_BIT = 0x40; // Free to use + const static AZ::u32 EIF_HDR = 0x40; // the image contains HDR data const static AZ::u32 EIF_AttachedAlpha = 0x400; // deprecated: info for the engine: it's a texture with attached alpha channel const static AZ::u32 EIF_SRGBRead = 0x800; // info for the engine: if gamma corrected rendering is on, this texture requires SRGBRead (it's not stored in linear) const static AZ::u32 EIF_DontResize = 0x8000; // info for the engine: for dds textures that shouldn't be resized diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/PixelFormatInfo.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/PixelFormatInfo.cpp index 8a741d6637..a413a29862 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/PixelFormatInfo.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/PixelFormatInfo.cpp @@ -52,6 +52,24 @@ namespace ImageProcessingAtom return false; } + bool IsHDRFormat(EPixelFormat fmt) + { + switch (fmt) + { + case ePixelFormat_BC6UH: + case ePixelFormat_R9G9B9E5: + case ePixelFormat_R32G32B32A32F: + case ePixelFormat_R32G32F: + case ePixelFormat_R32F: + case ePixelFormat_R16G16B16A16F: + case ePixelFormat_R16G16F: + case ePixelFormat_R16F: + return true; + default: + return false; + } + } + PixelFormatInfo::PixelFormatInfo( uint32_t a_bitsPerPixel, uint32_t a_Channels, From 04669544cc09c0e859ce2136b6e4fd269549bad1 Mon Sep 17 00:00:00 2001 From: Steve Pham <82231385+spham-amzn@users.noreply.github.com> Date: Mon, 13 Dec 2021 14:54:57 -0800 Subject: [PATCH 36/70] Remove unused trait AZ_TRAIT_DISABLE_FAILED_MULTIPLAYER_GRIDMATE_TESTS (#6389) Signed-off-by: Steve Pham <82231385+spham-amzn@users.noreply.github.com> --- .../AzTest/AzTest/Platform/Android/AzTest_Traits_Android.h | 1 - .../Framework/AzTest/AzTest/Platform/Linux/AzTest_Traits_Linux.h | 1 - 2 files changed, 2 deletions(-) diff --git a/Code/Framework/AzTest/AzTest/Platform/Android/AzTest_Traits_Android.h b/Code/Framework/AzTest/AzTest/Platform/Android/AzTest_Traits_Android.h index 9c22543293..764c48ddb2 100644 --- a/Code/Framework/AzTest/AzTest/Platform/Android/AzTest_Traits_Android.h +++ b/Code/Framework/AzTest/AzTest/Platform/Android/AzTest_Traits_Android.h @@ -26,7 +26,6 @@ #define AZ_TRAIT_DISABLE_FAILED_JOB_BASIC_TESTS true #define AZ_TRAIT_DISABLE_FAILED_MATH_TESTS true #define AZ_TRAIT_DISABLE_FAILED_MERGESETTINGSFOLDER_CONFLICTINGSPECIALIZATIONS true -#define AZ_TRAIT_DISABLE_FAILED_MULTIPLAYER_GRIDMATE_TESTS true #define AZ_TRAIT_DISABLE_FAILED_NETWORKING_TESTS true #define AZ_TRAIT_DISABLE_FAILED_PHYSICS_TESTS true #define AZ_TRAIT_DISABLE_FAILED_SAVE_DATA_TESTS true diff --git a/Code/Framework/AzTest/AzTest/Platform/Linux/AzTest_Traits_Linux.h b/Code/Framework/AzTest/AzTest/Platform/Linux/AzTest_Traits_Linux.h index c2ef308dbb..41770a0a7b 100644 --- a/Code/Framework/AzTest/AzTest/Platform/Linux/AzTest_Traits_Linux.h +++ b/Code/Framework/AzTest/AzTest/Platform/Linux/AzTest_Traits_Linux.h @@ -13,7 +13,6 @@ #define AZ_TRAIT_UNIT_TEST_ENTITY_ID_GEN_TEST_COUNT 10000 #define AZ_TRAIT_UNIT_TEST_DILLER_TRIGGER_EVENT_COUNT 100000 -#define AZ_TRAIT_DISABLE_FAILED_MULTIPLAYER_GRIDMATE_TESTS true #define AZ_TRAIT_DISABLE_FAILED_NATIVE_WINDOWS_TESTS true #define AZ_TRAIT_DISABLE_FAILED_EMOTION_FX_TESTS true #define AZ_TRAIT_DISABLE_FAILED_DLL_TESTS true From d951e1f652380aaab556e296153991db228d8b9b Mon Sep 17 00:00:00 2001 From: michabr <82236305+michabr@users.noreply.github.com> Date: Mon, 13 Dec 2021 15:00:26 -0800 Subject: [PATCH 37/70] LyShine cleanup of TODOs (#6138) * LyShine cleanup pass for Atom conversion Signed-off-by: abrmich * Add GHI numbers to comments Signed-off-by: abrmich --- Code/Editor/EditorViewportWidget.cpp | 6 --- Gems/LyShine/Code/Editor/ViewportWidget.cpp | 5 --- Gems/LyShine/Code/Include/LyShine/Draw2d.h | 4 +- .../Code/Include/LyShine/IRenderGraph.h | 21 ++++++++++ Gems/LyShine/Code/Include/LyShine/ISprite.h | 11 +++++ Gems/LyShine/Code/Source/LyShineDebug.cpp | 12 +++--- Gems/LyShine/Code/Source/RenderGraph.cpp | 6 +-- Gems/LyShine/Code/Source/RenderGraph.h | 20 ++++----- Gems/LyShine/Code/Source/Sprite.cpp | 4 +- Gems/LyShine/Code/Source/Sprite.h | 4 +- .../LyShine/Code/Source/UiCanvasComponent.cpp | 8 ++-- Gems/LyShine/Code/Source/UiFaderComponent.cpp | 23 ++++------ Gems/LyShine/Code/Source/UiImageComponent.cpp | 14 ++----- .../Code/Source/UiImageSequenceComponent.cpp | 10 ++--- Gems/LyShine/Code/Source/UiMaskComponent.cpp | 42 ++++++++----------- .../Source/UiParticleEmitterComponent.cpp | 12 +----- Gems/LyShine/Code/Source/UiRenderer.cpp | 6 +-- Gems/LyShine/Code/Source/UiRenderer.h | 2 +- Gems/LyShine/Code/Source/UiTextComponent.cpp | 24 +++-------- Gems/LyShine/Code/Tests/SpriteTest.cpp | 2 +- .../Code/Source/UiCustomImageComponent.cpp | 2 +- 21 files changed, 105 insertions(+), 133 deletions(-) diff --git a/Code/Editor/EditorViewportWidget.cpp b/Code/Editor/EditorViewportWidget.cpp index 7323da9e95..3f9ff03203 100644 --- a/Code/Editor/EditorViewportWidget.cpp +++ b/Code/Editor/EditorViewportWidget.cpp @@ -665,13 +665,7 @@ void EditorViewportWidget::OnBeginPrepareRender() RenderAll(); // Draw 2D helpers. -#ifdef LYSHINE_ATOM_TODO - TransformationMatrices backupSceneMatrices; -#endif m_debugDisplay->DepthTestOff(); -#ifdef LYSHINE_ATOM_TODO - m_renderer->Set2DMode(m_rcClient.right(), m_rcClient.bottom(), backupSceneMatrices); -#endif auto prevState = m_debugDisplay->GetState(); m_debugDisplay->SetState(e_Mode3D | e_AlphaBlended | e_FillModeSolid | e_CullModeBack | e_DepthWriteOn | e_DepthTestOn); diff --git a/Gems/LyShine/Code/Editor/ViewportWidget.cpp b/Gems/LyShine/Code/Editor/ViewportWidget.cpp index 0746a5213f..993f57aeeb 100644 --- a/Gems/LyShine/Code/Editor/ViewportWidget.cpp +++ b/Gems/LyShine/Code/Editor/ViewportWidget.cpp @@ -341,11 +341,6 @@ void ViewportWidget::ClearUntilSafeToRedraw() // set flag so that Update will just clear the screen rather than rendering canvas m_canvasRenderIsEnabled = false; -#ifdef LYSHINE_ATOM_TODO // check if still needed - // Force an update - Update(); -#endif - // Schedule a timer to set the m_canvasRenderIsEnabled flag // using a time of zero just waits until there is nothing on the event queue QTimer::singleShot(0, this, SLOT(EnableCanvasRender())); diff --git a/Gems/LyShine/Code/Include/LyShine/Draw2d.h b/Gems/LyShine/Code/Include/LyShine/Draw2d.h index 6c848a7f96..8123a834a1 100644 --- a/Gems/LyShine/Code/Include/LyShine/Draw2d.h +++ b/Gems/LyShine/Code/Include/LyShine/Draw2d.h @@ -23,7 +23,7 @@ //! The CDraw2d class implements the IDraw2d interface for drawing 2D images, shapes and text. //! Positions and sizes are specified in pixels in the associated 2D viewport. class CDraw2d - : public IDraw2d // LYSHINE_ATOM_TODO - keep around until gEnv->pLyShine is replaced by bus interface + : public IDraw2d // [LYSHINE_ATOM_TODO][GHI #3573] Make Draw2d work better as an API , public AZ::Render::Bootstrap::NotificationBus::Handler { public: // types @@ -582,7 +582,7 @@ public: // static member functions //! Helper to get the default IDraw2d interface static CDraw2d* GetDefaultDraw2d() { - if (gEnv && gEnv->pLyShine) // LYSHINE_ATOM_TODO - remove pLyShine and use bus interface + if (gEnv && gEnv->pLyShine) // [LYSHINE_ATOM_TODO][GHI #3569] Remove LyShine global interface pointer from legacy global environment { IDraw2d* draw2d = gEnv->pLyShine->GetDraw2d(); return reinterpret_cast(draw2d); diff --git a/Gems/LyShine/Code/Include/LyShine/IRenderGraph.h b/Gems/LyShine/Code/Include/LyShine/IRenderGraph.h index 0e7c127677..e67e234457 100644 --- a/Gems/LyShine/Code/Include/LyShine/IRenderGraph.h +++ b/Gems/LyShine/Code/Include/LyShine/IRenderGraph.h @@ -10,6 +10,8 @@ #include #include +#include + namespace AZ { class Color; @@ -41,9 +43,28 @@ namespace LyShine //! End the setup of a mask render node, this marks the end of adding child primitives virtual void EndMask() = 0; + //! Begin rendering to a texture + virtual void BeginRenderToTexture(AZ::Data::Instance attachmentImage, + const AZ::Vector2& viewportTopLeft, + const AZ::Vector2& viewportSize, + const AZ::Color& clearColor) = 0; + //! End rendering to a texture virtual void EndRenderToTexture() = 0; + //! Add an indexed triangle list primitive to the render graph with given render state + virtual void AddPrimitive(LyShine::UiPrimitive* primitive, const AZ::Data::Instance& texture, + bool isClampTextureMode, bool isTextureSRGB, bool isTexturePremultipliedAlpha, BlendMode blendMode) = 0; + + //! Add an indexed triangle list primitive to the render graph which will use maskTexture as an alpha (gradient) mask + virtual void AddAlphaMaskPrimitive(LyShine::UiPrimitive* primitive, + AZ::Data::Instance contentAttachmentImage, + AZ::Data::Instance maskAttachmentImage, + bool isClampTextureMode, + bool isTextureSRGB, + bool isTexturePremultipliedAlpha, + BlendMode blendMode) = 0; + //! Get a dynamic quad primitive that can be added as an image primitive to the render graph //! The graph handles the allocation of this DynUiPrimitive and deletes it when the graph is reset //! This can be used if the UI component doesn't want to own the storage of the primitive. Used infrequently, diff --git a/Gems/LyShine/Code/Include/LyShine/ISprite.h b/Gems/LyShine/Code/Include/LyShine/ISprite.h index 373024d2db..fdb4b88f22 100644 --- a/Gems/LyShine/Code/Include/LyShine/ISprite.h +++ b/Gems/LyShine/Code/Include/LyShine/ISprite.h @@ -11,6 +11,15 @@ #include #include #include +#include + +namespace AZ +{ + namespace RPI + { + class Image; + } +} //////////////////////////////////////////////////////////////////////////////////////////////////// //! A sprite is a texture with extra information about how it behaves for 2D drawing @@ -135,4 +144,6 @@ public: // member functions //! Returns true if this sprite is configured as a sprite-sheet, false otherwise virtual bool IsSpriteSheet() const = 0; + + virtual AZ::Data::Instance GetImage() = 0; }; diff --git a/Gems/LyShine/Code/Source/LyShineDebug.cpp b/Gems/LyShine/Code/Source/LyShineDebug.cpp index 15894fe4aa..7762b1403b 100644 --- a/Gems/LyShine/Code/Source/LyShineDebug.cpp +++ b/Gems/LyShine/Code/Source/LyShineDebug.cpp @@ -101,7 +101,7 @@ static const int g_numDstBlendModes = 10; //////////////////////////////////////////////////////////////////////////////////////////////////// #if !defined(_RELEASE) -#ifdef LYSHINE_ATOM_TODO +#ifdef LYSHINE_ATOM_TODO // [GHI #6270] Support RTT using Atom static int Create2DTexture(int width, int height, byte* data, ETEX_Format format) { IRenderer* renderer = gEnv->pRenderer; @@ -120,7 +120,7 @@ static AZ::Vector2 GetTextureSize(AZ::Data::Instance image) //////////////////////////////////////////////////////////////////////////////////////////////////// #if !defined(_RELEASE) -#ifdef LYSHINE_ATOM_TODO +#ifdef LYSHINE_ATOM_TODO // [GHI #6270] Support RTT using Atom static void FillTextureRectWithCheckerboard(uint32* data, int textureWidth, int textureHeight, int minX, int minY, [[maybe_unused]] int rectWidth, int rectHeight, int tileWidth, int tileHeight, uint32* colors, bool varyAlpha) @@ -152,7 +152,7 @@ static void FillTextureRectWithCheckerboard(uint32* data, int textureWidth, int #if !defined(_RELEASE) static AZ::Data::Instance CreateMonoTestTexture() { -#ifdef LYSHINE_ATOM_TODO +#ifdef LYSHINE_ATOM_TODO // [GHI #6270] Support RTT using Atom const int width = 32; const int height = 32; uint32 data[width * height]; @@ -192,7 +192,7 @@ static AZ::Data::Instance CreateMonoTestTexture() #if !defined(_RELEASE) static AZ::Data::Instance CreateColorTestTexture() { -#ifdef LYSHINE_ATOM_TODO +#ifdef LYSHINE_ATOM_TODO // [GHI #6270] Support RTT using Atom const int width = 32; const int height = 32; uint32 data[width * height]; @@ -232,7 +232,7 @@ static AZ::Data::Instance CreateColorTestTexture() #if !defined(_RELEASE) static AZ::Data::Instance CreateMonoAlphaTestTexture() { -#ifdef LYSHINE_ATOM_TODO +#ifdef LYSHINE_ATOM_TODO // [GHI #6270] Support RTT using Atom const int width = 32; const int height = 32; uint32 data[width * height]; @@ -272,7 +272,7 @@ static AZ::Data::Instance CreateMonoAlphaTestTexture() #if !defined(_RELEASE) static AZ::Data::Instance CreateColorAlphaTestTexture() { -#ifdef LYSHINE_ATOM_TODO +#ifdef LYSHINE_ATOM_TODO // [GHI #6270] Support RTT using Atom const int width = 32; const int height = 32; uint32 data[width * height]; diff --git a/Gems/LyShine/Code/Source/RenderGraph.cpp b/Gems/LyShine/Code/Source/RenderGraph.cpp index c7baf82fc0..db17fde601 100644 --- a/Gems/LyShine/Code/Source/RenderGraph.cpp +++ b/Gems/LyShine/Code/Source/RenderGraph.cpp @@ -151,7 +151,7 @@ namespace LyShine // Add the indexed primitives to the dynamic draw context for drawing // - // [LYSHINE_ATOM_TODO][ATOM-15073] - need to combine into a single DrawIndexed call to take advantage of the draw call + // [LYSHINE_ATOM_TODO][ATOM-15073] Combine into a single DrawIndexed call to take advantage of the draw call // optimization done by this RenderGraph. This option will be added to DynamicDrawContext. For // now we could combine the vertices ourselves for (const LyShine::UiPrimitive& primitive : m_primitives) @@ -698,7 +698,7 @@ namespace LyShine } //////////////////////////////////////////////////////////////////////////////////////////////////// - void RenderGraph::AddPrimitiveAtom(LyShine::UiPrimitive* primitive, const AZ::Data::Instance& texture, + void RenderGraph::AddPrimitive(LyShine::UiPrimitive* primitive, const AZ::Data::Instance& texture, bool isClampTextureMode, bool isTextureSRGB, bool isTexturePremultipliedAlpha, BlendMode blendMode) { AZStd::vector* renderNodeList = m_renderNodeListStack.top(); @@ -771,7 +771,7 @@ namespace LyShine } //////////////////////////////////////////////////////////////////////////////////////////////////// - void RenderGraph::AddAlphaMaskPrimitiveAtom(LyShine::UiPrimitive* primitive, + void RenderGraph::AddAlphaMaskPrimitive(LyShine::UiPrimitive* primitive, AZ::Data::Instance contentAttachmentImage, AZ::Data::Instance maskAttachmentImage, bool isClampTextureMode, diff --git a/Gems/LyShine/Code/Source/RenderGraph.h b/Gems/LyShine/Code/Source/RenderGraph.h index 36a9e63c5f..1ec1842da3 100644 --- a/Gems/LyShine/Code/Source/RenderGraph.h +++ b/Gems/LyShine/Code/Source/RenderGraph.h @@ -262,6 +262,10 @@ namespace LyShine void StartChildrenForMask() override; void EndMask() override; + void BeginRenderToTexture(AZ::Data::Instance attachmentImage, + const AZ::Vector2& viewportTopLeft, + const AZ::Vector2& viewportSize, + const AZ::Color& clearColor) override; void EndRenderToTexture() override; LyShine::UiPrimitive* GetDynamicQuadPrimitive(const AZ::Vector2* positions, uint32 packedColor) override; @@ -273,25 +277,19 @@ namespace LyShine void PushOverrideAlphaFade(float alphaFadeValue) override; void PopAlphaFade() override; float GetAlphaFade() const override; + + void AddPrimitive(LyShine::UiPrimitive* primitive, const AZ::Data::Instance& texture, + bool isClampTextureMode, bool isTextureSRGB, bool isTexturePremultipliedAlpha, BlendMode blendMode) override; // ~IRenderGraph - // LYSHINE_ATOM_TODO - this can be renamed back to AddPrimitive after removal of IRenderer from all UI components - void AddPrimitiveAtom(LyShine::UiPrimitive* primitive, const AZ::Data::Instance& texture, - bool isClampTextureMode, bool isTextureSRGB, bool isTexturePremultipliedAlpha, BlendMode blendMode); - //! Add an indexed triangle list primitive to the render graph which will use maskTexture as an alpha (gradient) mask - void AddAlphaMaskPrimitiveAtom(LyShine::UiPrimitive* primitive, + void AddAlphaMaskPrimitive(LyShine::UiPrimitive* primitive, AZ::Data::Instance contentAttachmentImage, AZ::Data::Instance maskAttachmentImage, bool isClampTextureMode, bool isTextureSRGB, bool isTexturePremultipliedAlpha, - BlendMode blendMode); - - void BeginRenderToTexture(AZ::Data::Instance attachmentImage, - const AZ::Vector2& viewportTopLeft, - const AZ::Vector2& viewportSize, - const AZ::Color& clearColor); + BlendMode blendMode) override; //! Render the display graph void Render(UiRenderer* uiRenderer, const AZ::Vector2& viewportSize); diff --git a/Gems/LyShine/Code/Source/Sprite.cpp b/Gems/LyShine/Code/Source/Sprite.cpp index 65da7fa159..f8982f4fc2 100644 --- a/Gems/LyShine/Code/Source/Sprite.cpp +++ b/Gems/LyShine/Code/Source/Sprite.cpp @@ -243,12 +243,10 @@ void CSprite::SetCellBorders(int cellIndex, Borders borders) AZ::Data::Instance CSprite::GetImage() { // Prioritize usage of an atlas -#ifdef LYSHINE_ATOM_TODO // texture atlas conversion to use Atom if (m_atlas) { return m_atlas->GetTexture(); } -#endif return m_image; } @@ -701,7 +699,7 @@ CSprite* CSprite::CreateSprite(const AZStd::string& renderTargetName) // create Sprite object CSprite* sprite = new CSprite; -#ifdef LYSHINE_ATOM_TODO // render target converstion to use ATom +#ifdef LYSHINE_ATOM_TODO // [GHI #6270] Support RTT using Atom // the render target texture may not exist yet in which case we will need to load it later sprite->m_texture = gEnv->pRenderer->EF_GetTextureByName(renderTargetName.c_str()); if (sprite->m_texture) diff --git a/Gems/LyShine/Code/Source/Sprite.h b/Gems/LyShine/Code/Source/Sprite.h index 0b2c790cf6..71c3bbcca2 100644 --- a/Gems/LyShine/Code/Source/Sprite.h +++ b/Gems/LyShine/Code/Source/Sprite.h @@ -56,7 +56,7 @@ public: // member functions void SetCellAlias(int cellIndex, const AZStd::string& cellAlias) override; int GetCellIndexFromAlias(const AZStd::string& cellAlias) const override; bool IsSpriteSheet() const override; - + AZ::Data::Instance GetImage() override; // ~ISprite // TextureAtlasNotifications @@ -66,8 +66,6 @@ public: // member functions // ~TextureAtlasNotifications - AZ::Data::Instance GetImage(); - public: // static member functions static void Initialize(); diff --git a/Gems/LyShine/Code/Source/UiCanvasComponent.cpp b/Gems/LyShine/Code/Source/UiCanvasComponent.cpp index 964ce1d0fa..78b9c71f8e 100644 --- a/Gems/LyShine/Code/Source/UiCanvasComponent.cpp +++ b/Gems/LyShine/Code/Source/UiCanvasComponent.cpp @@ -3605,7 +3605,7 @@ void UiCanvasComponent::CreateRenderTarget() return; } -#ifdef LYSHINE_ATOM_TODO // [LYN-3359] Support RTT using Atom +#ifdef LYSHINE_ATOM_TODO // [GHI #6269] Support RTT using Atom // Create a render target that this canvas will be rendered to. // The render target size is the canvas size. m_renderTargetHandle = gEnv->pRenderer->CreateRenderTarget(m_renderTargetName.c_str(), @@ -3636,11 +3636,11 @@ void UiCanvasComponent::DestroyRenderTarget() if (m_renderTargetHandle > 0) { ISystem::CrySystemNotificationBus::Handler::BusDisconnect(); -#ifdef LYSHINE_ATOM_TODO // [LYN-3359] Support RTT using Atom +#ifdef LYSHINE_ATOM_TODO // [GHI #6269] Support RTT using Atom gEnv->pRenderer->DestroyDepthSurface(m_renderTargetDepthSurface); #endif m_renderTargetDepthSurface = nullptr; -#ifdef LYSHINE_ATOM_TODO // [LYN-3359] Support RTT using Atom +#ifdef LYSHINE_ATOM_TODO // [GHI #6269] Support RTT using Atom gEnv->pRenderer->DestroyRenderTarget(m_renderTargetHandle); #endif m_renderTargetHandle = -1; @@ -3650,7 +3650,7 @@ void UiCanvasComponent::DestroyRenderTarget() //////////////////////////////////////////////////////////////////////////////////////////////////// void UiCanvasComponent::RenderCanvasToTexture() { -#ifdef LYSHINE_ATOM_TODO // [LYN-3359] Support RTT using Atom +#ifdef LYSHINE_ATOM_TODO // [GHI #6269] Support RTT using Atom if (m_renderTargetHandle <= 0) { return; diff --git a/Gems/LyShine/Code/Source/UiFaderComponent.cpp b/Gems/LyShine/Code/Source/UiFaderComponent.cpp index 62acbc30ef..e1f5153e99 100644 --- a/Gems/LyShine/Code/Source/UiFaderComponent.cpp +++ b/Gems/LyShine/Code/Source/UiFaderComponent.cpp @@ -455,7 +455,7 @@ void UiFaderComponent::CreateOrResizeRenderTarget(const AZ::Vector2& pixelAligne m_viewportTopLeft = pixelAlignedTopLeft; m_viewportSize = renderTargetSize; - // LYSHINE_ATOM_TODO: optimize by reusing/resizing targets + // [LYSHINE_ATOM_TODO][GHI #6271] Optimize by reusing existing render targets DestroyRenderTarget(); // Create a render target that this element and its children will be rendered to @@ -573,8 +573,7 @@ void UiFaderComponent::RenderRttFader(LyShine::IRenderGraph* renderGraph, UiElem AZ::Color clearColor(0.0f, 0.0f, 0.0f, 0.0f); // Start building the render to texture node in the render graph - LyShine::RenderGraph* lyRenderGraph = static_cast(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570 - lyRenderGraph->BeginRenderToTexture(attachmentImage, m_viewportTopLeft, m_viewportSize, clearColor); + renderGraph->BeginRenderToTexture(attachmentImage, m_viewportTopLeft, m_viewportSize, clearColor); // We don't want this fader or parent faders to affect what is rendered to the render target since we will // apply those fades when we render from the render target. @@ -613,17 +612,13 @@ void UiFaderComponent::RenderRttFader(LyShine::IRenderGraph* renderGraph, UiElem // Add a primitive to render a quad using the render target we have created { - LyShine::RenderGraph* lyRenderGraph = static_cast(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570 - if (lyRenderGraph) - { - // Set the texture and other render state required - AZ::Data::Instance image = attachmentImage; - bool isClampTextureMode = true; - bool isTextureSRGB = true; - bool isTexturePremultipliedAlpha = true; - LyShine::BlendMode blendMode = LyShine::BlendMode::Normal; - lyRenderGraph->AddPrimitiveAtom(&m_cachedPrimitive, image, isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, blendMode); - } + // Set the texture and other render state required + AZ::Data::Instance image = attachmentImage; + bool isClampTextureMode = true; + bool isTextureSRGB = true; + bool isTexturePremultipliedAlpha = true; + LyShine::BlendMode blendMode = LyShine::BlendMode::Normal; + renderGraph->AddPrimitive(&m_cachedPrimitive, image, isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, blendMode); } } } diff --git a/Gems/LyShine/Code/Source/UiImageComponent.cpp b/Gems/LyShine/Code/Source/UiImageComponent.cpp index c47d4b6ea1..100bee6bf6 100644 --- a/Gems/LyShine/Code/Source/UiImageComponent.cpp +++ b/Gems/LyShine/Code/Source/UiImageComponent.cpp @@ -278,11 +278,7 @@ namespace AZ::Data::Instance image; if (sprite) { - CSprite* cSprite = static_cast(sprite); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570 - if (cSprite) - { - image = cSprite->GetImage(); - } + image = sprite->GetImage(); } return image; @@ -469,7 +465,7 @@ void UiImageComponent::Render(LyShine::IRenderGraph* renderGraph) } } -#ifdef LYSHINE_ATOM_TODO // keeping this code for future phase (masks and render targets) +#ifdef LYSHINE_ATOM_TODO // [GHI #6270] Support RTT using Atom ITexture* texture = (sprite) ? sprite->GetTexture() : nullptr; bool isClampTextureMode = m_imageType == ImageType::Tiled ? false : true; bool isTextureSRGB = IsSpriteTypeRenderTarget() && m_isRenderTargetSRGB; @@ -482,11 +478,7 @@ void UiImageComponent::Render(LyShine::IRenderGraph* renderGraph) bool isTextureSRGB = IsSpriteTypeRenderTarget() && m_isRenderTargetSRGB; bool isTexturePremultipliedAlpha = false; // we are not rendering from a render target with alpha in it - LyShine::RenderGraph* lyRenderGraph = static_cast(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570 - if (lyRenderGraph) - { - lyRenderGraph->AddPrimitiveAtom(&m_cachedPrimitive, image, isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, m_blendMode); - } + renderGraph->AddPrimitive(&m_cachedPrimitive, image, isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, m_blendMode); #endif } } diff --git a/Gems/LyShine/Code/Source/UiImageSequenceComponent.cpp b/Gems/LyShine/Code/Source/UiImageSequenceComponent.cpp index 554a0383c1..4e7d22d96a 100644 --- a/Gems/LyShine/Code/Source/UiImageSequenceComponent.cpp +++ b/Gems/LyShine/Code/Source/UiImageSequenceComponent.cpp @@ -97,7 +97,7 @@ void UiImageSequenceComponent::Render(LyShine::IRenderGraph* renderGraph) return; } - CSprite* sprite = static_cast(m_spriteList[m_sequenceIndex]); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570 + ISprite* sprite = m_spriteList[m_sequenceIndex]; // get fade value (tracked by UiRenderer) and compute the desired alpha for the image float fade = renderGraph->GetAlphaFade(); @@ -165,12 +165,8 @@ void UiImageSequenceComponent::Render(LyShine::IRenderGraph* renderGraph) LyShine::BlendMode blendMode = LyShine::BlendMode::Normal; // Add the quad to the render graph - LyShine::RenderGraph* lyRenderGraph = static_cast(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570 - if (lyRenderGraph) - { - lyRenderGraph->AddPrimitiveAtom(&m_cachedPrimitive, image, - isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, blendMode); - } + renderGraph->AddPrimitive(&m_cachedPrimitive, image, + isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, blendMode); } } diff --git a/Gems/LyShine/Code/Source/UiMaskComponent.cpp b/Gems/LyShine/Code/Source/UiMaskComponent.cpp index ebe611d547..09975d1351 100644 --- a/Gems/LyShine/Code/Source/UiMaskComponent.cpp +++ b/Gems/LyShine/Code/Source/UiMaskComponent.cpp @@ -557,7 +557,7 @@ void UiMaskComponent::CreateOrResizeRenderTarget(const AZ::Vector2& pixelAligned m_viewportTopLeft = pixelAlignedTopLeft; m_viewportSize = renderTargetSize; - // LYSHINE_ATOM_TODO: optimize by reusing/resizing targets + // [LYSHINE_ATOM_TODO][GHI #6271] Optimize by reusing existing render targets DestroyRenderTarget(); // Create a render target that this element and its children will be rendered to @@ -721,8 +721,7 @@ void UiMaskComponent::RenderUsingGradientMask(LyShine::IRenderGraph* renderGraph // mask render target { // Start building the render to texture node in the render graph - LyShine::RenderGraph* lyRenderGraph = static_cast(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570 - lyRenderGraph->BeginRenderToTexture(maskAttachmentImage, m_viewportTopLeft, m_viewportSize, clearColor); + renderGraph->BeginRenderToTexture(maskAttachmentImage, m_viewportTopLeft, m_viewportSize, clearColor); // Render the visual component for this element (if there is one) plus the child mask element (if there is one) RenderMaskPrimitives(renderGraph, renderInterface, childMaskElementInterface, isInGame); @@ -734,8 +733,7 @@ void UiMaskComponent::RenderUsingGradientMask(LyShine::IRenderGraph* renderGraph // content render target { // Start building the render to texture node for the content render target in the render graph - LyShine::RenderGraph* lyRenderGraph = static_cast(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570 - lyRenderGraph->BeginRenderToTexture(contentAttachmentImage, m_viewportTopLeft, m_viewportSize, clearColor); + renderGraph->BeginRenderToTexture(contentAttachmentImage, m_viewportTopLeft, m_viewportSize, clearColor); // Render the "content" - the child elements excluding the child mask element (if any) RenderContentPrimitives(renderGraph, elementInterface, childMaskElementInterface, numChildren, isInGame); @@ -771,26 +769,22 @@ void UiMaskComponent::RenderUsingGradientMask(LyShine::IRenderGraph* renderGraph // Add a primitive to do the alpha mask { - LyShine::RenderGraph* lyRenderGraph = static_cast(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570 - if (lyRenderGraph) - { - // Set the texture and other render state required - AZ::Data::Instance contentImage = contentAttachmentImage; - AZ::Data::Instance maskImage = maskAttachmentImage; - bool isClampTextureMode = true; - bool isTextureSRGB = true; - bool isTexturePremultipliedAlpha = false; - LyShine::BlendMode blendMode = LyShine::BlendMode::Normal; + // Set the texture and other render state required + AZ::Data::Instance contentImage = contentAttachmentImage; + AZ::Data::Instance maskImage = maskAttachmentImage; + bool isClampTextureMode = true; + bool isTextureSRGB = true; + bool isTexturePremultipliedAlpha = false; + LyShine::BlendMode blendMode = LyShine::BlendMode::Normal; - // add a render node to render using the two render targets, one as an alpha mask of the other - lyRenderGraph->AddAlphaMaskPrimitiveAtom(&m_cachedPrimitive, - contentAttachmentImage, - maskAttachmentImage, - isClampTextureMode, - isTextureSRGB, - isTexturePremultipliedAlpha, - blendMode); - } + // add a render node to render using the two render targets, one as an alpha mask of the other + renderGraph->AddAlphaMaskPrimitive(&m_cachedPrimitive, + contentAttachmentImage, + maskAttachmentImage, + isClampTextureMode, + isTextureSRGB, + isTexturePremultipliedAlpha, + blendMode); } } } diff --git a/Gems/LyShine/Code/Source/UiParticleEmitterComponent.cpp b/Gems/LyShine/Code/Source/UiParticleEmitterComponent.cpp index e55b310e4a..b999480940 100644 --- a/Gems/LyShine/Code/Source/UiParticleEmitterComponent.cpp +++ b/Gems/LyShine/Code/Source/UiParticleEmitterComponent.cpp @@ -786,11 +786,7 @@ void UiParticleEmitterComponent::Render(LyShine::IRenderGraph* renderGraph) AZ::Data::Instance image; if (m_sprite) { - CSprite* sprite = static_cast(m_sprite); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570 - if (sprite) - { - image = sprite->GetImage(); - } + image = m_sprite->GetImage(); } bool isClampTextureMode = true; @@ -844,11 +840,7 @@ void UiParticleEmitterComponent::Render(LyShine::IRenderGraph* renderGraph) m_cachedPrimitive.m_numVertices = totalVerticesInserted; m_cachedPrimitive.m_numIndices = totalParticlesInserted * indicesPerParticle; - LyShine::RenderGraph* lyRenderGraph = static_cast(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570 - if (lyRenderGraph) - { - lyRenderGraph->AddPrimitiveAtom(&m_cachedPrimitive, image, isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, m_blendMode); - } + renderGraph->AddPrimitive(&m_cachedPrimitive, image, isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, m_blendMode); } //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Gems/LyShine/Code/Source/UiRenderer.cpp b/Gems/LyShine/Code/Source/UiRenderer.cpp index 98b376ec8b..ea5dfdd134 100644 --- a/Gems/LyShine/Code/Source/UiRenderer.cpp +++ b/Gems/LyShine/Code/Source/UiRenderer.cpp @@ -96,13 +96,13 @@ AZ::RPI::ScenePtr UiRenderer::CreateScene(AZStd::shared_ptrEnableAllFeatureProcessors(); // LYSHINE_ATOM_TODO - have a UI pipeline and enable only needed fps + atomScene->EnableAllFeatureProcessors(); // [LYSHINE_ATOM_TODO][GHI #6272] Enable minimal feature processors // Assign the new scene to the specified viewport context viewportContext->SetRenderScene(atomScene); // Create a render pipeline and add it to the scene - AZStd::string pipelineAssetPath = "passes/MainRenderPipeline.azasset"; // LYSHINE_ATOM_TODO - make and use a UI pipeline + AZStd::string pipelineAssetPath = "passes/MainRenderPipeline.azasset"; // [LYSHINE_ATOM_TODO][GHI #6272] Use a custom UI pipeline AZ::Data::Asset pipelineAsset = AZ::RPI::AssetUtils::LoadAssetByProductPath(pipelineAssetPath.c_str(), AZ::RPI::AssetUtils::TraceLevel::Error); AZStd::shared_ptr windowContext = viewportContext->GetWindowContext(); auto renderPipeline = AZ::RPI::RenderPipeline::CreateRenderPipelineForWindow(pipelineAsset, *windowContext.get()); @@ -436,7 +436,7 @@ void UiRenderer::DebugDisplayTextureData(int recordingOption) { if (recordingOption > 0) { -#ifdef LYSHINE_ATOM_TODO // Convert debug to use Atom images +#ifdef LYSHINE_ATOM_TODO // [GHI #3568] Support canvas debug display with Atom // compute the total area of all the textures, also create a vector that we can sort by area AZStd::vector textures; int totalArea = 0; diff --git a/Gems/LyShine/Code/Source/UiRenderer.h b/Gems/LyShine/Code/Source/UiRenderer.h index 0e15d41907..3ff3de5507 100644 --- a/Gems/LyShine/Code/Source/UiRenderer.h +++ b/Gems/LyShine/Code/Source/UiRenderer.h @@ -179,6 +179,6 @@ protected: // attributes #ifndef _RELEASE int m_debugTextureDataRecordLevel = 0; - AZStd::unordered_set m_texturesUsedInFrame; // LYSHINE_ATOM_TODO - convert to RPI::Image + AZStd::unordered_set m_texturesUsedInFrame; // [LYN-7857] - Support debug display with Atom #endif }; diff --git a/Gems/LyShine/Code/Source/UiTextComponent.cpp b/Gems/LyShine/Code/Source/UiTextComponent.cpp index 825f3869fd..01cfd49e99 100644 --- a/Gems/LyShine/Code/Source/UiTextComponent.cpp +++ b/Gems/LyShine/Code/Source/UiTextComponent.cpp @@ -1843,11 +1843,7 @@ void UiTextComponent::Render(LyShine::IRenderGraph* renderGraph) LyShine::UiPrimitive* primitive = renderGraph->GetDynamicQuadPrimitive(rect.pt, packedColor); primitive->m_next = nullptr; - LyShine::RenderGraph* lyRenderGraph = static_cast(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570 - if (lyRenderGraph) - { - lyRenderGraph->AddPrimitiveAtom(primitive, systemImage, isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, blendMode); - } + renderGraph->AddPrimitive(primitive, systemImage, isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, blendMode); } } @@ -1869,12 +1865,8 @@ void UiTextComponent::Render(LyShine::IRenderGraph* renderGraph) } bool isClampTextureMode = true; - LyShine::RenderGraph* lyRenderGraph = static_cast(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570 - if (lyRenderGraph) - { - lyRenderGraph->AddPrimitiveAtom(&batch->m_cachedPrimitive, texture, - isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, blendMode); - } + renderGraph->AddPrimitive(&batch->m_cachedPrimitive, texture, + isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, blendMode); } } @@ -1884,7 +1876,7 @@ void UiTextComponent::Render(LyShine::IRenderGraph* renderGraph) for (RenderCacheBatch* batch : m_renderCache.m_batches) { - AZ::FFont* font = static_cast(batch->m_font); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570 + AZ::FFont* font = static_cast(batch->m_font); // LYSHINE_ATOM_TODO - move IFont.h out of CryCommon/engine code AZ::Data::Instance fontImage = font->GetFontImage(); if (fontImage) { @@ -1907,12 +1899,8 @@ void UiTextComponent::Render(LyShine::IRenderGraph* renderGraph) // because there is no padding on the left of the glyphs. bool isClampTextureMode = false; - LyShine::RenderGraph* lyRenderGraph = static_cast(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570 - if (lyRenderGraph) - { - lyRenderGraph->AddPrimitiveAtom(&batch->m_cachedPrimitive, fontImage, - isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, blendMode); - } + renderGraph->AddPrimitive(&batch->m_cachedPrimitive, fontImage, + isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, blendMode); } } } diff --git a/Gems/LyShine/Code/Tests/SpriteTest.cpp b/Gems/LyShine/Code/Tests/SpriteTest.cpp index 2fc82546be..53fe27dcdc 100644 --- a/Gems/LyShine/Code/Tests/SpriteTest.cpp +++ b/Gems/LyShine/Code/Tests/SpriteTest.cpp @@ -50,7 +50,7 @@ namespace UnitTest }; -#ifdef LYSHINE_ATOM_TODO // [LYN-3359] - render target support using Atom +#ifdef LYSHINE_ATOM_TODO // [GHI #6270] Support RTT using Atom TEST_F(LyShineSpriteTest, Sprite_CanAcquireRenderTarget) { // initialize to create the static sprite cache diff --git a/Gems/LyShineExamples/Code/Source/UiCustomImageComponent.cpp b/Gems/LyShineExamples/Code/Source/UiCustomImageComponent.cpp index 2c8cb3df49..09ea375923 100644 --- a/Gems/LyShineExamples/Code/Source/UiCustomImageComponent.cpp +++ b/Gems/LyShineExamples/Code/Source/UiCustomImageComponent.cpp @@ -74,7 +74,7 @@ namespace LyShineExamples //////////////////////////////////////////////////////////////////////////////////////////////////// void UiCustomImageComponent::Render([[maybe_unused]] LyShine::IRenderGraph* renderGraph) { -#ifdef LYSHINE_ATOM_TODO // [LYN-3635] convert to use Atom +#ifdef LYSHINE_ATOM_TODO // [GHI #3568] Convert draws to use Atom // get fade value (tracked by UiRenderer) and compute the desired alpha for the image float fade = renderGraph->GetAlphaFade(); float desiredAlpha = m_overrideAlpha * fade; From 087081f449b219e15e7ead8509f373d7420d537b Mon Sep 17 00:00:00 2001 From: dmcdiarmid-ly <63674186+dmcdiarmid-ly@users.noreply.github.com> Date: Mon, 13 Dec 2021 23:26:39 -0700 Subject: [PATCH 38/70] Added DiffuseProbeGridDownsamplePass, which will disable when there are no DiffuseProbeGrids in the scene. Moved the IrradianceImage to the DiffuseGlobalIllumination parent pass. Signed-off-by: dmcdiarmid-ly <63674186+dmcdiarmid-ly@users.noreply.github.com> --- .../Passes/DiffuseGlobalIllumination.pass | 50 ++++++++++++++++++- .../Passes/DiffuseProbeGridDownsample.pass | 48 +----------------- .../Code/Source/CommonSystemComponent.cpp | 2 + ...fuseGlobalIlluminationFeatureProcessor.cpp | 27 ++++++++-- .../DiffuseProbeGridDownsamplePass.cpp | 36 +++++++++++++ .../DiffuseProbeGridDownsamplePass.h | 37 ++++++++++++++ .../Code/atom_feature_common_files.cmake | 2 + 7 files changed, 151 insertions(+), 51 deletions(-) create mode 100644 Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGridDownsamplePass.cpp create mode 100644 Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGridDownsamplePass.h diff --git a/Gems/Atom/Feature/Common/Assets/Passes/DiffuseGlobalIllumination.pass b/Gems/Atom/Feature/Common/Assets/Passes/DiffuseGlobalIllumination.pass index bd17939925..45278cd511 100644 --- a/Gems/Atom/Feature/Common/Assets/Passes/DiffuseGlobalIllumination.pass +++ b/Gems/Atom/Feature/Common/Assets/Passes/DiffuseGlobalIllumination.pass @@ -26,6 +26,54 @@ "Name": "DepthStencilInputOutput", "SlotType": "InputOutput", "ScopeAttachmentUsage": "DepthStencil" + }, + { + "Name": "IrradianceOutput", + "SlotType": "InputOutput", + "ScopeAttachmentUsage": "RenderTarget", + "LoadStoreAction": { + "ClearValue": { + "Value": [ + 0.0, + 0.0, + 0.0, + 0.0 + ] + }, + "LoadAction": "Clear" + } + } + ], + "ImageAttachments": [ + { + "Name": "IrradianceImage", + "SizeSource": { + "Source": { + "Pass": "This", + "Attachment": "NormalInput" + }, + "Multipliers": { + "WidthMultiplier": 0.25, + "HeightMultiplier": 0.25 + } + }, + "MultisampleSource": { + "Pass": "This", + "Attachment": "NormalInput" + }, + "ImageDescriptor": { + "Format": "R16G16B16A16_FLOAT", + "SharedQueueMask": "Graphics" + } + } + ], + "Connections": [ + { + "LocalSlot": "IrradianceOutput", + "AttachmentRef": { + "Pass": "This", + "Attachment": "IrradianceImage" + } } ], "PassRequests": [ @@ -78,7 +126,7 @@ { "LocalSlot": "Output", "AttachmentRef": { - "Pass": "DiffuseProbeGridDownsamplePass", + "Pass": "Parent", "Attachment": "IrradianceOutput" } } diff --git a/Gems/Atom/Feature/Common/Assets/Passes/DiffuseProbeGridDownsample.pass b/Gems/Atom/Feature/Common/Assets/Passes/DiffuseProbeGridDownsample.pass index 266f65f37b..0560cc2d75 100644 --- a/Gems/Atom/Feature/Common/Assets/Passes/DiffuseProbeGridDownsample.pass +++ b/Gems/Atom/Feature/Common/Assets/Passes/DiffuseProbeGridDownsample.pass @@ -5,7 +5,7 @@ "ClassData": { "PassTemplate": { "Name": "DiffuseProbeGridDownsamplePassTemplate", - "PassClass": "FullScreenTriangle", + "PassClass": "DiffuseProbeGridDownsamplePass", "Slots": [ { "Name": "NormalInput", @@ -38,24 +38,6 @@ "LoadStoreAction": { "LoadAction": "DontCare" } - }, - { - // Note: this is attached here to ensure that the image is cleared, - // but it is not used as an output from the shader - "Name": "IrradianceOutput", - "SlotType": "Output", - "ScopeAttachmentUsage": "RenderTarget", - "LoadStoreAction": { - "ClearValue": { - "Value": [ - 0.0, - 0.0, - 0.0, - 0.0 - ] - }, - "LoadAction": "Clear" - } } ], "ImageAttachments": [ @@ -103,27 +85,6 @@ "Format": "R16G16B16A16_FLOAT", "SharedQueueMask": "Graphics" } - }, - { - "Name": "IrradianceImage", - "SizeSource": { - "Source": { - "Pass": "This", - "Attachment": "NormalInput" - }, - "Multipliers": { - "WidthMultiplier": 0.25, - "HeightMultiplier": 0.25 - } - }, - "MultisampleSource": { - "Pass": "This", - "Attachment": "NormalInput" - }, - "ImageDescriptor": { - "Format": "R16G16B16A16_FLOAT", - "SharedQueueMask": "Graphics" - } } ], "Connections": [ @@ -140,13 +101,6 @@ "Pass": "This", "Attachment": "DownsampledDepthImage" } - }, - { - "LocalSlot": "IrradianceOutput", - "AttachmentRef": { - "Pass": "This", - "Attachment": "IrradianceImage" - } } ], "PassData": { diff --git a/Gems/Atom/Feature/Common/Code/Source/CommonSystemComponent.cpp b/Gems/Atom/Feature/Common/Code/Source/CommonSystemComponent.cpp index c3c189eb62..dc5d1a5c12 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CommonSystemComponent.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/CommonSystemComponent.cpp @@ -97,6 +97,7 @@ #include #include #include +#include #include #include #include @@ -285,6 +286,7 @@ namespace AZ passSystem->AddPassCreator(Name("DiffuseProbeGridBorderUpdatePass"), &Render::DiffuseProbeGridBorderUpdatePass::Create); passSystem->AddPassCreator(Name("DiffuseProbeGridRelocationPass"), &Render::DiffuseProbeGridRelocationPass::Create); passSystem->AddPassCreator(Name("DiffuseProbeGridClassificationPass"), &Render::DiffuseProbeGridClassificationPass::Create); + passSystem->AddPassCreator(Name("DiffuseProbeGridDownsamplePass"), &Render::DiffuseProbeGridDownsamplePass::Create); passSystem->AddPassCreator(Name("DiffuseProbeGridRenderPass"), &Render::DiffuseProbeGridRenderPass::Create); passSystem->AddPassCreator(Name("LuminanceHistogramGeneratorPass"), &LuminanceHistogramGeneratorPass::Create); diff --git a/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseGlobalIlluminationFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseGlobalIlluminationFeatureProcessor.cpp index 453dbbc0ab..768c183f03 100644 --- a/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseGlobalIlluminationFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseGlobalIlluminationFeatureProcessor.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -90,10 +91,11 @@ namespace AZ downsamplePassFilter, [sizeMultiplier](RPI::Pass* pass) -> RPI::PassFilterExecutionFlow { - for (uint32_t outputIndex = 0; outputIndex < pass->GetOutputCount(); ++outputIndex) + // update the downsample pass size multipliers + for (uint32_t attachmentIndex = 0; attachmentIndex < pass->GetOutputCount(); ++attachmentIndex) { - RPI::Ptr outputAttachment = pass->GetOutputBinding(outputIndex).m_attachment; - RPI::PassAttachmentSizeMultipliers& sizeMultipliers = outputAttachment->m_sizeMultipliers; + RPI::Ptr attachment = pass->GetOutputBinding(attachmentIndex).m_attachment; + RPI::PassAttachmentSizeMultipliers& sizeMultipliers = attachment->m_sizeMultipliers; sizeMultipliers.m_widthMultiplier = sizeMultiplier; sizeMultipliers.m_heightMultiplier = sizeMultiplier; @@ -105,6 +107,25 @@ namespace AZ downsamplePass->GetShaderResourceGroup()->SetConstant( outputImageScaleShaderInput, aznumeric_cast(1.0f / sizeMultiplier)); + // update the parent pass IrradianceImage size multiplier + RPI::ParentPass* parentPass = pass->GetParent(); + RPI::Ptr irradianceImageAttachment; + for (uint32_t attachmentIndex = 0; attachmentIndex < parentPass->GetInputOutputCount(); ++attachmentIndex) + { + RPI::Ptr attachment = parentPass->GetInputOutputBinding(attachmentIndex).m_attachment; + if (attachment->m_name == Name("IrradianceImage")) + { + irradianceImageAttachment = attachment; + break; + } + } + + AZ_Assert(irradianceImageAttachment != nullptr, "Unable to find IrradianceImage attachment"); + + RPI::PassAttachmentSizeMultipliers& sizeMultipliers = irradianceImageAttachment->m_sizeMultipliers; + sizeMultipliers.m_widthMultiplier = sizeMultiplier; + sizeMultipliers.m_heightMultiplier = sizeMultiplier; + // handle all downsample passes return RPI::PassFilterExecutionFlow::ContinueVisitingPasses; }); diff --git a/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGridDownsamplePass.cpp b/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGridDownsamplePass.cpp new file mode 100644 index 0000000000..2a11218b47 --- /dev/null +++ b/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGridDownsamplePass.cpp @@ -0,0 +1,36 @@ +/* + * 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 "DiffuseProbeGridDownsamplePass.h" +#include +#include + +namespace AZ +{ + namespace Render + { + RPI::Ptr DiffuseProbeGridDownsamplePass::Create(const RPI::PassDescriptor& descriptor) + { + RPI::Ptr pass = aznew DiffuseProbeGridDownsamplePass(descriptor); + return AZStd::move(pass); + } + + DiffuseProbeGridDownsamplePass::DiffuseProbeGridDownsamplePass(const RPI::PassDescriptor& descriptor) + : RPI::FullscreenTrianglePass(descriptor) + { + } + + bool DiffuseProbeGridDownsamplePass::IsEnabled() const + { + // only enabled if there are DiffuseProbeGrids present in the scene + DiffuseProbeGridFeatureProcessor* diffuseProbeGridFeatureProcessor = m_pipeline->GetScene()->GetFeatureProcessor(); + return (diffuseProbeGridFeatureProcessor && !diffuseProbeGridFeatureProcessor->GetProbeGrids().empty()); + } + + } // namespace RPI +} // namespace AZ diff --git a/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGridDownsamplePass.h b/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGridDownsamplePass.h new file mode 100644 index 0000000000..283c758c76 --- /dev/null +++ b/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGridDownsamplePass.h @@ -0,0 +1,37 @@ +/* + * 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 + * + */ +#pragma once + +#include +#include + +namespace AZ +{ + namespace Render + { + //! This pass downsamples the scene for use by the DiffuseProbeGridRenderPass. + class DiffuseProbeGridDownsamplePass + : public RPI::FullscreenTrianglePass + { + AZ_RPI_PASS(DiffuseProbeGridDownsamplePass); + + public: + AZ_RTTI(Render::DiffuseProbeGridDownsamplePass, "{B3331B68-F974-44D6-806B-2CFFB4B6B563}", FullscreenTrianglePass); + AZ_CLASS_ALLOCATOR(Render::DiffuseProbeGridDownsamplePass, SystemAllocator, 0); + + //! Creates a new pass without a PassTemplate + static RPI::Ptr Create(const RPI::PassDescriptor& descriptor); + + private: + explicit DiffuseProbeGridDownsamplePass(const RPI::PassDescriptor& descriptor); + + // Pass behavior overrides... + bool IsEnabled() const override; + }; + } // namespace RPI +} // namespace AZ diff --git a/Gems/Atom/Feature/Common/Code/atom_feature_common_files.cmake b/Gems/Atom/Feature/Common/Code/atom_feature_common_files.cmake index 3ed2ec8755..900e71717c 100644 --- a/Gems/Atom/Feature/Common/Code/atom_feature_common_files.cmake +++ b/Gems/Atom/Feature/Common/Code/atom_feature_common_files.cmake @@ -133,6 +133,8 @@ set(FILES Source/DiffuseGlobalIllumination/DiffuseProbeGridRelocationPass.h Source/DiffuseGlobalIllumination/DiffuseProbeGridClassificationPass.cpp Source/DiffuseGlobalIllumination/DiffuseProbeGridClassificationPass.h + Source/DiffuseGlobalIllumination/DiffuseProbeGridDownsamplePass.cpp + Source/DiffuseGlobalIllumination/DiffuseProbeGridDownsamplePass.h Source/DiffuseGlobalIllumination/DiffuseProbeGridRenderPass.cpp Source/DiffuseGlobalIllumination/DiffuseProbeGridRenderPass.h Source/DiffuseGlobalIllumination/DiffuseProbeGrid.cpp From 82e731b1c006736dfc8253f63bc16ce228671226 Mon Sep 17 00:00:00 2001 From: mrieggeramzn Date: Mon, 13 Dec 2021 22:43:41 -0800 Subject: [PATCH 39/70] Fix for dx12 validation spam Signed-off-by: mrieggeramzn --- .../Common/Assets/Passes/DiffuseProbeGridRender.pass | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Gems/Atom/Feature/Common/Assets/Passes/DiffuseProbeGridRender.pass b/Gems/Atom/Feature/Common/Assets/Passes/DiffuseProbeGridRender.pass index 69c5f48c9c..825a8bad2a 100644 --- a/Gems/Atom/Feature/Common/Assets/Passes/DiffuseProbeGridRender.pass +++ b/Gems/Atom/Feature/Common/Assets/Passes/DiffuseProbeGridRender.pass @@ -25,7 +25,12 @@ { "Name": "DepthStencilInput", "SlotType": "Input", - "ScopeAttachmentUsage": "DepthStencil" + "ScopeAttachmentUsage": "DepthStencil", + "ImageViewDesc": { + "AspectFlags": [ + "Depth" + ] + } }, { "Name": "Output", From f8ca427954cf335ead7915108238548414861f4f Mon Sep 17 00:00:00 2001 From: Guthrie Adams <82461473+gadams3@users.noreply.github.com> Date: Tue, 14 Dec 2021 10:52:01 -0600 Subject: [PATCH 40/70] Fixed several material editor bugs related to file paths and hot reload prompts (#6374) * draft Signed-off-by: Guthrie Adams * Removes automatic generation of relative paths for external references for materials Updated material editor functions for creating new materials, creating or saving model or lighting presets, to save to the project asset folder instead of the material folder which is not included in the new templates Changed function for getting saved file names to handle case where Qt save file dialog adds double extensions if the extension contains a dot Signed-off-by: Guthrie Adams * Fixed problems with material editor hot reloading after documents or dependencies changed. Triggering message boxes within the tick function, which is executed from the main application timer, caused the tick function to be called a second time recursively. Switched from using the tick bus to a timer so that the documents re opening and dialogs are triggered outside of the main tick. Signed-off-by: Guthrie Adams --- .../Util/MaterialPropertyUtil.h | 8 +++--- .../AtomToolsDocumentSystemComponent.cpp | 25 ++++++++++-------- .../AtomToolsDocumentSystemComponent.h | 9 +++---- .../Code/Source/Util/MaterialPropertyUtil.cpp | 26 +++++-------------- .../Code/Source/Util/Util.cpp | 6 ++++- .../Code/Tests/AtomToolsFrameworkTest.cpp | 18 ++++++------- .../Code/Source/Document/MaterialDocument.cpp | 2 +- .../CreateMaterialDialog.cpp | 20 ++++++-------- .../MaterialEditorBrowserInteractions.cpp | 9 ++++--- .../ViewportSettingsInspector.cpp | 14 +++++----- 10 files changed, 60 insertions(+), 77 deletions(-) diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Util/MaterialPropertyUtil.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Util/MaterialPropertyUtil.h index d27f2403a1..961febf0f4 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Util/MaterialPropertyUtil.h +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Util/MaterialPropertyUtil.h @@ -53,14 +53,12 @@ namespace AtomToolsFramework const AZ::RPI::MaterialTypeSourceData::PropertyDefinition& propertyDefinition, AZ::RPI::MaterialPropertyValue& propertyValue); - //! Generate a file path from the exported file to the external reference. - //! This function returns a relative path from the export file to the reference file. - //! If the relative path is too different or distant from the export path then we return the asset folder relative path. + //! Generate a file path that is relative to either the source asset root or the export path //! @param exportPath absolute path of the file being saved //! @param referencePath absolute path of a file that will be treated as an external reference - //! @param maxPathDepth the maximum relative depth or number of parent or child folders between the export path and the reference path + //! @param relativeToExportPath specifies if the path is relative to the source asset root or the export path AZStd::string GetExteralReferencePath( - const AZStd::string& exportPath, const AZStd::string& referencePath, const uint32_t maxPathDepth = 2); + const AZStd::string& exportPath, const AZStd::string& referencePath, const bool relativeToExportPath = false); //! Traverse up the instance data node hierarchy to find the containing dynamic property object const AtomToolsFramework::DynamicProperty* FindDynamicPropertyForInstanceDataNode(const AzToolsFramework::InstanceDataNode* pNode); diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentSystemComponent.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentSystemComponent.cpp index 3a392c1413..3b27c9cd0f 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentSystemComponent.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentSystemComponent.cpp @@ -24,6 +24,7 @@ AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnin #include #include #include +#include AZ_POP_DISABLE_WARNING namespace AtomToolsFramework @@ -121,7 +122,6 @@ namespace AtomToolsFramework void AtomToolsDocumentSystemComponent::Deactivate() { - AZ::TickBus::Handler::BusDisconnect(); AtomToolsDocumentNotificationBus::Handler::BusDisconnect(); AtomToolsDocumentSystemRequestBus::Handler::BusDisconnect(); m_documentMap.clear(); @@ -160,25 +160,30 @@ namespace AtomToolsFramework void AtomToolsDocumentSystemComponent::OnDocumentExternallyModified(const AZ::Uuid& documentId) { m_documentIdsWithExternalChanges.insert(documentId); - if (!AZ::TickBus::Handler::BusIsConnected()) - { - AZ::TickBus::Handler::BusConnect(); - } + QueueReopenDocuments(); } void AtomToolsDocumentSystemComponent::OnDocumentDependencyModified(const AZ::Uuid& documentId) { m_documentIdsWithDependencyChanges.insert(documentId); - if (!AZ::TickBus::Handler::BusIsConnected()) + QueueReopenDocuments(); + } + + void AtomToolsDocumentSystemComponent::QueueReopenDocuments() + { + if (!m_queueReopenDocuments) { - AZ::TickBus::Handler::BusConnect(); + m_queueReopenDocuments = true; + QTimer::singleShot(0, [this] { ReopenDocuments(); }); } } - void AtomToolsDocumentSystemComponent::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time) + void AtomToolsDocumentSystemComponent::ReopenDocuments() { for (const AZ::Uuid& documentId : m_documentIdsWithExternalChanges) { + m_documentIdsWithDependencyChanges.erase(documentId); + AZStd::string documentPath; AtomToolsDocumentRequestBus::EventResult(documentPath, documentId, &AtomToolsDocumentRequestBus::Events::GetAbsolutePath); @@ -191,8 +196,6 @@ namespace AtomToolsFramework continue; } - m_documentIdsWithDependencyChanges.erase(documentId); - AtomToolsFramework::TraceRecorder traceRecorder(m_maxMessageBoxLineCount); bool openResult = false; @@ -235,7 +238,7 @@ namespace AtomToolsFramework m_documentIdsWithDependencyChanges.clear(); m_documentIdsWithExternalChanges.clear(); - AZ::TickBus::Handler::BusDisconnect(); + m_queueReopenDocuments = false; } AZ::Uuid AtomToolsDocumentSystemComponent::OpenDocument(AZStd::string_view sourcePath) diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentSystemComponent.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentSystemComponent.h index a0f5eb085d..532271974c 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentSystemComponent.h +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentSystemComponent.h @@ -9,7 +9,6 @@ #pragma once #include -#include #include #include @@ -28,7 +27,6 @@ namespace AtomToolsFramework //! AtomToolsDocumentSystemComponent is the central component of the Material Editor Core gem class AtomToolsDocumentSystemComponent : public AZ::Component - , private AZ::TickBus::Handler , private AtomToolsDocumentNotificationBus::Handler , private AtomToolsDocumentSystemRequestBus::Handler { @@ -59,10 +57,8 @@ namespace AtomToolsFramework void OnDocumentExternallyModified(const AZ::Uuid& documentId) override; ////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////// - // AZ::TickBus::Handler overrides... - void OnTick(float deltaTime, AZ::ScriptTimePoint time) override; - //////////////////////////////////////////////////////////////////////// + void QueueReopenDocuments(); + void ReopenDocuments(); //////////////////////////////////////////////////////////////////////// // AtomToolsDocumentSystemRequestBus::Handler overrides... @@ -87,6 +83,7 @@ namespace AtomToolsFramework AZStd::unordered_map> m_documentMap; AZStd::unordered_set m_documentIdsWithExternalChanges; AZStd::unordered_set m_documentIdsWithDependencyChanges; + bool m_queueReopenDocuments = false; const size_t m_maxMessageBoxLineCount = 15; }; } // namespace AtomToolsFramework diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Util/MaterialPropertyUtil.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Util/MaterialPropertyUtil.cpp index 3ffd8efa6e..ab72214881 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Util/MaterialPropertyUtil.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Util/MaterialPropertyUtil.cpp @@ -222,31 +222,15 @@ namespace AtomToolsFramework return true; } - AZStd::string GetExteralReferencePath(const AZStd::string& exportPath, const AZStd::string& referencePath, const uint32_t maxPathDepth) + AZStd::string GetExteralReferencePath( + const AZStd::string& exportPath, const AZStd::string& referencePath, const bool relativeToExportPath) { if (referencePath.empty()) { return {}; } - AZ::IO::BasicPath exportFolder(exportPath); - exportFolder.RemoveFilename(); - - const AZStd::string relativePath = AZ::IO::PathView(referencePath).LexicallyRelative(exportFolder).StringAsPosix(); - - // Count the difference in depth between the export file path and the referenced file path. - uint32_t parentFolderCount = 0; - AZStd::string::size_type pos = 0; - const AZStd::string parentFolderToken = ".."; - while ((pos = relativePath.find(parentFolderToken, pos)) != AZStd::string::npos) - { - parentFolderCount++; - pos += parentFolderToken.length(); - } - - // If the difference in depth is too great then revert to using the asset folder relative path. - // We could change this to only use relative paths for references in subfolders. - if (parentFolderCount > maxPathDepth) + if (!relativeToExportPath) { AZStd::string watchFolder; AZ::Data::AssetInfo assetInfo; @@ -260,7 +244,9 @@ namespace AtomToolsFramework } } - return relativePath; + AZ::IO::BasicPath exportFolder(exportPath); + exportFolder.RemoveFilename(); + return AZ::IO::PathView(referencePath).LexicallyRelative(exportFolder).StringAsPosix(); } const AtomToolsFramework::DynamicProperty* FindDynamicPropertyForInstanceDataNode(const AzToolsFramework::InstanceDataNode* pNode) diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Util/Util.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Util/Util.cpp index cd50c10e23..b45ff3c12f 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Util/Util.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Util/Util.cpp @@ -62,6 +62,8 @@ namespace AtomToolsFramework const QFileInfo initialFileInfo(initialPath); const QString initialExt(initialFileInfo.completeSuffix()); + // Instead of just passing in the absolute file path, we pass in the absolute folder path and the base name to prevent the file + // dialog from displaying multiple extensions when the extension contains a "." const QFileInfo selectedFileInfo(AzQtComponents::FileDialog::GetSaveFileName( QApplication::activeWindow(), "Save File", @@ -82,7 +84,9 @@ namespace AtomToolsFramework return QFileInfo(); } - return selectedFileInfo; + // Reconstructing the file info from the absolute path and expected extension to compensate for an issue with the save file + // dialog adding the extension multiple times if it contains "." like *.lightingpreset.azasset + return QFileInfo(selectedFileInfo.absolutePath() + AZ_CORRECT_FILESYSTEM_SEPARATOR_STRING + selectedFileInfo.baseName() + "." + initialExt); } QFileInfo GetOpenFileInfo(const AZStd::vector& assetTypes) diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Tests/AtomToolsFrameworkTest.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Tests/AtomToolsFrameworkTest.cpp index 3124372bd2..bdd166192f 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Tests/AtomToolsFrameworkTest.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Tests/AtomToolsFrameworkTest.cpp @@ -66,15 +66,15 @@ namespace UnitTest TEST_F(AtomToolsFrameworkTest, GetExteralReferencePath_Succeeds) { - ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("", "", 2), ""); - ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/materials/condor.material", "", 2), ""); - ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/materials/talisman.material", "", 2), ""); - ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/materials/talisman.material", "d:/project/assets/textures/gold.png", 2), "../textures/gold.png"); - ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/materials/talisman.material", "d:/project/assets/textures/gold.png", 0), "textures/gold.png"); - ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/objects/upgrades/materials/supercondor.material", "d:/project/assets/materials/condor.material", 3), "../../../materials/condor.material"); - ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/objects/upgrades/materials/supercondor.material", "d:/project/assets/materials/condor.material", 2), "materials/condor.material"); - ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/objects/upgrades/materials/supercondor.material", "d:/project/assets/materials/condor.material", 1), "materials/condor.material"); - ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/objects/upgrades/materials/supercondor.material", "d:/project/assets/materials/condor.material", 0), "materials/condor.material"); + ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("", "", true), ""); + ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/materials/condor.material", "", true), ""); + ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/materials/talisman.material", "", false), ""); + ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/materials/talisman.material", "d:/project/assets/textures/gold.png", true), "../textures/gold.png"); + ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/materials/talisman.material", "d:/project/assets/textures/gold.png", false), "textures/gold.png"); + ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/objects/upgrades/materials/supercondor.material", "d:/project/assets/materials/condor.material", true), "../../../materials/condor.material"); + ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/objects/upgrades/materials/supercondor.material", "d:/project/assets/materials/condor.material", false), "materials/condor.material"); + ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/objects/upgrades/materials/supercondor.material", "d:/project/assets/materials/condor.material", false), "materials/condor.material"); + ASSERT_EQ(AtomToolsFramework::GetExteralReferencePath("d:/project/assets/objects/upgrades/materials/supercondor.material", "d:/project/assets/materials/condor.material", false), "materials/condor.material"); } AZ_UNIT_TEST_HOOK(new AtomToolsFrameworkTestEnvironment); diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocument.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocument.cpp index 2d7768feec..97d8d5e354 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocument.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocument.cpp @@ -555,7 +555,7 @@ namespace MaterialEditor void MaterialDocument::SourceFileChanged(AZStd::string relativePath, AZStd::string scanFolder, [[maybe_unused]] AZ::Uuid sourceUUID) { - auto sourcePath = AZ::RPI::AssetUtils::ResolvePathReference(scanFolder, relativePath); + const auto sourcePath = AZ::RPI::AssetUtils::ResolvePathReference(scanFolder, relativePath); if (m_absolutePath == sourcePath) { diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/CreateMaterialDialog/CreateMaterialDialog.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/CreateMaterialDialog/CreateMaterialDialog.cpp index fd20716570..31ca873c48 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/CreateMaterialDialog/CreateMaterialDialog.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/CreateMaterialDialog/CreateMaterialDialog.cpp @@ -6,25 +6,21 @@ * */ -#include - -#include -#include - -#include - -#include - +#include #include #include #include - -#include +#include +#include +#include +#include +#include +#include namespace MaterialEditor { CreateMaterialDialog::CreateMaterialDialog(QWidget* parent) - : CreateMaterialDialog(QString(AZ::IO::FileIOBase::GetInstance()->GetAlias("@projectroot@")) + AZ_CORRECT_FILESYSTEM_SEPARATOR + "Materials", parent) + : CreateMaterialDialog(QString(AZ::Utils::GetProjectPath().c_str()) + AZ_CORRECT_FILESYSTEM_SEPARATOR + "Assets", parent) { } diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorBrowserInteractions.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorBrowserInteractions.cpp index d73737a2dc..435d1f6f12 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorBrowserInteractions.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorBrowserInteractions.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -106,8 +107,8 @@ namespace MaterialEditor menu->addAction("Create Material...", [entry]() { const QString defaultPath = AtomToolsFramework::GetUniqueFileInfo( - QString(AZ::IO::FileIOBase::GetInstance()->GetAlias("@projectroot@")) + - AZ_CORRECT_FILESYSTEM_SEPARATOR + "Materials" + + QString(AZ::Utils::GetProjectPath().c_str()) + + AZ_CORRECT_FILESYSTEM_SEPARATOR + "Assets" + AZ_CORRECT_FILESYSTEM_SEPARATOR + "untitled." + AZ::RPI::MaterialSourceData::Extension).absoluteFilePath(); @@ -182,8 +183,8 @@ namespace MaterialEditor menu->addAction("Create Child Material...", [entry]() { const QString defaultPath = AtomToolsFramework::GetUniqueFileInfo( - QString(AZ::IO::FileIOBase::GetInstance()->GetAlias("@projectroot@")) + - AZ_CORRECT_FILESYSTEM_SEPARATOR + "Materials" + + QString(AZ::Utils::GetProjectPath().c_str()) + + AZ_CORRECT_FILESYSTEM_SEPARATOR + "Assets" + AZ_CORRECT_FILESYSTEM_SEPARATOR + "untitled." + AZ::RPI::MaterialSourceData::Extension).absoluteFilePath(); diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/ViewportSettingsInspector/ViewportSettingsInspector.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/ViewportSettingsInspector/ViewportSettingsInspector.cpp index 5721dfcc72..613762c10a 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/ViewportSettingsInspector/ViewportSettingsInspector.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/ViewportSettingsInspector/ViewportSettingsInspector.cpp @@ -6,10 +6,11 @@ * */ +#include #include #include #include -#include +#include #include #include #include @@ -346,13 +347,10 @@ namespace MaterialEditor AZStd::string ViewportSettingsInspector::GetDefaultUniqueSaveFilePath(const AZStd::string& baseName) const { - AZStd::string savePath = AZ::IO::FileIOBase::GetInstance()->GetAlias("@projectroot@"); - savePath += AZ_CORRECT_FILESYSTEM_SEPARATOR; - savePath += "Materials"; - savePath += AZ_CORRECT_FILESYSTEM_SEPARATOR; - savePath += baseName; - savePath = AtomToolsFramework::GetUniqueFileInfo(savePath.c_str()).absoluteFilePath().toUtf8().constData(); - return savePath; + return AtomToolsFramework::GetUniqueFileInfo( + QString(AZ::Utils::GetProjectPath().c_str()) + + AZ_CORRECT_FILESYSTEM_SEPARATOR + "Assets" + + AZ_CORRECT_FILESYSTEM_SEPARATOR + baseName.c_str()).absoluteFilePath().toUtf8().constData(); } AZ::Crc32 ViewportSettingsInspector::GetGroupSaveStateKey(const AZStd::string& groupName) const From e078eac379a0a75012f55d69b57614e77664c503 Mon Sep 17 00:00:00 2001 From: carlitosan <82187351+carlitosan@users.noreply.github.com> Date: Tue, 14 Dec 2021 14:17:06 -0800 Subject: [PATCH 41/70] redcode the asset itself WIP Signed-off-by: carlitosan <82187351+carlitosan@users.noreply.github.com> --- .../Code/Asset/EditorAssetSystemComponent.cpp | 7 +- .../Code/Asset/EditorAssetSystemComponent.h | 2 - .../Code/Builder/ScriptCanvasBuilder.cpp | 2 +- .../Builder/ScriptCanvasBuilderComponent.cpp | 2 +- .../Code/Editor/Assets/ScriptCanvasAsset.cpp | 126 ------------------ .../Assets/ScriptCanvasAssetHelpers.cpp | 2 +- .../EditorScriptCanvasComponent.cpp | 2 +- .../Framework/ScriptCanvasGraphUtilities.inl | 2 +- .../ScriptCanvas/Assets/ScriptCanvasAsset.h | 88 ------------ .../Assets/ScriptCanvasAssetBus.h | 31 ----- .../Assets/ScriptCanvasAssetTypes.h | 14 -- .../Assets/ScriptCanvasBaseAssetData.cpp | 10 -- .../Assets/ScriptCanvasBaseAssetData.h | 17 --- .../Assets/ScriptCanvasFileHandling.h | 2 +- .../Components/EditorDeprecationData.h | 43 ++++++ Gems/ScriptCanvas/Code/Editor/Settings.cpp | 2 +- .../GraphPivotTree/GraphPivotTree.cpp | 12 +- .../ScriptCanvasNodePaletteDockWidget.cpp | 57 ++++---- .../StatisticsDialog/NodeUsageTreeItem.cpp | 8 +- .../StatisticsDialog/NodeUsageTreeItem.h | 2 +- .../ScriptCanvasStatisticsDialog.cpp | 62 +++++---- .../UnitTestPanel/UnitTestDockWidget.cpp | 25 +--- .../UnitTestPanel/UnitTestTreeView.cpp | 2 +- .../VariablePanel/GraphVariablesTableView.cpp | 6 - .../VariablePanel/GraphVariablesTableView.h | 2 - .../Code/Editor/View/Windows/MainWindow.cpp | 7 +- .../Code/Editor/View/Windows/MainWindow.h | 1 - .../View/Windows/Tools/UpgradeTool/Model.cpp | 2 +- .../Windows/Tools/UpgradeTool/Modifier.cpp | 2 +- .../Windows/Tools/UpgradeTool/Scanner.cpp | 2 +- .../Code/Include/ScriptCanvas/Core/Core.h | 17 +++ .../Code/scriptcanvasgem_editor_files.cmake | 3 - .../Code/scriptcanvasgem_headers.cmake | 3 - 33 files changed, 152 insertions(+), 413 deletions(-) delete mode 100644 Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAsset.cpp delete mode 100644 Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasAsset.h delete mode 100644 Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasAssetBus.h delete mode 100644 Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasAssetTypes.h delete mode 100644 Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasBaseAssetData.cpp delete mode 100644 Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasBaseAssetData.h diff --git a/Gems/ScriptCanvas/Code/Asset/EditorAssetSystemComponent.cpp b/Gems/ScriptCanvas/Code/Asset/EditorAssetSystemComponent.cpp index 87a5dbf796..0a0ddbf8b8 100644 --- a/Gems/ScriptCanvas/Code/Asset/EditorAssetSystemComponent.cpp +++ b/Gems/ScriptCanvas/Code/Asset/EditorAssetSystemComponent.cpp @@ -22,7 +22,7 @@ // Undo this AZ_PUSH_DISABLE_WARNING(4251 4800 4244, "-Wunknown-warning-option") #include -#include + #include #include AZ_POP_DISABLE_WARNING @@ -84,10 +84,7 @@ namespace ScriptCanvasEditor static bool HandlesSource(const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry* entry) { AZStd::string_view targetExtension = entry->GetExtension(); - - ScriptCanvasAsset::Description description; - AZStd::string_view scriptCanvasFileFilter = description.GetFileFilterImpl(); - + AZStd::string_view scriptCanvasFileFilter = SourceDescription::GetFileFilter(); if (AZStd::wildcard_match(scriptCanvasFileFilter.data(), targetExtension.data())) { return true; diff --git a/Gems/ScriptCanvas/Code/Asset/EditorAssetSystemComponent.h b/Gems/ScriptCanvas/Code/Asset/EditorAssetSystemComponent.h index 7937950a05..ba4fdf56fc 100644 --- a/Gems/ScriptCanvas/Code/Asset/EditorAssetSystemComponent.h +++ b/Gems/ScriptCanvas/Code/Asset/EditorAssetSystemComponent.h @@ -17,8 +17,6 @@ namespace ScriptCanvasEditor { - class ScriptCanvasAsset; - class EditorAssetSystemComponent : public AZ::Component , public EditorAssetConversionBus::Handler diff --git a/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilder.cpp b/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilder.cpp index 00df5ad07b..65bd8d141f 100644 --- a/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilder.cpp +++ b/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilder.cpp @@ -9,7 +9,7 @@ #include #include #include -#include + #include #include #include diff --git a/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderComponent.cpp b/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderComponent.cpp index b7e4fb4a79..0705a19ba1 100644 --- a/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderComponent.cpp +++ b/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderComponent.cpp @@ -14,7 +14,7 @@ #include #include #include -#include + #include namespace ScriptCanvasBuilder diff --git a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAsset.cpp b/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAsset.cpp deleted file mode 100644 index 18736db12c..0000000000 --- a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAsset.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* - * 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 - -namespace ScriptCanvas -{ - ScriptCanvasData::ScriptCanvasData(ScriptCanvasData&& other) - : m_scriptCanvasEntity(AZStd::move(other.m_scriptCanvasEntity)) - { - } - - ScriptCanvasData& ScriptCanvasData::operator=(ScriptCanvasData&& other) - { - m_scriptCanvasEntity = AZStd::move(other.m_scriptCanvasEntity); - return *this; - } - - static bool ScriptCanvasDataVersionConverter(AZ::SerializeContext& context, AZ::SerializeContext::DataElementNode& rootDataElementNode) - { - if (rootDataElementNode.GetVersion() == 0) - { - int scriptCanvasEntityIndex = rootDataElementNode.FindElement(AZ_CRC("m_scriptCanvas", 0xfcd20d85)); - if (scriptCanvasEntityIndex == -1) - { - AZ_Error("Script Canvas", false, "Version Converter failed, The Script Canvas Entity is missing"); - return false; - } - - auto scComponentElements = AZ::Utils::FindDescendantElements(context, rootDataElementNode, AZStd::vector{AZ_CRC("m_scriptCanvas", 0xfcd20d85), - AZ_CRC("element", 0x41405e39), AZ_CRC("Components", 0xee48f5fd)}); - if (!scComponentElements.empty()) - { - scComponentElements.front()->AddElementWithData(context, "element", ScriptCanvasEditor::EditorGraphVariableManagerComponent()); - } - } - - if (rootDataElementNode.GetVersion() < 4) - { - auto scEntityElements = AZ::Utils::FindDescendantElements(context, rootDataElementNode, - AZStd::vector{AZ_CRC("m_scriptCanvas", 0xfcd20d85), AZ_CRC("element", 0x41405e39)}); - if (scEntityElements.empty()) - { - AZ_Error("Script Canvas", false, "Version Converter failed, The Script Canvas Entity is missing"); - return false; - } - auto& scEntityDataElement = *scEntityElements.front(); - - AZ::Entity scEntity; - if (!scEntityDataElement.GetData(scEntity)) - { - AZ_Error("Script Canvas", false, "Unable to retrieve entity data from the Data Element"); - return false; - } - - auto graph = AZ::EntityUtils::FindFirstDerivedComponent(&scEntity); - if (!graph) - { - AZ_Error("Script Canvas", false, "Script Canvas graph component could not be found on Script Canvas Entity for ScriptCanvasData version %u", rootDataElementNode.GetVersion()); - return false; - } - auto variableManager = AZ::EntityUtils::FindFirstDerivedComponent(&scEntity); - if (!variableManager) - { - AZ_Error("Script Canvas", false, "Script Canvas variable manager component could not be found on Script Canvas Entity for ScriptCanvasData version %u", rootDataElementNode.GetVersion()); - return false; - } - - variableManager->ConfigureScriptCanvasId(graph->GetScriptCanvasId()); - if (!scEntityDataElement.SetData(context, scEntity)) - { - AZ_Error("Script Canvas", false, "Failed to set converted Script Canvas Entity back on data element node when transitioning from version %u to version 4", rootDataElementNode.GetVersion()); - return false; - } - } - - return true; - } - - - void ScriptCanvasData::Reflect(AZ::ReflectContext* reflectContext) - { - if (auto serializeContext = azrtti_cast(reflectContext)) - { - serializeContext->Class() - ->Version(4, &ScriptCanvasDataVersionConverter) - ->Field("m_scriptCanvas", &ScriptCanvasData::m_scriptCanvasEntity) - ; - } - } - -} - -namespace ScriptCanvasEditor -{ - ScriptCanvas::Graph* ScriptCanvasAsset::GetScriptCanvasGraph() const - { - return AZ::EntityUtils::FindFirstDerivedComponent(m_data->m_scriptCanvasEntity.get()); - } - - ScriptCanvas::ScriptCanvasData& ScriptCanvasAsset::GetScriptCanvasData() - { - AZ_Assert(m_data != nullptr, "ScriptCanvasData not initialized, it must be created on construction"); - return *m_data; - } - - const ScriptCanvas::ScriptCanvasData& ScriptCanvasAsset::GetScriptCanvasData() const - { - AZ_Assert(m_data != nullptr, "ScriptCanvasData not initialized, it must be created on construction"); - return *m_data; - } -} diff --git a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetHelpers.cpp b/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetHelpers.cpp index 884fa2d5c9..07f7ac1e2f 100644 --- a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetHelpers.cpp +++ b/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetHelpers.cpp @@ -8,7 +8,7 @@ #include -#include + #include namespace ScriptCanvasEditor diff --git a/Gems/ScriptCanvas/Code/Editor/Components/EditorScriptCanvasComponent.cpp b/Gems/ScriptCanvas/Code/Editor/Components/EditorScriptCanvasComponent.cpp index 6419525726..c96ba4b0b3 100644 --- a/Gems/ScriptCanvas/Code/Editor/Components/EditorScriptCanvasComponent.cpp +++ b/Gems/ScriptCanvas/Code/Editor/Components/EditorScriptCanvasComponent.cpp @@ -23,7 +23,7 @@ #include #include #include -#include + #include #include #include diff --git a/Gems/ScriptCanvas/Code/Editor/Framework/ScriptCanvasGraphUtilities.inl b/Gems/ScriptCanvas/Code/Editor/Framework/ScriptCanvasGraphUtilities.inl index 83e4e2908c..8571c03638 100644 --- a/Gems/ScriptCanvas/Code/Editor/Framework/ScriptCanvasGraphUtilities.inl +++ b/Gems/ScriptCanvas/Code/Editor/Framework/ScriptCanvasGraphUtilities.inl @@ -16,7 +16,7 @@ #include #include #include -#include + #include #include #include diff --git a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasAsset.h b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasAsset.h deleted file mode 100644 index 0fb0f567e8..0000000000 --- a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasAsset.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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 - * - */ - -#pragma once - -#include -#include -#include -#include - -#include - -namespace AZ -{ - class Entity; -} - -namespace ScriptCanvas -{ - class Graph; -} - -namespace ScriptCanvasEditor -{ - class Graph; - class ScriptCanvasAsset; - - class ScriptCanvasAssetDescription : public ScriptCanvas::AssetDescription - { - public: - - AZ_TYPE_INFO(ScriptCanvasAssetDescription, "{3678E33E-521B-4CAC-9DC1-42566AC71249}"); - - ScriptCanvasAssetDescription() - : ScriptCanvas::AssetDescription( - azrtti_typeid(), - "Script Canvas", - "Script Canvas Graph Asset", - "@projectroot@/scriptcanvas", - ".scriptcanvas", - "Script Canvas", - "Untitled-%i", - "Script Canvas Files (*.scriptcanvas)", - "Script Canvas", - "Script Canvas", - "Icons/ScriptCanvas/Viewport/ScriptCanvas.png", - AZ::Color(0.321f, 0.302f, 0.164f, 1.0f), - true - ) - {} - }; - - class ScriptCanvasAsset - : public ScriptCanvas::ScriptCanvasAssetBase - { - - public: - AZ_RTTI(ScriptCanvasAsset, "{FA10C3DA-0717-4B72-8944-CD67D13DFA2B}", ScriptCanvas::ScriptCanvasAssetBase); - AZ_CLASS_ALLOCATOR(ScriptCanvasAsset, AZ::SystemAllocator, 0); - - ScriptCanvasAsset(const AZ::Data::AssetId& assetId = AZ::Data::AssetId(AZ::Uuid::CreateRandom()), - AZ::Data::AssetData::AssetStatus status = AZ::Data::AssetData::AssetStatus::NotLoaded) - : ScriptCanvas::ScriptCanvasAssetBase(assetId, status) - { - m_data = aznew ScriptCanvas::ScriptCanvasData(); - } - ~ScriptCanvasAsset() override - { - } - - ScriptCanvas::AssetDescription GetAssetDescription() const override - { - return ScriptCanvasAssetDescription(); - } - - ScriptCanvas::Graph* GetScriptCanvasGraph() const; - using Description = ScriptCanvasAssetDescription; - - ScriptCanvas::ScriptCanvasData& GetScriptCanvasData() override; - const ScriptCanvas::ScriptCanvasData& GetScriptCanvasData() const override; - - }; -} diff --git a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasAssetBus.h b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasAssetBus.h deleted file mode 100644 index 4c9f714b61..0000000000 --- a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasAssetBus.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 - * - */ - -#pragma once - -namespace ScriptCanvas -{ - - class ScriptCanvasAssetBusRequests : public AZ::EBusTraits - { - public: - - using BusIdType = AZ::Data::AssetId; - using MutexType = AZStd::recursive_mutex; - - static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single; - static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById; - - virtual void SetAsNewAsset() = 0; - - }; - - using ScriptCanvasAssetBusRequestBus = AZ::EBus; - - -} diff --git a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasAssetTypes.h b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasAssetTypes.h deleted file mode 100644 index 75cf42a894..0000000000 --- a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasAssetTypes.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * 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 - * - */ - -#pragma once - -namespace ScriptCanvasEditor -{ - -} diff --git a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasBaseAssetData.cpp b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasBaseAssetData.cpp deleted file mode 100644 index efb20e3518..0000000000 --- a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasBaseAssetData.cpp +++ /dev/null @@ -1,10 +0,0 @@ -/* - * 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 - diff --git a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasBaseAssetData.h b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasBaseAssetData.h deleted file mode 100644 index 7597da9081..0000000000 --- a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasBaseAssetData.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * 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 - * - */ - -#pragma once - -#include -#include - -namespace ScriptCanvas -{ - -} diff --git a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasFileHandling.h b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasFileHandling.h index bd3d2b9f0a..2260418fe8 100644 --- a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasFileHandling.h +++ b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasFileHandling.h @@ -11,7 +11,7 @@ #include #include #include -#include + namespace AZ { diff --git a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorDeprecationData.h b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorDeprecationData.h index a8e54f034e..96b922ddb3 100644 --- a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorDeprecationData.h +++ b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorDeprecationData.h @@ -19,6 +19,39 @@ namespace ScriptCanvasEditor { namespace Deprecated { + /* source file description + ScriptCanvasAssetDescription() + : ScriptCanvas::AssetDescription( + "{FA10C3DA-0717-4B72-8944-CD67D13DFA2B}", // type + "Script Canvas", // name + "Script Canvas Graph Asset", // description + "@projectroot@/scriptcanvas", // suggested save path + ".scriptcanvas", // fileExtention + "Script Canvas", // group + "Untitled-%i", // asset name pattern + "Script Canvas Files (*.scriptcanvas)", // file filter + "Script Canvas", // asset type display name + "Script Canvas", // entity name + "Icons/ScriptCanvas/Viewport/ScriptCanvas.png", // icon path + AZ::Color(0.321f, 0.302f, 0.164f, 1.0f), // display color + true // is editable type + ) + {} + + AssetDescription( AZ::Data::AssetType assetType, + const char* name, + const char* description, + const char* suggestedSavePath, + const char* fileExtension, + const char* group, + const char* assetNamePattern, + const char* fileFilter, + const char* assetTypeDisplayName, + const char* entityName, + const char* iconPath, + AZ::Color displayColor, + bool isEditableType) + */ class ScriptCanvasAssetHolder { public: @@ -30,5 +63,15 @@ namespace ScriptCanvasEditor AZ::Data::Asset m_scriptCanvasAsset; }; + + class ScriptCanvasAsset + { + public: + AZ_TYPE_INFO(ScriptCanvasAsset, "{3E80CEE3-2932-4DC1-AADF-398FDDC6DEFE}"); + AZ_CLASS_ALLOCATOR(ScriptCanvasAsset, AZ::SystemAllocator, 0); + + ScriptCanvasAsset() = default; + static void Reflect(AZ::ReflectContext * context); + }; } } diff --git a/Gems/ScriptCanvas/Code/Editor/Settings.cpp b/Gems/ScriptCanvas/Code/Editor/Settings.cpp index 84744f77e3..ac40324dff 100644 --- a/Gems/ScriptCanvas/Code/Editor/Settings.cpp +++ b/Gems/ScriptCanvas/Code/Editor/Settings.cpp @@ -13,7 +13,7 @@ #include "Settings.h" -#include + #include #include diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/LoggingPanel/PivotTree/GraphPivotTree/GraphPivotTree.cpp b/Gems/ScriptCanvas/Code/Editor/View/Widgets/LoggingPanel/PivotTree/GraphPivotTree/GraphPivotTree.cpp index a6f0a3743e..9b591466da 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/LoggingPanel/PivotTree/GraphPivotTree/GraphPivotTree.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/LoggingPanel/PivotTree/GraphPivotTree/GraphPivotTree.cpp @@ -9,11 +9,9 @@ #include #include #include - -#include - -#include #include +#include +#include namespace ScriptCanvasEditor { @@ -355,7 +353,7 @@ namespace ScriptCanvasEditor m_assetModel = new AzToolsFramework::AssetBrowser::AssetBrowserFilterModel(); AzToolsFramework::AssetBrowser::AssetGroupFilter* assetFilter = new AzToolsFramework::AssetBrowser::AssetGroupFilter(); - assetFilter->SetAssetGroup(ScriptCanvasEditor::ScriptCanvasAsset::Description::GetGroup(azrtti_typeid())); + assetFilter->SetAssetGroup(ScriptCanvasEditor::SourceDescription::GetGroup()); assetFilter->SetFilterPropagation(AzToolsFramework::AssetBrowser::AssetBrowserEntryFilter::PropagateDirection::Down); @@ -530,7 +528,7 @@ namespace ScriptCanvasEditor { const AzToolsFramework::AssetBrowser::ProductAssetBrowserEntry* productEntry = azrtti_cast(entry); - if (productEntry->GetAssetType() == azrtti_typeid()) + if (productEntry->GetAssetType() == azrtti_typeid()) { auto mapIter = m_graphTreeItemMapping.find(productEntry->GetAssetId()); @@ -556,7 +554,7 @@ namespace ScriptCanvasEditor { const AzToolsFramework::AssetBrowser::ProductAssetBrowserEntry* productEntry = static_cast(entry); - if (productEntry->GetAssetType() == azrtti_typeid()) + if (productEntry->GetAssetType() == azrtti_typeid()) { OnEntityGraphRegistered(AZ::NamedEntityId(), ScriptCanvas::GraphIdentifier(productEntry->GetAssetId(), k_dynamicallySpawnedControllerId)); } diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/ScriptCanvasNodePaletteDockWidget.cpp b/Gems/ScriptCanvas/Code/Editor/View/Widgets/ScriptCanvasNodePaletteDockWidget.cpp index 1258842b75..25f38afbae 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/ScriptCanvasNodePaletteDockWidget.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/ScriptCanvasNodePaletteDockWidget.cpp @@ -38,6 +38,7 @@ #include +#include #include #include #include @@ -461,35 +462,33 @@ namespace ScriptCanvasEditor return; } - // #sc_editor_asset_redux THIS WHOLE THING NEEDS TO BE REDONE TO MAKE SURE THAT USER FUNCTIONS SHOW UP IN THE - // NODE PALETTE -// -// AZStd::string rootPath, absolutePath; -// AZ::Data::AssetInfo assetInfo = AssetHelpers::GetAssetInfo(assetId, rootPath); -// AzFramework::StringFunc::Path::Join(rootPath.c_str(), assetInfo.m_relativePath.c_str(), absolutePath); -// -// AZStd::string normPath = absolutePath; -// AzFramework::StringFunc::Path::Normalize(normPath); -// -// AZStd::string watchFolder; -// bool sourceInfoFound{}; -// AzToolsFramework::AssetSystemRequestBus::BroadcastResult(sourceInfoFound, &AzToolsFramework::AssetSystemRequestBus::Events::GetSourceInfoBySourcePath, normPath.c_str(), assetInfo, watchFolder); -// -// if (!sourceInfoFound) -// { -// return; -// } -// -// CreateFunctionPaletteItem(asset, assetInfo); -// -// treePaletteIter = m_globalFunctionTreeItems.find(asset->GetId()); -// -// if (treePaletteIter != m_globalFunctionTreeItems.end()) -// { -// treePaletteIter->second->ClearError(); -// } -// -// m_monitoredAssets.emplace(asset->GetId(), asset); + + AZStd::string rootPath, absolutePath; + AZ::Data::AssetInfo assetInfo = AssetHelpers::GetAssetInfo(assetId, rootPath); + AzFramework::StringFunc::Path::Join(rootPath.c_str(), assetInfo.m_relativePath.c_str(), absolutePath); + + AZStd::string normPath = absolutePath; + AzFramework::StringFunc::Path::Normalize(normPath); + + AZStd::string watchFolder; + bool sourceInfoFound{}; + AzToolsFramework::AssetSystemRequestBus::BroadcastResult(sourceInfoFound, &AzToolsFramework::AssetSystemRequestBus::Events::GetSourceInfoBySourcePath, normPath.c_str(), assetInfo, watchFolder); + + if (!sourceInfoFound) + { + return; + } + + CreateFunctionPaletteItem(asset, assetInfo); + + treePaletteIter = m_globalFunctionTreeItems.find(asset->GetId()); + + if (treePaletteIter != m_globalFunctionTreeItems.end()) + { + treePaletteIter->second->ClearError(); + } + + m_monitoredAssets.emplace(asset->GetId(), asset); } else { diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/NodeUsageTreeItem.cpp b/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/NodeUsageTreeItem.cpp index b10a7fc314..2770202233 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/NodeUsageTreeItem.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/NodeUsageTreeItem.cpp @@ -13,7 +13,7 @@ #include #include -#include + #include namespace ScriptCanvasEditor @@ -135,8 +135,6 @@ namespace ScriptCanvasEditor void ScriptCanvasAssetNodeUsageTreeItem::SetAssetId(const AZ::Data::AssetId& assetId, AZ::Data::AssetType assetType) { - // If we are setting up a new assetId, we wantt o register for the bus. - // Otherwise we just want to reload the asset to scrape some data from it. if (m_assetId != assetId) { if (AZ::Data::AssetBus::Handler::BusIsConnected()) @@ -150,10 +148,6 @@ namespace ScriptCanvasEditor } m_assetType = assetType; - - // #sc-editor-asset-redux fix up - // auto onAssetReady = [](ScriptCanvasMemoryAsset&) {}; - // AssetTrackerRequestBus::Broadcast(&AssetTrackerRequests::Load, m_assetId, m_assetType, onAssetReady); } const AZ::Data::AssetId& ScriptCanvasAssetNodeUsageTreeItem::GetAssetId() const diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/NodeUsageTreeItem.h b/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/NodeUsageTreeItem.h index 69eb46d423..3e2c0b637b 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/NodeUsageTreeItem.h +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/NodeUsageTreeItem.h @@ -15,7 +15,7 @@ #include #include -#include + #include namespace ScriptCanvasEditor diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/ScriptCanvasStatisticsDialog.cpp b/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/ScriptCanvasStatisticsDialog.cpp index 4a0905c17c..62f0d7ddc7 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/ScriptCanvasStatisticsDialog.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/ScriptCanvasStatisticsDialog.cpp @@ -15,7 +15,7 @@ #include -#include + #include namespace @@ -176,14 +176,15 @@ namespace ScriptCanvasEditor { } - void StatisticsDialog::OnCatalogAssetChanged(const AZ::Data::AssetId& assetId) + void StatisticsDialog::OnCatalogAssetChanged(const AZ::Data::AssetId& /*assetId*/) { - AZ::Data::AssetInfo assetInfo; - AZ::Data::AssetCatalogRequestBus::BroadcastResult(assetInfo, &AZ::Data::AssetCatalogRequestBus::Events::GetAssetInfoById, assetId); - if (assetInfo.m_assetType == azrtti_typeid()) - { - m_scriptCanvasAssetTreeRoot->RegisterAsset(assetId, assetInfo.m_assetType); - } + // #sc_editor_asset_redux cut or update +// AZ::Data::AssetInfo assetInfo; +// AZ::Data::AssetCatalogRequestBus::BroadcastResult(assetInfo, &AZ::Data::AssetCatalogRequestBus::Events::GetAssetInfoById, assetId); +// if (assetInfo.m_assetType == azrtti_typeidRegisterAsset(assetId, assetInfo.m_assetType); +// } } void StatisticsDialog::OnCatalogAssetAdded(const AZ::Data::AssetId& assetId) @@ -191,14 +192,16 @@ namespace ScriptCanvasEditor OnCatalogAssetChanged(assetId); } - void StatisticsDialog::OnCatalogAssetRemoved(const AZ::Data::AssetId& assetId, const AZ::Data::AssetInfo& /*assetInfo*/) + void StatisticsDialog::OnCatalogAssetRemoved(const AZ::Data::AssetId& /*assetId*/, const AZ::Data::AssetInfo& /*assetInfo*/) { - AZ::Data::AssetInfo assetInfo; - AZ::Data::AssetCatalogRequestBus::BroadcastResult(assetInfo, &AZ::Data::AssetCatalogRequestBus::Events::GetAssetInfoById, assetId); - if (assetInfo.m_assetType == azrtti_typeid()) - { - m_scriptCanvasAssetTreeRoot->RemoveAsset(assetId); - } + // #sc_editor_asset_redux cut or update + +// AZ::Data::AssetInfo assetInfo; +// AZ::Data::AssetCatalogRequestBus::BroadcastResult(assetInfo, &AZ::Data::AssetCatalogRequestBus::Events::GetAssetInfoById, assetId); +// if (assetInfo.m_assetType == azrtti_typeid()) +// { +// m_scriptCanvasAssetTreeRoot->RemoveAsset(assetId); +// } } void StatisticsDialog::OnAssetModelRepopulated() @@ -434,20 +437,21 @@ namespace ScriptCanvasEditor void StatisticsDialog::ProcessAsset(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) { - if (entry) - { - if (entry->GetEntryType() == AzToolsFramework::AssetBrowser::AssetBrowserEntry::AssetEntryType::Product) - { - const AzToolsFramework::AssetBrowser::ProductAssetBrowserEntry* productEntry = static_cast(entry); - - if (productEntry->GetAssetType() == azrtti_typeid()) - { - const AZ::Data::AssetId& assetId = productEntry->GetAssetId(); - - m_scriptCanvasAssetTreeRoot->RegisterAsset(assetId, productEntry->GetAssetType()); - } - } - } + // #sc_editor_asset_redux cut or update +// if (entry) +// { +// if (entry->GetEntryType() == AzToolsFramework::AssetBrowser::AssetBrowserEntry::AssetEntryType::Product) +// { +// const AzToolsFramework::AssetBrowser::ProductAssetBrowserEntry* productEntry = static_cast(entry); +// +// if (productEntry->GetAssetType() == azrtti_typeid()) +// { +// const AZ::Data::AssetId& assetId = productEntry->GetAssetId(); +// +// m_scriptCanvasAssetTreeRoot->RegisterAsset(assetId, productEntry->GetAssetType()); +// } +// } +// } } #include diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/UnitTestPanel/UnitTestDockWidget.cpp b/Gems/ScriptCanvas/Code/Editor/View/Widgets/UnitTestPanel/UnitTestDockWidget.cpp index d3661a4ef3..63e41896fc 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/UnitTestPanel/UnitTestDockWidget.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/UnitTestPanel/UnitTestDockWidget.cpp @@ -26,7 +26,7 @@ #include #include #include - +#include #include #include @@ -46,7 +46,7 @@ #include -#include + #include #include #include @@ -522,18 +522,7 @@ namespace ScriptCanvasEditor ScriptCanvasEditor::SourceHandle source(nullptr, scriptUuid, ""); ScriptCanvasEditor::CompleteDescriptionInPlace(source); - - // #sc_editor_asset_redux -// AZ::Data::AssetInfo assetInfo; -// if (AssetHelpers::GetAssetInfo(sourceBrowserEntry->GetFullPath(), assetInfo)) -// { -// auto asset = AZ::Data::AssetManager::Instance().GetAsset(assetInfo.m_assetId, azrtti_typeid(), AZ::Data::AssetLoadBehavior::PreLoad); -// asset.BlockUntilLoadComplete(); -// if (asset.IsReady()) -// { -// RunTestGraph(asset, mode); -// } -// } + RunTestGraph(source, mode); } } } @@ -582,19 +571,19 @@ namespace ScriptCanvasEditor m_testMetrics[interpretedMode].Clear(); } - void UnitTestDockWidget::RunTestGraph(AZ::Data::Asset asset, ScriptCanvas::ExecutionMode mode) + void UnitTestDockWidget::RunTestGraph(SourceHandle asset, ScriptCanvas::ExecutionMode mode) { Reporter reporter; - UnitTestWidgetNotificationBus::Broadcast(&UnitTestWidgetNotifications::OnTestStart, asset.GetId().m_guid); + UnitTestWidgetNotificationBus::Broadcast(&UnitTestWidgetNotifications::OnTestStart, asset); ScriptCanvasExecutionBus::BroadcastResult(reporter, &ScriptCanvasExecutionRequests::RunAssetGraph, asset, mode); UnitTestResult testResult; UnitTestVerificationBus::BroadcastResult(testResult, &UnitTestVerificationRequests::Verify, reporter); - UnitTestWidgetNotificationBus::Broadcast(&UnitTestWidgetNotifications::OnTestResult, asset.GetId().m_guid, testResult); + UnitTestWidgetNotificationBus::Broadcast(&UnitTestWidgetNotifications::OnTestResult, asset, testResult); - m_pendingTests.Add(asset.GetId(), mode); + m_pendingTests.Add(asset, mode); ++m_testMetrics[static_cast(mode)].m_graphsTested; diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/UnitTestPanel/UnitTestTreeView.cpp b/Gems/ScriptCanvas/Code/Editor/View/Widgets/UnitTestPanel/UnitTestTreeView.cpp index 2e9c5d1852..9dbab22bb3 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/UnitTestPanel/UnitTestTreeView.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/UnitTestPanel/UnitTestTreeView.cpp @@ -33,7 +33,7 @@ #include #include -#include + #include #include diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/VariablePanel/GraphVariablesTableView.cpp b/Gems/ScriptCanvas/Code/Editor/View/Widgets/VariablePanel/GraphVariablesTableView.cpp index 1af554dd32..806f43aba1 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/VariablePanel/GraphVariablesTableView.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/VariablePanel/GraphVariablesTableView.cpp @@ -716,7 +716,6 @@ namespace ScriptCanvasEditor void GraphVariablesModel::SetActiveScene(const ScriptCanvas::ScriptCanvasId& scriptCanvasId) { ScriptCanvas::GraphVariableManagerNotificationBus::Handler::BusDisconnect(); - m_assetType = azrtti_typeid(); m_scriptCanvasId = scriptCanvasId; if (m_scriptCanvasId.IsValid()) @@ -919,11 +918,6 @@ namespace ScriptCanvasEditor return -1; } - bool GraphVariablesModel::IsFunction()const - { - return m_assetType == azrtti_typeid(); - } - //////////////////////////////////////////// // GraphVariablesModelSortFilterProxyModel //////////////////////////////////////////// diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/VariablePanel/GraphVariablesTableView.h b/Gems/ScriptCanvas/Code/Editor/View/Widgets/VariablePanel/GraphVariablesTableView.h index 962aadb8c8..f0e45978a0 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/VariablePanel/GraphVariablesTableView.h +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/VariablePanel/GraphVariablesTableView.h @@ -106,8 +106,6 @@ namespace ScriptCanvasEditor void PopulateSceneVariables(); - AZ::Data::AssetType m_assetType; - AZStd::vector m_variableIds; ScriptCanvas::ScriptCanvasId m_scriptCanvasId; }; diff --git a/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.cpp b/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.cpp index c40c126dd1..c0ab11b2fb 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.cpp @@ -96,7 +96,7 @@ #include #include -#include + #include #include @@ -146,7 +146,7 @@ #include #include #include -#include + #include #include @@ -434,7 +434,8 @@ namespace ScriptCanvasEditor m_scriptCanvasAssetModel = new ScriptCanvasAssetBrowserModel(this); AzToolsFramework::AssetBrowser::AssetGroupFilter* scriptCanvasAssetFilter = new AzToolsFramework::AssetBrowser::AssetGroupFilter(); - scriptCanvasAssetFilter->SetAssetGroup(ScriptCanvasAsset::Description::GetGroup(azrtti_typeid())); + // #sc_editor_asset_redux this may not be needed, may not be doing the right thing at all... + scriptCanvasAssetFilter->SetAssetGroup(ScriptCanvasAsset::Description::GetGroup(azrtti_typeid())); scriptCanvasAssetFilter->SetFilterPropagation(AzToolsFramework::AssetBrowser::AssetBrowserEntryFilter::PropagateDirection::Down); m_scriptCanvasAssetModel->setSourceModel(assetBrowserModel); diff --git a/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.h b/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.h index 4ff5cf094b..fbc363e444 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.h +++ b/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.h @@ -432,7 +432,6 @@ namespace ScriptCanvasEditor AZ::Outcome CreateScriptCanvasAsset(AZStd::string_view assetPath, int tabIndex = -1); - //! Removes the assetId -> ScriptCanvasAsset mapping and disconnects from the asset tracker void RemoveScriptCanvasAsset(const ScriptCanvasEditor::SourceHandle& assetId); void OnChangeActiveGraphTab(ScriptCanvasEditor::SourceHandle) override; diff --git a/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/Model.cpp b/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/Model.cpp index 70ff7a92ca..9714390022 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/Model.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/Model.cpp @@ -11,7 +11,7 @@ #include #include #include -#include + namespace ModifierCpp { diff --git a/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/Modifier.cpp b/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/Modifier.cpp index 14b292e489..37439c5703 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/Modifier.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/Modifier.cpp @@ -10,7 +10,7 @@ #include #include #include -#include + #include #include diff --git a/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/Scanner.cpp b/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/Scanner.cpp index 816ded8a7b..9e6340ee31 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/Scanner.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/Scanner.cpp @@ -12,7 +12,7 @@ #include #include #include -#include + #include namespace ScannerCpp diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Core.h b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Core.h index 215041e1fd..01280a4ee5 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Core.h +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Core.h @@ -317,6 +317,23 @@ namespace ScriptCanvasEditor using GraphPtr = Graph*; using GraphPtrConst = const Graph*; + class SourceDescription + { + public: + static inline constexpr const char* GetAssetGroup() { return "ScriptCanvas"; } + inline static constexpr const char* GetType() { return "{FA10C3DA-0717-4B72-8944-CD67D13DFA2B}"; } // type + inline static constexpr const char* GetName() { return "Script Canvas"; } // name + inline static constexpr const char* GetDescription() { return "Script Canvas Graph Asset"; } // description + inline static constexpr const char* GetSuggestedSavePath() { return "@projectroot@/scriptcanvas"; } // suggested save path + inline static constexpr const char* GetFileExtension() { return ".scriptcanvas"; } // fileExtention + inline static constexpr const char* GetGroup() { return "Script Canvas"; } // group + inline static constexpr const char* GetAssetNamePattern() { return "Untitled-%i"; } // asset name pattern + inline static constexpr const char* GetFileFilter() { return "Script Canvas Files (*.scriptcanvas)"; } // file filter + inline static constexpr const char* GetAssetTypeDisplayName() { return "Script Canvas"; } // asset type display name + inline static constexpr const char* GetEntityName() { return "Script Canvas"; } // entity name + inline static constexpr const char* GetIconPath() { return "Icons/ScriptCanvas/Viewport/ScriptCanvas.png"; } // icon pa + }; + class SourceHandle { public: diff --git a/Gems/ScriptCanvas/Code/scriptcanvasgem_editor_files.cmake b/Gems/ScriptCanvas/Code/scriptcanvasgem_editor_files.cmake index 897539db7b..30bedd634b 100644 --- a/Gems/ScriptCanvas/Code/scriptcanvasgem_editor_files.cmake +++ b/Gems/ScriptCanvas/Code/scriptcanvasgem_editor_files.cmake @@ -19,10 +19,7 @@ set(FILES Editor/Assets/ScriptCanvasAssetHelpers.cpp Editor/Include/ScriptCanvas/Assets/ScriptCanvasBaseAssetData.h Editor/Include/ScriptCanvas/Assets/ScriptCanvasBaseAssetData.cpp - Editor/Include/ScriptCanvas/Assets/ScriptCanvasAsset.h - Editor/Assets/ScriptCanvasAsset.cpp Editor/Include/ScriptCanvas/Assets/ScriptCanvasAssetBus.h - Editor/Include/ScriptCanvas/Assets/ScriptCanvasAssetTypes.h Editor/Include/ScriptCanvas/Assets/ScriptCanvasFileHandling.h Editor/Assets/ScriptCanvasFileHandling.cpp Editor/Assets/ScriptCanvasUndoHelper.h diff --git a/Gems/ScriptCanvas/Code/scriptcanvasgem_headers.cmake b/Gems/ScriptCanvas/Code/scriptcanvasgem_headers.cmake index 7f39c2f3d0..ecbcdc6ed6 100644 --- a/Gems/ScriptCanvas/Code/scriptcanvasgem_headers.cmake +++ b/Gems/ScriptCanvas/Code/scriptcanvasgem_headers.cmake @@ -9,15 +9,12 @@ set(FILES Include/ScriptCanvas/SystemComponent.h Include/ScriptCanvas/ScriptCanvasGem.h - Include/ScriptCanvas/Asset/AssetDescription.h Include/ScriptCanvas/Asset/AssetRegistry.h Include/ScriptCanvas/Asset/AssetRegistryBus.h Include/ScriptCanvas/Asset/ExecutionLogAsset.h Include/ScriptCanvas/Asset/ExecutionLogAssetBus.h Include/ScriptCanvas/Asset/RuntimeAsset.h Include/ScriptCanvas/Asset/RuntimeAssetHandler.h - Include/ScriptCanvas/Asset/ScriptCanvasAssetBase.h - Include/ScriptCanvas/Asset/ScriptCanvasAssetData.h Include/ScriptCanvas/Asset/SubgraphInterfaceAssetHandler.h Include/ScriptCanvas/Core/ScriptCanvasBus.h Include/ScriptCanvas/Core/ExecutionNotificationsBus.h From 2271fa3dc693efa4ce5ef6fd5bda7e6e6771f9ab Mon Sep 17 00:00:00 2001 From: carlitosan <82187351+carlitosan@users.noreply.github.com> Date: Tue, 14 Dec 2021 15:09:46 -0800 Subject: [PATCH 42/70] redcode sc asset files bloodbath Signed-off-by: carlitosan <82187351+carlitosan@users.noreply.github.com> --- .../Code/Builder/ScriptCanvasBuilder.cpp | 10 +-- .../Code/Builder/ScriptCanvasBuilder.h | 1 - .../Builder/ScriptCanvasBuilderComponent.cpp | 3 - .../Builder/ScriptCanvasBuilderWorker.cpp | 11 ++- .../Code/Builder/ScriptCanvasBuilderWorker.h | 3 - .../EditorScriptCanvasComponent.cpp | 2 +- .../Framework/ScriptCanvasTraceUtilities.h | 2 - .../ScriptCanvas/Bus/EditorScriptCanvasBus.h | 1 - .../Components/EditorDeprecationData.h | 45 ++-------- .../Components/EditorScriptCanvasComponent.h | 17 +--- .../Code/Editor/View/Windows/MainWindow.cpp | 28 +++--- .../Asset/ScriptCanvasAssetBase.h | 89 ------------------- .../Code/scriptcanvasgem_editor_files.cmake | 3 - 13 files changed, 36 insertions(+), 179 deletions(-) delete mode 100644 Gems/ScriptCanvas/Code/Include/ScriptCanvas/Asset/ScriptCanvasAssetBase.h diff --git a/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilder.cpp b/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilder.cpp index 65bd8d141f..d62ebb9c3a 100644 --- a/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilder.cpp +++ b/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilder.cpp @@ -6,15 +6,15 @@ * */ +#include #include #include #include - +#include +#include +#include #include #include -#include -#include -#include namespace BuildVariableOverridesCpp { @@ -41,7 +41,7 @@ namespace BuildVariableOverridesCpp } auto& sourceElement = rootElement.GetSubElement(sourceIndex); - AZ::Data::Asset asset; + AZ::Data::Asset asset; if (!sourceElement.GetData(asset)) { AZ_Error("ScriptCanvas", false, "BuildVariableOverrides coversion failed: could not retrieve 'source' data"); diff --git a/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilder.h b/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilder.h index 5cffa823dc..6e8e176145 100644 --- a/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilder.h +++ b/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilder.h @@ -15,7 +15,6 @@ namespace ScriptCanvasEditor { - class ScriptCanvasAsset; class EditorAssetTree; } diff --git a/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderComponent.cpp b/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderComponent.cpp index 0705a19ba1..4c80b7ed83 100644 --- a/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderComponent.cpp +++ b/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderComponent.cpp @@ -96,8 +96,6 @@ namespace ScriptCanvasBuilder builderDescriptor.m_productsToKeepOnFailure[s_scriptCanvasProcessJobKey] = { AZ_CRC("SubgraphInterface", 0xdfe6dc72) }; m_scriptCanvasBuilder.BusConnect(builderDescriptor.m_busId); AssetBuilderSDK::AssetBuilderBus::Broadcast(&AssetBuilderSDK::AssetBuilderBus::Handler::RegisterBuilderInformation, builderDescriptor); - - AzToolsFramework::ToolsAssetSystemBus::Broadcast(&AzToolsFramework::ToolsAssetSystemRequests::RegisterSourceAssetType, azrtti_typeid(), ScriptCanvasEditor::ScriptCanvasAsset::Description::GetFileFilter()); } m_sharedHandlers = HandleAssetTypes(); @@ -109,7 +107,6 @@ namespace ScriptCanvasBuilder { // Finish all queued work AZ::Data::AssetBus::ExecuteQueuedEvents(); - AzToolsFramework::ToolsAssetSystemBus::Broadcast(&AzToolsFramework::ToolsAssetSystemRequests::UnregisterSourceAssetType, azrtti_typeid()); m_scriptCanvasBuilder.BusDisconnect(); m_sharedHandlers.DeleteOwnedHandlers(); } diff --git a/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderWorker.cpp b/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderWorker.cpp index 24f9836236..62d5febe91 100644 --- a/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderWorker.cpp +++ b/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderWorker.cpp @@ -44,10 +44,8 @@ namespace ScriptCanvasBuilder AzFramework::StringFunc::Path::ConstructFull(request.m_watchFolder.data(), request.m_sourceFile.data(), fullPath, false); AzFramework::StringFunc::Path::Normalize(fullPath); - AZ::Data::Asset asset; const ScriptCanvasEditor::Graph* sourceGraph = nullptr; const ScriptCanvas::GraphData* graphData = nullptr; - ScriptCanvasEditor::SourceHandle sourceHandle; auto sourceOutcome = ScriptCanvasEditor::LoadFromFile(fullPath); @@ -57,7 +55,14 @@ namespace ScriptCanvasBuilder sourceGraph = sourceHandle.Get(); graphData = sourceGraph->GetGraphDataConst(); } - + else + { + AZ_TracePrintf(s_scriptCanvasBuilder, "Failed to load the file: %s", fullPath.c_str()); + response.m_result = AssetBuilderSDK::CreateJobsResultCode::Failed; + } + + // in terms of job creation, assert on anything but smooth sailing from this point + AZ_Assert(sourceGraph, "Graph component is missing from entity."); AZ_Assert(graphData, "GraphData is missing from entity"); diff --git a/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderWorker.h b/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderWorker.h index 817fe5d294..d0196d5f5c 100644 --- a/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderWorker.h +++ b/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderWorker.h @@ -36,7 +36,6 @@ namespace ScriptCanvas namespace ScriptCanvasEditor { class Graph; - class ScriptCanvasAsset; class SourceHandle; } @@ -132,8 +131,6 @@ namespace ScriptCanvasBuilder int GetBuilderVersion(); - AZ::Outcome, AZStd::string> LoadEditorAsset(AZStd::string_view graphPath, AZ::Data::AssetId assetId, AZ::Data::AssetFilterCB assetFilterCB = {}); - AZ::Outcome ParseGraph(AZ::Entity& buildEntity, AZStd::string_view graphPath); AZ::Outcome ProcessTranslationJob(ProcessTranslationJobInput& input); diff --git a/Gems/ScriptCanvas/Code/Editor/Components/EditorScriptCanvasComponent.cpp b/Gems/ScriptCanvas/Code/Editor/Components/EditorScriptCanvasComponent.cpp index c96ba4b0b3..be5d467f44 100644 --- a/Gems/ScriptCanvas/Code/Editor/Components/EditorScriptCanvasComponent.cpp +++ b/Gems/ScriptCanvas/Code/Editor/Components/EditorScriptCanvasComponent.cpp @@ -59,7 +59,7 @@ namespace ScriptCanvasEditor } auto assetElement = rootElement.GetSubElement(assetElementIndex); - AZ::Data::Asset scriptCanvasAsset; + AZ::Data::Asset scriptCanvasAsset; if (!assetElement.GetData(scriptCanvasAsset)) { AZ_Error("Script Canvas", false, "Unable to find Script Canvas Asset on a Version %u Editor ScriptCanvas Component", rootElement.GetVersion()); diff --git a/Gems/ScriptCanvas/Code/Editor/Framework/ScriptCanvasTraceUtilities.h b/Gems/ScriptCanvas/Code/Editor/Framework/ScriptCanvasTraceUtilities.h index 458852132d..4b10c71ba3 100644 --- a/Gems/ScriptCanvas/Code/Editor/Framework/ScriptCanvasTraceUtilities.h +++ b/Gems/ScriptCanvas/Code/Editor/Framework/ScriptCanvasTraceUtilities.h @@ -42,8 +42,6 @@ namespace ScriptCanvas namespace ScriptCanvasEditor { - class ScriptCanvasAsset; - struct LoadTestGraphResult { AZStd::unique_ptr m_entity; diff --git a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Bus/EditorScriptCanvasBus.h b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Bus/EditorScriptCanvasBus.h index b1fd291a1b..7f2d3ac162 100644 --- a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Bus/EditorScriptCanvasBus.h +++ b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Bus/EditorScriptCanvasBus.h @@ -20,7 +20,6 @@ #include #include -#include #include #include #include diff --git a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorDeprecationData.h b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorDeprecationData.h index 96b922ddb3..0b55e1cf23 100644 --- a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorDeprecationData.h +++ b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorDeprecationData.h @@ -11,67 +11,34 @@ #include #include #include - -class ScriptCanvasAsset; - +#include namespace ScriptCanvasEditor { namespace Deprecated { - /* source file description - ScriptCanvasAssetDescription() - : ScriptCanvas::AssetDescription( - "{FA10C3DA-0717-4B72-8944-CD67D13DFA2B}", // type - "Script Canvas", // name - "Script Canvas Graph Asset", // description - "@projectroot@/scriptcanvas", // suggested save path - ".scriptcanvas", // fileExtention - "Script Canvas", // group - "Untitled-%i", // asset name pattern - "Script Canvas Files (*.scriptcanvas)", // file filter - "Script Canvas", // asset type display name - "Script Canvas", // entity name - "Icons/ScriptCanvas/Viewport/ScriptCanvas.png", // icon path - AZ::Color(0.321f, 0.302f, 0.164f, 1.0f), // display color - true // is editable type - ) - {} - - AssetDescription( AZ::Data::AssetType assetType, - const char* name, - const char* description, - const char* suggestedSavePath, - const char* fileExtension, - const char* group, - const char* assetNamePattern, - const char* fileFilter, - const char* assetTypeDisplayName, - const char* entityName, - const char* iconPath, - AZ::Color displayColor, - bool isEditableType) - */ class ScriptCanvasAssetHolder { public: AZ_TYPE_INFO(ScriptCanvasAssetHolder, "{3E80CEE3-2932-4DC1-AADF-398FDDC6DEFE}"); AZ_CLASS_ALLOCATOR(ScriptCanvasAssetHolder, AZ::SystemAllocator, 0); - ScriptCanvasAssetHolder() = default; static void Reflect(AZ::ReflectContext* context); AZ::Data::Asset m_scriptCanvasAsset; + + ScriptCanvasAssetHolder() = default; }; + // only is used as a pass-through to loading a guid / hint during versioning class ScriptCanvasAsset + : public AZ::Data::AssetData { public: - AZ_TYPE_INFO(ScriptCanvasAsset, "{3E80CEE3-2932-4DC1-AADF-398FDDC6DEFE}"); + AZ_TYPE_INFO(ScriptCanvasAsset, "{FA10C3DA-0717-4B72-8944-CD67D13DFA2B}"); AZ_CLASS_ALLOCATOR(ScriptCanvasAsset, AZ::SystemAllocator, 0); ScriptCanvasAsset() = default; - static void Reflect(AZ::ReflectContext * context); }; } } diff --git a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorScriptCanvasComponent.h b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorScriptCanvasComponent.h index da1b0a22a6..ca381445ea 100644 --- a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorScriptCanvasComponent.h +++ b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorScriptCanvasComponent.h @@ -21,14 +21,8 @@ namespace ScriptCanvasEditor { /*! EditorScriptCanvasComponent - The user facing Editor Component for interfacing with ScriptCanvas - It connects to the AssetCatalogEventBus in order to remove the ScriptCanvasAssetHolder asset reference - when the asset is removed from the file system. The reason the ScriptCanvasAssetHolder holder does not - remove the asset reference itself is because the ScriptCanvasEditor MainWindow has a ScriptCanvasAssetHolder - which it uses to maintain the asset data in memory. Therefore removing an open ScriptCanvasAsset from the file system - will remove the reference from the EditorScriptCanvasComponent, but not the reference from the MainWindow allowing the - ScriptCanvas graph to still be modified while open - Finally per graph instance variables values are stored on the EditorScriptCanvasComponent and injected into the runtime ScriptCanvas component in BuildGameEntity + The user facing Editor Component for interfacing with ScriptCanvas. + Per graph instance variables values are stored here and injected into the runtime ScriptCanvas component in BuildGameEntity. */ class EditorScriptCanvasComponent : public AzToolsFramework::Components::EditorComponentBase @@ -88,13 +82,6 @@ namespace ScriptCanvasEditor AZ::Data::AssetId GetAssetId() const override; //===================================================================== - - - - //===================================================================== - // EditorEntityContextNotificationBus - - protected: enum class SourceChangeDescription : AZ::u8 { diff --git a/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.cpp b/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.cpp index c0ab11b2fb..3b110aba7b 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.cpp @@ -434,8 +434,9 @@ namespace ScriptCanvasEditor m_scriptCanvasAssetModel = new ScriptCanvasAssetBrowserModel(this); AzToolsFramework::AssetBrowser::AssetGroupFilter* scriptCanvasAssetFilter = new AzToolsFramework::AssetBrowser::AssetGroupFilter(); - // #sc_editor_asset_redux this may not be needed, may not be doing the right thing at all... - scriptCanvasAssetFilter->SetAssetGroup(ScriptCanvasAsset::Description::GetGroup(azrtti_typeid())); + // #sc_editor_asset_redux this may not be needed, may not be doing the right thing at all, verify that searching through + // the subgraph interface assets is the correct thing to do + scriptCanvasAssetFilter->SetAssetGroup(ScriptCanvas::SubgraphInterfaceAssetDescription().GetGroupImpl()); scriptCanvasAssetFilter->SetFilterPropagation(AzToolsFramework::AssetBrowser::AssetBrowserEntryFilter::PropagateDirection::Down); m_scriptCanvasAssetModel->setSourceModel(assetBrowserModel); @@ -1483,17 +1484,17 @@ namespace ScriptCanvasEditor for (;;) { - ScriptCanvasAssetDescription description; - AZStd::string newAssetName = AZStd::string::format(description.GetAssetNamePatternImpl(), ++scriptCanvasEditorDefaultNewNameCount); + AZStd::string newAssetName = AZStd::string::format(SourceDescription::GetAssetNamePattern() + , ++scriptCanvasEditorDefaultNewNameCount); AZStd::array assetRootArray; - if (!AZ::IO::FileIOBase::GetInstance()->ResolvePath(description.GetSuggestedSavePathImpl() + if (!AZ::IO::FileIOBase::GetInstance()->ResolvePath(SourceDescription::GetSuggestedSavePath() , assetRootArray.data(), assetRootArray.size())) { AZ_ErrorOnce("Script Canvas", false, "Unable to resolve @projectroot@ path"); } - AzFramework::StringFunc::Path::Join(assetRootArray.data(), (newAssetName + description.GetExtensionImpl()).data(), assetPath); + AzFramework::StringFunc::Path::Join(assetRootArray.data(), (newAssetName + SourceDescription::GetFileExtension()).data(), assetPath); AZ::Data::AssetInfo assetInfo; if (!AssetHelpers::GetAssetInfo(assetPath, assetInfo)) @@ -1621,7 +1622,6 @@ namespace ScriptCanvasEditor } PrepareAssetForSave(inMemoryAssetId); - ScriptCanvasAssetDescription assetDescription; AZStd::string suggestedFilename; AZStd::string suggestedFileFilter; @@ -1630,16 +1630,16 @@ namespace ScriptCanvasEditor if (save == Save::InPlace) { isValidFileName = true; - suggestedFileFilter = ScriptCanvasAssetDescription().GetExtensionImpl(); + suggestedFileFilter = SourceDescription::GetFileExtension(); suggestedFilename = inMemoryAssetId.Path().c_str(); } else { - suggestedFileFilter = ScriptCanvasAssetDescription().GetExtensionImpl(); + suggestedFileFilter = SourceDescription::GetFileExtension(); if (inMemoryAssetId.Path().empty()) { - suggestedFilename = ScriptCanvasAssetDescription().GetSuggestedSavePathImpl(); + suggestedFilename = SourceDescription::GetSuggestedSavePath(); } else { @@ -1661,9 +1661,9 @@ namespace ScriptCanvasEditor { AZStd::string filePath = selectedFile.toUtf8().data(); - if (!AZ::StringFunc::EndsWith(filePath, assetDescription.GetExtensionImpl(), false)) + if (!AZ::StringFunc::EndsWith(filePath, SourceDescription::GetFileExtension(), false)) { - filePath += assetDescription.GetExtensionImpl(); + filePath += SourceDescription::GetFileExtension(); } AZStd::string fileName; @@ -1695,9 +1695,9 @@ namespace ScriptCanvasEditor AZStd::string internalStringFile = selectedFile.toUtf8().data(); - if (!AZ::StringFunc::EndsWith(internalStringFile, assetDescription.GetExtensionImpl(), false)) + if (!AZ::StringFunc::EndsWith(internalStringFile, SourceDescription::GetFileExtension(), false)) { - internalStringFile += assetDescription.GetExtensionImpl(); + internalStringFile += SourceDescription::GetFileExtension(); } if (!AssetHelpers::IsValidSourceFile(internalStringFile, GetActiveScriptCanvasId())) diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Asset/ScriptCanvasAssetBase.h b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Asset/ScriptCanvasAssetBase.h deleted file mode 100644 index 1dc0b38e01..0000000000 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Asset/ScriptCanvasAssetBase.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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 - * - */ - -#pragma once - -#include -#include -#include -#include -#include - -namespace ScriptCanvas -{ - class ScriptCanvasAssetBase - : public AZ::Data::AssetData - , public AZStd::enable_shared_from_this - , ScriptCanvas::ScriptCanvasAssetBusRequestBus::Handler - { - - public: - AZ_RTTI(ScriptCanvasAssetBase, "{D07DBDE4-A169-4650-871B-FC75AFEEB03E}", AZ::Data::AssetData); - AZ_CLASS_ALLOCATOR(ScriptCanvasAssetBase, AZ::SystemAllocator, 0); - - ScriptCanvasAssetBase(const AZ::Data::AssetId& assetId = AZ::Data::AssetId(AZ::Uuid::CreateRandom()), - AZ::Data::AssetData::AssetStatus status = AZ::Data::AssetData::AssetStatus::NotLoaded) - : AZ::Data::AssetData(assetId, status) - { - ScriptCanvas::ScriptCanvasAssetBusRequestBus::Handler::BusConnect(GetId()); - } - - virtual ~ScriptCanvasAssetBase() - { - delete m_data; - ScriptCanvas::ScriptCanvasAssetBusRequestBus::Handler::BusDisconnect(); - } - - template - DataType* GetScriptCanvasDataAs() - { - return azrtti_cast(m_data); - } - - template - const DataType* GetScriptCanvasDataAs() const - { - return azrtti_cast(m_data); - } - - virtual ScriptCanvasData& GetScriptCanvasData() - { - return *m_data; - } - - virtual const ScriptCanvasData& GetScriptCanvasData() const - { - return *m_data; - } - - AZ::Entity* GetScriptCanvasEntity() const - { - return m_data->m_scriptCanvasEntity.get(); - } - - virtual void SetScriptCanvasEntity(AZ::Entity* scriptCanvasEntity) - { - if (m_data->m_scriptCanvasEntity.get() != scriptCanvasEntity) - { - m_data->m_scriptCanvasEntity.reset(scriptCanvasEntity); - } - } - - virtual ScriptCanvas::AssetDescription GetAssetDescription() const = 0; - - protected: - - ScriptCanvasData* m_data; - - void SetAsNewAsset() override - { - m_status = AZ::Data::AssetData::AssetStatus::Ready; - } - - }; -} diff --git a/Gems/ScriptCanvas/Code/scriptcanvasgem_editor_files.cmake b/Gems/ScriptCanvas/Code/scriptcanvasgem_editor_files.cmake index 30bedd634b..b2f98226b4 100644 --- a/Gems/ScriptCanvas/Code/scriptcanvasgem_editor_files.cmake +++ b/Gems/ScriptCanvas/Code/scriptcanvasgem_editor_files.cmake @@ -17,9 +17,6 @@ set(FILES Editor/QtMetaTypes.h Editor/Assets/ScriptCanvasAssetHelpers.h Editor/Assets/ScriptCanvasAssetHelpers.cpp - Editor/Include/ScriptCanvas/Assets/ScriptCanvasBaseAssetData.h - Editor/Include/ScriptCanvas/Assets/ScriptCanvasBaseAssetData.cpp - Editor/Include/ScriptCanvas/Assets/ScriptCanvasAssetBus.h Editor/Include/ScriptCanvas/Assets/ScriptCanvasFileHandling.h Editor/Assets/ScriptCanvasFileHandling.cpp Editor/Assets/ScriptCanvasUndoHelper.h From 81bb7aab80024090eab00c1af9a645d8634c0725 Mon Sep 17 00:00:00 2001 From: carlitosan <82187351+carlitosan@users.noreply.github.com> Date: Tue, 14 Dec 2021 17:32:22 -0800 Subject: [PATCH 43/70] the bloodbath compiles Signed-off-by: carlitosan <82187351+carlitosan@users.noreply.github.com> --- .../Code/Asset/EditorAssetSystemComponent.cpp | 2 +- .../Assets/ScriptCanvasAssetHelpers.cpp | 6 +- .../Code/Editor/Components/EditorGraph.cpp | 1 - .../Framework/ScriptCanvasGraphUtilities.inl | 51 +++++----- .../Include/ScriptCanvas/Bus/RequestBus.h | 5 - .../Bus/ScriptCanvasExecutionBus.h | 2 +- .../Components/EditorDeprecationData.h | 22 +++-- .../Code/Editor/ReflectComponent.cpp | 96 +++++++++++++++++-- .../Code/Editor/SystemComponent.cpp | 8 +- .../Code/Editor/SystemComponent.h | 2 +- .../Code/Editor/View/Widgets/GraphTabBar.cpp | 6 +- .../FunctionNodePaletteTreeItemTypes.h | 2 +- .../StatisticsDialog/NodeUsageTreeItem.cpp | 5 +- .../StatisticsDialog/NodeUsageTreeItem.h | 9 +- .../ScriptCanvasStatisticsDialog.cpp | 4 +- .../UnitTestPanel/UnitTestDockWidget.cpp | 12 +-- .../UnitTestPanel/UnitTestDockWidget.h | 8 +- .../Code/Editor/View/Windows/MainWindow.h | 6 +- .../Windows/Tools/UpgradeTool/Scanner.cpp | 2 +- .../Code/Include/ScriptCanvas/Core/Core.cpp | 1 - .../Code/Include/ScriptCanvas/Core/Core.h | 23 ++--- .../Code/scriptcanvasgem_headers.cmake | 1 + 22 files changed, 171 insertions(+), 103 deletions(-) diff --git a/Gems/ScriptCanvas/Code/Asset/EditorAssetSystemComponent.cpp b/Gems/ScriptCanvas/Code/Asset/EditorAssetSystemComponent.cpp index 0a0ddbf8b8..3491cb5360 100644 --- a/Gems/ScriptCanvas/Code/Asset/EditorAssetSystemComponent.cpp +++ b/Gems/ScriptCanvas/Code/Asset/EditorAssetSystemComponent.cpp @@ -128,7 +128,7 @@ namespace ScriptCanvasEditor // and then a lambda which will be activated if the user chooses to open it with your opener: openers.push_back({ "ScriptCanvas_Editor_Asset_Edit", "Script Canvas Editor..." - , QIcon(ScriptCanvasAssetDescription().GetIconPathImpl()), + , QIcon(ScriptCanvasEditor::SourceDescription::GetIconPath()), [](const char*, const AZ::Uuid& scSourceUuid) { AzToolsFramework::OpenViewPane(LyViewPane::ScriptCanvas); diff --git a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetHelpers.cpp b/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetHelpers.cpp index 07f7ac1e2f..44e529249c 100644 --- a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetHelpers.cpp +++ b/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetHelpers.cpp @@ -150,11 +150,7 @@ namespace ScriptCanvasEditor bool IsValidSourceFile(const AZStd::string& filePath, [[maybe_unused]] ScriptCanvas::ScriptCanvasId scriptCanvasId) { - ScriptCanvasAssetDescription assetDescription; - return AZ::StringFunc::EndsWith(filePath, assetDescription.GetExtensionImpl(), false); - { - return true; - } + return AZ::StringFunc::EndsWith(filePath, ScriptCanvasEditor::SourceDescription::GetFileExtension(), false); } } } diff --git a/Gems/ScriptCanvas/Code/Editor/Components/EditorGraph.cpp b/Gems/ScriptCanvas/Code/Editor/Components/EditorGraph.cpp index b50457adbf..d713bc09a6 100644 --- a/Gems/ScriptCanvas/Code/Editor/Components/EditorGraph.cpp +++ b/Gems/ScriptCanvas/Code/Editor/Components/EditorGraph.cpp @@ -77,7 +77,6 @@ AZ_POP_DISABLE_WARNING #include #include #include -#include #include #include #include diff --git a/Gems/ScriptCanvas/Code/Editor/Framework/ScriptCanvasGraphUtilities.inl b/Gems/ScriptCanvas/Code/Editor/Framework/ScriptCanvasGraphUtilities.inl index 8571c03638..51fef7efcf 100644 --- a/Gems/ScriptCanvas/Code/Editor/Framework/ScriptCanvasGraphUtilities.inl +++ b/Gems/ScriptCanvas/Code/Editor/Framework/ScriptCanvasGraphUtilities.inl @@ -149,36 +149,33 @@ namespace ScriptCanvasEditor } } - AZ_INLINE void RunEditorAsset(AZ::Data::Asset asset, Reporter& reporter, ScriptCanvas::ExecutionMode mode) + AZ_INLINE void RunEditorAsset(SourceHandle asset, Reporter& reporter, ScriptCanvas::ExecutionMode mode) { - if (asset.IsReady()) + AZ::Data::AssetId assetId = asset.Id(); + AZ::Data::AssetId runtimeAssetId(assetId.m_guid, AZ_CRC("RuntimeData", 0x163310ae)); + AZ::Data::Asset runtimeAsset; + if (!runtimeAsset.Create(runtimeAssetId, true)) { - AZ::Data::AssetId assetId = asset.GetId(); - AZ::Data::AssetId runtimeAssetId(assetId.m_guid, AZ_CRC("RuntimeData", 0x163310ae)); - AZ::Data::Asset runtimeAsset; - if (!runtimeAsset.Create(runtimeAssetId, true)) - { - return; - } - - reporter.SetExecutionMode(mode); - - LoadTestGraphResult loadResult; - loadResult.m_editorAsset = SourceHandle(nullptr, assetId.m_guid, asset.GetHint()); - AZ::EntityId scriptCanvasId; - loadResult.m_entity = AZStd::make_unique("Loaded test graph"); - loadResult.m_runtimeAsset = runtimeAsset; - - RunGraphSpec runGraphSpec; - runGraphSpec.dirPath = ""; - runGraphSpec.graphPath = asset.GetHint().c_str(); - runGraphSpec.runSpec.duration.m_spec = eDuration::Ticks; - runGraphSpec.runSpec.duration.m_ticks = 10; - runGraphSpec.runSpec.execution = mode; - runGraphSpec.runSpec.release = true; - runGraphSpec.runSpec.debug = runGraphSpec.runSpec.traced = false; - RunGraphImplementation(runGraphSpec, loadResult, reporter); + return; } + + reporter.SetExecutionMode(mode); + + LoadTestGraphResult loadResult; + loadResult.m_editorAsset = SourceHandle(nullptr, assetId.m_guid, asset.Path()); + AZ::EntityId scriptCanvasId; + loadResult.m_entity = AZStd::make_unique("Loaded test graph"); + loadResult.m_runtimeAsset = runtimeAsset; + + RunGraphSpec runGraphSpec; + runGraphSpec.dirPath = ""; + runGraphSpec.graphPath = asset.Path().c_str(); + runGraphSpec.runSpec.duration.m_spec = eDuration::Ticks; + runGraphSpec.runSpec.duration.m_ticks = 10; + runGraphSpec.runSpec.execution = mode; + runGraphSpec.runSpec.release = true; + runGraphSpec.runSpec.debug = runGraphSpec.runSpec.traced = false; + RunGraphImplementation(runGraphSpec, loadResult, reporter); } AZ_INLINE void RunGraphImplementation(const RunGraphSpec& runGraphSpec, Reporter& reporter) diff --git a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Bus/RequestBus.h b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Bus/RequestBus.h index 5ec0ee1636..fa4d5bbaa1 100644 --- a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Bus/RequestBus.h +++ b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Bus/RequestBus.h @@ -37,11 +37,6 @@ namespace GraphCanvas class NodePaletteDockWidget; } -namespace ScriptCanvas -{ - class ScriptCanvasAssetBase; -} - namespace ScriptCanvasEditor { struct CategoryInformation; diff --git a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Bus/ScriptCanvasExecutionBus.h b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Bus/ScriptCanvasExecutionBus.h index 54cc55a993..51d348e285 100644 --- a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Bus/ScriptCanvasExecutionBus.h +++ b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Bus/ScriptCanvasExecutionBus.h @@ -23,7 +23,7 @@ namespace ScriptCanvasEditor static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single; virtual Reporter RunGraph(AZStd::string_view path, ScriptCanvas::ExecutionMode mode) = 0; - virtual Reporter RunAssetGraph(AZ::Data::Asset, ScriptCanvas::ExecutionMode mode) = 0; + virtual Reporter RunAssetGraph(SourceHandle source, ScriptCanvas::ExecutionMode mode) = 0; }; using ScriptCanvasExecutionBus = AZ::EBus; diff --git a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorDeprecationData.h b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorDeprecationData.h index 0b55e1cf23..4c60441363 100644 --- a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorDeprecationData.h +++ b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorDeprecationData.h @@ -17,6 +17,18 @@ namespace ScriptCanvasEditor { namespace Deprecated { + // only used as a pass-through to loading a guid / hint during version conversion + class ScriptCanvasAsset + : public AZ::Data::AssetData + { + public: + AZ_TYPE_INFO(ScriptCanvasAsset, "{FA10C3DA-0717-4B72-8944-CD67D13DFA2B}"); + AZ_CLASS_ALLOCATOR(ScriptCanvasAsset, AZ::SystemAllocator, 0); + + ScriptCanvasAsset() = default; + }; + + // only used as a pass-through to loading a guid / hint during version conversion class ScriptCanvasAssetHolder { public: @@ -30,15 +42,5 @@ namespace ScriptCanvasEditor ScriptCanvasAssetHolder() = default; }; - // only is used as a pass-through to loading a guid / hint during versioning - class ScriptCanvasAsset - : public AZ::Data::AssetData - { - public: - AZ_TYPE_INFO(ScriptCanvasAsset, "{FA10C3DA-0717-4B72-8944-CD67D13DFA2B}"); - AZ_CLASS_ALLOCATOR(ScriptCanvasAsset, AZ::SystemAllocator, 0); - - ScriptCanvasAsset() = default; - }; } } diff --git a/Gems/ScriptCanvas/Code/Editor/ReflectComponent.cpp b/Gems/ScriptCanvas/Code/Editor/ReflectComponent.cpp index 8990b55798..45257150c6 100644 --- a/Gems/ScriptCanvas/Code/Editor/ReflectComponent.cpp +++ b/Gems/ScriptCanvas/Code/Editor/ReflectComponent.cpp @@ -6,26 +6,102 @@ * */ -#include - #include -#include #include - - +#include +#include +#include #include #include - #include -#include #include +#include #include +#include #include #include -#include -#include - #include +#include +#include +#include + +namespace CoreCpp +{ + static bool ScriptCanvasDataVersionConverter(AZ::SerializeContext& context, AZ::SerializeContext::DataElementNode& rootDataElementNode) + { + if (rootDataElementNode.GetVersion() == 0) + { + int scriptCanvasEntityIndex = rootDataElementNode.FindElement(AZ_CRC("m_scriptCanvas", 0xfcd20d85)); + if (scriptCanvasEntityIndex == -1) + { + AZ_Error("Script Canvas", false, "Version Converter failed, The Script Canvas Entity is missing"); + return false; + } + + auto scComponentElements = AZ::Utils::FindDescendantElements(context, rootDataElementNode, AZStd::vector{AZ_CRC("m_scriptCanvas", 0xfcd20d85), + AZ_CRC("element", 0x41405e39), AZ_CRC("Components", 0xee48f5fd)}); + if (!scComponentElements.empty()) + { + scComponentElements.front()->AddElementWithData(context, "element", ScriptCanvasEditor::EditorGraphVariableManagerComponent()); + } + } + + if (rootDataElementNode.GetVersion() < 4) + { + auto scEntityElements = AZ::Utils::FindDescendantElements(context, rootDataElementNode, + AZStd::vector{AZ_CRC("m_scriptCanvas", 0xfcd20d85), AZ_CRC("element", 0x41405e39)}); + if (scEntityElements.empty()) + { + AZ_Error("Script Canvas", false, "Version Converter failed, The Script Canvas Entity is missing"); + return false; + } + auto& scEntityDataElement = *scEntityElements.front(); + + AZ::Entity scEntity; + if (!scEntityDataElement.GetData(scEntity)) + { + AZ_Error("Script Canvas", false, "Unable to retrieve entity data from the Data Element"); + return false; + } + + auto graph = AZ::EntityUtils::FindFirstDerivedComponent(&scEntity); + if (!graph) + { + AZ_Error("Script Canvas", false, "Script Canvas graph component could not be found on Script Canvas Entity for ScriptCanvasData version %u", rootDataElementNode.GetVersion()); + return false; + } + auto variableManager = AZ::EntityUtils::FindFirstDerivedComponent(&scEntity); + if (!variableManager) + { + AZ_Error("Script Canvas", false, "Script Canvas variable manager component could not be found on Script Canvas Entity for ScriptCanvasData version %u", rootDataElementNode.GetVersion()); + return false; + } + + variableManager->ConfigureScriptCanvasId(graph->GetScriptCanvasId()); + if (!scEntityDataElement.SetData(context, scEntity)) + { + AZ_Error("Script Canvas", false, "Failed to set converted Script Canvas Entity back on data element node when transitioning from version %u to version 4", rootDataElementNode.GetVersion()); + return false; + } + } + + return true; + } +} + +namespace ScriptCanvas +{ + void ScriptCanvasData::Reflect(AZ::ReflectContext* reflectContext) + { + if (auto serializeContext = azrtti_cast(reflectContext)) + { + serializeContext->Class() + ->Version(4, &CoreCpp::ScriptCanvasDataVersionConverter) + ->Field("m_scriptCanvas", &ScriptCanvasData::m_scriptCanvasEntity) + ; + } + } +} namespace ScriptCanvasEditor { diff --git a/Gems/ScriptCanvas/Code/Editor/SystemComponent.cpp b/Gems/ScriptCanvas/Code/Editor/SystemComponent.cpp index 4933a31b60..9bbdddfedb 100644 --- a/Gems/ScriptCanvas/Code/Editor/SystemComponent.cpp +++ b/Gems/ScriptCanvas/Code/Editor/SystemComponent.cpp @@ -316,8 +316,8 @@ namespace ScriptCanvasEditor using namespace AzToolsFramework::AssetBrowser; bool isScriptCanvasAsset = false; - ScriptCanvasAssetDescription scriptCanvasAssetDescription; - if (AZStd::wildcard_match(AZStd::string::format("*%s", scriptCanvasAssetDescription.GetExtensionImpl()).c_str(), fullSourceFileName)) + + if (AZStd::wildcard_match(ScriptCanvasEditor::SourceDescription::GetFileExtension(), fullSourceFileName)) { isScriptCanvasAsset = true; } @@ -339,7 +339,7 @@ namespace ScriptCanvasEditor } }; - openers.push_back({ "O3DE_ScriptCanvasEditor", "Open In Script Canvas Editor...", QIcon(ScriptCanvasAssetDescription().GetIconPathImpl()), scriptCanvasEditorCallback }); + openers.push_back({ "O3DE_ScriptCanvasEditor", "Open In Script Canvas Editor...", QIcon(ScriptCanvasEditor::SourceDescription::GetIconPath()), scriptCanvasEditorCallback }); } } @@ -394,7 +394,7 @@ namespace ScriptCanvasEditor return ScriptCanvasEditor::RunGraph(runGraphSpec).front(); } - Reporter SystemComponent::RunAssetGraph(AZ::Data::Asset asset, ScriptCanvas::ExecutionMode mode) + Reporter SystemComponent::RunAssetGraph(SourceHandle asset, ScriptCanvas::ExecutionMode mode) { Reporter reporter; RunEditorAsset(asset, reporter, mode); diff --git a/Gems/ScriptCanvas/Code/Editor/SystemComponent.h b/Gems/ScriptCanvas/Code/Editor/SystemComponent.h index dc4175f938..9aecd00320 100644 --- a/Gems/ScriptCanvas/Code/Editor/SystemComponent.h +++ b/Gems/ScriptCanvas/Code/Editor/SystemComponent.h @@ -78,7 +78,7 @@ namespace ScriptCanvasEditor //////////////////////////////////////////////////////////////////////// // ScriptCanvasExecutionBus::Handler... - Reporter RunAssetGraph(AZ::Data::Asset, ScriptCanvas::ExecutionMode mode) override; + Reporter RunAssetGraph(SourceHandle source, ScriptCanvas::ExecutionMode mode) override; Reporter RunGraph(AZStd::string_view path, ScriptCanvas::ExecutionMode mode) override; //////////////////////////////////////////////////////////////////////// diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/GraphTabBar.cpp b/Gems/ScriptCanvas/Code/Editor/View/Widgets/GraphTabBar.cpp index 4e9398fdcf..c5f808d5f4 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/GraphTabBar.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/GraphTabBar.cpp @@ -78,7 +78,7 @@ namespace ScriptCanvasEditor if (!tabDataVariant.value().m_canvasWidget) { CanvasWidget* canvasWidget = new CanvasWidget(tabDataVariant.value().m_assetId, this); - canvasWidget->SetDefaultBorderColor(ScriptCanvasAssetDescription().GetDisplayColorImpl()); + canvasWidget->SetDefaultBorderColor(ScriptCanvasEditor::SourceDescription::GetDisplayColor()); GraphTabMetadata replacement = tabDataVariant.value(); replacement.m_canvasWidget = canvasWidget; tabDataVariant.setValue(replacement); @@ -147,11 +147,11 @@ namespace ScriptCanvasEditor { if (!SelectTab(assetId)) { - QIcon tabIcon = QIcon(ScriptCanvasAssetDescription().GetIconPathImpl()); + QIcon tabIcon = QIcon(ScriptCanvasEditor::SourceDescription::GetIconPath()); tabIndex = qobject_cast(parent())->insertTab(tabIndex, new QWidget(), tabIcon, ""); GraphTabMetadata metaData; CanvasWidget* canvasWidget = new CanvasWidget(assetId, this); - canvasWidget->SetDefaultBorderColor(ScriptCanvasAssetDescription().GetDisplayColorImpl()); + canvasWidget->SetDefaultBorderColor(SourceDescription::GetDisplayColor()); metaData.m_canvasWidget = canvasWidget; metaData.m_assetId = assetId; metaData.m_fileState = fileState; diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/NodePalette/FunctionNodePaletteTreeItemTypes.h b/Gems/ScriptCanvas/Code/Editor/View/Widgets/NodePalette/FunctionNodePaletteTreeItemTypes.h index 479fed1097..459c786edd 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/NodePalette/FunctionNodePaletteTreeItemTypes.h +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/NodePalette/FunctionNodePaletteTreeItemTypes.h @@ -17,7 +17,7 @@ #include #include #include - +#include #include namespace AZ diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/NodeUsageTreeItem.cpp b/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/NodeUsageTreeItem.cpp index 2770202233..64dfa30cff 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/NodeUsageTreeItem.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/NodeUsageTreeItem.cpp @@ -182,6 +182,7 @@ namespace ScriptCanvasEditor return nodeIter->second; } + /* void ScriptCanvasAssetNodeUsageTreeItem::OnAssetReady(AZ::Data::Asset asset) { ProcessAsset(asset); @@ -200,7 +201,8 @@ namespace ScriptCanvasEditor ProcessAsset(asset); } - void ScriptCanvasAssetNodeUsageTreeItem::ProcessAsset(const AZ::Data::Asset& scriptCanvasAsset) + // #sc_editor_asset_redux fix graph use statistics + void ScriptCanvasAssetNodeUsageTreeItem::ProcessAsset(const AZ::Data::Asset& scriptCanvasAsset) { if (scriptCanvasAsset.IsReady()) { @@ -222,6 +224,7 @@ namespace ScriptCanvasEditor } } } + */ /////////////////////////////////////////// // ScriptCanvasAssetNodeUsageTreeItemRoot diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/NodeUsageTreeItem.h b/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/NodeUsageTreeItem.h index 3e2c0b637b..7fbe3e173a 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/NodeUsageTreeItem.h +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/NodeUsageTreeItem.h @@ -94,15 +94,16 @@ namespace ScriptCanvasEditor void SetActiveNodeType(const ScriptCanvas::NodeTypeIdentifier& nodeTypeIdentifier); int GetNodeCount() const; + private: + // AZ::Data::AssetBus::Handler + /* void OnAssetReady(AZ::Data::Asset asset) override; void OnAssetSaved(AZ::Data::Asset asset, bool isSuccessful) override; void OnAssetReloaded(AZ::Data::Asset asset) override; + */ //// - - private: - - void ProcessAsset(const AZ::Data::Asset& scriptCanvasAsset); + // void ProcessAsset(const AZ::Data::Asset& scriptCanvasAsset); QString m_name; QIcon m_icon; diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/ScriptCanvasStatisticsDialog.cpp b/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/ScriptCanvasStatisticsDialog.cpp index 62f0d7ddc7..980e3a1e92 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/ScriptCanvasStatisticsDialog.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/ScriptCanvasStatisticsDialog.cpp @@ -435,9 +435,9 @@ namespace ScriptCanvasEditor } } - void StatisticsDialog::ProcessAsset(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) + void StatisticsDialog::ProcessAsset([[maybe_unused]] const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) { - // #sc_editor_asset_redux cut or update + // #sc_editor_asset_redux cut or update // if (entry) // { // if (entry->GetEntryType() == AzToolsFramework::AssetBrowser::AssetBrowserEntry::AssetEntryType::Product) diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/UnitTestPanel/UnitTestDockWidget.cpp b/Gems/ScriptCanvas/Code/Editor/View/Widgets/UnitTestPanel/UnitTestDockWidget.cpp index 63e41896fc..d3a948a6c4 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/UnitTestPanel/UnitTestDockWidget.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/UnitTestPanel/UnitTestDockWidget.cpp @@ -574,14 +574,14 @@ namespace ScriptCanvasEditor void UnitTestDockWidget::RunTestGraph(SourceHandle asset, ScriptCanvas::ExecutionMode mode) { Reporter reporter; - UnitTestWidgetNotificationBus::Broadcast(&UnitTestWidgetNotifications::OnTestStart, asset); + UnitTestWidgetNotificationBus::Broadcast(&UnitTestWidgetNotifications::OnTestStart, asset.Id()); ScriptCanvasExecutionBus::BroadcastResult(reporter, &ScriptCanvasExecutionRequests::RunAssetGraph, asset, mode); UnitTestResult testResult; UnitTestVerificationBus::BroadcastResult(testResult, &UnitTestVerificationRequests::Verify, reporter); - UnitTestWidgetNotificationBus::Broadcast(&UnitTestWidgetNotifications::OnTestResult, asset, testResult); + UnitTestWidgetNotificationBus::Broadcast(&UnitTestWidgetNotifications::OnTestResult, asset.Id(), testResult); m_pendingTests.Add(asset, mode); @@ -603,7 +603,7 @@ namespace ScriptCanvasEditor ++m_testMetrics[static_cast(mode)].m_compilationFailures; } - m_pendingTests.Complete(asset.GetId(), mode); + m_pendingTests.Complete(asset, mode); } void UnitTestDockWidget::OnSystemTick() @@ -614,14 +614,14 @@ namespace ScriptCanvasEditor } } - void UnitTestDockWidget::PendingTests::Add(AZ::Data::AssetId assetId, ExecutionMode mode) + void UnitTestDockWidget::PendingTests::Add(ScriptCanvasEditor::SourceHandle assetId, ExecutionMode mode) { m_pendingTests.push_back(AZStd::make_pair(assetId, mode)); } - void UnitTestDockWidget::PendingTests::Complete(AZ::Data::AssetId assetId, ExecutionMode mode) + void UnitTestDockWidget::PendingTests::Complete(ScriptCanvasEditor::SourceHandle assetId, ExecutionMode mode) { - AZStd::erase_if(m_pendingTests, [assetId, mode](const AZStd::pair& pending) + AZStd::erase_if(m_pendingTests, [assetId, mode](const AZStd::pair& pending) { return (assetId == pending.first && mode == pending.second); }); diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/UnitTestPanel/UnitTestDockWidget.h b/Gems/ScriptCanvas/Code/Editor/View/Widgets/UnitTestPanel/UnitTestDockWidget.h index 93bb093c49..fce520a6f2 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/UnitTestPanel/UnitTestDockWidget.h +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/UnitTestPanel/UnitTestDockWidget.h @@ -162,7 +162,7 @@ namespace ScriptCanvasEditor void OpenTestResults(AZ::Uuid sourceUuid, AZStd::string_view sourceDisplayName); void RunTests(const AZStd::vector& scriptUuids); - void RunTestGraph(AZ::Data::Asset, ScriptCanvas::ExecutionMode); + void RunTestGraph(SourceHandle sourceHandle, ScriptCanvas::ExecutionMode); void OnTestsComplete(); @@ -184,15 +184,15 @@ namespace ScriptCanvasEditor { public: - void Add(AZ::Data::AssetId assetId, ExecutionMode mode); + void Add(ScriptCanvasEditor::SourceHandle assetId, ExecutionMode mode); - void Complete(AZ::Data::AssetId assetId, ExecutionMode mode); + void Complete(ScriptCanvasEditor::SourceHandle assetId, ExecutionMode mode); bool IsFinished() const; private: - AZStd::vector> m_pendingTests; + AZStd::vector> m_pendingTests; }; PendingTests m_pendingTests; diff --git a/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.h b/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.h index fbc363e444..2d2c32be18 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.h +++ b/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.h @@ -56,10 +56,9 @@ #if SCRIPTCANVAS_EDITOR #include -#endif +#endif//#if SCRIPTCANVAS_EDITOR -#include -#endif +#endif//#if !defined(Q_MOC_RUN) namespace GraphCanvas { @@ -87,7 +86,6 @@ namespace AzQtComponents class QDir; class QFile; class QProgressDialog; -namespace ScriptCanvas { class ScriptCanvasAssetBase; } namespace ScriptCanvasEditor { diff --git a/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/Scanner.cpp b/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/Scanner.cpp index 9e6340ee31..29fa3c62e5 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/Scanner.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/Scanner.cpp @@ -6,13 +6,13 @@ * */ +#include #include #include #include #include #include #include - #include namespace ScannerCpp diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Core.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Core.cpp index 1ac7a33821..4a1d5d94c1 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Core.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Core.cpp @@ -13,7 +13,6 @@ #include #include #include -#include #include "Attributes.h" #include "Core.h" diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Core.h b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Core.h index 01280a4ee5..d283be79e5 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Core.h +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Core.h @@ -321,17 +321,18 @@ namespace ScriptCanvasEditor { public: static inline constexpr const char* GetAssetGroup() { return "ScriptCanvas"; } - inline static constexpr const char* GetType() { return "{FA10C3DA-0717-4B72-8944-CD67D13DFA2B}"; } // type - inline static constexpr const char* GetName() { return "Script Canvas"; } // name - inline static constexpr const char* GetDescription() { return "Script Canvas Graph Asset"; } // description - inline static constexpr const char* GetSuggestedSavePath() { return "@projectroot@/scriptcanvas"; } // suggested save path - inline static constexpr const char* GetFileExtension() { return ".scriptcanvas"; } // fileExtention - inline static constexpr const char* GetGroup() { return "Script Canvas"; } // group - inline static constexpr const char* GetAssetNamePattern() { return "Untitled-%i"; } // asset name pattern - inline static constexpr const char* GetFileFilter() { return "Script Canvas Files (*.scriptcanvas)"; } // file filter - inline static constexpr const char* GetAssetTypeDisplayName() { return "Script Canvas"; } // asset type display name - inline static constexpr const char* GetEntityName() { return "Script Canvas"; } // entity name - inline static constexpr const char* GetIconPath() { return "Icons/ScriptCanvas/Viewport/ScriptCanvas.png"; } // icon pa + inline static constexpr const char* GetType() { return "{FA10C3DA-0717-4B72-8944-CD67D13DFA2B}"; } + inline static constexpr const char* GetName() { return "Script Canvas"; } + inline static constexpr const char* GetDescription() { return "Script Canvas Graph File"; } + inline static constexpr const char* GetSuggestedSavePath() { return "@projectroot@/scriptcanvas"; } + inline static constexpr const char* GetFileExtension() { return ".scriptcanvas"; } + inline static constexpr const char* GetGroup() { return "Script Canvas"; } + inline static constexpr const char* GetAssetNamePattern() { return "Untitled-%i"; } + inline static constexpr const char* GetFileFilter() { return "Script Canvas Files (*.scriptcanvas)"; } + inline static constexpr const char* GetAssetTypeDisplayName() { return "Script Canvas"; } + inline static constexpr const char* GetEntityName() { return "Script Canvas"; } + inline static constexpr const char* GetIconPath() { return "Icons/ScriptCanvas/Viewport/ScriptCanvas.png"; } + inline static AZ::Color GetDisplayColor() { return AZ::Color(1.0f, 0.0f, 0.0f, 1.0f); }; }; class SourceHandle diff --git a/Gems/ScriptCanvas/Code/scriptcanvasgem_headers.cmake b/Gems/ScriptCanvas/Code/scriptcanvasgem_headers.cmake index ecbcdc6ed6..9830535ad8 100644 --- a/Gems/ScriptCanvas/Code/scriptcanvasgem_headers.cmake +++ b/Gems/ScriptCanvas/Code/scriptcanvasgem_headers.cmake @@ -9,6 +9,7 @@ set(FILES Include/ScriptCanvas/SystemComponent.h Include/ScriptCanvas/ScriptCanvasGem.h + Include/ScriptCanvas/Asset/AssetDescription.h Include/ScriptCanvas/Asset/AssetRegistry.h Include/ScriptCanvas/Asset/AssetRegistryBus.h Include/ScriptCanvas/Asset/ExecutionLogAsset.h From f2bbf418814bda8e85e167762900c6f7bf753c96 Mon Sep 17 00:00:00 2001 From: carlitosan <82187351+carlitosan@users.noreply.github.com> Date: Tue, 14 Dec 2021 18:01:22 -0800 Subject: [PATCH 44/70] fix color background in editor Signed-off-by: carlitosan <82187351+carlitosan@users.noreply.github.com> --- Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Core.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Core.h b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Core.h index d283be79e5..1a644d312e 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Core.h +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Core.h @@ -320,7 +320,7 @@ namespace ScriptCanvasEditor class SourceDescription { public: - static inline constexpr const char* GetAssetGroup() { return "ScriptCanvas"; } + inline static constexpr const char* GetAssetGroup() { return "ScriptCanvas"; } inline static constexpr const char* GetType() { return "{FA10C3DA-0717-4B72-8944-CD67D13DFA2B}"; } inline static constexpr const char* GetName() { return "Script Canvas"; } inline static constexpr const char* GetDescription() { return "Script Canvas Graph File"; } @@ -332,7 +332,7 @@ namespace ScriptCanvasEditor inline static constexpr const char* GetAssetTypeDisplayName() { return "Script Canvas"; } inline static constexpr const char* GetEntityName() { return "Script Canvas"; } inline static constexpr const char* GetIconPath() { return "Icons/ScriptCanvas/Viewport/ScriptCanvas.png"; } - inline static AZ::Color GetDisplayColor() { return AZ::Color(1.0f, 0.0f, 0.0f, 1.0f); }; + inline static AZ::Color GetDisplayColor() { return AZ::Color(0.5f, 0.5f, 0.5f, 0.5f); }; }; class SourceHandle From 686f82666bd2a9434e95faba6a392ba1079fe51e Mon Sep 17 00:00:00 2001 From: carlitosan <82187351+carlitosan@users.noreply.github.com> Date: Tue, 14 Dec 2021 18:52:50 -0800 Subject: [PATCH 45/70] disable test manager until the asset browsing is fixed Signed-off-by: carlitosan <82187351+carlitosan@users.noreply.github.com> --- Gems/ScriptCanvas/Code/Editor/View/Windows/mainwindow.ui | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Gems/ScriptCanvas/Code/Editor/View/Windows/mainwindow.ui b/Gems/ScriptCanvas/Code/Editor/View/Windows/mainwindow.ui index 1208a55a64..6276f7e2b4 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Windows/mainwindow.ui +++ b/Gems/ScriptCanvas/Code/Editor/View/Windows/mainwindow.ui @@ -529,7 +529,10 @@ Test Manager - + + false + + Ctrl+Shift+T From 671479c0951434117c2c056a4abe5a1335a86b86 Mon Sep 17 00:00:00 2001 From: carlitosan <82187351+carlitosan@users.noreply.github.com> Date: Tue, 14 Dec 2021 19:05:43 -0800 Subject: [PATCH 46/70] remove dev comment Signed-off-by: carlitosan <82187351+carlitosan@users.noreply.github.com> --- Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.cpp b/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.cpp index 3b110aba7b..40cc52ac85 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.cpp @@ -434,8 +434,6 @@ namespace ScriptCanvasEditor m_scriptCanvasAssetModel = new ScriptCanvasAssetBrowserModel(this); AzToolsFramework::AssetBrowser::AssetGroupFilter* scriptCanvasAssetFilter = new AzToolsFramework::AssetBrowser::AssetGroupFilter(); - // #sc_editor_asset_redux this may not be needed, may not be doing the right thing at all, verify that searching through - // the subgraph interface assets is the correct thing to do scriptCanvasAssetFilter->SetAssetGroup(ScriptCanvas::SubgraphInterfaceAssetDescription().GetGroupImpl()); scriptCanvasAssetFilter->SetFilterPropagation(AzToolsFramework::AssetBrowser::AssetBrowserEntryFilter::PropagateDirection::Down); From e1c1adf2dcbb2ae23ab68d942754acb0c376b326 Mon Sep 17 00:00:00 2001 From: carlitosan <82187351+carlitosan@users.noreply.github.com> Date: Tue, 14 Dec 2021 23:20:12 -0800 Subject: [PATCH 47/70] fix linux build error Signed-off-by: carlitosan <82187351+carlitosan@users.noreply.github.com> --- .../Include/ScriptCanvas/Assets/ScriptCanvasFileHandling.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasFileHandling.h b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasFileHandling.h index 2260418fe8..93d1558223 100644 --- a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasFileHandling.h +++ b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Assets/ScriptCanvasFileHandling.h @@ -11,7 +11,7 @@ #include #include #include - +#include namespace AZ { From cbba00d4735fba383cd5a9bedd13289e05836c5e Mon Sep 17 00:00:00 2001 From: Jonny Galloway Date: Wed, 15 Dec 2021 10:25:23 -0600 Subject: [PATCH 48/70] Atom/16852 (#6316) * discover build folder, don't assume or require Signed-off-by: Jonny Gallowy * update config_utils, no cyclical imports Signed-off-by: Jonny Gallowy * improved docstrings and some code formatting Signed-off-by: Jonny Gallowy * updates to config.py Signed-off-by: Jonny Gallowy * updates to config_utils.py Signed-off-by: Jonny Gallowy * dccsi bootstrap changes Signed-off-by: Jonny Gallowy * fixed testing for bootstrap externally Signed-off-by: Jonny Gallowy * added note for installing substance automation toolkit for tool dev Signed-off-by: Jonny Gallowy * based on user feedback suppress global debug by default in IDE Signed-off-by: Jonny Gallowy * small adjustments Signed-off-by: Jonny Gallowy --- .../Editor/Scripts/ColorGrading/initialize.py | 14 +- .../DccScriptingInterface/.env.example | 22 +- .../3rdParty/Python/README.txt | 9 +- .../Editor/Scripts/bootstrap.py | 353 ++++++++++++------ .../SDK/Lumberyard/Scripts/set_menu.py | 2 +- .../Scripts/Python/kitbash_converter/main.py | 4 +- .../Python/kitbash_converter/standalone.py | 10 +- .../SDK/Maya/Scripts/userSetup.py | 28 +- .../SDK/Substance/builder/bootstrap.py | 22 +- .../SDK/Substance/builder/sb_gui_main.py | 24 +- .../SDK/Substance/builder/sbs_to_sbsar.py | 6 +- .../SDK/Substance/builder/sbsar_info.py | 6 +- .../SDK/Substance/builder/sbsar_render.py | 6 +- .../SDK/Substance/builder/sbsar_utils.py | 10 +- .../SDK/Substance/builder/substance_tools.py | 6 +- .../Substance/builder/watchdog/__init__.py | 8 +- .../Tools/DCC/Maya/Scripts/userSetup.py | 38 +- .../Windows/{ => DCC}/Launch_Maya_2020.bat | 14 +- .../Dev/Windows/DCC/Launch_Maya_2022.bat | 73 ++++ .../Windows/{ => DCC}/Launch_mayaPy_2020.bat | 18 +- .../Dev/Windows/DCC/Launch_mayaPy_2022.bat | 73 ++++ .../Tools/Dev/Windows/Env_Core.bat | 28 +- .../Tools/Dev/Windows/Env_Dev.bat.example | 20 + .../Tools/Dev/Windows/Env_Maya.bat | 15 +- .../Tools/Dev/Windows/Env_PyCharm.bat | 26 +- .../Tools/Dev/Windows/Env_Python.bat | 22 +- .../Tools/Dev/Windows/Env_Qt.bat | 8 +- .../Tools/Dev/Windows/Env_Substance.bat | 12 +- .../Tools/Dev/Windows/Env_VScode.bat | 2 +- .../Tools/Dev/Windows/Env_WingIDE.bat | 4 +- .../{ => IDE}/Launch_MayaPy_PyCharmPro.bat | 34 +- .../Windows/{ => IDE}/Launch_PyCharmPro.bat | 16 +- .../Dev/Windows/{ => IDE}/Launch_VScode.bat | 31 +- .../Windows/{ => IDE}/Launch_WingIDE-7-1.bat | 26 +- .../{ => IDE}/Launch_mayapy_WingIDE-7-1.bat | 34 +- .../Tools/Dev/Windows/Launch_Env_Cmd.bat | 8 +- .../Tools/Dev/Windows/Launch_PyMin_Cmd.bat | 2 +- .../Tools/Dev/Windows/Launch_Qt_PyMin_Cmd.bat | 2 +- .../Tools/Dev/Windows/Launch_pyBASE_Cmd.bat | 2 +- .../Tools/Dev/Windows/Setuo_copy_oiio.bat | 4 +- .../Dev/Windows/Solutions/.idea/.gitignore | 3 +- .../Solutions/.idea/DccScriptingInterface.iml | 12 +- .../Dev/Windows/Solutions/.idea/misc.xml | 4 +- .../Tools/Dev/Windows/Solutions/.idea/vcs.xml | 4 +- .../DccScriptingInterface/azpy/__init__.py | 57 +-- .../azpy/config_utils.py | 332 ++++++++++++---- .../DccScriptingInterface/azpy/constants.py | 101 ++--- .../DccScriptingInterface/azpy/env_base.py | 10 +- .../azpy/synthetic_env.py | 86 ++--- .../azpy/test/entry_test.py | 39 +- .../DccScriptingInterface/config.py | 346 +++++++++-------- 51 files changed, 1263 insertions(+), 773 deletions(-) rename Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/{ => DCC}/Launch_Maya_2020.bat (91%) create mode 100644 Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/DCC/Launch_Maya_2022.bat rename Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/{ => DCC}/Launch_mayaPy_2020.bat (87%) create mode 100644 Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/DCC/Launch_mayaPy_2022.bat create mode 100644 Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Dev.bat.example rename Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/{ => IDE}/Launch_MayaPy_PyCharmPro.bat (70%) rename Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/{ => IDE}/Launch_PyCharmPro.bat (83%) rename Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/{ => IDE}/Launch_VScode.bat (79%) rename Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/{ => IDE}/Launch_WingIDE-7-1.bat (77%) rename Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/{ => IDE}/Launch_mayapy_WingIDE-7-1.bat (70%) diff --git a/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/initialize.py b/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/initialize.py index 24fcd08f02..3a6356f4c9 100644 --- a/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/initialize.py +++ b/Gems/Atom/Feature/Common/Editor/Scripts/ColorGrading/initialize.py @@ -81,10 +81,10 @@ def start(): try: _TAG_LY_BUILD_PATH = os.getenv('TAG_LY_BUILD_PATH', 'build') _DEFAULT_BIN_PATH = Path(str(_O3DE_DEV), _TAG_LY_BUILD_PATH, 'bin', 'profile') - _O3DE_BIN_PATH = Path(os.getenv('O3DE_BIN_PATH', _DEFAULT_BIN_PATH)) - os.environ['O3DE_BIN_PATH'] = _O3DE_BIN_PATH.as_posix() - _LOGGER.debug(f'O3DE_BIN_PATH is: {_O3DE_BIN_PATH}') - site.addsitedir(_O3DE_BIN_PATH.resolve()) + _PATH_O3DE_BIN = Path(os.getenv('PATH_O3DE_BIN', _DEFAULT_BIN_PATH)) + os.environ['PATH_O3DE_BIN'] = _PATH_O3DE_BIN.as_posix() + _LOGGER.debug(f'PATH_O3DE_BIN is: {_PATH_O3DE_BIN}') + site.addsitedir(_PATH_O3DE_BIN.resolve()) except EnvironmentError as e: _LOGGER.error('O3DE bin folder not set or found') raise e @@ -94,10 +94,10 @@ def start(): os.environ['O3DE_DEV'] = _O3DE_DEV.as_posix() _LOGGER.debug(_O3DE_DEV) - _O3DE_BIN_PATH = Path(str(_O3DE_DEV),Path(azlmbr.paths.executableFolder)) + _PATH_O3DE_BIN = Path(str(_O3DE_DEV),Path(azlmbr.paths.executableFolder)) - _O3DE_BIN = Path(os.getenv('O3DE_BIN', _O3DE_BIN_PATH.resolve())) - os.environ['O3DE_BIN'] = _O3DE_BIN_PATH.as_posix() + _O3DE_BIN = Path(os.getenv('O3DE_BIN', _PATH_O3DE_BIN.resolve())) + os.environ['O3DE_BIN'] = _PATH_O3DE_BIN.as_posix() _LOGGER.debug(_O3DE_BIN) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/.env.example b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/.env.example index 29c1739992..9f881ac3d3 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/.env.example +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/.env.example @@ -10,12 +10,12 @@ export DYNACONF_COMPANY=Amazon # if a O3DE project isn't set use this gem export DYNACONF_O3DE_PROJECT=DccScriptingInterface -export DYNACONF_O3DE_PROJECT_PATH=`pwd` -export DYNACONF_O3DE_DEV=${O3DE_PROJECT_PATH}\..\..\..\.. +export DYNACONF_PATH_O3DE_PROJECT=`pwd` +export DYNACONF_O3DE_DEV=${PATH_O3DE_PROJECT}\..\..\..\.. # LY build folder -export DYNACONF_O3DE_BUILD_PATH=${O3DE_DEV}\build -export DYNACONF_O3DE_BIN_PATH=${O3DE_BUILD_PATH}\bin\profile +export DYNACONF_PATH_O3DE_BUILD=${O3DE_DEV}\build +export DYNACONF_PATH_O3DE_BIN=${PATH_O3DE_BUILD}\bin\profile # default IDE and debug settings #export DYNACONF_DCCSI_GDEBUG=false @@ -24,7 +24,7 @@ export DYNACONF_DCCSI_GDEBUGGER=WING export DYNACONF_DCCSI_LOGLEVEL=20 # defaults for DccScriptingInterface (DCCsi) -export DYNACONF_DCCSIG_PATH=${O3DE_DEV}\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface +export DYNACONF_PATH_DCCSIG=${O3DE_DEV}\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface # set up default python interpreter (O3DE) # we may want to entirely remove these and rely on config.py to dynamically set up @@ -33,20 +33,20 @@ export DYNACONF_DCCSI_PY_VERSION_MAJOR=3 export DYNACONF_DCCSI_PY_VERSION_MINOR=7 export DYNACONF_DCCSI_PY_VERSION_RELEASE=11 # To Do: probably move the folder below into the /SDK folder? -export DYNACONF_DCCSI_PYTHON_PATH=${DCCSIG_PATH}\3rdParty\Python +export DYNACONF_PATH_DCCSI_PYTHON=${PATH_DCCSIG}\3rdParty\Python # add access to a Lib location that matches the py version (3.7.x) # switch this for other python version like (2.7.x) for Maya -export DYNACONF_DCCSI_PYTHON_LIB_PATH=${DCCSI_PYTHON_PATH}\Lib\${DCCSI_PY_VERSION_MAJOR}.x\${DCCSI_PY_VERSION_MAJOR}.${DCCSI_PY_VERSION_MINOR}.x\site-packages +export DYNACONF_PATH_DCCSI_PYTHON_LIB=${PATH_DCCSI_PYTHON}\Lib\${DCCSI_PY_VERSION_MAJOR}.x\${DCCSI_PY_VERSION_MAJOR}.${DCCSI_PY_VERSION_MINOR}.x\site-packages # TO DO: figure out how to best deal with OS folder (i.e. 'windows') -export DYNACONF_O3DE_PYTHON_INSTALL=${O3DE_DEV}\python -export DYNACONF_DCCSI_PY_BASE=${O3DE_PYTHON_INSTALL}\python.cmd +export DYNACONF_PATH_O3DE_PYTHON_INSTALL=${O3DE_DEV}\python +export DYNACONF_DCCSI_PY_BASE=${PATH_O3DE_PYTHON_INSTALL}\python.cmd # set up Qt / PySide2 # TO DO: These should NOT be set in the global env as they will cause conflicts # with other Qt apps (like DCC tools), only set in local.env, or modify config.py # for utils/tools/apps that need them ( see config.init_ly_pyside() ) #export DYNACONF_QTFORPYTHON_PATH=${O3DE_DEV}\Gems\QtForPython\3rdParty\pyside2\windows\release -#export DYNACONF_QT_PLUGIN_PATH=${O3DE_BUILD_PATH}\bin\profile\EditorPlugins -#export DYNACONF_QT_QPA_PLATFORM_PLUGIN_PATH=${O3DE_BUILD_PATH}\bin\profile\EditorPlugins\platforms +#export DYNACONF_QT_PLUGIN_PATH=${PATH_O3DE_BUILD}\bin\profile\EditorPlugins +#export DYNACONF_QT_QPA_PLATFORM_PLUGIN_PATH=${PATH_O3DE_BUILD}\bin\profile\EditorPlugins\platforms diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/3rdParty/Python/README.txt b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/3rdParty/Python/README.txt index 7f5a72fb1c..8146fc0020 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/3rdParty/Python/README.txt +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/3rdParty/Python/README.txt @@ -33,4 +33,11 @@ pyside2-tools instructions: 3. add to PYTHONPATH: < local DCCsi >\3rdParty\Python in .py something like: site.addsitedir(DCCSI_PYSIDE2_TOOLS) -See: "< local DCCsi >\config.py" \ No newline at end of file +See: "< local DCCsi >\config.py" + +Substance Automation Toolkit (SAT) Instructions: +Substance has a licensed python API for automating material data workflows. By default, their instructions cover installing it to a python 'system interpreter', however if we want to install it for use within the DCCsi (for custom tools) or even potentially to build inter-op and integrations with O3DE editors, we want to install it in a way that is accessible. + +Install Substance Automation Toolkit 3rd party library to DCCsi 3rdParty sandbox: + +> C:\Depot\o3de\python> pip install "c:\< path to >\SubstanceAutomationToolkit\Python API\Pysbs-2021.2.2-py2.py3-none-win_amd64.whl" --target="C:\Depot\o3de\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\3rdParty\Python\Lib\3.x\3.7.x\site-packages" \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Editor/Scripts/bootstrap.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Editor/Scripts/bootstrap.py index 406e2b04ff..6a4dbb2906 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Editor/Scripts/bootstrap.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Editor/Scripts/bootstrap.py @@ -14,74 +14,88 @@ If you need DCCsi access in py27 (Autodesk Maya for instance) you may need to implement your own boostrapper module. Currently this is boostrapped from add_dccsi.py, as a temporty measure related to this Jira: SPEC-2581""" + +# test bootstrap execution time +import time +_START = time.process_time() # start tracking + # standard imports import sys import os import site -import importlib.util from pathlib import Path import logging as _logging # ------------------------------------------------------------------------- # ------------------------------------------------------------------------- -_O3DE_RUNNING=None -try: - import azlmbr - _O3DE_RUNNING=True -except: - _O3DE_RUNNING=False -# ------------------------------------------------------------------------- +_MODULENAME = 'O3DE.DCCsi.bootstrap' + +# we don't use dynaconf setting here as we might not yet have access +# we need to set up basic access to the DCCsi +_MODULE_PATH = os.path.realpath(__file__) # To Do: what if frozen? +_PATH_DCCSIG = Path(os.path.join(_MODULE_PATH, '../../..')) +site.addsitedir(_PATH_DCCSIG) + +# set envar so DCCsi synthetic env bootstraps with it (config.py) +from azpy.constants import ENVAR_PATH_DCCSIG +os.environ[ENVAR_PATH_DCCSIG] = str(_PATH_DCCSIG.resolve()) +# ------------------------------------------------------------------------- # ------------------------------------------------------------------------- -# we don't use dynaconf setting here as we might not yet have access -# to that site-dir. - -_MODULENAME = __name__ -if _MODULENAME is '__main__': - _MODULENAME = 'O3DE.DCCsi.bootstrap' - -# set up module logging -for handler in _logging.root.handlers[:]: - _logging.root.removeHandler(handler) -_LOGGER = _logging.getLogger(_MODULENAME) - -# we need to set up basic access to the DCCsi -_MODULE_PATH = os.path.realpath(__file__) # To Do: what if frozen? -_DCCSI_PATH = os.path.normpath(os.path.join(_MODULE_PATH, '../../..')) -_DCCSI_PATH = os.getenv('DCCSI_PATH', _DCCSI_PATH) -site.addsitedir(_DCCSI_PATH) - # now we have azpy api access from azpy.env_bool import env_bool from azpy.constants import ENVAR_DCCSI_GDEBUG from azpy.constants import ENVAR_DCCSI_DEV_MODE from azpy.constants import ENVAR_DCCSI_LOGLEVEL +from azpy.constants import ENVAR_DCCSI_GDEBUGGER from azpy.constants import FRMT_LOG_LONG -# set up global space, logging etc. -# set these true if you want them set globally for debugging +from azpy.env_bool import env_bool _DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) _DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) -_DCCSI_LOGLEVEL = int(env_bool(ENVAR_DCCSI_LOGLEVEL, int(20))) -if _DCCSI_GDEBUG: - _DCCSI_LOGLEVEL = int(10) +_DCCSI_GDEBUGGER = env_bool(ENVAR_DCCSI_GDEBUGGER, 'WING') -_logging.basicConfig(format=FRMT_LOG_LONG, level=_DCCSI_LOGLEVEL) +# default loglevel to info unless set +_DCCSI_LOGLEVEL = int(env_bool(ENVAR_DCCSI_LOGLEVEL, _logging.INFO)) +if _DCCSI_GDEBUG: + # override loglevel if runnign debug + _DCCSI_LOGLEVEL = _logging.DEBUG + +# set up module logging +#for handler in _logging.root.handlers[:]: + #_logging.root.removeHandler(handler) + +# configure basic logger +# note: not using a common logger to reduce cyclical imports +_logging.basicConfig(level=_DCCSI_LOGLEVEL, + format=FRMT_LOG_LONG, + datefmt='%m-%d %H:%M') + +_LOGGER = _logging.getLogger(_MODULENAME) _LOGGER.debug('Initializing: {0}.'.format({_MODULENAME})) # ------------------------------------------------------------------------- +# ------------------------------------------------------------------------- +def attach_debugger(): + from azpy.test.entry_test import connect_wing + _debugger = connect_wing() + return _debugger +# ------------------------------------------------------------------------- + + # ------------------------------------------------------------------------- # _settings.setenv() # doing this will add the additional DYNACONF_ envars -def get_dccsi_config(DCCSI_PATH=_DCCSI_PATH): +import importlib.util +def get_dccsi_config(PATH_DCCSIG=_PATH_DCCSIG): """Convenience method to set and retreive settings directly from module.""" # we can go ahead and just make sure the the DCCsi env is set # _config is SO generic this ensures we are importing a specific one _spec_dccsi_config = importlib.util.spec_from_file_location("dccsi._config", - Path(DCCSI_PATH, + Path(PATH_DCCSIG, "config.py")) _dccsi_config = importlib.util.module_from_spec(_spec_dccsi_config) _spec_dccsi_config.loader.exec_module(_dccsi_config) @@ -89,114 +103,205 @@ def get_dccsi_config(DCCSI_PATH=_DCCSI_PATH): return _dccsi_config # ------------------------------------------------------------------------- -# set and retreive the base env context/_settings on import -_config = get_dccsi_config() -_settings = _config.get_config_settings() +# ------------------------------------------------------------------------- +# bootstrap in AssetProcessor +def bootstrap_Editor(test_config=_DCCSI_GDEBUG, + test_pyside2=_DCCSI_GDEBUG): + '''Put boostrapping code here to execute in O3DE Editor.exe''' + + _settings = None + + if test_config: + # set and retreive the base env context/_settings on import + _config = get_dccsi_config() + _settings = _config.get_config_settings(enable_o3de_python=True, + enable_o3de_pyside2=True) + # note: this can impact start up times so currently we are only + # running it to test. + # To Do: slim down start up times so we can init _settings + + if test_pyside2: + _config.test_pyside2() + + return _settings +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +# bootstrap in AssetProcessor +def bootstrap_MaterialEditor(): + '''Put boostrapping code here to execute in O3DE MaterialEdito.exe''' + pass + return None +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +# bootstrap in AssetProcessor +def bootstrap_AssetProcessor(): + '''Put boostrapping code here to execute in O3DE AssetProcessor.exe''' + pass + return None +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +# bootstrap in AssetProcessor +def bootstrap_AssetBuilder(): + '''Put boostrapping code here to execute in O3DE AssetBuilder.exe''' + pass + return None +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- if _DCCSI_DEV_MODE: - _config.attach_debugger() # attempts to start debugger -# done with basic setup -# --- END ----------------------------------------------------------------- + foo = attach_debugger() # attempts to start debugger + +# set and retreive the *basic* env context/_settings on import +# What application is executing the bootstrap? +# Python is being run from: +# editor.exe +# materialeditor.exe +# assetprocessor.exe +# assetbuilder.exe, or the Python executable. +# Exclude the .exe so it works on other platforms + +_O3DE_Editor = Path(sys.executable) +_LOGGER.debug(f'The sys.executable is: {_O3DE_Editor}') + +if _O3DE_Editor.stem.lower() == "editor": + # if _DCCSI_GDEBUG then run the pyside2 test + _settings = bootstrap_Editor(_DCCSI_GDEBUG) + +elif _O3DE_Editor.stem.lower() == "materialeditor": + _settings = bootstrap_MaterialEditor() + +elif _O3DE_Editor.stem.lower() == "assetprocessor": + _settings = bootstrap_AssetProcessor() + +elif _O3DE_Editor.stem.lower() == "assetbuilder": + _settings= bootstrap_AssetBuilder() + +elif _O3DE_Editor.stem.lower() == "python": + # in this case, we can re-use the editor settings + # which will init python and pyside2 access externally + _settings= bootstrap_Editor(_DCCSI_GDEBUG) + +else: + _LOGGER.warning('No bootstrapping code for: {_O3DE_Editor}') +# ------------------------------------------------------------------------- ########################################################################### # Main Code Block, runs this script as main (testing) # ------------------------------------------------------------------------- if __name__ == '__main__': - """Run this file as main""" + """Run this file as main (external commandline for testing)""" + # --------------------------------------------------------------------- + # force enable debug settings manually + _DCCSI_GDEBUG = False # enable here to force temporarily + _DCCSI_DEV_MODE = False + if _DCCSI_GDEBUG: + # override loglevel if runnign debug + _DCCSI_LOGLEVEL = _logging.DEBUG + # --------------------------------------------------------------------- - # ------------------------------------------------------------------------- + + # --------------------------------------------------------------------- _O3DE_RUNNING=None try: import azlmbr _O3DE_RUNNING=True except: _O3DE_RUNNING=False - # ------------------------------------------------------------------------- + # --------------------------------------------------------------------- - _MODULENAME = __name__ - if _MODULENAME is '__main__': - _MODULENAME = 'O3DE.DCCsi.bootstrap' - - from azpy.constants import STR_CROSSBAR - # module internal debugging flags - while 0: # temp internal debug flag - _DCCSI_GDEBUG = True - break - - # overide logger for standalone to be more verbose and log to file - import azpy - _LOGGER = azpy.initialize_logger(_MODULENAME, - log_to_file=_DCCSI_GDEBUG, - default_log_level=_DCCSI_LOGLEVEL) - # happy print - _LOGGER.info(STR_CROSSBAR) - _LOGGER.info('~ constants.py ... Running script as __main__') - _LOGGER.info(STR_CROSSBAR) - - # parse the command line args - import argparse - parser = argparse.ArgumentParser( - description='O3DE DCCsi Boostrap (Test)', - epilog="Will externally test the DCCsi boostrap") - - _config = get_dccsi_config() - _settings = _config.get_config_settings(enable_o3de_python=True, - enable_o3de_pyside2=True) - parser.add_argument('-gd', '--global-debug', - type=bool, - required=False, - help='Enables global debug flag.') - parser.add_argument('-dm', '--developer-mode', - type=bool, - required=False, - help='Enables dev mode for early auto attaching debugger.') - parser.add_argument('-tp', '--test-pyside2', - type=bool, - required=False, - help='Runs Qt/PySide2 tests and reports.') - args = parser.parse_args() - - # easy overrides - if args.global_debug: - _DCCSI_GDEBUG = True - if args.developer_mode: - _DCCSI_DEV_MODE = True - _config.attach_debugger() # attempts to start debugger - - if _DCCSI_GDEBUG: - _LOGGER.info(f'DCCSI_PATH: {_settings.DCCSI_PATH}') - _LOGGER.info(f'DCCSI_G_DEBUG: {_settings.DCCSI_GDEBUG}') - _LOGGER.info(f'DCCSI_DEV_MODE: {_settings.DCCSI_DEV_MODE}') - - _LOGGER.info(f'DCCSI_OS_FOLDER: {_settings.DCCSI_OS_FOLDER}') - _LOGGER.info(f'O3DE_PROJECT: {_settings.O3DE_PROJECT}') - _LOGGER.info(f'O3DE_PROJECT_PATH: {_settings.O3DE_PROJECT_PATH}') - _LOGGER.info(f'O3DE_DEV: {_settings.O3DE_DEV}') - _LOGGER.info(f'O3DE_BUILD_PATH: {_settings.O3DE_BUILD_PATH}') - _LOGGER.info(f'O3DE_BIN_PATH: {_settings.O3DE_BIN_PATH}') + # --------------------------------------------------------------------- + # this is a simple commandline interface for running and testing externally + if not _O3DE_RUNNING: # external tool or commandline - _LOGGER.info(f'DCCSI_PATH: {_settings.DCCSI_PATH}') - _LOGGER.info(f'DCCSI_PYTHON_LIB_PATH: {_settings.DCCSI_PYTHON_LIB_PATH}') - _LOGGER.info(f'DCCSI_PY_BASE: {_settings.DCCSI_PY_BASE}') + # parse the command line args + import argparse + parser = argparse.ArgumentParser( + description='O3DE DCCsi Boostrap (Test)', + epilog="Will externally test the DCCsi boostrap") - if _DCCSI_GDEBUG or args.test_pyside2: - try: - import PySide2 - except: - # set up Qt/PySide2 access and test - _settings = _config.get_config_settings(enable_o3de_pyside2=True) - import PySide2 - - _LOGGER.info(f'PySide2: {PySide2}') - _LOGGER.info(f'O3DE_BIN_PATH: {_settings.O3DE_BIN_PATH}') - _LOGGER.info(f'QT_PLUGIN_PATH: {_settings.QT_PLUGIN_PATH}') - _LOGGER.info(f'QT_QPA_PLATFORM_PLUGIN_PATH: {_settings.QT_QPA_PLATFORM_PLUGIN_PATH}') + parser.add_argument('-gd', '--global-debug', + type=bool, + required=False, + help='Enables global debug flag.') + + parser.add_argument('-sd', '--set-debugger', + type=str, + required=False, + help='Default debugger: WING, others: PYCHARM, VSCODE (not yet implemented).') - _config.test_pyside2() - - if not _O3DE_RUNNING: - # return - sys.exit() + parser.add_argument('-dm', '--developer-mode', + type=bool, + required=False, + help='Enables dev mode for early auto attaching debugger.') + + parser.add_argument('-tp', '--test-pyside2', + type=bool, + required=False, + help='Runs Qt/PySide2 tests and reports.') + + args = parser.parse_args() + + # easy overrides + if args.global_debug: + _DCCSI_GDEBUG = True + _DCCSI_LOGLEVEL = _logging.DEBUG + _LOGGER.setLevel(_DCCSI_LOGLEVEL) + + if args.set_debugger: + _LOGGER.info('Setting and switching debugger type not implemented (default=WING)') + # To Do: implement debugger plugin pattern + + if args.developer_mode or _DCCSI_DEV_MODE: + _DCCSI_DEV_MODE = True + foo = attach_debugger() # attempts to start debugger + + # happy print + from azpy.constants import STR_CROSSBAR + _LOGGER.info(STR_CROSSBAR) + _LOGGER.info('~ DCCsi: bootstrap.py ... Running script as __main__') + _LOGGER.info(STR_CROSSBAR) + + _TEST_PYSIDE2 = False + if args.test_pyside2: + _TEST_PYSIDE2 = True + + _settings= bootstrap_Editor(_DCCSI_GDEBUG, _TEST_PYSIDE2) + + if _DCCSI_GDEBUG: + _LOGGER.info(f'PATH_DCCSIG: {_settings.PATH_DCCSIG}') + _LOGGER.info(f'DCCSI_G_DEBUG: {_settings.DCCSI_GDEBUG}') + _LOGGER.info(f'DCCSI_DEV_MODE: {_settings.DCCSI_DEV_MODE}') + + _LOGGER.info(f'DCCSI_OS_FOLDER: {_settings.DCCSI_OS_FOLDER}') + _LOGGER.info(f'O3DE_PROJECT: {_settings.O3DE_PROJECT}') + _LOGGER.info(f'PATH_O3DE_PROJECT: {_settings.PATH_O3DE_PROJECT}') + _LOGGER.info(f'O3DE_DEV: {_settings.O3DE_DEV}') + _LOGGER.info(f'PATH_O3DE_BUILD: {_settings.PATH_O3DE_BUILD}') + _LOGGER.info(f'PATH_O3DE_BIN: {_settings.PATH_O3DE_BIN}') + + _LOGGER.info(f'PATH_DCCSIG: {_settings.PATH_DCCSIG}') + _LOGGER.info(f'PATH_DCCSI_PYTHON_LIB: {_settings.PATH_DCCSI_PYTHON_LIB}') + _LOGGER.info(f'DCCSI_PY_BASE: {_settings.DCCSI_PY_BASE}') + + if args.test_pyside2: + _LOGGER.info(f'PySide2: {PySide2}') + _LOGGER.info(f'PATH_O3DE_BIN: {_settings.PATH_O3DE_BIN}') + _LOGGER.info(f'QT_PLUGIN_PATH: {_settings.QT_PLUGIN_PATH}') + _LOGGER.info(f'QT_QPA_PLATFORM_PLUGIN_PATH: {_settings.QT_QPA_PLATFORM_PLUGIN_PATH}') + # --------------------------------------------------------------------- + + # custom prompt + sys.ps1 = "[azpy]>>" + +_LOGGER.debug('~ DCCsi: bootstrap.py took: {} sec'.format(time.process_time() - _START)) # --- END ----------------------------------------------------------------- diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Lumberyard/Scripts/set_menu.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Lumberyard/Scripts/set_menu.py index 3ed4040550..cff4ba0b33 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Lumberyard/Scripts/set_menu.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Lumberyard/Scripts/set_menu.py @@ -118,7 +118,7 @@ def clicked_launch_sub_builder(): print(debug_msg) _LOGGER.debug(debug_msg) - _SUB_BUILDER_PATH = Path(settings.DCCSIG_PATH, + _SUB_BUILDER_PATH = Path(settings.PATH_DCCSIG, 'SDK', 'Substance', 'builder') diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/kitbash_converter/main.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/kitbash_converter/main.py index d0e9759208..198dcdb5af 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/kitbash_converter/main.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/kitbash_converter/main.py @@ -34,7 +34,7 @@ print(_config) # this is an alternative to "from dynaconf import settings" with Qt settings = _config.get_config_settings(setup_ly_pyside=True) -# app_path = Path.joinpath(settings.DCCSIG_PATH, < relative path to current script dir >).resolve() +# app_path = Path.joinpath(settings.PATH_DCCSIG, < relative path to current script dir >).resolve() # 3rd Party (we may or do provide) from box import Box @@ -507,7 +507,7 @@ class FBXConverter(QtWidgets.QDialog): _LOGGER.debug('get_material_definition, os.getcwd() is: {}'.format(os.getcwd())) # build a resolved absolute path because cwd may be unknown and change running externally - material_file = Path(settings.DCCSIG_PATH, + material_file = Path(settings.PATH_DCCSIG, 'SDK', 'Maya', 'Scripts', 'Python', 'kitbash_converter', material_file).resolve() diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/kitbash_converter/standalone.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/kitbash_converter/standalone.py index b940a0eac8..5db297755a 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/kitbash_converter/standalone.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/Python/kitbash_converter/standalone.py @@ -18,14 +18,14 @@ import site _MODULE_PATH = os.path.abspath(__file__) _DCCSIG_REL_PATH = "../../../.." -_DCCSIG_PATH = os.path.join(_MODULE_PATH, _DCCSIG_REL_PATH) -_DCCSIG_PATH = os.path.normpath(_DCCSIG_PATH) +_PATH_DCCSIG = os.path.join(_MODULE_PATH, _DCCSIG_REL_PATH) +_PATH_DCCSIG = os.path.normpath(_PATH_DCCSIG) -_DCCSIG_PATH = os.getenv('DCCSIG_PATH', - os.path.abspath(_DCCSIG_PATH)) +_PATH_DCCSIG = os.getenv('PATH_DCCSIG', + os.path.abspath(_PATH_DCCSIG)) # we don't have access yet to the DCCsi Lib\site-packages -site.addsitedir(_DCCSIG_PATH) # PYTHONPATH +site.addsitedir(_PATH_DCCSIG) # PYTHONPATH # azpy bootstrapping and extensions import azpy.config_utils diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/userSetup.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/userSetup.py index 04eb027142..ad8bc9f1a6 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/userSetup.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Maya/Scripts/userSetup.py @@ -135,14 +135,14 @@ if _DCCSI_DEV_MODE: # ------------------------------------------------------------------------- # validate access to the DCCsi and it's Lib site-packages # bootstrap site-packages by version -from azpy.constants import PATH_DCCSI_PYTHON_LIB_PATH +from azpy.constants import PATH_DCCSI_PYTHON_LIB try: - os.path.exists(PATH_DCCSI_PYTHON_LIB_PATH) - site.addsitedir(PATH_DCCSI_PYTHON_LIB_PATH) - _LOGGER.info('azpy 3rdPary site-packages: is: {0}'.format(PATH_DCCSI_PYTHON_LIB_PATH)) + os.path.exists(PATH_DCCSI_PYTHON_LIB) + site.addsitedir(PATH_DCCSI_PYTHON_LIB) + _LOGGER.info('azpy 3rdPary site-packages: is: {0}'.format(PATH_DCCSI_PYTHON_LIB)) except Exception as e: - _LOGGER.error('ERROR: {0}, {1}'.format(e, PATH_DCCSI_PYTHON_LIB_PATH)) + _LOGGER.error('ERROR: {0}, {1}'.format(e, PATH_DCCSI_PYTHON_LIB)) raise e # 3rdparty @@ -175,15 +175,15 @@ try: except Exception as e: _LOGGER.critical(_STR_ERROR_ENVAR.format(_BASE_ENVVAR_DICT[ENVAR_DCCSI_SDK_PATH])) -_O3DE_PROJECT_PATH = None +_PATH_O3DE_PROJECT = None try: - _O3DE_PROJECT_PATH = _BASE_ENVVAR_DICT[ENVAR_O3DE_PROJECT_PATH] + _PATH_O3DE_PROJECT = _BASE_ENVVAR_DICT[ENVAR_PATH_O3DE_PROJECT] except Exception as e: - _LOGGER.critical(_STR_ERROR_ENVAR.format(_BASE_ENVVAR_DICT[ENVAR_O3DE_PROJECT_PATH])) + _LOGGER.critical(_STR_ERROR_ENVAR.format(_BASE_ENVVAR_DICT[ENVAR_PATH_O3DE_PROJECT])) # check some env var tags (fail if no, likely means no proper code access) _O3DE_DEV = _BASE_ENVVAR_DICT[ENVAR_O3DE_DEV] -_O3DE_DCCSIG_PATH = _BASE_ENVVAR_DICT[ENVAR_DCCSIG_PATH] +_O3DE_PATH_DCCSIG = _BASE_ENVVAR_DICT[ENVAR_PATH_DCCSIG] _O3DE_DCCSI_LOG_PATH = _BASE_ENVVAR_DICT[ENVAR_DCCSI_LOG_PATH] _O3DE_AZPY_PATH = _BASE_ENVVAR_DICT[ENVAR_DCCSI_AZPY_PATH] # ------------------------------------------------------------------------- @@ -270,18 +270,18 @@ def post_startup(): install_fix_paths() # set the project workspace - #_O3DE_PROJECT_PATH = _BASE_ENVVAR_DICT[ENVAR_O3DE_PROJECT_PATH] - _project_workspace = os.path.join(_O3DE_PROJECT_PATH, TAG_MAYA_WORKSPACE) + #_PATH_O3DE_PROJECT = _BASE_ENVVAR_DICT[ENVAR_PATH_O3DE_PROJECT] + _project_workspace = os.path.join(_PATH_O3DE_PROJECT, TAG_MAYA_WORKSPACE) if os.path.isfile(_project_workspace): try: # load workspace - maya.cmds.workspace(_O3DE_PROJECT_PATH, openWorkspace=True) + maya.cmds.workspace(_PATH_O3DE_PROJECT, openWorkspace=True) _LOGGER.info('Loaded workspace file: {0}'.format(_project_workspace)) - maya.cmds.workspace(_O3DE_PROJECT_PATH, update=True) + maya.cmds.workspace(_PATH_O3DE_PROJECT, update=True) except Exception as e: _LOGGER.error(e) else: - _LOGGER.warning('Workspace file not found: {1}'.format(_O3DE_PROJECT_PATH)) + _LOGGER.warning('Workspace file not found: {1}'.format(_PATH_O3DE_PROJECT)) # Set up Lumberyard, maya default setting from set_defaults import set_defaults diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/bootstrap.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/bootstrap.py index f3e91b59ce..2b735c3630 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/bootstrap.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/bootstrap.py @@ -19,10 +19,10 @@ import importlib.util # if running in py2.7 we won't have access to pathlib yet until we boostrap # the DCCsi _MODULE_PATH = os.path.realpath(__file__) # To Do: what if frozen? -_DCCSIG_PATH = os.path.normpath(os.path.join(_MODULE_PATH, '../../../..')) -_DCCSIG_PATH = os.getenv('DCCSIG_PATH', _DCCSIG_PATH) -site.addsitedir(_DCCSIG_PATH) -# print(_DCCSIG_PATH) +_PATH_DCCSIG = os.path.normpath(os.path.join(_MODULE_PATH, '../../../..')) +_PATH_DCCSIG = os.getenv('PATH_DCCSIG', _PATH_DCCSIG) +site.addsitedir(_PATH_DCCSIG) +# print(_PATH_DCCSIG) # Lumberyard DCCsi site extensions from pathlib import Path @@ -46,7 +46,7 @@ _LOGGER = azpy.initialize_logger(_PACKAGENAME, log_to_file=True, default_log_level=_log_level) _LOGGER.debug('Starting up: {0}.'.format({_PACKAGENAME})) -_LOGGER.debug('_DCCSIG_PATH: {}'.format(_DCCSIG_PATH)) +_LOGGER.debug('_PATH_DCCSIG: {}'.format(_PATH_DCCSIG)) _LOGGER.debug('_G_DEBUG: {}'.format(_DCCSI_GDEBUG)) _LOGGER.debug('_DCCSI_DEV_MODE: {}'.format(_DCCSI_DEV_MODE)) @@ -59,7 +59,7 @@ if _DCCSI_DEV_MODE: # we can go ahead and just make sure the the DCCsi env is set # config is SO generic this ensures we are importing a specific one _spec_dccsi_config = importlib.util.spec_from_file_location("dccsi.config", - Path(_DCCSIG_PATH, + Path(_PATH_DCCSIG, "config.py")) _dccsi_config = importlib.util.module_from_spec(_spec_dccsi_config) _spec_dccsi_config.loader.exec_module(_dccsi_config) @@ -96,16 +96,16 @@ from azpy.constants import ENVAR_O3DE_DEV _O3DE_DEV = Path(os.getenv(ENVAR_O3DE_DEV, settings.O3DE_DEV)).resolve() -from azpy.constants import ENVAR_O3DE_PROJECT_PATH -_O3DE_PROJECT_PATH = Path(os.getenv(ENVAR_O3DE_PROJECT_PATH, - settings.O3DE_PROJECT_PATH)).resolve() +from azpy.constants import ENVAR_PATH_O3DE_PROJECT +_PATH_O3DE_PROJECT = Path(os.getenv(ENVAR_PATH_O3DE_PROJECT, + settings.PATH_O3DE_PROJECT)).resolve() from azpy.constants import ENVAR_DCCSI_SDK_PATH _DCCSI_SDK_PATH = Path(os.getenv(ENVAR_DCCSI_SDK_PATH, settings.DCCSIG_SDK_PATH)).resolve() # build some reuseable path parts for the substance builder -_PROJECT_ASSETS_PATH = Path(_O3DE_PROJECT_PATH, 'Assets').resolve() +_PROJECT_ASSETS_PATH = Path(_PATH_O3DE_PROJECT, 'Assets').resolve() _PROJECT_MATERIALS_PATH = Path(_PROJECT_ASSETS_PATH, 'Materials').resolve() # ------------------------------------------------------------------------- @@ -117,7 +117,7 @@ if __name__ == "__main__": """Run this file as main""" _LOGGER.info('_O3DE_DEV: {}'.format(_O3DE_DEV)) - _LOGGER.info('_O3DE_PROJECT_PATH: {}'.format(_O3DE_PROJECT_PATH)) + _LOGGER.info('_PATH_O3DE_PROJECT: {}'.format(_PATH_O3DE_PROJECT)) _LOGGER.info('_DCCSI_SDK_PATH: {}'.format(_DCCSI_SDK_PATH)) _LOGGER.info('_PYSBS_DIR_PATH: {}'.format(_PYSBS_DIR_PATH)) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sb_gui_main.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sb_gui_main.py index 9408b94919..688fd65e9e 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sb_gui_main.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sb_gui_main.py @@ -76,7 +76,7 @@ settings.setenv() # for standalone # log debug info about Qt/PySide2 _LOGGER.debug('QTFORPYTHON_PATH: {}'.format(settings.QTFORPYTHON_PATH)) -_LOGGER.debug('O3DE_BIN_PATH: {}'.format(settings.O3DE_BIN_PATH)) +_LOGGER.debug('PATH_O3DE_BIN: {}'.format(settings.PATH_O3DE_BIN)) _LOGGER.debug('QT_PLUGIN_PATH: {}'.format(settings.QT_PLUGIN_PATH)) _LOGGER.debug('QT_QPA_PLATFORM_PLUGIN_PATH: {}'.format(settings.QT_QPA_PLATFORM_PLUGIN_PATH)) # ------------------------------------------------------------------------- @@ -129,15 +129,15 @@ _O3DE_DEV = Path(os.getenv(ENVAR_O3DE_DEV, None)).resolve() from azpy.constants import ENVAR_O3DE_PROJECT _O3DE_PROJECT = os.getenv(ENVAR_O3DE_PROJECT, None) -from azpy.constants import ENVAR_O3DE_PROJECT_PATH -_O3DE_PROJECT_PATH = Path(os.getenv(ENVAR_O3DE_PROJECT_PATH, None)).resolve() +from azpy.constants import ENVAR_PATH_O3DE_PROJECT +_PATH_O3DE_PROJECT = Path(os.getenv(ENVAR_PATH_O3DE_PROJECT, None)).resolve() from azpy.constants import ENVAR_DCCSI_SDK_PATH _DCCSI_SDK_PATH = Path(os.getenv(ENVAR_DCCSI_SDK_PATH, None)).resolve() # build some reuseable path parts -_PROJECT_ASSET_PATH = Path(_O3DE_PROJECT_PATH).resolve() -_PROJECT_ASSETS_PATH = Path(_O3DE_PROJECT_PATH, 'Materials').resolve() +_PROJECT_ASSET_PATH = Path(_PATH_O3DE_PROJECT).resolve() +_PROJECT_ASSETS_PATH = Path(_PATH_O3DE_PROJECT, 'Materials').resolve() # To Do: figure out a proper way to deal with Lumberyard game projects _GEM_MATPLAY_PATH = Path(_O3DE_DEV, 'Gems', 'AtomContent', 'AtomMaterialPlayground').resolve() @@ -150,9 +150,9 @@ _SUB_LIBRARY_PATH = Path(_GEM_SUBSOURCELIBRARY, 'Assets', 'SubstanceSource', 'Li # path to watcher script _WATCHER_SCRIPT_PATH = Path(_DCCSI_SDK_PATH, 'substance', 'builder', 'watchdog', '__init__.py').resolve() -_TEX_RNDR_PATH = Path(_O3DE_PROJECT_PATH, 'Materials', 'Substance').resolve() -_MAT_OUTPUT_PATH = Path(_O3DE_PROJECT_PATH, 'Materials', 'Substance').resolve() -_SBSAR_COOK_PATH = Path(_O3DE_PROJECT_PATH, 'Materials', 'Substance').resolve() +_TEX_RNDR_PATH = Path(_PATH_O3DE_PROJECT, 'Materials', 'Substance').resolve() +_MAT_OUTPUT_PATH = Path(_PATH_O3DE_PROJECT, 'Materials', 'Substance').resolve() +_SBSAR_COOK_PATH = Path(_PATH_O3DE_PROJECT, 'Materials', 'Substance').resolve() # ------------------------------------------------------------------------- @@ -171,12 +171,12 @@ class Window(QtWidgets.QDialog): # we should really init non-Qt stuff and set things up as properties if project_path is None: - self.project_path = str(_O3DE_PROJECT_PATH) + self.project_path = str(_PATH_O3DE_PROJECT) else: self.project_path = Path(project_path) if default_material_path is None: - self._default_material_path = Path(_DCCSIG_PATH, + self._default_material_path = Path(_PATH_DCCSIG, 'sdk', 'substance', 'resources', @@ -672,7 +672,7 @@ class Window(QtWidgets.QDialog): # if you want relative paths here is a better way # first of all, assume we know the project we are in - #_O3DE_PROJECT_PATH + #_PATH_O3DE_PROJECT texture_output_path = Path(self.texRenderPathComboBox.currentText()).resolve() rel_tex_path = None @@ -928,7 +928,7 @@ def substance_builder_launcher(): _LOGGER.info('file: {}'.format(__file__)) # *might* come back relative # we should ensure we know the abs path - qss_filepath = Path(_DCCSIG_PATH).resolve().absolute() + qss_filepath = Path(_PATH_DCCSIG).resolve().absolute() qss_filepath = Path(qss_filepath, 'SDK', 'substance', 'builder', 'ui', 'stylesheets', 'LYstyle.qss').resolve().absolute() window.setStyleSheet(qss_filepath.read_text()) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbs_to_sbsar.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbs_to_sbsar.py index 441110b8d4..e091849d23 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbs_to_sbsar.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbs_to_sbsar.py @@ -67,11 +67,11 @@ from collections import OrderedDict _SYNTH_ENV_DICT = OrderedDict() _SYNTH_ENV_DICT = azpy.synthetic_env.stash_env(_SYNTH_ENV_DICT) # grab a specific path from the base_env -_PATH_DCCSI = _SYNTH_ENV_DICT[ENVAR_DCCSIG_PATH] -_O3DE_PROJECT_PATH = _SYNTH_ENV_DICT[ENVAR_O3DE_PROJECT_PATH] +_PATH_DCCSI = _SYNTH_ENV_DICT[ENVAR_PATH_DCCSIG] +_PATH_O3DE_PROJECT = _SYNTH_ENV_DICT[ENVAR_PATH_O3DE_PROJECT] # build some reuseable path parts -_PATH_MOCK_ASSETS = Path(_O3DE_PROJECT_PATH, 'Assets').norm() +_PATH_MOCK_ASSETS = Path(_PATH_O3DE_PROJECT, 'Assets').norm() _PATH_MOCK_SUBLIB = Path(_PATH_MOCK_ASSETS, 'SubstanceSource').norm() _PATH_MOCK_SBS = Path(_PATH_MOCK_SUBLIB, 'sbs').norm() diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbsar_info.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbsar_info.py index 9652b8990a..be1dbbe165 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbsar_info.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbsar_info.py @@ -87,11 +87,11 @@ from collections import OrderedDict _SYNTH_ENV_DICT = OrderedDict() _SYNTH_ENV_DICT = azpy.synthetic_env.stash_env(_SYNTH_ENV_DICT) # grab a specific path from the base_env -_PATH_DCCSI = _SYNTH_ENV_DICT[ENVAR_DCCSIG_PATH] -_O3DE_PROJECT_PATH = _SYNTH_ENV_DICT[ENVAR_O3DE_PROJECT_PATH] +_PATH_DCCSI = _SYNTH_ENV_DICT[ENVAR_PATH_DCCSIG] +_PATH_O3DE_PROJECT = _SYNTH_ENV_DICT[ENVAR_PATH_O3DE_PROJECT] # build some reuseable path parts -_PATH_MOCK_ASSETS = Path(_O3DE_PROJECT_PATH, 'Assets').norm() +_PATH_MOCK_ASSETS = Path(_PATH_O3DE_PROJECT, 'Assets').norm() _PATH_MOCK_SUBLIB = Path(_PATH_MOCK_ASSETS, 'SubstanceSource').norm() _PATH_MOCK_SBS = Path(_PATH_MOCK_SUBLIB, 'sbs').norm() diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbsar_render.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbsar_render.py index 6285ea0335..a19343dc99 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbsar_render.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbsar_render.py @@ -65,11 +65,11 @@ from collections import OrderedDict _SYNTH_ENV_DICT = OrderedDict() _SYNTH_ENV_DICT = azpy.synthetic_env.stash_env(_SYNTH_ENV_DICT) # grab a specific path from the base_env -_PATH_DCCSI = _SYNTH_ENV_DICT[ENVAR_DCCSIG_PATH] -_O3DE_PROJECT_PATH = _SYNTH_ENV_DICT[ENVAR_O3DE_PROJECT_PATH] +_PATH_DCCSI = _SYNTH_ENV_DICT[ENVAR_PATH_DCCSIG] +_PATH_O3DE_PROJECT = _SYNTH_ENV_DICT[ENVAR_PATH_O3DE_PROJECT] # build some reuseable path parts -_PATH_MOCK_ASSETS = Path(_O3DE_PROJECT_PATH, 'Assets').norm() +_PATH_MOCK_ASSETS = Path(_PATH_O3DE_PROJECT, 'Assets').norm() _PATH_MOCK_SUBLIB = Path(_PATH_MOCK_ASSETS, 'SubstanceSource').norm() _PATH_MOCK_SBS = Path(_PATH_MOCK_SUBLIB, 'sbs').norm() diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbsar_utils.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbsar_utils.py index 8ffdf30e35..bfcc65b676 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbsar_utils.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/sbsar_utils.py @@ -189,16 +189,16 @@ if __name__ == "__main__": from azpy import synthetic_env _SYNTH_ENV_DICT = synthetic_env.stash_env() - from azpy.constants import ENVAR_DCCSIG_PATH - from azpy.constants import ENVAR_O3DE_PROJECT_PATH + from azpy.constants import ENVAR_PATH_DCCSIG + from azpy.constants import ENVAR_PATH_O3DE_PROJECT # grab a specific path from the base_env - _PATH_DCCSI = _SYNTH_ENV_DICT[ENVAR_DCCSIG_PATH] + _PATH_DCCSI = _SYNTH_ENV_DICT[ENVAR_PATH_DCCSIG] # use DCCsi as the project path for this test - _O3DE_PROJECT_PATH = _PATH_DCCSI + _PATH_O3DE_PROJECT = _PATH_DCCSI - _PROJECT_ASSETS_PATH = Path(_O3DE_PROJECT_PATH, 'Assets').resolve() + _PROJECT_ASSETS_PATH = Path(_PATH_O3DE_PROJECT, 'Assets').resolve() _PROJECT_MATERIALS_PATH = Path(_PROJECT_ASSETS_PATH, 'Materials').resolve() # this will combine two parts into a single path (object) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/substance_tools.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/substance_tools.py index 0407a1db08..cea6522e83 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/substance_tools.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/substance_tools.py @@ -66,11 +66,11 @@ from collections import OrderedDict _SYNTH_ENV_DICT = OrderedDict() _SYNTH_ENV_DICT = azpy.synthetic_env.stash_env(_SYNTH_ENV_DICT) # grab a specific path from the base_env -_PATH_DCCSI = _SYNTH_ENV_DICT[ENVAR_DCCSIG_PATH] -_O3DE_PROJECT_PATH = _SYNTH_ENV_DICT[ENVAR_O3DE_PROJECT_PATH] +_PATH_DCCSI = _SYNTH_ENV_DICT[ENVAR_PATH_DCCSIG] +_PATH_O3DE_PROJECT = _SYNTH_ENV_DICT[ENVAR_PATH_O3DE_PROJECT] # build some reuseable path parts -_PATH_MOCK_ASSETS = Path(_O3DE_PROJECT_PATH, 'Assets').norm() +_PATH_MOCK_ASSETS = Path(_PATH_O3DE_PROJECT, 'Assets').norm() _PATH_MOCK_SUBLIB = Path(_PATH_MOCK_ASSETS, 'SubstanceSource').norm() _PATH_MOCK_SBS = Path(_PATH_MOCK_SUBLIB, 'sbs').norm() diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/watchdog/__init__.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/watchdog/__init__.py index 35c970e711..51beb48f3b 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/watchdog/__init__.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/SDK/Substance/builder/watchdog/__init__.py @@ -17,9 +17,9 @@ import time # ------------------------------------------------------------------------- # we don't have access yet to the DCCsi Lib\site-packages # (1) this will give us import access to dccsi and azpy import -_DCCSIG_PATH = os.getenv('DCCSIG_PATH', os.getcwd()) # always?, doubtful +_PATH_DCCSIG = os.getenv('PATH_DCCSIG', os.getcwd()) # always?, doubtful # ^^ this assume that the \DccScriptingInterface is the cwd!!! (launch there) -site.addsitedir(_DCCSIG_PATH) +site.addsitedir(_PATH_DCCSIG) # Lumberyard extensions from azpy.env_bool import env_bool @@ -72,7 +72,7 @@ from collections import OrderedDict _SYNTH_ENV_DICT = OrderedDict() _SYNTH_ENV_DICT = azpy.synthetic_env.stash_env(_SYNTH_ENV_DICT) _O3DE_DEV = _SYNTH_ENV_DICT[ENVAR_O3DE_DEV] -_O3DE_PROJECT_PATH = _SYNTH_ENV_DICT[ENVAR_O3DE_PROJECT_PATH] +_PATH_O3DE_PROJECT = _SYNTH_ENV_DICT[ENVAR_PATH_O3DE_PROJECT] # ------------------------------------------------------------------------- @@ -90,7 +90,7 @@ class MyHandler(PatternMatchingEventHandler): """ self.outputName = event.src_path.split(".sbsar")[0].split("/")[-1] self.outputCookPath = event.src_path.split(self.outputName) - self.outputRenderPath = Path(_O3DE_PROJECT_PATH, 'Assets', 'Textures', 'Substance').norm() + self.outputRenderPath = Path(_PATH_O3DE_PROJECT, 'Assets', 'Textures', 'Substance').norm() _LOGGER.debug(self.outputCookPath, self.outputName, self.outputRenderPath) pysbs_batch.sbsrender_info(input=event.src_path) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/userSetup.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/userSetup.py index c68eb8d256..b08e79df2e 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/userSetup.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/DCC/Maya/Scripts/userSetup.py @@ -137,14 +137,14 @@ if _DCCSI_DEV_MODE: # ------------------------------------------------------------------------- # validate access to the DCCsi and it's Lib site-packages # bootstrap site-packages by version -from azpy.constants import PATH_DCCSI_PYTHON_LIB_PATH +from azpy.constants import PATH_DCCSI_PYTHON_LIB try: - os.path.exists(PATH_DCCSI_PYTHON_LIB_PATH) - site.addsitedir(PATH_DCCSI_PYTHON_LIB_PATH) - _LOGGER.info('azpy 3rdPary site-packages: is: {0}'.format(PATH_DCCSI_PYTHON_LIB_PATH)) + os.path.exists(PATH_DCCSI_PYTHON_LIB) + site.addsitedir(PATH_DCCSI_PYTHON_LIB) + _LOGGER.info('azpy 3rdPary site-packages: is: {0}'.format(PATH_DCCSI_PYTHON_LIB)) except Exception as e: - _LOGGER.error('ERROR: {0}, {1}'.format(e, PATH_DCCSI_PYTHON_LIB_PATH)) + _LOGGER.error('ERROR: {0}, {1}'.format(e, PATH_DCCSI_PYTHON_LIB)) raise e # 3rdparty @@ -171,22 +171,22 @@ _LOGGER.info('_MODULENAME: {}'.format(_MODULENAME)) # ------------------------------------------------------------------------- # check some env var tags (fail if no, likely means no proper code access) _STR_ERROR_ENVAR = "Envar 'key' does not exist in base_env: {0}" -_DCCSI_TOOLS_PATH = None +_PATH_DCCSI_TOOLS = None # To Do: needs to be updated to use dynaconf and config.py try: - _DCCSI_TOOLS_PATH = _BASE_ENVVAR_DICT[ENVAR_DCCSI_TOOLS_PATH] + _PATH_DCCSI_TOOLS = _BASE_ENVVAR_DICT[ENVAR_PATH_DCCSI_TOOLS] except Exception as e: - _LOGGER.critical(_STR_ERROR_ENVAR.format(_BASE_ENVVAR_DICT[ENVAR_DCCSI_TOOLS_PATH])) + _LOGGER.critical(_STR_ERROR_ENVAR.format(_BASE_ENVVAR_DICT[ENVAR_PATH_DCCSI_TOOLS])) -_O3DE_PROJECT_PATH = None +_PATH_O3DE_PROJECT = None try: - _O3DE_PROJECT_PATH = _BASE_ENVVAR_DICT[ENVAR_O3DE_PROJECT_PATH] + _PATH_O3DE_PROJECT = _BASE_ENVVAR_DICT[ENVAR_PATH_O3DE_PROJECT] except Exception as e: - _LOGGER.critical(_STR_ERROR_ENVAR.format(_BASE_ENVVAR_DICT[ENVAR_O3DE_PROJECT_PATH])) + _LOGGER.critical(_STR_ERROR_ENVAR.format(_BASE_ENVVAR_DICT[ENVAR_PATH_O3DE_PROJECT])) # check some env var tags (fail if no, likely means no proper code access) _O3DE_DEV = _BASE_ENVVAR_DICT[ENVAR_O3DE_DEV] -_O3DE_DCCSIG_PATH = _BASE_ENVVAR_DICT[ENVAR_DCCSIG_PATH] +_O3DE_PATH_DCCSIG = _BASE_ENVVAR_DICT[ENVAR_PATH_DCCSIG] _O3DE_DCCSI_LOG_PATH = _BASE_ENVVAR_DICT[ENVAR_DCCSI_LOG_PATH] _O3DE_AZPY_PATH = _BASE_ENVVAR_DICT[ENVAR_DCCSI_AZPY_PATH] # ------------------------------------------------------------------------- @@ -216,8 +216,8 @@ def startup(): # get known paths _KNOWN_PATHS = site._init_pathinfo() - if os.path.isdir(_DCCSI_TOOLS_PATH): - site.addsitedir(_DCCSI_TOOLS_PATH, _KNOWN_PATHS) + if os.path.isdir(_PATH_DCCSI_TOOLS): + site.addsitedir(_PATH_DCCSI_TOOLS, _KNOWN_PATHS) try: import azpy.test _LOGGER.info('SUCCESS, import azpy.test') @@ -273,18 +273,18 @@ def post_startup(): install_fix_paths() # set the project workspace - #_O3DE_PROJECT_PATH = _BASE_ENVVAR_DICT[ENVAR_O3DE_PROJECT_PATH] - _project_workspace = os.path.join(_O3DE_PROJECT_PATH, TAG_MAYA_WORKSPACE) + #_PATH_O3DE_PROJECT = _BASE_ENVVAR_DICT[ENVAR_PATH_O3DE_PROJECT] + _project_workspace = os.path.join(_PATH_O3DE_PROJECT, TAG_MAYA_WORKSPACE) if os.path.isfile(_project_workspace): try: # load workspace - maya.cmds.workspace(_O3DE_PROJECT_PATH, openWorkspace=True) + maya.cmds.workspace(_PATH_O3DE_PROJECT, openWorkspace=True) _LOGGER.info('Loaded workspace file: {0}'.format(_project_workspace)) - maya.cmds.workspace(_O3DE_PROJECT_PATH, update=True) + maya.cmds.workspace(_PATH_O3DE_PROJECT, update=True) except Exception as e: _LOGGER.error(e) else: - _LOGGER.warning('Workspace file not found: {1}'.format(_O3DE_PROJECT_PATH)) + _LOGGER.warning('Workspace file not found: {1}'.format(_PATH_O3DE_PROJECT)) # Set up Lumberyard, maya default setting from set_defaults import set_defaults diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Maya_2020.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/DCC/Launch_Maya_2020.bat similarity index 91% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Maya_2020.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/DCC/Launch_Maya_2020.bat index ee2ea5bf1f..230962a4e4 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Maya_2020.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/DCC/Launch_Maya_2020.bat @@ -14,15 +14,18 @@ PUSHD %~dp0 SETLOCAL ENABLEDELAYEDEXPANSION +:: if the user has set up a custom env call it +IF EXIST "%~dp0..\Env_Dev.bat" CALL %~dp0..\Env_Dev.bat + :: Default Maya and Python version set MAYA_VERSION=2020 set DCCSI_PY_VERSION_MAJOR=2 set DCCSI_PY_VERSION_MINOR=7 set DCCSI_PY_VERSION_RELEASE=11 -CALL %~dp0\Env_Core.bat -CALL %~dp0\Env_Python.bat -CALL %~dp0\Env_Maya.bat +CALL %~dp0\..\Env_Core.bat +CALL %~dp0\..\Env_Python.bat +CALL %~dp0\..\Env_Maya.bat :: ide and debugger plug set DCCSI_PY_DEFAULT=%DCCSI_PY_MAYA% @@ -32,9 +35,6 @@ set DCCSI_PY_DEFAULT=%DCCSI_PY_MAYA% set DCCSI_PY_DCCSI=%DCCSI_LAUNCHERS_PATH%Launch_mayaPy_2020.bat echo DCCSI_PY_DCCSI = %DCCSI_PY_DCCSI% -:: if the user has set up a custom env call it -IF EXIST "%~dp0Env_Dev.bat" CALL %~dp0Env_Dev.bat - echo. echo _____________________________________________________________________ echo. @@ -50,7 +50,7 @@ echo MAYA_LOCATION = %MAYA_LOCATION% echo MAYA_BIN_PATH = %MAYA_BIN_PATH% :: Change to root dir -CD /D %O3DE_PROJECT_PATH% +CD /D %PATH_O3DE_PROJECT% :: Default to the right version of Maya if we can detect it... and launch IF EXIST "%MAYA_BIN_PATH%\maya.exe" ( diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/DCC/Launch_Maya_2022.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/DCC/Launch_Maya_2022.bat new file mode 100644 index 0000000000..2ab189fb87 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/DCC/Launch_Maya_2022.bat @@ -0,0 +1,73 @@ +@echo off +REM +REM Copyright (c) Contributors to the Open 3D Engine Project. +REM For complete copyright and license terms please see the LICENSE at the root of this distribution. +REM +REM SPDX-License-Identifier: Apache-2.0 OR MIT +REM +REM + +:: Store current dir +%~d0 +cd %~dp0 +PUSHD %~dp0 + +SETLOCAL ENABLEDELAYEDEXPANSION + +:: if the user has set up a custom env call it +IF EXIST "%~dp0..\Env_Dev.bat" CALL %~dp0..\Env_Dev.bat + +:: Default Maya and Python version +set MAYA_VERSION=2022 +set DCCSI_PY_VERSION_MAJOR=3 +set DCCSI_PY_VERSION_MINOR=7 +set DCCSI_PY_VERSION_RELEASE=7 + +CALL %~dp0\..\Env_Core.bat +CALL %~dp0\..\Env_Python.bat +CALL %~dp0\..\Env_Maya.bat + +:: ide and debugger plug +set DCCSI_PY_DEFAULT=%DCCSI_PY_MAYA% + +:: Default BASE DCCsi python 3.7 location +:: Can be overridden (example, Launch_mayaPy_%MAYA_VERSION%.bat :: MayaPy.exe) +set DCCSI_PY_DCCSI=%DCCSI_LAUNCHERS_PATH%Launch_mayaPy_%MAYA_VERSION%.bat +echo DCCSI_PY_DCCSI = %DCCSI_PY_DCCSI% + +echo. +echo _____________________________________________________________________ +echo. +echo Launching Maya %MAYA_VERSION% for O3DE DCCsi... +echo _____________________________________________________________________ +echo. + +echo MAYA_VERSION = %MAYA_VERSION% +echo DCCSI_PY_VERSION_MAJOR = %DCCSI_PY_VERSION_MAJOR% +echo DCCSI_PY_VERSION_MINOR = %DCCSI_PY_VERSION_MINOR% +echo DCCSI_PY_VERSION_RELEASE = %DCCSI_PY_VERSION_RELEASE% +echo MAYA_LOCATION = %MAYA_LOCATION% +echo MAYA_BIN_PATH = %MAYA_BIN_PATH% + +:: Change to root dir +CD /D %PATH_O3DE_PROJECT% + +:: Default to the right version of Maya if we can detect it... and launch +IF EXIST "%MAYA_BIN_PATH%\maya.exe" ( + start "" "%MAYA_BIN_PATH%\maya.exe" %* +) ELSE ( + Where maya.exe 2> NUL + IF ERRORLEVEL 1 ( + echo Maya.exe could not be found + pause + ) ELSE ( + start "" Maya.exe %* + ) +) + +::ENDLOCAL + +:: Restore previous directory +POPD + +:END_OF_FILE diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_mayaPy_2020.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/DCC/Launch_mayaPy_2020.bat similarity index 87% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_mayaPy_2020.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/DCC/Launch_mayaPy_2020.bat index 33b8bc6392..cb947a9b6c 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_mayaPy_2020.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/DCC/Launch_mayaPy_2020.bat @@ -17,18 +17,18 @@ COLOR 8E cd %~dp0 PUSHD %~dp0 +:: if the user has set up a custom env call it +IF EXIST "%~dp0..\Env_Dev.bat" CALL %~dp0..\Env_Dev.bat + :: Default Maya and Python version set MAYA_VERSION=2020 set DCCSI_PY_VERSION_MAJOR=2 set DCCSI_PY_VERSION_MINOR=7 set DCCSI_PY_VERSION_RELEASE=11 -CALL %~dp0\Env_Core.bat -CALL %~dp0\Env_Python.bat -CALL %~dp0\Env_Maya.bat - -:: if the user has set up a custom env call it -IF EXIST "%~dp0Env_Dev.bat" CALL %~dp0Env_Dev.bat +CALL %~dp0\..\Env_Core.bat +CALL %~dp0\..\Env_Python.bat +CALL %~dp0\..\Env_Maya.bat :: ide and debugger plug set DCCSI_PY_DEFAULT=%DCCSI_PY_MAYA% @@ -48,7 +48,7 @@ echo MAYA_LOCATION = %MAYA_LOCATION% echo MAYA_BIN_PATH = %MAYA_BIN_PATH% :: Change to root dir -CD /D %O3DE_PROJECT_PATH% +CD /D %PATH_O3DE_PROJECT% SETLOCAL ENABLEDELAYEDEXPANSION @@ -58,10 +58,10 @@ IF EXIST "%DCCSI_PY_MAYA%" ( ) ELSE ( Where maya.exe 2> NUL IF ERRORLEVEL 1 ( - echo Maya.exe could not be found + echo MayaPy.exe could not be found pause ) ELSE ( - start "" Maya.exe %* + start "" MayaPy.exe %* ) ) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/DCC/Launch_mayaPy_2022.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/DCC/Launch_mayaPy_2022.bat new file mode 100644 index 0000000000..91b1750a3c --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/DCC/Launch_mayaPy_2022.bat @@ -0,0 +1,73 @@ +@echo off +REM +REM Copyright (c) Contributors to the Open 3D Engine Project. +REM For complete copyright and license terms please see the LICENSE at the root of this distribution. +REM +REM SPDX-License-Identifier: Apache-2.0 OR MIT +REM +REM + +:: Set up window +TITLE O3DE DCCsi Launch MayaPy +:: Use obvious color to prevent confusion (Grey with Yellow Text) +COLOR 8E + +:: Store current directory and change to environment directory so script works in any path. +%~d0 +cd %~dp0 +PUSHD %~dp0 + +:: if the user has set up a custom env call it +IF EXIST "%~dp0..\Env_Dev.bat" CALL %~dp0..\Env_Dev.bat + +:: Default Maya and Python version +set MAYA_VERSION=2022 +set DCCSI_PY_VERSION_MAJOR=3 +set DCCSI_PY_VERSION_MINOR=7 +set DCCSI_PY_VERSION_RELEASE=7 + +CALL %~dp0\..\Env_Core.bat +CALL %~dp0\..\Env_Python.bat +CALL %~dp0\..\Env_Maya.bat + +:: ide and debugger plug +set DCCSI_PY_DEFAULT=%DCCSI_PY_MAYA% + +echo. +echo _____________________________________________________________________ +echo. +echo ~ Launching O3DE DCCsi MayaPy (%MAYA_VERSION%) ... +echo ________________________________________________________________ +echo. + +echo MAYA_VERSION = %MAYA_VERSION% +echo DCCSI_PY_VERSION_MAJOR = %DCCSI_PY_VERSION_MAJOR% +echo DCCSI_PY_VERSION_MINOR = %DCCSI_PY_VERSION_MINOR% +echo DCCSI_PY_VERSION_RELEASE = %DCCSI_PY_VERSION_RELEASE% +echo MAYA_LOCATION = %MAYA_LOCATION% +echo MAYA_BIN_PATH = %MAYA_BIN_PATH% + +:: Change to root dir +CD /D %PATH_O3DE_PROJECT% + +SETLOCAL ENABLEDELAYEDEXPANSION + +:: Default to the right version of Maya if we can detect it... and launch +IF EXIST "%DCCSI_PY_MAYA%" ( + start "" "%DCCSI_PY_MAYA%" %* +) ELSE ( + Where maya.exe 2> NUL + IF ERRORLEVEL 1 ( + echo MayaPy.exe could not be found + pause + ) ELSE ( + start "" MayaPy.exe %* + ) +) + +ENDLOCAL + +:: Return to starting directory +POPD + +:END_OF_FILE diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Core.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Core.bat index b37170d605..a124c100b0 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Core.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Core.bat @@ -74,8 +74,8 @@ echo O3DE_PROJECT = %O3DE_PROJECT% :: if not set we also use the DCCsi path as stand-in CD /D ..\..\..\ :: To Do: remove one of these -IF "%O3DE_PROJECT_PATH%"=="" (set O3DE_PROJECT_PATH=%CD%) -echo O3DE_PROJECT_PATH = %O3DE_PROJECT_PATH% +IF "%PATH_O3DE_PROJECT%"=="" (set PATH_O3DE_PROJECT=%CD%) +echo PATH_O3DE_PROJECT = %PATH_O3DE_PROJECT% IF "%ABS_PATH%"=="" (set ABS_PATH=%CD%) echo ABS_PATH = %ABS_PATH% @@ -84,7 +84,7 @@ echo ABS_PATH = %ABS_PATH% pushd %ABS_PATH% :: Change to root Lumberyard dev dir -CD /d %O3DE_PROJECT_PATH%\%O3DE_REL_PATH% +CD /d %PATH_O3DE_PROJECT%\%O3DE_REL_PATH% IF "%O3DE_DEV%"=="" (set O3DE_DEV=%CD%) echo O3DE_DEV = %O3DE_DEV% :: Restore original directory @@ -92,32 +92,32 @@ popd :: dcc scripting interface gem path :: currently know relative path to this gem -set DCCSIG_PATH=%O3DE_DEV%\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface -echo DCCSIG_PATH = %DCCSIG_PATH% +set PATH_DCCSIG=%O3DE_DEV%\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface +echo PATH_DCCSIG = %PATH_DCCSIG% :: Change to DCCsi root dir -CD /D %DCCSIG_PATH% +CD /D %PATH_DCCSIG% :: per-dcc sdk path -set DCCSI_TOOLS_PATH=%DCCSIG_PATH%\Tools -echo DCCSI_TOOLS_PATH = %DCCSI_TOOLS_PATH% +set PATH_DCCSI_TOOLS=%PATH_DCCSIG%\Tools +echo PATH_DCCSI_TOOLS = %PATH_DCCSI_TOOLS% :: temp log location specific to this gem -set DCCSI_LOG_PATH=%O3DE_PROJECT_PATH%\.temp\logs +set DCCSI_LOG_PATH=%PATH_O3DE_PROJECT%\.temp\logs echo DCCSI_LOG_PATH = %DCCSI_LOG_PATH% :: O3DE build path IF "%O3DE_BUILD_FOLDER%"=="" (set O3DE_BUILD_FOLDER=build) echo O3DE_BUILD_FOLDER = %O3DE_BUILD_FOLDER% -IF "%O3DE_BUILD_PATH%"=="" (set O3DE_BUILD_PATH=%O3DE_DEV%\%O3DE_BUILD_FOLDER%) -echo O3DE_BUILD_PATH = %O3DE_BUILD_PATH% +IF "%PATH_O3DE_BUILD%"=="" (set PATH_O3DE_BUILD=%O3DE_DEV%\%O3DE_BUILD_FOLDER%) +echo PATH_O3DE_BUILD = %PATH_O3DE_BUILD% -IF "%O3DE_BIN_PATH%"=="" (set O3DE_BIN_PATH=%O3DE_BUILD_PATH%\bin\profile) -echo O3DE_BIN_PATH = %O3DE_BIN_PATH% +IF "%PATH_O3DE_BIN%"=="" (set PATH_O3DE_BIN=%PATH_O3DE_BUILD%\bin\profile) +echo PATH_O3DE_BIN = %PATH_O3DE_BIN% :: add to the PATH -SET PATH=%O3DE_BIN_PATH%;%DCCSIG_PATH%;%PATH% +SET PATH=%PATH_O3DE_BIN%;%PATH_DCCSIG%;%PATH% ::ENDLOCAL diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Dev.bat.example b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Dev.bat.example new file mode 100644 index 0000000000..ad1e429967 --- /dev/null +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Dev.bat.example @@ -0,0 +1,20 @@ +@echo off + +REM +REM Copyright (c) Contributors to the Open 3D Engine Project. +REM For complete copyright and license terms please see the LICENSE at the root of this distribution. +REM +REM SPDX-License-Identifier: Apache-2.0 OR MIT +REM +REM + +set DCCSI_CUSTOM=Foo +echo DCCSI_CUSTOM = %DCCSI_CUSTOM% + +set O3DE_BUILD_FOLDER=custom_build +echo O3DE_BUILD_FOLDER = %O3DE_BUILD_FOLDER% + +set DCCSI_GDEBUG=True +set DCCSI_DEV_MODE=True +set DCCSI_GDEBUGGER=WING +set DCCSI_LOGLEVEL=10 \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Maya.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Maya.bat index 0ed46e9400..9bed3b301b 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Maya.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Maya.bat @@ -22,12 +22,13 @@ IF "%DCCSI_ENV_MAYA_INIT%"=="1" GOTO :END_OF_FILE cd %~dp0 PUSHD %~dp0 -IF "%DCCSI_PY_VERSION_MAJOR%"=="" (set DCCSI_PY_VERSION_MAJOR=2) +:: Maya 2022: 3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 10:41:24) [MSC v.1900 64 bit (AMD64)] +IF "%DCCSI_PY_VERSION_MAJOR%"=="" (set DCCSI_PY_VERSION_MAJOR=3) IF "%DCCSI_PY_VERSION_MINOR%"=="" (set DCCSI_PY_VERSION_MINOR=7) -IF "%DCCSI_PY_VERSION_RELEASE%"=="" (set DCCSI_PY_VERSION_RELEASE=11) +IF "%DCCSI_PY_VERSION_RELEASE%"=="" (set DCCSI_PY_VERSION_RELEASE=7) :: Default Maya Version -IF "%DCCSI_MAYA_VERSION%"=="" (set DCCSI_MAYA_VERSION=2020) +IF "%MAYA_VERSION%"=="" (set MAYA_VERSION=2022) :: Initialize env CALL %~dp0\Env_Core.bat @@ -43,14 +44,14 @@ echo. echo DCCSI_PY_VERSION_MAJOR = %DCCSI_PY_VERSION_MAJOR% echo DCCSI_PY_VERSION_MINOR = %DCCSI_PY_VERSION_MINOR% echo DCCSI_PY_VERSION_RELEASE = %DCCSI_PY_VERSION_RELEASE% -echo DCCSI_MAYA_VERSION = %DCCSI_MAYA_VERSION% +echo MAYA_VERSION = %MAYA_VERSION% :::: Set Maya native project acess to this project -IF "%MAYA_PROJECT%"=="" (set MAYA_PROJECT=%O3DE_PROJECT_PATH%) +IF "%MAYA_PROJECT%"=="" (set MAYA_PROJECT=%PATH_O3DE_PROJECT%) echo MAYA_PROJECT = %MAYA_PROJECT% :: maya sdk path -set DCCSI_TOOLS_MAYA_PATH=%DCCSI_TOOLS_PATH%\DCC\Maya +set DCCSI_TOOLS_MAYA_PATH=%PATH_DCCSI_TOOLS%\DCC\Maya echo DCCSI_TOOLS_MAYA_PATH = %DCCSI_TOOLS_MAYA_PATH% set MAYA_MODULE_PATH=%DCCSI_TOOLS_MAYA_PATH%;%MAYA_MODULE_PATH% @@ -59,7 +60,7 @@ echo MAYA_MODULE_PATH = %MAYA_MODULE_PATH% :: Maya File Paths, etc :: https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2015/ENU/Maya/files/Environment-Variables-File-path-variables-htm.html :::: Set Maya native project acess to this project -IF "%MAYA_LOCATION%"=="" (set MAYA_LOCATION=%ProgramFiles%\Autodesk\Maya%DCCSI_MAYA_VERSION%) +IF "%MAYA_LOCATION%"=="" (set MAYA_LOCATION=%ProgramFiles%\Autodesk\Maya%MAYA_VERSION%) echo MAYA_LOCATION = %MAYA_LOCATION% IF "%MAYA_BIN_PATH%"=="" (set MAYA_BIN_PATH=%MAYA_LOCATION%\bin) diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_PyCharm.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_PyCharm.bat index 7be9154e6d..fbcc59d5d0 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_PyCharm.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_PyCharm.bat @@ -17,30 +17,32 @@ IF "%DCCSI_ENV_PYCHARM_INIT%"=="1" GOTO :END_OF_FILE cd %~dp0 PUSHD %~dp0 +:: version Year +IF "%PYCHARM_VERSION_YEAR%"=="" (set PYCHARM_VERSION_YEAR=2020) :: version Major -SET PYCHARM_VERSION_YEAR=2020 -:: version Major -SET PYCHARM_VERSION_MAJOR=2 +IF "%PYCHARM_VERSION_MAJOR%"=="" (set PYCHARM_VERSION_MAJOR=3) +:: version Minor +IF "%PYCHARM_VERSION_MINOR%"=="" (set PYCHARM_VERSION_MINOR=2) + +:: PyCharm install paths look something like the following and has changed from release to release ::"C:\Program Files\JetBrains\PyCharm 2019.1.3\bin" +::"C:\Program Files\JetBrains\PyCharm 2020.3.2\bin" <-- this is mine @HogJonnyAMZN ::"C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.5\bin\pycharm64.exe" +:: The version of PyCharm can be updated without altering the install path +:: You can set the envar to your local install path in the Env_Dev.bat file to override +:: C:< o3de install location >\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\Tools\Dev\Windows\Env_Dev.bat" + :: put project env variables/paths here -set PYCHARM_HOME=%PROGRAMFILES%\JetBrains\PyCharm %PYCHARM_VERSION_YEAR%.%PYCHARM_VERSION_MAJOR% +IF "%PYCHARM_HOME%"=="" (set PYCHARM_HOME=%PROGRAMFILES%\JetBrains\PyCharm %PYCHARM_VERSION_YEAR%.%PYCHARM_VERSION_MAJOR%.%PYCHARM_VERSION_MINOR%) :: Initialize env CALL %~dp0\Env_Core.bat CALL %~dp0\Env_Python.bat CALL %~dp0\Env_Qt.bat -:: Wing and other IDEs probably prefer access directly to the python.exe -set DCCSI_PY_IDE = %O3DE_PYTHON_INSTALL%\runtime\python-3.7.10-rev2-windows\python -echo DCCSI_PY_IDE = %DCCSI_PY_IDE% - -:: ide and debugger plug -set DCCSI_PY_DEFAULT=%DCCSI_PY_IDE%\python.exe - -SET PYCHARM_PROJ=%DCCSIG_PATH%\Solutions +IF "%PYCHARM_PROJ%"=="" (SET PYCHARM_PROJ=%PATH_DCCSIG%\Tools\Dev\Windows\Solutions) echo. echo _____________________________________________________________________ diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Python.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Python.bat index 388ab531df..92030f9d61 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Python.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Python.bat @@ -42,39 +42,39 @@ echo DCCSI_PY_VERSION_RELEASE = %DCCSI_PY_VERSION_RELEASE% :: shared location for 64bit python 3.7 DEV location :: this defines a DCCsi sandbox for lib site-packages by version :: \Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\3rdParty\Python\Lib -set DCCSI_PYTHON_PATH=%DCCSIG_PATH%\3rdParty\Python -echo DCCSI_PYTHON_PATH = %DCCSI_PYTHON_PATH% +set PATH_DCCSI_PYTHON=%PATH_DCCSIG%\3rdParty\Python +echo PATH_DCCSI_PYTHON = %PATH_DCCSI_PYTHON% :: add access to a Lib location that matches the py version (example: 3.7.x) :: switch this for other python versions like maya (2.7.x) -IF "%DCCSI_PYTHON_LIB_PATH%"=="" (set DCCSI_PYTHON_LIB_PATH=%DCCSI_PYTHON_PATH%\Lib\%DCCSI_PY_VERSION_MAJOR%.x\%DCCSI_PY_VERSION_MAJOR%.%DCCSI_PY_VERSION_MINOR%.x\site-packages) -echo DCCSI_PYTHON_LIB_PATH = %DCCSI_PYTHON_LIB_PATH% +IF "%PATH_DCCSI_PYTHON_LIB%"=="" (set PATH_DCCSI_PYTHON_LIB=%PATH_DCCSI_PYTHON%\Lib\%DCCSI_PY_VERSION_MAJOR%.x\%DCCSI_PY_VERSION_MAJOR%.%DCCSI_PY_VERSION_MINOR%.x\site-packages) +echo PATH_DCCSI_PYTHON_LIB = %PATH_DCCSI_PYTHON_LIB% :: add to the PATH -SET PATH=%DCCSI_PYTHON_LIB_PATH%;%PATH% +SET PATH=%PATH_DCCSI_PYTHON_LIB%;%PATH% :: shared location for default O3DE python location -set O3DE_PYTHON_INSTALL=%O3DE_DEV%\python -echo O3DE_PYTHON_INSTALL = %O3DE_PYTHON_INSTALL% +set PATH_O3DE_PYTHON_INSTALL=%O3DE_DEV%\python +echo PATH_O3DE_PYTHON_INSTALL = %PATH_O3DE_PYTHON_INSTALL% :: location for O3DE python 3.7 location :: Note, many DCC tools (like Maya) include thier own python interpretter :: Some DCC apps may not operate correctly if PYTHONHOME is set (this is definitely the case with Maya) :: Be aware the python.cmd below does set PYTHONHOME -set DCCSI_PY_BASE=%O3DE_PYTHON_INSTALL%\python.cmd +set DCCSI_PY_BASE=%PATH_O3DE_PYTHON_INSTALL%\python.cmd echo DCCSI_PY_BASE = %DCCSI_PY_BASE% -CALL %O3DE_PYTHON_INSTALL%\get_python_path.bat +CALL %PATH_O3DE_PYTHON_INSTALL%\get_python_path.bat :: Some IDEs like Wing, may in some cases need acess directly to the exe to operate correctly IF "%DCCSI_PY_IDE%"=="" (set DCCSI_PY_IDE=%O3DE_PYTHONHOME%\python.exe) echo DCCSI_PY_IDE = %DCCSI_PY_IDE% :: add to the PATH -SET PATH=%O3DE_PYTHON_INSTALL%;%O3DE_PYTHONHOME%;%DCCSI_PY_IDE%;%PATH% +SET PATH=%PATH_O3DE_PYTHON_INSTALL%;%O3DE_PYTHONHOME%;%DCCSI_PY_IDE%;%PATH% :: add all python related paths to PYTHONPATH for package imports -set PYTHONPATH=%DCCSIG_PATH%;%DCCSI_PYTHON_LIB_PATH%;%O3DE_BUILD_PATH%;%PYTHONPATH% +set PYTHONPATH=%PATH_DCCSIG%;%PATH_DCCSI_PYTHON_LIB%;%PATH_O3DE_BUILD%;%PYTHONPATH% echo PYTHONPATH = %PYTHONPATH% :: Set flag so we don't initialize dccsi environment twice diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Qt.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Qt.bat index 6202ead2f2..dff775efda 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Qt.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Qt.bat @@ -41,16 +41,16 @@ echo QTFORPYTHON_PATH = %QTFORPYTHON_PATH% SET PATH=%QTFORPYTHON_PATH%;%PATH% SET PYTHONPATH=%QTFORPYTHON_PATH%;%PYTHONPATH% -set QT_PLUGIN_PATH=%O3DE_BUILD_PATH%\bin\profile\EditorPlugins +set QT_PLUGIN_PATH=%PATH_O3DE_BUILD%\bin\profile\EditorPlugins echo QT_PLUGIN_PATH = %QT_PLUGIN_PATH% :: add to the PATH SET PATH=%QT_PLUGIN_PATH%;%PATH% SET PYTHONPATH=%QT_PLUGIN_PATH%;%PYTHONPATH% -set O3DE_BIN_PATH=%O3DE_BUILD_PATH%\bin\profile -echo O3DE_BIN_PATH = %O3DE_BIN_PATH% -SET PATH=%O3DE_BIN_PATH%;%PATH% +set PATH_O3DE_BIN=%PATH_O3DE_BUILD%\bin\profile +echo PATH_O3DE_BIN = %PATH_O3DE_BIN% +SET PATH=%PATH_O3DE_BIN%;%PATH% ::ENDLOCAL diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Substance.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Substance.bat index d44ed985da..200c8c6435 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Substance.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_Substance.bat @@ -31,16 +31,16 @@ echo. : Substance Designer :: maya sdk path -set DCCSI_SUBSTANCE_PATH=%DCCSI_TOOLS_PATH%\Substance -echo DCCSI_SUBSTANCE_PATH = %DCCSI_SUBSTANCE_PATH% +set PATH_DCCSI_SUBSTANCE=%PATH_DCCSI_TOOLS%\Substance +echo PATH_DCCSI_SUBSTANCE = %PATH_DCCSI_SUBSTANCE% :: https://docs.substance3d.com/sddoc/project-preferences-107118596.html#ProjectPreferences-ConfigurationFile :: Path to .exe, "C:\Program Files\Allegorithmic\Substance Designer\Substance Designer.exe" -set SUBSTANCE_PATH="%ProgramFiles%\Allegorithmic\Substance Designer" -echo SUBSTANCE_PATH = %SUBSTANCE_PATH% +set PATH_SUBSTANCE_DESIGNER="%ProgramFiles%\Allegorithmic\Substance Designer" +echo PATH_SUBSTANCE_DESIGNER = %PATH_SUBSTANCE_DESIGNER% :: default config -set SUBSTANCE_CFG_PATH=%O3DE_PROJECT_PATH%\DCCsi_default.sbscfg -echo SUBSTANCE_CFG_PATH = %SUBSTANCE_CFG_PATH% +IF "%PATH_SUBSTANCE_DESIGNER_CFG%"=="" (set PATH_SUBSTANCE_DESIGNER_CFG=%PATH_O3DE_PROJECT%\DCCsi_default.sbscfg) +echo PATH_SUBSTANCE_DESIGNER_CFG = %PATH_SUBSTANCE_DESIGNER_CFG% ::ENDLOCAL diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_VScode.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_VScode.bat index 960d910a54..dc4beedf7f 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_VScode.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_VScode.bat @@ -29,7 +29,7 @@ CALL %~dp0\Env_Qt.bat :: that will change the paths assumed in this launcher (assume system install) :: vscode envars: https://code.visualstudio.com/docs/editor/variables-reference -SET VSCODE_WRKSPC=%DCCSIG_PATH%\Solutions\.vscode\dccsi.code-workspace +IF "%VSCODE_WRKSPC%"=="" (SET VSCODE_WRKSPC=%PATH_DCCSIG%\Solutions\.vscode\dccsi.code-workspace) echo. echo _____________________________________________________________________ diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_WingIDE.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_WingIDE.bat index a8c3b3d073..d8ff58b575 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_WingIDE.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Env_WingIDE.bat @@ -28,8 +28,8 @@ CALL %~dp0\Env_Python.bat CALL %~dp0\Env_Qt.bat :: put project env variables/paths here -set WINGHOME=%PROGRAMFILES(X86)%\Wing Pro %DCCSI_WING_VERSION_MAJOR%.%DCCSI_WING_VERSION_MINOR% -SET WING_PROJ=%DCCSIG_PATH%\Tools\Dev\Windows\Solutions\.wing\DCCsi_%DCCSI_WING_VERSION_MAJOR%x.wpr +IF "%WINGHOME%"=="" (set WINGHOME=%PROGRAMFILES(X86)%\Wing Pro %DCCSI_WING_VERSION_MAJOR%.%DCCSI_WING_VERSION_MINOR%) +IF "%WING_PROJ%"=="" (set WING_PROJ=%PATH_DCCSIG%\Tools\Dev\Windows\Solutions\.wing\DCCsi_%DCCSI_WING_VERSION_MAJOR%x.wpr) echo. echo _____________________________________________________________________ diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_MayaPy_PyCharmPro.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/IDE/Launch_MayaPy_PyCharmPro.bat similarity index 70% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_MayaPy_PyCharmPro.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/IDE/Launch_MayaPy_PyCharmPro.bat index e451050ab8..8802b8dd54 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_MayaPy_PyCharmPro.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/IDE/Launch_MayaPy_PyCharmPro.bat @@ -19,10 +19,10 @@ PUSHD %~dp0 :: Constant Vars (Global) :: global debug (propogates) -IF "%DCCSI_GDEBUG%"=="" (set DCCSI_GDEBUG=True) +IF "%DCCSI_GDEBUG%"=="" (set DCCSI_GDEBUG=False) echo DCCSI_GDEBUG = %DCCSI_GDEBUG% :: initiates debugger connection -IF "%DCCSI_DEV_MODE%"=="" (set DCCSI_DEV_MODE=True) +IF "%DCCSI_DEV_MODE%"=="" (set DCCSI_DEV_MODE=False) echo DCCSI_DEV_MODE = %DCCSI_DEV_MODE% :: sets debugger, options: WING, PYCHARM IF "%DCCSI_GDEBUGGER%"=="" (set DCCSI_GDEBUGGER=WING) @@ -34,14 +34,17 @@ echo DCCSI_GDEBUGGER = %DCCSI_GDEBUGGER% :: INFO:20 :: DEBUG:10 :: NOTSET:0 -IF "%DCCSI_LOGLEVEL%"=="" (set DCCSI_LOGLEVEL=10) +IF "%DCCSI_LOGLEVEL%"=="" (set DCCSI_LOGLEVEL=20) echo DCCSI_LOGLEVEL = %DCCSI_LOGLEVEL% +:: if the user has set up a custom env call it +IF EXIST "%~dp0..\Env_Dev.bat" CALL %~dp0..\Env_Dev.bat + :: Initialize env -CALL %~dp0\Env_Core.bat -CALL %~dp0\Env_Python.bat -CALL %~dp0\Env_PyCharm.bat -CALL %~dp0\Env_Maya.bat +CALL %~dp0..\Env_Core.bat +CALL %~dp0..\Env_Python.bat +CALL %~dp0..\Env_PyCharm.bat +CALL %~dp0..\Env_Maya.bat set DCCSI_PY_DEFAULT=%DCCSI_PY_MAYA% @@ -58,29 +61,14 @@ echo. echo O3DE_DEV = %O3DE_DEV% -:: shared location for default O3DE python location -set O3DE_PYTHON_INSTALL=%O3DE_DEV%\Python -echo O3DE_PYTHON_INSTALL = %O3DE_PYTHON_INSTALL% - -:: Wing and other IDEs probably prefer access directly to the python.exe -set DCCSI_PY_IDE = %O3DE_PYTHON_INSTALL%\runtime\python-3.7.10-rev2-windows\python -echo DCCSI_PY_IDE = %DCCSI_PY_IDE% - -:: ide and debugger plug -set DCCSI_PY_BASE=%DCCSI_PY_IDE%\python.exe -echo DCCSI_PY_BASE = %DCCSI_PY_BASE% - :: ide and debugger plug set DCCSI_PY_DEFAULT=%DCCSI_PY_MAYA% echo DCCSI_PY_DEFAULT = %DCCSI_PY_DEFAULT% -:: if the user has set up a custom env call it -IF EXIST "%~dp0Env_Dev.bat" CALL %~dp0Env_Dev.bat - echo. :: Change to root dir -CD /D %O3DE_PROJECT_PATH% +CD /D %PATH_O3DE_PROJECT% IF EXIST "%PYCHARM_HOME%\bin\pycharm64.exe" ( start "" "%PYCHARM_HOME%\bin\pycharm64.exe" "%PYCHARM_PROJ%" diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_PyCharmPro.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/IDE/Launch_PyCharmPro.bat similarity index 83% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_PyCharmPro.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/IDE/Launch_PyCharmPro.bat index 4b9edb9e50..849cda7a19 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_PyCharmPro.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/IDE/Launch_PyCharmPro.bat @@ -19,13 +19,13 @@ PUSHD %~dp0 :: Constant Vars (Global) :: global debug (propogates) -IF "%DCCSI_GDEBUG%"=="" (set DCCSI_GDEBUG=True) +IF "%DCCSI_GDEBUG%"=="" (set DCCSI_GDEBUG=False) echo DCCSI_GDEBUG = %DCCSI_GDEBUG% :: initiates debugger connection -IF "%DCCSI_DEV_MODE%"=="" (set DCCSI_DEV_MODE=True) +IF "%DCCSI_DEV_MODE%"=="" (set DCCSI_DEV_MODE=False) echo DCCSI_DEV_MODE = %DCCSI_DEV_MODE% :: sets debugger, options: WING, PYCHARM -IF "%DCCSI_GDEBUGGER%"=="" (set DCCSI_GDEBUGGER=WING) +IF "%DCCSI_GDEBUGGER%"=="" (set DCCSI_GDEBUGGER=PYCHARM) echo DCCSI_GDEBUGGER = %DCCSI_GDEBUGGER% :: Default level logger will handle :: CRITICAL:50 @@ -34,14 +34,14 @@ echo DCCSI_GDEBUGGER = %DCCSI_GDEBUGGER% :: INFO:20 :: DEBUG:10 :: NOTSET:0 -IF "%DCCSI_LOGLEVEL%"=="" (set DCCSI_LOGLEVEL=10) +IF "%DCCSI_LOGLEVEL%"=="" (set DCCSI_LOGLEVEL=20) echo DCCSI_LOGLEVEL = %DCCSI_LOGLEVEL% -:: Initialize env -CALL %~dp0\Env_PyCharm.bat - :: if the user has set up a custom env call it -IF EXIST "%~dp0Env_Dev.bat" CALL %~dp0Env_Dev.bat +IF EXIST "%~dp0..\Env_Dev.bat" CALL %~dp0..\Env_Dev.bat + +:: Initialize env +CALL %~dp0\..\Env_PyCharm.bat echo. echo _____________________________________________________________________ diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_VScode.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/IDE/Launch_VScode.bat similarity index 79% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_VScode.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/IDE/Launch_VScode.bat index 2dc5b06032..8f978e0830 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_VScode.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/IDE/Launch_VScode.bat @@ -29,10 +29,10 @@ PUSHD %~dp0 :: Constant Vars (Global) :: global debug (propogates) -IF "%DCCSI_GDEBUG%"=="" (set DCCSI_GDEBUG=True) +IF "%DCCSI_GDEBUG%"=="" (set DCCSI_GDEBUG=False) echo DCCSI_GDEBUG = %DCCSI_GDEBUG% :: initiates debugger connection -IF "%DCCSI_DEV_MODE%"=="" (set DCCSI_DEV_MODE=True) +IF "%DCCSI_DEV_MODE%"=="" (set DCCSI_DEV_MODE=False) echo DCCSI_DEV_MODE = %DCCSI_DEV_MODE% :: sets debugger, options: WING, PYCHARM IF "%DCCSI_GDEBUGGER%"=="" (set DCCSI_GDEBUGGER=WING) @@ -44,15 +44,19 @@ echo DCCSI_GDEBUGGER = %DCCSI_GDEBUGGER% :: INFO:20 :: DEBUG:10 :: NOTSET:0 -IF "%DCCSI_LOGLEVEL%"=="" (set DCCSI_LOGLEVEL=10) +IF "%DCCSI_LOGLEVEL%"=="" (set DCCSI_LOGLEVEL=20) echo DCCSI_LOGLEVEL = %DCCSI_LOGLEVEL% -:: Initialize envCALL %~dp0\Env_Core.bat -CALL %~dp0\Env_Python.bat -CALL %~dp0\Env_Qt.bat -CALL %~dp0\Env_Maya.bat -CALL %~dp0\Env_Substance.bat -CALL %~dp0\Env_VScode.bat +:: if the user has set up a custom env call it +IF EXIST "%~dp0..\Env_Dev.bat" CALL %~dp0..\Env_Dev.bat + +:: Initialize env +CALL %~dp0\..\Env_Core.bat +CALL %~dp0\..\Env_Python.bat +CALL %~dp0\..\Env_Qt.bat +CALL %~dp0\..\Env_Maya.bat +CALL %~dp0\..\Env_Substance.bat +CALL %~dp0\..\Env_VScode.bat echo. echo _____________________________________________________________________ @@ -64,11 +68,11 @@ echo. echo O3DE_DEV = %O3DE_DEV% :: shared location for default O3DE python location -set O3DE_PYTHON_INSTALL=%O3DE_DEV%\Python -echo O3DE_PYTHON_INSTALL = %O3DE_PYTHON_INSTALL% +set PATH_O3DE_PYTHON_INSTALL=%O3DE_DEV%\Python +echo PATH_O3DE_PYTHON_INSTALL = %PATH_O3DE_PYTHON_INSTALL% :: Wing and other IDEs probably prefer access directly to the python.exe -set DCCSI_PY_IDE = %O3DE_PYTHON_INSTALL%\runtime\python-3.7.10-rev2-windows\python +set DCCSI_PY_IDE = %PATH_O3DE_PYTHON_INSTALL%\runtime\python-3.7.10-rev2-windows\python echo DCCSI_PY_IDE = %DCCSI_PY_IDE% :: ide and debugger plug @@ -79,9 +83,6 @@ echo DCCSI_PY_BASE = %DCCSI_PY_BASE% set DCCSI_PY_DEFAULT=%DCCSI_PY_BASE% echo DCCSI_PY_DEFAULT = %DCCSI_PY_DEFAULT% -:: if the user has set up a custom env call it -IF EXIST "%~dp0Env_Dev.bat" CALL %~dp0Env_Dev.bat - echo. REM "C:\Program Files\Microsoft VS Code\Code.exe" diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_WingIDE-7-1.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/IDE/Launch_WingIDE-7-1.bat similarity index 77% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_WingIDE-7-1.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/IDE/Launch_WingIDE-7-1.bat index 56e278da08..5330dcd941 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_WingIDE-7-1.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/IDE/Launch_WingIDE-7-1.bat @@ -21,14 +21,14 @@ cd %~dp0 PUSHD %~dp0 :: if the user has set up a custom env call it -IF EXIST "%~dp0Env_Dev.bat" CALL %~dp0Env_Dev.bat +IF EXIST "%~dp0..\Env_Dev.bat" CALL %~dp0..\Env_Dev.bat :: Constant Vars (Global) :: global debug (propogates) -IF "%DCCSI_GDEBUG%"=="" (set DCCSI_GDEBUG=True) +IF "%DCCSI_GDEBUG%"=="" (set DCCSI_GDEBUG=False) echo DCCSI_GDEBUG = %DCCSI_GDEBUG% :: initiates debugger connection -IF "%DCCSI_DEV_MODE%"=="" (set DCCSI_DEV_MODE=True) +IF "%DCCSI_DEV_MODE%"=="" (set DCCSI_DEV_MODE=False) echo DCCSI_DEV_MODE = %DCCSI_DEV_MODE% :: sets debugger, options: WING, PYCHARM IF "%DCCSI_GDEBUGGER%"=="" (set DCCSI_GDEBUGGER=WING) @@ -40,16 +40,16 @@ echo DCCSI_GDEBUGGER = %DCCSI_GDEBUGGER% :: INFO:20 :: DEBUG:10 :: NOTSET:0 -IF "%DCCSI_LOGLEVEL%"=="" (set DCCSI_LOGLEVEL=10) +IF "%DCCSI_LOGLEVEL%"=="" (set DCCSI_LOGLEVEL=20) echo DCCSI_LOGLEVEL = %DCCSI_LOGLEVEL% :: Initialize env -CALL %~dp0\Env_Core.bat -CALL %~dp0\Env_Python.bat -CALL %~dp0\Env_Qt.bat -CALL %~dp0\Env_Maya.bat -CALL %~dp0\Env_Substance.bat -CALL %~dp0\Env_WingIDE.bat +CALL %~dp0\..\Env_Core.bat +CALL %~dp0\..\Env_Python.bat +CALL %~dp0\..\Env_Qt.bat +CALL %~dp0\..\Env_Maya.bat +CALL %~dp0\..\Env_Substance.bat +CALL %~dp0\..\Env_WingIDE.bat echo. echo _____________________________________________________________________ echo. @@ -61,13 +61,13 @@ echo. echo O3DE_DEV = %O3DE_DEV% :: shared location for default O3DE python location -set O3DE_PYTHON_INSTALL=%O3DE_DEV%\Python -echo O3DE_PYTHON_INSTALL = %O3DE_PYTHON_INSTALL% +set PATH_O3DE_PYTHON_INSTALL=%O3DE_DEV%\Python +echo PATH_O3DE_PYTHON_INSTALL = %PATH_O3DE_PYTHON_INSTALL% echo. :: Change to root dir -CD /D %O3DE_PROJECT_PATH% +CD /D %PATH_O3DE_PROJECT% IF EXIST "%WINGHOME%\bin\wing.exe" ( start "" "%WINGHOME%\bin\wing.exe" "%WING_PROJ%" diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_mayapy_WingIDE-7-1.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/IDE/Launch_mayapy_WingIDE-7-1.bat similarity index 70% rename from Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_mayapy_WingIDE-7-1.bat rename to Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/IDE/Launch_mayapy_WingIDE-7-1.bat index ca5b175c39..92201ef048 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_mayapy_WingIDE-7-1.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/IDE/Launch_mayapy_WingIDE-7-1.bat @@ -22,10 +22,10 @@ PUSHD %~dp0 :: Constant Vars (Global) :: global debug (propogates) -IF "%DCCSI_GDEBUG%"=="" (set DCCSI_GDEBUG=True) +IF "%DCCSI_GDEBUG%"=="" (set DCCSI_GDEBUG=False) echo DCCSI_GDEBUG = %DCCSI_GDEBUG% :: initiates debugger connection -IF "%DCCSI_DEV_MODE%"=="" (set DCCSI_DEV_MODE=True) +IF "%DCCSI_DEV_MODE%"=="" (set DCCSI_DEV_MODE=False) echo DCCSI_DEV_MODE = %DCCSI_DEV_MODE% :: sets debugger, options: WING, PYCHARM IF "%DCCSI_GDEBUGGER%"=="" (set DCCSI_GDEBUGGER=WING) @@ -37,14 +37,17 @@ echo DCCSI_GDEBUGGER = %DCCSI_GDEBUGGER% :: INFO:20 :: DEBUG:10 :: NOTSET:0 -IF "%DCCSI_LOGLEVEL%"=="" (set DCCSI_LOGLEVEL=10) +IF "%DCCSI_LOGLEVEL%"=="" (set DCCSI_LOGLEVEL=20) echo DCCSI_LOGLEVEL = %DCCSI_LOGLEVEL% +:: if the user has set up a custom env call it +IF EXIST "%~dp0..\Env_Dev.bat" CALL %~dp0..\Env_Dev.bat + :: Initialize env -CALL %~dp0\Env_Core.bat -CALL %~dp0\Env_Python.bat -CALL %~dp0\Env_WingIDE.bat -CALL %~dp0\Env_Maya.bat +CALL %~dp0\..\Env_Core.bat +CALL %~dp0\..\Env_Python.bat +CALL %~dp0\..\Env_WingIDE.bat +CALL %~dp0\..\Env_Maya.bat echo. echo _____________________________________________________________________ @@ -57,29 +60,14 @@ echo. echo O3DE_DEV = %O3DE_DEV% -:: shared location for default O3DE python location -set O3DE_PYTHON_INSTALL=%O3DE_DEV%\Python -echo O3DE_PYTHON_INSTALL = %O3DE_PYTHON_INSTALL% - -:: Wing and other IDEs probably prefer access directly to the python.exe -set DCCSI_PY_IDE = %O3DE_PYTHON_INSTALL%\runtime\python-3.7.10-rev2-windows\python -echo DCCSI_PY_IDE = %DCCSI_PY_IDE% - -:: ide and debugger plug -set DCCSI_PY_BASE=%DCCSI_PY_IDE%\python.exe -echo DCCSI_PY_BASE = %DCCSI_PY_BASE% - :: ide and debugger plug set DCCSI_PY_DEFAULT=%DCCSI_PY_MAYA% echo DCCSI_PY_DEFAULT = %DCCSI_PY_DEFAULT% -:: if the user has set up a custom env call it -IF EXIST "%~dp0Env_Dev.bat" CALL %~dp0Env_Dev.bat - echo. :: Change to root dir -CD /D %O3DE_PROJECT_PATH% +CD /D %PATH_O3DE_PROJECT% IF EXIST "%WINGHOME%\bin\wing.exe" ( start "" "%WINGHOME%\bin\wing.exe" "%WING_PROJ%" diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Env_Cmd.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Env_Cmd.bat index 5b76de1401..3387633838 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Env_Cmd.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Env_Cmd.bat @@ -29,6 +29,9 @@ PUSHD %~dp0 SETLOCAL ENABLEDELAYEDEXPANSION +:: if the user has set up a custom env call it +IF EXIST "%~dp0Env_Dev.bat" CALL %~dp0Env_Dev.bat + CALL %~dp0\Env_Core.bat CALL %~dp0\Env_Python.bat CALL %~dp0\Env_Qt.bat @@ -36,11 +39,8 @@ CALL %~dp0\Env_Maya.bat CALL %~dp0\Env_Substance.bat CALL %~dp0\Env_WingIDE.bat -:: if the user has set up a custom env call it -IF EXIST "%~dp0Env_Dev.bat" CALL %~dp0Env_Dev.bat - :: Change to root dir -CD /D %O3DE_PROJECT_PATH% +CD /D %PATH_O3DE_PROJECT% :: Create command prompt with environment CALL %windir%\system32\cmd.exe diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_PyMin_Cmd.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_PyMin_Cmd.bat index 193cb40de8..d4d5d08c19 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_PyMin_Cmd.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_PyMin_Cmd.bat @@ -38,7 +38,7 @@ echo _____________________________________________________________________ echo. :: Change to root dir -CD /D %O3DE_PROJECT_PATH% +CD /D %PATH_O3DE_PROJECT% :: Create command prompt with environment CALL %windir%\system32\cmd.exe diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Qt_PyMin_Cmd.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Qt_PyMin_Cmd.bat index 75d1ff8cc4..f3e815ed8c 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Qt_PyMin_Cmd.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_Qt_PyMin_Cmd.bat @@ -39,7 +39,7 @@ echo _____________________________________________________________________ echo. :: Change to root dir -CD /D %O3DE_PROJECT_PATH% +CD /D %PATH_O3DE_PROJECT% :: Create command prompt with environment CALL %windir%\system32\cmd.exe diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_pyBASE_Cmd.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_pyBASE_Cmd.bat index e1b075e065..133fa3906d 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_pyBASE_Cmd.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Launch_pyBASE_Cmd.bat @@ -33,7 +33,7 @@ CALL %~dp0\Env_Maya.bat IF EXIST "%~dp0Env_Dev.bat" CALL %~dp0Env_Dev.bat :: Change to root dir -CD /D %O3DE_PROJECT_PATH% +CD /D %PATH_O3DE_PROJECT% :: Create command prompt with environment CALL %windir%\system32\cmd.exe diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Setuo_copy_oiio.bat b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Setuo_copy_oiio.bat index 18a58e1371..51233b256d 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Setuo_copy_oiio.bat +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Setuo_copy_oiio.bat @@ -16,9 +16,9 @@ PUSHD %~dp0 set O3DE_DEV=..\..\..\..\..\.. :: shared location for default O3DE python location -set O3DE_PYTHON_INSTALL=%O3DE_DEV%\Python +set PATH_O3DE_PYTHON_INSTALL=%O3DE_DEV%\Python -set PY_SITE=%O3DE_PYTHON_INSTALL%\runtime\python-3.7.10-rev2-windows\python\Lib\site-packages +set PY_SITE=%PATH_O3DE_PYTHON_INSTALL%\runtime\python-3.7.10-rev2-windows\python\Lib\site-packages set PACKAGE_LOC=C:\Depot\3rdParty\packages\openimageio-2.1.16.0-rev1-windows\OpenImageIO\2.1.16.0\win_x64\bin diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/.gitignore b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/.gitignore index 265145e9c1..cc9ae87641 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/.gitignore +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/.gitignore @@ -1,2 +1,3 @@ # Default ignored files -./workspace.xml \ No newline at end of file +./workspace.xml +venv \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/DccScriptingInterface.iml b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/DccScriptingInterface.iml index 764d6090c1..1d9156afc8 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/DccScriptingInterface.iml +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/DccScriptingInterface.iml @@ -12,15 +12,9 @@ + - + - - - - + \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/misc.xml b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/misc.xml index 1069eb4889..49bab22105 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/misc.xml +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/misc.xml @@ -3,8 +3,8 @@ - + - + \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/vcs.xml b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/vcs.xml index ed52866afa..07117e447d 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/vcs.xml +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/Tools/Dev/Windows/Solutions/.idea/vcs.xml @@ -1,6 +1,6 @@ - + - + \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/__init__.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/__init__.py index 958508c227..f23fa1e9a5 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/__init__.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/__init__.py @@ -40,9 +40,9 @@ __all__ = ['config_utils', # we need to set up basic access to the DCCsi _MODULE_PATH = os.path.realpath(__file__) # To Do: what if frozen? -_DCCSIG_PATH = os.path.normpath(os.path.join(_MODULE_PATH, '../..')) -_DCCSIG_PATH = os.getenv('DCCSIG_PATH', _DCCSIG_PATH) -site.addsitedir(_DCCSIG_PATH) +_PATH_DCCSIG = os.path.normpath(os.path.join(_MODULE_PATH, '../..')) +_PATH_DCCSIG = os.getenv('PATH_DCCSIG', _PATH_DCCSIG) +site.addsitedir(_PATH_DCCSIG) # azpy import azpy.return_stub as return_stub @@ -52,12 +52,31 @@ import azpy.config_utils as config_utils _DCCSI_GDEBUG = env_bool.env_bool(constants.ENVAR_DCCSI_GDEBUG, False) _DCCSI_DEV_MODE = env_bool.env_bool(constants.ENVAR_DCCSI_DEV_MODE, False) -_DCCSI_LOGLEVEL = int(env_bool.env_bool(constants.ENVAR_DCCSI_LOGLEVEL, int(20))) -if _DCCSI_GDEBUG: - _DCCSI_LOGLEVEL = int(10) +_DCCSI_GDEBUGGER = env_bool.env_bool(constants.ENVAR_DCCSI_GDEBUGGER, 'WING') +# default loglevel to info unless set +_DCCSI_LOGLEVEL = int(env_bool.env_bool(constants.ENVAR_DCCSI_LOGLEVEL, + _logging.INFO)) +if _DCCSI_GDEBUG: + # override loglevel if runnign debug + _DCCSI_LOGLEVEL = _logging.DEBUG + +# set up module logging +for handler in _logging.root.handlers[:]: + _logging.root.removeHandler(handler) + +_logging.basicConfig(level=_DCCSI_LOGLEVEL, + format=constants.FRMT_LOG_LONG, + datefmt='%m-%d %H:%M') + +_LOGGER = _logging.getLogger(_PACKAGENAME) +_LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME})) +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- # for py2.7 (Maya) we provide this, so we must assume some bootstrapping -# has occured, see DccScriptingInterface\\config.py (_DCCSI_PYTHON_LIB_PATH) +# has occured, see DccScriptingInterface\\config.py (_PATH_DCCSI_PYTHON_LIB) try: import pathlib @@ -69,16 +88,6 @@ if _DCCSI_GDEBUG: # ------------------------------------------------------------------------- -# ------------------------------------------------------------------------- -# set up module logging -#for handler in _logging.root.handlers[:]: - #_logging.root.removeHandler(handler) -_logging.basicConfig(format=constants.FRMT_LOG_LONG, level=_DCCSI_LOGLEVEL) -_LOGGER = _logging.getLogger(_PACKAGENAME) -_LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME})) -# ------------------------------------------------------------------------- - - # ------------------------------------------------------------------------- # get/set the project name _O3DE_DEV = Path(os.getenv(constants.ENVAR_O3DE_DEV, @@ -86,21 +95,21 @@ _O3DE_DEV = Path(os.getenv(constants.ENVAR_O3DE_DEV, check_stub='engine.json'))) _LOGGER.debug('_O3DE_DEV" {}'.format(_O3DE_DEV.resolve())) -_O3DE_PROJECT_PATH = Path(os.getenv(constants.ENVAR_O3DE_PROJECT_PATH, +_PATH_O3DE_PROJECT = Path(os.getenv(constants.ENVAR_PATH_O3DE_PROJECT, config_utils.get_o3de_project_path())) -_LOGGER.debug('_O3DE_PROJECT_PATH" {}'.format(_O3DE_PROJECT_PATH.resolve())) +_LOGGER.debug('_PATH_O3DE_PROJECT" {}'.format(_PATH_O3DE_PROJECT.resolve())) # get/set the project name -if _O3DE_PROJECT_PATH: +if _PATH_O3DE_PROJECT: _O3DE_PROJECT = str(os.getenv(constants.ENVAR_O3DE_PROJECT, - _O3DE_PROJECT_PATH.name)) + _PATH_O3DE_PROJECT.name)) else: _O3DE_PROJECT='o3de' # project cache log dir path from azpy.constants import TAG_DCCSI_NICKNAME from azpy.constants import PATH_DCCSI_LOG_PATH -_DCCSI_LOG_PATH = Path(PATH_DCCSI_LOG_PATH.format(O3DE_PROJECT_PATH=_O3DE_PROJECT_PATH.resolve(), +_DCCSI_LOG_PATH = Path(PATH_DCCSI_LOG_PATH.format(PATH_O3DE_PROJECT=_PATH_O3DE_PROJECT.resolve(), TAG_DCCSI_NICKNAME=TAG_DCCSI_NICKNAME)) # ------------------------------------------------------------------------- @@ -214,7 +223,7 @@ if _DCCSI_GDEBUG: # debug breadcrumbs to check this module and used paths _LOGGER.debug('MODULE_PATH: {}'.format(_MODULE_PATH)) _LOGGER.debug('O3DE_DEV_PATH: {}'.format(_O3DE_DEV)) -_LOGGER.debug('DCCSI_PATH: {}'.format(_DCCSIG_PATH)) +_LOGGER.debug('PATH_DCCSIG: {}'.format(_PATH_DCCSIG)) _LOGGER.debug('O3DE_PROJECT_TAG: {}'.format(_O3DE_PROJECT)) _LOGGER.debug('DCCSI_LOG_PATH: {}'.format(_DCCSI_LOG_PATH)) # ------------------------------------------------------------------------- @@ -258,5 +267,5 @@ if __name__ == '__main__': _DCCSI_DEV_MODE = True if _DCCSI_GDEBUG: - print(_DCCSIG_PATH) + print(_PATH_DCCSIG) test_imports() diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/config_utils.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/config_utils.py index f6b71a7d97..a1baabcfb0 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/config_utils.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/config_utils.py @@ -8,7 +8,29 @@ # # # note: this module should reamin py2.7 compatible (Maya) so no f'strings -# -------------------------------------------------------------------------- +# ------------------------------------------------------------------------- +"""@module docstring +This module is part of the O3DE DccScriptingInterface Gem +This module is a set of utils related to config.py, it hase several methods +that can fullfil discovery of paths for use in standing up a synthetic env. +This is particularly useful when the config is used outside of O3DE, +in an external standalone tool with PySide2(Qt). Foe example, these paths +are discoverable so that we can synthetically derive code access to various +aspects of O3DE outside of the executables. + +return_stub_dir() :discover path by walking from module to file stub +get_stub_check_path() :discover by walking from known path to file stub +get_o3de_engine_root() :combines multiple methods to discover engine root +get_o3de_build_path() :searches for the build path using file stub +get_dccsi_config() :convenience method to get the dccsi config +get_current_project_cfg() :will be depricated (don't use) +get_check_global_project() :get global project path from user .o3de data +get_o3de_project_path() :get the project path while within editor +bootstrap_dccsi_py_libs() :extends code access (mainly used in Maya py27) +""" +import time +start = time.process_time() # start tracking + import sys import os import re @@ -18,34 +40,60 @@ import logging as _logging # -------------------------------------------------------------------------- -# note: this module is called in other root modules -# must avoid cyclical imports - # global scope -# normally would pull the constant envar string -# but avoiding cyclical imports here -FRMT_LOG_LONG = "[%(name)s][%(levelname)s] >> %(message)s (%(asctime)s; %(filename)s:%(lineno)d)" -from azpy.env_bool import env_bool -_DCCSI_GDEBUG = env_bool('DCCSI_GDEBUG', False) -_DCCSI_LOGLEVEL = env_bool('DCCSI_LOGLEVEL', False) -_DCCSI_LOGLEVEL = int(env_bool('DCCSI_LOGLEVEL', int(20))) -if _DCCSI_GDEBUG: - _DCCSI_LOGLEVEL = int(10) +_MODULENAME = 'azpy.config_utils' + +__all__ = ['get_os', + 'return_stub', + 'get_stub_check_path', + 'get_dccsi_config', + 'get_current_project'] -_MODULENAME = __name__ -if _MODULENAME is '__main__': - _MODULENAME = 'azpy.config_utils' +# dccsi site/code access +#os.environ['PYTHONINSPECT'] = 'True' +_MODULE_PATH = os.path.abspath(__file__) + +# we don't have access yet to the DCCsi Lib\site-packages +# (1) this will give us import access to azpy (always?) +# we know where the dccsi root should be from here +_PATH_DCCSIG = os.path.abspath(os.path.dirname(os.path.dirname(_MODULE_PATH))) +# it can be set or overrriden by dev with envar +_PATH_DCCSIG = os.getenv('PATH_DCCSIG', _PATH_DCCSIG) +# ^ we assume this config is in the root of the DCCsi +# if it's not, be sure to set envar 'PATH_DCCSIG' to ensure it +site.addsitedir(_PATH_DCCSIG) # must be done for azpy + +# note: this module is called in other root modules +# must avoid cyclical imports, no imports from azpy.constants +ENVAR_DCCSI_GDEBUG = 'DCCSI_GDEBUG' +ENVAR_DCCSI_DEV_MODE = 'DCCSI_DEV_MODE' +ENVAR_DCCSI_GDEBUGGER = 'DCCSI_GDEBUGGER' +ENVAR_DCCSI_LOGLEVEL = 'DCCSI_LOGLEVEL' +FRMT_LOG_LONG = "[%(name)s][%(levelname)s] >> %(message)s (%(asctime)s; %(filename)s:%(lineno)d)" + +from azpy.env_bool import env_bool +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) +_DCCSI_GDEBUGGER = env_bool(ENVAR_DCCSI_GDEBUGGER, 'WING') + +# default loglevel to info unless set +_DCCSI_LOGLEVEL = int(env_bool(ENVAR_DCCSI_LOGLEVEL, _logging.INFO)) +if _DCCSI_GDEBUG: + # override loglevel if runnign debug + _DCCSI_LOGLEVEL = _logging.DEBUG # set up module logging #for handler in _logging.root.handlers[:]: #_logging.root.removeHandler(handler) -_LOGGER = _logging.getLogger(_MODULENAME) -#_logging.basicConfig(format=FRMT_LOG_LONG, level=_DCCSI_LOGLEVEL) -_LOGGER.propagate = False -_LOGGER.debug('Initializing: {0}.'.format({_MODULENAME})) + +# configure basic logger +# note: not using a common logger to reduce cyclical imports +_logging.basicConfig(level=_DCCSI_LOGLEVEL, + format=FRMT_LOG_LONG, + datefmt='%m-%d %H:%M') -__all__ = ['get_os', 'return_stub', 'get_stub_check_path', - 'get_dccsi_config', 'get_current_project'] +_LOGGER = _logging.getLogger(_MODULENAME) +_LOGGER.debug('Initializing: {0}.'.format({_MODULENAME})) # ------------------------------------------------------------------------- @@ -77,6 +125,56 @@ except Exception as e: # ------------------------------------------------------------------------- +def attach_debugger(): + _DCCSI_GDEBUG = True + os.environ["DYNACONF_DCCSI_GDEBUG"] = str(_DCCSI_GDEBUG) + + _DCCSI_DEV_MODE = True + os.environ["DYNACONF_DCCSI_DEV_MODE"] = str(_DCCSI_DEV_MODE) + + from azpy.test.entry_test import connect_wing + _debugger = connect_wing() + + return _debugger +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +# exapnd the global scope and module CONST + +# this is the DCCsi envar used for discovering the engine path (if set) +ENVAR_O3DE_DEV = 'O3DE_DEV' +STUB_O3DE_DEV = 'engine.json' + +# this block is related to .o3de data +# os.path.expanduser("~") returns different values in py2.7 vs 3 +# Note: py27 support will be deprecated in the future +from os.path import expanduser +PATH_USER_HOME = expanduser("~") +_LOGGER.debug('user home: {}'.format(PATH_USER_HOME)) + +# special case, make sure didn't return \documents +user_home_parts = os.path.split(PATH_USER_HOME) + +if str(user_home_parts[1].lower()) == 'documents': + PATH_USER_HOME = user_home_parts[0] + _LOGGER.debug('user home CORRECTED: {}'.format(PATH_USER_HOME)) + +# the global project may be defined in the registry +PATH_USER_O3DE = Path(PATH_USER_HOME, '.o3de') +PATH_USER_O3DE_REGISTRY = Path(PATH_USER_O3DE, 'Registry') +PATH_USER_O3DE_BOOTSTRAP = Path(PATH_USER_O3DE_REGISTRY, 'bootstrap.setreg') + +# this is the DCCsi envar used for discovering the project path (if set) +ENVAR_PATH_O3DE_PROJECT = 'PATH_O3DE_PROJECT' + +# python related envars and paths +STR_PATH_DCCSI_PYTHON_LIB = '{0}\\3rdParty\\Python\\Lib\\{1}.x\\{1}.{2}.x\\site-packages' +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +# first define all the methods for the module def get_os(): """returns lumberyard dir names used in python path""" if sys.platform.startswith('win'): @@ -96,7 +194,7 @@ def get_os(): # ------------------------------------------------------------------------- -from azpy.core import get_datadir +# from azpy.core import get_datadir # there was a method here refactored out to add py2.7 support for Maya 2020 #"DccScriptingInterface\azpy\core\py2\utils.py get_datadir()" #"DccScriptingInterface\azpy\core\py3\utils.py get_datadir()" @@ -106,8 +204,10 @@ from azpy.core import get_datadir # ------------------------------------------------------------------------- def return_stub_dir(stub_file='dccsi_stub'): + '''discover and return path by walking from module to file stub + Input: a file name (stub_file) + Output: returns the directory of the file (stub_file)''' _dir_to_last_file = None - '''Take a file name (stub_file) and returns the directory of the file (stub_file)''' # To Do: refactor to use pathlib object oriented Path if _dir_to_last_file is None: path = os.path.abspath(__file__) @@ -129,12 +229,15 @@ def return_stub_dir(stub_file='dccsi_stub'): # ------------------------------------------------------------------------- -def get_stub_check_path(in_path=os.getcwd(), check_stub='engine.json'): +def get_stub_check_path(in_path=os.getcwd(), check_stub=STUB_O3DE_DEV): ''' Returns the branch root directory of the dev\\'engine.json' - (... or you can pass it another known stub) - - so we can safely build relative filepaths within that branch. + (... or you can pass it another known stub) so we can safely build + relative filepaths within that branch. + + Input: a starting directory, default is os.getcwd() + Input: a file name stub (to search for) + Output: a path (the stubs parent directory) If the stub is not found, it returns None ''' @@ -155,7 +258,11 @@ def get_stub_check_path(in_path=os.getcwd(), check_stub='engine.json'): # ------------------------------------------------------------------------- -def get_o3de_engine_root(check_stub='engine.json'): +def get_o3de_engine_root(check_stub=STUB_O3DE_DEV): + '''Discovers the engine root + Input: a file name stub, default engine.json + Output: engine root path (if found) + ''' # get the O3DE engine root folder # if we are running within O3DE we can ensure which engine is running _O3DE_DEV = None @@ -164,20 +271,61 @@ def get_o3de_engine_root(check_stub='engine.json'): except ImportError as e: # if that fails, we can search up # search up to get \dev - _O3DE_DEV = get_stub_check_path(check_stub='engine.json') + _O3DE_DEV = get_stub_check_path(check_stub=STUB_O3DE_DEV) # To Do: What if engine.json doesn't exist? else: - # execute if no exception - # allow for external ENVAR override - from azpy.constants import ENVAR_O3DE_DEV + # execute if no exception, allow for external ENVAR override _O3DE_DEV = Path(os.getenv(ENVAR_O3DE_DEV, azlmbr.paths.engroot)) finally: - # note: can't use fstrings as this module gets called with py2.7 in maya - _LOGGER.info('O3DE engine root: {}'.format(_O3DE_DEV.resolve())) + if _DCCSI_GDEBUG: # to verbose, used often + # note: can't use fstrings as this module gets called with py2.7 in maya + _LOGGER.info('O3DE engine root: {}'.format(_O3DE_DEV.resolve())) return _O3DE_DEV # ------------------------------------------------------------------------- +# ------------------------------------------------------------------------- +def get_o3de_build_path(root_directory=get_o3de_engine_root(), + marker='CMakeCache.txt'): + """Returns a path for the O3DE\build root if found. Searchs down from a + known engine root path. + Input: a root directory, default is to discover the engine root + Output: the path of the build folder (if found) + """ + + if _DCCSI_GDEBUG: + import time + start = time.process_time() + + for root, dirs, files in os.walk(root_directory): + if marker in files: + if _DCCSI_GDEBUG: + _LOGGER.debug('Find PATH_O3DE_BUILD took: {} sec' + ''.format(time.process_time() - start)) + return Path(root) + else: + if _DCCSI_GDEBUG: + _LOGGER.debug('Not fidning PATH_O3DE_BUILD took: {} sec' + ''.format(time.process_time() - start)) + return None + +# note: if we use this method to find PATH_O3DE_BUILD +# by searching for the 'CMakeCache.txt' it can take 1 or more seconds +# this will slow down boot times! +# +# this works fine for a engine dev, but is not really suitable for end users +# it assumes that the engine is being built and 'CMakeCache.txt' exists +# but the engine could be pre-built or packaged somehow +# +# other ways to deal with it: +# 1 - Use the running application .exe to discover the build path? +# 2 - Set PATH_O3DE_BUILD envar in +# "C:\Depot\o3de\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\.env" +# 3 - Set in commandline (or from .bat file) +# 4 - To Do (maybe): Set in a dccsi_configuration.setreg? +# ------------------------------------------------------------------------- + + # ------------------------------------------------------------------------- # settings.setenv() # doing this will add the additional DYNACONF_ envars def get_dccsi_config(dccsi_dirpath=return_stub_dir()): @@ -231,10 +379,8 @@ def get_current_project_cfg(dev_folder=get_stub_check_path()): def get_check_global_project(): """Gets o3de project via .o3de data in user directory""" - from azpy.constants import PATH_USER_O3DE_BOOTSTRAP from collections import OrderedDict from box import Box - from azpy.core import get_datadir bootstrap_box = None json_file_path = Path(PATH_USER_O3DE_BOOTSTRAP) @@ -260,46 +406,44 @@ def get_check_global_project(): # ------------------------------------------------------------------------- def get_o3de_project_path(): - """figures out the o3de project path - if not found defaults to the engine folder""" - _O3DE_PROJECT_PATH = None + """figures out the o3de project path if not found defaults to the engine folder""" + _PATH_O3DE_PROJECT = None try: import azlmbr # this file will fail outside of O3DE except ImportError as e: # (fallback 1) this checks if a global project is set # This check user home for .o3de data - _O3DE_PROJECT_PATH = get_check_global_project() + _PATH_O3DE_PROJECT = get_check_global_project() else: # execute if no exception, this would indicate we are in O3DE land # allow for external ENVAR override - from azpy.constants import ENVAR_O3DE_PROJECT_PATH - _O3DE_PROJECT_PATH = Path(os.getenv(ENVAR_O3DE_PROJECT_PATH, azlmbr.paths.projectroot)) + _PATH_O3DE_PROJECT = Path(os.getenv(ENVAR_PATH_O3DE_PROJECT, azlmbr.paths.projectroot)) finally: # (fallback 2) if None, fallback to engine folder - if not _O3DE_PROJECT_PATH: - _O3DE_PROJECT_PATH = get_o3de_engine_root() - # note: can't use fstrings as this module gets called with py2.7 in maya - _LOGGER.info('O3DE project root: {}'.format(_O3DE_PROJECT_PATH.resolve())) - return _O3DE_PROJECT_PATH + if not _PATH_O3DE_PROJECT: + _PATH_O3DE_PROJECT = get_o3de_engine_root() + + if _DCCSI_GDEBUG: # to verbose, used often + # note: can't use fstrings as this module gets called with py2.7 in maya + _LOGGER.debug('O3DE project root: {}'.format(_PATH_O3DE_PROJECT.resolve())) + return _PATH_O3DE_PROJECT # ------------------------------------------------------------------------- # ------------------------------------------------------------------------- def bootstrap_dccsi_py_libs(dccsi_dirpath=return_stub_dir()): """Builds and adds local site dir libs based on py version""" - - from azpy.constants import STR_DCCSI_PYTHON_LIB_PATH # a path string constructor - _DCCSI_PYTHON_LIB_PATH = Path(STR_DCCSI_PYTHON_LIB_PATH.format(dccsi_dirpath, + _PATH_DCCSI_PYTHON_LIB = Path(STR_PATH_DCCSI_PYTHON_LIB.format(dccsi_dirpath, sys.version_info[0], sys.version_info[1])) - if _DCCSI_PYTHON_LIB_PATH.exists(): - site.addsitedir(_DCCSI_PYTHON_LIB_PATH.resolve()) # PYTHONPATH + if _PATH_DCCSI_PYTHON_LIB.exists(): + site.addsitedir(_PATH_DCCSI_PYTHON_LIB.resolve()) # PYTHONPATH _LOGGER.debug('Performed site.addsitedir({})' - ''.format(_DCCSI_PYTHON_LIB_PATH.resolve())) - return _DCCSI_PYTHON_LIB_PATH + ''.format(_PATH_DCCSI_PYTHON_LIB.resolve())) + return _PATH_DCCSI_PYTHON_LIB else: - message = "Doesn't exist: {}".format(_DCCSI_PYTHON_LIB_PATH) + message = "Doesn't exist: {}".format(_PATH_DCCSI_PYTHON_LIB) _LOGGER.error(message) raise NotADirectoryError(message) # ------------------------------------------------------------------------- @@ -309,27 +453,87 @@ def bootstrap_dccsi_py_libs(dccsi_dirpath=return_stub_dir()): # Main Code Block, runs this script as main (testing) # ------------------------------------------------------------------------- if __name__ == '__main__': + """Run this file as a standalone cli script for testing/debugging""" + + # global scope + _MODULENAME = 'azpy.config_utils' + + # enable debug + _DCCSI_GDEBUG = False # enable here to force temporarily + _DCCSI_DEV_MODE = False + _DCCSI_LOGLEVEL = _logging.INFO + + # parse the command line args + import argparse + parser = argparse.ArgumentParser( + description='O3DE DCCsi: {}'.format(_MODULENAME), + epilog="Coomandline args enable deeper testing and info from commandline") + + parser.add_argument('-gd', '--global-debug', + type=bool, + required=False, + help='Enables global debug flag.') + + parser.add_argument('-sd', '--set-debugger', + type=str, + required=False, + help='Default debugger: WING, others: PYCHARM, VSCODE (not yet implemented).') + + parser.add_argument('-dm', '--developer-mode', + type=bool, + required=False, + help='Enables dev mode for early auto attaching debugger.') + + args = parser.parse_args() + + # easy overrides + if args.global_debug: + _DCCSI_GDEBUG = True + _DCCSI_LOGLEVEL = _logging.DEBUG + _LOGGER.setLevel(_DCCSI_LOGLEVEL) + + if args.set_debugger: + _LOGGER.info('Setting and switching debugger type not implemented (default=WING)') + # To Do: implement debugger plugin pattern + + if args.developer_mode or _DCCSI_DEV_MODE: + _DCCSI_DEV_MODE = True + attach_debugger() # attempts to start debugger # happy print _LOGGER.info("# {0} #".format('-' * 72)) _LOGGER.info('~ config_utils.py ... Running script as __main__') _LOGGER.info("# {0} #".format('-' * 72)) + + from pathlib import Path + # built in simple tests and info from commandline _LOGGER.info('Current Work dir: {0}'.format(os.getcwd())) _LOGGER.info('OS: {}'.format(get_os())) + + _PATH_DCCSIG = Path(return_stub_dir('dccsi_stub')) + _LOGGER.info('PATH_DCCSIG: {}'.format(_PATH_DCCSIG.resolve())) - _LOGGER.info('DCCSIG_PATH: {}'.format(return_stub_dir('dccsi_stub'))) - - _config = get_dccsi_config() - _LOGGER.info('DCCSI_CONFIG_PATH: {}'.format(_config)) - - _LOGGER.info('O3DE_DEV: {}'.format(get_o3de_engine_root(check_stub='engine.json'))) + _O3DE_DEV = get_o3de_engine_root(check_stub='engine.json') + _LOGGER.info('O3DE_DEV: {}'.format(_O3DE_DEV.resolve())) + + _PATH_O3DE_BUILD = get_o3de_build_path(_O3DE_DEV, 'CMakeCache.txt') + _LOGGER.info('PATH_O3DE_BUILD: {}'.format(_PATH_O3DE_BUILD.resolve())) # new o3de version - _LOGGER.info('O3DE_PROJECT: {}'.format(get_check_global_project())) + _PATH_O3DE_PROJECT = get_check_global_project() + _LOGGER.info('PATH_O3DE_PROJECT: {}'.format(_PATH_O3DE_PROJECT.resolve())) - _LOGGER.info('DCCSI_PYTHON_LIB_PATH: {}'.format(bootstrap_dccsi_py_libs(return_stub_dir('dccsi_stub')))) + _PATH_DCCSI_PYTHON_LIB = bootstrap_dccsi_py_libs(_PATH_DCCSIG) + _LOGGER.info('PATH_DCCSI_PYTHON_LIB: {}'.format(_PATH_DCCSI_PYTHON_LIB.resolve())) + _DCCSI_CONFIG = get_dccsi_config(_PATH_DCCSIG) + _LOGGER.info('PATH_DCCSI_CONFIG: {}'.format(_DCCSI_CONFIG)) + # --------------------------------------------------------------------- + # custom prompt sys.ps1 = "[azpy]>>" + +_LOGGER.debug('DCCsi: config_utils.py took: {} sec'.format(time.process_time() - start)) +# --- END ----------------------------------------------------------------- \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/constants.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/constants.py index d23601a33d..43efaa1201 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/constants.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/constants.py @@ -23,6 +23,7 @@ So we can make an update here once that is used elsewhere. import os import sys import site +import time from os.path import expanduser import logging as _logging # ------------------------------------------------------------------------- @@ -30,22 +31,23 @@ import logging as _logging # ------------------------------------------------------------------------- # global scope -_MODULENAME = __name__ -if _MODULENAME is '__main__': - _MODULENAME = 'azpy.constants' +_MODULENAME = 'azpy.constants' + +start = time.process_time() # start tracking os.environ['PYTHONINSPECT'] = 'True' # for this module to perform standalone # we need to set up basic access to the DCCsi _MODULE_PATH = os.path.realpath(__file__) # To Do: what if frozen? -_DCCSIG_PATH = os.path.normpath(os.path.join(_MODULE_PATH, '../..')) -_DCCSIG_PATH = os.getenv('DCCSIG_PATH', _DCCSIG_PATH) -site.addsitedir(_DCCSIG_PATH) +_PATH_DCCSIG = os.path.normpath(os.path.join(_MODULE_PATH, '../..')) +_PATH_DCCSIG = os.getenv('PATH_DCCSIG', _PATH_DCCSIG) +site.addsitedir(_PATH_DCCSIG) # now we have azpy api access import azpy from azpy.env_bool import env_bool from azpy.config_utils import return_stub_dir +from azpy.config_utils import get_stub_check_path # ------------------------------------------------------------------------- @@ -65,18 +67,23 @@ FRMT_LOG_SHRT = "[%(asctime)s][%(name)s][%(levelname)s] >> %(message)s" # global debug stuff _DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) _DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) -_DCCSI_LOGLEVEL = int(env_bool(ENVAR_DCCSI_LOGLEVEL, int(20))) +# default loglevel to info unless set +_DCCSI_LOGLEVEL = int(env_bool(ENVAR_DCCSI_LOGLEVEL, _logging.INFO)) if _DCCSI_GDEBUG: - _DCCSI_LOGLEVEL = int(10) -# ------------------------------------------------------------------------- + # override loglevel if runnign debug + _DCCSI_LOGLEVEL = _logging.DEBUG - -# ------------------------------------------------------------------------- # set up module logging -for handler in _logging.root.handlers[:]: - _logging.root.removeHandler(handler) +#for handler in _logging.root.handlers[:]: + #_logging.root.removeHandler(handler) + +# configure basic logger +# note: not using a common logger to reduce cyclical imports +_logging.basicConfig(level=_DCCSI_LOGLEVEL, + format=FRMT_LOG_LONG, + datefmt='%m-%d %H:%M') + _LOGGER = _logging.getLogger(_MODULENAME) -_logging.basicConfig(format=FRMT_LOG_LONG, level=_DCCSI_LOGLEVEL) _LOGGER.debug('Initializing: {0}.'.format({_MODULENAME})) # ------------------------------------------------------------------------- @@ -107,6 +114,7 @@ TAG_DCCSI_CONFIG = str('dccsiconfiguration.setreg') # filesystem markers, stub file names. STUB_O3DE_DEV = str('engine.json') +STUB_O3DE_BUILD = str('CMakeCache.txt') STUB_O3DE_ROOT_DCCSI = str('dccsi_stub') STUB_O3DE_DCCSI_AZPY = str('dccsi_azpy_stub') STUB_O3DE_DCCSI_TOOLS = str('dccsi_tools_stub') @@ -147,27 +155,27 @@ PATH_PROGRAMFILES_X64 = str(os.environ['PROGRAMFILES']) # base env var key as str ENVAR_COMPANY = str('COMPANY') -ENVAR_O3DE_PROJECT = str('O3DE_PROJECT') -ENVAR_O3DE_PROJECT_PATH = str('O3DE_PROJECT_PATH') +ENVAR_O3DE_PROJECT = str('O3DE_PROJECT') # project name +ENVAR_PATH_O3DE_PROJECT = str('PATH_O3DE_PROJECT') # path to project ENVAR_O3DE_DEV = str('O3DE_DEV') -ENVAR_DCCSIG_PATH = str('DCCSIG_PATH') +ENVAR_PATH_DCCSIG = str('PATH_DCCSIG') ENVAR_DCCSI_AZPY_PATH = str('DCCSI_AZPY_PATH') -ENVAR_DCCSI_TOOLS_PATH = str('DCCSI_TOOLS_PATH') +ENVAR_PATH_DCCSI_TOOLS = str('PATH_DCCSI_TOOLS') ENVAR_O3DE_BUILD_DIR_NAME = str('O3DE_BUILD_DIR_NAME') -ENVAR_O3DE_BUILD_PATH = str('O3DE_BUILD_PATH') +ENVAR_PATH_O3DE_BUILD = str('PATH_O3DE_BUILD') ENVAR_QT_PLUGIN_PATH = TAG_QT_PLUGIN_PATH ENVAR_QTFORPYTHON_PATH = str('QTFORPYTHON_PATH') -ENVAR_O3DE_BIN_PATH = str('O3DE_BIN_PATH') +ENVAR_PATH_O3DE_BIN = str('PATH_O3DE_BIN') ENVAR_DCCSI_LOG_PATH = str('DCCSI_LOG_PATH') ENVAR_DCCSI_LAUNCHERS_PATH = str('DCCSI_LAUNCHERS_PATH') ENVAR_DCCSI_PY_VERSION_MAJOR = str('DCCSI_PY_VERSION_MAJOR') ENVAR_DCCSI_PY_VERSION_MINOR = str('DCCSI_PY_VERSION_MINOR') -ENVAR_DCCSI_PYTHON_PATH = str('DCCSI_PYTHON_PATH') -ENVAR_DCCSI_PYTHON_LIB_PATH = str('DCCSI_PYTHON_LIB_PATH') -ENVAR_O3DE_PYTHON_INSTALL = str('O3DE_PYTHON_INSTALL') +ENVAR_PATH_DCCSI_PYTHON = str('PATH_DCCSI_PYTHON') +ENVAR_PATH_DCCSI_PYTHON_LIB = str('PATH_DCCSI_PYTHON_LIB') +ENVAR_PATH_O3DE_PYTHON_INSTALL = str('PATH_O3DE_PYTHON_INSTALL') ENVAR_WINGHOME = str('WINGHOME') ENVAR_DCCSI_WING_VERSION_MAJOR = str('DCCSI_WING_VERSION_MAJOR') @@ -178,7 +186,7 @@ ENVAR_DCCSI_PY_DCCSI = str('DCCSI_PY_DCCSI') ENVAR_DCCSI_PY_MAYA = str('DCCSI_PY_MAYA') ENVAR_DCCSI_PY_DEFAULT = str('DCCSI_PY_DEFAULT') -ENVAR_DCCSI_MAYA_VERSION = str('DCCSI_MAYA_VERSION') +ENVAR_MAYA_VERSION = str('MAYA_VERSION') ENVAR_MAYA_LOCATION = str('MAYA_LOCATION') ENVAR_DCCSI_TOOLS_MAYA_PATH = str('DCCSI_TOOLS_MAYA_PATH') @@ -206,27 +214,29 @@ TAG_MAYA_WORKSPACE = 'workspace.mel' # dcc scripting interface common and default paths PATH_O3DE_DEV = str(return_stub_dir(STUB_O3DE_DEV)) -PATH_DCCSIG_PATH = str(return_stub_dir(STUB_O3DE_ROOT_DCCSI)) +PATH_DCCSIG = str(return_stub_dir(STUB_O3DE_ROOT_DCCSI)) PATH_DCCSI_AZPY_PATH = str(return_stub_dir(STUB_O3DE_DCCSI_AZPY)) -PATH_DCCSI_TOOLS_PATH = str('{0}\\{1}'.format(PATH_DCCSIG_PATH, TAG_DIR_DCCSI_TOOLS)) +PATH_DCCSI_TOOLS = str('{0}\\{1}'.format(PATH_DCCSIG, TAG_DIR_DCCSI_TOOLS)) # logging into the cache -PATH_DCCSI_LOG_PATH = str('{O3DE_PROJECT_PATH}\\user\\log\{TAG_DCCSI_NICKNAME}') +PATH_DCCSI_LOG_PATH = str('{PATH_O3DE_PROJECT}\\user\\log\{TAG_DCCSI_NICKNAME}') # dev \ \ -STR_CONSTRUCT_O3DE_BUILD_PATH = str('{0}\\{1}') -PATH_O3DE_BUILD_PATH = str(STR_CONSTRUCT_O3DE_BUILD_PATH.format(PATH_O3DE_DEV, +STR_CONSTRUCT_PATH_O3DE_BUILD = str('{0}\\{1}') +PATH_O3DE_BUILD = str(STR_CONSTRUCT_PATH_O3DE_BUILD.format(PATH_O3DE_DEV, TAG_DIR_O3DE_BUILD_FOLDER)) # ENVAR_QT_PLUGIN_PATH = TAG_QT_PLUGIN_PATH STR_QTPLUGIN_DIR = str('{0}\\bin\\profile\\EditorPlugins') STR_QTFORPYTHON_PATH = str('{0}\\Gems\\QtForPython\\3rdParty\\pyside2\\windows\\release') -STR_O3DE_BIN_PATH = str('{0}\\bin\\profile') +STR_PATH_O3DE_BIN = str('{0}\\bin\\profile') + +STR_PATH_O3DE_BUILD = str('{0}\\{1}') +PATH_O3DE_BUILD = STR_PATH_O3DE_BUILD.format(PATH_O3DE_DEV, TAG_DIR_O3DE_BUILD_FOLDER) -PATH_O3DE_BUILD_PATH = str('{0}\\{1}'.format(PATH_O3DE_DEV, TAG_DIR_O3DE_BUILD_FOLDER)) PATH_QTFORPYTHON_PATH = str(STR_QTFORPYTHON_PATH.format(PATH_O3DE_DEV)) -PATH_QT_PLUGIN_PATH = str(STR_QTPLUGIN_DIR).format(PATH_O3DE_BUILD_PATH) -PATH_O3DE_BIN_PATH = str(STR_O3DE_BIN_PATH).format(PATH_O3DE_BUILD_PATH) +PATH_QT_PLUGIN_PATH = str(STR_QTPLUGIN_DIR).format(PATH_O3DE_BUILD) +PATH_O3DE_BIN = str(STR_PATH_O3DE_BIN).format(PATH_O3DE_BUILD) # py path string, parts, etc. TAG_DEFAULT_PY = str('Launch_pyBASE.bat') @@ -266,21 +276,21 @@ TAG_DCCSI_PY_VERSION_RELEASE = str(10) TAG_PYTHON_EXE = str('python.exe') TAG_TOOLS_DIR = str('Tools\\Python') TAG_PLATFORM = str('windows') -STR_CONSTRUCT_O3DE_PYTHON_INSTALL = str('{0}\\{1}\\{2}.{3}.{4}\\{5}') -PATH_DCCSI_PYTHON_PATH = str(STR_CONSTRUCT_O3DE_PYTHON_INSTALL.format(PATH_O3DE_DEV, +STR_CONSTRUCT_PATH_O3DE_PYTHON_INSTALL = str('{0}\\{1}\\{2}.{3}.{4}\\{5}') +PATH_DCCSI_PYTHON = str(STR_CONSTRUCT_PATH_O3DE_PYTHON_INSTALL.format(PATH_O3DE_DEV, TAG_TOOLS_DIR, TAG_DCCSI_PY_VERSION_MAJOR, TAG_DCCSI_PY_VERSION_MINOR, TAG_DCCSI_PY_VERSION_RELEASE, TAG_PLATFORM)) -PATH_DCCSI_PY_BASE = str('{0}\\{1}').format(PATH_DCCSI_PYTHON_PATH, TAG_PYTHON_EXE) +PATH_DCCSI_PY_BASE = str('{0}\\{1}').format(PATH_DCCSI_PYTHON, TAG_PYTHON_EXE) PATH_DCCSI_PY_DEFAULT = PATH_DCCSI_PY_BASE # bootstrap site-packages by version TAG_PY_MAJOR = str(sys.version_info.major) # future proof TAG_PY_MINOR = str(sys.version_info.minor) -STR_DCCSI_PYTHON_LIB_PATH = str('{0}\\3rdParty\\Python\\Lib\\{1}.x\\{1}.{2}.x\\site-packages') -PATH_DCCSI_PYTHON_LIB_PATH = STR_DCCSI_PYTHON_LIB_PATH.format(PATH_DCCSIG_PATH, +STR_PATH_DCCSI_PYTHON_LIB = str('{0}\\3rdParty\\Python\\Lib\\{1}.x\\{1}.{2}.x\\site-packages') +PATH_DCCSI_PYTHON_LIB = STR_PATH_DCCSI_PYTHON_LIB.format(PATH_DCCSIG, TAG_PY_MAJOR, TAG_PY_MINOR) # default path strings (and afe associated attributes) @@ -334,14 +344,14 @@ if __name__ == '__main__': _stash_dict = {} _stash_dict['O3DE_DEV'] = Path(PATH_O3DE_DEV) - _stash_dict['DCCSIG_PATH'] = Path(PATH_DCCSIG_PATH) + _stash_dict['PATH_DCCSIG'] = Path(PATH_DCCSIG) _stash_dict['DCCSI_AZPY_PATH'] = Path(PATH_DCCSI_AZPY_PATH) - _stash_dict['DCCSI_TOOLS_PATH'] = Path(PATH_DCCSI_TOOLS_PATH) - _stash_dict['DCCSI_PYTHON_PATH'] = Path(PATH_DCCSI_PYTHON_PATH) + _stash_dict['PATH_DCCSI_TOOLS'] = Path(PATH_DCCSI_TOOLS) + _stash_dict['PATH_DCCSI_PYTHON'] = Path(PATH_DCCSI_PYTHON) _stash_dict['DCCSI_PY_BASE'] = Path(PATH_DCCSI_PY_BASE) - _stash_dict['DCCSI_PYTHON_LIB_PATH'] = Path(PATH_DCCSI_PYTHON_LIB_PATH) - _stash_dict['O3DE_BUILD_PATH'] = Path(PATH_O3DE_BUILD_PATH) - _stash_dict['O3DE_BIN_PATH'] = Path(PATH_O3DE_BIN_PATH) + _stash_dict['PATH_DCCSI_PYTHON_LIB'] = Path(PATH_DCCSI_PYTHON_LIB) + _stash_dict['PATH_O3DE_BUILD'] = Path(PATH_O3DE_BUILD) + _stash_dict['PATH_O3DE_BIN'] = Path(PATH_O3DE_BIN) _stash_dict['QTFORPYTHON_PATH'] = Path(PATH_QTFORPYTHON_PATH) _stash_dict['QT_PLUGIN_PATH'] = Path(PATH_QT_PLUGIN_PATH) _stash_dict['SAT_INSTALL_PATH'] = Path(PATH_SAT_INSTALL_PATH) @@ -363,3 +373,6 @@ if __name__ == '__main__': # custom prompt sys.ps1 = "[azpy]>>" + +_LOGGER.debug('{0} took: {1} sec'.format(_MODULENAME, time.process_time() - start)) +# --- END ----------------------------------------------------------------- \ No newline at end of file diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/env_base.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/env_base.py index cdcf99d762..ec90a17ffd 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/env_base.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/env_base.py @@ -69,11 +69,11 @@ _BASE_ENVVAR_DICT[ENVAR_O3DE_PROJECT] = '${0}'.format(ENVAR_O3DE_PROJECT) # paths _BASE_ENVVAR_DICT[ENVAR_O3DE_DEV] = Path('${0}'.format(ENVAR_O3DE_DEV)) -_BASE_ENVVAR_DICT[ENVAR_O3DE_PROJECT_PATH] = Path('${0}'.format(ENVAR_O3DE_PROJECT_PATH)) -_BASE_ENVVAR_DICT[ENVAR_DCCSIG_PATH] = Path('${0}'.format(ENVAR_DCCSIG_PATH)) +_BASE_ENVVAR_DICT[ENVAR_PATH_O3DE_PROJECT] = Path('${0}'.format(ENVAR_PATH_O3DE_PROJECT)) +_BASE_ENVVAR_DICT[ENVAR_PATH_DCCSIG] = Path('${0}'.format(ENVAR_PATH_DCCSIG)) _BASE_ENVVAR_DICT[ENVAR_DCCSI_LOG_PATH] = Path('${0}'.format(ENVAR_DCCSI_LOG_PATH)) _BASE_ENVVAR_DICT[ENVAR_DCCSI_AZPY_PATH] = Path('${0}'.format(ENVAR_DCCSI_AZPY_PATH)) -_BASE_ENVVAR_DICT[ENVAR_DCCSI_TOOLS_PATH] = Path('${0}'.format(ENVAR_DCCSI_TOOLS_PATH)) +_BASE_ENVVAR_DICT[ENVAR_PATH_DCCSI_TOOLS] = Path('${0}'.format(ENVAR_PATH_DCCSI_TOOLS)) # dev env flags _BASE_ENVVAR_DICT[ENVAR_DCCSI_GDEBUG] = '${0}'.format(ENVAR_DCCSI_GDEBUG) @@ -83,8 +83,8 @@ _BASE_ENVVAR_DICT[ENVAR_DCCSI_GDEBUGGER] = '${0}'.format(ENVAR_DCCSI_GDEBUGGER) # default python dist _BASE_ENVVAR_DICT[ENVAR_DCCSI_PY_VERSION_MAJOR] = '${0}'.format(ENVAR_DCCSI_PY_VERSION_MAJOR) _BASE_ENVVAR_DICT[ENVAR_DCCSI_PY_VERSION_MINOR] = '${0}'.format(ENVAR_DCCSI_PY_VERSION_MINOR) -_BASE_ENVVAR_DICT[ENVAR_DCCSI_PYTHON_PATH] = '${0}'.format(ENVAR_DCCSI_PYTHON_PATH) -_BASE_ENVVAR_DICT[ENVAR_DCCSI_PYTHON_LIB_PATH] = '${0}'.format(ENVAR_DCCSI_PYTHON_LIB_PATH) +_BASE_ENVVAR_DICT[ENVAR_PATH_DCCSI_PYTHON] = '${0}'.format(ENVAR_PATH_DCCSI_PYTHON) +_BASE_ENVVAR_DICT[ENVAR_PATH_DCCSI_PYTHON_LIB] = '${0}'.format(ENVAR_PATH_DCCSI_PYTHON_LIB) # try to fetch and set the base values from the environment # this makes sure all envars set, are resolved on import diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/synthetic_env.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/synthetic_env.py index 2d0685b67d..21f9692dc5 100644 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/synthetic_env.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/synthetic_env.py @@ -42,9 +42,9 @@ Configures several useful environment config settings and paths, # this is the required base environment O3DE_PROJECT : name of project (project directory) O3DE_DEV : path to Lumberyard \dev root - O3DE_PROJECT_PATH : path to project dir - DCCSIG_PATH : path to the DCCsi Gem root - DCCSI_TOOLS_PATH : path to associated (non-api code) DCC SDK + PATH_O3DE_PROJECT : path to project dir + PATH_DCCSIG : path to the DCCsi Gem root + PATH_DCCSI_TOOLS : path to associated (non-api code) DCC SDK # nice to haves in base env to define core support DCCSI_GDEBUG : sets global debug prints @@ -58,7 +58,7 @@ Configures several useful environment config settings and paths, :: Default version py37 has a launcher (activates the env, starts py interpreter) - set DCCSI_PY_BASE=%O3DE_PYTHON_INSTALL%\python.exe + set DCCSI_PY_BASE=%PATH_O3DE_PYTHON_INSTALL%\python.exe :: shared location for 64bit python 3.7 BASE location set DCCSI_PY_DCCSI=%DCCSI_LAUNCHERS_PATH%\Launch_pyBASE.bat @@ -107,9 +107,9 @@ from collections import OrderedDict os.environ['PYTHONINSPECT'] = 'True' _MODULE_PATH = os.path.realpath(__file__) # To Do: what if frozen? -_DCCSIG_PATH = os.path.normpath(os.path.join(_MODULE_PATH, '../..')) -_DCCSIG_PATH = os.getenv('DCCSIG_PATH', _DCCSIG_PATH) -site.addsitedir(_DCCSIG_PATH) +_PATH_DCCSIG = os.path.normpath(os.path.join(_MODULE_PATH, '../..')) +_PATH_DCCSIG = os.getenv('PATH_DCCSIG', _PATH_DCCSIG) +site.addsitedir(_PATH_DCCSIG) # ------------------------------------------------------------------------- @@ -135,7 +135,7 @@ _LOGGER = _logging.getLogger(_PACKAGENAME) _logging.basicConfig(format=FRMT_LOG_LONG) _LOGGER.debug('Initializing: {0}.'.format({_PACKAGENAME})) -_LOGGER.debug('_DCCSIG_PATH: {}'.format(_DCCSIG_PATH)) +_LOGGER.debug('_PATH_DCCSIG: {}'.format(_PATH_DCCSIG)) _LOGGER.debug('_DCCSI_GDEBUG: {}'.format(_DCCSI_GDEBUG)) _LOGGER.debug('_DCCSI_DEV_MODE: {}'.format(_DCCSI_DEV_MODE)) @@ -146,7 +146,7 @@ if _DCCSI_DEV_MODE: # we can go ahead and just make sure the the DCCsi env is set # config is SO generic this ensures we are importing a specific one _spec_dccsi_config = importlib.util.spec_from_file_location("dccsi.config", - Path(_DCCSIG_PATH, + Path(_PATH_DCCSIG, "config.py")) _dccsi_config = importlib.util.module_from_spec(_spec_dccsi_config) _spec_dccsi_config.loader.exec_module(_dccsi_config) @@ -159,12 +159,12 @@ from azpy.constants import * from azpy.shared.common.core_utils import walk_up_dir from azpy.shared.common.core_utils import get_stub_check_path -_DCCSI_PYTHON_LIB_PATH = os.getenv(ENVAR_DCCSI_PYTHON_LIB_PATH, - PATH_DCCSI_PYTHON_LIB_PATH) -_LOGGER.debug('Dccsi Lib Path: {0}'.format(_DCCSI_PYTHON_LIB_PATH)) +_PATH_DCCSI_PYTHON_LIB = os.getenv(ENVAR_PATH_DCCSI_PYTHON_LIB, + PATH_DCCSI_PYTHON_LIB) +_LOGGER.debug('Dccsi Lib Path: {0}'.format(_PATH_DCCSI_PYTHON_LIB)) -if os.path.exists(_DCCSI_PYTHON_LIB_PATH): - site.addsitedir(_DCCSI_PYTHON_LIB_PATH) # add access +if os.path.exists(_PATH_DCCSI_PYTHON_LIB): + site.addsitedir(_PATH_DCCSI_PYTHON_LIB) # add access # ------------------------------------------------------------------------- # post-bootstrap global space @@ -404,53 +404,53 @@ def stash_env(_SYNTH_ENV_DICT = OrderedDict()): # so we guess based on how I set up the original dev environment # -- envar -- - _O3DE_BUILD_PATH = Path(os.getenv(ENVAR_O3DE_BUILD_PATH, - PATH_O3DE_BUILD_PATH)) - _SYNTH_ENV_DICT[ENVAR_O3DE_BUILD_PATH] = _O3DE_BUILD_PATH.as_posix() + _PATH_O3DE_BUILD = Path(os.getenv(ENVAR_PATH_O3DE_BUILD, + PATH_O3DE_BUILD)) + _SYNTH_ENV_DICT[ENVAR_PATH_O3DE_BUILD] = _PATH_O3DE_BUILD.as_posix() # -- envar -- - _O3DE_BIN_PATH = Path(os.getenv(ENVAR_O3DE_BIN_PATH, - PATH_O3DE_BIN_PATH)) + _PATH_O3DE_BIN = Path(os.getenv(ENVAR_PATH_O3DE_BIN, + PATH_O3DE_BIN)) # some of these need hard checks - if not _O3DE_BIN_PATH.exists(): - raise Exception('O3DE_BIN_PATH does NOT exist: {0}'.format(_O3DE_BIN_PATH)) + if not _PATH_O3DE_BIN.exists(): + raise Exception('PATH_O3DE_BIN does NOT exist: {0}'.format(_PATH_O3DE_BIN)) else: - _SYNTH_ENV_DICT[ENVAR_O3DE_BIN_PATH] = _O3DE_BIN_PATH.as_posix() + _SYNTH_ENV_DICT[ENVAR_PATH_O3DE_BIN] = _PATH_O3DE_BIN.as_posix() # adding to sys.path apparently doesn't work for .dll locations like Qt - os.environ['PATH'] = _O3DE_BIN_PATH.as_posix() + os.pathsep + os.environ['PATH'] + os.environ['PATH'] = _PATH_O3DE_BIN.as_posix() + os.pathsep + os.environ['PATH'] # -- envar -- # if that stub marker doesn't exist assume DCCsi path (fallback 1) - _O3DE_PROJECT_PATH = Path(os.getenv(ENVAR_O3DE_PROJECT_PATH, + _PATH_O3DE_PROJECT = Path(os.getenv(ENVAR_PATH_O3DE_PROJECT, Path(_O3DE_DEV, _O3DE_PROJECT))) - _SYNTH_ENV_DICT[ENVAR_O3DE_PROJECT_PATH] = _O3DE_PROJECT_PATH.as_posix() + _SYNTH_ENV_DICT[ENVAR_PATH_O3DE_PROJECT] = _PATH_O3DE_PROJECT.as_posix() # -- envar -- - _DCCSIG_PATH = resolve_envar_path(ENVAR_DCCSIG_PATH, # envar + _PATH_DCCSIG = resolve_envar_path(ENVAR_PATH_DCCSIG, # envar _THIS_MODULE_PATH, # search path STUB_O3DE_ROOT_DCCSI, # stub name TAG_DEFAULT_PROJECT) # dir - _SYNTH_ENV_DICT[ENVAR_DCCSIG_PATH] = _DCCSIG_PATH.as_posix() + _SYNTH_ENV_DICT[ENVAR_PATH_DCCSIG] = _PATH_DCCSIG.as_posix() # -- envar -- _AZPY_PATH = Path(os.getenv(ENVAR_DCCSI_AZPY_PATH, - Path(_DCCSIG_PATH, TAG_DIR_DCCSI_AZPY))) + Path(_PATH_DCCSIG, TAG_DIR_DCCSI_AZPY))) _SYNTH_ENV_DICT[ENVAR_DCCSI_AZPY_PATH] = _AZPY_PATH.as_posix() # -- envar -- - _DCCSI_TOOLS_PATH = Path(os.getenv(ENVAR_DCCSI_TOOLS_PATH, - Path(_DCCSIG_PATH, TAG_DIR_DCCSI_TOOLS))) - _SYNTH_ENV_DICT[ENVAR_DCCSI_TOOLS_PATH] = _DCCSI_TOOLS_PATH.as_posix() + _PATH_DCCSI_TOOLS = Path(os.getenv(ENVAR_PATH_DCCSI_TOOLS, + Path(_PATH_DCCSIG, TAG_DIR_DCCSI_TOOLS))) + _SYNTH_ENV_DICT[ENVAR_PATH_DCCSI_TOOLS] = _PATH_DCCSI_TOOLS.as_posix() # -- envar -- # external dccsi site-packages - _DCCSI_PYTHON_LIB_PATH = Path(os.getenv(ENVAR_DCCSI_PYTHON_LIB_PATH, - PATH_DCCSI_PYTHON_LIB_PATH)) - _SYNTH_ENV_DICT[ENVAR_DCCSI_PYTHON_LIB_PATH] = _DCCSI_PYTHON_LIB_PATH.as_posix() + _PATH_DCCSI_PYTHON_LIB = Path(os.getenv(ENVAR_PATH_DCCSI_PYTHON_LIB, + PATH_DCCSI_PYTHON_LIB)) + _SYNTH_ENV_DICT[ENVAR_PATH_DCCSI_PYTHON_LIB] = _PATH_DCCSI_PYTHON_LIB.as_posix() # -- envar -- # extend to py36 (conda env) and interpreter (wrapped as a .bat file) - _DEFAULT_PY_PATH = Path(_DCCSIG_PATH, TAG_DEFAULT_PY) + _DEFAULT_PY_PATH = Path(_PATH_DCCSIG, TAG_DEFAULT_PY) _DEFAULT_PY_PATH = Path(os.getenv(ENVAR_DCCSI_PY_DEFAULT, _DEFAULT_PY_PATH)) _SYNTH_ENV_DICT[ENVAR_DCCSI_PY_DEFAULT] = _DEFAULT_PY_PATH.as_posix() @@ -507,16 +507,16 @@ def init_ly_pyside(env_dict=_SYNTH_ENV_DICT): sys.path.insert(1, str(QTFORPYTHON_PATH)) site.addsitedir(str(QTFORPYTHON_PATH)) - O3DE_BIN_PATH = Path.joinpath(O3DE_DEV, + PATH_O3DE_BIN = Path.joinpath(O3DE_DEV, 'windows', 'bin', 'profile').resolve() - os.environ["DYNACONF_O3DE_BIN_PATH"] = str(O3DE_BIN_PATH) - os.environ["O3DE_BIN_PATH"] = str(O3DE_BIN_PATH) - site.addsitedir(str(O3DE_BIN_PATH)) - sys.path.insert(1, str(O3DE_BIN_PATH)) + os.environ["DYNACONF_PATH_O3DE_BIN"] = str(PATH_O3DE_BIN) + os.environ["PATH_O3DE_BIN"] = str(PATH_O3DE_BIN) + site.addsitedir(str(PATH_O3DE_BIN)) + sys.path.insert(1, str(PATH_O3DE_BIN)) - QT_PLUGIN_PATH = Path.joinpath(O3DE_BIN_PATH, + QT_PLUGIN_PATH = Path.joinpath(PATH_O3DE_BIN, 'EditorPlugins').resolve() os.environ["DYNACONF_QT_PLUGIN_PATH"] = str(QT_PLUGIN_PATH) os.environ["QT_PLUGIN_PATH"] = str(QT_PLUGIN_PATH) @@ -534,7 +534,7 @@ def init_ly_pyside(env_dict=_SYNTH_ENV_DICT): if sys.platform.startswith('win'): path = os.environ['PATH'] newPath = '' - newPath += str(O3DE_BIN_PATH) + os.pathsep + newPath += str(PATH_O3DE_BIN) + os.pathsep newPath += str(Path.joinpath(QTFORPYTHON_PATH, 'shiboken2').resolve()) + os.pathsep newPath += str(Path.joinpath(QTFORPYTHON_PATH, @@ -675,7 +675,7 @@ if __name__ == '__main__': if _DCCSI_GDEBUG: - tempBoxJsonFilePath = Path(_SYNTH_ENV_DICT['DCCSIG_PATH'], '.temp') + tempBoxJsonFilePath = Path(_SYNTH_ENV_DICT['PATH_DCCSIG'], '.temp') tempBoxJsonFilePath = Path(tempBoxJsonFilePath, 'boxDumpTest.json') _LOGGER.info(f'tempBoxJsonFilePath: {tempBoxJsonFilePath}') diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/test/entry_test.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/test/entry_test.py index aad440d11f..d1ba5fbd10 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/test/entry_test.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/azpy/test/entry_test.py @@ -7,10 +7,8 @@ # SPDX-License-Identifier: Apache-2.0 OR MIT # # -# -- This line is 75 characters ------------------------------------------- -from __future__ import unicode_literals - # ------------------------------------------------------------------------- +from __future__ import unicode_literals import os import site import logging as _logging @@ -19,27 +17,42 @@ import logging as _logging # See example: #"dev\Gems\AtomLyIntegration\TechnicalArt\DccScriptingInterface\SDK\Lumberyard\Scripts\set_menu.py" from pathlib import Path +# ------------------------------------------------------------------------- + # ------------------------------------------------------------------------- +# global scope +_MODULENAME = 'azpy.test.entry_test' _BOOT_CHECK = False # set true to test breakpoint in this module directly -import azpy.env_bool as env_bool +from azpy.env_bool import env_bool from azpy.constants import ENVAR_DCCSI_GDEBUG from azpy.constants import ENVAR_DCCSI_DEV_MODE +from azpy.constants import ENVAR_DCCSI_LOGLEVEL +from azpy.constants import ENVAR_DCCSI_GDEBUGGER from azpy.constants import FRMT_LOG_LONG -_DCCSI_GDEBUG = env_bool.env_bool(ENVAR_DCCSI_GDEBUG, False) -_DCCSI_DEV_MODE = env_bool.env_bool(ENVAR_DCCSI_DEV_MODE, False) - -_MODULENAME = __name__ -if _MODULENAME is '__main__': - _MODULENAME = 'azpy.test.entry_test' +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) +_DCCSI_GDEBUGGER = env_bool(ENVAR_DCCSI_GDEBUGGER, 'WING') +# default loglevel to info unless set +_DCCSI_LOGLEVEL = int(env_bool(ENVAR_DCCSI_LOGLEVEL, _logging.INFO)) +if _DCCSI_GDEBUG: + # override loglevel if runnign debug + _DCCSI_LOGLEVEL = _logging.DEBUG + # set up module logging -for handler in _logging.root.handlers[:]: - _logging.root.removeHandler(handler) +#for handler in _logging.root.handlers[:]: + #_logging.root.removeHandler(handler) + +# configure basic logger +# note: not using a common logger to reduce cyclical imports +_logging.basicConfig(level=_DCCSI_LOGLEVEL, + format=FRMT_LOG_LONG, + datefmt='%m-%d %H:%M') + _LOGGER = _logging.getLogger(_MODULENAME) -_logging.basicConfig(format=FRMT_LOG_LONG) _LOGGER.debug('Initializing: {0}.'.format({_MODULENAME})) # ------------------------------------------------------------------------- diff --git a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/config.py b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/config.py index a9cf5e8ee5..33dd3f7810 100755 --- a/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/config.py +++ b/Gems/AtomLyIntegration/TechnicalArt/DccScriptingInterface/config.py @@ -38,6 +38,63 @@ except: # ------------------------------------------------------------------------- +# ------------------------------------------------------------------------- +# global scope +_MODULENAME = 'DCCsi.config' + +#os.environ['PYTHONINSPECT'] = 'True' +_MODULE_PATH = os.path.abspath(__file__) + +# we don't have access yet to the DCCsi Lib\site-packages +# (1) this will give us import access to azpy (always?) +_PATH_DCCSIG = os.getenv('PATH_DCCSIG', + os.path.abspath(os.path.dirname(_MODULE_PATH))) +os. environ['PATH_DCCSIG'] = _PATH_DCCSIG +# ^ we assume this config is in the root of the DCCsi +# if it's not, be sure to set envar 'PATH_DCCSIG' to ensure it +site.addsitedir(_PATH_DCCSIG) # must be done for azpy +# ------------------------------------------------------------------------- + + +# ------------------------------------------------------------------------- +# now we have azpy api access +import azpy +from azpy.env_bool import env_bool +from azpy.constants import ENVAR_DCCSI_GDEBUG +from azpy.constants import ENVAR_DCCSI_DEV_MODE +from azpy.constants import ENVAR_DCCSI_LOGLEVEL +from azpy.constants import ENVAR_DCCSI_GDEBUGGER +from azpy.constants import FRMT_LOG_LONG + +_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) +_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) +_DCCSI_GDEBUGGER = env_bool(ENVAR_DCCSI_GDEBUGGER, 'WING') + +# default loglevel to info unless set +_DCCSI_LOGLEVEL = int(env_bool(ENVAR_DCCSI_LOGLEVEL, _logging.INFO)) +if _DCCSI_GDEBUG: + # override loglevel if runnign debug + _DCCSI_LOGLEVEL = _logging.DEBUG + +# set up module logging +#for handler in _logging.root.handlers[:]: + #_logging.root.removeHandler(handler) + +# configure basic logger +# note: not using a common logger to reduce cyclical imports +_logging.basicConfig(level=_DCCSI_LOGLEVEL, + format=FRMT_LOG_LONG, + datefmt='%m-%d %H:%M') + +_LOGGER = _logging.getLogger(_MODULENAME) +_LOGGER.debug('Initializing: {}.'.format({_MODULENAME})) +_LOGGER.debug('site.addsitedir({})'.format(_PATH_DCCSIG)) +_LOGGER.debug('_DCCSI_GDEBUG: {}'.format(_DCCSI_GDEBUG)) +_LOGGER.debug('_DCCSI_DEV_MODE: {}'.format(_DCCSI_DEV_MODE)) +_LOGGER.debug('_DCCSI_LOGLEVEL: {}'.format(_DCCSI_LOGLEVEL)) +# ------------------------------------------------------------------------- + + # ------------------------------------------------------------------------- def attach_debugger(): _DCCSI_GDEBUG = True @@ -53,63 +110,9 @@ def attach_debugger(): # ------------------------------------------------------------------------- -# ------------------------------------------------------------------------- -# global scope -_MODULENAME = __name__ -if _MODULENAME is '__main__': - _MODULENAME = 'DCCsi.config' - -#os.environ['PYTHONINSPECT'] = 'True' -_MODULE_PATH = os.path.abspath(__file__) - -# we don't have access yet to the DCCsi Lib\site-packages -# (1) this will give us import access to azpy (always?) -_DCCSI_PATH = os.getenv('DCCSI_PATH', - os.path.abspath(os.path.dirname(_MODULE_PATH))) -# ^ we assume this config is in the root of the DCCsi -# if it's not, be sure to set envar 'DCCSI_PATH' to ensure it -site.addsitedir(_DCCSI_PATH) # must be done for azpy - -# now we have azpy api access -import azpy -from azpy.env_bool import env_bool -from azpy.constants import ENVAR_DCCSI_GDEBUG -from azpy.constants import ENVAR_DCCSI_DEV_MODE -from azpy.constants import ENVAR_DCCSI_LOGLEVEL - -# set up global space, logging etc. -# set these true if you want them set globally for debugging -_DCCSI_GDEBUG = env_bool(ENVAR_DCCSI_GDEBUG, False) -_DCCSI_DEV_MODE = env_bool(ENVAR_DCCSI_DEV_MODE, False) -_DCCSI_LOGLEVEL = int(env_bool(ENVAR_DCCSI_LOGLEVEL, int(20))) -if _DCCSI_GDEBUG: - _DCCSI_LOGLEVEL = int(10) - -# early attach WingIDE debugger (can refactor to include other IDEs later) -# requires externally enabling via ENVAR -if _DCCSI_DEV_MODE: - _debugger = attach_debugger() -# to do: ^ this should be replaced with full featured azpy.dev.util -# that supports additional debuggers (pycharm, vscode, etc.) - -# set up module logging -for handler in _logging.root.handlers[:]: - _logging.root.removeHandler(handler) - -_LOGGER = azpy.initialize_logger(_MODULENAME, - log_to_file=_DCCSI_GDEBUG, - default_log_level=_DCCSI_LOGLEVEL) -_LOGGER.debug('Initializing: {0}.'.format({_MODULENAME})) -_LOGGER.info('site.addsitedir({})'.format(_DCCSI_PATH)) -_LOGGER.debug('_DCCSI_GDEBUG: {}'.format(_DCCSI_GDEBUG)) -_LOGGER.debug('_DCCSI_DEV_MODE: {}'.format(_DCCSI_DEV_MODE)) -_LOGGER.debug('_DCCSI_LOGLEVEL: {}'.format(_DCCSI_LOGLEVEL)) -# ------------------------------------------------------------------------- - - # ------------------------------------------------------------------------- # this will give us import access to additional modules we provide with DCCsi -_DCCSI_PYTHON_LIB_PATH = azpy.config_utils.bootstrap_dccsi_py_libs(_DCCSI_PATH) +_PATH_DCCSI_PYTHON_LIB = azpy.config_utils.bootstrap_dccsi_py_libs(_PATH_DCCSIG) # Now we should be able to just carry on with pth lib and dynaconf from dynaconf import Dynaconf @@ -119,60 +122,56 @@ except: import pathlib2 as pathlib from pathlib import Path -_DCCSI_PATH = Path(_DCCSI_PATH) # pathify -_DCCSI_PYTHON_PATH = Path(_DCCSI_PATH,'3rdParty','Python') -_DCCSI_PYTHON_LIB_PATH = Path(_DCCSI_PYTHON_LIB_PATH) +_PATH_DCCSIG = Path(_PATH_DCCSIG) # pathify +_PATH_DCCSI_PYTHON = Path(_PATH_DCCSIG,'3rdParty','Python') +_PATH_DCCSI_PYTHON_LIB = Path(_PATH_DCCSI_PYTHON_LIB) # ------------------------------------------------------------------------- # ------------------------------------------------------------------------- # start locally prepping known default values for dyanmic environment settings -_O3DE_DCCSI_PATH = os.environ['PATH'] -os.environ["DYNACONF_PATH"] = _O3DE_DCCSI_PATH +_O3DE_PATH_DCCSIG = os.environ['PATH'] +os.environ["DYNACONF_PATH"] = _O3DE_PATH_DCCSIG # this will retreive the O3DE engine root _O3DE_DEV = azpy.config_utils.get_o3de_engine_root() # set up dynamic config envars os.environ["DYNACONF_O3DE_DEV"] = str(_O3DE_DEV.resolve()) -from azpy.constants import TAG_DIR_O3DE_BUILD_FOLDER -_O3DE_BUILD_FOLDER = TAG_DIR_O3DE_BUILD_FOLDER -os.environ["DYNACONF_O3DE_BUILD_FOLDER"] = str(_O3DE_BUILD_FOLDER) -_O3DE_BUILD_PATH = Path(_O3DE_DEV, TAG_DIR_O3DE_BUILD_FOLDER) -os.environ["DYNACONF_O3DE_BUILD_PATH"] = str(_O3DE_BUILD_PATH.resolve()) +_PATH_O3DE_BUILD = azpy.config_utils.get_o3de_build_path(_O3DE_DEV,'CMakeCache.txt') -from azpy.constants import STR_O3DE_BIN_PATH -_O3DE_BIN_PATH = Path(STR_O3DE_BIN_PATH.format(_O3DE_BUILD_PATH)) -os.environ["DYNACONF_O3DE_BIN_PATH"] = str(_O3DE_BIN_PATH.resolve()) +from azpy.constants import STR_PATH_O3DE_BIN +_PATH_O3DE_BIN = Path(STR_PATH_O3DE_BIN.format(_PATH_O3DE_BUILD)) +os.environ["DYNACONF_PATH_O3DE_BIN"] = str(_PATH_O3DE_BIN.resolve()) # this in most cases will return the project folder # if it returns a matching engine folder then we don't know the project folder -_O3DE_PROJECT_PATH = azpy.config_utils.get_o3de_project_path() -os.environ["DYNACONF_O3DE_PROJECT_PATH"] = str(_O3DE_PROJECT_PATH.resolve()) +_PATH_O3DE_PROJECT = azpy.config_utils.get_o3de_project_path() +os.environ["DYNACONF_PATH_O3DE_PROJECT"] = str(_PATH_O3DE_PROJECT.resolve()) # special, a home for stashing PYTHONPATHs into managed settings _O3DE_PYTHONPATH = list() -_O3DE_PYTHONPATH.append(_DCCSI_PATH) +_O3DE_PYTHONPATH.append(_PATH_DCCSIG) # ------------------------------------------------------------------------- # ------------------------------------------------------------------------- -def init_o3de_pyside2(dccsi_path=_DCCSI_PATH, - engine_bin=_O3DE_BIN_PATH): +def init_o3de_pyside2(dccsi_path=_PATH_DCCSIG, + engine_bin=_PATH_O3DE_BIN): """Initialize the DCCsi Qt/PySide dynamic env and settings sets access to lumberyards Qt dlls and PySide""" - _DCCSI_PATH = Path(dccsi_path) - _O3DE_BIN_PATH = Path(engine_bin) + _PATH_DCCSIG = Path(dccsi_path) + _PATH_O3DE_BIN = Path(engine_bin) - if not _O3DE_BIN_PATH.exists(): - raise Exception('_O3DE_BIN_PATH does NOT exist: {0}'.format(_O3DE_BIN_PATH)) + if not _PATH_O3DE_BIN.exists(): + raise Exception('_PATH_O3DE_BIN does NOT exist: {0}'.format(_PATH_O3DE_BIN)) else: pass # python config - _DCCSI_PYTHON_PATH = Path(_DCCSI_PATH,'3rdParty','Python') - os.environ["DYNACONF_DCCSI_PYTHON_PATH"] = str(_DCCSI_PYTHON_PATH.resolve()) + _PATH_DCCSI_PYTHON = Path(_PATH_DCCSIG,'3rdParty','Python') + os.environ["DYNACONF_PATH_DCCSI_PYTHON"] = str(_PATH_DCCSI_PYTHON.resolve()) # # allows to retreive from settings.QTFORPYTHON_PATH # from azpy.constants import STR_QTFORPYTHON_PATH # a path string constructor @@ -180,7 +179,7 @@ def init_o3de_pyside2(dccsi_path=_DCCSI_PATH, # os.environ["DYNACONF_QTFORPYTHON_PATH"] = str(QTFORPYTHON_PATH) # site.addsitedir(str(QTFORPYTHON_PATH)) # PYTHONPATH - QT_PLUGIN_PATH = Path.joinpath(_O3DE_BIN_PATH,'EditorPlugins') + QT_PLUGIN_PATH = Path.joinpath(_PATH_O3DE_BIN,'EditorPlugins') os.environ["DYNACONF_QT_PLUGIN_PATH"] = str(QT_PLUGIN_PATH.resolve()) os.environ['PATH'] = QT_PLUGIN_PATH.as_posix() + os.pathsep + os.environ['PATH'] @@ -224,7 +223,7 @@ def init_o3de_pyside2(dccsi_path=_DCCSI_PATH, # have not done that yet as I really want to get legal approval and # add this to the QtForPython Gem # please pass this in current code reviews - _DCCSI_PYSIDE2_TOOLS = Path(_DCCSI_PYTHON_PATH,'pyside2-tools') + _DCCSI_PYSIDE2_TOOLS = Path(_PATH_DCCSI_PYTHON,'pyside2-tools') if _DCCSI_PYSIDE2_TOOLS.exists(): os.environ["DYNACONF_DCCSI_PYSIDE2_TOOLS"] = str(_DCCSI_PYSIDE2_TOOLS.resolve()) os.environ['PATH'] = _DCCSI_PYSIDE2_TOOLS.as_posix() + os.pathsep + os.environ['PATH'] @@ -242,10 +241,10 @@ def init_o3de_pyside2(dccsi_path=_DCCSI_PATH, status = False raise(e) else: - _LOGGER.warning('~ No PySide2 Tools: {}'.format(_DCCSI_PYSIDE2_TOOLS.resolve)) + _LOGGER.warning('~ No PySide2 Tools: {}'.format(_DCCSI_PYSIDE2_TOOLS.resolve())) - _O3DE_DCCSI_PATH = os.environ['PATH'] - os.environ["DYNACONF_PATH"] = _O3DE_DCCSI_PATH + _O3DE_PATH_DCCSIG = os.environ['PATH'] + os.environ["DYNACONF_PATH"] = _O3DE_PATH_DCCSIG try: _DCCSI_PYTHONPATH = os.environ['PYTHONPATH'] @@ -287,9 +286,8 @@ def test_pyside2(): # ------------------------------------------------------------------------- def init_o3de_core(engine_path=_O3DE_DEV, - build_folder=_O3DE_BUILD_FOLDER, project_name=None, - project_path=_O3DE_PROJECT_PATH): + project_path=_PATH_O3DE_PROJECT): """Initialize the DCCsi Core dynamic env and settings""" # `envvar_prefix` = export envvars with `export DYNACONF_FOO=bar`. # `settings_files` = Load this files in the order. @@ -306,70 +304,69 @@ def init_o3de_core(engine_path=_O3DE_DEV, os.environ["DYNACONF_DCCSI_DEV_MODE"] = str(_DCCSI_DEV_MODE) os.environ['DYNACONF_DCCSI_LOGLEVEL'] = str(_DCCSI_LOGLEVEL) - os.environ["DYNACONF_DCCSI_PATH"] = str(_DCCSI_PATH.resolve()) - os.environ['PATH'] = _DCCSI_PATH.as_posix() + os.pathsep + os.environ['PATH'] + os.environ["DYNACONF_PATH_DCCSIG"] = str(_PATH_DCCSIG.resolve()) + os.environ['PATH'] = _PATH_DCCSIG.as_posix() + os.pathsep + os.environ['PATH'] # we already defaulted to discovering these two early because of importance #os.environ["DYNACONF_O3DE_DEV"] = str(_O3DE_DEV.resolve()) - #os.environ["DYNACONF_O3DE_PROJECT_PATH"] = str(_O3DE_PROJECT_PATH) + #os.environ["DYNACONF_PATH_O3DE_PROJECT"] = str(_PATH_O3DE_PROJECT) # we also already added them to DYNACONF_ # this in an explicit pass in if project_path: _project_path = Path(project_path) try: _project_path.exists() - _O3DE_PROJECT_PATH = _project_path - os.environ["DYNACONF_O3DE_PROJECT_PATH"] = str(_O3DE_PROJECT_PATH.resolve()) + _PATH_O3DE_PROJECT = _project_path + os.environ["DYNACONF_PATH_O3DE_PROJECT"] = str(_PATH_O3DE_PROJECT.resolve()) except FileExistsError as e: _LOGGER.error('~ The project path specified does not appear to exist!') _LOGGER.warning('~ project_path: {}'.format(project_path)) _LOGGER.warning('~ fallback to engine root: {}'.format()) project_path = _O3DE_DEV - os.environ["DYNACONF_O3DE_PROJECT_PATH"] = str(_O3DE_DEV.resolve()) + os.environ["DYNACONF_PATH_O3DE_PROJECT"] = str(_O3DE_DEV.resolve()) # we can pull the O3DE_PROJECT (name) from the project path if not project_name: - project_name = Path(_O3DE_PROJECT_PATH).name + project_name = Path(_PATH_O3DE_PROJECT).name os.environ["DYNACONF_O3DE_PROJECT"] = str(project_name) # To Do: there might be a project namespace in the project.json? # -- O3DE build -- set up \bin\path (for Qt dll access) - os.environ["DYNACONF_O3DE_BUILD_FOLDER"] = str(build_folder) - _O3DE_BUILD_PATH = Path(_O3DE_DEV, build_folder) + _PATH_O3DE_BUILD = Path(azpy.config_utils.get_o3de_build_path(_O3DE_DEV, + 'CMakeCache.txt')) + os.environ["DYNACONF_PATH_O3DE_BUILD"] = str(_PATH_O3DE_BUILD.resolve()) - os.environ["DYNACONF_O3DE_BUILD_PATH"] = str(_O3DE_BUILD_PATH.resolve()) - - _O3DE_BIN_PATH = Path(STR_O3DE_BIN_PATH.format(_O3DE_BUILD_PATH)) - os.environ["DYNACONF_O3DE_BIN_PATH"] = str(_O3DE_BIN_PATH.resolve()) + _PATH_O3DE_BIN = Path(STR_PATH_O3DE_BIN.format(_PATH_O3DE_BUILD)) + os.environ["DYNACONF_PATH_O3DE_BIN"] = str(_PATH_O3DE_BIN.resolve()) # hard check - if not _O3DE_BIN_PATH.exists(): - raise Exception('O3DE_BIN_PATH does NOT exist: {0}'.format(_O3DE_BIN_PATH)) + if not _PATH_O3DE_BIN.exists(): + raise Exception('PATH_O3DE_BIN does NOT exist: {0}'.format(_PATH_O3DE_BIN)) else: # adding to sys.path apparently doesn't work for .dll locations like Qt - os.environ['PATH'] = _O3DE_BIN_PATH.as_posix() + os.pathsep + os.environ['PATH'] + os.environ['PATH'] = _PATH_O3DE_BIN.as_posix() + os.pathsep + os.environ['PATH'] # -- from azpy.constants import TAG_DIR_DCCSI_TOOLS - _DCCSI_TOOLS_PATH = Path(_DCCSI_PATH, TAG_DIR_DCCSI_TOOLS) - os.environ["DYNACONF_DCCSI_TOOLS_PATH"] = str(_DCCSI_TOOLS_PATH.resolve()) + _PATH_DCCSI_TOOLS = Path(_PATH_DCCSIG, TAG_DIR_DCCSI_TOOLS) + os.environ["DYNACONF_PATH_DCCSI_TOOLS"] = str(_PATH_DCCSI_TOOLS.resolve()) from azpy.constants import TAG_DCCSI_NICKNAME from azpy.constants import PATH_DCCSI_LOG_PATH - _DCCSI_LOG_PATH = Path(PATH_DCCSI_LOG_PATH.format(O3DE_PROJECT_PATH=project_path, + _DCCSI_LOG_PATH = Path(PATH_DCCSI_LOG_PATH.format(PATH_O3DE_PROJECT=project_path, TAG_DCCSI_NICKNAME=TAG_DCCSI_NICKNAME)) os.environ["DYNACONF_DCCSI_LOG_PATH"] = str(_DCCSI_LOG_PATH) from azpy.constants import TAG_DIR_REGISTRY, TAG_DCCSI_CONFIG - _DCCSI_CONFIG_PATH = Path(project_path, TAG_DIR_REGISTRY, TAG_DCCSI_CONFIG) - os.environ["DYNACONF_DCCSI_CONFIG_PATH"] = str(_DCCSI_CONFIG_PATH.resolve()) + _PATH_DCCSI_CONFIG = Path(project_path, TAG_DIR_REGISTRY, TAG_DCCSI_CONFIG) + os.environ["DYNACONF_PATH_DCCSI_CONFIG"] = str(_PATH_DCCSI_CONFIG.resolve()) from azpy.constants import TAG_DIR_DCCSI_TOOLS - _DCCSIG_TOOLS_PATH = Path.joinpath(_DCCSI_PATH, TAG_DIR_DCCSI_TOOLS) + _DCCSIG_TOOLS_PATH = Path.joinpath(_PATH_DCCSIG, TAG_DIR_DCCSI_TOOLS) os.environ["DYNACONF_DCCSIG_TOOLS_PATH"] = str(_DCCSIG_TOOLS_PATH.resolve()) - _O3DE_DCCSI_PATH = os.environ['PATH'] - os.environ["DYNACONF_PATH"] = _O3DE_DCCSI_PATH + _O3DE_PATH_DCCSIG = os.environ['PATH'] + os.environ["DYNACONF_PATH"] = _O3DE_PATH_DCCSIG from dynaconf import settings @@ -381,26 +378,26 @@ def init_o3de_core(engine_path=_O3DE_DEV, # ------------------------------------------------------------------------- def init_o3de_python(engine_path=_O3DE_DEV, - engine_bin=_O3DE_BIN_PATH, - dccsi_path=_DCCSI_PATH): + engine_bin=_PATH_O3DE_BIN, + dccsi_path=_PATH_DCCSIG): # pathify _O3DE_DEV = Path(engine_path) - _O3DE_BIN_PATH = Path(engine_bin) - _DCCSI_PATH = Path(dccsi_path) + _PATH_O3DE_BIN = Path(engine_bin) + _PATH_DCCSIG = Path(dccsi_path) # python config - _DCCSI_PYTHON_PATH = Path(_DCCSI_PATH,'3rdParty','Python') - os.environ["DYNACONF_DCCSI_PYTHON_PATH"] = str(_DCCSI_PYTHON_PATH.resolve()) + _PATH_DCCSI_PYTHON = Path(_PATH_DCCSIG,'3rdParty','Python') + os.environ["DYNACONF_PATH_DCCSI_PYTHON"] = str(_PATH_DCCSI_PYTHON.resolve()) - _DCCSI_PYTHON_LIB_PATH = azpy.config_utils.bootstrap_dccsi_py_libs(_DCCSI_PATH) - os.environ["DYNACONF_DCCSI_PYTHON_LIB_PATH"] = str(_DCCSI_PYTHON_LIB_PATH.resolve()) - os.environ['PATH'] = _DCCSI_PYTHON_LIB_PATH.as_posix() + os.pathsep + os.environ['PATH'] - site.addsitedir(_DCCSI_PYTHON_LIB_PATH) - _O3DE_PYTHONPATH.append(_DCCSI_PYTHON_LIB_PATH.resolve()) + _PATH_DCCSI_PYTHON_LIB = azpy.config_utils.bootstrap_dccsi_py_libs(_PATH_DCCSIG) + os.environ["DYNACONF_PATH_DCCSI_PYTHON_LIB"] = str(_PATH_DCCSI_PYTHON_LIB.resolve()) + os.environ['PATH'] = _PATH_DCCSI_PYTHON_LIB.as_posix() + os.pathsep + os.environ['PATH'] + site.addsitedir(_PATH_DCCSI_PYTHON_LIB) + _O3DE_PYTHONPATH.append(_PATH_DCCSI_PYTHON_LIB.resolve()) - site.addsitedir(_O3DE_BIN_PATH) - _O3DE_PYTHONPATH.append(_O3DE_BIN_PATH.resolve()) + site.addsitedir(_PATH_O3DE_BIN) + _O3DE_PYTHONPATH.append(_PATH_O3DE_BIN.resolve()) _O3DE_PY_EXE = Path(sys.executable) _DCCSI_PY_IDE = Path(_O3DE_PY_EXE) @@ -411,24 +408,24 @@ def init_o3de_python(engine_path=_O3DE_DEV, os.environ['PATH'] = _O3DE_PYTHONHOME.as_posix() + os.pathsep + os.environ['PATH'] _LOGGER.info('~ O3DE_PYTHONHOME - is now the folder containing O3DE python executable') - _O3DE_PYTHON_INSTALL = Path(_O3DE_DEV, 'python') - os.environ["DYNACONF_O3DE_PYTHON_INSTALL"] = str(_O3DE_PYTHON_INSTALL.resolve()) - os.environ['PATH'] = _O3DE_PYTHON_INSTALL.as_posix() + os.pathsep + os.environ['PATH'] + _PATH_O3DE_PYTHON_INSTALL = Path(_O3DE_DEV, 'python') + os.environ["DYNACONF_PATH_O3DE_PYTHON_INSTALL"] = str(_PATH_O3DE_PYTHON_INSTALL.resolve()) + os.environ['PATH'] = _PATH_O3DE_PYTHON_INSTALL.as_posix() + os.pathsep + os.environ['PATH'] if sys.platform.startswith('win'): - _DCCSI_PY_BASE = Path(_O3DE_PYTHON_INSTALL, 'python.cmd') + _DCCSI_PY_BASE = Path(_PATH_O3DE_PYTHON_INSTALL, 'python.cmd') elif sys.platform == "linux": - _DCCSI_PY_BASE = Path(_O3DE_PYTHON_INSTALL, 'python.sh') + _DCCSI_PY_BASE = Path(_PATH_O3DE_PYTHON_INSTALL, 'python.sh') elif sys.platform == "darwin": - _DCCSI_PY_BASE = Path(_O3DE_PYTHON_INSTALL, 'python.sh') + _DCCSI_PY_BASE = Path(_PATH_O3DE_PYTHON_INSTALL, 'python.sh') else: _DCCSI_PY_BASE = None if _DCCSI_PY_BASE: os.environ["DYNACONF_DCCSI_PY_BASE"] = str(_DCCSI_PY_BASE.resolve()) - _O3DE_DCCSI_PATH = os.environ['PATH'] - os.environ["DYNACONF_PATH"] = _O3DE_DCCSI_PATH + _O3DE_PATH_DCCSIG = os.environ['PATH'] + os.environ["DYNACONF_PATH"] = _O3DE_PATH_DCCSIG try: _DCCSI_PYTHONPATH = os.environ['PYTHONPATH'] @@ -447,23 +444,21 @@ def init_o3de_python(engine_path=_O3DE_DEV, # ------------------------------------------------------------------------- # settings.setenv() # doing this will add the additional DYNACONF_ envars def get_config_settings(engine_path=_O3DE_DEV, - build_folder=_O3DE_BUILD_FOLDER, project_name=None, - project_path=_O3DE_PROJECT_PATH, + project_path=_PATH_O3DE_PROJECT, enable_o3de_python=None, enable_o3de_pyside2=None, set_env=True): """Convenience method to initialize and retreive settings directly from module.""" settings = init_o3de_core(engine_path, - build_folder, project_name, project_path) if enable_o3de_python: settings = init_o3de_python(settings.O3DE_DEV, - settings.O3DE_BIN_PATH, - settings.DCCSI_PATH) + settings.PATH_O3DE_BIN, + settings.PATH_DCCSIG) # These should ONLY be set for O3DE and non-DCC environments # They will most likely cause other Qt/PySide DCC apps to fail @@ -474,8 +469,8 @@ def get_config_settings(engine_path=_O3DE_DEV, # assume our standalone python tools wants this access? # it's safe to do this for dev and from ide if enable_o3de_pyside2: - settings = init_o3de_pyside2(settings.DCCSI_PATH, - settings.O3DE_BIN_PATH) + settings = init_o3de_pyside2(settings.PATH_DCCSIG, + settings.PATH_O3DE_BIN) # now standalone we can validate the config. env, settings. from dynaconf import settings @@ -489,11 +484,11 @@ def get_config_settings(engine_path=_O3DE_DEV, # Main Code Block, runs this script as main (testing) # ------------------------------------------------------------------------- if __name__ == '__main__': - """Run this file as a standalone cli script""" + """Run this file as a standalone cli script for testing/debugging""" + import time + start = time.process_time() # start tracking - _MODULENAME = __name__ - if _MODULENAME is '__main__': - _MODULENAME = 'DCCsi.config' + _MODULENAME = 'DCCsi.config' from azpy.constants import STR_CROSSBAR @@ -508,7 +503,7 @@ if __name__ == '__main__': # happy print _LOGGER.info(STR_CROSSBAR) - _LOGGER.info('~ constants.py ... Running script as __main__') + _LOGGER.info('~ {}.py ... Running script as __main__'.format(_MODULENAME)) _LOGGER.info(STR_CROSSBAR) # go ahead and run the rest of the configuration @@ -521,6 +516,10 @@ if __name__ == '__main__': type=bool, required=False, help='Enables global debug flag.') + parser.add_argument('-sd', '--set-debugger', + type=str, + required=False, + help='Default debugger: WING, others: PYCHARM, VSCODE (not yet implemented).') parser.add_argument('-dm', '--developer-mode', type=bool, required=False, @@ -549,10 +548,6 @@ if __name__ == '__main__': type=bool, required=False, help='Enables O3DE Qt\PySide2 access.') - parser.add_argument('-sd', '--set-debugger', - type=str, - required=False, - help='Default debugger: WING, others: PYCHARM, VSCODE (not yet implemented).') parser.add_argument('-pc', '--project-config', type=bool, required=False, @@ -575,13 +570,15 @@ if __name__ == '__main__': if args.global_debug: _DCCSI_GDEBUG = True os.environ["DYNACONF_DCCSI_GDEBUG"] = str(_DCCSI_GDEBUG) - if args.developer_mode: - attach_debugger() # attempts to start debugger if args.set_debugger: - _LOGGER.info('Setting and switching debugger type from WingIDE not implemented.') + _LOGGER.info('Setting and switching debugger type not implemented (default=WING)') # To Do: implement debugger plugin pattern + if args.developer_mode: + _DCCSI_DEV_MODE = True + attach_debugger() # attempts to start debugger + # need to do a little plumbing if not args.engine_path: args.engine_path=_O3DE_DEV @@ -589,7 +586,7 @@ if __name__ == '__main__': from azpy.constants import TAG_DIR_O3DE_BUILD_FOLDER args.build_folder = TAG_DIR_O3DE_BUILD_FOLDER if not args.project_path: - args.project_path=_O3DE_PROJECT_PATH + args.project_path=_PATH_O3DE_PROJECT if _DCCSI_GDEBUG: args.enable_python = True @@ -597,7 +594,6 @@ if __name__ == '__main__': # now standalone we can validate the config. env, settings. settings = get_config_settings(engine_path=args.engine_path, - build_folder=args.build_folder, project_name=args.project_name, project_path=args.project_path, enable_o3de_python=args.enable_python, @@ -612,47 +608,54 @@ if __name__ == '__main__': _LOGGER.info('DCCSI_OS_FOLDER: {}'.format(settings.DCCSI_OS_FOLDER)) _LOGGER.info('O3DE_DEV: {}'.format(settings.O3DE_DEV)) - _LOGGER.info('O3DE_O3DE_BUILD_FOLDER: {}'.format(settings.O3DE_BUILD_PATH)) - _LOGGER.info('O3DE_BUILD_PATH: {}'.format(settings.O3DE_BUILD_PATH)) - _LOGGER.info('O3DE_BIN_PATH: {}'.format(settings.O3DE_BIN_PATH)) + _LOGGER.info('O3DE_O3DE_BUILD_FOLDER: {}'.format(settings.PATH_O3DE_BUILD)) + _LOGGER.info('PATH_O3DE_BUILD: {}'.format(settings.PATH_O3DE_BUILD)) + _LOGGER.info('PATH_O3DE_BIN: {}'.format(settings.PATH_O3DE_BIN)) _LOGGER.info('O3DE_PROJECT: {}'.format(settings.O3DE_PROJECT)) - _LOGGER.info('O3DE_PROJECT_PATH: {}'.format(settings.O3DE_PROJECT_PATH)) + _LOGGER.info('PATH_O3DE_PROJECT: {}'.format(settings.PATH_O3DE_PROJECT)) - _LOGGER.info('DCCSI_PATH: {}'.format(settings.DCCSI_PATH)) + _LOGGER.info('PATH_DCCSIG: {}'.format(settings.PATH_DCCSIG)) _LOGGER.info('DCCSI_LOG_PATH: {}'.format(settings.DCCSI_LOG_PATH)) - _LOGGER.info('DCCSI_CONFIG_PATH: {}'.format(settings.DCCSI_CONFIG_PATH)) + _LOGGER.info('PATH_DCCSI_CONFIG: {}'.format(settings.PATH_DCCSI_CONFIG)) - if settings.O3DE_DCCSI_ENV_TEST: + try: + settings.O3DE_DCCSI_ENV_TEST _LOGGER.info('O3DE_DCCSI_ENV_TEST: {}'.format(settings.O3DE_DCCSI_ENV_TEST)) + except: + pass # don't exist _LOGGER.info(STR_CROSSBAR) _LOGGER.info('') if args.enable_python: _LOGGER.info(STR_CROSSBAR) - _LOGGER.info('DCCSI_PYTHON_PATH'.format(settings.DCCSI_PYTHON_PATH)) - _LOGGER.info('DCCSI_PYTHON_LIB_PATH: {}'.format(settings.DCCSI_PYTHON_LIB_PATH)) + _LOGGER.info('PATH_DCCSI_PYTHON'.format(settings.PATH_DCCSI_PYTHON)) + _LOGGER.info('PATH_DCCSI_PYTHON_LIB: {}'.format(settings.PATH_DCCSI_PYTHON_LIB)) _LOGGER.info('DCCSI_PY_IDE'.format(settings.DCCSI_PY_IDE)) _LOGGER.info('O3DE_PYTHONHOME'.format(settings.O3DE_PYTHONHOME)) - _LOGGER.info('O3DE_PYTHON_INSTALL'.format(settings.O3DE_PYTHON_INSTALL)) + _LOGGER.info('PATH_O3DE_PYTHON_INSTALL'.format(settings.PATH_O3DE_PYTHON_INSTALL)) _LOGGER.info('DCCSI_PY_BASE: {}'.format(settings.DCCSI_PY_BASE)) _LOGGER.info(STR_CROSSBAR) _LOGGER.info('') else: - _LOGGER.info('Tip: add arg --enable-python to extend the environment with O3DE python access') + _LOGGER.info('Tip: add arg --enable-python (-py) to extend the environment with O3DE python access') if args.enable_qt: _LOGGER.info(STR_CROSSBAR) # _LOGGER.info('QTFORPYTHON_PATH: {}'.format(settings.QTFORPYTHON_PATH)) _LOGGER.info('QT_PLUGIN_PATH: {}'.format(settings.QT_PLUGIN_PATH)) _LOGGER.info('QT_QPA_PLATFORM_PLUGIN_PATH: {}'.format(settings.QT_QPA_PLATFORM_PLUGIN_PATH)) - _LOGGER.info('DCCSI_PYSIDE2_TOOLS: {}'.format(settings.DCCSI_PYSIDE2_TOOLS)) + try: + settings.DCCSI_PYSIDE2_TOOLS + _LOGGER.info('DCCSI_PYSIDE2_TOOLS: {}'.format(settings.DCCSI_PYSIDE2_TOOLS)) + except: + pass # don't exist _LOGGER.info(STR_CROSSBAR) _LOGGER.info('') else: - - _LOGGER.info('Tip: add arg --enable-qt to extend the environment with O3DE Qt/PySide2 support') + _LOGGER.info('Tip: add arg --enable-qt (-qt) to extend the environment with O3DE Qt/PySide2 support') + _LOGGER.info('Tip: add arg --test-pyside2 (-tp) to test the O3DE Qt/PySide2 support') settings.setenv() # doing this will add/set the additional DYNACONF_ envars @@ -695,14 +698,9 @@ if __name__ == '__main__': _LOGGER.warning("Could not import 'pyside2uic'") _LOGGER.warning("Refer to: '< local DCCsi >\3rdParty\Python\README.txt'") _LOGGER.error(e) + + _LOGGER.info('DCCsi: config.py took: {} sec'.format(time.process_time() - start)) # return sys.exit() -# --- END ----------------------------------------------------------------- - - - - - - - +# --- END ----------------------------------------------------------------- \ No newline at end of file From 33bfdc0bd30f0c453c14d06fe89808b07a7843e6 Mon Sep 17 00:00:00 2001 From: amzn-sean <75276488+amzn-sean@users.noreply.github.com> Date: Wed, 15 Dec 2021 16:44:38 +0000 Subject: [PATCH 49/70] corrected implementation of GetRealElapseTime (#6422) Signed-off-by: amzn-sean <75276488+amzn-sean@users.noreply.github.com> --- Code/Framework/AzCore/AzCore/Time/TimeSystem.cpp | 7 ++++++- Code/Framework/AzCore/AzCore/Time/TimeSystem.h | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Code/Framework/AzCore/AzCore/Time/TimeSystem.cpp b/Code/Framework/AzCore/AzCore/Time/TimeSystem.cpp index a5e0908ac4..f8e254d32d 100644 --- a/Code/Framework/AzCore/AzCore/Time/TimeSystem.cpp +++ b/Code/Framework/AzCore/AzCore/Time/TimeSystem.cpp @@ -62,6 +62,7 @@ namespace AZ TimeSystem::TimeSystem() { m_lastInvokedTimeUs = static_cast(AZStd::GetTimeNowMicroSecond()); + m_realLastInvokedTimeUs = static_cast(AZStd::GetTimeNowMicroSecond()); AZ::Interface::Register(this); ITimeRequestBus::Handler::BusConnect(); } @@ -101,7 +102,11 @@ namespace AZ TimeUs TimeSystem::GetRealElapsedTimeUs() const { - return static_cast(AZStd::GetTimeNowMicroSecond()); + const TimeUs currentTime = static_cast(AZStd::GetTimeNowMicroSecond()); + m_realAccumulatedTimeUs += currentTime - m_realLastInvokedTimeUs; + m_realLastInvokedTimeUs = currentTime; + + return m_realAccumulatedTimeUs; } TimeUs TimeSystem::GetSimulationTickDeltaTimeUs() const diff --git a/Code/Framework/AzCore/AzCore/Time/TimeSystem.h b/Code/Framework/AzCore/AzCore/Time/TimeSystem.h index ded70c9be5..9d5f2a6d7c 100644 --- a/Code/Framework/AzCore/AzCore/Time/TimeSystem.h +++ b/Code/Framework/AzCore/AzCore/Time/TimeSystem.h @@ -64,6 +64,14 @@ namespace AZ //! Mutable to allow GetElapsedTimeMs/TimeUs() to be a const functions. mutable TimeUs m_accumulatedTimeUs = AZ::Time::ZeroTimeUs; + //! Used to calculate the delta time between calls to GetRealElapsedTimeMs/TimeUs(). + //! Mutable to allow GetRealElapsedTimeMs/TimeUs() to be a const functions. + mutable TimeUs m_realLastInvokedTimeUs = AZ::Time::ZeroTimeUs; + + //! Accumulates the delta time of GetRealElapsedTimeMs/TimeUs() calls. + //! Mutable to allow GetRealElapsedTimeMs/TimeUs() to be a const functions. + mutable TimeUs m_realAccumulatedTimeUs = AZ::Time::ZeroTimeUs; + //! The current game tick delta time. //! Can be affected by time system cvars. //! Updated in AdvanceTickDeltaTimes(). From b640f6d691b97ae608081c9a4dd7cbddb019721a Mon Sep 17 00:00:00 2001 From: Qing Tao <55564570+VickyAtAZ@users.noreply.github.com> Date: Wed, 15 Dec 2021 08:56:28 -0800 Subject: [PATCH 50/70] ATOM-16958 [Image Builder] Alpha data would be removed for source image with alpha content (#6412) Fixed a regression issue with image builder which it can choose proper preset for images with alpha content. Signed-off-by: Qing Tao <55564570+VickyAtAZ@users.noreply.github.com> --- .../BuilderSettings/BuilderSettingManager.cpp | 14 ++++++++++++-- .../Code/Source/ImageBuilderComponent.cpp | 12 +++++++----- .../Code/Source/Processing/ImageConvert.cpp | 2 +- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/BuilderSettings/BuilderSettingManager.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/BuilderSettings/BuilderSettingManager.cpp index 1ae406c6fd..0e9681f38b 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/BuilderSettings/BuilderSettingManager.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/BuilderSettings/BuilderSettingManager.cpp @@ -620,6 +620,7 @@ namespace ImageProcessingAtom { PresetName emptyPreset; + //get file mask of this image file AZStd::string fileMask = GetFileMask(imageFilePath); @@ -636,8 +637,17 @@ namespace ImageProcessingAtom } if (outPreset == emptyPreset) - { - outPreset = m_defaultPreset; + { + auto image = IImageObjectPtr(LoadImageFromFile(imageFilePath)); + if (image->GetAlphaContent() == EAlphaContent::eAlphaContent_Absent + || image->GetAlphaContent() == EAlphaContent::eAlphaContent_OnlyWhite) + { + outPreset = m_defaultPreset; + } + else + { + outPreset = m_defaultPresetAlpha; + } } return outPreset; diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/ImageBuilderComponent.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/ImageBuilderComponent.cpp index c44cb39452..5e021a3fdd 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/ImageBuilderComponent.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/ImageBuilderComponent.cpp @@ -74,7 +74,7 @@ namespace ImageProcessingAtom builderDescriptor.m_busId = azrtti_typeid(); builderDescriptor.m_createJobFunction = AZStd::bind(&ImageBuilderWorker::CreateJobs, &m_imageBuilder, AZStd::placeholders::_1, AZStd::placeholders::_2); builderDescriptor.m_processJobFunction = AZStd::bind(&ImageBuilderWorker::ProcessJob, &m_imageBuilder, AZStd::placeholders::_1, AZStd::placeholders::_2); - builderDescriptor.m_version = 26; // [ATOM-15086] + builderDescriptor.m_version = 27; // [ATOM-16958] builderDescriptor.m_analysisFingerprint = ImageProcessingAtom::BuilderSettingManager::Instance()->GetAnalysisFingerprint(); m_imageBuilder.BusConnect(builderDescriptor.m_busId); AssetBuilderSDK::AssetBuilderBus::Broadcast(&AssetBuilderSDK::AssetBuilderBusTraits::RegisterBuilderInformation, builderDescriptor); @@ -284,6 +284,10 @@ namespace ImageProcessingAtom return; } + // Full path of the image file + AZStd::string fullPath; + AzFramework::StringFunc::Path::Join(request.m_watchFolder.data(), request.m_sourceFile.data(), fullPath, true, true); + // Get the extension of the file AZStd::string ext; AzFramework::StringFunc::Path::GetExtension(request.m_sourceFile.c_str(), ext, false); @@ -306,13 +310,11 @@ namespace ImageProcessingAtom // add source dependency for .assetinfo file AssetBuilderSDK::SourceFileDependency sourceFileDependency; sourceFileDependency.m_sourceDependencyType = AssetBuilderSDK::SourceFileDependency::SourceFileDependencyType::Absolute; - sourceFileDependency.m_sourceFileDependencyPath = request.m_sourceFile + TextureSettings::ExtensionName; + sourceFileDependency.m_sourceFileDependencyPath = fullPath + TextureSettings::ExtensionName; response.m_sourceFileDependencyList.push_back(sourceFileDependency); // add source dependencies for .preset files - // Get the preset for this file - AZ::IO::FixedMaxPath fullPath(request.m_watchFolder); - fullPath /= request.m_sourceFile; + // Get the preset for this file auto presetName = GetImagePreset(fullPath.c_str()); HandlePresetDependency(presetName, response.m_sourceFileDependencyList); diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageConvert.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageConvert.cpp index defca690a3..058daf7ca4 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageConvert.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageConvert.cpp @@ -193,7 +193,7 @@ namespace ImageProcessingAtom } m_image->Get()->Swizzle(swizzle.c_str()); - if (!m_input->m_presetSetting.m_discardAlpha) + if (m_input->m_presetSetting.m_discardAlpha) { m_alphaContent = EAlphaContent::eAlphaContent_Absent; } From 024c53ece39b183d93ef3e57dee96d515e5bf090 Mon Sep 17 00:00:00 2001 From: carlitosan <82187351+carlitosan@users.noreply.github.com> Date: Wed, 15 Dec 2021 10:24:32 -0800 Subject: [PATCH 51/70] untested fix for object stream version bug Signed-off-by: carlitosan <82187351+carlitosan@users.noreply.github.com> --- .../Code/Editor/Components/EditorScriptCanvasComponent.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/ScriptCanvas/Code/Editor/Components/EditorScriptCanvasComponent.cpp b/Gems/ScriptCanvas/Code/Editor/Components/EditorScriptCanvasComponent.cpp index be5d467f44..1f08207a48 100644 --- a/Gems/ScriptCanvas/Code/Editor/Components/EditorScriptCanvasComponent.cpp +++ b/Gems/ScriptCanvas/Code/Editor/Components/EditorScriptCanvasComponent.cpp @@ -157,7 +157,7 @@ namespace ScriptCanvasEditor auto assetId = assetHolder.m_scriptCanvasAsset.GetId(); auto path = assetHolder.m_scriptCanvasAsset.GetHint(); - if (!rootElement.AddElementWithData(serializeContext, "runtimeDataOverrides", SourceHandle(nullptr, assetId.m_guid, path))) + if (!rootElement.AddElementWithData(serializeContext, "sourceHandle", SourceHandle(nullptr, assetId.m_guid, path))) { AZ_Error("ScriptCanvas", false, "EditorScriptCanvasComponent conversion failed: failed to add 'sourceHandle'"); return false; From 797af76f0e1f5f13f2191c7f1776474af659cb89 Mon Sep 17 00:00:00 2001 From: dmcdiarmid-ly <63674186+dmcdiarmid-ly@users.noreply.github.com> Date: Wed, 15 Dec 2021 12:08:11 -0700 Subject: [PATCH 52/70] Minor changes to DiffuseProbeGridDownsamplePass Signed-off-by: dmcdiarmid-ly <63674186+dmcdiarmid-ly@users.noreply.github.com> --- .../DiffuseProbeGridDownsamplePass.cpp | 13 ++++++++++++- .../DiffuseProbeGridDownsamplePass.h | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGridDownsamplePass.cpp b/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGridDownsamplePass.cpp index 2a11218b47..e00213c524 100644 --- a/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGridDownsamplePass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGridDownsamplePass.cpp @@ -27,8 +27,19 @@ namespace AZ bool DiffuseProbeGridDownsamplePass::IsEnabled() const { + if (!Base::IsEnabled()) + { + return false; + } + + RPI::Scene* scene = m_pipeline->GetScene(); + if (!scene) + { + return false; + } + // only enabled if there are DiffuseProbeGrids present in the scene - DiffuseProbeGridFeatureProcessor* diffuseProbeGridFeatureProcessor = m_pipeline->GetScene()->GetFeatureProcessor(); + DiffuseProbeGridFeatureProcessor* diffuseProbeGridFeatureProcessor = scene->GetFeatureProcessor(); return (diffuseProbeGridFeatureProcessor && !diffuseProbeGridFeatureProcessor->GetProbeGrids().empty()); } diff --git a/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGridDownsamplePass.h b/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGridDownsamplePass.h index 283c758c76..de5a981fa1 100644 --- a/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGridDownsamplePass.h +++ b/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGridDownsamplePass.h @@ -18,10 +18,11 @@ namespace AZ class DiffuseProbeGridDownsamplePass : public RPI::FullscreenTrianglePass { + using Base = RPI::FullscreenTrianglePass; AZ_RPI_PASS(DiffuseProbeGridDownsamplePass); public: - AZ_RTTI(Render::DiffuseProbeGridDownsamplePass, "{B3331B68-F974-44D6-806B-2CFFB4B6B563}", FullscreenTrianglePass); + AZ_RTTI(Render::DiffuseProbeGridDownsamplePass, "{B3331B68-F974-44D6-806B-2CFFB4B6B563}", Base); AZ_CLASS_ALLOCATOR(Render::DiffuseProbeGridDownsamplePass, SystemAllocator, 0); //! Creates a new pass without a PassTemplate From 1fdee48b6d86d1a11d6674014696cace21377e2d Mon Sep 17 00:00:00 2001 From: carlitosan <82187351+carlitosan@users.noreply.github.com> Date: Wed, 15 Dec 2021 11:08:23 -0800 Subject: [PATCH 53/70] fix Linux build error Signed-off-by: carlitosan <82187351+carlitosan@users.noreply.github.com> --- .../Code/Editor/Components/EditorScriptCanvasComponent.cpp | 7 +++++-- .../ScriptCanvas/Components/EditorDeprecationData.cpp | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Gems/ScriptCanvas/Code/Editor/Components/EditorScriptCanvasComponent.cpp b/Gems/ScriptCanvas/Code/Editor/Components/EditorScriptCanvasComponent.cpp index 1f08207a48..bb9e829bf5 100644 --- a/Gems/ScriptCanvas/Code/Editor/Components/EditorScriptCanvasComponent.cpp +++ b/Gems/ScriptCanvas/Code/Editor/Components/EditorScriptCanvasComponent.cpp @@ -145,10 +145,13 @@ namespace ScriptCanvasEditor } } - if (rootElement.GetVersion() < EditorScriptCanvasComponentCpp::Version::AddSourceHandle) + auto scriptCanvasAssetHolderElementIndex = rootElement.FindElement(AZ_CRC_CE("m_assetHolder")); + if (scriptCanvasAssetHolderElementIndex != -1) { + auto& scriptCanvasAssetHolderElement = rootElement.GetSubElement(scriptCanvasAssetHolderElementIndex); Deprecated::ScriptCanvasAssetHolder assetHolder; - if (!rootElement.FindSubElementAndGetData(AZ_CRC_CE("m_assetHolder"), assetHolder)) + + if (!scriptCanvasAssetHolderElement.GetData(assetHolder)) { AZ_Error("ScriptCanvas", false, "EditorScriptCanvasComponent conversion failed: could not retrieve old 'm_assetHolder'"); return false; diff --git a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorDeprecationData.cpp b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorDeprecationData.cpp index 635f6e09e9..e94ef68234 100644 --- a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorDeprecationData.cpp +++ b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorDeprecationData.cpp @@ -10,6 +10,7 @@ #include #include +#include namespace ScriptCanvasEditor { From f82b3292919cad5a8915baf2f4ae96daf5360c27 Mon Sep 17 00:00:00 2001 From: rgba16f <82187279+rgba16f@users.noreply.github.com> Date: Wed, 15 Dec 2021 15:06:05 -0600 Subject: [PATCH 54/70] Minor optimizations from profiling. (#6416) Remove noisy profile marker in the SRG validator Make the SRG compile marker say which srg is being compiled Move some dx12 validation code behind the AZ_RHI_ENABLE_VALIDATION define Signed-off-by: rgba16f <82187279+rgba16f@users.noreply.github.com> --- Gems/Atom/RHI/Code/Source/RHI/CommandListValidator.cpp | 1 - Gems/Atom/RHI/Code/Source/RHI/ShaderResourceGroupPool.cpp | 4 ++-- Gems/Atom/RHI/DX12/Code/Source/RHI/CommandList.h | 4 +++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Gems/Atom/RHI/Code/Source/RHI/CommandListValidator.cpp b/Gems/Atom/RHI/Code/Source/RHI/CommandListValidator.cpp index 58c2136e2f..ec5220aeeb 100644 --- a/Gems/Atom/RHI/Code/Source/RHI/CommandListValidator.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI/CommandListValidator.cpp @@ -56,7 +56,6 @@ namespace AZ { return true; } - AZ_PROFILE_FUNCTION(RHI); ValidateViewContext context; context.m_scopeName = m_scope->GetId().GetCStr(); context.m_srgName = shaderResourceGroup.GetName().GetCStr(); diff --git a/Gems/Atom/RHI/Code/Source/RHI/ShaderResourceGroupPool.cpp b/Gems/Atom/RHI/Code/Source/RHI/ShaderResourceGroupPool.cpp index 3209a30f1a..5d1da487ab 100644 --- a/Gems/Atom/RHI/Code/Source/RHI/ShaderResourceGroupPool.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI/ShaderResourceGroupPool.cpp @@ -248,8 +248,6 @@ namespace AZ void ShaderResourceGroupPool::CompileGroupsForInterval(Interval interval) { - AZ_PROFILE_SCOPE(RHI, "CompileGroupsForInterval"); - AZ_Assert(m_isCompiling, "You must call CompileGroupsBegin() first!"); AZ_Assert( interval.m_max >= interval.m_min && @@ -259,6 +257,8 @@ namespace AZ for (uint32_t i = interval.m_min; i < interval.m_max; ++i) { ShaderResourceGroup* group = m_groupsToCompile[i]; + AZ_PROFILE_SCOPE(RHI, "CompileGroupsForInterval %s", group->GetName().GetCStr()); + CompileGroupInternal(*group, group->GetData()); group->m_isQueuedForCompile = false; } diff --git a/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandList.h b/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandList.h index 1472cdc80e..da71d669b4 100644 --- a/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandList.h +++ b/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandList.h @@ -390,7 +390,6 @@ namespace AZ } const PipelineLayout& pipelineLayout = pipelineState->GetPipelineLayout(); - const RHI::PipelineLayoutDescriptor& pipelineLayoutDescriptor = pipelineLayout.GetPipelineLayoutDescriptor(); // Pull from slot bindings dictated by the pipeline layout. Re-bind anything that has changed // at the flat index level. @@ -499,12 +498,15 @@ namespace AZ } } +#if defined (AZ_RHI_ENABLE_VALIDATION) if (updatePipelineState || updateSRG) { + const RHI::PipelineLayoutDescriptor& pipelineLayoutDescriptor = pipelineLayout.GetPipelineLayoutDescriptor(); m_validator.ValidateShaderResourceGroup( *shaderResourceGroup, pipelineLayoutDescriptor.GetShaderResourceGroupBindingInfo(srgIndex)); } +#endif } return true; } From 3a4eb3785a94f4f1739d68df1d6dfde41c1ecdc1 Mon Sep 17 00:00:00 2001 From: Roman <69218254+amzn-rhhong@users.noreply.github.com> Date: Wed, 15 Dec 2021 13:21:22 -0800 Subject: [PATCH 55/70] small bugfix (#6420) Signed-off-by: rhhong --- .../EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.cpp | 3 +++ .../EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.h | 1 + .../EMotionFXAtom/Code/Tools/EMStudio/AnimViewportToolBar.cpp | 1 + 3 files changed, 5 insertions(+) diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.cpp b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.cpp index ef6ff4681a..5e4afb68c7 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.cpp +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.cpp @@ -326,6 +326,9 @@ namespace EMStudio Camera::Configuration cameraConfig; cameraConfig.m_fovRadians = AZ::DegToRad(m_renderOptions->GetFOV()); cameraConfig.m_nearClipDistance = m_renderOptions->GetNearClipPlaneDistance(); + cameraConfig.m_farClipDistance = m_renderOptions->GetFarClipPlaneDistance(); + cameraConfig.m_frustumWidth = DefaultFrustumDimension; + cameraConfig.m_frustumHeight = DefaultFrustumDimension; preset->ApplyLightingPreset( iblFeatureProcessor, m_skyboxFeatureProcessor, exposureControlSettingInterface, m_directionalLightFeatureProcessor, diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.h b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.h index 27e62bb130..10745c6c26 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.h +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportRenderer.h @@ -89,6 +89,7 @@ namespace EMStudio AZStd::vector m_actorEntities; const RenderOptions* m_renderOptions; + const float DefaultFrustumDimension = 128.0f; AZStd::vector m_lightHandles; }; } diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportToolBar.cpp b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportToolBar.cpp index 0cf6dd70b3..962c9417b7 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportToolBar.cpp +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AnimViewportToolBar.cpp @@ -162,6 +162,7 @@ namespace EMStudio const bool isChecked = settings.value("CameraFollowUp", false).toBool(); m_followCharacterAction->setChecked(isChecked); + AnimViewportRequestBus::Broadcast(&AnimViewportRequestBus::Events::SetFollowCharacter, isChecked); } void AnimViewportToolBar::SaveSettings() From cf9385fc39c737e838dddf6d16102d64dc1163e6 Mon Sep 17 00:00:00 2001 From: tjmgd <92784061+tjmgd@users.noreply.github.com> Date: Wed, 15 Dec 2021 23:42:14 +0000 Subject: [PATCH 56/70] Garbled name when using Chinese charaters (#6379) Signed-off-by: T.J. McGrath-Daly --- Gems/EMotionFX/Code/MysticQt/Source/MysticQtConfig.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gems/EMotionFX/Code/MysticQt/Source/MysticQtConfig.h b/Gems/EMotionFX/Code/MysticQt/Source/MysticQtConfig.h index 9f3f2351cd..9b756b1db2 100644 --- a/Gems/EMotionFX/Code/MysticQt/Source/MysticQtConfig.h +++ b/Gems/EMotionFX/Code/MysticQt/Source/MysticQtConfig.h @@ -35,14 +35,14 @@ enum // convert from a QString into an AZStd::string MCORE_INLINE AZStd::string FromQtString(const QString& s) { - return {s.toUtf8().data(), static_cast(s.size())}; + return { s.toUtf8().data(), static_cast(s.toUtf8().length()) }; } // convert from a QString into an AZStd::string MCORE_INLINE void FromQtString(const QString& s, AZStd::string* result) { - *result = AZStd::string{s.toUtf8().data(), static_cast(s.size())}; + *result = AZStd::string{ s.toUtf8().data(), static_cast(s.toUtf8().length()) }; } inline QString FromStdString(AZStd::string_view s) From 0a8ba357382fc87040444278910b80c32fb668a8 Mon Sep 17 00:00:00 2001 From: antonmic <56370189+antonmic@users.noreply.github.com> Date: Wed, 15 Dec 2021 18:32:59 -0800 Subject: [PATCH 57/70] Added ClearPass and automatic instantiation from ParentPass for slots specifying a clear action Signed-off-by: antonmic <56370189+antonmic@users.noreply.github.com> --- .../Feature/Common/Assets/Passes/Clear.pass | 30 ++++++++++ .../Assets/Passes/PassTemplates.azasset | 4 ++ .../Passes/SMAA1xApplyLinearHDRColor.pass | 5 +- .../Passes/SMAA1xApplyPerceptualColor.pass | 5 +- .../atom_feature_common_asset_files.cmake | 4 ++ .../PostProcessing/EyeAdaptationPass.cpp | 2 - .../Include/Atom/RPI.Public/Pass/ClearPass.h | 45 +++++++++++++++ .../Include/Atom/RPI.Public/Pass/ParentPass.h | 4 ++ .../Atom/RPI.Reflect/Pass/ClearPassData.h | 43 ++++++++++++++ .../Code/Source/RPI.Public/Pass/ClearPass.cpp | 57 +++++++++++++++++++ .../Source/RPI.Public/Pass/ParentPass.cpp | 50 +++++++++++++++- .../Source/RPI.Public/Pass/PassFactory.cpp | 2 + .../Source/RPI.Public/Pass/PassSystem.cpp | 2 + .../Atom/RPI/Code/atom_rpi_public_files.cmake | 2 + .../RPI/Code/atom_rpi_reflect_files.cmake | 1 + 15 files changed, 245 insertions(+), 11 deletions(-) create mode 100644 Gems/Atom/Feature/Common/Assets/Passes/Clear.pass create mode 100644 Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ClearPass.h create mode 100644 Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Pass/ClearPassData.h create mode 100644 Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ClearPass.cpp diff --git a/Gems/Atom/Feature/Common/Assets/Passes/Clear.pass b/Gems/Atom/Feature/Common/Assets/Passes/Clear.pass new file mode 100644 index 0000000000..a36c2ef03d --- /dev/null +++ b/Gems/Atom/Feature/Common/Assets/Passes/Clear.pass @@ -0,0 +1,30 @@ +{ + "Type": "JsonSerialization", + "Version": 1, + "ClassName": "PassAsset", + "ClassData": { + "PassTemplate": { + "Name": "ClearPassTemplate", + "PassClass": "ClearPass", + "Slots": [ + { + "Name": "ClearInputOutput", + "SlotType": "InputOutput", + "ScopeAttachmentUsage": "RenderTarget", + "LoadStoreAction": { + "ClearValue": { + "Value": [ + 0.0, + 0.0, + 0.0, + 0.0 + ] + }, + "LoadAction": "Clear", + "LoadActionStencil": "Clear" + } + } + ] + } + } +} diff --git a/Gems/Atom/Feature/Common/Assets/Passes/PassTemplates.azasset b/Gems/Atom/Feature/Common/Assets/Passes/PassTemplates.azasset index eba745fb3c..b16536b276 100644 --- a/Gems/Atom/Feature/Common/Assets/Passes/PassTemplates.azasset +++ b/Gems/Atom/Feature/Common/Assets/Passes/PassTemplates.azasset @@ -64,6 +64,10 @@ "Name": "CascadedShadowmapsTemplate", "Path": "Passes/CascadedShadowmaps.pass" }, + { + "Name": "ClearPassTemplate", + "Path": "Passes/Clear.pass" + }, { "Name": "FullscreenCopyTemplate", "Path": "Passes/FullscreenCopy.pass" diff --git a/Gems/Atom/Feature/Common/Assets/Passes/SMAA1xApplyLinearHDRColor.pass b/Gems/Atom/Feature/Common/Assets/Passes/SMAA1xApplyLinearHDRColor.pass index 70604fba25..9ae0f62bc7 100644 --- a/Gems/Atom/Feature/Common/Assets/Passes/SMAA1xApplyLinearHDRColor.pass +++ b/Gems/Atom/Feature/Common/Assets/Passes/SMAA1xApplyLinearHDRColor.pass @@ -25,10 +25,7 @@ { "Name": "OutputColor", "SlotType": "Output", - "ScopeAttachmentUsage": "RenderTarget", - "LoadStoreAction": { - "LoadAction": "DontCare" - } + "ScopeAttachmentUsage": "RenderTarget" } ], "Connections": [ diff --git a/Gems/Atom/Feature/Common/Assets/Passes/SMAA1xApplyPerceptualColor.pass b/Gems/Atom/Feature/Common/Assets/Passes/SMAA1xApplyPerceptualColor.pass index 27fcff21cf..04484e1f17 100644 --- a/Gems/Atom/Feature/Common/Assets/Passes/SMAA1xApplyPerceptualColor.pass +++ b/Gems/Atom/Feature/Common/Assets/Passes/SMAA1xApplyPerceptualColor.pass @@ -25,10 +25,7 @@ { "Name": "OutputColor", "SlotType": "Output", - "ScopeAttachmentUsage": "RenderTarget", - "LoadStoreAction": { - "LoadAction": "DontCare" - } + "ScopeAttachmentUsage": "RenderTarget" } ], "Connections": [ diff --git a/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake b/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake index c4d198fef9..a684b4b299 100644 --- a/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake +++ b/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake @@ -53,6 +53,7 @@ set(FILES Materials/Types/StandardPBR_LowEndForward.azsl Materials/Types/StandardPBR_LowEndForward.shader Materials/Types/StandardPBR_LowEndForward_EDS.shader + Materials/Types/StandardPBR_Metallic.lua Materials/Types/StandardPBR_ParallaxState.lua Materials/Types/StandardPBR_Roughness.lua Materials/Types/StandardPBR_ShaderEnable.lua @@ -85,6 +86,7 @@ set(FILES Passes/CascadedShadowmaps.pass Passes/CheckerboardResolveColor.pass Passes/CheckerboardResolveDepth.pass + Passes/Clear.pass Passes/ContrastAdaptiveSharpening.pass Passes/ConvertToAcescg.pass Passes/DebugOverlayParent.pass @@ -129,6 +131,7 @@ set(FILES Passes/DownsampleMipChain.pass Passes/EnvironmentCubeMapDepthMSAA.pass Passes/EnvironmentCubeMapForwardMSAA.pass + Passes/EnvironmentCubeMapForwardSubsurfaceMSAA.pass Passes/EnvironmentCubeMapPipeline.pass Passes/EnvironmentCubeMapSkyBox.pass Passes/EsmShadowmaps.pass @@ -303,6 +306,7 @@ set(FILES ShaderLib/Atom/Features/ScreenSpace/ScreenSpaceUtil.azsli ShaderLib/Atom/Features/Shadow/BicubicPcfFilters.azsli ShaderLib/Atom/Features/Shadow/DirectionalLightShadow.azsli + ShaderLib/Atom/Features/Shadow/ESM.azsli ShaderLib/Atom/Features/Shadow/NormalOffsetShadows.azsli ShaderLib/Atom/Features/Shadow/ProjectedShadow.azsli ShaderLib/Atom/Features/Shadow/ReceiverPlaneDepthBias.azsli diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.cpp b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.cpp index 5683241693..20254690f9 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.cpp @@ -73,8 +73,6 @@ namespace AZ return false; } - AZ_Assert(m_pipeline->GetScene(), "EyeAdaptationPass's Pipeline does not have a valid scene pointer"); - AZ::RPI::Scene* scene = GetScene(); bool enabled = false; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ClearPass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ClearPass.h new file mode 100644 index 0000000000..e917584fca --- /dev/null +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ClearPass.h @@ -0,0 +1,45 @@ +/* + * 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 + * + */ +#pragma once + +#include + +#include +#include +#include + +#include + +namespace AZ +{ + namespace RPI + { + //! A simple pass to clear a render target + class ClearPass + : public RenderPass + { + AZ_RPI_PASS(ClearPass); + + public: + AZ_RTTI(ClearPass, "{31CBAD6C-108F-4F3F-B498-ED968DFCFCE2}", RenderPass); + AZ_CLASS_ALLOCATOR(ClearPass, SystemAllocator, 0); + virtual ~ClearPass() = default; + + //! Creates a ClearPass + static Ptr Create(const PassDescriptor& descriptor); + + protected: + ClearPass(const PassDescriptor& descriptor); + void InitializeInternal() override; + + private: + + RHI::ClearValue m_clearValue; + }; + } // namespace RPI +} // namespace AZ diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ParentPass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ParentPass.h index 6523f0a6d8..6ee0b43ce5 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ParentPass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ParentPass.h @@ -131,6 +131,10 @@ namespace AZ // Generates child passes from source PassTemplate void CreatePassesFromTemplate(); + + // Generates child clear passes to clear input and input/output attachments + void CreateClearPassFromBinding(PassAttachmentBinding& binding, PassRequest& clearRequest); + void CreateClearPassesFromBindings(); }; template diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Pass/ClearPassData.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Pass/ClearPassData.h new file mode 100644 index 0000000000..5eed6d54fa --- /dev/null +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Pass/ClearPassData.h @@ -0,0 +1,43 @@ +/* + * 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 + * + */ +#pragma once + +#include + +#include + +namespace AZ +{ + namespace RPI + { + //! Custom data for the ClearPass. Should be specified in the PassRequest. + struct ClearPassData + : public RenderPassData + { + AZ_RTTI(ClearPassData, "{5F2C24A4-62D0-4E60-91EC-C207C10D15C6}", RenderPassData); + AZ_CLASS_ALLOCATOR(ClearPassData, SystemAllocator, 0); + + ClearPassData() = default; + virtual ~ClearPassData() = default; + + static void Reflect(ReflectContext* context) + { + if (auto* serializeContext = azrtti_cast(context)) + { + serializeContext->Class() + ->Version(0) + ->Field("ClearValue", &ClearPassData::m_clearValue) + ; + } + } + + RHI::ClearValue m_clearValue; + }; + } // namespace RPI +} // namespace AZ + diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ClearPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ClearPass.cpp new file mode 100644 index 0000000000..1ba16f4b5a --- /dev/null +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ClearPass.cpp @@ -0,0 +1,57 @@ +/* + * 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 + +namespace AZ +{ + namespace RPI + { + Ptr ClearPass::Create(const PassDescriptor& descriptor) + { + Ptr pass = aznew ClearPass(descriptor); + return pass; + } + + ClearPass::ClearPass(const PassDescriptor& descriptor) + : RenderPass(descriptor) + { + const ClearPassData* passData = PassUtils::GetPassData(descriptor); + if (passData != nullptr) + { + m_clearValue = passData->m_clearValue; + } + } + + void ClearPass::InitializeInternal() + { + RenderPass::InitializeInternal(); + + // Set clear value + AZ_Assert(GetInputOutputCount() > 0, "ClearPass: Missing InputOutput binding!"); + RPI::PassAttachmentBinding& binding = GetInputOutputBinding(0); + binding.m_unifiedScopeDesc.m_loadStoreAction.m_clearValue = m_clearValue; + } + + } // namespace RPI +} // namespace AZ diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp index dccf5dbc2e..f0154b371a 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp @@ -9,11 +9,15 @@ #include #include +#include #include +#include #include #include #include +#include +#include #include namespace AZ @@ -196,7 +200,7 @@ namespace AZ } } - // --- PassTemplate related functions --- + // --- Child creation --- void ParentPass::CreatePassesFromTemplate() { @@ -217,6 +221,49 @@ namespace AZ } } + void ParentPass::CreateClearPassFromBinding(PassAttachmentBinding& binding, PassRequest& clearRequest) + { + if (binding.m_unifiedScopeDesc.m_loadStoreAction.m_loadAction == RHI::AttachmentLoadAction::Clear || + binding.m_unifiedScopeDesc.m_loadStoreAction.m_loadActionStencil == RHI::AttachmentLoadAction::Clear) + { + // Set the name of the child clear pass as well as the binding it's connected to + clearRequest.m_passName = ConcatPassName(Name("Clear"), binding.m_name); + clearRequest.m_connections[0].m_attachmentRef.m_attachment = binding.m_name; + + // Set the pass clear value to the clear value of the attachment binding + ClearPassData* clearData = static_cast(clearRequest.m_passData.get()); + clearData->m_clearValue = binding.m_unifiedScopeDesc.m_loadStoreAction.m_clearValue; + + // Create and add the pass + Ptr clearPass = PassSystemInterface::Get()->CreatePassFromRequest(&clearRequest); + if (clearPass) + { + AddChild(clearPass); + } + } + + } + + void ParentPass::CreateClearPassesFromBindings() + { + PassRequest clearRequest; + clearRequest.m_templateName = Name("ClearPassTemplate"); + clearRequest.m_passData = AZStd::make_shared(); + clearRequest.m_connections.push_back(); + clearRequest.m_connections[0].m_localSlot = Name("ClearInputOutput"); + clearRequest.m_connections[0].m_attachmentRef.m_pass = Name("Parent"); + + for (uint32_t idx = 0; idx < GetInputCount(); ++idx) + { + CreateClearPassFromBinding(GetInputBinding(idx), clearRequest); + } + + for (uint32_t idx = 0; idx < GetInputOutputCount(); ++idx) + { + CreateClearPassFromBinding(GetInputOutputBinding(idx), clearRequest); + } + } + // --- Pass behavior functions --- void ParentPass::CreateChildPasses() @@ -229,6 +276,7 @@ namespace AZ m_flags.m_alreadyCreatedChildren = true; RemoveChildren(); + CreateClearPassesFromBindings(); CreatePassesFromTemplate(); CreateChildPassesInternal(); diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassFactory.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassFactory.cpp index ef8d7a3fae..7443c51bff 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassFactory.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassFactory.cpp @@ -8,6 +8,7 @@ #include +#include #include #include #include @@ -60,6 +61,7 @@ namespace AZ { AddPassCreator(Name("ParentPass"), &ParentPass::Create); AddPassCreator(Name("RasterPass"), &RasterPass::Create); + AddPassCreator(Name("ClearPass"), &ClearPass::Create); AddPassCreator(Name("CopyPass"), &CopyPass::Create); AddPassCreator(Name("FullScreenTriangle"), &FullscreenTrianglePass::Create); AddPassCreator(Name("ComputePass"), &ComputePass::Create); diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp index cd64010680..f45d28518f 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -67,6 +68,7 @@ namespace AZ PassSlot::Reflect(context); PassData::Reflect(context); + ClearPassData::Reflect(context); CopyPassData::Reflect(context); RenderPassData::Reflect(context); ComputePassData::Reflect(context); diff --git a/Gems/Atom/RPI/Code/atom_rpi_public_files.cmake b/Gems/Atom/RPI/Code/atom_rpi_public_files.cmake index 93b85375f0..91dcf479e9 100644 --- a/Gems/Atom/RPI/Code/atom_rpi_public_files.cmake +++ b/Gems/Atom/RPI/Code/atom_rpi_public_files.cmake @@ -57,6 +57,7 @@ set(FILES Include/Atom/RPI.Public/Model/ModelSystem.h Include/Atom/RPI.Public/Model/UvStreamTangentBitmask.h Include/Atom/RPI.Public/Pass/AttachmentReadback.h + Include/Atom/RPI.Public/Pass/ClearPass.h Include/Atom/RPI.Public/Pass/ComputePass.h Include/Atom/RPI.Public/Pass/CopyPass.h Include/Atom/RPI.Public/Pass/FullscreenTrianglePass.h @@ -135,6 +136,7 @@ set(FILES Source/RPI.Public/Model/ModelSystem.cpp Source/RPI.Public/Model/UvStreamTangentBitmask.cpp Source/RPI.Public/Pass/AttachmentReadback.cpp + Source/RPI.Public/Pass/ClearPass.cpp Source/RPI.Public/Pass/ComputePass.cpp Source/RPI.Public/Pass/CopyPass.cpp Source/RPI.Public/Pass/FullscreenTrianglePass.cpp diff --git a/Gems/Atom/RPI/Code/atom_rpi_reflect_files.cmake b/Gems/Atom/RPI/Code/atom_rpi_reflect_files.cmake index 4f0e432511..921d5a8e46 100644 --- a/Gems/Atom/RPI/Code/atom_rpi_reflect_files.cmake +++ b/Gems/Atom/RPI/Code/atom_rpi_reflect_files.cmake @@ -62,6 +62,7 @@ set(FILES Include/Atom/RPI.Reflect/Material/ShaderCollection.h Include/Atom/RPI.Reflect/Material/MaterialFunctor.h Include/Atom/RPI.Reflect/Material/MaterialVersionUpdate.h + Include/Atom/RPI.Reflect/Pass/ClearPassData.h Include/Atom/RPI.Reflect/Pass/ComputePassData.h Include/Atom/RPI.Reflect/Pass/CopyPassData.h Include/Atom/RPI.Reflect/Pass/DownsampleMipChainPassData.h From 18bb69a5cbecf53ce9388300090391bbc5aba071 Mon Sep 17 00:00:00 2001 From: antonmic <56370189+antonmic@users.noreply.github.com> Date: Wed, 15 Dec 2021 18:37:48 -0800 Subject: [PATCH 58/70] removed unnecessary lines Signed-off-by: antonmic <56370189+antonmic@users.noreply.github.com> --- .../Code/Include/Atom/RPI.Public/Pass/ClearPass.h | 7 +------ .../Include/Atom/RPI.Reflect/Pass/ClearPassData.h | 2 +- .../RPI/Code/Source/RPI.Public/Pass/ClearPass.cpp | 12 ------------ 3 files changed, 2 insertions(+), 19 deletions(-) diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ClearPass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ClearPass.h index e917584fca..3599e6de44 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ClearPass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ClearPass.h @@ -8,11 +8,6 @@ #pragma once #include - -#include -#include -#include - #include namespace AZ @@ -38,8 +33,8 @@ namespace AZ void InitializeInternal() override; private: - RHI::ClearValue m_clearValue; }; + } // namespace RPI } // namespace AZ diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Pass/ClearPassData.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Pass/ClearPassData.h index 5eed6d54fa..9c03f5ccd6 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Pass/ClearPassData.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Pass/ClearPassData.h @@ -8,7 +8,6 @@ #pragma once #include - #include namespace AZ @@ -38,6 +37,7 @@ namespace AZ RHI::ClearValue m_clearValue; }; + } // namespace RPI } // namespace AZ diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ClearPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ClearPass.cpp index 1ba16f4b5a..0e3ea76728 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ClearPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ClearPass.cpp @@ -8,20 +8,8 @@ #include #include -#include -#include #include -#include -#include - -#include -#include -#include - -#include -#include -#include namespace AZ { From a1be8f832e4218db213fa2a4b131a8a426332c3e Mon Sep 17 00:00:00 2001 From: dmcdiarmid-ly <63674186+dmcdiarmid-ly@users.noreply.github.com> Date: Wed, 15 Dec 2021 19:38:39 -0700 Subject: [PATCH 59/70] Build BLAS objects from the BLAS instance list instead of the mesh list Signed-off-by: dmcdiarmid-ly <63674186+dmcdiarmid-ly@users.noreply.github.com> --- .../RayTracingAccelerationStructurePass.cpp | 13 ++++---- .../RayTracing/RayTracingFeatureProcessor.cpp | 19 ++++------- .../RayTracing/RayTracingFeatureProcessor.h | 32 ++++++++++--------- 3 files changed, 30 insertions(+), 34 deletions(-) diff --git a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.cpp b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.cpp index abdf59a915..2073c0b8c0 100644 --- a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.cpp @@ -150,18 +150,17 @@ namespace AZ } // build newly added BLAS objects - // [GFX TODO][ATOM-14159] Add changelist for meshes in the RayTracingFeatureProcessor - RayTracingFeatureProcessor::MeshMap& rayTracingMeshes = rayTracingFeatureProcessor->GetMeshes(); - for (auto& rayTracingMesh : rayTracingMeshes) + RayTracingFeatureProcessor::BlasInstanceMap& blasInstances = rayTracingFeatureProcessor->GetBlasInstances(); + for (auto& blasInstance : blasInstances) { - if (rayTracingMesh.second.m_blasBuilt == false) + if (blasInstance.second.m_blasBuilt == false) { - for (auto& rayTracingSubMesh : rayTracingMesh.second.m_subMeshes) + for (auto& blasInstanceSubMesh : blasInstance.second.m_subMeshes) { - context.GetCommandList()->BuildBottomLevelAccelerationStructure(*rayTracingSubMesh.m_blas); + context.GetCommandList()->BuildBottomLevelAccelerationStructure(*blasInstanceSubMesh.m_blas); } - rayTracingMesh.second.m_blasBuilt = true; + blasInstance.second.m_blasBuilt = true; } } diff --git a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp index bef95ced17..0a9782980f 100644 --- a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp @@ -149,23 +149,18 @@ namespace AZ { AZ_Assert(blasInstanceFound == false, "Partial set of RayTracingBlas objects found for mesh"); - // create the BLAS object - subMesh.m_blas = AZ::RHI::RayTracingBlas::CreateRHIRayTracingBlas(); + // create the BLAS object and store it in the BLAS list + RHI::Ptr rayTracingBlas = AZ::RHI::RayTracingBlas::CreateRHIRayTracingBlas(); + itMeshBlasInstance->second.m_subMeshes.push_back({ rayTracingBlas }); - // create the buffers from the descriptor - subMesh.m_blas->CreateBuffers(*device, &blasDescriptor, *m_bufferPools); + // create the buffers from the BLAS descriptor + rayTracingBlas->CreateBuffers(*device, &blasDescriptor, *m_bufferPools); - // store the BLAS in the side list - itMeshBlasInstance->second.m_subMeshes.push_back({ subMesh.m_blas }); + // store the BLAS in the mesh + subMesh.m_blas = rayTracingBlas; } } - if (blasInstanceFound) - { - // set the mesh BLAS flag so we don't try to rebuild it in the RayTracingAccelerationStructurePass - mesh.m_blasBuilt = true; - } - // set initial transform mesh.m_transform = m_transformServiceFeatureProcessor->GetTransformForId(objectId); mesh.m_nonUniformScale = m_transformServiceFeatureProcessor->GetNonUniformScaleForId(objectId); diff --git a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.h index fbed3b80cf..d098fca35a 100644 --- a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.h @@ -127,9 +127,6 @@ namespace AZ // mesh non-uniform scale AZ::Vector3 m_nonUniformScale = AZ::Vector3::CreateOne(); - - // flag indicating if the Blas objects in the sub-meshes are built - bool m_blasBuilt = false; }; using MeshMap = AZStd::map; @@ -184,6 +181,23 @@ namespace AZ //! Updates the RayTracingSceneSrg and RayTracingMaterialSrg, called after the TLAS is allocated in the RayTracingAccelerationStructurePass void UpdateRayTracingSrgs(); + struct SubMeshBlasInstance + { + RHI::Ptr m_blas; + }; + + struct MeshBlasInstance + { + uint32_t m_count = 0; + AZStd::vector m_subMeshes; + + // flag indicating if the Blas objects in the sub-mesh list are built + bool m_blasBuilt = false; + }; + + using BlasInstanceMap = AZStd::unordered_map; + BlasInstanceMap& GetBlasInstances() { return m_blasInstanceMap; } + private: AZ_DISABLE_COPY_MOVE(RayTracingFeatureProcessor); @@ -266,18 +280,6 @@ namespace AZ bool m_materialInfoBufferNeedsUpdate = false; // side list for looking up existing BLAS objects so they can be re-used when the same mesh is added multiple times - struct SubMeshBlasInstance - { - RHI::Ptr m_blas; - }; - - struct MeshBlasInstance - { - uint32_t m_count = 0; - AZStd::vector m_subMeshes; - }; - - using BlasInstanceMap = AZStd::unordered_map; BlasInstanceMap m_blasInstanceMap; // Cache view pointers so we dont need to update them if none changed from frame to frame. From 73e0bdbe6e35fe465f8c2221a7b79e49bf127ba8 Mon Sep 17 00:00:00 2001 From: carlitosan <82187351+carlitosan@users.noreply.github.com> Date: Wed, 15 Dec 2021 21:49:01 -0800 Subject: [PATCH 60/70] fix version deletion error Signed-off-by: carlitosan <82187351+carlitosan@users.noreply.github.com> --- .../Include/ScriptCanvas/Components/EditorDeprecationData.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorDeprecationData.cpp b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorDeprecationData.cpp index e94ef68234..a1afc8eeae 100644 --- a/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorDeprecationData.cpp +++ b/Gems/ScriptCanvas/Code/Editor/Include/ScriptCanvas/Components/EditorDeprecationData.cpp @@ -21,6 +21,7 @@ namespace ScriptCanvasEditor if (auto serializeContext = azrtti_cast(context)) { serializeContext->Class() + ->Version(1) ->Field("m_asset", &ScriptCanvasAssetHolder::m_scriptCanvasAsset) ; } From d065eb949878c297a0996f59de1121630ed8df67 Mon Sep 17 00:00:00 2001 From: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> Date: Thu, 16 Dec 2021 09:35:23 +0000 Subject: [PATCH 61/70] Initial improvements to fix viewport icon selection and draw order (#6284) * wip fixes for entity viewport icons displaying in the correct order and handling selection correctly Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * add additional comment about z value Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * move manual sorting and some small tidy-up Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * update comment Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * updates following initial round of PR feedback Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * additional changes to support tests for entity icon intersection Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * add support to enable/disable icons separately from helpers Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * final tests added and small tidy-up to display EntityId correctly Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * update some manipulator test framework calls after utility functions were moved Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * fix for implicit cast Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * move icon scale values to AZ_CVARS Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * fix failing tests caught in AR and update some naming conventions for tests Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * update naming convention for members of ProjectedViewportRay Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * update other references to ProjectedViewportRay Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * update more references to ProjectedViewportRay change Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * update menus for python tests Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> --- .../EditorScripts/Menus_EditMenuOptions.py | 7 +- .../EditorScripts/Menus_ViewMenuOptions.py | 3 +- Code/Editor/Core/LevelEditorMenuHandler.cpp | 4 +- Code/Editor/CryEdit.cpp | 7 - Code/Editor/CryEdit.h | 1 - Code/Editor/DisplaySettings.cpp | 2 - Code/Editor/EditorViewportWidget.cpp | 15 +- Code/Editor/EditorViewportWidget.h | 2 + Code/Editor/IEditor.h | 2 - Code/Editor/MainWindow.cpp | 84 ++++++-- .../SandboxIntegration.cpp | 5 - .../SandboxIntegration.h | 1 - Code/Editor/Resource.h | 1 - Code/Editor/ViewportManipulatorController.cpp | 4 +- Code/Editor/ViewportTitleDlg.cpp | 123 ++++++----- Code/Editor/ViewportTitleDlg.h | 4 +- .../AzFramework/Viewport/ScreenGeometry.h | 7 + .../AzManipulatorTestFramework.h | 24 ++- .../AzManipulatorTestFrameworkTestHelpers.h | 2 +- .../AzManipulatorTestFrameworkUtils.h | 23 --- .../IndirectManipulatorViewportInteraction.h | 5 +- .../ViewportInteraction.h | 12 +- .../AzManipulatorTestFrameworkUtils.cpp | 43 ---- .../Source/ImmediateModeActionDispatcher.cpp | 3 +- .../Source/ViewportInteraction.cpp | 24 +++ .../AzManipulatorTestFrameworkTestFixtures.h | 39 ++-- .../Tests/BusCallTest.cpp | 18 +- Code/Framework/AzTest/AzTest/Printers.cpp | 15 +- Code/Framework/AzTest/AzTest/Printers.h | 8 + .../API/ToolsApplicationAPI.h | 3 - .../Viewport/ViewportMessages.cpp | 4 +- .../Viewport/ViewportMessages.h | 21 +- .../Viewport/ViewportSettings.cpp | 22 ++ .../Viewport/ViewportSettings.h | 6 + .../Viewport/ViewportTypes.cpp | 17 ++ .../AzToolsFramework/Viewport/ViewportTypes.h | 49 ++++- .../ViewportSelection/EditorHelpers.cpp | 169 +++++++++------ .../ViewportSelection/EditorHelpers.h | 8 + .../EditorTransformComponentSelection.cpp | 13 +- ...torTransformComponentSelectionRequestBus.h | 2 + ...EditorTransformComponentSelectionTests.cpp | 192 +++++++++++++++--- .../Tests/EntityIdQLabelTests.cpp | 1 - .../ContainerEntitySelectionTests.cpp | 16 +- .../Tests/FocusMode/ContainerEntityTests.cpp | 73 ++++--- .../FocusMode/EditorFocusModeFixture.cpp | 40 ++-- .../Tests/FocusMode/EditorFocusModeFixture.h | 11 +- .../EditorFocusModeSelectionFixture.h | 12 +- .../EditorFocusModeSelectionTests.cpp | 14 +- .../Tests/FocusMode/EditorFocusModeTests.cpp | 16 +- .../SliceStabilityTestFramework.h | 1 - .../Tests/UI/EntityPropertyEditorTests.cpp | 1 - .../Common/Assets/Passes/UIParent.pass | 3 +- .../Tests/ViewportInteractionImplTests.cpp | 3 +- ...tomViewportDisplayIconsSystemComponent.cpp | 39 ++-- Gems/PhysX/Code/Editor/DebugDraw.cpp | 6 +- .../Code/Source/EditorWhiteBoxComponent.cpp | 2 - 56 files changed, 783 insertions(+), 449 deletions(-) diff --git a/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/Menus_EditMenuOptions.py b/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/Menus_EditMenuOptions.py index c7088a54c5..bd213be293 100644 --- a/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/Menus_EditMenuOptions.py +++ b/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/Menus_EditMenuOptions.py @@ -40,11 +40,12 @@ def Menus_EditMenuOptions_Work(): ("Toggle Pivot Location",), ("Reset Entity Transform",), ("Reset Manipulator",), - ("Reset Transform (Local)",), - ("Reset Transform (World)",), ("Hide Selection",), ("Show All",), - ("Modify", "Snap", "Snap angle"), + ("Lock Selection",), + ("Unlock All Entities",), + ("Modify", "Snap", "Angle snapping"), + ("Modify", "Snap", "Grid snapping"), ("Modify", "Transform Mode", "Move"), ("Modify", "Transform Mode", "Rotate"), ("Modify", "Transform Mode", "Scale"), diff --git a/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/Menus_ViewMenuOptions.py b/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/Menus_ViewMenuOptions.py index f1b9e5d4d8..deff2855a0 100644 --- a/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/Menus_ViewMenuOptions.py +++ b/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/Menus_ViewMenuOptions.py @@ -39,7 +39,8 @@ def Menus_ViewMenuOptions_Work(): ("Viewport", "Go to Location"), ("Viewport", "Remember Location"), ("Viewport", "Switch Camera"), - ("Viewport", "Show/Hide Helpers"), + ("Viewport", "Show Helpers"), + ("Viewport", "Show Icons"), ("Refresh Style",), ] diff --git a/Code/Editor/Core/LevelEditorMenuHandler.cpp b/Code/Editor/Core/LevelEditorMenuHandler.cpp index 70aff10f87..a90b0a597a 100644 --- a/Code/Editor/Core/LevelEditorMenuHandler.cpp +++ b/Code/Editor/Core/LevelEditorMenuHandler.cpp @@ -538,6 +538,7 @@ void LevelEditorMenuHandler::PopulateEditMenu(ActionManager::MenuWrapper& editMe auto snapMenu = modifyMenu.AddMenu(tr("Snap")); snapMenu.AddAction(AzToolsFramework::SnapAngle); + snapMenu.AddAction(AzToolsFramework::SnapToGrid); auto transformModeMenu = modifyMenu.AddMenu(tr("Transform Mode")); transformModeMenu.AddAction(AzToolsFramework::EditModeMove); @@ -723,7 +724,8 @@ QMenu* LevelEditorMenuHandler::CreateViewMenu() // MISSING AVIRECORDER viewportViewsMenuWrapper.AddSeparator(); - viewportViewsMenuWrapper.AddAction(ID_DISPLAY_SHOWHELPERS); + viewportViewsMenuWrapper.AddAction(AzToolsFramework::Helpers); + viewportViewsMenuWrapper.AddAction(AzToolsFramework::Icons); // Refresh Style viewMenu.AddAction(ID_SKINS_REFRESH); diff --git a/Code/Editor/CryEdit.cpp b/Code/Editor/CryEdit.cpp index 3890a9e59a..4415308730 100644 --- a/Code/Editor/CryEdit.cpp +++ b/Code/Editor/CryEdit.cpp @@ -445,7 +445,6 @@ void CCryEditApp::RegisterActionHandlers() ON_COMMAND(ID_OPEN_ASSET_BROWSER, OnOpenAssetBrowserView) ON_COMMAND(ID_OPEN_AUDIO_CONTROLS_BROWSER, OnOpenAudioControlsEditor) - ON_COMMAND(ID_DISPLAY_SHOWHELPERS, OnShowHelpers) ON_COMMAND(ID_OPEN_TRACKVIEW, OnOpenTrackView) ON_COMMAND(ID_OPEN_UICANVASEDITOR, OnOpenUICanvasEditor) @@ -2617,12 +2616,6 @@ void CCryEditApp::OnUpdateSelected(QAction* action) action->setEnabled(!GetIEditor()->GetSelection()->IsEmpty()); } -void CCryEditApp::OnShowHelpers() -{ - GetIEditor()->GetDisplaySettings()->DisplayHelpers(!GetIEditor()->GetDisplaySettings()->IsDisplayHelpers()); - GetIEditor()->Notify(eNotify_OnDisplayRenderUpdate); -} - ////////////////////////////////////////////////////////////////////////// void CCryEditApp::OnEditLevelData() { diff --git a/Code/Editor/CryEdit.h b/Code/Editor/CryEdit.h index 8c514170ae..97fcde8f34 100644 --- a/Code/Editor/CryEdit.h +++ b/Code/Editor/CryEdit.h @@ -237,7 +237,6 @@ public: void OnSyncPlayerUpdate(QAction* action); void OnResourcesReduceworkingset(); void OnDummyCommand() {}; - void OnShowHelpers(); void OnFileSave(); void OnUpdateDocumentReady(QAction* action); void OnUpdateFileOpen(QAction* action); diff --git a/Code/Editor/DisplaySettings.cpp b/Code/Editor/DisplaySettings.cpp index ed4ca180b4..bfeac3e37f 100644 --- a/Code/Editor/DisplaySettings.cpp +++ b/Code/Editor/DisplaySettings.cpp @@ -68,8 +68,6 @@ void CDisplaySettings::SetObjectHideMask(int hideMask) m_objectHideMask = hideMask; gSettings.objectHideMask = m_objectHideMask; - - GetIEditor()->Notify(eNotify_OnDisplayRenderUpdate); }; ////////////////////////////////////////////////////////////////////////// diff --git a/Code/Editor/EditorViewportWidget.cpp b/Code/Editor/EditorViewportWidget.cpp index 3f9ff03203..754ea84544 100644 --- a/Code/Editor/EditorViewportWidget.cpp +++ b/Code/Editor/EditorViewportWidget.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -1621,14 +1622,14 @@ Vec3 EditorViewportWidget::ViewToWorld( auto ray = m_renderViewport->ViewportScreenToWorldRay(AzToolsFramework::ViewportInteraction::ScreenPointFromQPoint(vp)); const float maxDistance = 10000.f; - Vec3 v = AZVec3ToLYVec3(ray.direction) * maxDistance; + Vec3 v = AZVec3ToLYVec3(ray.m_direction) * maxDistance; if (!_finite(v.x) || !_finite(v.y) || !_finite(v.z)) { return Vec3(0, 0, 0); } - Vec3 colp = AZVec3ToLYVec3(ray.origin) + 0.002f * v; + Vec3 colp = AZVec3ToLYVec3(ray.m_origin) + 0.002f * v; return colp; } @@ -2420,6 +2421,16 @@ AZ::Vector3 EditorViewportSettings::DefaultEditorCameraPosition() const return SandboxEditor::CameraDefaultEditorPosition(); } +bool EditorViewportSettings::IconsVisible() const +{ + return AzToolsFramework::IconsVisible(); +} + +bool EditorViewportSettings::HelpersVisible() const +{ + return AzToolsFramework::HelpersVisible(); +} + AZ_CVAR_EXTERNED(bool, ed_previewGameInFullscreen_once); bool EditorViewportWidget::ShouldPreviewFullscreen() const diff --git a/Code/Editor/EditorViewportWidget.h b/Code/Editor/EditorViewportWidget.h index 3d52b2416d..83ca655326 100644 --- a/Code/Editor/EditorViewportWidget.h +++ b/Code/Editor/EditorViewportWidget.h @@ -79,6 +79,8 @@ struct EditorViewportSettings : public AzToolsFramework::ViewportInteraction::Vi float ManipulatorCircleBoundWidth() const override; bool StickySelectEnabled() const override; AZ::Vector3 DefaultEditorCameraPosition() const override; + bool IconsVisible() const override; + bool HelpersVisible() const override; }; // EditorViewportWidget window diff --git a/Code/Editor/IEditor.h b/Code/Editor/IEditor.h index 48c8392f32..c6f72a7dbc 100644 --- a/Code/Editor/IEditor.h +++ b/Code/Editor/IEditor.h @@ -168,8 +168,6 @@ enum EEditorNotifyEvent eNotify_OnVegetationObjectSelection, // When vegetation objects selection change. eNotify_OnVegetationPanelUpdate, // When vegetation objects selection change. - eNotify_OnDisplayRenderUpdate, // Sent when editor finish terrain texture generation. - eNotify_OnDataBaseUpdate, // DataBase Library was modified. eNotify_OnLayerImportBegin, //layer import was started diff --git a/Code/Editor/MainWindow.cpp b/Code/Editor/MainWindow.cpp index 38e433c3a3..f92e39f285 100644 --- a/Code/Editor/MainWindow.cpp +++ b/Code/Editor/MainWindow.cpp @@ -47,6 +47,7 @@ AZ_POP_DISABLE_WARNING #include #include #include +#include #include // AzQtComponents @@ -445,11 +446,11 @@ void MainWindow::Initialize() { m_viewPaneManager->SetMainWindow(m_viewPaneHost, &m_settings, /*unused*/ QByteArray()); + InitActions(); + RegisterStdViewClasses(); InitCentralWidget(); - InitActions(); - // load toolbars ("shelves") and macros GetIEditor()->GetToolBoxManager()->Load(m_actionManager); @@ -798,27 +799,40 @@ void MainWindow::InitActions() EditorTransformComponentSelectionRequests::Mode::Scale); }); - am->AddAction(AzToolsFramework::SnapToGrid, tr("Snap to grid")) + am->AddAction(AzToolsFramework::SnapToGrid, tr("Grid snapping")) .SetIcon(Style::icon("Grid")) + .SetStatusTip(tr("Toggle grid snapping")) .SetShortcut(tr("G")) - .SetToolTip(tr("Snap to grid (G)")) - .SetStatusTip(tr("Toggles snap to grid")) .SetCheckable(true) - .RegisterUpdateCallback([](QAction* action) { - Q_ASSERT(action->isCheckable()); - action->setChecked(SandboxEditor::GridSnappingEnabled()); - }) - .Connect(&QAction::triggered, []() { SandboxEditor::SetGridSnapping(!SandboxEditor::GridSnappingEnabled()); }); + .RegisterUpdateCallback( + [](QAction* action) + { + Q_ASSERT(action->isCheckable()); + action->setChecked(SandboxEditor::GridSnappingEnabled()); + }) + .Connect( + &QAction::triggered, + [] + { + SandboxEditor::SetGridSnapping(!SandboxEditor::GridSnappingEnabled()); + }); - am->AddAction(AzToolsFramework::SnapAngle, tr("Snap angle")) + am->AddAction(AzToolsFramework::SnapAngle, tr("Angle snapping")) .SetIcon(Style::icon("Angle")) - .SetStatusTip(tr("Snap angle")) + .SetStatusTip(tr("Toggle angle snapping")) .SetCheckable(true) - .RegisterUpdateCallback([](QAction* action) { - Q_ASSERT(action->isCheckable()); - action->setChecked(SandboxEditor::AngleSnappingEnabled()); - }) - .Connect(&QAction::triggered, []() { SandboxEditor::SetAngleSnapping(!SandboxEditor::AngleSnappingEnabled()); }); + .RegisterUpdateCallback( + [](QAction* action) + { + Q_ASSERT(action->isCheckable()); + action->setChecked(SandboxEditor::AngleSnappingEnabled()); + }) + .Connect( + &QAction::triggered, + [] + { + SandboxEditor::SetAngleSnapping(!SandboxEditor::AngleSnappingEnabled()); + }); // Display actions am->AddAction(ID_SWITCHCAMERA_DEFAULTCAMERA, tr("Default Camera")).SetCheckable(true) @@ -918,9 +932,41 @@ void MainWindow::InitActions() .SetStatusTip(tr("Cycle 2D Viewport")) .RegisterUpdateCallback(cryEdit, &CCryEditApp::OnUpdateNonGameMode); #endif - am->AddAction(ID_DISPLAY_SHOWHELPERS, tr("Show/Hide Helpers")) + am->AddAction(AzToolsFramework::Helpers, tr("Show Helpers")) .SetShortcut(tr("Shift+Space")) - .SetToolTip(tr("Show/Hide Helpers (Shift+Space)")); + .SetToolTip(tr("Show/Hide Helpers (Shift+Space)")) + .SetCheckable(true) + .RegisterUpdateCallback( + [](QAction* action) + { + Q_ASSERT(action->isCheckable()); + action->setChecked(AzToolsFramework::HelpersVisible()); + }) + .Connect( + &QAction::triggered, + []() + { + AzToolsFramework::SetHelpersVisible(!AzToolsFramework::HelpersVisible()); + AzToolsFramework::ViewportInteraction::ViewportSettingsNotificationBus::Broadcast( + &AzToolsFramework::ViewportInteraction::ViewportSettingNotifications::OnDrawHelpersChanged, + AzToolsFramework::HelpersVisible()); + }); + am->AddAction(AzToolsFramework::Icons, tr("Show Icons")) + .SetShortcut(tr("Ctrl+Space")) + .SetToolTip(tr("Show/Hide Icons (Ctrl+Space)")) + .SetCheckable(true) + .RegisterUpdateCallback( + [](QAction* action) + { + Q_ASSERT(action->isCheckable()); + action->setChecked(AzToolsFramework::IconsVisible()); + }) + .Connect( + &QAction::triggered, + []() + { + AzToolsFramework::SetIconsVisible(!AzToolsFramework::IconsVisible()); + }); // Audio actions am->AddAction(ID_SOUND_STOPALLSOUNDS, tr("Stop All Sounds")) diff --git a/Code/Editor/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp b/Code/Editor/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp index d5b903585e..69b195d243 100644 --- a/Code/Editor/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp +++ b/Code/Editor/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp @@ -1986,8 +1986,3 @@ void SandboxIntegrationManager::BrowseForAssets(AssetSelectionModel& selection) { AssetBrowserComponentRequestBus::Broadcast(&AssetBrowserComponentRequests::PickAssets, selection, GetMainWindow()); } - -bool SandboxIntegrationManager::DisplayHelpersVisible() -{ - return GetIEditor()->GetDisplaySettings()->IsDisplayHelpers(); -} diff --git a/Code/Editor/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.h b/Code/Editor/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.h index 79e7a4334d..c58f019c85 100644 --- a/Code/Editor/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.h +++ b/Code/Editor/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.h @@ -165,7 +165,6 @@ private: void InstantiateSliceFromAssetId(const AZ::Data::AssetId& assetId) override; void ClearRedoStack() override; int GetIconTextureIdFromEntityIconPath(const AZStd::string& entityIconPath) override; - bool DisplayHelpersVisible() override; ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// diff --git a/Code/Editor/Resource.h b/Code/Editor/Resource.h index ba3cd39fe7..432f07a531 100644 --- a/Code/Editor/Resource.h +++ b/Code/Editor/Resource.h @@ -191,7 +191,6 @@ #define ID_BRUSH_CSGSUBSTRUCT 33837 #define ID_MATERIAL_PICKTOOL 33842 #define ID_MODIFY_AIPOINT_PICKIMPASSLINK 33865 -#define ID_DISPLAY_SHOWHELPERS 33871 #define ID_FILE_EXPORTSELECTION 33875 #define ID_EDIT_PASTE_WITH_LINKS 33893 #define ID_FILE_EXPORT_TERRAINAREA 33904 diff --git a/Code/Editor/ViewportManipulatorController.cpp b/Code/Editor/ViewportManipulatorController.cpp index e46328eb65..9879a84b62 100644 --- a/Code/Editor/ViewportManipulatorController.cpp +++ b/Code/Editor/ViewportManipulatorController.cpp @@ -129,8 +129,8 @@ namespace SandboxEditor ViewportInteractionRequestBus::EventResult( ray, GetViewportId(), &ViewportInteractionRequestBus::Events::ViewportScreenToWorldRay, screenPoint); - m_mouseInteraction.m_mousePick.m_rayOrigin = ray.origin; - m_mouseInteraction.m_mousePick.m_rayDirection = ray.direction; + m_mouseInteraction.m_mousePick.m_rayOrigin = ray.m_origin; + m_mouseInteraction.m_mousePick.m_rayDirection = ray.m_direction; m_mouseInteraction.m_mousePick.m_screenCoordinates = screenPoint; } diff --git a/Code/Editor/ViewportTitleDlg.cpp b/Code/Editor/ViewportTitleDlg.cpp index 49459fad0f..888089fd72 100644 --- a/Code/Editor/ViewportTitleDlg.cpp +++ b/Code/Editor/ViewportTitleDlg.cpp @@ -6,7 +6,6 @@ * */ - // Description : CViewportTitleDlg implementation file #if !defined(Q_MOC_RUN) @@ -42,38 +41,18 @@ #include #include #include +#include +#include #include AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING #include "ui_ViewportTitleDlg.h" AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING -#endif //!defined(Q_MOC_RUN) +#endif //! defined(Q_MOC_RUN) // CViewportTitleDlg dialog -inline namespace Helpers -{ - void ToggleHelpers() - { - const bool newValue = !GetIEditor()->GetDisplaySettings()->IsDisplayHelpers(); - GetIEditor()->GetDisplaySettings()->DisplayHelpers(newValue); - GetIEditor()->Notify(eNotify_OnDisplayRenderUpdate); - - if (newValue == false) - { - GetIEditor()->GetObjectManager()->SendEvent(EVENT_HIDE_HELPER); - } - AzToolsFramework::ViewportInteraction::ViewportSettingsNotificationBus::Broadcast( - &AzToolsFramework::ViewportInteraction::ViewportSettingNotifications::OnDrawHelpersChanged, newValue); - } - - bool IsHelpersShown() - { - return GetIEditor()->GetDisplaySettings()->IsDisplayHelpers(); - } -} - namespace { class CViewportTitleDlgDisplayInfoHelper @@ -98,7 +77,7 @@ namespace emit ViewportInfoStatusUpdated(static_cast(state)); } }; -} //end anonymous namespace +} // end anonymous namespace CViewportTitleDlg::CViewportTitleDlg(QWidget* pParent) : QWidget(pParent) @@ -215,13 +194,65 @@ void CViewportTitleDlg::SetupViewportInformationMenu() m_ui->m_debugInformationMenu->setMenu(GetViewportInformationMenu()); connect(m_ui->m_debugInformationMenu, &QToolButton::clicked, this, &CViewportTitleDlg::OnToggleDisplayInfo); m_ui->m_debugInformationMenu->setPopupMode(QToolButton::MenuButtonPopup); - } void CViewportTitleDlg::SetupHelpersButton() { - connect(m_ui->m_helpers, &QToolButton::clicked, this, &CViewportTitleDlg::OnToggleHelpers); - m_ui->m_helpers->setChecked(Helpers::IsHelpersShown()); + if (m_helpersMenu == nullptr) + { + m_helpersMenu = new QMenu("Helpers State", this); + + auto helperAction = MainWindow::instance()->GetActionManager()->GetAction(AzToolsFramework::Helpers); + connect( + helperAction, &QAction::triggered, this, + [this] + { + m_ui->m_helpers->setChecked(AzToolsFramework::HelpersVisible() || AzToolsFramework::IconsVisible()); + }); + + auto iconAction = MainWindow::instance()->GetActionManager()->GetAction(AzToolsFramework::Icons); + connect( + iconAction, &QAction::triggered, this, + [this] + { + m_ui->m_helpers->setChecked(AzToolsFramework::HelpersVisible() || AzToolsFramework::IconsVisible()); + }); + + m_helpersAction = new QAction(tr("Helpers"), m_helpersMenu); + m_helpersAction->setCheckable(true); + connect( + m_helpersAction, &QAction::triggered, this, + [helperAction] + { + helperAction->trigger(); + }); + + m_iconsAction = new QAction(tr("Icons"), m_helpersMenu); + m_iconsAction->setCheckable(true); + connect( + m_iconsAction, &QAction::triggered, this, + [iconAction] + { + iconAction->trigger(); + }); + + m_helpersMenu->addAction(m_helpersAction); + m_helpersMenu->addAction(m_iconsAction); + + connect( + m_helpersMenu, &QMenu::aboutToShow, this, + [this] + { + m_helpersAction->setChecked(AzToolsFramework::HelpersVisible()); + m_iconsAction->setChecked(AzToolsFramework::IconsVisible()); + }); + + m_ui->m_helpers->setCheckable(true); + m_ui->m_helpers->setMenu(m_helpersMenu); + m_ui->m_helpers->setPopupMode(QToolButton::InstantPopup); + } + + m_ui->m_helpers->setChecked(AzToolsFramework::HelpersVisible() || AzToolsFramework::IconsVisible()); } void CViewportTitleDlg::SetupOverflowMenu() @@ -279,15 +310,20 @@ void CViewportTitleDlg::SetupOverflowMenu() UpdateMuteActionText(); } - ////////////////////////////////////////////////////////////////////////// void CViewportTitleDlg::SetViewPane(CLayoutViewPane* pViewPane) { if (m_pViewPane) + { m_pViewPane->disconnect(this); + } + m_pViewPane = pViewPane; + if (m_pViewPane) + { connect(this, &QWidget::customContextMenuRequested, m_pViewPane, &CLayoutViewPane::ShowTitleMenu); + } } ////////////////////////////////////////////////////////////////////////// @@ -318,7 +354,6 @@ void CViewportTitleDlg::OnInitDialog() m_ui->m_prefabFocusPath->hide(); m_ui->m_prefabFocusBackButton->hide(); } - } ////////////////////////////////////////////////////////////////////////// @@ -336,13 +371,6 @@ void CViewportTitleDlg::OnMaximize() } } -////////////////////////////////////////////////////////////////////////// -void CViewportTitleDlg::OnToggleHelpers() -{ - Helpers::ToggleHelpers(); - m_ui->m_helpers->setChecked(Helpers::IsHelpersShown()); -} - void CViewportTitleDlg::SetNoViewportInfo() { AZ::AtomBridge::AtomViewportInfoDisplayRequestBus::Broadcast( @@ -367,7 +395,6 @@ void CViewportTitleDlg::SetCompactViewportInfo() &AZ::AtomBridge::AtomViewportInfoDisplayRequestBus::Events::SetDisplayState, AZ::AtomBridge::ViewportInfoDisplayState::CompactInfo); } - ////////////////////////////////////////////////////////////////////////// void CViewportTitleDlg::UpdateDisplayInfo() { @@ -783,9 +810,6 @@ void CViewportTitleDlg::OnEditorNotifyEvent(EEditorNotifyEvent event) { switch (event) { - case eNotify_OnDisplayRenderUpdate: - m_ui->m_helpers->setChecked(Helpers::IsHelpersShown()); - break; case eNotify_OnBeginGameMode: case eNotify_OnEndGameMode: UpdateMuteActionText(); @@ -997,24 +1021,18 @@ void CViewportTitleDlg::UpdateOverFlowMenuState() m_angleSizeActionWidget->setEnabled(angleSnappingActive); } -namespace + namespace { void PyToggleHelpers() { - GetIEditor()->GetDisplaySettings()->DisplayHelpers(!GetIEditor()->GetDisplaySettings()->IsDisplayHelpers()); - GetIEditor()->Notify(eNotify_OnDisplayRenderUpdate); - - if (GetIEditor()->GetDisplaySettings()->IsDisplayHelpers() == false) - { - GetIEditor()->GetObjectManager()->SendEvent(EVENT_HIDE_HELPER); - } + AzToolsFramework::SetHelpersVisible(!AzToolsFramework::HelpersVisible()); } bool PyIsHelpersShown() { - return GetIEditor()->GetDisplaySettings()->IsDisplayHelpers(); + return AzToolsFramework::HelpersVisible(); } -} +} // namespace namespace AzToolsFramework { @@ -1029,11 +1047,12 @@ namespace AzToolsFramework ->Attribute(AZ::Script::Attributes::Category, "Legacy/Editor") ->Attribute(AZ::Script::Attributes::Module, "legacy.general"); }; + addLegacyGeneral(behaviorContext->Method("toggle_helpers", PyToggleHelpers, nullptr, "Toggles the display of helpers.")); addLegacyGeneral(behaviorContext->Method("is_helpers_shown", PyIsHelpersShown, nullptr, "Gets the display state of helpers.")); } } -} +} // namespace AzToolsFramework #include "ViewportTitleDlg.moc" #include diff --git a/Code/Editor/ViewportTitleDlg.h b/Code/Editor/ViewportTitleDlg.h index a3e19837b4..ba3dba858a 100644 --- a/Code/Editor/ViewportTitleDlg.h +++ b/Code/Editor/ViewportTitleDlg.h @@ -80,7 +80,6 @@ protected: void OnSystemEvent(ESystemEvent event, UINT_PTR wparam, UINT_PTR lparam) override; void OnMaximize(); - void OnToggleHelpers(); void UpdateDisplayInfo(); void SetupCameraDropdownMenu(); @@ -153,6 +152,9 @@ protected: QMenu* m_aspectMenu = nullptr; QMenu* m_resolutionMenu = nullptr; QMenu* m_viewportInformationMenu = nullptr; + QMenu* m_helpersMenu = nullptr; + QAction* m_helpersAction = nullptr; + QAction* m_iconsAction = nullptr; QAction* m_noInformationAction = nullptr; QAction* m_normalInformationAction = nullptr; QAction* m_fullInformationAction = nullptr; diff --git a/Code/Framework/AzFramework/AzFramework/Viewport/ScreenGeometry.h b/Code/Framework/AzFramework/AzFramework/Viewport/ScreenGeometry.h index 7a5d7fdc62..27031c6ab3 100644 --- a/Code/Framework/AzFramework/AzFramework/Viewport/ScreenGeometry.h +++ b/Code/Framework/AzFramework/AzFramework/Viewport/ScreenGeometry.h @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -203,6 +204,12 @@ namespace AzFramework return AZ::Vector2(aznumeric_cast(screenPoint.m_x), aznumeric_cast(screenPoint.m_y)); } + //! Return an AZ::Vector3 from a ScreenPoint (including z/depth value, defaulting to 0.0f). + inline AZ::Vector3 Vector3FromScreenPoint(const ScreenPoint& screenPoint, const float z = 0.0f) + { + return AZ::Vector3(aznumeric_cast(screenPoint.m_x), aznumeric_cast(screenPoint.m_y), z); + } + //! Return an AZ::Vector2 from a ScreenVector. inline AZ::Vector2 Vector2FromScreenVector(const ScreenVector& screenVector) { diff --git a/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/AzManipulatorTestFramework.h b/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/AzManipulatorTestFramework.h index 66227c692b..865a571d3b 100644 --- a/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/AzManipulatorTestFramework.h +++ b/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/AzManipulatorTestFramework.h @@ -26,29 +26,33 @@ namespace AzManipulatorTestFramework { public: virtual ~ViewportInteractionInterface() = default; - //! Return the camera state. + //! Returns the camera state. virtual AzFramework::CameraState GetCameraState() = 0; - //! Set the camera state. + //! Sets the camera state. virtual void SetCameraState(const AzFramework::CameraState& cameraState) = 0; - //! Retrieve the debug display. + //! Retrieves the debug display. virtual AzFramework::DebugDisplayRequests& GetDebugDisplay() = 0; - //! Set if grid snapping is enabled or not. + //! Sets if grid snapping is enabled or not. virtual void SetGridSnapping(bool enabled) = 0; - //! Set if angular snapping is enabled or not. + //! Sets if angular snapping is enabled or not. virtual void SetAngularSnapping(bool enabled) = 0; - //! Set the grid size. + //! Sets the grid size. virtual void SetGridSize(float size) = 0; - //! Set the angular step. + //! Sets the angular step. virtual void SetAngularStep(float step) = 0; - //! Get the viewport id. + //! Gets the viewport id. virtual AzFramework::ViewportId GetViewportId() const = 0; //! Updates the visibility state. //! Updates which entities are currently visible given the current camera state. virtual void UpdateVisibility() = 0; - //! Set if sticky select is enabled or not. + //! Sets if sticky select is enabled or not. virtual void SetStickySelect(bool enabled) = 0; - //! Get default Editor Camera Position. + //! Gets default Editor Camera Position. virtual AZ::Vector3 DefaultEditorCameraPosition() const = 0; + //! Sets if icons are visible in the viewport. + virtual void SetIconsVisible(bool visible) = 0; + //! Sets if helpers are visible in the viewport. + virtual void SetHelpersVisible(bool visible) = 0; }; //! This interface is used to simulate the manipulator manager while the manipulators are under test. diff --git a/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/AzManipulatorTestFrameworkTestHelpers.h b/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/AzManipulatorTestFrameworkTestHelpers.h index 63392eb82f..8528795206 100644 --- a/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/AzManipulatorTestFrameworkTestHelpers.h +++ b/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/AzManipulatorTestFrameworkTestHelpers.h @@ -26,6 +26,7 @@ namespace UnitTest using IndirectCallManipulatorViewportInteraction = AzManipulatorTestFramework::IndirectCallManipulatorViewportInteraction; using ImmediateModeActionDispatcher = AzManipulatorTestFramework::ImmediateModeActionDispatcher; + public: void SetUpEditorFixtureImpl() override { ToolsApplicationFixtureT::SetUpEditorFixtureImpl(); @@ -43,7 +44,6 @@ namespace UnitTest ToolsApplicationFixtureT::TearDownEditorFixtureImpl(); } - public: AzFramework::CameraState m_cameraState; AZStd::unique_ptr m_actionDispatcher; AZStd::unique_ptr m_viewportManipulatorInteraction; diff --git a/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/AzManipulatorTestFrameworkUtils.h b/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/AzManipulatorTestFrameworkUtils.h index 1dcbea2125..653644aefe 100644 --- a/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/AzManipulatorTestFrameworkUtils.h +++ b/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/AzManipulatorTestFrameworkUtils.h @@ -27,29 +27,6 @@ namespace AzManipulatorTestFramework const AZ::Vector3& position = AZ::Vector3::CreateZero(), float radius = 1.0f); - //! Create a mouse pick from the specified ray and screen point. - AzToolsFramework::ViewportInteraction::MousePick CreateMousePick( - const AZ::Vector3& origin, const AZ::Vector3& direction, const AzFramework::ScreenPoint& screenPoint); - - //! Build a mouse pick from the specified mouse position and camera state. - AzToolsFramework::ViewportInteraction::MousePick BuildMousePick( - const AzFramework::ScreenPoint& screenPoint, const AzFramework::CameraState& cameraState); - - //! Create a mouse interaction from the specified pick, buttons, interaction id and keyboard modifiers. - AzToolsFramework::ViewportInteraction::MouseInteraction CreateMouseInteraction( - const AzToolsFramework::ViewportInteraction::MousePick& mousePick, - AzToolsFramework::ViewportInteraction::MouseButtons buttons, - AzToolsFramework::ViewportInteraction::InteractionId interactionId, - AzToolsFramework::ViewportInteraction::KeyboardModifiers modifiers); - - //! Create a mouse buttons from the specified mouse button. - AzToolsFramework::ViewportInteraction::MouseButtons CreateMouseButtons(AzToolsFramework::ViewportInteraction::MouseButton button); - - //! Create a mouse interaction event from the specified interaction and event. - AzToolsFramework::ViewportInteraction::MouseInteractionEvent CreateMouseInteractionEvent( - const AzToolsFramework::ViewportInteraction::MouseInteraction& mouseInteraction, - AzToolsFramework::ViewportInteraction::MouseEvent event); - //! Dispatch a mouse event to the main manipulator manager via a bus call. void DispatchMouseInteractionEvent(const AzToolsFramework::ViewportInteraction::MouseInteractionEvent& event); diff --git a/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/IndirectManipulatorViewportInteraction.h b/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/IndirectManipulatorViewportInteraction.h index da2804dfd5..2d5a41c2c2 100644 --- a/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/IndirectManipulatorViewportInteraction.h +++ b/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/IndirectManipulatorViewportInteraction.h @@ -24,9 +24,12 @@ namespace AzManipulatorTestFramework explicit IndirectCallManipulatorViewportInteraction(AZStd::shared_ptr debugDisplayRequests); ~IndirectCallManipulatorViewportInteraction(); - // ManipulatorViewportInteractionInterface ... + // ManipulatorViewportInteraction overrides ... const ViewportInteractionInterface& GetViewportInteraction() const override; const ManipulatorManagerInterface& GetManipulatorManager() const override; + // make non-const overloads visible + using ManipulatorViewportInteraction::GetViewportInteraction; + using ManipulatorViewportInteraction::GetManipulatorManager; private: AZStd::unique_ptr m_viewportInteraction; diff --git a/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/ViewportInteraction.h b/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/ViewportInteraction.h index 1568c1a931..f29245bb34 100644 --- a/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/ViewportInteraction.h +++ b/Code/Framework/AzManipulatorTestFramework/Include/AzManipulatorTestFramework/ViewportInteraction.h @@ -39,7 +39,8 @@ namespace AzManipulatorTestFramework AzFramework::ViewportId GetViewportId() const override; void UpdateVisibility() override; void SetStickySelect(bool enabled) override; - AZ::Vector3 DefaultEditorCameraPosition() const override; + void SetIconsVisible(bool visible) override; + void SetHelpersVisible(bool visible) override; // ViewportInteractionRequestBus overrides ... AzFramework::CameraState GetCameraState() override; @@ -58,6 +59,9 @@ namespace AzManipulatorTestFramework float ManipulatorLineBoundWidth() const override; float ManipulatorCircleBoundWidth() const override; bool StickySelectEnabled() const override; + AZ::Vector3 DefaultEditorCameraPosition() const override; + bool IconsVisible() const override; + bool HelpersVisible() const override; // EditorEntityViewportInteractionRequestBus overrides ... void FindVisibleEntities(AZStd::vector& visibleEntities) override; @@ -68,10 +72,12 @@ namespace AzManipulatorTestFramework AzFramework::EntityVisibilityQuery m_entityVisibilityQuery; AZStd::shared_ptr m_debugDisplayRequests; AzFramework::CameraState m_cameraState; + float m_gridSize = 1.0f; + float m_angularStep = 0.0f; bool m_gridSnapping = false; bool m_angularSnapping = false; bool m_stickySelect = true; - float m_gridSize = 1.0f; - float m_angularStep = 0.0f; + bool m_iconsVisible = true; + bool m_helpersVisible = true; }; } // namespace AzManipulatorTestFramework diff --git a/Code/Framework/AzManipulatorTestFramework/Source/AzManipulatorTestFrameworkUtils.cpp b/Code/Framework/AzManipulatorTestFramework/Source/AzManipulatorTestFrameworkUtils.cpp index 6fbf2cb219..4c7d7f6901 100644 --- a/Code/Framework/AzManipulatorTestFramework/Source/AzManipulatorTestFrameworkUtils.cpp +++ b/Code/Framework/AzManipulatorTestFramework/Source/AzManipulatorTestFrameworkUtils.cpp @@ -82,49 +82,6 @@ namespace AzManipulatorTestFramework return manipulator; } - AzToolsFramework::ViewportInteraction::MousePick CreateMousePick( - const AZ::Vector3& origin, const AZ::Vector3& direction, const AzFramework::ScreenPoint& screenPoint) - { - return { origin, direction, screenPoint }; - } - - AzToolsFramework::ViewportInteraction::MousePick BuildMousePick( - const AzFramework::ScreenPoint& screenPoint, const AzFramework::CameraState& cameraState) - { - const auto nearPlaneWorldPosition = AzFramework::ScreenToWorld(screenPoint, cameraState); - - AzToolsFramework::ViewportInteraction::MousePick mousePick; - mousePick.m_screenCoordinates = screenPoint; - mousePick.m_rayOrigin = nearPlaneWorldPosition; - mousePick.m_rayDirection = (nearPlaneWorldPosition - cameraState.m_position).GetNormalized(); - - return mousePick; - } - - MouseInteraction CreateMouseInteraction( - const MousePick& mousePick, MouseButtons buttons, InteractionId interactionId, KeyboardModifiers modifiers) - { - AzToolsFramework::ViewportInteraction::MouseInteraction interaction; - interaction.m_mousePick = mousePick; - interaction.m_mouseButtons = buttons; - interaction.m_interactionId = interactionId; - interaction.m_keyboardModifiers = modifiers; - - return interaction; - } - - MouseButtons CreateMouseButtons(MouseButton button) - { - MouseButtons buttons; - buttons.m_mouseButtons = static_cast(button); - return buttons; - } - - MouseInteractionEvent CreateMouseInteractionEvent(const MouseInteraction& mouseInteraction, MouseEvent event) - { - return MouseInteractionEvent(mouseInteraction, event, /*captured=*/false); - } - void DispatchMouseInteractionEvent(const MouseInteractionEvent& event) { AzToolsFramework::EditorInteractionSystemViewportSelectionRequestBus::Event( diff --git a/Code/Framework/AzManipulatorTestFramework/Source/ImmediateModeActionDispatcher.cpp b/Code/Framework/AzManipulatorTestFramework/Source/ImmediateModeActionDispatcher.cpp index aea93ca342..715c2b1083 100644 --- a/Code/Framework/AzManipulatorTestFramework/Source/ImmediateModeActionDispatcher.cpp +++ b/Code/Framework/AzManipulatorTestFramework/Source/ImmediateModeActionDispatcher.cpp @@ -120,7 +120,8 @@ namespace AzManipulatorTestFramework void ImmediateModeActionDispatcher::MousePositionImpl(const AzFramework::ScreenPoint& position) { const auto cameraState = m_manipulatorViewportInteraction.GetViewportInteraction().GetCameraState(); - GetMouseInteractionEvent()->m_mouseInteraction.m_mousePick = BuildMousePick(position, cameraState); + GetMouseInteractionEvent()->m_mouseInteraction.m_mousePick = + AzToolsFramework::ViewportInteraction::BuildMousePick(cameraState, position); GetMouseInteractionEvent()->m_mouseEvent = AzToolsFramework::ViewportInteraction::MouseEvent::Move; m_manipulatorViewportInteraction.GetManipulatorManager().ConsumeMouseInteractionEvent(*m_event); } diff --git a/Code/Framework/AzManipulatorTestFramework/Source/ViewportInteraction.cpp b/Code/Framework/AzManipulatorTestFramework/Source/ViewportInteraction.cpp index 1a28c8cad1..b7fd5e2b73 100644 --- a/Code/Framework/AzManipulatorTestFramework/Source/ViewportInteraction.cpp +++ b/Code/Framework/AzManipulatorTestFramework/Source/ViewportInteraction.cpp @@ -10,6 +10,7 @@ #include #include #include +#include namespace AzManipulatorTestFramework { @@ -19,6 +20,9 @@ namespace AzManipulatorTestFramework AzToolsFramework::ViewportInteraction::ViewportInteractionRequestBus::Handler::BusConnect(m_viewportId); AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::Handler::BusConnect(m_viewportId); AzToolsFramework::ViewportInteraction::EditorEntityViewportInteractionRequestBus::Handler::BusConnect(m_viewportId); + + m_cameraState = + AzFramework::CreateIdentityDefaultCamera(AZ::Vector3::CreateZero(), AzManipulatorTestFramework::DefaultViewportSize); } ViewportInteraction::~ViewportInteraction() @@ -113,6 +117,16 @@ namespace AzManipulatorTestFramework m_stickySelect = enabled; } + void ViewportInteraction::SetIconsVisible(const bool visible) + { + m_iconsVisible = visible; + } + + void ViewportInteraction::SetHelpersVisible(const bool visible) + { + m_helpersVisible = visible; + } + AZ::Vector3 ViewportInteraction::DefaultEditorCameraPosition() const { return {}; @@ -148,4 +162,14 @@ namespace AzManipulatorTestFramework { return 1.0f; } + + bool ViewportInteraction::IconsVisible() const + { + return m_iconsVisible; + } + + bool ViewportInteraction::HelpersVisible() const + { + return m_helpersVisible; + } } // namespace AzManipulatorTestFramework diff --git a/Code/Framework/AzManipulatorTestFramework/Tests/AzManipulatorTestFrameworkTestFixtures.h b/Code/Framework/AzManipulatorTestFramework/Tests/AzManipulatorTestFrameworkTestFixtures.h index 4679ac142c..24ede71904 100644 --- a/Code/Framework/AzManipulatorTestFramework/Tests/AzManipulatorTestFrameworkTestFixtures.h +++ b/Code/Framework/AzManipulatorTestFramework/Tests/AzManipulatorTestFrameworkTestFixtures.h @@ -8,21 +8,22 @@ #pragma once +#include #include #include -#include namespace UnitTest { - class LinearManipulatorTestFixture - : public ToolsApplicationFixture + class LinearManipulatorTestFixture : public ToolsApplicationFixture { protected: LinearManipulatorTestFixture(const AzToolsFramework::ManipulatorManagerId& manipulatorManagerId) - : m_manipulatorManagerId(manipulatorManagerId) {} + : m_manipulatorManagerId(manipulatorManagerId) + { + } void SetUpEditorFixtureImpl() override - { + { m_linearManipulator = AzManipulatorTestFramework::CreateLinearManipulator( m_manipulatorManagerId, /*position=*/AZ::Vector3::CreateZero(), @@ -31,21 +32,21 @@ namespace UnitTest // default sanity check call backs m_linearManipulator->InstallLeftMouseDownCallback( [this](const AzToolsFramework::LinearManipulator::Action& /*action*/) - { - m_receivedLeftMouseDown = true; - }); + { + m_receivedLeftMouseDown = true; + }); m_linearManipulator->InstallMouseMoveCallback( [this](const AzToolsFramework::LinearManipulator::Action& /*action*/) - { - m_receivedMouseMove = true; - }); + { + m_receivedMouseMove = true; + }); m_linearManipulator->InstallLeftMouseUpCallback( [this](const AzToolsFramework::LinearManipulator::Action& /*action*/) - { - m_receivedLeftMouseUp = true; - }); + { + m_receivedLeftMouseUp = true; + }); } void TearDownEditorFixtureImpl() override @@ -63,16 +64,16 @@ namespace UnitTest bool m_receivedLeftMouseUp = false; // initial world space starting position for mouse interaction - const AzToolsFramework::ViewportInteraction::MousePick m_mouseStartingPositionRay = - AzManipulatorTestFramework::CreateMousePick( - AZ::Vector3(0.0f, -2.0f, 0.0f), AZ::Vector3(0.0f, 1.0f, 0.0f), AzFramework::ScreenPoint( 0,0 )); + const AzToolsFramework::ViewportInteraction::MousePick m_mouseStartingPositionRay{ AZ::Vector3(0.0f, -2.0f, 0.0f), + AZ::Vector3(0.0f, 1.0f, 0.0f), + AzFramework::ScreenPoint(0, 0) }; // left mouse down ray in world space 2 units back from origin looking down +y axis with a null interaction // id and no keyboard modifiers AzToolsFramework::ViewportInteraction::MouseInteraction m_interaction = - AzManipulatorTestFramework::CreateMouseInteraction( + AzToolsFramework::ViewportInteraction::BuildMouseInteraction( m_mouseStartingPositionRay, - AzManipulatorTestFramework::CreateMouseButtons(AzToolsFramework::ViewportInteraction::MouseButton::Left), + AzToolsFramework::ViewportInteraction::BuildMouseButtons(AzToolsFramework::ViewportInteraction::MouseButton::Left), AzToolsFramework::ViewportInteraction::InteractionId(AZ::EntityId(0), 0), AzToolsFramework::ViewportInteraction::KeyboardModifiers(0)); }; diff --git a/Code/Framework/AzManipulatorTestFramework/Tests/BusCallTest.cpp b/Code/Framework/AzManipulatorTestFramework/Tests/BusCallTest.cpp index 11f35d8fdc..8d86a96ffa 100644 --- a/Code/Framework/AzManipulatorTestFramework/Tests/BusCallTest.cpp +++ b/Code/Framework/AzManipulatorTestFramework/Tests/BusCallTest.cpp @@ -7,6 +7,8 @@ */ #include "AzManipulatorTestFrameworkTestFixtures.h" + +#include #include #include @@ -34,8 +36,8 @@ namespace UnitTest TEST_F(AzManipulatorTestFrameworkBusCallTestFixture, ConsumeViewportLeftMouseClick) { // given a left mouse down ray in world space - auto event = - AzManipulatorTestFramework::CreateMouseInteractionEvent(m_interaction, AzToolsFramework::ViewportInteraction::MouseEvent::Down); + auto event = AzToolsFramework::ViewportInteraction::BuildMouseInteractionEvent( + m_interaction, AzToolsFramework::ViewportInteraction::MouseEvent::Down); // consume the mouse down and up events AzManipulatorTestFramework::DispatchMouseInteractionEvent(event); @@ -53,8 +55,8 @@ namespace UnitTest TEST_F(AzManipulatorTestFrameworkBusCallTestFixture, ConsumeViewportMouseMoveHover) { // given a left mouse down ray in world space - const auto event = - AzManipulatorTestFramework::CreateMouseInteractionEvent(m_interaction, AzToolsFramework::ViewportInteraction::MouseEvent::Move); + const auto event = AzToolsFramework::ViewportInteraction::BuildMouseInteractionEvent( + m_interaction, AzToolsFramework::ViewportInteraction::MouseEvent::Move); // consume the mouse move event AzManipulatorTestFramework::DispatchMouseInteractionEvent(event); @@ -72,8 +74,8 @@ namespace UnitTest TEST_F(AzManipulatorTestFrameworkBusCallTestFixture, ConsumeViewportMouseMoveActive) { // given a left mouse down ray in world space - auto event = - AzManipulatorTestFramework::CreateMouseInteractionEvent(m_interaction, AzToolsFramework::ViewportInteraction::MouseEvent::Down); + auto event = AzToolsFramework::ViewportInteraction::BuildMouseInteractionEvent( + m_interaction, AzToolsFramework::ViewportInteraction::MouseEvent::Down); // consume the mouse down event AzManipulatorTestFramework::DispatchMouseInteractionEvent(event); @@ -113,8 +115,8 @@ namespace UnitTest }); // given a left mouse down ray in world space - auto event = - AzManipulatorTestFramework::CreateMouseInteractionEvent(m_interaction, AzToolsFramework::ViewportInteraction::MouseEvent::Down); + auto event = AzToolsFramework::ViewportInteraction::BuildMouseInteractionEvent( + m_interaction, AzToolsFramework::ViewportInteraction::MouseEvent::Down); // consume the mouse down event AzManipulatorTestFramework::DispatchMouseInteractionEvent(event); diff --git a/Code/Framework/AzTest/AzTest/Printers.cpp b/Code/Framework/AzTest/AzTest/Printers.cpp index dc639d87d1..978fda3b32 100644 --- a/Code/Framework/AzTest/AzTest/Printers.cpp +++ b/Code/Framework/AzTest/AzTest/Printers.cpp @@ -5,9 +5,12 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ -#include + +#include #include +#include + namespace AZ::IO { void PrintTo(const AZ::IO::PathView& path, ::std::ostream* os) @@ -24,4 +27,12 @@ namespace AZ::IO { *os << "path: " << AZ::IO::FixedMaxPath(path.Native(), AZ::IO::PosixPathSeparator).MakePreferred().c_str(); } -} +} // namespace AZ::IO + +namespace AZ +{ + void PrintTo(const AZ::EntityId entityId, ::std::ostream* os) + { + *os << entityId.ToString().c_str(); + } +} // namespace AZ diff --git a/Code/Framework/AzTest/AzTest/Printers.h b/Code/Framework/AzTest/AzTest/Printers.h index 3615f7b576..82af0e07d7 100644 --- a/Code/Framework/AzTest/AzTest/Printers.h +++ b/Code/Framework/AzTest/AzTest/Printers.h @@ -5,6 +5,7 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ + #pragma once #include @@ -37,4 +38,11 @@ namespace AZ::IO void PrintTo(const AZ::IO::FixedMaxPath& path, ::std::ostream* os); } +namespace AZ +{ + class EntityId; + + void PrintTo(AZ::EntityId entityId, ::std::ostream* os); +} + #include diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/API/ToolsApplicationAPI.h b/Code/Framework/AzToolsFramework/AzToolsFramework/API/ToolsApplicationAPI.h index 282898c37d..bca68a6c0a 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/API/ToolsApplicationAPI.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/API/ToolsApplicationAPI.h @@ -878,9 +878,6 @@ namespace AzToolsFramework /// Return the icon texture id (from internal IconManager) for a given entity icon path. /// This can be passed to DrawTextureLabel to draw an entity icon. virtual int GetIconTextureIdFromEntityIconPath(const AZStd::string& entityIconPath) = 0; - - /// Returns if the Display Helpers option is toggled on in the Editor. - virtual bool DisplayHelpersVisible() = 0; }; using EditorRequestBus = AZ::EBus; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportMessages.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportMessages.cpp index df96836bde..24b3c95310 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportMessages.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportMessages.cpp @@ -89,8 +89,8 @@ namespace AzToolsFramework const float rayLength) { AZ_Assert(rayLength > 0.0f, "Invalid ray length passed to RefreshRayRequest"); - rayRequest.m_startWorldPosition = viewportRay.origin; - rayRequest.m_endWorldPosition = viewportRay.origin + viewportRay.direction * rayLength; + rayRequest.m_startWorldPosition = viewportRay.m_origin; + rayRequest.m_endWorldPosition = viewportRay.m_origin + viewportRay.m_direction * rayLength; } AZ::Vector3 FindClosestPickIntersection( diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportMessages.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportMessages.h index aec2d3fbca..4dbcc9d926 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportMessages.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportMessages.h @@ -15,7 +15,6 @@ #include #include #include -#include #include #include @@ -151,13 +150,6 @@ namespace AzToolsFramework static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single; }; - //! A ray projection, originating from a point and extending in a direction specified as a normal. - struct ProjectedViewportRay - { - AZ::Vector3 origin; - AZ::Vector3 direction; - }; - //! Requests that can be made to the viewport to query and modify its state. class ViewportInteractionRequests { @@ -183,15 +175,6 @@ namespace AzToolsFramework //! Type to inherit to implement ViewportInteractionRequests. using ViewportInteractionRequestBus = AZ::EBus; - //! Utility function to return a viewport ray. - inline ProjectedViewportRay ViewportScreenToWorldRay( - const AzFramework::CameraState& cameraState, const AzFramework::ScreenPoint& screenPoint) - { - const AZ::Vector3 rayOrigin = AzFramework::ScreenToWorld(screenPoint, cameraState); - const AZ::Vector3 rayDirection = (rayOrigin - cameraState.m_position).GetNormalized(); - return AzToolsFramework::ViewportInteraction::ProjectedViewportRay{ rayOrigin, rayDirection }; - } - //! Utility function to return a viewport ray using the ViewportInteractionRequestBus. inline ProjectedViewportRay ViewportScreenToWorldRay( const AzFramework::ViewportId viewportId, const AzFramework::ScreenPoint& screenPoint) @@ -225,6 +208,10 @@ namespace AzToolsFramework virtual bool StickySelectEnabled() const = 0; //! Returns the default viewport camera position. virtual AZ::Vector3 DefaultEditorCameraPosition() const = 0; + //! Returns if icons are visible in the viewport. + virtual bool IconsVisible() const = 0; + //! Returns if viewport helpers (additional debug drawing) are visible in the viewport. + virtual bool HelpersVisible() const = 0; protected: ~ViewportSettingsRequests() = default; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportSettings.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportSettings.cpp index f8550b1a29..3bf25d4231 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportSettings.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportSettings.cpp @@ -20,6 +20,8 @@ namespace AzToolsFramework constexpr AZStd::string_view ScaleManipulatorBoxHalfExtentSetting = "/Amazon/Preferences/Editor/Manipulator/ScaleManipulatorBoxHalfExtent"; constexpr AZStd::string_view RotationManipulatorRadiusSetting = "/Amazon/Preferences/Editor/Manipulator/RotationManipulatorRadius"; constexpr AZStd::string_view ManipulatorViewBaseScaleSetting = "/Amazon/Preferences/Editor/Manipulator/ViewBaseScale"; + constexpr AZStd::string_view IconsVisibleSetting = "/Amazon/Preferences/Editor/IconsVisible"; + constexpr AZStd::string_view HelpersVisibleSetting = "/Amazon/Preferences/Editor/HelpersVisible"; bool FlipManipulatorAxesTowardsView() { @@ -120,4 +122,24 @@ namespace AzToolsFramework { SetRegistry(ManipulatorViewBaseScaleSetting, scale); } + + bool IconsVisible() + { + return GetRegistry(IconsVisibleSetting, true); + } + + void SetIconsVisible(const bool visible) + { + SetRegistry(IconsVisibleSetting, visible); + } + + bool HelpersVisible() + { + return GetRegistry(HelpersVisibleSetting, true); + } + + void SetHelpersVisible(const bool visible) + { + SetRegistry(HelpersVisibleSetting, visible); + } } // namespace AzToolsFramework diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportSettings.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportSettings.h index f5371b6035..80880e0bae 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportSettings.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportSettings.h @@ -66,4 +66,10 @@ namespace AzToolsFramework float ManipulatorViewBaseScale(); void SetManipulatorViewBaseScale(float scale); + + bool IconsVisible(); + void SetIconsVisible(bool visible); + + bool HelpersVisible(); + void SetHelpersVisible(bool visible); } // namespace AzToolsFramework diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportTypes.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportTypes.cpp index 546320d1e9..f884ab245e 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportTypes.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportTypes.cpp @@ -49,5 +49,22 @@ namespace AzToolsFramework ->Field("MouseEvent", &MouseInteractionEvent::m_mouseEvent) ->Field("WheelDelta", &MouseInteractionEvent::m_wheelDelta); } + + MouseInteraction BuildMouseInteraction( + const MousePick& mousePick, const MouseButtons buttons, const InteractionId interactionId, const KeyboardModifiers modifiers) + { + MouseInteraction interaction; + interaction.m_mousePick = mousePick; + interaction.m_mouseButtons = buttons; + interaction.m_interactionId = interactionId; + interaction.m_keyboardModifiers = modifiers; + return interaction; + } + + MouseInteractionEvent BuildMouseInteractionEvent( + const MouseInteraction& mouseInteraction, const MouseEvent event, const bool cursorCaptured /*= false*/) + { + return MouseInteractionEvent(mouseInteraction, event, cursorCaptured); + } } // namespace ViewportInteraction } // namespace AzToolsFramework diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportTypes.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportTypes.h index bc1d277609..903c91fb0a 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportTypes.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Viewport/ViewportTypes.h @@ -8,11 +8,11 @@ #pragma once -#include "AzFramework/Viewport/ScreenGeometry.h" - #include #include #include +#include +#include #include @@ -20,7 +20,7 @@ namespace AZ { class ReflectContext; class SerializeContext; -} +} // namespace AZ namespace AzToolsFramework { @@ -178,6 +178,12 @@ namespace AzToolsFramework //! @cond AZ_TYPE_INFO(MousePick, "{A69B9562-FC8C-4DE7-9137-0FF867B1513D}"); MousePick() = default; + MousePick(const AZ::Vector3& rayOrigin, const AZ::Vector3& rayDirection, const AzFramework::ScreenPoint& screenPoint) + : m_rayOrigin(rayOrigin) + , m_rayDirection(rayDirection) + , m_screenCoordinates(screenPoint) + { + } //! @endcond AZ::Vector3 m_rayOrigin = AZ::Vector3::CreateZero(); //!< World space. @@ -249,6 +255,22 @@ namespace AzToolsFramework return mouseInteractionEvent.m_wheelDelta; } + //! A ray projection, originating from a point and extending in a direction specified as a normal. + struct ProjectedViewportRay + { + AZ::Vector3 m_origin; + AZ::Vector3 m_direction; + }; + + //! Utility function to return a viewport ray. + inline ProjectedViewportRay ViewportScreenToWorldRay( + const AzFramework::CameraState& cameraState, const AzFramework::ScreenPoint& screenPoint) + { + const AZ::Vector3 rayOrigin = AzFramework::ScreenToWorld(screenPoint, cameraState); + const AZ::Vector3 rayDirection = (rayOrigin - cameraState.m_position).GetNormalized(); + return ProjectedViewportRay{ rayOrigin, rayDirection }; + } + //! Return QPoint from AzFramework::ScreenPoint. inline QPoint QPointFromScreenPoint(const AzFramework::ScreenPoint& screenPoint) { @@ -301,6 +323,27 @@ namespace AzToolsFramework return mouseButtons; } + //! Build a mouse pick from the specified mouse position and camera state. + inline MousePick BuildMousePick(const AzFramework::CameraState& cameraState, const AzFramework::ScreenPoint& screenPoint) + { + const auto ray = ViewportScreenToWorldRay(cameraState, screenPoint); + return MousePick(ray.m_origin, ray.m_direction, screenPoint); + } + + //! Create a mouse interaction from the specified pick, buttons, interaction id and keyboard modifiers. + MouseInteraction BuildMouseInteraction( + const MousePick& mousePick, MouseButtons buttons, InteractionId interactionId, KeyboardModifiers modifiers); + + //! Create a mouse buttons from the specified mouse button. + inline MouseButtons BuildMouseButtons(const MouseButton button) + { + return MouseButtons(aznumeric_cast(button)); + } + + //! Create a mouse interaction event from the specified interaction and event. + MouseInteractionEvent BuildMouseInteractionEvent( + const MouseInteraction& mouseInteraction, MouseEvent event, bool cursorCaptured = false); + //! Reflect all viewport related types. void ViewportInteractionReflect(AZ::ReflectContext* context); } // namespace ViewportInteraction diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp index ee30b9e29d..ace2156d85 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.cpp @@ -52,34 +52,45 @@ AZ_CVAR( AZ::ConsoleFunctorFlags::Null, "Use a lock icon when the cursor is over entities that cannot be interacted with"); +AZ_CVAR(float, ed_iconMinScale, 0.1f, nullptr, AZ::ConsoleFunctorFlags::Null, "Minimum scale for icons in the distance"); +AZ_CVAR(float, ed_iconMaxScale, 1.0f, nullptr, AZ::ConsoleFunctorFlags::Null, "Maximum scale for icons near the camera"); +AZ_CVAR(float, ed_iconCloseDist, 3.0f, nullptr, AZ::ConsoleFunctorFlags::Null, "Distance at which icons are at maximum scale"); +AZ_CVAR(float, ed_iconFarDist, 40.f, nullptr, AZ::ConsoleFunctorFlags::Null, "Distance at which icons are at minimum scale"); + namespace AzToolsFramework { AZ_CLASS_ALLOCATOR_IMPL(EditorHelpers, AZ::SystemAllocator, 0) - static const int s_iconSize = 36; // icon display size (in pixels) - static const float s_iconMinScale = 0.1f; // minimum scale for icons in the distance - static const float s_iconMaxScale = 1.0f; // maximum scale for icons near the camera - static const float s_iconCloseDist = 3.f; // distance at which icons are at maximum scale - static const float s_iconFarDist = 40.f; // distance at which icons are at minimum scale + static const int IconSize = 36; // icon display size (in pixels) // helper function to wrap EBus call to check if helpers are being displayed - // note: the ['?'] icon in the top right of the editor - static bool HelpersVisible() + static bool HelpersVisible(const AzFramework::ViewportId viewportId) { bool helpersVisible = false; - EditorRequestBus::BroadcastResult(helpersVisible, &EditorRequests::DisplayHelpersVisible); + ViewportInteraction::ViewportSettingsRequestBus::EventResult( + helpersVisible, viewportId, &ViewportInteraction::ViewportSettingsRequestBus::Events::HelpersVisible); return helpersVisible; } - // calculate the icon scale based on how far away it is (distanceSq) from a given point - // note: this is mostly likely distance from the camera - static float GetIconScale(const float distSq) + // helper function to wrap EBus call to check if icons are being displayed + static bool IconsVisible(const AzFramework::ViewportId viewportId) { - AZ_PROFILE_FUNCTION(AzToolsFramework); + bool iconsVisible = false; + ViewportInteraction::ViewportSettingsRequestBus::EventResult( + iconsVisible, viewportId, &ViewportInteraction::ViewportSettingsRequestBus::Events::IconsVisible); + return iconsVisible; + } - return s_iconMinScale + - (s_iconMaxScale - s_iconMinScale) * - (1.0f - AZ::GetClamp(AZ::GetMax(0.0f, sqrtf(distSq) - s_iconCloseDist) / s_iconFarDist, 0.0f, 1.0f)); + float GetIconScale(const float distance) + { + return ed_iconMinScale + + (ed_iconMaxScale - ed_iconMinScale) * + (1.0f - AZ::GetClamp(AZ::GetMax(0.0f, distance - ed_iconCloseDist) / (ed_iconFarDist - ed_iconCloseDist), 0.0f, 1.0f)); + } + + float GetIconSize(const float distance) + { + return GetIconScale(distance) * IconSize; } static void DisplayComponents( @@ -171,11 +182,14 @@ namespace AzToolsFramework const int viewportId = mouseInteraction.m_mouseInteraction.m_interactionId.m_viewportId; - const bool helpersVisible = HelpersVisible(); + const bool iconsVisible = IconsVisible(viewportId); + + const AZ::Matrix3x4 cameraView = AzFramework::CameraView(cameraState); + const AZ::Matrix4x4 cameraProjection = AzFramework::CameraProjection(cameraState); // selecting new entities AZ::EntityId entityIdUnderCursor; - float closestDistance = std::numeric_limits::max(); + float closestDistance = AZStd::numeric_limits::max(); for (size_t entityCacheIndex = 0; entityCacheIndex < m_entityDataCache->VisibleEntityDataCount(); ++entityCacheIndex) { const AZ::EntityId entityId = m_entityDataCache->GetVisibleEntityId(entityCacheIndex); @@ -185,8 +199,7 @@ namespace AzToolsFramework continue; } - // 2d screen space selection - did we click an icon - if (helpersVisible) + if (iconsVisible) { // some components choose to hide their icons (e.g. meshes) // we also do not want to test against icons that may not be showing as they're inside a 'closed' entity container @@ -197,17 +210,23 @@ namespace AzToolsFramework const AZ::Vector3& entityPosition = m_entityDataCache->GetVisibleEntityPosition(entityCacheIndex); // selecting based on 2d icon - should only do it when visible and not selected - const AzFramework::ScreenPoint screenPosition = AzFramework::WorldToScreen(entityPosition, cameraState); + const AZ::Vector3 ndcPoint = AzFramework::WorldToScreenNdc(entityPosition, cameraView, cameraProjection); + const AzFramework::ScreenPoint screenPosition = + AzFramework::ScreenPointFromNdc(AZ::Vector3ToVector2(ndcPoint), cameraState.m_viewportSize); - const float distSqFromCamera = cameraState.m_position.GetDistanceSq(entityPosition); - const auto iconRange = static_cast(GetIconScale(distSqFromCamera) * s_iconSize * 0.5f); + const float distanceFromCamera = cameraState.m_position.GetDistance(entityPosition); + const auto iconRange = GetIconSize(distanceFromCamera) * 0.5f; const auto screenCoords = mouseInteraction.m_mouseInteraction.m_mousePick.m_screenCoordinates; + // 2d screen space selection - did we click an icon if (screenCoords.m_x >= screenPosition.m_x - iconRange && screenCoords.m_x <= screenPosition.m_x + iconRange && - screenCoords.m_y >= screenPosition.m_y - iconRange && screenCoords.m_y <= screenPosition.m_y + iconRange) + screenCoords.m_y >= screenPosition.m_y - iconRange && screenCoords.m_y <= screenPosition.m_y + iconRange && + ndcPoint.GetZ() < closestDistance) { + // use ndc z value for distance here which is in 0-1 range so will most likely 'win' when it comes to the + // distance check (this is what we want as the cursor should always favor icons if they are hovered) + closestDistance = ndcPoint.GetZ(); entityIdUnderCursor = entityId; - break; } } } @@ -220,9 +239,14 @@ namespace AzToolsFramework if (AabbIntersectMouseRay(mouseInteraction.m_mouseInteraction, aabb)) { // if success, pick against specific component - if (PickEntity(entityId, mouseInteraction.m_mouseInteraction, closestDistance, viewportId)) + float closestBoundDifference = AZStd::numeric_limits::max(); + if (PickEntity(entityId, mouseInteraction.m_mouseInteraction, closestBoundDifference, viewportId)) { - entityIdUnderCursor = entityId; + if (closestBoundDifference < closestDistance) + { + closestDistance = closestBoundDifference; + entityIdUnderCursor = entityId; + } } } } @@ -276,55 +300,78 @@ namespace AzToolsFramework { AZ_PROFILE_FUNCTION(AzToolsFramework); - if (HelpersVisible()) + const bool iconsVisible = IconsVisible(viewportInfo.m_viewportId); + const bool helpersVisible = HelpersVisible(viewportInfo.m_viewportId); + + auto displayCheck = [this](const size_t entityCacheIndex, const AZ::EntityId entityId) + { + if (!m_entityDataCache->IsVisibleEntityVisible(entityCacheIndex) || !IsSelectableInViewport(entityId)) + { + return false; + } + return true; + }; + + if (helpersVisible) { for (size_t entityCacheIndex = 0; entityCacheIndex < m_entityDataCache->VisibleEntityDataCount(); ++entityCacheIndex) { - const AZ::EntityId entityId = m_entityDataCache->GetVisibleEntityId(entityCacheIndex); - - if (!m_entityDataCache->IsVisibleEntityVisible(entityCacheIndex) || !IsSelectableInViewport(entityId)) + if (const AZ::EntityId entityId = m_entityDataCache->GetVisibleEntityId(entityCacheIndex); + displayCheck(entityCacheIndex, entityId)) { - continue; + // notify components to display + DisplayComponents(entityId, viewportInfo, debugDisplay); } + } + } - // notify components to display - DisplayComponents(entityId, viewportInfo, debugDisplay); + if (iconsVisible) + { + auto editorViewportIconDisplay = EditorViewportIconDisplay::Get(); + if (!editorViewportIconDisplay) + { + return; + } - if (m_entityDataCache->IsVisibleEntityIconHidden(entityCacheIndex) || - (m_entityDataCache->IsVisibleEntitySelected(entityCacheIndex) && !showIconCheck(entityId))) + for (size_t entityCacheIndex = 0; entityCacheIndex < m_entityDataCache->VisibleEntityDataCount(); ++entityCacheIndex) + { + if (const AZ::EntityId entityId = m_entityDataCache->GetVisibleEntityId(entityCacheIndex); + displayCheck(entityCacheIndex, entityId)) { - continue; - } - - int iconTextureId = 0; - EditorEntityIconComponentRequestBus::EventResult( - iconTextureId, entityId, &EditorEntityIconComponentRequests::GetEntityIconTextureId); - - const AZ::Vector3& entityPosition = m_entityDataCache->GetVisibleEntityPosition(entityCacheIndex); - const float distSqFromCamera = cameraState.m_position.GetDistanceSq(entityPosition); - - const float iconScale = GetIconScale(distSqFromCamera); - const float iconSize = s_iconSize * iconScale; - - using ComponentEntityAccentType = Components::EditorSelectionAccentSystemComponent::ComponentEntityAccentType; - const AZ::Color iconHighlight = [this, entityCacheIndex]() - { - if (m_entityDataCache->IsVisibleEntityLocked(entityCacheIndex)) + if (m_entityDataCache->IsVisibleEntityIconHidden(entityCacheIndex) || + (m_entityDataCache->IsVisibleEntitySelected(entityCacheIndex) && !showIconCheck(entityId))) { - return AZ::Color(AZ::u8(100), AZ::u8(100), AZ::u8(100), AZ::u8(255)); + continue; } - if (m_entityDataCache->GetVisibleEntityAccent(entityCacheIndex) == ComponentEntityAccentType::Hover) + int iconTextureId = 0; + EditorEntityIconComponentRequestBus::EventResult( + iconTextureId, entityId, &EditorEntityIconComponentRequests::GetEntityIconTextureId); + + using ComponentEntityAccentType = Components::EditorSelectionAccentSystemComponent::ComponentEntityAccentType; + const AZ::Color iconHighlight = [this, entityCacheIndex]() { - return AZ::Color(AZ::u8(255), AZ::u8(120), AZ::u8(0), AZ::u8(204)); - } + if (m_entityDataCache->IsVisibleEntityLocked(entityCacheIndex)) + { + return AZ::Color(AZ::u8(100), AZ::u8(100), AZ::u8(100), AZ::u8(255)); + } - return AZ::Color(1.0f, 1.0f, 1.0f, 1.0f); - }(); + if (m_entityDataCache->GetVisibleEntityAccent(entityCacheIndex) == ComponentEntityAccentType::Hover) + { + return AZ::Color(AZ::u8(255), AZ::u8(120), AZ::u8(0), AZ::u8(204)); + } - EditorViewportIconDisplay::Get()->DrawIcon({ viewportInfo.m_viewportId, iconTextureId, iconHighlight, entityPosition, - EditorViewportIconDisplayInterface::CoordinateSpace::WorldSpace, - AZ::Vector2{ iconSize, iconSize } }); + return AZ::Color(1.0f, 1.0f, 1.0f, 1.0f); + }(); + + const AZ::Vector3& entityPosition = m_entityDataCache->GetVisibleEntityPosition(entityCacheIndex); + const float distanceFromCamera = cameraState.m_position.GetDistance(entityPosition); + const float iconSize = GetIconSize(distanceFromCamera); + + editorViewportIconDisplay->DrawIcon({ viewportInfo.m_viewportId, iconTextureId, iconHighlight, entityPosition, + EditorViewportIconDisplayInterface::CoordinateSpace::WorldSpace, + AZ::Vector2{ iconSize, iconSize } }); + } } } } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.h b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.h index 458f15c1f2..358e6d9117 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorHelpers.h @@ -106,4 +106,12 @@ namespace AzToolsFramework const EditorVisibleEntityDataCache* m_entityDataCache = nullptr; //!< Entity Data queried by the EditorHelpers. const FocusModeInterface* m_focusModeInterface = nullptr; //!< API to interact with focus mode functionality. }; + + //! Calculate the icon scale based on how far away it is from a given point. + //! @note This is mostly likely distance from the camera. + float GetIconScale(float distance); + + //! Calculate the icon size based on how far away it is from a given point. + //! @note This is the base icon size multiplied by the icon scale to give a final viewport size. + float GetIconSize(float distance); } // namespace AzToolsFramework diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp index bd9292db32..b14f58fafa 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelection.cpp @@ -2521,10 +2521,9 @@ namespace AzToolsFramework AZStd::erase_if( m_selectedEntityIds, [readOnlyEntityPublicInterface](auto entityId) - { - return readOnlyEntityPublicInterface->IsReadOnly(entityId); - } - ); + { + return readOnlyEntityPublicInterface->IsReadOnly(entityId); + }); } // note: create/destroy pattern to be addressed @@ -3285,9 +3284,9 @@ namespace AzToolsFramework QObject::connect( action, &QAction::triggered, action, [this] - { - ToggleCenterPivotSelection(); - }); + { + ToggleCenterPivotSelection(); + }); } } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelectionRequestBus.h b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelectionRequestBus.h index 35f5b0ba99..7ae1db1073 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelectionRequestBus.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportSelection/EditorTransformComponentSelectionRequestBus.h @@ -32,6 +32,8 @@ namespace AzToolsFramework constexpr inline AZ::Crc32 EditReset = AZ_CRC_CE("com.o3de.action.editortransform.editreset"); constexpr inline AZ::Crc32 EditResetManipulator = AZ_CRC_CE("com.o3de.action.editortransform.editresetmanipulator"); constexpr inline AZ::Crc32 ViewportUiVisible = AZ_CRC_CE("com.o3de.action.editortransform.viewportuivisible"); + constexpr inline AZ::Crc32 Helpers = AZ_CRC_CE("com.o3de.action.editor.helpers"); + constexpr inline AZ::Crc32 Icons = AZ_CRC_CE("com.o3de.action.editor.icons"); //@} //! Provide interface for EditorTransformComponentSelection requests. diff --git a/Code/Framework/AzToolsFramework/Tests/EditorTransformComponentSelectionTests.cpp b/Code/Framework/AzToolsFramework/Tests/EditorTransformComponentSelectionTests.cpp index 859cc67c41..dc9e1180b7 100644 --- a/Code/Framework/AzToolsFramework/Tests/EditorTransformComponentSelectionTests.cpp +++ b/Code/Framework/AzToolsFramework/Tests/EditorTransformComponentSelectionTests.cpp @@ -40,16 +40,12 @@ #include -namespace AZ -{ - std::ostream& operator<<(std::ostream& os, const EntityId entityId) - { - return os << entityId.ToString().c_str(); - } -} // namespace AZ - namespace UnitTest { + using AzToolsFramework::ViewportInteraction::BuildMouseButtons; + using AzToolsFramework::ViewportInteraction::BuildMouseInteraction; + using AzToolsFramework::ViewportInteraction::BuildMousePick; + AzToolsFramework::EntityIdList SelectedEntities() { AzToolsFramework::EntityIdList selectedEntitiesBefore; @@ -137,6 +133,18 @@ namespace UnitTest AzToolsFramework::EntityIdList m_entityIds; }; + AZ::EntityId CreateEntityWithBounds(const char* entityName) + { + AZ::Entity* entity = nullptr; + AZ::EntityId entityId = CreateDefaultEditorEntity(entityName, &entity); + + entity->Deactivate(); + entity->CreateComponent(); + entity->Activate(); + + return entityId; + } + class EditorTransformComponentSelectionViewportPickingFixture : public ToolsApplicationFixture { public: @@ -146,21 +154,9 @@ namespace UnitTest // register a simple component implementing BoundsRequestBus and EditorComponentSelectionRequestsBus app->RegisterComponentDescriptor(BoundsTestComponent::CreateDescriptor()); - auto createEntityWithBoundsFn = [](const char* entityName) - { - AZ::Entity* entity = nullptr; - AZ::EntityId entityId = CreateDefaultEditorEntity(entityName, &entity); - - entity->Deactivate(); - entity->CreateComponent(); - entity->Activate(); - - return entityId; - }; - - m_entityId1 = createEntityWithBoundsFn("Entity1"); - m_entityId2 = createEntityWithBoundsFn("Entity2"); - m_entityId3 = createEntityWithBoundsFn("Entity3"); + m_entityId1 = CreateEntityWithBounds("Entity1"); + m_entityId2 = CreateEntityWithBounds("Entity2"); + m_entityId3 = CreateEntityWithBounds("Entity3"); } void PositionEntities() @@ -959,6 +955,9 @@ namespace UnitTest const auto entity2ScreenPosition = AzFramework::WorldToScreen(AzToolsFramework::GetWorldTranslation(m_entityId2), m_cameraState); + // ensure icons are not enabled to avoid them interfering with bound detection + m_viewportManipulatorInteraction->GetViewportInteraction().SetIconsVisible(false); + // click the entity in the viewport m_actionDispatcher->SetStickySelect(true) ->CameraState(m_cameraState) @@ -974,6 +973,137 @@ namespace UnitTest EXPECT_THAT(selectedEntities, UnorderedElementsAreArray(expectedSelectedEntities)); } + // entity can be selected using icon + TEST_F(EditorTransformComponentSelectionViewportPickingManipulatorTestFixture, CursorOverEntityIconReturnsThatEntityId) + { + const AZ::EntityId boundlessEntityId = CreateDefaultEditorEntity("BoundlessEntity"); + + // camera (go to position format) -5.00, -8.00, 5.00, 0.00, 0.00 + AzFramework::SetCameraTransform(m_cameraState, AZ::Transform::CreateTranslation(AZ::Vector3(-5.0f, -8.0f, 5.0f))); + // position entity in the world + AZ::TransformBus::Event(boundlessEntityId, &AZ::TransformBus::Events::SetWorldTranslation, AZ::Vector3(-5.0f, -1.0f, 5.0f)); + + const float distanceFromCamera = m_cameraState.m_position.GetDistance(AzToolsFramework::GetWorldTranslation(boundlessEntityId)); + + const auto quaterIconSize = AzToolsFramework::GetIconSize(distanceFromCamera) * 0.25f; + const auto entity1ScreenPosition = + AzFramework::WorldToScreen(AzToolsFramework::GetWorldTranslation(boundlessEntityId), m_cameraState) + + AzFramework::ScreenVectorFromVector2(AZ::Vector2(quaterIconSize)); + + AzToolsFramework::EditorVisibleEntityDataCache editorVisibleEntityDataCache; + AzToolsFramework::EditorHelpers editorHelpers(&editorVisibleEntityDataCache); + + const auto viewportId = m_viewportManipulatorInteraction->GetViewportInteraction().GetViewportId(); + const auto mousePick = BuildMousePick(m_cameraState, entity1ScreenPosition); + const auto mouseInteraction = BuildMouseInteraction( + mousePick, BuildMouseButtons(AzToolsFramework::ViewportInteraction::MouseButton::None), + AzToolsFramework::ViewportInteraction::InteractionId(AZ::EntityId(), viewportId), + AzToolsFramework::ViewportInteraction::KeyboardModifiers()); + const auto mouseInteractionEvent = AzToolsFramework::ViewportInteraction::BuildMouseInteractionEvent( + mouseInteraction, AzToolsFramework::ViewportInteraction::MouseEvent::Move, false); + + // mimic mouse move + m_actionDispatcher->CameraState(m_cameraState)->MousePosition(entity1ScreenPosition); + + // simulate hovering over an icon in the viewport + editorVisibleEntityDataCache.CalculateVisibleEntityDatas(AzFramework::ViewportInfo{ viewportId }); + auto entityIdUnderCursor = editorHelpers.FindEntityIdUnderCursor(m_cameraState, mouseInteractionEvent); + + using ::testing::Eq; + EXPECT_THAT(entityIdUnderCursor.EntityIdUnderCursor(), Eq(boundlessEntityId)); + } + + // overlapping icons, nearest is detected + TEST_F(EditorTransformComponentSelectionViewportPickingManipulatorTestFixture, CursorOverOverlappingEntityIconsReturnsClosestEntityId) + { + const AZ::EntityId boundlessEntityId1 = CreateDefaultEditorEntity("BoundlessEntity1"); + const AZ::EntityId boundlessEntityId2 = CreateDefaultEditorEntity("BoundlessEntity2"); + + // camera (go to position format) -5.00, -8.00, 5.00, 0.00, 0.00 + AzFramework::SetCameraTransform(m_cameraState, AZ::Transform::CreateTranslation(AZ::Vector3(-5.0f, -8.0f, 5.0f))); + // position entities in the world + AZ::TransformBus::Event(boundlessEntityId1, &AZ::TransformBus::Events::SetWorldTranslation, AZ::Vector3(-5.0f, -1.0f, 5.0f)); + // note: boundlessEntityId2 is closer to the camera + AZ::TransformBus::Event(boundlessEntityId2, &AZ::TransformBus::Events::SetWorldTranslation, AZ::Vector3(-5.0f, -3.0f, 5.0f)); + + const float distanceFromCamera = m_cameraState.m_position.GetDistance(AzToolsFramework::GetWorldTranslation(boundlessEntityId2)); + + const auto quaterIconSize = AzToolsFramework::GetIconSize(distanceFromCamera) * 0.25f; + const auto entity2ScreenPosition = + AzFramework::WorldToScreen(AzToolsFramework::GetWorldTranslation(boundlessEntityId2), m_cameraState) + + AzFramework::ScreenVectorFromVector2(AZ::Vector2(quaterIconSize)); + + AzToolsFramework::EditorVisibleEntityDataCache editorVisibleEntityDataCache; + AzToolsFramework::EditorHelpers editorHelpers(&editorVisibleEntityDataCache); + + const auto viewportId = m_viewportManipulatorInteraction->GetViewportInteraction().GetViewportId(); + const auto mousePick = BuildMousePick(m_cameraState, entity2ScreenPosition); + const auto mouseInteraction = BuildMouseInteraction( + mousePick, BuildMouseButtons(AzToolsFramework::ViewportInteraction::MouseButton::None), + AzToolsFramework::ViewportInteraction::InteractionId(AZ::EntityId(), viewportId), + AzToolsFramework::ViewportInteraction::KeyboardModifiers()); + const auto mouseInteractionEvent = AzToolsFramework::ViewportInteraction::BuildMouseInteractionEvent( + mouseInteraction, AzToolsFramework::ViewportInteraction::MouseEvent::Move, false); + + // mimic mouse move + m_actionDispatcher->CameraState(m_cameraState)->MousePosition(entity2ScreenPosition); + + // simulate hovering over an icon in the viewport + editorVisibleEntityDataCache.CalculateVisibleEntityDatas(AzFramework::ViewportInfo{ viewportId }); + auto entityIdUnderCursor = editorHelpers.FindEntityIdUnderCursor(m_cameraState, mouseInteractionEvent); + + using ::testing::Eq; + EXPECT_THAT(entityIdUnderCursor.EntityIdUnderCursor(), Eq(boundlessEntityId2)); + } + + // if an entity with an icon is behind an entity with a bound, the entity with the icon will be selected + // even if the bound is closer (this is because icons are treated as if they are on the near clip plane) + TEST_F( + EditorTransformComponentSelectionViewportPickingManipulatorTestFixture, FurtherAwayEntityWithIconReturnedWhenBoundEntityIsInFront) + { + const AZ::EntityId boundEntityId = CreateEntityWithBounds("BoundEntity"); + const AZ::EntityId boundlessEntityId = CreateDefaultEditorEntity("BoundlessEntity"); + + auto* boundTestComponent = AzToolsFramework::GetEntityById(boundEntityId)->FindComponent(); + boundTestComponent->m_localBounds = AZ::Aabb::CreateFromMinMax(AZ::Vector3(-1.5f, -0.5f, -0.5f), AZ::Vector3(1.5f, 0.5, 0.5f)); + + // camera (go to position format) -5.00, -8.00, 5.00, 0.00, 0.00 + AzFramework::SetCameraTransform(m_cameraState, AZ::Transform::CreateTranslation(AZ::Vector3(-5.0f, -8.0f, 5.0f))); + // position entities in the world + AZ::TransformBus::Event(boundEntityId, &AZ::TransformBus::Events::SetWorldTranslation, AZ::Vector3(-4.0f, -3.0f, 5.0f)); + // note: boundlessEntityId2 is closer to the camera + AZ::TransformBus::Event(boundlessEntityId, &AZ::TransformBus::Events::SetWorldTranslation, AZ::Vector3(-5.0f, -1.0f, 5.0f)); + + const float distanceFromCamera = m_cameraState.m_position.GetDistance(AzToolsFramework::GetWorldTranslation(boundlessEntityId)); + + const auto quaterIconSize = AzToolsFramework::GetIconSize(distanceFromCamera) * 0.25f; + const auto entity2ScreenPosition = + AzFramework::WorldToScreen(AzToolsFramework::GetWorldTranslation(boundlessEntityId), m_cameraState) + + AzFramework::ScreenVectorFromVector2(AZ::Vector2(quaterIconSize)); + + AzToolsFramework::EditorVisibleEntityDataCache editorVisibleEntityDataCache; + AzToolsFramework::EditorHelpers editorHelpers(&editorVisibleEntityDataCache); + + const auto viewportId = m_viewportManipulatorInteraction->GetViewportInteraction().GetViewportId(); + const auto mousePick = BuildMousePick(m_cameraState, entity2ScreenPosition); + const auto mouseInteraction = BuildMouseInteraction( + mousePick, BuildMouseButtons(AzToolsFramework::ViewportInteraction::MouseButton::None), + AzToolsFramework::ViewportInteraction::InteractionId(AZ::EntityId(), viewportId), + AzToolsFramework::ViewportInteraction::KeyboardModifiers()); + const auto mouseInteractionEvent = AzToolsFramework::ViewportInteraction::BuildMouseInteractionEvent( + mouseInteraction, AzToolsFramework::ViewportInteraction::MouseEvent::Move, false); + + // mimic mouse move + m_actionDispatcher->CameraState(m_cameraState)->MousePosition(entity2ScreenPosition); + + // simulate hovering over an icon in the viewport + editorVisibleEntityDataCache.CalculateVisibleEntityDatas(AzFramework::ViewportInfo{ viewportId }); + auto entityIdUnderCursor = editorHelpers.FindEntityIdUnderCursor(m_cameraState, mouseInteractionEvent); + + using ::testing::Eq; + EXPECT_THAT(entityIdUnderCursor.EntityIdUnderCursor(), Eq(boundlessEntityId)); + } + class EditorTransformComponentSelectionViewportPickingManipulatorTestFixtureParam : public EditorTransformComponentSelectionViewportPickingManipulatorTestFixture , public ::testing::WithParamInterface @@ -1709,8 +1839,9 @@ namespace UnitTest using MouseInteractionResult = AzToolsFramework::ViewportInteraction::MouseInteractionResult; public: - WheelEventWidget(QWidget* parent = nullptr) + WheelEventWidget(const AzFramework::ViewportId viewportId, QWidget* parent = nullptr) : QWidget(parent) + , m_viewportId(viewportId) { } @@ -1719,7 +1850,7 @@ namespace UnitTest namespace vi = AzToolsFramework::ViewportInteraction; vi::MouseInteraction mouseInteraction; mouseInteraction.m_interactionId.m_cameraId = AZ::EntityId(); - mouseInteraction.m_interactionId.m_viewportId = 0; + mouseInteraction.m_interactionId.m_viewportId = m_viewportId; mouseInteraction.m_mouseButtons = vi::BuildMouseButtons(ev->buttons()); mouseInteraction.m_mousePick = vi::MousePick(); mouseInteraction.m_keyboardModifiers = vi::BuildKeyboardModifiers(ev->modifiers()); @@ -1731,15 +1862,15 @@ namespace UnitTest } MouseInteractionResult m_mouseInteractionResult; + AzFramework::ViewportId m_viewportId; }; - TEST_F(EditorTransformComponentSelectionFixture, MouseScrollWheelSwitchesTransformMode) + TEST_F(EditorTransformComponentSelectionManipulatorTestFixture, MouseScrollWheelSwitchesTransformMode) { - using ::testing::Eq; namespace vi = AzToolsFramework::ViewportInteraction; using AzToolsFramework::EditorTransformComponentSelectionRequestBus; - const auto transformMode = []() + const auto transformMode = [] { EditorTransformComponentSelectionRequestBus::Events::Mode transformMode; EditorTransformComponentSelectionRequestBus::EventResult( @@ -1752,7 +1883,7 @@ namespace UnitTest // preconditions EXPECT_THAT(transformMode(), EditorTransformComponentSelectionRequestBus::Events::Mode::Translation); - auto wheelEventWidget = WheelEventWidget(); + auto wheelEventWidget = WheelEventWidget(m_viewportManipulatorInteraction->GetViewportInteraction().GetViewportId()); // attach the global event filter to the placeholder widget AzQtComponents::GlobalEventFilter globalEventFilter(QApplication::instance()); wheelEventWidget.installEventFilter(&globalEventFilter); @@ -1768,6 +1899,7 @@ namespace UnitTest // then // transform mode has changed and mouse event was handled + using ::testing::Eq; EXPECT_THAT(transformMode(), Eq(EditorTransformComponentSelectionRequestBus::Events::Mode::Rotation)); EXPECT_THAT(wheelEventWidget.m_mouseInteractionResult, Eq(vi::MouseInteractionResult::Viewport)); } @@ -3100,7 +3232,7 @@ namespace UnitTest const AZ::Transform finalEntityTransform = AzToolsFramework::GetWorldTransform(m_entityIdBox); const auto viewportRay = AzToolsFramework::ViewportInteraction::ViewportScreenToWorldRay(m_cameraState, initialPositionScreen); - const auto distanceAway = (finalEntityTransform.GetTranslation() - viewportRay.origin).GetLength(); + const auto distanceAway = (finalEntityTransform.GetTranslation() - viewportRay.m_origin).GetLength(); // ensure final world positions match EXPECT_THAT(finalEntityTransform, IsCloseTolerance(finalTransformWorld, 0.01f)); diff --git a/Code/Framework/AzToolsFramework/Tests/EntityIdQLabelTests.cpp b/Code/Framework/AzToolsFramework/Tests/EntityIdQLabelTests.cpp index 486224c011..c2b4ff3cc4 100644 --- a/Code/Framework/AzToolsFramework/Tests/EntityIdQLabelTests.cpp +++ b/Code/Framework/AzToolsFramework/Tests/EntityIdQLabelTests.cpp @@ -62,7 +62,6 @@ namespace UnitTest void BrowseForAssets(AssetBrowser::AssetSelectionModel& /*selection*/) override {} int GetIconTextureIdFromEntityIconPath(const AZStd::string& entityIconPath) override { AZ_UNUSED(entityIconPath); return 0; } - bool DisplayHelpersVisible() override { return false; } void GoToSelectedEntitiesInViewports() override { diff --git a/Code/Framework/AzToolsFramework/Tests/FocusMode/ContainerEntitySelectionTests.cpp b/Code/Framework/AzToolsFramework/Tests/FocusMode/ContainerEntitySelectionTests.cpp index a47e41da42..0ad61b924b 100644 --- a/Code/Framework/AzToolsFramework/Tests/FocusMode/ContainerEntitySelectionTests.cpp +++ b/Code/Framework/AzToolsFramework/Tests/FocusMode/ContainerEntitySelectionTests.cpp @@ -8,12 +8,12 @@ #include -namespace AzToolsFramework +namespace UnitTest { - TEST_F(EditorFocusModeSelectionFixture, ContainerEntitySelectionTests_FindHighestSelectableEntityWithNoContainers) + TEST_F(EditorFocusModeSelectionFixture, ContainerEntitySelectionFindHighestSelectableEntityWithNoContainers) { // When no containers are in the way, the function will just return the entityId of the entity that was clicked. - + // Click on Car Entity ClickAtWorldPositionOnViewport(WorldCarEntityPosition); @@ -23,7 +23,7 @@ namespace AzToolsFramework EXPECT_EQ(selectedEntitiesAfter.front(), m_entityMap[CarEntityName]); } - TEST_F(EditorFocusModeSelectionFixture, ContainerEntitySelectionTests_FindHighestSelectableEntityWithClosedContainer) + TEST_F(EditorFocusModeSelectionFixture, ContainerEntitySelectionFindHighestSelectableEntityWithClosedContainer) { // If a closed container is an ancestor of the queried entity, the closed container is selected. m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[StreetEntityName]); // Containers are closed by default @@ -40,7 +40,7 @@ namespace AzToolsFramework m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[StreetEntityName]); } - TEST_F(EditorFocusModeSelectionFixture, ContainerEntitySelectionTests_FindHighestSelectableEntityWithOpenContainer) + TEST_F(EditorFocusModeSelectionFixture, ContainerEntitySelectionFindHighestSelectableEntityWithOpenContainer) { // If a closed container is an ancestor of the queried entity, the closed container is selected. m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[StreetEntityName]); @@ -58,7 +58,7 @@ namespace AzToolsFramework m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[StreetEntityName]); } - TEST_F(EditorFocusModeSelectionFixture, ContainerEntitySelectionTests_FindHighestSelectableEntityWithMultipleClosedContainers) + TEST_F(EditorFocusModeSelectionFixture, ContainerEntitySelectionFindHighestSelectableEntityWithMultipleClosedContainers) { // If multiple closed containers are ancestors of the queried entity, the highest closed container is selected. m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[StreetEntityName]); @@ -77,7 +77,7 @@ namespace AzToolsFramework m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[CityEntityName]); } - TEST_F(EditorFocusModeSelectionFixture, ContainerEntitySelectionTests_FindHighestSelectableEntityWithMultipleContainers) + TEST_F(EditorFocusModeSelectionFixture, ContainerEntitySelectionFindHighestSelectableEntityWithMultipleContainers) { // If multiple containers are ancestors of the queried entity, the highest closed container is selected. m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[StreetEntityName]); @@ -96,4 +96,4 @@ namespace AzToolsFramework m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[StreetEntityName]); m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[CityEntityName]); } -} +} // namespace UnitTest diff --git a/Code/Framework/AzToolsFramework/Tests/FocusMode/ContainerEntityTests.cpp b/Code/Framework/AzToolsFramework/Tests/FocusMode/ContainerEntityTests.cpp index 031062f027..db81f7bb0b 100644 --- a/Code/Framework/AzToolsFramework/Tests/FocusMode/ContainerEntityTests.cpp +++ b/Code/Framework/AzToolsFramework/Tests/FocusMode/ContainerEntityTests.cpp @@ -8,9 +8,9 @@ #include -namespace AzToolsFramework +namespace UnitTest { - TEST_F(EditorFocusModeFixture, ContainerEntityTests_Register) + TEST_F(EditorFocusModeFixture, ContainerEntityRegister) { // Registering an entity is successful. auto outcome = m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[CarEntityName]); @@ -20,7 +20,7 @@ namespace AzToolsFramework m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[CarEntityName]); } - TEST_F(EditorFocusModeFixture, ContainerEntityTests_RegisterTwice) + TEST_F(EditorFocusModeFixture, ContainerEntityRegisterTwice) { // Registering an entity twice fails. m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[CarEntityName]); @@ -31,7 +31,7 @@ namespace AzToolsFramework m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[CarEntityName]); } - TEST_F(EditorFocusModeFixture, ContainerEntityTests_Unregister) + TEST_F(EditorFocusModeFixture, ContainerEntityUnregister) { // Unregistering a container entity is successful. m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[CarEntityName]); @@ -39,21 +39,21 @@ namespace AzToolsFramework EXPECT_TRUE(outcome.IsSuccess()); } - TEST_F(EditorFocusModeFixture, ContainerEntityTests_UnregisterRegularEntity) + TEST_F(EditorFocusModeFixture, ContainerEntityUnregisterRegularEntity) { // Unregistering an entity that was not previously registered fails. auto outcome = m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[CarEntityName]); EXPECT_FALSE(outcome.IsSuccess()); } - TEST_F(EditorFocusModeFixture, ContainerEntityTests_UnregisterTwice) + TEST_F(EditorFocusModeFixture, ContainerEntityUnregisterTwice) { // Unregistering a container entity twice fails. auto outcome = m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[CarEntityName]); EXPECT_FALSE(outcome.IsSuccess()); } - TEST_F(EditorFocusModeFixture, ContainerEntityTests_IsContainerOnRegularEntity) + TEST_F(EditorFocusModeFixture, ContainerEntityIsContainerOnRegularEntity) { // If a regular entity is passed, IsContainer returns false. // Note that we use a different entity than the tests above to validate a completely new EntityId. @@ -61,7 +61,7 @@ namespace AzToolsFramework EXPECT_FALSE(isContainer); } - TEST_F(EditorFocusModeFixture, ContainerEntityTests_IsContainerOnRegisteredContainer) + TEST_F(EditorFocusModeFixture, ContainerEntityIsContainerOnRegisteredContainer) { // If a container entity is passed, IsContainer returns true. m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[SportsCarEntityName]); @@ -72,7 +72,7 @@ namespace AzToolsFramework m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[SportsCarEntityName]); } - TEST_F(EditorFocusModeFixture, ContainerEntityTests_IsContainerOnUnRegisteredContainer) + TEST_F(EditorFocusModeFixture, ContainerEntityIsContainerOnUnRegisteredContainer) { // If an entity that was previously a container but was then unregistered is passed, IsContainer returns false. m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[SportsCarEntityName]); @@ -82,14 +82,14 @@ namespace AzToolsFramework EXPECT_FALSE(isContainer); } - TEST_F(EditorFocusModeFixture, ContainerEntityTests_SetContainerOpenOnRegularEntity) + TEST_F(EditorFocusModeFixture, ContainerEntitySetContainerOpenOnRegularEntity) { // Setting a regular entity to open should return a failure. auto outcome = m_containerEntityInterface->SetContainerOpen(m_entityMap[StreetEntityName], true); EXPECT_FALSE(outcome.IsSuccess()); } - TEST_F(EditorFocusModeFixture, ContainerEntityTests_SetContainerOpen) + TEST_F(EditorFocusModeFixture, ContainerEntitySetContainerOpen) { // Set a container entity to open, and verify the operation was successful. m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[StreetEntityName]); @@ -100,7 +100,7 @@ namespace AzToolsFramework m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[StreetEntityName]); } - TEST_F(EditorFocusModeFixture, ContainerEntityTests_SetContainerOpenTwice) + TEST_F(EditorFocusModeFixture, ContainerEntitySetContainerOpenTwice) { // Set a container entity to open twice, and verify that does not cause a failure (as intended). m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[StreetEntityName]); @@ -112,7 +112,7 @@ namespace AzToolsFramework m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[StreetEntityName]); } - TEST_F(EditorFocusModeFixture, ContainerEntityTests_SetContainerClosed) + TEST_F(EditorFocusModeFixture, ContainerEntitySetContainerClosed) { // Set a container entity to closed, and verify the operation was successful. m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[StreetEntityName]); @@ -122,16 +122,16 @@ namespace AzToolsFramework // Restore default state for other tests. m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[StreetEntityName]); } - - TEST_F(EditorFocusModeFixture, ContainerEntityTests_IsContainerOpenOnRegularEntity) + + TEST_F(EditorFocusModeFixture, ContainerEntityIsContainerOpenOnRegularEntity) { // Query open state on a regular entity, and verify it returns true. // Open containers behave exactly as regular entities, so this is the expected return value. bool isOpen = m_containerEntityInterface->IsContainerOpen(m_entityMap[CityEntityName]); EXPECT_TRUE(isOpen); } - - TEST_F(EditorFocusModeFixture, ContainerEntityTests_IsContainerOpenOnDefaultContainerEntity) + + TEST_F(EditorFocusModeFixture, ContainerEntityIsContainerOpenOnDefaultContainerEntity) { // Query open state on a newly registered container entity, and verify it returns false. // Containers are registered closed by default. @@ -142,8 +142,8 @@ namespace AzToolsFramework // Restore default state for other tests. m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[CityEntityName]); } - - TEST_F(EditorFocusModeFixture, ContainerEntityTests_IsContainerOpenOnOpenContainerEntity) + + TEST_F(EditorFocusModeFixture, ContainerEntityIsContainerOpenOnOpenContainerEntity) { // Query open state on a container entity that was opened, and verify it returns true. m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[CityEntityName]); @@ -154,8 +154,8 @@ namespace AzToolsFramework // Restore default state for other tests. m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[CityEntityName]); } - - TEST_F(EditorFocusModeFixture, ContainerEntityTests_IsContainerOpenOnClosedContainerEntity) + + TEST_F(EditorFocusModeFixture, ContainerEntityIsContainerOpenOnClosedContainerEntity) { // Query open state on a container entity that was opened and then closed, and verify it returns false. m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[CityEntityName]); @@ -167,8 +167,8 @@ namespace AzToolsFramework // Restore default state for other tests. m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[CityEntityName]); } - - TEST_F(EditorFocusModeFixture, ContainerEntityTests_ContainerOpenStateIsPreserved) + + TEST_F(EditorFocusModeFixture, ContainerEntityContainerOpenStateIsPreserved) { // Register an entity as container, open it, then unregister it. // When the entity is registered again, the open state should be preserved. @@ -184,15 +184,15 @@ namespace AzToolsFramework // Restore default state for other tests. m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[CityEntityName]); } - - TEST_F(EditorFocusModeFixture, ContainerEntityTests_ClearSucceeds) + + TEST_F(EditorFocusModeFixture, ContainerEntityClearSucceeds) { // The Clear function works if no container is registered. auto outcome = m_containerEntityInterface->Clear(m_editorEntityContextId); EXPECT_TRUE(outcome.IsSuccess()); } - - TEST_F(EditorFocusModeFixture, ContainerEntityTests_ClearFailsIfContainersAreStillRegistered) + + TEST_F(EditorFocusModeFixture, ContainerEntityClearFailsIfContainersAreStillRegistered) { // The Clear function fails if a container is registered. m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[Passenger1EntityName]); @@ -202,8 +202,8 @@ namespace AzToolsFramework // Restore default state for other tests. m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[Passenger1EntityName]); } - - TEST_F(EditorFocusModeFixture, ContainerEntityTests_ClearSucceedsIfContainersAreUnregistered) + + TEST_F(EditorFocusModeFixture, ContainerEntityClearSucceedsIfContainersAreUnregistered) { // The Clear function fails if a container is registered. m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[Passenger1EntityName]); @@ -212,7 +212,7 @@ namespace AzToolsFramework EXPECT_TRUE(outcome.IsSuccess()); } - TEST_F(EditorFocusModeFixture, ContainerEntityTests_ClearDeletesPreservedOpenStates) + TEST_F(EditorFocusModeFixture, ContainerEntityClearDeletesPreservedOpenStates) { // Register an entity as container, open it, unregister it, then call clear. // When the entity is registered again, the open state should not be preserved. @@ -230,14 +230,14 @@ namespace AzToolsFramework m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[Passenger1EntityName]); } - TEST_F(EditorFocusModeFixture, ContainerEntityTests_FindHighestSelectableEntityWithNoContainers) + TEST_F(EditorFocusModeFixture, ContainerEntityFindHighestSelectableEntityWithNoContainers) { // When no containers are in the way, the function will just return the entityId that was passed to it. AZ::EntityId selectedEntityId = m_containerEntityInterface->FindHighestSelectableEntity(m_entityMap[Passenger2EntityName]); EXPECT_EQ(selectedEntityId, m_entityMap[Passenger2EntityName]); } - TEST_F(EditorFocusModeFixture, ContainerEntityTests_FindHighestSelectableEntityWithClosedContainer) + TEST_F(EditorFocusModeFixture, ContainerEntityFindHighestSelectableEntityWithClosedContainer) { // If a closed container is an ancestor of the queried entity, the closed container is selected. m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[SportsCarEntityName]); // Containers are closed by default @@ -248,7 +248,7 @@ namespace AzToolsFramework m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[SportsCarEntityName]); } - TEST_F(EditorFocusModeFixture, ContainerEntityTests_FindHighestSelectableEntityWithOpenContainer) + TEST_F(EditorFocusModeFixture, ContainerEntityFindHighestSelectableEntityWithOpenContainer) { // If an open container is an ancestor of the queried entity, it is ignored. m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[SportsCarEntityName]); @@ -261,7 +261,7 @@ namespace AzToolsFramework m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[SportsCarEntityName]); } - TEST_F(EditorFocusModeFixture, ContainerEntityTests_FindHighestSelectableEntityWithMultipleClosedContainers) + TEST_F(EditorFocusModeFixture, ContainerEntityFindHighestSelectableEntityWithMultipleClosedContainers) { // If multiple closed containers are ancestors of the queried entity, the highest closed container is selected. m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[StreetEntityName]); @@ -275,7 +275,7 @@ namespace AzToolsFramework m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[SportsCarEntityName]); } - TEST_F(EditorFocusModeFixture, ContainerEntityTests_FindHighestSelectableEntityWithMultipleContainers) + TEST_F(EditorFocusModeFixture, ContainerEntityFindHighestSelectableEntityWithMultipleContainers) { // If multiple containers are ancestors of the queried entity, the highest closed container is selected. m_containerEntityInterface->RegisterEntityAsContainer(m_entityMap[StreetEntityName]); @@ -289,5 +289,4 @@ namespace AzToolsFramework m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[StreetEntityName]); m_containerEntityInterface->UnregisterEntityAsContainer(m_entityMap[SportsCarEntityName]); } - -} +} // namespace UnitTest diff --git a/Code/Framework/AzToolsFramework/Tests/FocusMode/EditorFocusModeFixture.cpp b/Code/Framework/AzToolsFramework/Tests/FocusMode/EditorFocusModeFixture.cpp index 49bf7cee15..90becfa46f 100644 --- a/Code/Framework/AzToolsFramework/Tests/FocusMode/EditorFocusModeFixture.cpp +++ b/Code/Framework/AzToolsFramework/Tests/FocusMode/EditorFocusModeFixture.cpp @@ -12,7 +12,7 @@ #include -namespace AzToolsFramework +namespace UnitTest { void ClearSelectedEntities() { @@ -31,14 +31,14 @@ namespace AzToolsFramework void EditorFocusModeFixture::SetUpEditorFixtureImpl() { // Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is - // shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash + // shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash // in the unit tests. AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize); - m_containerEntityInterface = AZ::Interface::Get(); + m_containerEntityInterface = AZ::Interface::Get(); ASSERT_TRUE(m_containerEntityInterface != nullptr); - m_focusModeInterface = AZ::Interface::Get(); + m_focusModeInterface = AZ::Interface::Get(); ASSERT_TRUE(m_focusModeInterface != nullptr); // register a simple component implementing BoundsRequestBus and EditorComponentSelectionRequestsBus @@ -68,26 +68,26 @@ namespace AzToolsFramework ClearSelectedEntities(); } - void EditorFocusModeFixture::GenerateTestHierarchy() + void EditorFocusModeFixture::GenerateTestHierarchy() { /* - * City - * |_ Street - * |_ Car - * | |_ Passenger - * |_ SportsCar - * |_ Passenger - */ + * City + * |_ Street + * |_ Car + * | |_ Passenger + * |_ SportsCar + * |_ Passenger + */ - m_entityMap[CityEntityName] = CreateEditorEntity(CityEntityName, AZ::EntityId()); - m_entityMap[StreetEntityName] = CreateEditorEntity(StreetEntityName, m_entityMap[CityEntityName]); - m_entityMap[CarEntityName] = CreateEditorEntity(CarEntityName, m_entityMap[StreetEntityName]); - m_entityMap[Passenger1EntityName] = CreateEditorEntity(Passenger1EntityName, m_entityMap[CarEntityName]); - m_entityMap[SportsCarEntityName] = CreateEditorEntity(SportsCarEntityName, m_entityMap[StreetEntityName]); - m_entityMap[Passenger2EntityName] = CreateEditorEntity(Passenger2EntityName, m_entityMap[SportsCarEntityName]); + m_entityMap[CityEntityName] = CreateEditorEntity(CityEntityName, AZ::EntityId()); + m_entityMap[StreetEntityName] = CreateEditorEntity(StreetEntityName, m_entityMap[CityEntityName]); + m_entityMap[CarEntityName] = CreateEditorEntity(CarEntityName, m_entityMap[StreetEntityName]); + m_entityMap[Passenger1EntityName] = CreateEditorEntity(Passenger1EntityName, m_entityMap[CarEntityName]); + m_entityMap[SportsCarEntityName] = CreateEditorEntity(SportsCarEntityName, m_entityMap[StreetEntityName]); + m_entityMap[Passenger2EntityName] = CreateEditorEntity(Passenger2EntityName, m_entityMap[SportsCarEntityName]); // Add a BoundsTestComponent to the Car entity. - AZ::Entity* entity = GetEntityById(m_entityMap[CarEntityName]); + AZ::Entity* entity = AzToolsFramework::GetEntityById(m_entityMap[CarEntityName]); entity->Deactivate(); entity->CreateComponent(); @@ -113,4 +113,4 @@ namespace AzToolsFramework return entity->GetId(); } -} +} // namespace UnitTest diff --git a/Code/Framework/AzToolsFramework/Tests/FocusMode/EditorFocusModeFixture.h b/Code/Framework/AzToolsFramework/Tests/FocusMode/EditorFocusModeFixture.h index c48795a3a4..0cf1be6ffd 100644 --- a/Code/Framework/AzToolsFramework/Tests/FocusMode/EditorFocusModeFixture.h +++ b/Code/Framework/AzToolsFramework/Tests/FocusMode/EditorFocusModeFixture.h @@ -18,10 +18,9 @@ #include #include -namespace AzToolsFramework +namespace UnitTest { - class EditorFocusModeFixture - : public UnitTest::ToolsApplicationFixture + class EditorFocusModeFixture : public ToolsApplicationFixture { protected: void SetUpEditorFixtureImpl() override; @@ -32,8 +31,8 @@ namespace AzToolsFramework AZStd::unordered_map m_entityMap; - ContainerEntityInterface* m_containerEntityInterface = nullptr; - FocusModeInterface* m_focusModeInterface = nullptr; + AzToolsFramework::ContainerEntityInterface* m_containerEntityInterface = nullptr; + AzToolsFramework::FocusModeInterface* m_focusModeInterface = nullptr; public: AzToolsFramework::EntityIdList GetSelectedEntities(); @@ -53,4 +52,4 @@ namespace AzToolsFramework inline static AZ::Vector3 WorldCarEntityPosition = AZ::Vector3(5.0f, 15.0f, 0.0f); }; -} +} // namespace UnitTest diff --git a/Code/Framework/AzToolsFramework/Tests/FocusMode/EditorFocusModeSelectionFixture.h b/Code/Framework/AzToolsFramework/Tests/FocusMode/EditorFocusModeSelectionFixture.h index 4c9369bc46..fe1de9b122 100644 --- a/Code/Framework/AzToolsFramework/Tests/FocusMode/EditorFocusModeSelectionFixture.h +++ b/Code/Framework/AzToolsFramework/Tests/FocusMode/EditorFocusModeSelectionFixture.h @@ -26,11 +26,17 @@ #include #include -namespace AzToolsFramework +namespace UnitTest { - class EditorFocusModeSelectionFixture : public UnitTest::IndirectCallManipulatorViewportInteractionFixtureMixin + class EditorFocusModeSelectionFixture : public IndirectCallManipulatorViewportInteractionFixtureMixin { public: + void SetUpEditorFixtureImpl() override + { + IndirectCallManipulatorViewportInteractionFixtureMixin::SetUpEditorFixtureImpl(); + m_viewportManipulatorInteraction->GetViewportInteraction().SetIconsVisible(false); + } + void ClickAtWorldPositionOnViewport(const AZ::Vector3& worldPosition) { // Calculate the world position in screen space @@ -40,4 +46,4 @@ namespace AzToolsFramework m_actionDispatcher->CameraState(m_cameraState)->MousePosition(carScreenPosition)->MouseLButtonDown()->MouseLButtonUp(); } }; -} // namespace AzToolsFramework +} // namespace UnitTest diff --git a/Code/Framework/AzToolsFramework/Tests/FocusMode/EditorFocusModeSelectionTests.cpp b/Code/Framework/AzToolsFramework/Tests/FocusMode/EditorFocusModeSelectionTests.cpp index 2f746c9d63..1efcb15b30 100644 --- a/Code/Framework/AzToolsFramework/Tests/FocusMode/EditorFocusModeSelectionTests.cpp +++ b/Code/Framework/AzToolsFramework/Tests/FocusMode/EditorFocusModeSelectionTests.cpp @@ -8,9 +8,9 @@ #include -namespace AzToolsFramework +namespace UnitTest { - TEST_F(EditorFocusModeSelectionFixture, EditorFocusModeSelectionTests_SelectEntityWithFocusOnLevel) + TEST_F(EditorFocusModeSelectionFixture, EditorFocusModeSelectionSelectEntityWithFocusOnLevel) { // Click on Car Entity ClickAtWorldPositionOnViewport(WorldCarEntityPosition); @@ -21,7 +21,7 @@ namespace AzToolsFramework EXPECT_EQ(selectedEntitiesAfter.front(), m_entityMap[CarEntityName]); } - TEST_F(EditorFocusModeSelectionFixture, EditorFocusModeSelectionTests_SelectEntityWithFocusOnAncestor) + TEST_F(EditorFocusModeSelectionFixture, EditorFocusModeSelectionSelectEntityWithFocusOnAncestor) { // Set the focus on the Street Entity (parent of the test entity) m_focusModeInterface->SetFocusRoot(m_entityMap[StreetEntityName]); @@ -35,7 +35,7 @@ namespace AzToolsFramework EXPECT_EQ(selectedEntitiesAfter.front(), m_entityMap[CarEntityName]); } - TEST_F(EditorFocusModeSelectionFixture, EditorFocusModeSelectionTests_SelectEntityWithFocusOnItself) + TEST_F(EditorFocusModeSelectionFixture, EditorFocusModeSelectionSelectEntityWithFocusOnItself) { // Set the focus on the Car Entity (test entity) m_focusModeInterface->SetFocusRoot(m_entityMap[CarEntityName]); @@ -49,7 +49,7 @@ namespace AzToolsFramework EXPECT_EQ(selectedEntitiesAfter.front(), m_entityMap[CarEntityName]); } - TEST_F(EditorFocusModeSelectionFixture, EditorFocusModeSelectionTests_SelectEntityWithFocusOnSibling) + TEST_F(EditorFocusModeSelectionFixture, EditorFocusModeSelectionSelectEntityWithFocusOnSibling) { // Set the focus on the SportsCar Entity (sibling of the test entity) m_focusModeInterface->SetFocusRoot(m_entityMap[SportsCarEntityName]); @@ -62,7 +62,7 @@ namespace AzToolsFramework EXPECT_EQ(selectedEntitiesAfter.size(), 0); } - TEST_F(EditorFocusModeSelectionFixture, EditorFocusModeSelectionTests_SelectEntityWithFocusOnDescendant) + TEST_F(EditorFocusModeSelectionFixture, EditorFocusModeSelectionSelectEntityWithFocusOnDescendant) { // Set the focus on the Passenger1 Entity (child of the entity) m_focusModeInterface->SetFocusRoot(m_entityMap[Passenger1EntityName]); @@ -74,4 +74,4 @@ namespace AzToolsFramework auto selectedEntitiesAfter = GetSelectedEntities(); EXPECT_EQ(selectedEntitiesAfter.size(), 0); } -} +} // namespace UnitTest diff --git a/Code/Framework/AzToolsFramework/Tests/FocusMode/EditorFocusModeTests.cpp b/Code/Framework/AzToolsFramework/Tests/FocusMode/EditorFocusModeTests.cpp index eec3902f99..bac60230d6 100644 --- a/Code/Framework/AzToolsFramework/Tests/FocusMode/EditorFocusModeTests.cpp +++ b/Code/Framework/AzToolsFramework/Tests/FocusMode/EditorFocusModeTests.cpp @@ -8,9 +8,9 @@ #include -namespace AzToolsFramework +namespace UnitTest { - TEST_F(EditorFocusModeFixture, EditorFocusModeTests_SetFocus) + TEST_F(EditorFocusModeFixture, SetFocus) { // When an entity is set as the focus root, GetFocusRoot should return its EntityId. m_focusModeInterface->SetFocusRoot(m_entityMap[CarEntityName]); @@ -20,7 +20,7 @@ namespace AzToolsFramework m_focusModeInterface->ClearFocusRoot(m_editorEntityContextId); } - TEST_F(EditorFocusModeFixture, EditorFocusModeTests_ClearFocus) + TEST_F(EditorFocusModeFixture, ClearFocus) { // Change the value from the default. m_focusModeInterface->SetFocusRoot(m_entityMap[CarEntityName]); @@ -30,7 +30,7 @@ namespace AzToolsFramework EXPECT_EQ(m_focusModeInterface->GetFocusRoot(m_editorEntityContextId), AZ::EntityId()); } - TEST_F(EditorFocusModeFixture, EditorFocusModeTests_IsInFocusSubTree_AncestorsDescendants) + TEST_F(EditorFocusModeFixture, IsInFocusSubTreeAncestorsDescendants) { // When the focus is set to an entity, all its descendants are in the focus subtree while the ancestors aren't. m_focusModeInterface->SetFocusRoot(m_entityMap[StreetEntityName]); @@ -43,7 +43,7 @@ namespace AzToolsFramework EXPECT_EQ(m_focusModeInterface->IsInFocusSubTree(m_entityMap[Passenger2EntityName]), true); } - TEST_F(EditorFocusModeFixture, EditorFocusModeTests_IsInFocusSubTree_Siblings) + TEST_F(EditorFocusModeFixture, IsInFocusSubTreeSiblings) { // If the root entity has siblings, they are also outside of the focus subtree. m_focusModeInterface->SetFocusRoot(m_entityMap[CarEntityName]); @@ -56,7 +56,7 @@ namespace AzToolsFramework EXPECT_EQ(m_focusModeInterface->IsInFocusSubTree(m_entityMap[Passenger2EntityName]), false); } - TEST_F(EditorFocusModeFixture, EditorFocusModeTests_IsInFocusSubTree_Leaf) + TEST_F(EditorFocusModeFixture, IsInFocusSubTreeLeaf) { // If the root is a leaf, then the focus subtree will consists of just that entity. m_focusModeInterface->SetFocusRoot(m_entityMap[Passenger2EntityName]); @@ -69,7 +69,7 @@ namespace AzToolsFramework EXPECT_EQ(m_focusModeInterface->IsInFocusSubTree(m_entityMap[Passenger2EntityName]), true); } - TEST_F(EditorFocusModeFixture, EditorFocusModeTests_IsInFocusSubTree_Clear) + TEST_F(EditorFocusModeFixture, IsInFocusSubTreeClear) { // Change the value from the default. m_focusModeInterface->SetFocusRoot(m_entityMap[StreetEntityName]); @@ -84,4 +84,4 @@ namespace AzToolsFramework EXPECT_EQ(m_focusModeInterface->IsInFocusSubTree(m_entityMap[SportsCarEntityName]), true); EXPECT_EQ(m_focusModeInterface->IsInFocusSubTree(m_entityMap[Passenger2EntityName]), true); } -} +} // namespace UnitTest diff --git a/Code/Framework/AzToolsFramework/Tests/SliceStabilityTests/SliceStabilityTestFramework.h b/Code/Framework/AzToolsFramework/Tests/SliceStabilityTests/SliceStabilityTestFramework.h index 01b40fbb16..56f4bb5243 100644 --- a/Code/Framework/AzToolsFramework/Tests/SliceStabilityTests/SliceStabilityTestFramework.h +++ b/Code/Framework/AzToolsFramework/Tests/SliceStabilityTests/SliceStabilityTestFramework.h @@ -137,7 +137,6 @@ namespace UnitTest void CreateEditorRepresentation(AZ::Entity* entity) override; void BrowseForAssets(AzToolsFramework::AssetBrowser::AssetSelectionModel& selection) override { AZ_UNUSED(selection); } int GetIconTextureIdFromEntityIconPath(const AZStd::string& entityIconPath) override { AZ_UNUSED(entityIconPath); return 0; } - bool DisplayHelpersVisible() override { return false; } /* * AssetSystemRequestBus diff --git a/Code/Framework/AzToolsFramework/Tests/UI/EntityPropertyEditorTests.cpp b/Code/Framework/AzToolsFramework/Tests/UI/EntityPropertyEditorTests.cpp index bf3e6e9787..9a96c716fb 100644 --- a/Code/Framework/AzToolsFramework/Tests/UI/EntityPropertyEditorTests.cpp +++ b/Code/Framework/AzToolsFramework/Tests/UI/EntityPropertyEditorTests.cpp @@ -243,7 +243,6 @@ namespace UnitTest // These are required by implementing the EditorRequestBus void BrowseForAssets(AssetBrowser::AssetSelectionModel& /*selection*/) override {} int GetIconTextureIdFromEntityIconPath([[maybe_unused]] const AZStd::string& entityIconPath) override { return 0; } - bool DisplayHelpersVisible() override { return false; } public: EntityPropertyEditor* m_levelEditor; diff --git a/Gems/Atom/Feature/Common/Assets/Passes/UIParent.pass b/Gems/Atom/Feature/Common/Assets/Passes/UIParent.pass index 4ae67b9b09..54491216dd 100644 --- a/Gems/Atom/Feature/Common/Assets/Passes/UIParent.pass +++ b/Gems/Atom/Feature/Common/Assets/Passes/UIParent.pass @@ -41,7 +41,8 @@ "PassData": { "$type": "RasterPassData", "DrawListTag": "2dpass", - "PipelineViewTag": "MainCamera" + "PipelineViewTag": "MainCamera", + "DrawListSortType": "KeyThenReverseDepth" } }, { diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Tests/ViewportInteractionImplTests.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Tests/ViewportInteractionImplTests.cpp index 19c55d7473..3a96d3c07b 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Tests/ViewportInteractionImplTests.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Tests/ViewportInteractionImplTests.cpp @@ -167,7 +167,8 @@ namespace UnitTest const auto ray = m_viewportInteractionImpl->ViewportScreenToWorldRay(ScreenPoint(832, 226)); float unused; - auto intersection = AZ::Intersect::IntersectRaySphere(ray.origin, ray.direction, AZ::Vector3(-14.0f, 5.7f, 0.75f), 0.5f, unused); + auto intersection = + AZ::Intersect::IntersectRaySphere(ray.m_origin, ray.m_direction, AZ::Vector3(-14.0f, 5.7f, 0.75f), 0.5f, unused); EXPECT_EQ(intersection, AZ::Intersect::SphereIsectTypes::ISECT_RAY_SPHERE_ISECT); } diff --git a/Gems/AtomLyIntegration/AtomViewportDisplayIcons/Code/Source/AtomViewportDisplayIconsSystemComponent.cpp b/Gems/AtomLyIntegration/AtomViewportDisplayIcons/Code/Source/AtomViewportDisplayIconsSystemComponent.cpp index fa7a0cf2bf..b96fdc9f1d 100644 --- a/Gems/AtomLyIntegration/AtomViewportDisplayIcons/Code/Source/AtomViewportDisplayIconsSystemComponent.cpp +++ b/Gems/AtomLyIntegration/AtomViewportDisplayIcons/Code/Source/AtomViewportDisplayIconsSystemComponent.cpp @@ -8,6 +8,7 @@ #include "AtomViewportDisplayIconsSystemComponent.h" +#include #include #include #include @@ -117,8 +118,7 @@ namespace AZ::Render return; } - auto perViewportDynamicDrawInterface = - AtomBridge::PerViewportDynamicDraw::Get(); + auto perViewportDynamicDrawInterface = AtomBridge::PerViewportDynamicDraw::Get(); if (!perViewportDynamicDrawInterface) { return; @@ -131,7 +131,7 @@ namespace AZ::Render return; } - // Find our icon, falling back on a grey placeholder if its image is unavailable + // Find our icon, falling back on a gray placeholder if its image is unavailable AZ::Data::Instance image = AZ::RPI::ImageSystemInterface::Get()->GetSystemImage(AZ::RPI::SystemImage::Grey); if (auto iconIt = m_iconData.find(drawParameters.m_icon); iconIt != m_iconData.end()) { @@ -172,13 +172,16 @@ namespace AZ::Render } else if (drawParameters.m_positionSpace == CoordinateSpace::WorldSpace) { + // Calculate the ndc point (0.0-1.0 range) including depth + const AZ::Vector3 ndcPoint = AzFramework::WorldToScreenNdc( + drawParameters.m_position, viewportContext->GetCameraViewMatrixAsMatrix3x4(), + viewportContext->GetCameraProjectionMatrix()); + // Calculate our screen space position using the viewport size // We want this instead of RenderViewportWidget::WorldToScreen which works in QWidget virtual coordinate space - const AzFramework::ScreenPoint position = AzFramework::WorldToScreen( - drawParameters.m_position, viewportContext->GetCameraViewMatrixAsMatrix3x4(), - viewportContext->GetCameraProjectionMatrix(), viewportSize); - screenPosition.SetX(aznumeric_cast(position.m_x)); - screenPosition.SetY(aznumeric_cast(position.m_y)); + const AzFramework::ScreenPoint screenPoint = AzFramework::ScreenPointFromNdc(AZ::Vector3ToVector2(ndcPoint), viewportSize); + + screenPosition = AzFramework::Vector3FromScreenPoint(screenPoint, ndcPoint.GetZ()); } struct Vertex @@ -210,7 +213,12 @@ namespace AZ::Render createVertex(-0.5f, 0.5f, 0.f, 1.f) }; AZStd::array indices = {0, 1, 2, 0, 2, 3}; - dynamicDraw->DrawIndexed(&vertices, static_cast(vertices.size()), &indices, static_cast(indices.size()), RHI::IndexFormat::Uint16, drawSrg); + + dynamicDraw->SetSortKey( + aznumeric_cast(screenPosition.GetZ() * aznumeric_cast(AZStd::numeric_limits::max()))); + dynamicDraw->DrawIndexed( + &vertices, static_cast(vertices.size()), &indices, static_cast(indices.size()), RHI::IndexFormat::Uint16, + drawSrg); } QString AtomViewportDisplayIconsSystemComponent::FindAssetPath(const QString& path) const @@ -354,7 +362,7 @@ namespace AZ::Render { // Once the shader is loaded, register it with the dynamic draw context Data::Asset shaderAsset = asset; - AtomBridge::PerViewportDynamicDraw::Get()->RegisterDynamicDrawContext(m_drawContextName, [shaderAsset](RPI::Ptr drawContext) + AtomBridge::PerViewportDynamicDraw::Get()->RegisterDynamicDrawContext(m_drawContextName, [shaderAsset](RPI::Ptr dynamicDraw) { AZ_Assert(shaderAsset->IsReady(), "Attempting to register the AtomViewportDisplayIconsSystemComponent" " dynamic draw context before the shader asset is loaded. The shader should be loaded first" @@ -362,12 +370,11 @@ namespace AZ::Render " will be executed during scene processing and there may be multiple scenes executing in parallel."); Data::Instance shader = RPI::Shader::FindOrCreate(shaderAsset); - drawContext->InitShader(shader); - drawContext->InitVertexFormat( - { {"POSITION", RHI::Format::R32G32B32_FLOAT}, - {"COLOR", RHI::Format::R8G8B8A8_UNORM}, - {"TEXCOORD", RHI::Format::R32G32_FLOAT} }); - drawContext->EndInit(); + dynamicDraw->InitShader(shader); + dynamicDraw->InitVertexFormat({ { "POSITION", RHI::Format::R32G32B32_FLOAT }, + { "COLOR", RHI::Format::R8G8B8A8_UNORM }, + { "TEXCOORD", RHI::Format::R32G32_FLOAT } }); + dynamicDraw->EndInit(); }); m_drawContextRegistered = true; diff --git a/Gems/PhysX/Code/Editor/DebugDraw.cpp b/Gems/PhysX/Code/Editor/DebugDraw.cpp index a54230ec38..0af5822edf 100644 --- a/Gems/PhysX/Code/Editor/DebugDraw.cpp +++ b/Gems/PhysX/Code/Editor/DebugDraw.cpp @@ -56,9 +56,9 @@ namespace PhysX bool IsDrawColliderReadOnly() { bool helpersVisible = false; - AzToolsFramework::EditorRequestBus::BroadcastResult(helpersVisible, - &AzToolsFramework::EditorRequests::DisplayHelpersVisible); - // if helpers are visible, draw colliders is NOT read only and can be changed. + AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::BroadcastResult( + helpersVisible, &AzToolsFramework::ViewportInteraction::ViewportSettingsRequestBus::Events::HelpersVisible); + // if helpers are visible, draw colliders is not read only and can be changed return !helpersVisible; } diff --git a/Gems/WhiteBox/Code/Source/EditorWhiteBoxComponent.cpp b/Gems/WhiteBox/Code/Source/EditorWhiteBoxComponent.cpp index 5c6fa73bb2..c29305e1f4 100644 --- a/Gems/WhiteBox/Code/Source/EditorWhiteBoxComponent.cpp +++ b/Gems/WhiteBox/Code/Source/EditorWhiteBoxComponent.cpp @@ -720,7 +720,6 @@ namespace WhiteBox // must have at least one triangle if (m_faces->empty()) { - distance = std::numeric_limits::max(); return false; } @@ -735,7 +734,6 @@ namespace WhiteBox const AZ::Vector3 localRayEnd = localRayOrigin + localRayDirection * rayLength; bool intersection = false; - distance = std::numeric_limits::max(); for (const auto& face : m_faces.value()) { float t; From 01770a1574819625c2ed406d2954ce83744d6272 Mon Sep 17 00:00:00 2001 From: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> Date: Thu, 16 Dec 2021 09:35:39 +0000 Subject: [PATCH 62/70] Fixes for `CameraInput` handling (#6425) * add temporary optimize off calls Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * fix + tests for camera input issue Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * simplify boolean expression (PR feedback) Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> --- .../AzFramework/Viewport/CameraInput.cpp | 40 ++++++---- .../AzFramework/Viewport/CameraInput.h | 5 ++ .../AzFramework/Tests/CameraInputTests.cpp | 74 +++++++++++++++++++ 3 files changed, 105 insertions(+), 14 deletions(-) diff --git a/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp b/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp index 856d40e57d..cd33f60b91 100644 --- a/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp +++ b/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp @@ -213,27 +213,33 @@ namespace AzFramework Camera Cameras::StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, const float scrollDelta, const float deltaTime) { - for (int i = 0; i < m_idleCameraInputs.size();) + for (int idleIndex = 0; idleIndex < m_idleCameraInputs.size();) { - auto& cameraInput = m_idleCameraInputs[i]; + auto& cameraInput = m_idleCameraInputs[idleIndex]; const bool canBegin = cameraInput->Beginning() && AZStd::all_of(m_activeCameraInputs.cbegin(), m_activeCameraInputs.cend(), [](const auto& input) { return !input->Exclusive(); }) && - (!cameraInput->Exclusive() || (cameraInput->Exclusive() && m_activeCameraInputs.empty())); + (!cameraInput->Exclusive() || m_activeCameraInputs.empty()); if (canBegin) { m_activeCameraInputs.push_back(cameraInput); using AZStd::swap; - swap(m_idleCameraInputs[i], m_idleCameraInputs[m_idleCameraInputs.size() - 1]); + swap(m_idleCameraInputs[idleIndex], m_idleCameraInputs[m_idleCameraInputs.size() - 1]); m_idleCameraInputs.pop_back(); } else { - i++; + // if a camera attempted to start but was not allowed to, ensure activation is cancelled + if (!cameraInput->Idle()) + { + cameraInput->CancelActivation(); + } + + idleIndex++; } } @@ -245,21 +251,21 @@ namespace AzFramework return acc; }); - for (int i = 0; i < m_activeCameraInputs.size();) + for (int activeIndex = 0; activeIndex < m_activeCameraInputs.size();) { - auto& cameraInput = m_activeCameraInputs[i]; + auto& cameraInput = m_activeCameraInputs[activeIndex]; if (cameraInput->Ending()) { cameraInput->ClearActivation(); m_idleCameraInputs.push_back(cameraInput); using AZStd::swap; - swap(m_activeCameraInputs[i], m_activeCameraInputs[m_activeCameraInputs.size() - 1]); + swap(m_activeCameraInputs[activeIndex], m_activeCameraInputs[m_activeCameraInputs.size() - 1]); m_activeCameraInputs.pop_back(); } else { cameraInput->ContinueActivation(); - i++; + activeIndex++; } } @@ -470,9 +476,10 @@ namespace AzFramework { if (input->m_state == InputChannel::State::Began) { - m_translation |= TranslationFromKey(input->m_channelId, m_translateCameraInputChannelIds); - if (m_translation != TranslationType::Nil) + if (auto translation = TranslationFromKey(input->m_channelId, m_translateCameraInputChannelIds); + translation != TranslationType::Nil) { + m_translation |= translation; BeginActivation(); } @@ -484,11 +491,16 @@ namespace AzFramework // ensure we don't process end events in the idle state else if (input->m_state == InputChannel::State::Ended && !Idle()) { - m_translation &= ~(TranslationFromKey(input->m_channelId, m_translateCameraInputChannelIds)); - if (m_translation == TranslationType::Nil) + if (auto translation = TranslationFromKey(input->m_channelId, m_translateCameraInputChannelIds); + translation != TranslationType::Nil) { - EndActivation(); + m_translation &= ~translation; + if (m_translation == TranslationType::Nil) + { + EndActivation(); + } } + if (input->m_channelId == m_translateCameraInputChannelIds.m_boostChannelId) { m_boost = false; diff --git a/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.h b/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.h index 96a9b54dc8..b652d616b2 100644 --- a/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.h +++ b/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.h @@ -185,6 +185,11 @@ namespace AzFramework m_activation = Activation::Ending; } + void CancelActivation() + { + m_activation = Activation::Idle; + } + void ContinueActivation() { // continue activation is called after the first step of the camera input, diff --git a/Code/Framework/AzFramework/Tests/CameraInputTests.cpp b/Code/Framework/AzFramework/Tests/CameraInputTests.cpp index 5f327fb2fd..0ddf9e89b9 100644 --- a/Code/Framework/AzFramework/Tests/CameraInputTests.cpp +++ b/Code/Framework/AzFramework/Tests/CameraInputTests.cpp @@ -416,4 +416,78 @@ namespace UnitTest using ::testing::FloatNear; EXPECT_THAT(m_camera.m_pitch, FloatNear(expectedPitch, 0.001f)); } + + TEST_F(CameraInputFixture, InvalidTranslationInputKeyCannotBeginTranslateCameraInputAgain) + { + HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_translateCameraInputChannelIds.m_forwardChannelId, + AzFramework::InputChannel::State::Began }); + + const bool consumed = + m_cameraSystem->HandleEvents(AzFramework::DiscreteInputEvent{ m_orbitChannelId, AzFramework::InputChannel::State::Began }); + + using ::testing::IsFalse; + using ::testing::IsTrue; + EXPECT_THAT(consumed, IsTrue()); + EXPECT_THAT(m_firstPersonTranslateCamera->Beginning(), IsFalse()); + EXPECT_THAT(m_firstPersonTranslateCamera->Active(), IsTrue()); + } + + TEST_F(CameraInputFixture, InvalidTranslationInputKeyDownCannotBeginTranslateCameraInputAgain) + { + HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_translateCameraInputChannelIds.m_forwardChannelId, + AzFramework::InputChannel::State::Began }); + + const bool consumed = + m_cameraSystem->HandleEvents(AzFramework::DiscreteInputEvent{ m_orbitChannelId, AzFramework::InputChannel::State::Began }); + + using ::testing::IsFalse; + using ::testing::IsTrue; + EXPECT_THAT(consumed, IsTrue()); + EXPECT_THAT(m_firstPersonTranslateCamera->Beginning(), IsFalse()); + EXPECT_THAT(m_firstPersonTranslateCamera->Active(), IsTrue()); + } + + TEST_F(CameraInputFixture, InvalidTranslationInputKeyUpDoesNotAffectTranslateCameraInputEnd) + { + HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_translateCameraInputChannelIds.m_forwardChannelId, + AzFramework::InputChannel::State::Began }); + + const bool consumed = + m_cameraSystem->HandleEvents(AzFramework::DiscreteInputEvent{ m_orbitChannelId, AzFramework::InputChannel::State::Began }); + + HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_translateCameraInputChannelIds.m_forwardChannelId, + AzFramework::InputChannel::State::Ended }); + + using ::testing::IsFalse; + using ::testing::IsTrue; + EXPECT_THAT(consumed, IsTrue()); + EXPECT_THAT(m_firstPersonTranslateCamera->Idle(), IsTrue()); + } + + TEST_F(CameraInputFixture, OrbitCameraInputCannotBeLeftInInvalidStateIfItCannotFullyBeginAfterInputChannelBegin) + { + HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_translateCameraInputChannelIds.m_forwardChannelId, + AzFramework::InputChannel::State::Began }); + + HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_orbitChannelId, AzFramework::InputChannel::State::Began }); + + using ::testing::IsFalse; + using ::testing::IsTrue; + EXPECT_THAT(m_orbitCamera->Beginning(), IsFalse()); + EXPECT_THAT(m_orbitCamera->Idle(), IsTrue()); + } + + TEST_F(CameraInputFixture, OrbitCameraInputCannotBeLeftInInvalidStateIfItCannotFullyBeginAfterInputChannelBeginAndEnd) + { + HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_translateCameraInputChannelIds.m_forwardChannelId, + AzFramework::InputChannel::State::Began }); + + HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_orbitChannelId, AzFramework::InputChannel::State::Began }); + HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_orbitChannelId, AzFramework::InputChannel::State::Ended }); + + using ::testing::IsFalse; + using ::testing::IsTrue; + EXPECT_THAT(m_orbitCamera->Ending(), IsFalse()); + EXPECT_THAT(m_orbitCamera->Idle(), IsTrue()); + } } // namespace UnitTest From f4ae3a5b7d74614b3a035439574a9306cd537ed5 Mon Sep 17 00:00:00 2001 From: tjmgd <92784061+tjmgd@users.noreply.github.com> Date: Thu, 16 Dec 2021 15:39:03 +0000 Subject: [PATCH 63/70] Fix: Find function reports code with a line offset of 1 (#6331) Signed-off-by: T.J. McGrath-Daly --- Code/Tools/LuaIDE/Source/LUA/LUAEditorFindDialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Code/Tools/LuaIDE/Source/LUA/LUAEditorFindDialog.cpp b/Code/Tools/LuaIDE/Source/LUA/LUAEditorFindDialog.cpp index c775ddc0ba..c426566c5f 100644 --- a/Code/Tools/LuaIDE/Source/LUA/LUAEditorFindDialog.cpp +++ b/Code/Tools/LuaIDE/Source/LUA/LUAEditorFindDialog.cpp @@ -610,7 +610,7 @@ namespace LUAEditor { m_resultList[qAssetName].m_assetId = docInfo.m_assetId; } - entry.m_lineNumber = line; + entry.m_lineNumber = line + 1; entry.m_lineText = entry.m_lineText.trimmed(); while (index > -1) From 18cfcd659b5b65e20249b1097464362c1c003875 Mon Sep 17 00:00:00 2001 From: amzn-mike <80125227+amzn-mike@users.noreply.github.com> Date: Thu, 16 Dec 2021 09:49:32 -0600 Subject: [PATCH 64/70] Fix missing parent class reflection for ProceduralPrefabSystemComponent (#6413) Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com> --- .../AzToolsFramework/Prefab/ProceduralPrefabSystemComponent.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/ProceduralPrefabSystemComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/ProceduralPrefabSystemComponent.cpp index 8eeee4b28f..4a8e140e73 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/ProceduralPrefabSystemComponent.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/ProceduralPrefabSystemComponent.cpp @@ -24,7 +24,7 @@ namespace AzToolsFramework { if (auto serializationContext = azrtti_cast(context)) { - serializationContext->Class(); + serializationContext->Class(); } } From 2bc381811d0a5d5fd508d7c4443371e8a04f8f36 Mon Sep 17 00:00:00 2001 From: antonmic <56370189+antonmic@users.noreply.github.com> Date: Thu, 16 Dec 2021 10:42:53 -0800 Subject: [PATCH 65/70] addressed PR feedback Signed-off-by: antonmic <56370189+antonmic@users.noreply.github.com> --- .../Feature/Common/Assets/Passes/PassTemplates.azasset | 4 ++-- .../Common/Assets/Passes/{Clear.pass => SlowClear.pass} | 6 +++++- .../Common/Assets/atom_feature_common_asset_files.cmake | 2 +- .../RPI/Code/Include/Atom/RPI.Public/Pass/ClearPass.h | 4 +++- .../RPI/Code/Include/Atom/RPI.Public/Pass/ParentPass.h | 9 +++++++++ Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp | 2 +- 6 files changed, 21 insertions(+), 6 deletions(-) rename Gems/Atom/Feature/Common/Assets/Passes/{Clear.pass => SlowClear.pass} (79%) diff --git a/Gems/Atom/Feature/Common/Assets/Passes/PassTemplates.azasset b/Gems/Atom/Feature/Common/Assets/Passes/PassTemplates.azasset index b16536b276..96cf769690 100644 --- a/Gems/Atom/Feature/Common/Assets/Passes/PassTemplates.azasset +++ b/Gems/Atom/Feature/Common/Assets/Passes/PassTemplates.azasset @@ -65,8 +65,8 @@ "Path": "Passes/CascadedShadowmaps.pass" }, { - "Name": "ClearPassTemplate", - "Path": "Passes/Clear.pass" + "Name": "SlowClearPassTemplate", + "Path": "Passes/SlowClear.pass" }, { "Name": "FullscreenCopyTemplate", diff --git a/Gems/Atom/Feature/Common/Assets/Passes/Clear.pass b/Gems/Atom/Feature/Common/Assets/Passes/SlowClear.pass similarity index 79% rename from Gems/Atom/Feature/Common/Assets/Passes/Clear.pass rename to Gems/Atom/Feature/Common/Assets/Passes/SlowClear.pass index a36c2ef03d..417cf94eac 100644 --- a/Gems/Atom/Feature/Common/Assets/Passes/Clear.pass +++ b/Gems/Atom/Feature/Common/Assets/Passes/SlowClear.pass @@ -4,7 +4,11 @@ "ClassName": "PassAsset", "ClassData": { "PassTemplate": { - "Name": "ClearPassTemplate", + + // This is for debug purposes and edge cases only + // If you want to clear an attachment you should + // use the LoadStoreAction on your pass slot. + "Name": "SlowClearPassTemplate", "PassClass": "ClearPass", "Slots": [ { diff --git a/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake b/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake index a684b4b299..a03058e2bf 100644 --- a/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake +++ b/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake @@ -86,7 +86,6 @@ set(FILES Passes/CascadedShadowmaps.pass Passes/CheckerboardResolveColor.pass Passes/CheckerboardResolveDepth.pass - Passes/Clear.pass Passes/ContrastAdaptiveSharpening.pass Passes/ConvertToAcescg.pass Passes/DebugOverlayParent.pass @@ -201,6 +200,7 @@ set(FILES Passes/Skinning.pass Passes/SkyBox.pass Passes/SkyBox_TwoOutputs.pass + Passes/SlowClear.pass Passes/SMAA1xApplyLinearHDRColor.pass Passes/SMAA1xApplyPerceptualColor.pass Passes/SMAABlendingWeightCalculation.pass diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ClearPass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ClearPass.h index 3599e6de44..96252ca82c 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ClearPass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ClearPass.h @@ -14,7 +14,9 @@ namespace AZ { namespace RPI { - //! A simple pass to clear a render target + //! Only use this for debug purposes and edge cases + //! The correct and efficient way to clear a pass is through the LoadStoreAction on the pass slot + //! This will clear a given image attachment to the specified clear value. class ClearPass : public RenderPass { diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ParentPass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ParentPass.h index 6ee0b43ce5..00b7a76f77 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ParentPass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ParentPass.h @@ -133,6 +133,15 @@ namespace AZ void CreatePassesFromTemplate(); // Generates child clear passes to clear input and input/output attachments + // TODO: These two functions are a workaround for a complicated edge case: + // Let Parent Pass P1 have two children, C1 and C2. C1 writes to an attachment that C2 reads, + // but C1 can be disabled, in which case we just want C2 to read the cleared texture. + // Because of this, the attachment is owned by the parent pass, that way it is always available for C2 + // to read even when C1 is disabled. However we still want to clear the attachment before C2 reads it. + // We tried overriding the LoadStoreAction to clear on C2's slot when C1 is disabled, but the RHI + // doesn't allow for clears on Input only slots. Changing the slot to InputOutput was in conflict with + // the texture definition in the SRG, and it couldn't be changed to RW because it was an MSAA texture. + // So now we detect clear actions on parent slots and generate a clear pass for them. void CreateClearPassFromBinding(PassAttachmentBinding& binding, PassRequest& clearRequest); void CreateClearPassesFromBindings(); }; diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp index f0154b371a..fff6fae0a3 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp @@ -247,7 +247,7 @@ namespace AZ void ParentPass::CreateClearPassesFromBindings() { PassRequest clearRequest; - clearRequest.m_templateName = Name("ClearPassTemplate"); + clearRequest.m_templateName = Name("SlowClearPassTemplate"); clearRequest.m_passData = AZStd::make_shared(); clearRequest.m_connections.push_back(); clearRequest.m_connections[0].m_localSlot = Name("ClearInputOutput"); From 53cf7b462bf58385d39cf4714642e1c4e33b6761 Mon Sep 17 00:00:00 2001 From: antonmic <56370189+antonmic@users.noreply.github.com> Date: Thu, 16 Dec 2021 11:03:20 -0800 Subject: [PATCH 66/70] Changing all ClearPass to SlowClearPass Signed-off-by: antonmic <56370189+antonmic@users.noreply.github.com> --- .../Feature/Common/Assets/Passes/SlowClear.pass | 2 +- .../Pass/{ClearPass.h => SlowClearPass.h} | 16 ++++++++-------- .../{ClearPassData.h => SlowClearPassData.h} | 16 ++++++++-------- .../Code/Source/RPI.Public/Pass/ParentPass.cpp | 8 ++++---- .../Code/Source/RPI.Public/Pass/PassFactory.cpp | 4 ++-- .../Code/Source/RPI.Public/Pass/PassSystem.cpp | 4 ++-- .../Pass/{ClearPass.cpp => SlowClearPass.cpp} | 16 ++++++++-------- Gems/Atom/RPI/Code/atom_rpi_public_files.cmake | 4 ++-- Gems/Atom/RPI/Code/atom_rpi_reflect_files.cmake | 2 +- 9 files changed, 36 insertions(+), 36 deletions(-) rename Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/{ClearPass.h => SlowClearPass.h} (65%) rename Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Pass/{ClearPassData.h => SlowClearPassData.h} (58%) rename Gems/Atom/RPI/Code/Source/RPI.Public/Pass/{ClearPass.cpp => SlowClearPass.cpp} (59%) diff --git a/Gems/Atom/Feature/Common/Assets/Passes/SlowClear.pass b/Gems/Atom/Feature/Common/Assets/Passes/SlowClear.pass index 417cf94eac..97b486191a 100644 --- a/Gems/Atom/Feature/Common/Assets/Passes/SlowClear.pass +++ b/Gems/Atom/Feature/Common/Assets/Passes/SlowClear.pass @@ -9,7 +9,7 @@ // If you want to clear an attachment you should // use the LoadStoreAction on your pass slot. "Name": "SlowClearPassTemplate", - "PassClass": "ClearPass", + "PassClass": "SlowClearPass", "Slots": [ { "Name": "ClearInputOutput", diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ClearPass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/SlowClearPass.h similarity index 65% rename from Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ClearPass.h rename to Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/SlowClearPass.h index 96252ca82c..6fcb7abd17 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ClearPass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/SlowClearPass.h @@ -17,21 +17,21 @@ namespace AZ //! Only use this for debug purposes and edge cases //! The correct and efficient way to clear a pass is through the LoadStoreAction on the pass slot //! This will clear a given image attachment to the specified clear value. - class ClearPass + class SlowClearPass : public RenderPass { - AZ_RPI_PASS(ClearPass); + AZ_RPI_PASS(SlowClearPass); public: - AZ_RTTI(ClearPass, "{31CBAD6C-108F-4F3F-B498-ED968DFCFCE2}", RenderPass); - AZ_CLASS_ALLOCATOR(ClearPass, SystemAllocator, 0); - virtual ~ClearPass() = default; + AZ_RTTI(SlowClearPass, "{31CBAD6C-108F-4F3F-B498-ED968DFCFCE2}", RenderPass); + AZ_CLASS_ALLOCATOR(SlowClearPass, SystemAllocator, 0); + virtual ~SlowClearPass() = default; - //! Creates a ClearPass - static Ptr Create(const PassDescriptor& descriptor); + //! Creates a SlowClearPass + static Ptr Create(const PassDescriptor& descriptor); protected: - ClearPass(const PassDescriptor& descriptor); + SlowClearPass(const PassDescriptor& descriptor); void InitializeInternal() override; private: diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Pass/ClearPassData.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Pass/SlowClearPassData.h similarity index 58% rename from Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Pass/ClearPassData.h rename to Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Pass/SlowClearPassData.h index 9c03f5ccd6..7607bca285 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Pass/ClearPassData.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Pass/SlowClearPassData.h @@ -14,23 +14,23 @@ namespace AZ { namespace RPI { - //! Custom data for the ClearPass. Should be specified in the PassRequest. - struct ClearPassData + //! Custom data for the SlowClearPass. Should be specified in the PassRequest. + struct SlowClearPassData : public RenderPassData { - AZ_RTTI(ClearPassData, "{5F2C24A4-62D0-4E60-91EC-C207C10D15C6}", RenderPassData); - AZ_CLASS_ALLOCATOR(ClearPassData, SystemAllocator, 0); + AZ_RTTI(SlowClearPassData, "{5F2C24A4-62D0-4E60-91EC-C207C10D15C6}", RenderPassData); + AZ_CLASS_ALLOCATOR(SlowClearPassData, SystemAllocator, 0); - ClearPassData() = default; - virtual ~ClearPassData() = default; + SlowClearPassData() = default; + virtual ~SlowClearPassData() = default; static void Reflect(ReflectContext* context) { if (auto* serializeContext = azrtti_cast(context)) { - serializeContext->Class() + serializeContext->Class() ->Version(0) - ->Field("ClearValue", &ClearPassData::m_clearValue) + ->Field("ClearValue", &SlowClearPassData::m_clearValue) ; } } diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp index fff6fae0a3..55f3e44173 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp @@ -9,14 +9,14 @@ #include #include -#include +#include #include #include #include #include #include -#include +#include #include #include @@ -231,7 +231,7 @@ namespace AZ clearRequest.m_connections[0].m_attachmentRef.m_attachment = binding.m_name; // Set the pass clear value to the clear value of the attachment binding - ClearPassData* clearData = static_cast(clearRequest.m_passData.get()); + SlowClearPassData* clearData = static_cast(clearRequest.m_passData.get()); clearData->m_clearValue = binding.m_unifiedScopeDesc.m_loadStoreAction.m_clearValue; // Create and add the pass @@ -248,7 +248,7 @@ namespace AZ { PassRequest clearRequest; clearRequest.m_templateName = Name("SlowClearPassTemplate"); - clearRequest.m_passData = AZStd::make_shared(); + clearRequest.m_passData = AZStd::make_shared(); clearRequest.m_connections.push_back(); clearRequest.m_connections[0].m_localSlot = Name("ClearInputOutput"); clearRequest.m_connections[0].m_attachmentRef.m_pass = Name("Parent"); diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassFactory.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassFactory.cpp index 7443c51bff..cc79df144d 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassFactory.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassFactory.cpp @@ -8,7 +8,6 @@ #include -#include #include #include #include @@ -20,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -61,7 +61,7 @@ namespace AZ { AddPassCreator(Name("ParentPass"), &ParentPass::Create); AddPassCreator(Name("RasterPass"), &RasterPass::Create); - AddPassCreator(Name("ClearPass"), &ClearPass::Create); + AddPassCreator(Name("SlowClearPass"), &SlowClearPass::Create); AddPassCreator(Name("CopyPass"), &CopyPass::Create); AddPassCreator(Name("FullScreenTriangle"), &FullscreenTrianglePass::Create); AddPassCreator(Name("ComputePass"), &ComputePass::Create); diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp index f45d28518f..9e1333b7ab 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp @@ -28,7 +28,6 @@ #include #include -#include #include #include #include @@ -40,6 +39,7 @@ #include #include #include +#include namespace AZ { @@ -68,7 +68,7 @@ namespace AZ PassSlot::Reflect(context); PassData::Reflect(context); - ClearPassData::Reflect(context); + SlowClearPassData::Reflect(context); CopyPassData::Reflect(context); RenderPassData::Reflect(context); ComputePassData::Reflect(context); diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ClearPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/SlowClearPass.cpp similarity index 59% rename from Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ClearPass.cpp rename to Gems/Atom/RPI/Code/Source/RPI.Public/Pass/SlowClearPass.cpp index 0e3ea76728..62a8241242 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ClearPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/SlowClearPass.cpp @@ -6,37 +6,37 @@ * */ -#include +#include #include -#include +#include namespace AZ { namespace RPI { - Ptr ClearPass::Create(const PassDescriptor& descriptor) + Ptr SlowClearPass::Create(const PassDescriptor& descriptor) { - Ptr pass = aznew ClearPass(descriptor); + Ptr pass = aznew SlowClearPass(descriptor); return pass; } - ClearPass::ClearPass(const PassDescriptor& descriptor) + SlowClearPass::SlowClearPass(const PassDescriptor& descriptor) : RenderPass(descriptor) { - const ClearPassData* passData = PassUtils::GetPassData(descriptor); + const SlowClearPassData* passData = PassUtils::GetPassData(descriptor); if (passData != nullptr) { m_clearValue = passData->m_clearValue; } } - void ClearPass::InitializeInternal() + void SlowClearPass::InitializeInternal() { RenderPass::InitializeInternal(); // Set clear value - AZ_Assert(GetInputOutputCount() > 0, "ClearPass: Missing InputOutput binding!"); + AZ_Assert(GetInputOutputCount() > 0, "SlowClearPass: Missing InputOutput binding!"); RPI::PassAttachmentBinding& binding = GetInputOutputBinding(0); binding.m_unifiedScopeDesc.m_loadStoreAction.m_clearValue = m_clearValue; } diff --git a/Gems/Atom/RPI/Code/atom_rpi_public_files.cmake b/Gems/Atom/RPI/Code/atom_rpi_public_files.cmake index 91dcf479e9..36df56cdab 100644 --- a/Gems/Atom/RPI/Code/atom_rpi_public_files.cmake +++ b/Gems/Atom/RPI/Code/atom_rpi_public_files.cmake @@ -57,7 +57,6 @@ set(FILES Include/Atom/RPI.Public/Model/ModelSystem.h Include/Atom/RPI.Public/Model/UvStreamTangentBitmask.h Include/Atom/RPI.Public/Pass/AttachmentReadback.h - Include/Atom/RPI.Public/Pass/ClearPass.h Include/Atom/RPI.Public/Pass/ComputePass.h Include/Atom/RPI.Public/Pass/CopyPass.h Include/Atom/RPI.Public/Pass/FullscreenTrianglePass.h @@ -74,6 +73,7 @@ set(FILES Include/Atom/RPI.Public/Pass/RasterPass.h Include/Atom/RPI.Public/Pass/RenderPass.h Include/Atom/RPI.Public/Pass/MSAAResolvePass.h + Include/Atom/RPI.Public/Pass/SlowClearPass.h Include/Atom/RPI.Public/Pass/Specific/DownsampleMipChainPass.h Include/Atom/RPI.Public/Pass/Specific/ImageAttachmentPreviewPass.h Include/Atom/RPI.Public/Pass/Specific/EnvironmentCubeMapPass.h @@ -136,7 +136,6 @@ set(FILES Source/RPI.Public/Model/ModelSystem.cpp Source/RPI.Public/Model/UvStreamTangentBitmask.cpp Source/RPI.Public/Pass/AttachmentReadback.cpp - Source/RPI.Public/Pass/ClearPass.cpp Source/RPI.Public/Pass/ComputePass.cpp Source/RPI.Public/Pass/CopyPass.cpp Source/RPI.Public/Pass/FullscreenTrianglePass.cpp @@ -151,6 +150,7 @@ set(FILES Source/RPI.Public/Pass/RasterPass.cpp Source/RPI.Public/Pass/RenderPass.cpp Source/RPI.Public/Pass/MSAAResolvePass.cpp + Source/RPI.Public/Pass/SlowClearPass.cpp Source/RPI.Public/Pass/Specific/DownsampleMipChainPass.cpp Source/RPI.Public/Pass/Specific/ImageAttachmentPreviewPass.cpp Source/RPI.Public/Pass/Specific/EnvironmentCubeMapPass.cpp diff --git a/Gems/Atom/RPI/Code/atom_rpi_reflect_files.cmake b/Gems/Atom/RPI/Code/atom_rpi_reflect_files.cmake index 921d5a8e46..df8f389c37 100644 --- a/Gems/Atom/RPI/Code/atom_rpi_reflect_files.cmake +++ b/Gems/Atom/RPI/Code/atom_rpi_reflect_files.cmake @@ -62,7 +62,6 @@ set(FILES Include/Atom/RPI.Reflect/Material/ShaderCollection.h Include/Atom/RPI.Reflect/Material/MaterialFunctor.h Include/Atom/RPI.Reflect/Material/MaterialVersionUpdate.h - Include/Atom/RPI.Reflect/Pass/ClearPassData.h Include/Atom/RPI.Reflect/Pass/ComputePassData.h Include/Atom/RPI.Reflect/Pass/CopyPassData.h Include/Atom/RPI.Reflect/Pass/DownsampleMipChainPassData.h @@ -76,6 +75,7 @@ set(FILES Include/Atom/RPI.Reflect/Pass/PassTemplate.h Include/Atom/RPI.Reflect/Pass/RasterPassData.h Include/Atom/RPI.Reflect/Pass/RenderPassData.h + Include/Atom/RPI.Reflect/Pass/SlowClearPassData.h Include/Atom/RPI.Reflect/Shader/ShaderCommonTypes.h Include/Atom/RPI.Reflect/Shader/ShaderAsset.h Include/Atom/RPI.Reflect/Shader/ShaderAssetCreator.h From 20e697a8d66fd914d00741603c2e42d799c338c6 Mon Sep 17 00:00:00 2001 From: nwidmaie Date: Thu, 16 Dec 2021 11:32:47 -0800 Subject: [PATCH 67/70] Fixing case error with material files Signed-off-by: nwidmaie --- .../Levels/PbrMaterialChart/materials/basic_m00_r00.material | 2 +- .../Levels/PbrMaterialChart/materials/basic_m00_r01.material | 2 +- .../Levels/PbrMaterialChart/materials/basic_m00_r02.material | 2 +- .../Levels/PbrMaterialChart/materials/basic_m00_r03.material | 2 +- .../Levels/PbrMaterialChart/materials/basic_m00_r04.material | 2 +- .../Levels/PbrMaterialChart/materials/basic_m00_r05.material | 2 +- .../Levels/PbrMaterialChart/materials/basic_m00_r06.material | 2 +- .../Levels/PbrMaterialChart/materials/basic_m00_r07.material | 2 +- .../Levels/PbrMaterialChart/materials/basic_m00_r08.material | 2 +- .../Levels/PbrMaterialChart/materials/basic_m00_r09.material | 2 +- .../Levels/PbrMaterialChart/materials/basic_m00_r10.material | 2 +- .../Levels/PbrMaterialChart/materials/basic_m10_r00.material | 2 +- .../Levels/PbrMaterialChart/materials/basic_m10_r01.material | 2 +- .../Levels/PbrMaterialChart/materials/basic_m10_r02.material | 2 +- .../Levels/PbrMaterialChart/materials/basic_m10_r03.material | 2 +- .../Levels/PbrMaterialChart/materials/basic_m10_r04.material | 2 +- .../Levels/PbrMaterialChart/materials/basic_m10_r05.material | 2 +- .../Levels/PbrMaterialChart/materials/basic_m10_r06.material | 2 +- .../Levels/PbrMaterialChart/materials/basic_m10_r07.material | 2 +- .../Levels/PbrMaterialChart/materials/basic_m10_r08.material | 2 +- .../Levels/PbrMaterialChart/materials/basic_m10_r09.material | 2 +- .../Levels/PbrMaterialChart/materials/basic_m10_r10.material | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r00.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r00.material index dcadcb9bfe..1c1096bf12 100644 --- a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r00.material +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r00.material @@ -1,6 +1,6 @@ { "parentMaterial": "./basic.material", - "materialType": "materials/Types/StandardPBR.materialtype", + "materialType": "Materials/Types/StandardPBR.materialtype", "propertyLayoutVersion": 1, "properties": { "metallic": { diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r01.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r01.material index 0c2b3e62b3..33148f3f73 100644 --- a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r01.material +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r01.material @@ -1,6 +1,6 @@ { "parentMaterial": "./basic.material", - "materialType": "materials/Types/StandardPBR.materialtype", + "materialType": "Materials/Types/StandardPBR.materialtype", "propertyLayoutVersion": 1, "properties": { "metallic": { diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r02.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r02.material index 8d29890384..38339454cb 100644 --- a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r02.material +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r02.material @@ -1,6 +1,6 @@ { "parentMaterial": "./basic.material", - "materialType": "materials/Types/StandardPBR.materialtype", + "materialType": "Materials/Types/StandardPBR.materialtype", "propertyLayoutVersion": 1, "properties": { "metallic": { diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r03.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r03.material index bb9557241b..e21ab5775a 100644 --- a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r03.material +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r03.material @@ -1,6 +1,6 @@ { "parentMaterial": "./basic.material", - "materialType": "materials/Types/StandardPBR.materialtype", + "materialType": "Materials/Types/StandardPBR.materialtype", "propertyLayoutVersion": 1, "properties": { "metallic": { diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r04.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r04.material index e14e2899fa..0272e66081 100644 --- a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r04.material +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r04.material @@ -1,6 +1,6 @@ { "parentMaterial": "./basic.material", - "materialType": "materials/Types/StandardPBR.materialtype", + "materialType": "Materials/Types/StandardPBR.materialtype", "propertyLayoutVersion": 1, "properties": { "metallic": { diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r05.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r05.material index 344ce084e5..67d51777a4 100644 --- a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r05.material +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r05.material @@ -1,6 +1,6 @@ { "parentMaterial": "./basic.material", - "materialType": "materials/Types/StandardPBR.materialtype", + "materialType": "Materials/Types/StandardPBR.materialtype", "propertyLayoutVersion": 1, "properties": { "metallic": { diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r06.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r06.material index 0f8195653f..3136f654e6 100644 --- a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r06.material +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r06.material @@ -1,6 +1,6 @@ { "parentMaterial": "./basic.material", - "materialType": "materials/Types/StandardPBR.materialtype", + "materialType": "Materials/Types/StandardPBR.materialtype", "propertyLayoutVersion": 1, "properties": { "metallic": { diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r07.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r07.material index d5d95ff285..a79744ea11 100644 --- a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r07.material +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r07.material @@ -1,6 +1,6 @@ { "parentMaterial": "./basic.material", - "materialType": "materials/Types/StandardPBR.materialtype", + "materialType": "Materials/Types/StandardPBR.materialtype", "propertyLayoutVersion": 1, "properties": { "metallic": { diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r08.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r08.material index 801b138831..1372283500 100644 --- a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r08.material +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r08.material @@ -1,6 +1,6 @@ { "parentMaterial": "./basic.material", - "materialType": "materials/Types/StandardPBR.materialtype", + "materialType": "Materials/Types/StandardPBR.materialtype", "propertyLayoutVersion": 1, "properties": { "metallic": { diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r09.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r09.material index 0710a320cb..d1c951e53c 100644 --- a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r09.material +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r09.material @@ -1,6 +1,6 @@ { "parentMaterial": "./basic.material", - "materialType": "materials/Types/StandardPBR.materialtype", + "materialType": "Materials/Types/StandardPBR.materialtype", "propertyLayoutVersion": 1, "properties": { "metallic": { diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r10.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r10.material index d1cc781c61..d34fc46530 100644 --- a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r10.material +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m00_r10.material @@ -1,6 +1,6 @@ { "parentMaterial": "./basic.material", - "materialType": "materials/Types/StandardPBR.materialtype", + "materialType": "Materials/Types/StandardPBR.materialtype", "propertyLayoutVersion": 1, "properties": { "metallic": { diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r00.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r00.material index 945cd1e9eb..92ddfec7c4 100644 --- a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r00.material +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r00.material @@ -1,6 +1,6 @@ { "parentMaterial": "./basic.material", - "materialType": "materials/Types/StandardPBR.materialtype", + "materialType": "Materials/Types/StandardPBR.materialtype", "propertyLayoutVersion": 1, "properties": { "metallic": { diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r01.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r01.material index 85f6008782..874422384a 100644 --- a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r01.material +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r01.material @@ -1,6 +1,6 @@ { "parentMaterial": "./basic.material", - "materialType": "materials/Types/StandardPBR.materialtype", + "materialType": "Materials/Types/StandardPBR.materialtype", "propertyLayoutVersion": 1, "properties": { "metallic": { diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r02.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r02.material index 5abedc34e2..b017add10b 100644 --- a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r02.material +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r02.material @@ -1,6 +1,6 @@ { "parentMaterial": "./basic.material", - "materialType": "materials/Types/StandardPBR.materialtype", + "materialType": "Materials/Types/StandardPBR.materialtype", "propertyLayoutVersion": 1, "properties": { "metallic": { diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r03.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r03.material index 50b37a647d..5353d651c8 100644 --- a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r03.material +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r03.material @@ -1,6 +1,6 @@ { "parentMaterial": "./basic.material", - "materialType": "materials/Types/StandardPBR.materialtype", + "materialType": "Materials/Types/StandardPBR.materialtype", "propertyLayoutVersion": 1, "properties": { "metallic": { diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r04.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r04.material index ad74ddf08b..6dd47e4e3b 100644 --- a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r04.material +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r04.material @@ -1,6 +1,6 @@ { "parentMaterial": "./basic.material", - "materialType": "materials/Types/StandardPBR.materialtype", + "materialType": "Materials/Types/StandardPBR.materialtype", "propertyLayoutVersion": 1, "properties": { "metallic": { diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r05.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r05.material index f7f3260b97..04912cbfd4 100644 --- a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r05.material +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r05.material @@ -1,6 +1,6 @@ { "parentMaterial": "./basic.material", - "materialType": "materials/Types/StandardPBR.materialtype", + "materialType": "Materials/Types/StandardPBR.materialtype", "propertyLayoutVersion": 1, "properties": { "metallic": { diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r06.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r06.material index fc982f9c22..27f7f6ff42 100644 --- a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r06.material +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r06.material @@ -1,6 +1,6 @@ { "parentMaterial": "./basic.material", - "materialType": "materials/Types/StandardPBR.materialtype", + "materialType": "Materials/Types/StandardPBR.materialtype", "propertyLayoutVersion": 1, "properties": { "metallic": { diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r07.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r07.material index c4526dfd2c..e2b5df681c 100644 --- a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r07.material +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r07.material @@ -1,6 +1,6 @@ { "parentMaterial": "./basic.material", - "materialType": "materials/Types/StandardPBR.materialtype", + "materialType": "Materials/Types/StandardPBR.materialtype", "propertyLayoutVersion": 1, "properties": { "metallic": { diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r08.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r08.material index f756a36ded..5418f9c855 100644 --- a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r08.material +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r08.material @@ -1,6 +1,6 @@ { "parentMaterial": "./basic.material", - "materialType": "materials/Types/StandardPBR.materialtype", + "materialType": "Materials/Types/StandardPBR.materialtype", "propertyLayoutVersion": 1, "properties": { "metallic": { diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r09.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r09.material index a853979d6d..dd1ec3489a 100644 --- a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r09.material +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r09.material @@ -1,6 +1,6 @@ { "parentMaterial": "./basic.material", - "materialType": "materials/Types/StandardPBR.materialtype", + "materialType": "Materials/Types/StandardPBR.materialtype", "propertyLayoutVersion": 1, "properties": { "metallic": { diff --git a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r10.material b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r10.material index e4528d45fd..5f9317d2cc 100644 --- a/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r10.material +++ b/AutomatedTesting/Levels/PbrMaterialChart/materials/basic_m10_r10.material @@ -1,6 +1,6 @@ { "parentMaterial": "./basic.material", - "materialType": "materials/Types/StandardPBR.materialtype", + "materialType": "Materials/Types/StandardPBR.materialtype", "propertyLayoutVersion": 1, "properties": { "metallic": { From 285d92ff0d2e269ac3630b6149a3bb0106ff54be Mon Sep 17 00:00:00 2001 From: Maxim Ivanov <59574542+imginimg@users.noreply.github.com> Date: Thu, 16 Dec 2021 23:53:22 +0300 Subject: [PATCH 68/70] [AudioSystem] ACE bug fix: Ctrl-S doesn't work correctly when a level is loaded. (#6411) Signed-off-by: Maxim Ivanov --- .../Editor/AudioControlsEditorMainWindow.ui | 3 +++ .../Editor/AudioControlsEditorWindow.cpp | 21 ------------------- .../Source/Editor/AudioControlsEditorWindow.h | 1 - 3 files changed, 3 insertions(+), 22 deletions(-) diff --git a/Gems/AudioSystem/Code/Source/Editor/AudioControlsEditorMainWindow.ui b/Gems/AudioSystem/Code/Source/Editor/AudioControlsEditorMainWindow.ui index 8954bbc812..549e746de6 100644 --- a/Gems/AudioSystem/Code/Source/Editor/AudioControlsEditorMainWindow.ui +++ b/Gems/AudioSystem/Code/Source/Editor/AudioControlsEditorMainWindow.ui @@ -154,6 +154,9 @@ Save All + + Ctrl+S + diff --git a/Gems/AudioSystem/Code/Source/Editor/AudioControlsEditorWindow.cpp b/Gems/AudioSystem/Code/Source/Editor/AudioControlsEditorWindow.cpp index 54a8ce616d..5f870d06d4 100644 --- a/Gems/AudioSystem/Code/Source/Editor/AudioControlsEditorWindow.cpp +++ b/Gems/AudioSystem/Code/Source/Editor/AudioControlsEditorWindow.cpp @@ -121,27 +121,6 @@ namespace AudioControls } } - //-------------------------------------------------------------------------------------------// - void CAudioControlsEditorWindow::keyPressEvent(QKeyEvent* pEvent) - { - if (pEvent->key() == Qt::Key_S && pEvent->modifiers() == Qt::ControlModifier) - { - Save(); - } - else if (pEvent->key() == Qt::Key_Z && (pEvent->modifiers() & Qt::ControlModifier)) - { - if (pEvent->modifiers() & Qt::ShiftModifier) - { - GetIEditor()->Redo(); - } - else - { - GetIEditor()->Undo(); - } - } - QMainWindow::keyPressEvent(pEvent); - } - //-------------------------------------------------------------------------------------------// void CAudioControlsEditorWindow::closeEvent(QCloseEvent* pEvent) { diff --git a/Gems/AudioSystem/Code/Source/Editor/AudioControlsEditorWindow.h b/Gems/AudioSystem/Code/Source/Editor/AudioControlsEditorWindow.h index abe5fd4511..00ffabfbe9 100644 --- a/Gems/AudioSystem/Code/Source/Editor/AudioControlsEditorWindow.h +++ b/Gems/AudioSystem/Code/Source/Editor/AudioControlsEditorWindow.h @@ -63,7 +63,6 @@ namespace AudioControls void Update(); protected: - void keyPressEvent(QKeyEvent* pEvent) override; void closeEvent(QCloseEvent* pEvent) override; private: From f52d49834acc3dbaa1652bc93fb50e7bf834afc6 Mon Sep 17 00:00:00 2001 From: Chris Burel Date: Thu, 16 Dec 2021 13:42:38 -0800 Subject: [PATCH 69/70] [EMotionFX] Prefer `#pragma once` (#6435) Signed-off-by: Chris Burel --- .../CommandSystem/Source/ActorInstanceCommands.h | 6 +----- .../EMotionFX/CommandSystem/Source/AttachmentCommands.h | 6 +----- .../EMotionFX/CommandSystem/Source/CommandSystemConfig.h | 5 +---- .../EMotionFX/CommandSystem/Source/ImporterCommands.h | 6 +----- .../EMotionFX/CommandSystem/Source/MorphTargetCommands.h | 6 +----- .../EMotionFX/CommandSystem/Source/SelectionCommands.h | 6 +----- Gems/EMotionFX/Code/EMotionFX/Rendering/Common/Camera.h | 6 +----- .../Code/EMotionFX/Rendering/Common/FirstPersonCamera.h | 6 +----- .../Code/EMotionFX/Rendering/Common/LookAtCamera.h | 6 +----- .../Code/EMotionFX/Rendering/Common/MCommonConfig.h | 5 +---- .../Code/EMotionFX/Rendering/Common/OrbitCamera.h | 6 +----- .../EMotionFX/Rendering/Common/TranslateManipulator.h | 6 +----- .../Code/EMotionFX/Rendering/OpenGL2/Source/GBuffer.h | 6 +----- .../EMotionFX/Rendering/OpenGL2/Source/GLRenderUtil.h | 6 +----- .../Code/EMotionFX/Rendering/OpenGL2/Source/GLSLShader.h | 8 ++------ .../EMotionFX/Rendering/OpenGL2/Source/GraphicsManager.h | 7 ++----- .../Code/EMotionFX/Rendering/OpenGL2/Source/IndexBuffer.h | 7 ++----- .../Code/EMotionFX/Rendering/OpenGL2/Source/Material.h | 7 ++----- .../Rendering/OpenGL2/Source/PostProcessShader.h | 7 ++----- .../EMotionFX/Rendering/OpenGL2/Source/RenderGLConfig.h | 6 +----- .../EMotionFX/Rendering/OpenGL2/Source/RenderTexture.h | 7 ++----- .../Code/EMotionFX/Rendering/OpenGL2/Source/Shader.h | 7 ++----- .../EMotionFX/Rendering/OpenGL2/Source/StandardMaterial.h | 6 +----- .../EMotionFX/Rendering/OpenGL2/Source/TextureCache.h | 8 ++------ .../EMotionFX/Rendering/OpenGL2/Source/VertexBuffer.h | 5 +---- .../Code/EMotionFX/Rendering/OpenGL2/Source/glactor.h | 7 ++----- .../Code/EMotionFX/Rendering/OpenGL2/Source/shadercache.h | 5 +---- .../EMotionStudio/EMStudioSDK/Source/EMStudioConfig.h | 5 +---- .../Tools/EMotionStudio/EMStudioSDK/Source/EMStudioCore.h | 5 +---- .../EMotionStudio/EMStudioSDK/Source/EMStudioPlugin.h | 5 +---- .../EMotionStudio/EMStudioSDK/Source/InvisiblePlugin.h | 5 +---- .../EMStudioSDK/Source/NodeSelectionWindow.h | 5 +---- .../EMotionStudio/EMStudioSDK/Source/PluginManager.h | 5 +---- .../Source/RenderPlugin/ManipulatorCallbacks.h | 8 ++------ .../EMStudioSDK/Source/RenderPlugin/RenderLayouts.h | 6 +----- .../Source/RenderPlugin/RenderUpdateCallback.h | 6 +----- .../EMotionStudio/EMStudioSDK/Source/ToolBarPlugin.h | 5 +---- .../Plugins/RenderPlugins/Source/OpenGLRender/GLWidget.h | 6 +----- .../Plugins/RenderPlugins/Source/RenderPluginsConfig.h | 5 +---- .../StandardPlugins/Source/AnimGraph/AnimGraphPlugin.h | 6 +----- .../StandardPlugins/Source/AnimGraph/DebugEventHandler.h | 5 +---- .../StandardPlugins/Source/AnimGraph/GameController.h | 5 +---- .../Source/AnimGraph/GameControllerWindow.h | 5 +---- .../Source/AnimGraph/GraphWidgetCallback.h | 5 +---- .../Source/Attachments/AttachmentNodesWindow.h | 6 +----- .../Source/Attachments/AttachmentsHierarchyWindow.h | 6 +----- .../Source/Attachments/AttachmentsPlugin.h | 6 +----- .../StandardPlugins/Source/LogWindow/LogWindowCallback.h | 5 +---- .../StandardPlugins/Source/LogWindow/LogWindowPlugin.h | 5 +---- .../Source/MotionWindow/MotionExtractionWindow.h | 6 +----- .../Source/MotionWindow/MotionPropertiesWindow.h | 6 +----- .../Source/MotionWindow/MotionRetargetingWindow.h | 6 +----- .../StandardPlugins/Source/StandardPluginsConfig.h | 5 +---- Gems/EMotionFX/Code/MysticQt/Source/MysticQtManager.h | 5 +---- 54 files changed, 64 insertions(+), 253 deletions(-) diff --git a/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/ActorInstanceCommands.h b/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/ActorInstanceCommands.h index 604d88d037..4681b19bf2 100644 --- a/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/ActorInstanceCommands.h +++ b/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/ActorInstanceCommands.h @@ -6,8 +6,7 @@ * */ -#ifndef __EMFX_ACTORINSTANCECOMMANDS_H -#define __EMFX_ACTORINSTANCECOMMANDS_H +#pragma once // include the required headers #include "CommandSystemConfig.h" @@ -61,6 +60,3 @@ public: void COMMANDSYSTEM_API MakeSelectedActorInstancesVisible(); void COMMANDSYSTEM_API UnselectSelectedActorInstances(); } // namespace CommandSystem - - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/AttachmentCommands.h b/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/AttachmentCommands.h index db4f4b9e04..8ea098021f 100644 --- a/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/AttachmentCommands.h +++ b/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/AttachmentCommands.h @@ -6,8 +6,7 @@ * */ -#ifndef __EMFX_ATTACHMENTCOMMANDS_H -#define __EMFX_ATTACHMENTCOMMANDS_H +#pragma once // include the required headers #include "CommandSystemConfig.h" @@ -35,6 +34,3 @@ public: static bool AddAttachment(MCore::Command* command, const MCore::CommandLine& parameters, AZStd::string& outResult, bool remove); MCORE_DEFINECOMMAND_END } // namespace CommandSystem - - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/CommandSystemConfig.h b/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/CommandSystemConfig.h index 48d2d01644..328785453c 100644 --- a/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/CommandSystemConfig.h +++ b/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/CommandSystemConfig.h @@ -6,8 +6,7 @@ * */ -#ifndef __COMMANDSYSTEM_CONFIG_H -#define __COMMANDSYSTEM_CONFIG_H +#pragma once #include @@ -35,5 +34,3 @@ enum { MEMCATEGORY_COMMANDSYSTEM = 990 }; - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/ImporterCommands.h b/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/ImporterCommands.h index 6e8f4728c7..b3906dbfe0 100644 --- a/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/ImporterCommands.h +++ b/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/ImporterCommands.h @@ -6,8 +6,7 @@ * */ -#ifndef __EMFX_IMPORTERCOMMANDS_H -#define __EMFX_IMPORTERCOMMANDS_H +#pragma once // include the required headers #include "CommandSystemConfig.h" @@ -35,6 +34,3 @@ public: MCORE_DEFINECOMMAND_END } // namespace CommandSystem - - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/MorphTargetCommands.h b/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/MorphTargetCommands.h index 2ae284e907..7bfb0084aa 100644 --- a/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/MorphTargetCommands.h +++ b/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/MorphTargetCommands.h @@ -6,8 +6,7 @@ * */ -#ifndef __EMFX_MORPHTARGETCOMMANDS_H -#define __EMFX_MORPHTARGETCOMMANDS_H +#pragma once // include the required headers #include "CommandSystemConfig.h" @@ -30,6 +29,3 @@ namespace CommandSystem bool GetMorphTarget(EMotionFX::Actor* actor, EMotionFX::ActorInstance* actorInstance, uint32 lodLevel, const char* morphTargetName, EMotionFX::MorphTarget** outMorphTarget, EMotionFX::MorphSetupInstance::MorphTarget** outMorphTargetInstance, AZStd::string& outResult); MCORE_DEFINECOMMAND_END } // namespace CommandSystem - - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/SelectionCommands.h b/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/SelectionCommands.h index 13a39e5e8a..04af437935 100644 --- a/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/SelectionCommands.h +++ b/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/SelectionCommands.h @@ -6,8 +6,7 @@ * */ -#ifndef __EMFX_SELECTIONCOMMANDS_H -#define __EMFX_SELECTIONCOMMANDS_H +#pragma once // include the required headers #include "CommandSystemConfig.h" @@ -49,6 +48,3 @@ public: bool COMMANDSYSTEM_API CheckIfHasAnimGraphSelectionParameter(const MCore::CommandLine& parameters); bool COMMANDSYSTEM_API CheckIfHasActorSelectionParameter(const MCore::CommandLine& parameters, bool ignoreInstanceParameters = false); } // namespace CommandSystem - - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/Camera.h b/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/Camera.h index 46b81a9d25..2c685ce77f 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/Camera.h +++ b/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/Camera.h @@ -6,8 +6,7 @@ * */ -#ifndef __MCOMMON_CAMERA_H -#define __MCOMMON_CAMERA_H +#pragma once #include #include @@ -280,6 +279,3 @@ namespace MCommon // include inline code #include "Camera.inl" } // namespace MCommon - - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/FirstPersonCamera.h b/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/FirstPersonCamera.h index e0abe7922c..fa3631713c 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/FirstPersonCamera.h +++ b/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/FirstPersonCamera.h @@ -6,8 +6,7 @@ * */ -#ifndef __MCOMMON_FIRSTPERSONCAMERA_H -#define __MCOMMON_FIRSTPERSONCAMERA_H +#pragma once // include required headers #include "Camera.h" @@ -124,6 +123,3 @@ namespace MCommon float m_roll; /**< Rotation around axis of screen. (0=straight, +clockwise, -CCW) */ }; } // namespace MCommon - - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/LookAtCamera.h b/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/LookAtCamera.h index e17fe65985..a2fd21a9b9 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/LookAtCamera.h +++ b/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/LookAtCamera.h @@ -6,8 +6,7 @@ * */ -#ifndef __MCOMMON_LOOKATCAMERA_H -#define __MCOMMON_LOOKATCAMERA_H +#pragma once // include required headers #include "Camera.h" @@ -91,6 +90,3 @@ namespace MCommon AZ::Vector3 m_up; /**< The up vector of the camera. */ }; } // namespace MCommon - - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/MCommonConfig.h b/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/MCommonConfig.h index 634c01951e..94860cdc1c 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/MCommonConfig.h +++ b/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/MCommonConfig.h @@ -6,8 +6,7 @@ * */ -#ifndef __MCOMMON_CONFIG_H -#define __MCOMMON_CONFIG_H +#pragma once #include @@ -27,5 +26,3 @@ enum { MEMCATEGORY_MCOMMON = 992, }; - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/OrbitCamera.h b/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/OrbitCamera.h index 8aaa465da9..ae6383d6a8 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/OrbitCamera.h +++ b/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/OrbitCamera.h @@ -6,8 +6,7 @@ * */ -#ifndef __MCOMMON_ORBITCAMERA_H -#define __MCOMMON_ORBITCAMERA_H +#pragma once // include required headers #include "LookAtCamera.h" @@ -125,6 +124,3 @@ namespace MCommon float m_flightTargetBeta; }; } // namespace MCommon - - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/TranslateManipulator.h b/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/TranslateManipulator.h index 4b916f43b7..a8946dfff0 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/TranslateManipulator.h +++ b/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/TranslateManipulator.h @@ -6,8 +6,7 @@ * */ -#ifndef __MCOMMON_TRANSLATEMANIPULATOR_H -#define __MCOMMON_TRANSLATEMANIPULATOR_H +#pragma once #include #include @@ -111,6 +110,3 @@ namespace MCommon bool m_zAxisVisible; }; } // namespace MCommon - - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/GBuffer.h b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/GBuffer.h index cce01485e0..7995d4df2a 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/GBuffer.h +++ b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/GBuffer.h @@ -6,8 +6,7 @@ * */ -#ifndef __RENDERGL_GBUFFER_H -#define __RENDERGL_GBUFFER_H +#pragma once // include required headers #include @@ -76,6 +75,3 @@ namespace RenderGL RenderTexture* m_renderTargetE; /**< Render target with width and height divided by four. */ }; } // namespace RenderGL - - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/GLRenderUtil.h b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/GLRenderUtil.h index aa64581449..84e6e1a6b2 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/GLRenderUtil.h +++ b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/GLRenderUtil.h @@ -6,8 +6,7 @@ * */ -#ifndef __OPENGLRENDERUTIL_H -#define __OPENGLRENDERUTIL_H +#pragma once #include "RenderGLConfig.h" #include "../../Common/RenderUtil.h" @@ -114,6 +113,3 @@ namespace RenderGL uint32 m_maxNumTextures; }; } // namespace RenderGL - - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/GLSLShader.h b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/GLSLShader.h index 5975470f86..b8e34d90ba 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/GLSLShader.h +++ b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/GLSLShader.h @@ -6,8 +6,7 @@ * */ -#ifndef __RENDERGL_GLSLSHADER_H -#define __RENDERGL_GLSLSHADER_H +#pragma once #include #include @@ -96,7 +95,4 @@ namespace RenderGL uint32 m_textureUnit; }; -} - - -#endif +} // namespace RenderGL diff --git a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/GraphicsManager.h b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/GraphicsManager.h index 67ebbd9441..0b22df1656 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/GraphicsManager.h +++ b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/GraphicsManager.h @@ -6,8 +6,7 @@ * */ -#ifndef __RENDERGL_GRAPHICSMANAGER__H -#define __RENDERGL_GRAPHICSMANAGER__H +#pragma once #include #include @@ -198,6 +197,4 @@ namespace RenderGL }; GraphicsManager* GetGraphicsManager(); -} - -#endif +} // namespace RenderGL diff --git a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/IndexBuffer.h b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/IndexBuffer.h index b09e5f394d..09e49d4c5f 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/IndexBuffer.h +++ b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/IndexBuffer.h @@ -6,8 +6,7 @@ * */ -#ifndef __RENDERGL_INDEXBUFFER_H -#define __RENDERGL_INDEXBUFFER_H +#pragma once #include "VertexBuffer.h" @@ -51,6 +50,4 @@ namespace RenderGL bool GetIsSuccess(); bool GetHasError(); }; -} - -#endif +} // namespace RenderGL diff --git a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/Material.h b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/Material.h index 825fa4c7b0..69b22184c8 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/Material.h +++ b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/Material.h @@ -6,8 +6,7 @@ * */ -#ifndef __RENDERGL_MATERIAL_H -#define __RENDERGL_MATERIAL_H +#pragma once #include #include @@ -105,6 +104,4 @@ namespace RenderGL GLActor* m_actor; }; -} - -#endif +} // namespace RenderGL diff --git a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/PostProcessShader.h b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/PostProcessShader.h index 644e47b9b9..3c38626672 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/PostProcessShader.h +++ b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/PostProcessShader.h @@ -6,8 +6,7 @@ * */ -#ifndef __RENDERGL_POSTPROCESS_SHADER_H -#define __RENDERGL_POSTPROCESS_SHADER_H +#pragma once #include #include "GLSLShader.h" @@ -38,6 +37,4 @@ namespace RenderGL RenderTexture* m_rt; }; -} - -#endif +} // namespace RenderGL diff --git a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/RenderGLConfig.h b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/RenderGLConfig.h index 066b6e681d..4cdf646a34 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/RenderGLConfig.h +++ b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/RenderGLConfig.h @@ -6,8 +6,7 @@ * */ -#ifndef __RENDERGL_CONFIG_H -#define __RENDERGL_CONFIG_H +#pragma once #include @@ -28,6 +27,3 @@ enum { MEMCATEGORY_RENDERING = 997 }; - - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/RenderTexture.h b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/RenderTexture.h index 9839ca0a5f..7ff3c08f33 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/RenderTexture.h +++ b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/RenderTexture.h @@ -6,8 +6,7 @@ * */ -#ifndef __RENDERGL_RENDERTEXTURE_H -#define __RENDERGL_RENDERTEXTURE_H +#pragma once #include "TextureCache.h" #include @@ -66,6 +65,4 @@ namespace RenderGL AZ::u32 m_frameBuffer; AZ::u32 m_depthBuffer; }; -} - -#endif +} // namespace RenderGL diff --git a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/Shader.h b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/Shader.h index ebb2e7e0a4..cd57446468 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/Shader.h +++ b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/Shader.h @@ -6,8 +6,7 @@ * */ -#ifndef __RENDERGL_SHADER__H -#define __RENDERGL_SHADER__H +#pragma once #include #include "RenderGLConfig.h" @@ -51,6 +50,4 @@ namespace RenderGL virtual void SetUniform(const char* name, Texture* texture) = 0; virtual void SetUniform(const char* name, const float* values, uint32 numFloats) = 0; }; -} - -#endif +} // namespace RenderGL diff --git a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/StandardMaterial.h b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/StandardMaterial.h index 528269765c..2e240042db 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/StandardMaterial.h +++ b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/StandardMaterial.h @@ -6,8 +6,7 @@ * */ -#ifndef __RENDERGL_STANDARD_MATERIAL_H -#define __RENDERGL_STANDARD_MATERIAL_H +#pragma once #include #include @@ -54,6 +53,3 @@ namespace RenderGL Texture* m_normalMap; }; } // namespace RenderGL - - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/TextureCache.h b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/TextureCache.h index 4350cd67c7..57510133af 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/TextureCache.h +++ b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/TextureCache.h @@ -6,8 +6,7 @@ * */ -#ifndef __RENDERGL_TEXTURECACHE_H -#define __RENDERGL_TEXTURECACHE_H +#pragma once #include #include @@ -76,7 +75,4 @@ namespace RenderGL Texture* m_whiteTexture; Texture* m_defaultNormalTexture; }; -} - - -#endif +} // namespace RenderGL diff --git a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/VertexBuffer.h b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/VertexBuffer.h index c76cf5137a..71c04e6c93 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/VertexBuffer.h +++ b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/VertexBuffer.h @@ -6,8 +6,7 @@ * */ -#ifndef __RENDERGL_VERTEXBUFFER_H -#define __RENDERGL_VERTEXBUFFER_H +#pragma once #include "RenderGLConfig.h" #include @@ -66,5 +65,3 @@ namespace RenderGL bool GetHasError(); }; } // namespace RenderGL - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/glactor.h b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/glactor.h index 36158306a1..ab2ef8686b 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/glactor.h +++ b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/glactor.h @@ -6,8 +6,7 @@ * */ -#ifndef __RENDERGL_GLACTOR_H -#define __RENDERGL_GLACTOR_H +#pragma once #include "RenderGLConfig.h" #include "VertexBuffer.h" @@ -99,6 +98,4 @@ namespace RenderGL void Delete() override; }; -} - -#endif +} // namespace RenderGL diff --git a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/shadercache.h b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/shadercache.h index d33cfcfd7d..7006e62dde 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/shadercache.h +++ b/Gems/EMotionFX/Code/EMotionFX/Rendering/OpenGL2/Source/shadercache.h @@ -6,8 +6,7 @@ * */ -#ifndef __RENDERGL_SHADERCACHE__H -#define __RENDERGL_SHADERCACHE__H +#pragma once #include "Shader.h" #include @@ -45,5 +44,3 @@ namespace RenderGL AZStd::vector m_entries; // the shader cache entries }; } // namespace RenderGL - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/EMStudioConfig.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/EMStudioConfig.h index 7fc4b1224c..6d339148f3 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/EMStudioConfig.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/EMStudioConfig.h @@ -6,8 +6,7 @@ * */ -#ifndef __EMSTUDIO_EMSTUDIOCONFIG_H -#define __EMSTUDIO_EMSTUDIOCONFIG_H +#pragma once #include @@ -31,5 +30,3 @@ enum }; #define SHOW_REALTIMEINTERFACE_PERFORMANCEINFO - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/EMStudioCore.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/EMStudioCore.h index 9d510c0769..2899ebc33a 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/EMStudioCore.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/EMStudioCore.h @@ -6,8 +6,7 @@ * */ -#ifndef __EMSTUDIO_EMSTUDIOCORE_H -#define __EMSTUDIO_EMSTUDIOCORE_H +#pragma once // include all headers #include "EMStudioConfig.h" @@ -16,5 +15,3 @@ #include "PluginManager.h" #include "EMStudioPlugin.h" #include "LayoutManager.h" - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/EMStudioPlugin.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/EMStudioPlugin.h index 8ae84b6e49..f1cabccc31 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/EMStudioPlugin.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/EMStudioPlugin.h @@ -6,8 +6,7 @@ * */ -#ifndef __EMSTUDIO_EMSTUDIOPLUGIN_H -#define __EMSTUDIO_EMSTUDIOPLUGIN_H +#pragma once // include MCore #if !defined(Q_MOC_RUN) @@ -127,5 +126,3 @@ namespace EMStudio virtual void AddWindowMenuEntries([[maybe_unused]] QMenu* parent) { } }; } // namespace EMStudio - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/InvisiblePlugin.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/InvisiblePlugin.h index 6021f52217..127705867a 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/InvisiblePlugin.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/InvisiblePlugin.h @@ -6,8 +6,7 @@ * */ -#ifndef __EMSTUDIO_INVISIBLEPLUGIN_H -#define __EMSTUDIO_INVISIBLEPLUGIN_H +#pragma once // include MCore #if !defined(Q_MOC_RUN) @@ -41,5 +40,3 @@ namespace EMStudio void CreateBaseInterface(const char* objectName) override { MCORE_UNUSED(objectName); } }; } // namespace EMStudio - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/NodeSelectionWindow.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/NodeSelectionWindow.h index df6f0195bc..97ca74284a 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/NodeSelectionWindow.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/NodeSelectionWindow.h @@ -6,8 +6,7 @@ * */ -#ifndef __EMSTUDIO_NODESELECTIONWINDOW_H -#define __EMSTUDIO_NODESELECTIONWINDOW_H +#pragma once // include MCore #if !defined(Q_MOC_RUN) @@ -57,5 +56,3 @@ namespace EMStudio bool m_accepted; }; } // namespace EMStudio - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/PluginManager.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/PluginManager.h index e3a5f9627a..b295f786a0 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/PluginManager.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/PluginManager.h @@ -6,8 +6,7 @@ * */ -#ifndef __EMSTUDIO_PLUGINMANAGER_H -#define __EMSTUDIO_PLUGINMANAGER_H +#pragma once #include #include @@ -68,5 +67,3 @@ namespace EMStudio void UnloadPlugins(); }; } // namespace EMStudio - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/RenderPlugin/ManipulatorCallbacks.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/RenderPlugin/ManipulatorCallbacks.h index 2f9201ffa9..16cf8f8f31 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/RenderPlugin/ManipulatorCallbacks.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/RenderPlugin/ManipulatorCallbacks.h @@ -6,8 +6,7 @@ * */ -#ifndef __MCOMMON_MANIPULATORCALLBACKS_H -#define __MCOMMON_MANIPULATORCALLBACKS_H +#pragma once // include the Core system #include "../EMStudioConfig.h" @@ -142,7 +141,4 @@ namespace EMStudio bool GetResetFollowMode() const override { return true; } }; -} // namespace MCommon - - -#endif +} // namespace EMStudio diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/RenderPlugin/RenderLayouts.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/RenderPlugin/RenderLayouts.h index fbc4178009..c792efddda 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/RenderPlugin/RenderLayouts.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/RenderPlugin/RenderLayouts.h @@ -6,8 +6,7 @@ * */ -#ifndef __EMSTUDIO_RENDERPLUGINLAYOUTS_H -#define __EMSTUDIO_RENDERPLUGINLAYOUTS_H +#pragma once // include the required headers #include "RenderPlugin.h" @@ -176,6 +175,3 @@ namespace EMStudio // register all available layouts (this will be automatically called inside the RenderPlugin's constructor) void EMSTUDIO_API RegisterRenderPluginLayouts(RenderPlugin* renderPlugin); } // namespace EMStudio - - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/RenderPlugin/RenderUpdateCallback.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/RenderPlugin/RenderUpdateCallback.h index a9bc26ae22..af5c1c367a 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/RenderPlugin/RenderUpdateCallback.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/RenderPlugin/RenderUpdateCallback.h @@ -6,8 +6,7 @@ * */ -#ifndef __EMSTUDIO_RENDERUPDATECALLBACK_H -#define __EMSTUDIO_RENDERUPDATECALLBACK_H +#pragma once #include "../EMStudioConfig.h" #include @@ -38,6 +37,3 @@ namespace EMStudio RenderPlugin* m_plugin; }; } // namespace EMStudio - - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/ToolBarPlugin.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/ToolBarPlugin.h index dcda6d2c1f..6c329a1320 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/ToolBarPlugin.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/ToolBarPlugin.h @@ -6,8 +6,7 @@ * */ -#ifndef __EMSTUDIO_TOOLBARPLUGIN_H -#define __EMSTUDIO_TOOLBARPLUGIN_H +#pragma once // include MCore #if !defined(Q_MOC_RUN) @@ -59,5 +58,3 @@ namespace EMStudio QPointer m_bar; }; } // namespace EMStudio - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/RenderPlugins/Source/OpenGLRender/GLWidget.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/RenderPlugins/Source/OpenGLRender/GLWidget.h index f821a7710e..e94fc0a060 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/RenderPlugins/Source/OpenGLRender/GLWidget.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/RenderPlugins/Source/OpenGLRender/GLWidget.h @@ -6,8 +6,7 @@ * */ -#ifndef __EMSTUDIO_GLWIDGET_H -#define __EMSTUDIO_GLWIDGET_H +#pragma once #if !defined(Q_MOC_RUN) #include "../RenderPluginsConfig.h" @@ -84,6 +83,3 @@ namespace EMStudio AZ::Debug::Timer m_perfTimer; }; } // namespace EMStudio - - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/RenderPlugins/Source/RenderPluginsConfig.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/RenderPlugins/Source/RenderPluginsConfig.h index 2bb4301781..b4b0299c7e 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/RenderPlugins/Source/RenderPluginsConfig.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/RenderPlugins/Source/RenderPluginsConfig.h @@ -6,8 +6,7 @@ * */ -#ifndef __EMSTUDIO_RENDERPLUGINSCONFIG_H -#define __EMSTUDIO_RENDERPLUGINSCONFIG_H +#pragma once #include @@ -27,5 +26,3 @@ enum { MEMCATEGORY_RENDERPLUGIN = 993 }; - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/AnimGraphPlugin.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/AnimGraphPlugin.h index 3510920d2c..14ecf6db34 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/AnimGraphPlugin.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/AnimGraphPlugin.h @@ -6,8 +6,7 @@ * */ -#ifndef __EMSTUDIO_ANIMGRAPHPLUGIN_H -#define __EMSTUDIO_ANIMGRAPHPLUGIN_H +#pragma once // include MCore #if !defined(Q_MOC_RUN) @@ -320,6 +319,3 @@ namespace EMStudio void UpdateWindowActionsCheckState(); }; } // namespace EMStudio - - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/DebugEventHandler.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/DebugEventHandler.h index 5e8e76b7ef..4786527f62 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/DebugEventHandler.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/DebugEventHandler.h @@ -6,8 +6,7 @@ * */ -#ifndef __EMSTUDIO_BENDSETUPINSTANCEDEBUGEVENTHANDLER_H -#define __EMSTUDIO_BENDSETUPINSTANCEDEBUGEVENTHANDLER_H +#pragma once // include MCore #if !defined(Q_MOC_RUN) @@ -45,5 +44,3 @@ namespace EMStudio private: }; } // namespace EMStudio - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/GameController.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/GameController.h index 47cfb9ddfc..b1925add10 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/GameController.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/GameController.h @@ -6,8 +6,7 @@ * */ -#ifndef __GAMECONTROLLER_H -#define __GAMECONTROLLER_H +#pragma once // include the required headers @@ -157,5 +156,3 @@ private: }; #endif - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/GameControllerWindow.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/GameControllerWindow.h index 059108625a..d3dda7196f 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/GameControllerWindow.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/GameControllerWindow.h @@ -6,8 +6,7 @@ * */ -#ifndef __EMSTUDIO_GAMECONTROLLERWINDOW_H -#define __EMSTUDIO_GAMECONTROLLERWINDOW_H +#pragma once #if !defined(Q_MOC_RUN) #include "../StandardPluginsConfig.h" @@ -190,5 +189,3 @@ namespace EMStudio void AutoSelectGameController(); }; } // namespace EMStudio - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/GraphWidgetCallback.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/GraphWidgetCallback.h index ff14484dc5..2ce33f9011 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/GraphWidgetCallback.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/GraphWidgetCallback.h @@ -6,8 +6,7 @@ * */ -#ifndef __EMSTUDIO_GRAPHWIDGETCALLBACK_H -#define __EMSTUDIO_GRAPHWIDGETCALLBACK_H +#pragma once // include required headers #include @@ -36,5 +35,3 @@ namespace EMStudio NodeGraphWidget* m_graphWidget; }; } // namespace EMStudio - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/Attachments/AttachmentNodesWindow.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/Attachments/AttachmentNodesWindow.h index 1743db3ab9..94cfaf275b 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/Attachments/AttachmentNodesWindow.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/Attachments/AttachmentNodesWindow.h @@ -6,8 +6,7 @@ * */ -#ifndef __EMSTUDIO_ATTACHMENTNODESWINDOW_H -#define __EMSTUDIO_ATTACHMENTNODESWINDOW_H +#pragma once // include MCore #if !defined(Q_MOC_RUN) @@ -80,6 +79,3 @@ namespace EMStudio QToolButton* m_removeNodesButton; }; } // namespace EMStudio - - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/Attachments/AttachmentsHierarchyWindow.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/Attachments/AttachmentsHierarchyWindow.h index 92a55668e8..e5ecbedc19 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/Attachments/AttachmentsHierarchyWindow.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/Attachments/AttachmentsHierarchyWindow.h @@ -6,8 +6,7 @@ * */ -#ifndef __EMSTUDIO_ATTACHMENTSHIERARCHYWINDOW_H -#define __EMSTUDIO_ATTACHMENTSHIERARCHYWINDOW_H +#pragma once // include MCore #if !defined(Q_MOC_RUN) @@ -42,6 +41,3 @@ namespace EMStudio QTreeWidget* m_hierarchy; }; } // namespace EMStudio - - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/Attachments/AttachmentsPlugin.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/Attachments/AttachmentsPlugin.h index edab3a9580..2d8d9632ba 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/Attachments/AttachmentsPlugin.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/Attachments/AttachmentsPlugin.h @@ -6,8 +6,7 @@ * */ -#ifndef __EMSTUDIO_ATTACHMENTSPLUGIN_H -#define __EMSTUDIO_ATTACHMENTSPLUGIN_H +#pragma once // include MCore #if !defined(Q_MOC_RUN) @@ -91,6 +90,3 @@ namespace EMStudio AttachmentNodesWindow* m_attachmentNodesWindow; }; } // namespace EMStudio - - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/LogWindow/LogWindowCallback.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/LogWindow/LogWindowCallback.h index 2e319e1dfa..586dfb8f44 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/LogWindow/LogWindowCallback.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/LogWindow/LogWindowCallback.h @@ -6,8 +6,7 @@ * */ -#ifndef __EMSTUDIO_LOGWINDOWCALLBACK_H -#define __EMSTUDIO_LOGWINDOWCALLBACK_H +#pragma once #if !defined(Q_MOC_RUN) #include "../StandardPluginsConfig.h" @@ -78,5 +77,3 @@ namespace EMStudio } // namespace EMStudio Q_DECLARE_METATYPE(MCore::LogCallback::ELogLevel) - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/LogWindow/LogWindowPlugin.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/LogWindow/LogWindowPlugin.h index 61b6ab4b8c..db8aa0ab24 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/LogWindow/LogWindowPlugin.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/LogWindow/LogWindowPlugin.h @@ -6,8 +6,7 @@ * */ -#ifndef __EMSTUDIO_LOGWINDOWPLUGIN_H -#define __EMSTUDIO_LOGWINDOWPLUGIN_H +#pragma once #if !defined(Q_MOC_RUN) #include @@ -65,5 +64,3 @@ namespace EMStudio AzQtComponents::FilteredSearchWidget* m_searchWidget; }; } // namespace EMStudio - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionWindow/MotionExtractionWindow.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionWindow/MotionExtractionWindow.h index 2f0bf63685..e4004a62aa 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionWindow/MotionExtractionWindow.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionWindow/MotionExtractionWindow.h @@ -6,8 +6,7 @@ * */ -#ifndef __EMSTUDIO_MOTIONEXTRACTIONWINDOW_H -#define __EMSTUDIO_MOTIONEXTRACTIONWINDOW_H +#pragma once // include MCore #if !defined(Q_MOC_RUN) @@ -88,6 +87,3 @@ namespace EMStudio void CreateWarningWidget(); }; } // namespace EMStudio - - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionWindow/MotionPropertiesWindow.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionWindow/MotionPropertiesWindow.h index eb1bcad3a3..3aa9133bb4 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionWindow/MotionPropertiesWindow.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionWindow/MotionPropertiesWindow.h @@ -6,8 +6,7 @@ * */ -#ifndef __EMSTUDIO_MOTIONPROPERTIESWINDOW_H -#define __EMSTUDIO_MOTIONPROPERTIESWINDOW_H +#pragma once // include MCore #if !defined(Q_MOC_RUN) @@ -48,6 +47,3 @@ namespace EMStudio void FinalizeSubProperties(); }; } // namespace EMStudio - - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionWindow/MotionRetargetingWindow.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionWindow/MotionRetargetingWindow.h index 3090a1f8bd..dbf39ccd84 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionWindow/MotionRetargetingWindow.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionWindow/MotionRetargetingWindow.h @@ -6,8 +6,7 @@ * */ -#ifndef __EMSTUDIO_MOTIONRETARGETINGWINDOW_H -#define __EMSTUDIO_MOTIONRETARGETINGWINDOW_H +#pragma once // include MCore #if !defined(Q_MOC_RUN) @@ -52,6 +51,3 @@ namespace EMStudio CommandSystem::SelectionList m_selectionList; }; } // namespace EMStudio - - -#endif diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/StandardPluginsConfig.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/StandardPluginsConfig.h index 80c51cc36f..8937c4efaf 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/StandardPluginsConfig.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/StandardPluginsConfig.h @@ -6,8 +6,7 @@ * */ -#ifndef __EMSTUDIO_STANDARDPLUGINSCONFIG_H -#define __EMSTUDIO_STANDARDPLUGINSCONFIG_H +#pragma once // include the EMotion FX config and mem categories on default #include @@ -32,5 +31,3 @@ enum MEMCATEGORY_STANDARDPLUGINS_ANIMGRAPH = 1001, MEMCATEGORY_STANDARDPLUGINS_RESEARCH = 1002 }; - -#endif diff --git a/Gems/EMotionFX/Code/MysticQt/Source/MysticQtManager.h b/Gems/EMotionFX/Code/MysticQt/Source/MysticQtManager.h index 9c8a73b92f..c313cd5489 100644 --- a/Gems/EMotionFX/Code/MysticQt/Source/MysticQtManager.h +++ b/Gems/EMotionFX/Code/MysticQt/Source/MysticQtManager.h @@ -6,8 +6,7 @@ * */ -#ifndef __MYSTICQT_MANAGER_H -#define __MYSTICQT_MANAGER_H +#pragma once // include required files #if !defined(Q_MOC_RUN) @@ -91,5 +90,3 @@ namespace MysticQt MCORE_INLINE const AZStd::string& GetAppDir() { return gMysticQtManager->GetAppDir(); } MCORE_INLINE const AZStd::string& GetDataDir() { return gMysticQtManager->GetDataDir(); } } // namespace MysticQt - -#endif From d20aa935ba9015299f5b606f81460c4d7aa278c5 Mon Sep 17 00:00:00 2001 From: Benjamin Jillich <43751992+amzn-jillich@users.noreply.github.com> Date: Fri, 17 Dec 2021 09:43:35 +0100 Subject: [PATCH 70/70] Quaternion to scaled-axis angle representation (and back) helpers (#6421) Direct conversion helpers for quaternion to the scaled axis-angle representation and back without the need to convert them first to the axis-angle format and manually scale (or normalize on the way back). This also avoids having to deal with the special case of an identity representation which is 0,0,0 in the scaled axis-angle format while our convention for axis-angle is 0,1,0 for the axis and 0 for the angle. Added unit tests that check the conversion round-trips from quaternion -> (scaled) axis-angle -> quaternion as well as comparing the scaled axis-angle representations from the direct helper functions as well as the axis-angle while manually scaling/normalizing. Signed-off-by: Benjamin Jillich --- .../AzCore/AzCore/Math/Quaternion.cpp | 22 +++- .../Framework/AzCore/AzCore/Math/Quaternion.h | 6 ++ .../AzCore/AzCore/Math/Quaternion.inl | 18 ++++ .../AzCore/Tests/Math/QuaternionTests.cpp | 102 ++++++++++++++++++ 4 files changed, 147 insertions(+), 1 deletion(-) diff --git a/Code/Framework/AzCore/AzCore/Math/Quaternion.cpp b/Code/Framework/AzCore/AzCore/Math/Quaternion.cpp index e06cd184ad..fac70bd05a 100644 --- a/Code/Framework/AzCore/AzCore/Math/Quaternion.cpp +++ b/Code/Framework/AzCore/AzCore/Math/Quaternion.cpp @@ -254,13 +254,13 @@ namespace AZ Method("CreateFromMatrix3x3", &Quaternion::CreateFromMatrix3x3)-> Method("CreateFromMatrix4x4", &Quaternion::CreateFromMatrix4x4)-> Method("CreateFromAxisAngle", &Quaternion::CreateFromAxisAngle)-> + Method("CreateFromScaledAxisAngle", &Quaternion::CreateFromScaledAxisAngle)-> Method("CreateShortestArc", &Quaternion::CreateShortestArc)-> Method("CreateFromEulerAnglesDegrees", &Quaternion::CreateFromEulerAnglesDegrees) ; } } - Quaternion Quaternion::CreateFromMatrix3x3(const Matrix3x3& m) { return CreateFromBasis(m.GetBasisX(), m.GetBasisY(), m.GetBasisZ()); @@ -430,4 +430,24 @@ namespace AZ outAngle = 0.0f; } } + + + Vector3 Quaternion::ConvertToScaledAxisAngle() const + { + // Take the log of the quaternion to convert it to the exponential map + // and multiply it by 2.0 to bring it into the scaled axis-angle representation. + const AZ::Vector3 imaginary = GetImaginary(); + const float length = imaginary.GetLength(); + if (length < AZ::Constants::FloatEpsilon) + { + return imaginary * 2.0f; + } + else + { + const float halfAngle = acosf(AZ::GetClamp(GetW(), -1.0f, 1.0f)); + + // Multiply by 2.0 to convert the half angle into the full one. + return halfAngle * 2.0f * (imaginary / length); + } + } } diff --git a/Code/Framework/AzCore/AzCore/Math/Quaternion.h b/Code/Framework/AzCore/AzCore/Math/Quaternion.h index f2c266ed3e..83e8012a62 100644 --- a/Code/Framework/AzCore/AzCore/Math/Quaternion.h +++ b/Code/Framework/AzCore/AzCore/Math/Quaternion.h @@ -77,6 +77,9 @@ namespace AZ static Quaternion CreateFromAxisAngle(const Vector3& axis, float angle); + //! Create a quaternion from a scaled axis-angle representation. + static Quaternion CreateFromScaledAxisAngle(const Vector3& scaledAxisAngle); + static Quaternion CreateShortestArc(const Vector3& v1, const Vector3& v2); //! Creates a quaternion using rotation in degrees about the axes. First rotated about the X axis, followed by the Y axis, then the Z axis. @@ -231,6 +234,9 @@ namespace AZ //! @param[out] outAngle A float rotation angle around the axis in radians. void ConvertToAxisAngle(Vector3& outAxis, float& outAngle) const; + //! Convert the quaternion into scaled axis-angle representation. + Vector3 ConvertToScaledAxisAngle() const; + //! Returns the imaginary (X/Y/Z) portion of the quaternion. Vector3 GetImaginary() const; diff --git a/Code/Framework/AzCore/AzCore/Math/Quaternion.inl b/Code/Framework/AzCore/AzCore/Math/Quaternion.inl index 82cd9078fa..37319ae146 100644 --- a/Code/Framework/AzCore/AzCore/Math/Quaternion.inl +++ b/Code/Framework/AzCore/AzCore/Math/Quaternion.inl @@ -109,6 +109,24 @@ namespace AZ } + AZ_MATH_INLINE Quaternion Quaternion::CreateFromScaledAxisAngle(const Vector3& scaledAxisAngle) + { + const AZ::Vector3 exponentialMap = scaledAxisAngle / 2.0f; + const float halfAngle = exponentialMap.GetLength(); + + if (halfAngle < AZ::Constants::FloatEpsilon) + { + return AZ::Quaternion::CreateFromVector3AndValue(exponentialMap, 1.0f).GetNormalized(); + } + else + { + float sin, cos; + SinCos(halfAngle, sin, cos); + return AZ::Quaternion::CreateFromVector3AndValue((sin / halfAngle) * exponentialMap, cos); + } + } + + AZ_MATH_INLINE void Quaternion::StoreToFloat4(float* values) const { Simd::Vec4::StoreUnaligned(values, m_value); diff --git a/Code/Framework/AzCore/Tests/Math/QuaternionTests.cpp b/Code/Framework/AzCore/Tests/Math/QuaternionTests.cpp index cbff646990..9ef38d7115 100644 --- a/Code/Framework/AzCore/Tests/Math/QuaternionTests.cpp +++ b/Code/Framework/AzCore/Tests/Math/QuaternionTests.cpp @@ -408,4 +408,106 @@ namespace UnitTest Matrix4x4 m = Matrix4x4::CreateFromQuaternion(rotQuat); AZ_TEST_ASSERT(m.IsClose(rotMatrix)); } + + class QuaternionScaledAxisAngleConversionFixture + : public ::testing::TestWithParam + { + public: + AZ::Quaternion GetAbs(const AZ::Quaternion& in) + { + // Take the shortest path for quaternions containing rotations bigger than 180.0°. + if (in.GetW() < 0.0f) + { + return -in; + } + + return in; + } + }; + + static const AZ::Quaternion RotationRepresentationConversionTestQuats[] = + { + AZ::Quaternion::CreateIdentity(), + -AZ::Quaternion::CreateIdentity(), + AZ::Quaternion::CreateRotationX(AZ::Constants::TwoPi), + AZ::Quaternion::CreateRotationY(AZ::Constants::Pi), + AZ::Quaternion::CreateRotationZ(AZ::Constants::HalfPi), + AZ::Quaternion::CreateRotationX(AZ::Constants::QuarterPi), + AZ::Quaternion(0.64f, 0.36f, 0.48f, 0.48f), + AZ::Quaternion(0.70f, -0.34f, 0.10f, 0.62f), + AZ::Quaternion(-0.38f, 0.34f, 0.70f, -0.50f), + AZ::Quaternion(0.70f, -0.34f, -0.38f, 0.50f), + AZ::Quaternion(0.00f, 0.00f, -0.28f, 0.96f), + AZ::Quaternion(0.24f, -0.64f, 0.72f, 0.12f), + AZ::Quaternion(-0.66f, 0.62f, 0.42f, 0.06f) + }; + + TEST_P(QuaternionScaledAxisAngleConversionFixture, ScaledAxisAngleQuatRoundtripTests) + { + const AZ::Quaternion testQuat = GetAbs(GetParam()); + + // Convert test quaternion to scaled axis-angle representation. + const AZ::Vector3 scaledAxisAngle = testQuat.ConvertToScaledAxisAngle(); + + // Convert the scaled axis-angle back into a quaternion. + AZ::Quaternion backFromScaledAxisAngle = AZ::Quaternion::CreateFromScaledAxisAngle(scaledAxisAngle); + + // Compare the original quaternion with the one after the conversion. + EXPECT_TRUE(testQuat.IsClose(backFromScaledAxisAngle, 1e-6f)); + } + + TEST_P(QuaternionScaledAxisAngleConversionFixture, AxisAngleQuatRoundtripTests) + { + const AZ::Quaternion testQuat = GetAbs(GetParam()); + + // Convert test quaternion to axis-angle representation. + AZ::Vector3 axis; + float angle; + testQuat.ConvertToAxisAngle(axis, angle); + + // Convert the axis-angle back into a quaternion and compare the original quaternion with the one after the conversion. + const AZ::Quaternion backFromAxisAngle = AZ::Quaternion::CreateFromAxisAngle(axis, angle); + EXPECT_TRUE(testQuat.IsClose(backFromAxisAngle, 1e-6f)); + } + + TEST_P(QuaternionScaledAxisAngleConversionFixture, CompareAxisAngleConversionTests) + { + const AZ::Quaternion testQuat = GetAbs(GetParam()); + + // Convert test quaternion to scaled axis-angle representation. + const AZ::Vector3 scaledAxisAngle = testQuat.ConvertToScaledAxisAngle(); + + // Convert test quaternion to axis-angle representation and scale it manually. + AZ::Vector3 axis; + float angle; + testQuat.ConvertToAxisAngle(axis, angle); + + // Compare the scaled result to the version from the helper that directly converts it to scaled axis-angle. + AZ::Vector3 scaledResult = axis*angle; + EXPECT_TRUE(scaledResult.IsClose(scaledAxisAngle, 1e-5f)); + } + + TEST_P(QuaternionScaledAxisAngleConversionFixture, CompareScaledAxisAngleConversionTests) + { + const AZ::Quaternion testQuat = GetAbs(GetParam()); + + // Convert test quaternion to axis-angle representation and scale it manually. + AZ::Vector3 axis; + float angle; + testQuat.ConvertToAxisAngle(axis, angle); + AZ::Vector3 scaledResult = axis*angle; + + // Special case handling for identity rotation. + AZ::Vector3 axisFromScaledResult = scaledResult.GetNormalized(); + float angleFromScaledResult = scaledResult.GetLength(); + if (AZ::IsClose(angleFromScaledResult, 0.0f)) + { + axisFromScaledResult = AZ::Vector3::CreateAxisY(); + } + + const AZ::Quaternion backFromAxisAngle = AZ::Quaternion::CreateFromAxisAngle(axisFromScaledResult, angleFromScaledResult); + EXPECT_TRUE(testQuat.IsClose(backFromAxisAngle, 1e-6f)); + } + + INSTANTIATE_TEST_CASE_P(MATH_Quaternion, QuaternionScaledAxisAngleConversionFixture, ::testing::ValuesIn(RotationRepresentationConversionTestQuats)); }