From e76ed67e950e5abd375ccfef1b551eb334d9e060 Mon Sep 17 00:00:00 2001 From: nggieber Date: Tue, 21 Sep 2021 18:34:15 -0700 Subject: [PATCH 01/19] Add no repositories added screen Signed-off-by: nggieber --- .../Resources/ProjectManager.qss | 11 +- .../Source/GemRepo/GemRepoAddDialog.cpp | 18 +++ .../Source/GemRepo/GemRepoAddDialog.h | 24 +++ .../Source/GemRepo/GemRepoScreen.cpp | 139 +++++++++++++----- .../Source/GemRepo/GemRepoScreen.h | 8 + .../project_manager_files.cmake | 2 + 6 files changed, 164 insertions(+), 38 deletions(-) create mode 100644 Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.cpp create mode 100644 Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.h diff --git a/Code/Tools/ProjectManager/Resources/ProjectManager.qss b/Code/Tools/ProjectManager/Resources/ProjectManager.qss index 30117d6636..52cc784336 100644 --- a/Code/Tools/ProjectManager/Resources/ProjectManager.qss +++ b/Code/Tools/ProjectManager/Resources/ProjectManager.qss @@ -556,17 +556,20 @@ QProgressBar::chunk { font-size: 12px; } +#gemRepoNoReposLabel { + font-size: 16px; +} + #gemRepoHeaderRefreshButton { background-color: transparent; qproperty-flat: true; qproperty-iconSize: 14px; } -#gemRepoHeaderAddButton { +#gemRepoAddButton { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #888888, stop: 1.0 #555555); qproperty-flat: true; - margin-right:30px; min-width:120px; max-width:120px; min-height:24px; @@ -576,11 +579,11 @@ QProgressBar::chunk { font-size:12px; font-weight:600; } -#gemRepoHeaderAddButton:hover { +#gemRepoAddButton:hover { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #999999, stop: 1.0 #666666); } -#gemRepoHeaderAddButton:pressed { +#gemRepoAddButton:pressed { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #555555, stop: 1.0 #777777); } diff --git a/Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.cpp b/Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.cpp new file mode 100644 index 0000000000..31e98a965b --- /dev/null +++ b/Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.cpp @@ -0,0 +1,18 @@ +/* + * 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 + +namespace O3DE::ProjectManager +{ + GemRepoAddDialog::GemRepoAddDialog(QWidget* parent) + : QDialog(parent) + { + + } +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.h b/Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.h new file mode 100644 index 0000000000..24c9b4b357 --- /dev/null +++ b/Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.h @@ -0,0 +1,24 @@ +/* + * 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 +#endif + +namespace O3DE::ProjectManager +{ + class GemRepoAddDialog + : public QDialog + { + public: + explicit GemRepoAddDialog(QWidget* parent = nullptr); + ~GemRepoAddDialog() = default; + }; +} // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.cpp b/Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.cpp index 82de53a0d0..5838abf643 100644 --- a/Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.cpp +++ b/Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.cpp @@ -20,6 +20,8 @@ #include #include #include +#include +#include namespace O3DE::ProjectManager { @@ -31,12 +33,109 @@ namespace O3DE::ProjectManager QVBoxLayout* vLayout = new QVBoxLayout(); vLayout->setMargin(0); vLayout->setSpacing(0); - setLayout(vLayout); + setLayout(vLayout); + + m_contentStack = new QStackedWidget(this); + + m_noRepoContent = CreateNoReposContent(); + m_contentStack->addWidget(m_noRepoContent); + + m_repoContent = CreateReposContent(); + m_contentStack->addWidget(m_repoContent); + + vLayout->addWidget(m_contentStack); + + Reinit(); + } + + void GemRepoScreen::Reinit() + { + m_gemRepoModel->clear(); + FillModel(); + + // If model contains any data show the repos + if (m_gemRepoModel->rowCount()) + { + m_contentStack->setCurrentWidget(m_repoContent); + } + else + { + m_contentStack->setCurrentWidget(m_noRepoContent); + } + + // Select the first entry after everything got correctly sized + QTimer::singleShot(200, [=]{ + QModelIndex firstModelIndex = m_gemRepoListView->model()->index(0,0); + m_gemRepoListView->selectionModel()->select(firstModelIndex, QItemSelectionModel::ClearAndSelect); + }); + } + + void GemRepoScreen::FillModel() + { + AZ::Outcome, AZStd::string> allGemRepoInfosResult = PythonBindingsInterface::Get()->GetAllGemRepoInfos(); + if (allGemRepoInfosResult.IsSuccess()) + { + // Add all available repos to the model + const QVector allGemRepoInfos = allGemRepoInfosResult.GetValue(); + for (const GemRepoInfo& gemRepoInfo : allGemRepoInfos) + { + m_gemRepoModel->AddGemRepo(gemRepoInfo); + } + } + else + { + QMessageBox::critical(this, tr("Operation failed"), QString("Cannot retrieve gem repos for engine.\n\nError:\n%2").arg(allGemRepoInfosResult.GetError().c_str())); + } + } + + QFrame* GemRepoScreen::CreateNoReposContent() + { + QFrame* contentFrame = new QFrame(this); + + QVBoxLayout* vLayout = new QVBoxLayout(); + vLayout->setAlignment(Qt::AlignHCenter); + vLayout->setMargin(0); + vLayout->setSpacing(0); + contentFrame->setLayout(vLayout); + + vLayout->addStretch(); + + QLabel* noRepoLabel = new QLabel(tr("No repositories have been added yet."), this); + noRepoLabel->setObjectName("gemRepoNoReposLabel"); + vLayout->addWidget(noRepoLabel); + vLayout->setAlignment(noRepoLabel, Qt::AlignHCenter); + + vLayout->addSpacing(20); + + // Size hint for button is wrong so horizontal layout with stretch is used to center it + QHBoxLayout* hLayout = new QHBoxLayout(); + hLayout->setMargin(0); + hLayout->setSpacing(0); + + hLayout->addStretch(); + + m_AddRepoButton = new QPushButton(tr("Add Repository"), this); + m_AddRepoButton->setObjectName("gemRepoAddButton"); + m_AddRepoButton->setMinimumWidth(120); + hLayout->addWidget(m_AddRepoButton); + + hLayout->addStretch(); + + vLayout->addLayout(hLayout); + + vLayout->addStretch(); + + return contentFrame; + } + + QFrame* GemRepoScreen::CreateReposContent() + { + QFrame* contentFrame = new QFrame(this); QHBoxLayout* hLayout = new QHBoxLayout(); hLayout->setMargin(0); hLayout->setSpacing(0); - vLayout->addLayout(hLayout); + contentFrame->setLayout(hLayout); hLayout->addSpacing(60); @@ -67,9 +166,11 @@ namespace O3DE::ProjectManager topMiddleHLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum)); m_AddRepoButton = new QPushButton(tr("Add Repository"), this); - m_AddRepoButton->setObjectName("gemRepoHeaderAddButton"); + m_AddRepoButton->setObjectName("gemRepoAddButton"); topMiddleHLayout->addWidget(m_AddRepoButton); + topMiddleHLayout->addSpacing(30); + middleVLayout->addLayout(topMiddleHLayout); middleVLayout->addSpacing(30); @@ -105,37 +206,7 @@ namespace O3DE::ProjectManager hLayout->addLayout(middleVLayout); hLayout->addWidget(m_gemRepoInspector); - Reinit(); - } - - void GemRepoScreen::Reinit() - { - m_gemRepoModel->clear(); - FillModel(); - - // Select the first entry after everything got correctly sized - QTimer::singleShot(200, [=]{ - QModelIndex firstModelIndex = m_gemRepoListView->model()->index(0,0); - m_gemRepoListView->selectionModel()->select(firstModelIndex, QItemSelectionModel::ClearAndSelect); - }); - } - - void GemRepoScreen::FillModel() - { - AZ::Outcome, AZStd::string> allGemRepoInfosResult = PythonBindingsInterface::Get()->GetAllGemRepoInfos(); - if (allGemRepoInfosResult.IsSuccess()) - { - // Add all available repos to the model - const QVector allGemRepoInfos = allGemRepoInfosResult.GetValue(); - for (const GemRepoInfo& gemRepoInfo : allGemRepoInfos) - { - m_gemRepoModel->AddGemRepo(gemRepoInfo); - } - } - else - { - QMessageBox::critical(this, tr("Operation failed"), QString("Cannot retrieve gem repos for engine.\n\nError:\n%2").arg(allGemRepoInfosResult.GetError().c_str())); - } + return contentFrame; } ProjectManagerScreen GemRepoScreen::GetScreenEnum() diff --git a/Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.h b/Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.h index b5316db84f..ab679ad39b 100644 --- a/Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.h +++ b/Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.h @@ -16,6 +16,8 @@ QT_FORWARD_DECLARE_CLASS(QLabel) QT_FORWARD_DECLARE_CLASS(QPushButton) QT_FORWARD_DECLARE_CLASS(QHeaderView) QT_FORWARD_DECLARE_CLASS(QTableWidget) +QT_FORWARD_DECLARE_CLASS(QFrame) +QT_FORWARD_DECLARE_CLASS(QStackedWidget) namespace O3DE::ProjectManager { @@ -36,6 +38,12 @@ namespace O3DE::ProjectManager private: void FillModel(); + QFrame* CreateNoReposContent(); + QFrame* CreateReposContent(); + + QStackedWidget* m_contentStack = nullptr; + QFrame* m_noRepoContent; + QFrame* m_repoContent; QTableWidget* m_gemRepoHeaderTable = nullptr; QHeaderView* m_gemRepoListHeader = nullptr; diff --git a/Code/Tools/ProjectManager/project_manager_files.cmake b/Code/Tools/ProjectManager/project_manager_files.cmake index 7a336972e0..31686faa2f 100644 --- a/Code/Tools/ProjectManager/project_manager_files.cmake +++ b/Code/Tools/ProjectManager/project_manager_files.cmake @@ -102,6 +102,8 @@ set(FILES Source/GemCatalog/GemSortFilterProxyModel.cpp Source/GemRepo/GemRepoScreen.h Source/GemRepo/GemRepoScreen.cpp + Source/GemRepo/GemRepoAddDialog.h + Source/GemRepo/GemRepoAddDialog.cpp Source/GemRepo/GemRepoInfo.h Source/GemRepo/GemRepoInfo.cpp Source/GemRepo/GemRepoItemDelegate.h From 09ce73aa44303cfd4622c578f311bc41c6fef65b Mon Sep 17 00:00:00 2001 From: sweeneys Date: Wed, 22 Sep 2021 17:50:12 -0700 Subject: [PATCH 02/19] Initial update for this module's unit tests on Linux Signed-off-by: sweeneys --- Tools/LyTestTools/ly_test_tools/__init__.py | 17 +- .../_internal/managers/platforms/linux.py | 78 ++++++ .../ly_test_tools/builtin/helpers.py | 7 +- .../environment/process_utils.py | 10 +- .../ly_test_tools/environment/reg_cleaner.py | 4 +- .../ly_test_tools/environment/watchdog.py | 16 +- .../ly_test_tools/launchers/__init__.py | 4 +- .../launchers/platforms/linux/__init__.py | 6 + .../launchers/platforms/linux/launcher.py | 224 ++++++++++++++++++ .../tests/unit/test_builtin_helpers.py | 23 +- .../tests/unit/test_file_system.py | 28 --- .../tests/unit/test_launcher_base.py | 11 +- .../tests/unit/test_launcher_linux.py | 63 +++++ .../tests/unit/test_process_utils.py | 2 +- 14 files changed, 417 insertions(+), 76 deletions(-) create mode 100644 Tools/LyTestTools/ly_test_tools/_internal/managers/platforms/linux.py create mode 100644 Tools/LyTestTools/ly_test_tools/launchers/platforms/linux/__init__.py create mode 100644 Tools/LyTestTools/ly_test_tools/launchers/platforms/linux/launcher.py create mode 100644 Tools/LyTestTools/tests/unit/test_launcher_linux.py diff --git a/Tools/LyTestTools/ly_test_tools/__init__.py b/Tools/LyTestTools/ly_test_tools/__init__.py index 3fb84e9fe5..58340342ab 100755 --- a/Tools/LyTestTools/ly_test_tools/__init__.py +++ b/Tools/LyTestTools/ly_test_tools/__init__.py @@ -11,16 +11,16 @@ import sys logger = logging.getLogger(__name__) -# Supported platforms. +# Supported platforms ALL_PLATFORM_OPTIONS = ['android', 'ios', 'linux', 'mac', 'windows'] -ALL_LAUNCHER_OPTIONS = ['android', 'base', 'mac', 'windows', 'windows_editor', 'windows_dedicated', 'windows_generic'] +ALL_LAUNCHER_OPTIONS = ['android', 'base', 'linux', 'mac', 'windows', 'windows_editor', 'windows_dedicated', 'windows_generic'] ANDROID = False IOS = False # Not implemented - see SPEC-2505 LINUX = sys.platform.startswith('linux') # Not implemented - see SPEC-2501 MAC = sys.platform.startswith('darwin') WINDOWS = sys.platform.startswith('win') -# Detect platforms. +# Detect available platforms HOST_OS_PLATFORM = 'unknown' HOST_OS_EDITOR = 'unknown' HOST_OS_DEDICATED_SERVER = 'unknown' @@ -51,9 +51,12 @@ elif MAC: from ly_test_tools.launchers import MacLauncher LAUNCHERS['mac'] = MacLauncher elif LINUX: - logger.warning(f'Linux operating system is currently not supported, LyTestTools only supports Windows and Mac.') HOST_OS_PLATFORM = 'linux' - HOST_OS_EDITOR = NotImplementedError('LyTestTools does not yet support Linux editor') - HOST_OS_DEDICATED_SERVER = NotImplementedError('LyTestTools does not yet support Linux dedicated server') + HOST_OS_EDITOR = 'linux_editor' + HOST_OS_DEDICATED_SERVER = 'linux_dedicated' + from ly_test_tools.launchers.platforms.linux.launcher import (LinuxLauncher, LinuxEditor, DedicatedLinuxLauncher) + LAUNCHERS['linux'] = LinuxLauncher + LAUNCHERS['linux_editor'] = LinuxEditor + LAUNCHERS['linux_dedicated'] = DedicatedLinuxLauncher else: - logger.warning(f'WARNING: LyTestTools only supports Windows and Mac, got HOST_OS_PLATFORM: "{HOST_OS_PLATFORM}".') + logger.warning(f'WARNING: LyTestTools only supports Windows, Mac, and Linux. Unexpectedly detected HOST_OS_PLATFORM: "{HOST_OS_PLATFORM}".') diff --git a/Tools/LyTestTools/ly_test_tools/_internal/managers/platforms/linux.py b/Tools/LyTestTools/ly_test_tools/_internal/managers/platforms/linux.py new file mode 100644 index 0000000000..0cf213c746 --- /dev/null +++ b/Tools/LyTestTools/ly_test_tools/_internal/managers/platforms/linux.py @@ -0,0 +1,78 @@ +""" +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 + +Linux directory and workspace mappings +""" + +import os +import logging + +from ly_test_tools._internal.managers.workspace import AbstractWorkspaceManager +from ly_test_tools._internal.managers.abstract_resource_locator import AbstractResourceLocator + +logger = logging.getLogger(__name__) + +CACHE_DIR = 'linux' +CONFIG_FILE = 'system_linux_pc.cfg' + + +class _LinuxResourceManager(AbstractResourceLocator): + """ + Override for locating resources in a Linux operating system running LyTestTools. + """ + def __init__(self, build_directory: str, project: str): + pass + + def platform_config_file(self): + """ + :return: path to the platform config file + """ + return os.path.join(self.engine_root(), CONFIG_FILE) + + def platform_cache(self): + """ + :return: path to cache for the Linux operating system + """ + return os.path.join(self.project_cache(), CACHE_DIR) + + def project_log(self): + """ + :return: path to 'log' dir in the platform cache dir + """ + return os.path.join(self.project(), 'user', 'log') + + def project_screenshots(self): + """ + :return: path to 'screenshot' dir in the platform cache dir + """ + return os.path.join(self.project(), 'user', 'ScreenShots') + + def editor_log(self): + """ + :return: path to editor.log + """ + return os.path.join(self.project_log(), "editor.log") + + +class LinuxWorkspaceManager(AbstractWorkspaceManager): + """ + A Mac host WorkspaceManager. Contains Mac overridden functions for the AbstractWorkspaceManager class. + Also creates a Mac host ResourceLocator for directory and build mappings. + """ + def __init__( + self, + build_directory=None, + project=None, + tmp_path=None, + output_path=None, + ): + # Type: (str,str,str,str) -> None + super(LinuxWorkspaceManager, self).__init__( + _LinuxResourceManager(build_directory, project), + project=project, + tmp_path=tmp_path, + output_path=output_path, + ) diff --git a/Tools/LyTestTools/ly_test_tools/builtin/helpers.py b/Tools/LyTestTools/ly_test_tools/builtin/helpers.py index f40c8c2234..59117a42f9 100755 --- a/Tools/LyTestTools/ly_test_tools/builtin/helpers.py +++ b/Tools/LyTestTools/ly_test_tools/builtin/helpers.py @@ -9,7 +9,7 @@ Helper file for assisting in building workspaces and setting up LTT with the cur import ly_test_tools._internal.pytest_plugin as pytest_plugin import ly_test_tools._internal.managers.workspace as internal_workspace -from ly_test_tools import MAC, WINDOWS +from ly_test_tools import LINUX, MAC, WINDOWS import os, stat @@ -47,6 +47,11 @@ def create_builtin_workspace( elif MAC: from ly_test_tools._internal.managers.platforms.mac import MacWorkspaceManager build_class = MacWorkspaceManager + elif LINUX: + from ly_test_tools._internal.managers.platforms.linux import LinuxWorkspaceManager + build_class = LinuxWorkspaceManager + else: + raise NotImplementedError("No workspace manager found for current Operating System") instance = build_class( build_directory=build_directory, diff --git a/Tools/LyTestTools/ly_test_tools/environment/process_utils.py b/Tools/LyTestTools/ly_test_tools/environment/process_utils.py index be2f279512..1c0be299a8 100755 --- a/Tools/LyTestTools/ly_test_tools/environment/process_utils.py +++ b/Tools/LyTestTools/ly_test_tools/environment/process_utils.py @@ -12,8 +12,8 @@ import psutil import subprocess import ctypes +import ly_test_tools import ly_test_tools.environment.waiter as waiter -from ly_test_tools import WINDOWS, MAC logger = logging.getLogger(__name__) _PROCESS_OUTPUT_ENCODING = 'utf-8' @@ -182,7 +182,7 @@ def process_is_unresponsive(name): :param name: the name of the process to check :return: True if the specified process is unresponsive and False otherwise """ - if WINDOWS: + if ly_test_tools.WINDOWS: output = check_output(['tasklist', '/FI', f'IMAGENAME eq {name}', '/FI', 'STATUS eq NOT RESPONDING']) @@ -194,7 +194,7 @@ def process_is_unresponsive(name): return True logger.debug(f"Process '{name}' was not unresponsive.") return False - elif MAC: + else: cmd = ["ps", "-axc", "-o", "command,state"] output = check_output(cmd) for line in output.splitlines()[1:]: @@ -209,8 +209,6 @@ def process_is_unresponsive(name): return True logger.debug(f"Process '{name}' was not unresponsive.") return False - else: - raise NotImplementedError('Only Windows and Mac hosts are supported.') def check_output(command, **kwargs): @@ -406,7 +404,7 @@ def close_windows_process(pid, timeout=20, raise_on_missing=False): :param pid: the pid of the process to kill :param raise_on_missing: if set to True, raise RuntimeError if the process does not already exist """ - if not WINDOWS: + if not ly_test_tools.WINDOWS: raise NotImplementedError("close_windows_process() is only implemented on Windows.") if pid is None: diff --git a/Tools/LyTestTools/ly_test_tools/environment/reg_cleaner.py b/Tools/LyTestTools/ly_test_tools/environment/reg_cleaner.py index a3dee1319f..1ffd5a1b4c 100755 --- a/Tools/LyTestTools/ly_test_tools/environment/reg_cleaner.py +++ b/Tools/LyTestTools/ly_test_tools/environment/reg_cleaner.py @@ -8,8 +8,10 @@ Reg cleaner: tools for working with the lumberyard windows registry keys """ import logging import os -import winreg +import ly_test_tools +if ly_test_tools.WINDOWS: + import winreg # OS-specific module availability, must be mocked if this file is accessed elsewhere e.g. unit tests import ly_test_tools.environment.process_utils as process_utils CONST_LY_REG = r'SOFTWARE\O3DE\O3DE' diff --git a/Tools/LyTestTools/ly_test_tools/environment/watchdog.py b/Tools/LyTestTools/ly_test_tools/environment/watchdog.py index 58ac87d9e7..6186a3d354 100755 --- a/Tools/LyTestTools/ly_test_tools/environment/watchdog.py +++ b/Tools/LyTestTools/ly_test_tools/environment/watchdog.py @@ -14,8 +14,8 @@ import re import psutil import time +import ly_test_tools import ly_test_tools.environment.process_utils as process_utils -from ly_test_tools import WINDOWS logger = logging.getLogger(__name__) @@ -28,7 +28,7 @@ class Watchdog(object): DEFAULT_JOIN_TIMEOUT = 10 # seconds def __init__(self, bool_fn, interval=1, raise_on_condition=True, name='ly_test_watchdog', error_message=''): - # type: (func, int, bool, str, str) -> Watchdog + # type: (function, int, bool, str, str) -> Watchdog """ A Watchdog object that takes in a boolean function. It spawns a thread that loops over the boolean function until it returns True. If the boolean function returns True, then a flag will be set and an exception @@ -44,7 +44,7 @@ class Watchdog(object): """ self.caught_failure = False self.name = name - + self._bool_fn = bool_fn self._interval = interval self._raise_on_condition = raise_on_condition @@ -66,7 +66,7 @@ class Watchdog(object): self.caught_failure = False def stop(self, join_timeout=DEFAULT_JOIN_TIMEOUT): - # type: () -> None + # type: (int) -> None """ Stops the watchdog's thread if it's executing by enabling its shutdown Event. If the target function's condition was found, then it will either raise an exception or log an error message. @@ -106,7 +106,7 @@ class Watchdog(object): """ The main function of the watchdog thread. It will repeatedly call its target function until the target function returns True, in which it will set the self.caught_failure attribute to True. - + :return: None """ while True: @@ -128,7 +128,7 @@ class ProcessUnresponsiveWatchdog(Watchdog): Watches a process ID and reports if it is unresponsive for a given timeout. If multiple processes need to be watched, then multiple watchdogs should be instantiated. Note: This is for windows OS only. - + :param process_id: The process id to watch :param interval: The interval (in seconds) for how frequently the bool_fn is called on the thread. :param raise_on_condition: If True, raises an exception when bool_fn returns True. If False, logs an error @@ -138,8 +138,8 @@ class ProcessUnresponsiveWatchdog(Watchdog): :param unresponsive_timeout_seconds: How long the process needs to be unresponsive for in order for the watchdog to report (in seconds). """ - if not WINDOWS: - raise (NotImplementedError, "Process watchdog is only implemented on Windows.") + if not ly_test_tools.WINDOWS: + pass # TODO add non-windows support self._unresponsive_timeout = unresponsive_timeout_seconds self._calculated_timeout_point = None self._pid = process_id diff --git a/Tools/LyTestTools/ly_test_tools/launchers/__init__.py b/Tools/LyTestTools/ly_test_tools/launchers/__init__.py index bb299d89f9..94b712bade 100755 --- a/Tools/LyTestTools/ly_test_tools/launchers/__init__.py +++ b/Tools/LyTestTools/ly_test_tools/launchers/__init__.py @@ -6,7 +6,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT """ from ly_test_tools.launchers.platforms.base import Launcher +from ly_test_tools.launchers.platforms.linux.launcher import LinuxLauncher, LinuxEditor, DedicatedLinuxLauncher from ly_test_tools.launchers.platforms.mac.launcher import MacLauncher -from ly_test_tools.launchers.platforms.win.launcher import ( - WinLauncher, DedicatedWinLauncher, WinEditor, WinGenericLauncher) +from ly_test_tools.launchers.platforms.win.launcher import WinLauncher, DedicatedWinLauncher, WinEditor, WinGenericLauncher from ly_test_tools.launchers.platforms.android.launcher import AndroidLauncher diff --git a/Tools/LyTestTools/ly_test_tools/launchers/platforms/linux/__init__.py b/Tools/LyTestTools/ly_test_tools/launchers/platforms/linux/__init__.py new file mode 100644 index 0000000000..f5193b300e --- /dev/null +++ b/Tools/LyTestTools/ly_test_tools/launchers/platforms/linux/__init__.py @@ -0,0 +1,6 @@ +""" +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 +""" diff --git a/Tools/LyTestTools/ly_test_tools/launchers/platforms/linux/launcher.py b/Tools/LyTestTools/ly_test_tools/launchers/platforms/linux/launcher.py new file mode 100644 index 0000000000..47a538d90e --- /dev/null +++ b/Tools/LyTestTools/ly_test_tools/launchers/platforms/linux/launcher.py @@ -0,0 +1,224 @@ +""" +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 + +Linux compatible launcher +""" + +import logging +import os +import subprocess + +import ly_test_tools.environment.waiter +import ly_test_tools.launchers.exceptions + +from ly_test_tools.launchers.platforms.base import Launcher +from ly_test_tools.launchers.exceptions import TeardownError, ProcessNotStartedError +from tempfile import TemporaryFile + +log = logging.getLogger(__name__) + + +class LinuxLauncher(Launcher): + def __init__(self, build, args): + super(LinuxLauncher, self).__init__(build, args) + self._proc = None + self._ret_code = None + self._tmpout = None + log.debug("Initialized Linux Launcher") + + def binary_path(self): + """ + Return full path to the launcher for this build's configuration and project + + :return: full path to .GameLauncher + """ + assert self.workspace.project is not None + return os.path.join(self.workspace.paths.build_directory(), f"{self.workspace.project}.GameLauncher") + + def setup(self, backupFiles=True, launch_ap=True, configure_settings=True): + """ + Perform setup of this launcher, must be called before launching. + Subclasses should call its parent's setup() before calling its own code, unless it changes configuration files + + :param backupFiles: Bool to backup setup files + :param lauch_ap: Bool to lauch the asset processor + :return: None + """ + # Backup + if backupFiles: + self.backup_settings() + + # Base setup defaults to None + if launch_ap is None: + launch_ap = True + + # Modify and re-configure + if configure_settings: + self.configure_settings() + super(LinuxLauncher, self).setup(backupFiles, launch_ap) + + def launch(self): + """ + Launch the executable and track the subprocess + + :return: None + """ + command = [self.binary_path()] + self.args + self._tmpout = TemporaryFile() + self._proc = subprocess.Popen(command, stdout=self._tmpout, stderr=self._tmpout, universal_newlines=True) + log.debug(f"Started Linux Launcher with command: {command}") + + def get_output(self, encoding="utf-8"): + if self._tmpout is None: + raise ProcessNotStartedError("Process must be started before retrieving output") + + self._tmpout.seek(0) + return self._tmpout.read().decode(encoding) + + def teardown(self): + """ + Perform teardown of this launcher, undoing actions taken by calling setup() + Subclasses should call its parent's teardown() after performing its own teardown. + + :return: None + """ + self.restore_settings() + super(LinuxLauncher, self).teardown() + + def kill(self): + """ + This is a hard kill, and then wait to make sure until it actually ended. + + :return: None + """ + if self._proc is not None: + self._proc.kill() + ly_test_tools.environment.waiter.wait_for( + lambda: not self.is_alive(), + exc=ly_test_tools.launchers.exceptions.TeardownError( + f"Unable to terminate active Linux Launcher with process ID {self._proc.pid}") + ) + self._proc = None + self._ret_code = None + log.debug("Linux Launcher terminated successfully") + + def is_alive(self): + """ + Check the process to verify activity. Side effect of setting self.proc to None if it has ended. + + :return: None + """ + if self._proc is None: + return False + else: + if self._proc.poll() is not None: + self._ret_code = self._proc.poll() + self._proc = None + return False + return True + + def get_pid(self): + # type: () -> int or None + """ + Returns the pid of the launcher process if it exists, else it returns None + + :return: process id or None + """ + if self._proc: + return self._proc.pid + return None + + def get_returncode(self): + # type: () -> int or None + """ + Returns the returncode of the launcher process if it exists, else return None. + The returncode attribute is set when the process is terminated. + + :return: The returncode of the launcher's process + """ + if self._proc: + return self._proc.poll() + else: + return self._ret_code + + def check_returncode(self): + # type: () -> None + """ + Checks the returncode of the launcher if it exists. Raises a CrashError if the returncode is non-zero. Returns + None otherwise. This function must be called after exiting the launcher properly and NOT using its provided + teardown(). Provided teardown() will always return a non-zero returncode and should not be checked. + + :return: None + """ + return_code = self.get_returncode() + if return_code != 0: + log.error(f"Launcher exited with non-zero return code: {return_code}") + raise ly_test_tools.launchers.exceptions.CrashError() + return None + + def configure_settings(self): + """ + Configures system level settings and syncs the launcher to the targeted console IP. + + :return: None + """ + # Update settings via the settings registry to avoid modifying the bootstrap.cfg + host_ip = '127.0.0.1' + self.args.append(f'--regset="/Amazon/AzCore/Bootstrap/project_path={self.workspace.paths.project()}"') + self.args.append(f'--regset="/Amazon/AzCore/Bootstrap/remote_ip={host_ip}"') + self.args.append('--regset="/Amazon/AzCore/Bootstrap/wait_for_connect=1"') + self.args.append(f'--regset="/Amazon/AzCore/Bootstrap/allowed_list={host_ip}"') + + self.workspace.settings.modify_platform_setting("r_AssetProcessorShaderCompiler", 1) + self.workspace.settings.modify_platform_setting("r_ShaderCompilerServer", host_ip) + self.workspace.settings.modify_platform_setting("log_RemoteConsoleAllowedAddresses", host_ip) + + +class DedicatedLinuxLauncher(LinuxLauncher): + + def setup(self, backupFiles=True, launch_ap=False): + """ + Perform setup of this launcher, must be called before launching. + Subclasses should call its parent's setup() before calling its own code, unless it changes configuration files + + :param backupFiles: Bool to backup setup files + :param lauch_ap: Bool to lauch the asset processor + :return: None + """ + # Base setup defaults to None + if launch_ap is None: + launch_ap = False + + super(DedicatedLinuxLauncher, self).setup(backupFiles, launch_ap) + + def binary_path(self): + """ + Return full path to the dedicated server launcher for the build directory. + + :return: full path to Launcher_Server + """ + assert self.workspace.project is not None, ( + 'Project cannot be NoneType - please specify a project name string.') + return os.path.join(f"{self.workspace.paths.build_directory()}", + f"{self.workspace.project}.ServerLauncher") + + +class LinuxEditor(LinuxLauncher): + + def __init__(self, build, args): + super(LinuxEditor, self).__init__(build, args) + self.args.append('--regset="/Amazon/Settings/EnableSourceControl=false"') + self.args.append('--regset="/Amazon/AWS/Preferences/AWSAttributionConsentShown=true"') + self.args.append('--regset="/Amazon/AWS/Preferences/AWSAttributionEnabled=false"') + + def binary_path(self): + """ + Return full path to the Editor for this build's configuration and project + + :return: full path to Editor + """ + assert self.workspace.project is not None + return os.path.join(self.workspace.paths.build_directory(), "Editor") diff --git a/Tools/LyTestTools/tests/unit/test_builtin_helpers.py b/Tools/LyTestTools/tests/unit/test_builtin_helpers.py index 9eb8a1703d..1c583632a8 100755 --- a/Tools/LyTestTools/tests/unit/test_builtin_helpers.py +++ b/Tools/LyTestTools/tests/unit/test_builtin_helpers.py @@ -8,7 +8,6 @@ Unit tests for ly_test_tools.builtin.helpers functions. """ import unittest.mock as mock import os - import pytest import ly_test_tools.builtin.helpers @@ -112,10 +111,11 @@ class TestBuiltinHelpers(object): ly_test_tools._internal.managers.abstract_resource_locator._find_engine_root( initial_path='mock_dev_dir') + @mock.patch('ly_test_tools._internal.managers.workspace.AbstractWorkspaceManager.teardown') @mock.patch('ly_test_tools._internal.managers.workspace.AbstractWorkspaceManager.setup') @mock.patch('ly_test_tools._internal.managers.artifact_manager.NullArtifactManager', mock.MagicMock()) @mock.patch('os.path.exists', mock.MagicMock(return_value=True)) - def test_SetupBuiltinWorkspace_ValidWorkspaceSetup_ReturnsWorkspaceObject(self, mock_setup): + def test_SetupTeardownBuiltinWorkspace_ValidWorkspaceSetup_ReturnsWorkspaceObject(self, mock_setup, mock_teardown): mock_test_name = 'mock_test_name' mock_test_amount = 10 mock_workspace = ly_test_tools.builtin.helpers.create_builtin_workspace( @@ -125,25 +125,16 @@ class TestBuiltinHelpers(object): output_path='mock_output_path', ) - under_test = ly_test_tools.builtin.helpers.setup_builtin_workspace( + setup_test = ly_test_tools.builtin.helpers.setup_builtin_workspace( mock_workspace, mock_test_name, mock_test_amount) - assert under_test == mock_workspace + assert setup_test == mock_workspace assert mock_setup.call_count == 1 mock_workspace.artifact_manager.set_test_name.assert_called_with( test_name=mock_test_name, amount=mock_test_amount) - @mock.patch('ly_test_tools._internal.managers.workspace.AbstractWorkspaceManager.teardown') - @mock.patch('os.path.exists', mock.MagicMock(return_value=True)) - def test_TeardownBuiltinWorkspace_ValidWorkspaceSetup_ReturnsWorkspaceObject(self, mock_teardown): - mock_workspace = ly_test_tools.builtin.helpers.create_builtin_workspace( - build_directory='build_directory', - project='mock_project', - tmp_path='mock_tmp_path', - output_path='mock_output_path', - ) + # Teardown not tested separately due to patched MockedAbstractResourceLocator creating a StopIteration error on Linux + teardown_test = ly_test_tools.builtin.helpers.teardown_builtin_workspace(mock_workspace) - under_test = ly_test_tools.builtin.helpers.teardown_builtin_workspace(mock_workspace) - - assert under_test == mock_workspace + assert teardown_test == mock_workspace assert mock_teardown.call_count == 1 diff --git a/Tools/LyTestTools/tests/unit/test_file_system.py b/Tools/LyTestTools/tests/unit/test_file_system.py index 80c7e51f53..53ca5a700e 100755 --- a/Tools/LyTestTools/tests/unit/test_file_system.py +++ b/Tools/LyTestTools/tests/unit/test_file_system.py @@ -208,20 +208,6 @@ class TestUnZip(unittest.TestCase): self.assertEqual(path, expected_path) - @mock.patch('os.path.exists') - @mock.patch('ly_test_tools.environment.file_system.check_free_space') - @mock.patch('os.path.join') - def test_Unzip_ReleaseBuild_JoinCalledWithNoPathNoExtension(self, mock_join, mock_check_free, mock_exists): - - path = '' - self.src_path = r'C:\packages\lumberyard-1.2.0.3-54321-pc-1234.zip' - mock_exists.return_value = self.exists - - with mock.patch(self.decomp_obj_name, self.mock_decomp): - path = self.call_decomp(self.dest_path, self.src_path) - - mock_join.assert_called_once_with(self.dest_path, 'lumberyard-1.2.0.3-54321-pc-1234') - @mock.patch('ly_test_tools.environment.file_system.logger') @mock.patch('os.path.exists') @mock.patch('ly_test_tools.environment.file_system.check_free_space') @@ -375,20 +361,6 @@ class TestUnTgz(unittest.TestCase): self.assertEqual(path, expected_path) - @mock.patch('ly_test_tools.environment.file_system.check_free_space') - @mock.patch('os.path.join') - @mock.patch('os.stat') - def test_Untgz_ReleaseBuild_JoinCalledWithNoPathNoExtension(self, mock_stat, mock_join, mock_check_free): - - mock_stat.return_value = self.src_stat - - path = '' - self.src_path = r'C:\packages\lumberyard-1.2.0.3-54321-pc-1234.zip' - with mock.patch(self.decomp_obj_name, self.mock_decomp): - path = self.call_decomp(self.dest_path, self.src_path) - - mock_join.assert_called_once_with(self.dest_path, 'lumberyard-1.2.0.3-54321-pc-1234') - @mock.patch('ly_test_tools.environment.file_system.logger') @mock.patch('os.path.exists') @mock.patch('ly_test_tools.environment.file_system.check_free_space') diff --git a/Tools/LyTestTools/tests/unit/test_launcher_base.py b/Tools/LyTestTools/tests/unit/test_launcher_base.py index 8d7daaab72..1ab9129a7d 100755 --- a/Tools/LyTestTools/tests/unit/test_launcher_base.py +++ b/Tools/LyTestTools/tests/unit/test_launcher_base.py @@ -204,21 +204,20 @@ class TestLauncherBuilder(object): """ def test_CreateLauncher_DummyWorkspace_DefaultLauncher(self): dummy_workspace = mock.MagicMock() - launcher_platform = 'windows' under_test = ly_test_tools.launchers.launcher_helper.create_launcher( - dummy_workspace, launcher_platform) + dummy_workspace, ly_test_tools.HOST_OS_EDITOR) assert isinstance(under_test, ly_test_tools.launchers.Launcher) def test_CreateDedicateLauncher_DummyWorkspace_DefaultLauncher(self): dummy_workspace = mock.MagicMock() - launcher_platform = 'windows_dedicated' under_test = ly_test_tools.launchers.launcher_helper.create_dedicated_launcher( - dummy_workspace, launcher_platform) + dummy_workspace, ly_test_tools.HOST_OS_DEDICATED_SERVER) assert isinstance(under_test, ly_test_tools.launchers.Launcher) + @mock.patch('os.path.exists', mock.MagicMock(return_value=True)) def test_CreateEditor_DummyWorkspace_DefaultLauncher(self): dummy_workspace = mock.MagicMock() - launcher_platform = 'windows_editor' + dummy_workspace.paths.build_directory.return_value = 'dummy' under_test = ly_test_tools.launchers.launcher_helper.create_editor( - dummy_workspace, launcher_platform) + dummy_workspace, ly_test_tools.HOST_OS_GENERIC_EXECUTABLE) assert isinstance(under_test, ly_test_tools.launchers.Launcher) diff --git a/Tools/LyTestTools/tests/unit/test_launcher_linux.py b/Tools/LyTestTools/tests/unit/test_launcher_linux.py new file mode 100644 index 0000000000..2a6c6f7014 --- /dev/null +++ b/Tools/LyTestTools/tests/unit/test_launcher_linux.py @@ -0,0 +1,63 @@ +""" +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 + +Unit Tests for linux launcher-wrappers: all are sanity code-path tests, since no interprocess actions should be taken +""" +import os +import pytest +import unittest.mock as mock + +import ly_test_tools.launchers + +pytestmark = pytest.mark.SUITE_smoke + + +class TestLinuxLauncher(object): + + def test_Construct_TestDoubles_LinuxLauncherCreated(self): + under_test = ly_test_tools.launchers.LinuxLauncher(mock.MagicMock(), ["some_args"]) + assert isinstance(under_test, ly_test_tools.launchers.Launcher) + assert isinstance(under_test, ly_test_tools.launchers.LinuxLauncher) + + def test_BinaryPath_DummyPath_AddPathToApp(self): + dummy_path = "dummy_workspace_path" + dummy_project = "dummy_project" + mock_workspace = mock.MagicMock() + mock_workspace.paths.build_directory.return_value = dummy_path + mock_workspace.project = dummy_project + launcher = ly_test_tools.launchers.LinuxLauncher(mock_workspace, ["some_args"]) + + under_test = launcher.binary_path() + expected = os.path.join(dummy_path, f"{dummy_project}.GameLauncher") + + assert under_test == expected + + @mock.patch('ly_test_tools.launchers.LinuxLauncher.binary_path', mock.MagicMock) + @mock.patch('subprocess.Popen') + def test_Launch_DummyArgs_ArgsPassedToPopen(self, mock_subprocess): + dummy_args = ["some_args"] + launcher = ly_test_tools.launchers.LinuxLauncher(mock.MagicMock(), dummy_args) + + launcher.launch() + + mock_subprocess.assert_called_once() + name, args, kwargs = mock_subprocess.mock_calls[0] + unpacked_args = args[0] # args is a list inside a tuple + assert len(dummy_args) > 0, "accidentally removed dummy_args" + for expected_arg in dummy_args: + assert expected_arg in unpacked_args + + @mock.patch('ly_test_tools.launchers.LinuxLauncher.is_alive') + def test_Kill_MockAliveFalse_SilentSuccess(self, mock_alive): + mock_alive.return_value = False + mock_proc = mock.MagicMock() + launcher = ly_test_tools.launchers.LinuxLauncher(mock.MagicMock(), ["dummy"]) + launcher._proc = mock_proc + + launcher.kill() + + mock_proc.kill.assert_called_once() + mock_alive.assert_called_once() diff --git a/Tools/LyTestTools/tests/unit/test_process_utils.py b/Tools/LyTestTools/tests/unit/test_process_utils.py index a3cdae84ad..de40fb8e34 100755 --- a/Tools/LyTestTools/tests/unit/test_process_utils.py +++ b/Tools/LyTestTools/tests/unit/test_process_utils.py @@ -191,7 +191,7 @@ class TestSubprocessCheckCallWrapperSafe(unittest.TestCase): reason="tests.unit.test_process_utils is restricted to the Windows platform.") class TestCloseWindowsProcess(unittest.TestCase): - @mock.patch('ly_test_tools.environment.process_utils.WINDOWS', False) + @mock.patch('ly_test_tools.WINDOWS', False) def test_CloseWindowsProccess_NotOnWindows_Error(self): with pytest.raises(NotImplementedError): process_utils.close_windows_process(1) From 536ef46e2bc1e5e20e1f4f46ff6377c58726187f Mon Sep 17 00:00:00 2001 From: nggieber Date: Mon, 27 Sep 2021 07:12:10 -0700 Subject: [PATCH 03/19] Add Add Gem Repo Dialog Signed-off-by: nggieber --- .../Resources/ProjectManager.qss | 4 ++ .../Source/GemRepo/GemRepoAddDialog.cpp | 62 +++++++++++++++++++ .../Source/GemRepo/GemRepoAddDialog.h | 15 +++++ .../Source/GemRepo/GemRepoScreen.cpp | 45 +++++++++++--- .../Source/GemRepo/GemRepoScreen.h | 4 +- .../ProjectManager/Source/PythonBindings.cpp | 7 +++ .../ProjectManager/Source/PythonBindings.h | 1 + .../Source/PythonBindingsInterface.h | 7 +++ 8 files changed, 137 insertions(+), 8 deletions(-) diff --git a/Code/Tools/ProjectManager/Resources/ProjectManager.qss b/Code/Tools/ProjectManager/Resources/ProjectManager.qss index 52cc784336..8bfd647a56 100644 --- a/Code/Tools/ProjectManager/Resources/ProjectManager.qss +++ b/Code/Tools/ProjectManager/Resources/ProjectManager.qss @@ -600,3 +600,7 @@ QProgressBar::chunk { #gemRepoInspector { background: #444444; } + +#gemRepoAddDialogInstructionTitleLabel { + font-size:14px; +} diff --git a/Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.cpp b/Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.cpp index 31e98a965b..4525abb16b 100644 --- a/Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.cpp +++ b/Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.cpp @@ -7,12 +7,74 @@ */ #include +#include + +#include +#include +#include +#include namespace O3DE::ProjectManager { GemRepoAddDialog::GemRepoAddDialog(QWidget* parent) : QDialog(parent) { + setWindowTitle(tr("Add a User Repository")); + setModal(true); + QVBoxLayout* vLayout = new QVBoxLayout(); + vLayout->setContentsMargins(30, 30, 25, 10); + vLayout->setSpacing(0); + setLayout(vLayout); + + QLabel* instructionTitleLabel = new QLabel(tr("Enter a valid path to add a new user repository")); + instructionTitleLabel->setObjectName("gemRepoAddDialogInstructionTitleLabel"); + instructionTitleLabel->setAlignment(Qt::AlignLeft); + vLayout->addWidget(instructionTitleLabel); + + vLayout->addSpacing(10); + + QLabel* instructionContextLabel = new QLabel(tr("The path can be a Repository URL or a Local Path in your directory.")); + instructionContextLabel->setAlignment(Qt::AlignLeft); + vLayout->addWidget(instructionContextLabel); + + m_repoPath = new FormLineEditWidget(tr("Repository Path"), "", this); + m_repoPath->setFixedWidth(500); + vLayout->addWidget(m_repoPath); + + vLayout->addSpacing(40); + + QDialogButtonBox* dialogButtons = new QDialogButtonBox(); + dialogButtons->setObjectName("footer"); + vLayout->addWidget(dialogButtons); + + QPushButton* cancelButton = dialogButtons->addButton(tr("Cancel"), QDialogButtonBox::RejectRole); + cancelButton->setProperty("secondary", true); + QPushButton* continueButton = dialogButtons->addButton(tr("Add"), QDialogButtonBox::ApplyRole); + + connect(cancelButton, &QPushButton::clicked, this, &GemRepoAddDialog::CancelButtonPressed); + connect(continueButton, &QPushButton::clicked, this, &GemRepoAddDialog::ContinueButtonPressed); + } + + QDialogButtonBox::ButtonRole GemRepoAddDialog::GetButtonResult() + { + return m_buttonResult; + } + + QString GemRepoAddDialog::GetRepoPath() + { + return m_repoPath->lineEdit()->text(); + } + + void GemRepoAddDialog::CancelButtonPressed() + { + m_buttonResult = QDialogButtonBox::RejectRole; + close(); + } + + void GemRepoAddDialog::ContinueButtonPressed() + { + m_buttonResult = QDialogButtonBox::ApplyRole; + close(); } } // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.h b/Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.h index 24c9b4b357..28530c5f0b 100644 --- a/Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.h +++ b/Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.h @@ -10,15 +10,30 @@ #if !defined(Q_MOC_RUN) #include + +#include #endif namespace O3DE::ProjectManager { + QT_FORWARD_DECLARE_CLASS(FormLineEditWidget) + class GemRepoAddDialog : public QDialog { public: explicit GemRepoAddDialog(QWidget* parent = nullptr); ~GemRepoAddDialog() = default; + + QDialogButtonBox::ButtonRole GetButtonResult(); + QString GetRepoPath(); + + private: + void CancelButtonPressed(); + void ContinueButtonPressed(); + + FormLineEditWidget* m_repoPath = nullptr; + + QDialogButtonBox::ButtonRole m_buttonResult = QDialogButtonBox::RejectRole; }; } // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.cpp b/Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.cpp index 5838abf643..5e533414b0 100644 --- a/Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.cpp +++ b/Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -70,6 +71,32 @@ namespace O3DE::ProjectManager }); } + void GemRepoScreen::HandleAddRepoButton() + { + GemRepoAddDialog* repoAddDialog = new GemRepoAddDialog(this); + repoAddDialog->exec(); + + if (repoAddDialog->GetButtonResult() == QDialogButtonBox::ApplyRole) + { + QString repoUrl = repoAddDialog->GetRepoPath(); + if (repoUrl.isEmpty()) + { + return; + } + + AZ::Outcome addGemRepoResult = PythonBindingsInterface::Get()->AddGemRepo(repoUrl); + if (addGemRepoResult.IsSuccess()) + { + Reinit(); + } + else + { + QMessageBox::critical(this, tr("Operation failed"), + QString("Failed to add gem repo: %1.\nError:\n%2").arg(repoUrl, addGemRepoResult.GetError().c_str())); + } + } + } + void GemRepoScreen::FillModel() { AZ::Outcome, AZStd::string> allGemRepoInfosResult = PythonBindingsInterface::Get()->GetAllGemRepoInfos(); @@ -114,10 +141,12 @@ namespace O3DE::ProjectManager hLayout->addStretch(); - m_AddRepoButton = new QPushButton(tr("Add Repository"), this); - m_AddRepoButton->setObjectName("gemRepoAddButton"); - m_AddRepoButton->setMinimumWidth(120); - hLayout->addWidget(m_AddRepoButton); + QPushButton* addRepoButton = new QPushButton(tr("Add Repository"), this); + addRepoButton->setObjectName("gemRepoAddButton"); + addRepoButton->setMinimumWidth(120); + hLayout->addWidget(addRepoButton); + + connect(addRepoButton, &QPushButton::clicked, this, &GemRepoScreen::HandleAddRepoButton); hLayout->addStretch(); @@ -165,9 +194,11 @@ namespace O3DE::ProjectManager topMiddleHLayout->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum)); - m_AddRepoButton = new QPushButton(tr("Add Repository"), this); - m_AddRepoButton->setObjectName("gemRepoAddButton"); - topMiddleHLayout->addWidget(m_AddRepoButton); + QPushButton* addRepoButton = new QPushButton(tr("Add Repository"), this); + addRepoButton->setObjectName("gemRepoAddButton"); + topMiddleHLayout->addWidget(addRepoButton); + + connect(addRepoButton, &QPushButton::clicked, this, &GemRepoScreen::HandleAddRepoButton); topMiddleHLayout->addSpacing(30); diff --git a/Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.h b/Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.h index ab679ad39b..fcbb59cceb 100644 --- a/Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.h +++ b/Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.h @@ -36,6 +36,9 @@ namespace O3DE::ProjectManager GemRepoModel* GetGemRepoModel() const { return m_gemRepoModel; } + public slots: + void HandleAddRepoButton(); + private: void FillModel(); QFrame* CreateNoReposContent(); @@ -53,6 +56,5 @@ namespace O3DE::ProjectManager QLabel* m_lastAllUpdateLabel; QPushButton* m_AllUpdateButton; - QPushButton* m_AddRepoButton; }; } // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/PythonBindings.cpp b/Code/Tools/ProjectManager/Source/PythonBindings.cpp index 6f8ff9abce..aa3f957a2a 100644 --- a/Code/Tools/ProjectManager/Source/PythonBindings.cpp +++ b/Code/Tools/ProjectManager/Source/PythonBindings.cpp @@ -913,6 +913,13 @@ namespace O3DE::ProjectManager } } + AZ::Outcome PythonBindings::AddGemRepo(const QString& repoUri) + { + // o3de scripts need method added + (void)repoUri; + return AZ::Failure("Adding Gem Repo not implemented yet in o3de scripts."); + } + GemRepoInfo PythonBindings::GemRepoInfoFromPath(pybind11::handle path, pybind11::handle pyEnginePath) { /* Placeholder Logic */ diff --git a/Code/Tools/ProjectManager/Source/PythonBindings.h b/Code/Tools/ProjectManager/Source/PythonBindings.h index 3b766c3797..c216be0acb 100644 --- a/Code/Tools/ProjectManager/Source/PythonBindings.h +++ b/Code/Tools/ProjectManager/Source/PythonBindings.h @@ -57,6 +57,7 @@ namespace O3DE::ProjectManager AZ::Outcome> GetProjectTemplates(const QString& projectPath = {}) override; // Gem Repos + AZ::Outcome AddGemRepo(const QString& repoUri = {}) override; AZ::Outcome, AZStd::string> GetAllGemRepoInfos() override; private: diff --git a/Code/Tools/ProjectManager/Source/PythonBindingsInterface.h b/Code/Tools/ProjectManager/Source/PythonBindingsInterface.h index 9fd3002f93..4baab85145 100644 --- a/Code/Tools/ProjectManager/Source/PythonBindingsInterface.h +++ b/Code/Tools/ProjectManager/Source/PythonBindingsInterface.h @@ -159,6 +159,13 @@ namespace O3DE::ProjectManager // Gem Repos + /** + * A gem repo to engine. Registers this gem repo with the current engine. + * @param repoUri the absolute filesystem path or url to the gem repo manifest file. + * @return An outcome with the success flag as well as an error message in case of a failure. + */ + virtual AZ::Outcome AddGemRepo(const QString& repoUri = {}) = 0; + /** * Get all available gem repo infos. Gathers all repos registered with the engine. * @return A list of gem repo infos. From 690f8e6925a13f097ef17e5e60ec9babb4c465f1 Mon Sep 17 00:00:00 2001 From: nggieber Date: Mon, 27 Sep 2021 07:31:32 -0700 Subject: [PATCH 04/19] Minor merge fix Signed-off-by: nggieber --- Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.cpp b/Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.cpp index 63f92466b5..0d0605f750 100644 --- a/Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.cpp +++ b/Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.cpp @@ -10,8 +10,8 @@ #include #include #include -#include #include +#include #include #include @@ -35,7 +35,7 @@ namespace O3DE::ProjectManager QVBoxLayout* vLayout = new QVBoxLayout(); vLayout->setMargin(0); vLayout->setSpacing(0); - setLayout(vLayout); + setLayout(vLayout); m_contentStack = new QStackedWidget(this); From 0b5aaa297e69d123397c76f57075ef216f3f5f47 Mon Sep 17 00:00:00 2001 From: nggieber Date: Mon, 27 Sep 2021 07:40:33 -0700 Subject: [PATCH 05/19] Fix text alignment Signed-off-by: nggieber --- Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.cpp b/Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.cpp index 0d0605f750..e2c03b6cc2 100644 --- a/Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.cpp +++ b/Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.cpp @@ -35,7 +35,7 @@ namespace O3DE::ProjectManager QVBoxLayout* vLayout = new QVBoxLayout(); vLayout->setMargin(0); vLayout->setSpacing(0); - setLayout(vLayout); + setLayout(vLayout); m_contentStack = new QStackedWidget(this); From f6585a741c69083527b816bc40733c1d41dde9ce Mon Sep 17 00:00:00 2001 From: sweeneys Date: Tue, 28 Sep 2021 14:53:58 -0700 Subject: [PATCH 06/19] docstring updates Signed-off-by: sweeneys --- .../ly_test_tools/_internal/managers/platforms/linux.py | 2 +- .../ly_test_tools/launchers/platforms/linux/launcher.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Tools/LyTestTools/ly_test_tools/_internal/managers/platforms/linux.py b/Tools/LyTestTools/ly_test_tools/_internal/managers/platforms/linux.py index 0cf213c746..cdbd379183 100644 --- a/Tools/LyTestTools/ly_test_tools/_internal/managers/platforms/linux.py +++ b/Tools/LyTestTools/ly_test_tools/_internal/managers/platforms/linux.py @@ -59,7 +59,7 @@ class _LinuxResourceManager(AbstractResourceLocator): class LinuxWorkspaceManager(AbstractWorkspaceManager): """ - A Mac host WorkspaceManager. Contains Mac overridden functions for the AbstractWorkspaceManager class. + A Linux host WorkspaceManager. Contains Mac overridden functions for the AbstractWorkspaceManager class. Also creates a Mac host ResourceLocator for directory and build mappings. """ def __init__( diff --git a/Tools/LyTestTools/ly_test_tools/launchers/platforms/linux/launcher.py b/Tools/LyTestTools/ly_test_tools/launchers/platforms/linux/launcher.py index 47a538d90e..210519d197 100644 --- a/Tools/LyTestTools/ly_test_tools/launchers/platforms/linux/launcher.py +++ b/Tools/LyTestTools/ly_test_tools/launchers/platforms/linux/launcher.py @@ -147,7 +147,7 @@ class LinuxLauncher(Launcher): def check_returncode(self): # type: () -> None """ - Checks the returncode of the launcher if it exists. Raises a CrashError if the returncode is non-zero. Returns + Checks the return code of the launcher if it exists. Raises a CrashError if the returncode is non-zero. Returns None otherwise. This function must be called after exiting the launcher properly and NOT using its provided teardown(). Provided teardown() will always return a non-zero returncode and should not be checked. From 16e66cfa7145d077af7a593cac51c75e6b871d83 Mon Sep 17 00:00:00 2001 From: nggieber Date: Tue, 28 Sep 2021 18:37:44 -0700 Subject: [PATCH 07/19] Addressed review feedback Signed-off-by: nggieber --- .../Resources/ProjectManager.qss | 4 +++ .../Source/GemRepo/GemRepoAddDialog.cpp | 27 +++++-------------- .../Source/GemRepo/GemRepoAddDialog.h | 8 ------ .../Source/GemRepo/GemRepoScreen.cpp | 7 +++-- .../ProjectManager/Source/PythonBindings.h | 2 +- .../Source/PythonBindingsInterface.h | 2 +- 6 files changed, 15 insertions(+), 35 deletions(-) diff --git a/Code/Tools/ProjectManager/Resources/ProjectManager.qss b/Code/Tools/ProjectManager/Resources/ProjectManager.qss index 8898a94652..eeed316cbc 100644 --- a/Code/Tools/ProjectManager/Resources/ProjectManager.qss +++ b/Code/Tools/ProjectManager/Resources/ProjectManager.qss @@ -617,6 +617,10 @@ QProgressBar::chunk { font-size:14px; } +#addGemRepoDialog #formFrame { + margin-left:0px; +} + /************** Gem Repo Inspector **************/ #gemRepoInspectorNameLabel { diff --git a/Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.cpp b/Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.cpp index 4525abb16b..9e40a2b231 100644 --- a/Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.cpp +++ b/Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include namespace O3DE::ProjectManager @@ -21,6 +22,7 @@ namespace O3DE::ProjectManager { setWindowTitle(tr("Add a User Repository")); setModal(true); + setObjectName("addGemRepoDialog"); QVBoxLayout* vLayout = new QVBoxLayout(); vLayout->setContentsMargins(30, 30, 25, 10); @@ -39,7 +41,7 @@ namespace O3DE::ProjectManager vLayout->addWidget(instructionContextLabel); m_repoPath = new FormLineEditWidget(tr("Repository Path"), "", this); - m_repoPath->setFixedWidth(500); + m_repoPath->setFixedWidth(600); vLayout->addWidget(m_repoPath); vLayout->addSpacing(40); @@ -50,31 +52,14 @@ namespace O3DE::ProjectManager QPushButton* cancelButton = dialogButtons->addButton(tr("Cancel"), QDialogButtonBox::RejectRole); cancelButton->setProperty("secondary", true); - QPushButton* continueButton = dialogButtons->addButton(tr("Add"), QDialogButtonBox::ApplyRole); + QPushButton* applyButton = dialogButtons->addButton(tr("Add"), QDialogButtonBox::ApplyRole); - connect(cancelButton, &QPushButton::clicked, this, &GemRepoAddDialog::CancelButtonPressed); - connect(continueButton, &QPushButton::clicked, this, &GemRepoAddDialog::ContinueButtonPressed); - } - - QDialogButtonBox::ButtonRole GemRepoAddDialog::GetButtonResult() - { - return m_buttonResult; + connect(cancelButton, &QPushButton::clicked, this, &QDialog::reject); + connect(applyButton, &QPushButton::clicked, this, &QDialog::accept); } QString GemRepoAddDialog::GetRepoPath() { return m_repoPath->lineEdit()->text(); } - - void GemRepoAddDialog::CancelButtonPressed() - { - m_buttonResult = QDialogButtonBox::RejectRole; - close(); - } - - void GemRepoAddDialog::ContinueButtonPressed() - { - m_buttonResult = QDialogButtonBox::ApplyRole; - close(); - } } // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.h b/Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.h index 28530c5f0b..38b9bf68eb 100644 --- a/Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.h +++ b/Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.h @@ -10,8 +10,6 @@ #if !defined(Q_MOC_RUN) #include - -#include #endif namespace O3DE::ProjectManager @@ -25,15 +23,9 @@ namespace O3DE::ProjectManager explicit GemRepoAddDialog(QWidget* parent = nullptr); ~GemRepoAddDialog() = default; - QDialogButtonBox::ButtonRole GetButtonResult(); QString GetRepoPath(); private: - void CancelButtonPressed(); - void ContinueButtonPressed(); - FormLineEditWidget* m_repoPath = nullptr; - - QDialogButtonBox::ButtonRole m_buttonResult = QDialogButtonBox::RejectRole; }; } // namespace O3DE::ProjectManager diff --git a/Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.cpp b/Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.cpp index e2c03b6cc2..9c432884e6 100644 --- a/Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.cpp +++ b/Code/Tools/ProjectManager/Source/GemRepo/GemRepoScreen.cpp @@ -75,9 +75,8 @@ namespace O3DE::ProjectManager void GemRepoScreen::HandleAddRepoButton() { GemRepoAddDialog* repoAddDialog = new GemRepoAddDialog(this); - repoAddDialog->exec(); - if (repoAddDialog->GetButtonResult() == QDialogButtonBox::ApplyRole) + if (repoAddDialog->exec() == QDialog::DialogCode::Accepted) { QString repoUrl = repoAddDialog->GetRepoPath(); if (repoUrl.isEmpty()) @@ -93,7 +92,7 @@ namespace O3DE::ProjectManager else { QMessageBox::critical(this, tr("Operation failed"), - QString("Failed to add gem repo: %1.\nError:\n%2").arg(repoUrl, addGemRepoResult.GetError().c_str())); + QString("Failed to add gem repo: %1.
Error:
%2").arg(repoUrl, addGemRepoResult.GetError().c_str())); } } } @@ -112,7 +111,7 @@ namespace O3DE::ProjectManager } else { - QMessageBox::critical(this, tr("Operation failed"), QString("Cannot retrieve gem repos for engine.\n\nError:\n%2").arg(allGemRepoInfosResult.GetError().c_str())); + QMessageBox::critical(this, tr("Operation failed"), QString("Cannot retrieve gem repos for engine.
Error:
%2").arg(allGemRepoInfosResult.GetError().c_str())); } } diff --git a/Code/Tools/ProjectManager/Source/PythonBindings.h b/Code/Tools/ProjectManager/Source/PythonBindings.h index c216be0acb..42f04ed6e6 100644 --- a/Code/Tools/ProjectManager/Source/PythonBindings.h +++ b/Code/Tools/ProjectManager/Source/PythonBindings.h @@ -57,7 +57,7 @@ namespace O3DE::ProjectManager AZ::Outcome> GetProjectTemplates(const QString& projectPath = {}) override; // Gem Repos - AZ::Outcome AddGemRepo(const QString& repoUri = {}) override; + AZ::Outcome AddGemRepo(const QString& repoUri) override; AZ::Outcome, AZStd::string> GetAllGemRepoInfos() override; private: diff --git a/Code/Tools/ProjectManager/Source/PythonBindingsInterface.h b/Code/Tools/ProjectManager/Source/PythonBindingsInterface.h index 5a008c46df..92139f3df5 100644 --- a/Code/Tools/ProjectManager/Source/PythonBindingsInterface.h +++ b/Code/Tools/ProjectManager/Source/PythonBindingsInterface.h @@ -165,7 +165,7 @@ namespace O3DE::ProjectManager * @param repoUri the absolute filesystem path or url to the gem repo manifest file. * @return An outcome with the success flag as well as an error message in case of a failure. */ - virtual AZ::Outcome AddGemRepo(const QString& repoUri = {}) = 0; + virtual AZ::Outcome AddGemRepo(const QString& repoUri) = 0; /** * Get all available gem repo infos. Gathers all repos registered with the engine. From c34b6ffe3bc302cce3fa814da40518a08c5a3638 Mon Sep 17 00:00:00 2001 From: hultonha <82228511+hultonha@users.noreply.github.com> Date: Wed, 29 Sep 2021 10:11:49 +0100 Subject: [PATCH 08/19] Overhaul of how camera orbit/pivot behavior works (#4345) * overhaul to how camera orbit/pivot behavior works Signed-off-by: hultonha * update naming from orbit to pivot Signed-off-by: hultonha * fix camera unit tests Signed-off-by: hultonha * add additional tests for new camera pivot behavior Signed-off-by: hultonha * fix comment and add additional info for tests Signed-off-by: hultonha --- .../EditorModularViewportCameraComposer.cpp | 105 +++++------ .../EditorModularViewportCameraComposer.h | 12 +- .../EditorPreferencesPageViewportCamera.cpp | 54 +++--- .../EditorPreferencesPageViewportCamera.h | 10 +- Code/Editor/EditorViewportSettings.cpp | 50 ++--- Code/Editor/EditorViewportSettings.h | 20 +- .../AzFramework/Viewport/CameraInput.cpp | 175 +++++++----------- .../AzFramework/Viewport/CameraInput.h | 121 ++++++++---- .../AzFramework/Tests/CameraInputTests.cpp | 163 +++++++++++++--- .../ModularViewportCameraController.h | 5 - .../ModularViewportCameraController.cpp | 29 +-- 11 files changed, 410 insertions(+), 334 deletions(-) diff --git a/Code/Editor/EditorModularViewportCameraComposer.cpp b/Code/Editor/EditorModularViewportCameraComposer.cpp index e375e98fb6..600f2089e6 100644 --- a/Code/Editor/EditorModularViewportCameraComposer.cpp +++ b/Code/Editor/EditorModularViewportCameraComposer.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include namespace SandboxEditor @@ -94,7 +95,7 @@ namespace SandboxEditor cameras.AddCamera(m_firstPersonPanCamera); cameras.AddCamera(m_firstPersonTranslateCamera); cameras.AddCamera(m_firstPersonScrollCamera); - cameras.AddCamera(m_orbitCamera); + cameras.AddCamera(m_pivotCamera); }); return controller; @@ -131,8 +132,8 @@ namespace SandboxEditor m_firstPersonRotateCamera->SetActivationBeganFn(hideCursor); m_firstPersonRotateCamera->SetActivationEndedFn(showCursor); - m_firstPersonPanCamera = - AZStd::make_shared(SandboxEditor::CameraFreePanChannelId(), AzFramework::LookPan); + m_firstPersonPanCamera = AZStd::make_shared( + SandboxEditor::CameraFreePanChannelId(), AzFramework::LookPan, AzFramework::TranslatePivot); m_firstPersonPanCamera->m_panSpeedFn = [] { @@ -151,8 +152,8 @@ namespace SandboxEditor const auto translateCameraInputChannelIds = BuildTranslateCameraInputChannelIds(); - m_firstPersonTranslateCamera = - AZStd::make_shared(AzFramework::LookTranslation, translateCameraInputChannelIds); + m_firstPersonTranslateCamera = AZStd::make_shared( + translateCameraInputChannelIds, AzFramework::LookTranslation, AzFramework::TranslatePivot); m_firstPersonTranslateCamera->m_translateSpeedFn = [] { @@ -171,10 +172,10 @@ namespace SandboxEditor return SandboxEditor::CameraScrollSpeed(); }; - m_orbitCamera = AZStd::make_shared(SandboxEditor::CameraOrbitChannelId()); + m_pivotCamera = AZStd::make_shared(SandboxEditor::CameraPivotChannelId()); - m_orbitCamera->SetLookAtFn( - [viewportId = m_viewportId](const AZ::Vector3& position, const AZ::Vector3& direction) -> AZStd::optional + m_pivotCamera->SetPivotFn( + [viewportId = m_viewportId]([[maybe_unused]] const AZ::Vector3& position, [[maybe_unused]] const AZ::Vector3& direction) { AZStd::optional lookAtAfterInterpolation; AtomToolsFramework::ModularViewportCameraControllerRequestBus::EventResult( @@ -182,109 +183,98 @@ namespace SandboxEditor &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::LookAtAfterInterpolation); // initially attempt to use the last set look at point after an interpolation has finished - if (lookAtAfterInterpolation.has_value()) + // note: ignore this if it is the same location as the camera (e.g. after go to position) + if (lookAtAfterInterpolation.has_value() && !lookAtAfterInterpolation->IsClose(position)) { return *lookAtAfterInterpolation; } - const float RayDistance = 1000.0f; - AzFramework::RenderGeometry::RayRequest ray; - ray.m_startWorldPosition = position; - ray.m_endWorldPosition = position + direction * RayDistance; - ray.m_onlyVisible = true; + // otherwise fall back to the selected entity pivot + AZStd::optional entityPivot; + AzToolsFramework::EditorTransformComponentSelectionRequestBus::EventResult( + entityPivot, AzToolsFramework::GetEntityContextId(), + &AzToolsFramework::EditorTransformComponentSelectionRequestBus::Events::GetManipulatorTransform); - AzFramework::RenderGeometry::RayResult renderGeometryIntersectionResult; - AzFramework::RenderGeometry::IntersectorBus::EventResult( - renderGeometryIntersectionResult, AzToolsFramework::GetEntityContextId(), - &AzFramework::RenderGeometry::IntersectorBus::Events::RayIntersect, ray); - - // attempt a ray intersection with any visible mesh and return the intersection position if successful - if (renderGeometryIntersectionResult) - { - return renderGeometryIntersectionResult.m_worldPosition; - } - - // if there is no selection or no intersection, fallback to default camera orbit behavior (ground plane - // intersection) - return {}; + // finally just use the identity + return entityPivot.value_or(AZ::Transform::CreateIdentity()).GetTranslation(); }); - m_orbitRotateCamera = AZStd::make_shared(SandboxEditor::CameraOrbitLookChannelId()); + m_pivotRotateCamera = AZStd::make_shared(SandboxEditor::CameraPivotLookChannelId()); - m_orbitRotateCamera->m_rotateSpeedFn = [] + m_pivotRotateCamera->m_rotateSpeedFn = [] { return SandboxEditor::CameraRotateSpeed(); }; - m_orbitRotateCamera->m_invertYawFn = [] + m_pivotRotateCamera->m_invertYawFn = [] { - return SandboxEditor::CameraOrbitYawRotationInverted(); + return SandboxEditor::CameraPivotYawRotationInverted(); }; - m_orbitTranslateCamera = - AZStd::make_shared(AzFramework::OrbitTranslation, translateCameraInputChannelIds); + m_pivotTranslateCamera = AZStd::make_shared( + translateCameraInputChannelIds, AzFramework::LookTranslation, AzFramework::TranslateOffset); - m_orbitTranslateCamera->m_translateSpeedFn = [] + m_pivotTranslateCamera->m_translateSpeedFn = [] { return SandboxEditor::CameraTranslateSpeed(); }; - m_orbitTranslateCamera->m_boostMultiplierFn = [] + m_pivotTranslateCamera->m_boostMultiplierFn = [] { return SandboxEditor::CameraBoostMultiplier(); }; - m_orbitDollyScrollCamera = AZStd::make_shared(); + m_pivotDollyScrollCamera = AZStd::make_shared(); - m_orbitDollyScrollCamera->m_scrollSpeedFn = [] + m_pivotDollyScrollCamera->m_scrollSpeedFn = [] { return SandboxEditor::CameraScrollSpeed(); }; - m_orbitDollyMoveCamera = - AZStd::make_shared(SandboxEditor::CameraOrbitDollyChannelId()); + m_pivotDollyMoveCamera = AZStd::make_shared(SandboxEditor::CameraPivotDollyChannelId()); - m_orbitDollyMoveCamera->m_cursorSpeedFn = [] + m_pivotDollyMoveCamera->m_motionSpeedFn = [] { return SandboxEditor::CameraDollyMotionSpeed(); }; - m_orbitPanCamera = AZStd::make_shared(SandboxEditor::CameraOrbitPanChannelId(), AzFramework::OrbitPan); + m_pivotPanCamera = AZStd::make_shared( + SandboxEditor::CameraPivotPanChannelId(), AzFramework::LookPan, AzFramework::TranslateOffset); - m_orbitPanCamera->m_panSpeedFn = [] + m_pivotPanCamera->m_panSpeedFn = [] { return SandboxEditor::CameraPanSpeed(); }; - m_orbitPanCamera->m_invertPanXFn = [] + m_pivotPanCamera->m_invertPanXFn = [] { return SandboxEditor::CameraPanInvertedX(); }; - m_orbitPanCamera->m_invertPanYFn = [] + m_pivotPanCamera->m_invertPanYFn = [] { return SandboxEditor::CameraPanInvertedY(); }; - m_orbitCamera->m_orbitCameras.AddCamera(m_orbitRotateCamera); - m_orbitCamera->m_orbitCameras.AddCamera(m_orbitTranslateCamera); - m_orbitCamera->m_orbitCameras.AddCamera(m_orbitDollyScrollCamera); - m_orbitCamera->m_orbitCameras.AddCamera(m_orbitDollyMoveCamera); - m_orbitCamera->m_orbitCameras.AddCamera(m_orbitPanCamera); + m_pivotCamera->m_pivotCameras.AddCamera(m_pivotRotateCamera); + m_pivotCamera->m_pivotCameras.AddCamera(m_pivotTranslateCamera); + m_pivotCamera->m_pivotCameras.AddCamera(m_pivotDollyScrollCamera); + m_pivotCamera->m_pivotCameras.AddCamera(m_pivotDollyMoveCamera); + m_pivotCamera->m_pivotCameras.AddCamera(m_pivotPanCamera); } void EditorModularViewportCameraComposer::OnEditorModularViewportCameraComposerSettingsChanged() { const auto translateCameraInputChannelIds = BuildTranslateCameraInputChannelIds(); m_firstPersonTranslateCamera->SetTranslateCameraInputChannelIds(translateCameraInputChannelIds); - m_orbitTranslateCamera->SetTranslateCameraInputChannelIds(translateCameraInputChannelIds); - m_firstPersonPanCamera->SetPanInputChannelId(SandboxEditor::CameraFreePanChannelId()); - m_orbitPanCamera->SetPanInputChannelId(SandboxEditor::CameraOrbitPanChannelId()); m_firstPersonRotateCamera->SetRotateInputChannelId(SandboxEditor::CameraFreeLookChannelId()); - m_orbitRotateCamera->SetRotateInputChannelId(SandboxEditor::CameraOrbitLookChannelId()); - m_orbitCamera->SetOrbitInputChannelId(SandboxEditor::CameraOrbitChannelId()); - m_orbitDollyMoveCamera->SetDollyInputChannelId(SandboxEditor::CameraOrbitDollyChannelId()); + + m_pivotCamera->SetPivotInputChannelId(SandboxEditor::CameraPivotChannelId()); + m_pivotTranslateCamera->SetTranslateCameraInputChannelIds(translateCameraInputChannelIds); + m_pivotPanCamera->SetPanInputChannelId(SandboxEditor::CameraPivotPanChannelId()); + m_pivotRotateCamera->SetRotateInputChannelId(SandboxEditor::CameraPivotLookChannelId()); + m_pivotDollyMoveCamera->SetDollyInputChannelId(SandboxEditor::CameraPivotDollyChannelId()); } void EditorModularViewportCameraComposer::OnViewportViewEntityChanged(const AZ::EntityId& viewEntityId) @@ -295,8 +285,7 @@ namespace SandboxEditor AZ::TransformBus::EventResult(worldFromLocal, viewEntityId, &AZ::TransformBus::Events::GetWorldTM); AtomToolsFramework::ModularViewportCameraControllerRequestBus::Event( - m_viewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::SetReferenceFrame, - worldFromLocal); + m_viewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::SetReferenceFrame, worldFromLocal); } else { diff --git a/Code/Editor/EditorModularViewportCameraComposer.h b/Code/Editor/EditorModularViewportCameraComposer.h index e6e71c976c..e691ca1c89 100644 --- a/Code/Editor/EditorModularViewportCameraComposer.h +++ b/Code/Editor/EditorModularViewportCameraComposer.h @@ -42,12 +42,12 @@ namespace SandboxEditor AZStd::shared_ptr m_firstPersonPanCamera; AZStd::shared_ptr m_firstPersonTranslateCamera; AZStd::shared_ptr m_firstPersonScrollCamera; - AZStd::shared_ptr m_orbitCamera; - AZStd::shared_ptr m_orbitRotateCamera; - AZStd::shared_ptr m_orbitTranslateCamera; - AZStd::shared_ptr m_orbitDollyScrollCamera; - AZStd::shared_ptr m_orbitDollyMoveCamera; - AZStd::shared_ptr m_orbitPanCamera; + AZStd::shared_ptr m_pivotCamera; + AZStd::shared_ptr m_pivotRotateCamera; + AZStd::shared_ptr m_pivotTranslateCamera; + AZStd::shared_ptr m_pivotDollyScrollCamera; + AZStd::shared_ptr m_pivotDollyMoveCamera; + AZStd::shared_ptr m_pivotPanCamera; AzFramework::ViewportId m_viewportId; }; diff --git a/Code/Editor/EditorPreferencesPageViewportCamera.cpp b/Code/Editor/EditorPreferencesPageViewportCamera.cpp index 368d2769f8..55b631e1f6 100644 --- a/Code/Editor/EditorPreferencesPageViewportCamera.cpp +++ b/Code/Editor/EditorPreferencesPageViewportCamera.cpp @@ -61,7 +61,7 @@ static AZStd::vector GetEditorInputNames() void CEditorPreferencesPage_ViewportCamera::Reflect(AZ::SerializeContext& serialize) { serialize.Class() - ->Version(2) + ->Version(3) ->Field("TranslateSpeed", &CameraMovementSettings::m_translateSpeed) ->Field("RotateSpeed", &CameraMovementSettings::m_rotateSpeed) ->Field("BoostMultiplier", &CameraMovementSettings::m_boostMultiplier) @@ -73,12 +73,12 @@ void CEditorPreferencesPage_ViewportCamera::Reflect(AZ::SerializeContext& serial ->Field("TranslateSmoothing", &CameraMovementSettings::m_translateSmoothing) ->Field("TranslateSmoothness", &CameraMovementSettings::m_translateSmoothness) ->Field("CaptureCursorLook", &CameraMovementSettings::m_captureCursorLook) - ->Field("OrbitYawRotationInverted", &CameraMovementSettings::m_orbitYawRotationInverted) + ->Field("PivotYawRotationInverted", &CameraMovementSettings::m_pivotYawRotationInverted) ->Field("PanInvertedX", &CameraMovementSettings::m_panInvertedX) ->Field("PanInvertedY", &CameraMovementSettings::m_panInvertedY); serialize.Class() - ->Version(1) + ->Version(2) ->Field("TranslateForward", &CameraInputSettings::m_translateForwardChannelId) ->Field("TranslateBackward", &CameraInputSettings::m_translateBackwardChannelId) ->Field("TranslateLeft", &CameraInputSettings::m_translateLeftChannelId) @@ -86,12 +86,12 @@ void CEditorPreferencesPage_ViewportCamera::Reflect(AZ::SerializeContext& serial ->Field("TranslateUp", &CameraInputSettings::m_translateUpChannelId) ->Field("TranslateDown", &CameraInputSettings::m_translateDownChannelId) ->Field("Boost", &CameraInputSettings::m_boostChannelId) - ->Field("Orbit", &CameraInputSettings::m_orbitChannelId) + ->Field("Pivot", &CameraInputSettings::m_pivotChannelId) ->Field("FreeLook", &CameraInputSettings::m_freeLookChannelId) ->Field("FreePan", &CameraInputSettings::m_freePanChannelId) - ->Field("OrbitLook", &CameraInputSettings::m_orbitLookChannelId) - ->Field("OrbitDolly", &CameraInputSettings::m_orbitDollyChannelId) - ->Field("OrbitPan", &CameraInputSettings::m_orbitPanChannelId); + ->Field("PivotLook", &CameraInputSettings::m_pivotLookChannelId) + ->Field("PivotDolly", &CameraInputSettings::m_pivotDollyChannelId) + ->Field("PivotPan", &CameraInputSettings::m_pivotPanChannelId); serialize.Class() ->Version(1) @@ -143,8 +143,8 @@ void CEditorPreferencesPage_ViewportCamera::Reflect(AZ::SerializeContext& serial ->Attribute(AZ::Edit::Attributes::Min, minValue) ->Attribute(AZ::Edit::Attributes::Visibility, &CameraMovementSettings::TranslateSmoothingVisibility) ->DataElement( - AZ::Edit::UIHandlers::CheckBox, &CameraMovementSettings::m_orbitYawRotationInverted, "Camera Orbit Yaw Inverted", - "Inverted yaw rotation while orbiting") + AZ::Edit::UIHandlers::CheckBox, &CameraMovementSettings::m_pivotYawRotationInverted, "Camera Pivot Yaw Inverted", + "Inverted yaw rotation while pivoting") ->DataElement( AZ::Edit::UIHandlers::CheckBox, &CameraMovementSettings::m_panInvertedX, "Invert Pan X", "Invert direction of pan in local X axis") @@ -185,8 +185,8 @@ void CEditorPreferencesPage_ViewportCamera::Reflect(AZ::SerializeContext& serial "Key/button to move the camera more quickly") ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames) ->DataElement( - AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_orbitChannelId, "Orbit", - "Key/button to begin the camera orbit behavior") + AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_pivotChannelId, "Pivot", + "Key/button to begin the camera pivot behavior") ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames) ->DataElement( AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_freeLookChannelId, "Free Look", @@ -196,16 +196,16 @@ void CEditorPreferencesPage_ViewportCamera::Reflect(AZ::SerializeContext& serial AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_freePanChannelId, "Free Pan", "Key/button to begin camera free pan") ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames) ->DataElement( - AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_orbitLookChannelId, "Orbit Look", - "Key/button to begin camera orbit look") + AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_pivotLookChannelId, "Pivot Look", + "Key/button to begin camera pivot look") ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames) ->DataElement( - AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_orbitDollyChannelId, "Orbit Dolly", - "Key/button to begin camera orbit dolly") + AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_pivotDollyChannelId, "Pivot Dolly", + "Key/button to begin camera pivot dolly") ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames) ->DataElement( - AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_orbitPanChannelId, "Orbit Pan", - "Key/button to begin camera orbit pan") + AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_pivotPanChannelId, "Pivot Pan", + "Key/button to begin camera pivot pan") ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames); editContext->Class("Viewport Preferences", "Viewport Preferences") @@ -264,7 +264,7 @@ void CEditorPreferencesPage_ViewportCamera::OnApply() SandboxEditor::SetCameraTranslateSmoothness(m_cameraMovementSettings.m_translateSmoothness); SandboxEditor::SetCameraTranslateSmoothingEnabled(m_cameraMovementSettings.m_translateSmoothing); SandboxEditor::SetCameraCaptureCursorForLook(m_cameraMovementSettings.m_captureCursorLook); - SandboxEditor::SetCameraOrbitYawRotationInverted(m_cameraMovementSettings.m_orbitYawRotationInverted); + SandboxEditor::SetCameraPivotYawRotationInverted(m_cameraMovementSettings.m_pivotYawRotationInverted); SandboxEditor::SetCameraPanInvertedX(m_cameraMovementSettings.m_panInvertedX); SandboxEditor::SetCameraPanInvertedY(m_cameraMovementSettings.m_panInvertedY); @@ -275,12 +275,12 @@ void CEditorPreferencesPage_ViewportCamera::OnApply() SandboxEditor::SetCameraTranslateUpChannelId(m_cameraInputSettings.m_translateUpChannelId); SandboxEditor::SetCameraTranslateDownChannelId(m_cameraInputSettings.m_translateDownChannelId); SandboxEditor::SetCameraTranslateBoostChannelId(m_cameraInputSettings.m_boostChannelId); - SandboxEditor::SetCameraOrbitChannelId(m_cameraInputSettings.m_orbitChannelId); + SandboxEditor::SetCameraPivotChannelId(m_cameraInputSettings.m_pivotChannelId); SandboxEditor::SetCameraFreeLookChannelId(m_cameraInputSettings.m_freeLookChannelId); SandboxEditor::SetCameraFreePanChannelId(m_cameraInputSettings.m_freePanChannelId); - SandboxEditor::SetCameraOrbitLookChannelId(m_cameraInputSettings.m_orbitLookChannelId); - SandboxEditor::SetCameraOrbitDollyChannelId(m_cameraInputSettings.m_orbitDollyChannelId); - SandboxEditor::SetCameraOrbitPanChannelId(m_cameraInputSettings.m_orbitPanChannelId); + SandboxEditor::SetCameraPivotLookChannelId(m_cameraInputSettings.m_pivotLookChannelId); + SandboxEditor::SetCameraPivotDollyChannelId(m_cameraInputSettings.m_pivotDollyChannelId); + SandboxEditor::SetCameraPivotPanChannelId(m_cameraInputSettings.m_pivotPanChannelId); SandboxEditor::EditorModularViewportCameraComposerNotificationBus::Broadcast( &SandboxEditor::EditorModularViewportCameraComposerNotificationBus::Events::OnEditorModularViewportCameraComposerSettingsChanged); @@ -299,7 +299,7 @@ void CEditorPreferencesPage_ViewportCamera::InitializeSettings() m_cameraMovementSettings.m_translateSmoothness = SandboxEditor::CameraTranslateSmoothness(); m_cameraMovementSettings.m_translateSmoothing = SandboxEditor::CameraTranslateSmoothingEnabled(); m_cameraMovementSettings.m_captureCursorLook = SandboxEditor::CameraCaptureCursorForLook(); - m_cameraMovementSettings.m_orbitYawRotationInverted = SandboxEditor::CameraOrbitYawRotationInverted(); + m_cameraMovementSettings.m_pivotYawRotationInverted = SandboxEditor::CameraPivotYawRotationInverted(); m_cameraMovementSettings.m_panInvertedX = SandboxEditor::CameraPanInvertedX(); m_cameraMovementSettings.m_panInvertedY = SandboxEditor::CameraPanInvertedY(); @@ -310,10 +310,10 @@ void CEditorPreferencesPage_ViewportCamera::InitializeSettings() m_cameraInputSettings.m_translateUpChannelId = SandboxEditor::CameraTranslateUpChannelId().GetName(); m_cameraInputSettings.m_translateDownChannelId = SandboxEditor::CameraTranslateDownChannelId().GetName(); m_cameraInputSettings.m_boostChannelId = SandboxEditor::CameraTranslateBoostChannelId().GetName(); - m_cameraInputSettings.m_orbitChannelId = SandboxEditor::CameraOrbitChannelId().GetName(); + m_cameraInputSettings.m_pivotChannelId = SandboxEditor::CameraPivotChannelId().GetName(); m_cameraInputSettings.m_freeLookChannelId = SandboxEditor::CameraFreeLookChannelId().GetName(); m_cameraInputSettings.m_freePanChannelId = SandboxEditor::CameraFreePanChannelId().GetName(); - m_cameraInputSettings.m_orbitLookChannelId = SandboxEditor::CameraOrbitLookChannelId().GetName(); - m_cameraInputSettings.m_orbitDollyChannelId = SandboxEditor::CameraOrbitDollyChannelId().GetName(); - m_cameraInputSettings.m_orbitPanChannelId = SandboxEditor::CameraOrbitPanChannelId().GetName(); + m_cameraInputSettings.m_pivotLookChannelId = SandboxEditor::CameraPivotLookChannelId().GetName(); + m_cameraInputSettings.m_pivotDollyChannelId = SandboxEditor::CameraPivotDollyChannelId().GetName(); + m_cameraInputSettings.m_pivotPanChannelId = SandboxEditor::CameraPivotPanChannelId().GetName(); } diff --git a/Code/Editor/EditorPreferencesPageViewportCamera.h b/Code/Editor/EditorPreferencesPageViewportCamera.h index 31a728599f..01dc4664f6 100644 --- a/Code/Editor/EditorPreferencesPageViewportCamera.h +++ b/Code/Editor/EditorPreferencesPageViewportCamera.h @@ -54,7 +54,7 @@ private: float m_translateSmoothness; bool m_translateSmoothing; bool m_captureCursorLook; - bool m_orbitYawRotationInverted; + bool m_pivotYawRotationInverted; bool m_panInvertedX; bool m_panInvertedY; @@ -80,12 +80,12 @@ private: AZStd::string m_translateUpChannelId; AZStd::string m_translateDownChannelId; AZStd::string m_boostChannelId; - AZStd::string m_orbitChannelId; + AZStd::string m_pivotChannelId; AZStd::string m_freeLookChannelId; AZStd::string m_freePanChannelId; - AZStd::string m_orbitLookChannelId; - AZStd::string m_orbitDollyChannelId; - AZStd::string m_orbitPanChannelId; + AZStd::string m_pivotLookChannelId; + AZStd::string m_pivotDollyChannelId; + AZStd::string m_pivotPanChannelId; }; CameraMovementSettings m_cameraMovementSettings; diff --git a/Code/Editor/EditorViewportSettings.cpp b/Code/Editor/EditorViewportSettings.cpp index 063ec125ba..fe8efecd17 100644 --- a/Code/Editor/EditorViewportSettings.cpp +++ b/Code/Editor/EditorViewportSettings.cpp @@ -28,7 +28,7 @@ namespace SandboxEditor constexpr AZStd::string_view CameraRotateSpeedSetting = "/Amazon/Preferences/Editor/Camera/RotateSpeed"; constexpr AZStd::string_view CameraScrollSpeedSetting = "/Amazon/Preferences/Editor/Camera/DollyScrollSpeed"; constexpr AZStd::string_view CameraDollyMotionSpeedSetting = "/Amazon/Preferences/Editor/Camera/DollyMotionSpeed"; - constexpr AZStd::string_view CameraOrbitYawRotationInvertedSetting = "/Amazon/Preferences/Editor/Camera/YawRotationInverted"; + constexpr AZStd::string_view CameraPivotYawRotationInvertedSetting = "/Amazon/Preferences/Editor/Camera/YawRotationInverted"; constexpr AZStd::string_view CameraPanInvertedXSetting = "/Amazon/Preferences/Editor/Camera/PanInvertedX"; constexpr AZStd::string_view CameraPanInvertedYSetting = "/Amazon/Preferences/Editor/Camera/PanInvertedY"; constexpr AZStd::string_view CameraPanSpeedSetting = "/Amazon/Preferences/Editor/Camera/PanSpeed"; @@ -44,12 +44,12 @@ namespace SandboxEditor constexpr AZStd::string_view CameraTranslateUpIdSetting = "/Amazon/Preferences/Editor/Camera/CameraTranslateUpId"; constexpr AZStd::string_view CameraTranslateDownIdSetting = "/Amazon/Preferences/Editor/Camera/CameraTranslateUpDownId"; constexpr AZStd::string_view CameraTranslateBoostIdSetting = "/Amazon/Preferences/Editor/Camera/TranslateBoostId"; - constexpr AZStd::string_view CameraOrbitIdSetting = "/Amazon/Preferences/Editor/Camera/OrbitId"; + constexpr AZStd::string_view CameraPivotIdSetting = "/Amazon/Preferences/Editor/Camera/PivotId"; constexpr AZStd::string_view CameraFreeLookIdSetting = "/Amazon/Preferences/Editor/Camera/FreeLookId"; constexpr AZStd::string_view CameraFreePanIdSetting = "/Amazon/Preferences/Editor/Camera/FreePanId"; - constexpr AZStd::string_view CameraOrbitLookIdSetting = "/Amazon/Preferences/Editor/Camera/OrbitLookId"; - constexpr AZStd::string_view CameraOrbitDollyIdSetting = "/Amazon/Preferences/Editor/Camera/OrbitDollyId"; - constexpr AZStd::string_view CameraOrbitPanIdSetting = "/Amazon/Preferences/Editor/Camera/OrbitPanId"; + constexpr AZStd::string_view CameraPivotLookIdSetting = "/Amazon/Preferences/Editor/Camera/PivotLookId"; + constexpr AZStd::string_view CameraPivotDollyIdSetting = "/Amazon/Preferences/Editor/Camera/PivotDollyId"; + constexpr AZStd::string_view CameraPivotPanIdSetting = "/Amazon/Preferences/Editor/Camera/PivotPanId"; template void SetRegistry(const AZStd::string_view setting, T&& value) @@ -239,14 +239,14 @@ namespace SandboxEditor SetRegistry(CameraDollyMotionSpeedSetting, speed); } - bool CameraOrbitYawRotationInverted() + bool CameraPivotYawRotationInverted() { - return GetRegistry(CameraOrbitYawRotationInvertedSetting, false); + return GetRegistry(CameraPivotYawRotationInvertedSetting, false); } - void SetCameraOrbitYawRotationInverted(const bool inverted) + void SetCameraPivotYawRotationInverted(const bool inverted) { - SetRegistry(CameraOrbitYawRotationInvertedSetting, inverted); + SetRegistry(CameraPivotYawRotationInvertedSetting, inverted); } bool CameraPanInvertedX() @@ -403,14 +403,14 @@ namespace SandboxEditor SetRegistry(CameraTranslateBoostIdSetting, cameraTranslateBoostId); } - AzFramework::InputChannelId CameraOrbitChannelId() + AzFramework::InputChannelId CameraPivotChannelId() { - return AzFramework::InputChannelId(GetRegistry(CameraOrbitIdSetting, AZStd::string("keyboard_key_modifier_alt_l")).c_str()); + return AzFramework::InputChannelId(GetRegistry(CameraPivotIdSetting, AZStd::string("keyboard_key_modifier_alt_l")).c_str()); } - void SetCameraOrbitChannelId(AZStd::string_view cameraOrbitId) + void SetCameraPivotChannelId(AZStd::string_view cameraPivotId) { - SetRegistry(CameraOrbitIdSetting, cameraOrbitId); + SetRegistry(CameraPivotIdSetting, cameraPivotId); } AzFramework::InputChannelId CameraFreeLookChannelId() @@ -433,33 +433,33 @@ namespace SandboxEditor SetRegistry(CameraFreePanIdSetting, cameraFreePanId); } - AzFramework::InputChannelId CameraOrbitLookChannelId() + AzFramework::InputChannelId CameraPivotLookChannelId() { - return AzFramework::InputChannelId(GetRegistry(CameraOrbitLookIdSetting, AZStd::string("mouse_button_left")).c_str()); + return AzFramework::InputChannelId(GetRegistry(CameraPivotLookIdSetting, AZStd::string("mouse_button_left")).c_str()); } - void SetCameraOrbitLookChannelId(AZStd::string_view cameraOrbitLookId) + void SetCameraPivotLookChannelId(AZStd::string_view cameraPivotLookId) { - SetRegistry(CameraOrbitLookIdSetting, cameraOrbitLookId); + SetRegistry(CameraPivotLookIdSetting, cameraPivotLookId); } - AzFramework::InputChannelId CameraOrbitDollyChannelId() + AzFramework::InputChannelId CameraPivotDollyChannelId() { - return AzFramework::InputChannelId(GetRegistry(CameraOrbitDollyIdSetting, AZStd::string("mouse_button_right")).c_str()); + return AzFramework::InputChannelId(GetRegistry(CameraPivotDollyIdSetting, AZStd::string("mouse_button_right")).c_str()); } - void SetCameraOrbitDollyChannelId(AZStd::string_view cameraOrbitDollyId) + void SetCameraPivotDollyChannelId(AZStd::string_view cameraPivotDollyId) { - SetRegistry(CameraOrbitDollyIdSetting, cameraOrbitDollyId); + SetRegistry(CameraPivotDollyIdSetting, cameraPivotDollyId); } - AzFramework::InputChannelId CameraOrbitPanChannelId() + AzFramework::InputChannelId CameraPivotPanChannelId() { - return AzFramework::InputChannelId(GetRegistry(CameraOrbitPanIdSetting, AZStd::string("mouse_button_middle")).c_str()); + return AzFramework::InputChannelId(GetRegistry(CameraPivotPanIdSetting, AZStd::string("mouse_button_middle")).c_str()); } - void SetCameraOrbitPanChannelId(AZStd::string_view cameraOrbitPanId) + void SetCameraPivotPanChannelId(AZStd::string_view cameraPivotPanId) { - SetRegistry(CameraOrbitPanIdSetting, cameraOrbitPanId); + SetRegistry(CameraPivotPanIdSetting, cameraPivotPanId); } } // namespace SandboxEditor diff --git a/Code/Editor/EditorViewportSettings.h b/Code/Editor/EditorViewportSettings.h index 20d397a29e..d1271017c6 100644 --- a/Code/Editor/EditorViewportSettings.h +++ b/Code/Editor/EditorViewportSettings.h @@ -71,8 +71,8 @@ namespace SandboxEditor SANDBOX_API float CameraDollyMotionSpeed(); SANDBOX_API void SetCameraDollyMotionSpeed(float speed); - SANDBOX_API bool CameraOrbitYawRotationInverted(); - SANDBOX_API void SetCameraOrbitYawRotationInverted(bool inverted); + SANDBOX_API bool CameraPivotYawRotationInverted(); + SANDBOX_API void SetCameraPivotYawRotationInverted(bool inverted); SANDBOX_API bool CameraPanInvertedX(); SANDBOX_API void SetCameraPanInvertedX(bool inverted); @@ -119,8 +119,8 @@ namespace SandboxEditor SANDBOX_API AzFramework::InputChannelId CameraTranslateBoostChannelId(); SANDBOX_API void SetCameraTranslateBoostChannelId(AZStd::string_view cameraTranslateBoostId); - SANDBOX_API AzFramework::InputChannelId CameraOrbitChannelId(); - SANDBOX_API void SetCameraOrbitChannelId(AZStd::string_view cameraOrbitId); + SANDBOX_API AzFramework::InputChannelId CameraPivotChannelId(); + SANDBOX_API void SetCameraPivotChannelId(AZStd::string_view cameraPivotId); SANDBOX_API AzFramework::InputChannelId CameraFreeLookChannelId(); SANDBOX_API void SetCameraFreeLookChannelId(AZStd::string_view cameraFreeLookId); @@ -128,12 +128,12 @@ namespace SandboxEditor SANDBOX_API AzFramework::InputChannelId CameraFreePanChannelId(); SANDBOX_API void SetCameraFreePanChannelId(AZStd::string_view cameraFreePanId); - SANDBOX_API AzFramework::InputChannelId CameraOrbitLookChannelId(); - SANDBOX_API void SetCameraOrbitLookChannelId(AZStd::string_view cameraOrbitLookId); + SANDBOX_API AzFramework::InputChannelId CameraPivotLookChannelId(); + SANDBOX_API void SetCameraPivotLookChannelId(AZStd::string_view cameraPivotLookId); - SANDBOX_API AzFramework::InputChannelId CameraOrbitDollyChannelId(); - SANDBOX_API void SetCameraOrbitDollyChannelId(AZStd::string_view cameraOrbitDollyId); + SANDBOX_API AzFramework::InputChannelId CameraPivotDollyChannelId(); + SANDBOX_API void SetCameraPivotDollyChannelId(AZStd::string_view cameraPivotDollyId); - SANDBOX_API AzFramework::InputChannelId CameraOrbitPanChannelId(); - SANDBOX_API void SetCameraOrbitPanChannelId(AZStd::string_view cameraOrbitPanId); + SANDBOX_API AzFramework::InputChannelId CameraPivotPanChannelId(); + SANDBOX_API void SetCameraPivotPanChannelId(AZStd::string_view cameraPivotPanId); } // namespace SandboxEditor diff --git a/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp b/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp index 18667ac153..a3eb4d8329 100644 --- a/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp +++ b/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp @@ -17,15 +17,6 @@ namespace AzFramework { - AZ_CVAR( - float, - ed_cameraSystemDefaultPlaneHeight, - 34.0f, - nullptr, - AZ::ConsoleFunctorFlags::Null, - "The default height of the ground plane to do intersection tests against when orbiting"); - AZ_CVAR(float, ed_cameraSystemMinOrbitDistance, 10.0f, nullptr, AZ::ConsoleFunctorFlags::Null, ""); - AZ_CVAR(float, ed_cameraSystemMaxOrbitDistance, 50.0f, nullptr, AZ::ConsoleFunctorFlags::Null, ""); AZ_CVAR( bool, ed_cameraSystemUseCursor, @@ -135,8 +126,8 @@ namespace AzFramework camera.m_pitch = eulerAngles.GetX(); camera.m_yaw = eulerAngles.GetZ(); - // note: m_lookDist is negative so we must invert it here - camera.m_lookAt = transform.GetTranslation() + (camera.Rotation().GetBasisY() * -camera.m_lookDist); + camera.m_pivot = transform.GetTranslation(); + camera.m_offset = AZ::Vector3::CreateZero(); } bool CameraSystem::HandleEvents(const InputEvent& event) @@ -320,14 +311,8 @@ namespace AzFramework nextCamera.m_pitch -= float(cursorDelta.m_y) * rotateSpeed * Invert(m_invertPitchFn()); nextCamera.m_yaw -= float(cursorDelta.m_x) * rotateSpeed * Invert(m_invertYawFn()); - const auto clampRotation = [](const float angle) - { - return AZStd::fmod(angle + AZ::Constants::TwoPi, AZ::Constants::TwoPi); - }; - - nextCamera.m_yaw = clampRotation(nextCamera.m_yaw); - // clamp pitch to be +/-90 degrees - nextCamera.m_pitch = AZ::GetClamp(nextCamera.m_pitch, -AZ::Constants::HalfPi, AZ::Constants::HalfPi); + nextCamera.m_yaw = WrapYawRotation(nextCamera.m_yaw); + nextCamera.m_pitch = ClampPitchRotation(nextCamera.m_pitch); return nextCamera; } @@ -337,9 +322,10 @@ namespace AzFramework m_rotateChannelId = rotateChannelId; } - PanCameraInput::PanCameraInput(const InputChannelId& panChannelId, PanAxesFn panAxesFn) + PanCameraInput::PanCameraInput(const InputChannelId& panChannelId, PanAxesFn panAxesFn, TranslationDeltaFn translationDeltaFn) : m_panAxesFn(AZStd::move(panAxesFn)) , m_panChannelId(panChannelId) + , m_translationDeltaFn(translationDeltaFn) { m_panSpeedFn = []() constexpr { @@ -375,11 +361,11 @@ namespace AzFramework const auto panAxes = m_panAxesFn(nextCamera); const float panSpeed = m_panSpeedFn(); - const auto deltaPanX = float(cursorDelta.m_x) * panAxes.m_horizontalAxis * panSpeed; - const auto deltaPanY = float(cursorDelta.m_y) * panAxes.m_verticalAxis * panSpeed; + const auto deltaPanX = aznumeric_cast(cursorDelta.m_x) * panAxes.m_horizontalAxis * panSpeed; + const auto deltaPanY = aznumeric_cast(cursorDelta.m_y) * panAxes.m_verticalAxis * panSpeed; - nextCamera.m_lookAt += deltaPanX * Invert(m_invertPanXFn()); - nextCamera.m_lookAt += deltaPanY * -Invert(m_invertPanYFn()); + m_translationDeltaFn(nextCamera, deltaPanX * Invert(m_invertPanXFn())); + m_translationDeltaFn(nextCamera, deltaPanY * -Invert(m_invertPanYFn())); return nextCamera; } @@ -426,8 +412,11 @@ namespace AzFramework } TranslateCameraInput::TranslateCameraInput( - TranslationAxesFn translationAxesFn, const TranslateCameraInputChannelIds& translateCameraInputChannelIds) + const TranslateCameraInputChannelIds& translateCameraInputChannelIds, + TranslationAxesFn translationAxesFn, + TranslationDeltaFn translateDeltaFn) : m_translationAxesFn(AZStd::move(translationAxesFn)) + , m_translateDeltaFn(AZStd::move(translateDeltaFn)) , m_translateCameraInputChannelIds(translateCameraInputChannelIds) { m_translateSpeedFn = []() constexpr @@ -497,32 +486,32 @@ namespace AzFramework if ((m_translation & TranslationType::Forward) == TranslationType::Forward) { - nextCamera.m_lookAt += axisY * speed * deltaTime; + m_translateDeltaFn(nextCamera, axisY * speed * deltaTime); } if ((m_translation & TranslationType::Backward) == TranslationType::Backward) { - nextCamera.m_lookAt -= axisY * speed * deltaTime; + m_translateDeltaFn(nextCamera, -axisY * speed * deltaTime); } if ((m_translation & TranslationType::Left) == TranslationType::Left) { - nextCamera.m_lookAt -= axisX * speed * deltaTime; + m_translateDeltaFn(nextCamera, -axisX * speed * deltaTime); } if ((m_translation & TranslationType::Right) == TranslationType::Right) { - nextCamera.m_lookAt += axisX * speed * deltaTime; + m_translateDeltaFn(nextCamera, axisX * speed * deltaTime); } if ((m_translation & TranslationType::Up) == TranslationType::Up) { - nextCamera.m_lookAt += axisZ * speed * deltaTime; + m_translateDeltaFn(nextCamera, axisZ * speed * deltaTime); } if ((m_translation & TranslationType::Down) == TranslationType::Down) { - nextCamera.m_lookAt -= axisZ * speed * deltaTime; + m_translateDeltaFn(nextCamera, -axisZ * speed * deltaTime); } if (Ending()) @@ -544,16 +533,20 @@ namespace AzFramework m_translateCameraInputChannelIds = translateCameraInputChannelIds; } - OrbitCameraInput::OrbitCameraInput(const InputChannelId& orbitChannelId) - : m_orbitChannelId(orbitChannelId) + PivotCameraInput::PivotCameraInput(const InputChannelId& pivotChannelId) + : m_pivotChannelId(pivotChannelId) { + m_pivotFn = []([[maybe_unused]] const AZ::Vector3& position, [[maybe_unused]] const AZ::Vector3& direction) + { + return AZ::Vector3::CreateZero(); + }; } - bool OrbitCameraInput::HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, const float scrollDelta) + bool PivotCameraInput::HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, const float scrollDelta) { if (const auto* input = AZStd::get_if(&event)) { - if (input->m_channelId == m_orbitChannelId) + if (input->m_channelId == m_pivotChannelId) { if (input->m_state == InputChannel::State::Began) { @@ -568,85 +561,46 @@ namespace AzFramework if (Active()) { - return m_orbitCameras.HandleEvents(event, cursorDelta, scrollDelta); + return m_pivotCameras.HandleEvents(event, cursorDelta, scrollDelta); } return !Idle(); } - Camera OrbitCameraInput::StepCamera( + Camera PivotCameraInput::StepCamera( const Camera& targetCamera, const ScreenVector& cursorDelta, const float scrollDelta, const float deltaTime) { Camera nextCamera = targetCamera; if (Beginning()) { - const auto hasLookAt = [&nextCamera, &targetCamera, &lookAtFn = m_lookAtFn] - { - if (lookAtFn) - { - // pass through the camera's position and look vector for use in the lookAt function - if (const auto lookAt = lookAtFn(targetCamera.Translation(), targetCamera.Rotation().GetBasisY())) - { - // default to internal look at behavior if the look at point matches the camera translation - if (targetCamera.m_lookAt.IsClose(*lookAt)) - { - return false; - } - - auto transform = AZ::Transform::CreateLookAt(targetCamera.m_lookAt, *lookAt); - nextCamera.m_lookDist = -lookAt->GetDistance(targetCamera.m_lookAt); - UpdateCameraFromTransform(nextCamera, transform); - - return true; - } - } - return false; - }(); - - if (!hasLookAt) - { - float hit_distance = 0.0f; - AZ::Plane::CreateFromNormalAndPoint(AZ::Vector3::CreateAxisZ(), AZ::Vector3::CreateAxisZ(ed_cameraSystemDefaultPlaneHeight)) - .CastRay(targetCamera.Translation(), targetCamera.Rotation().GetBasisY(), hit_distance); - - if (hit_distance > 0.0f) - { - hit_distance = AZStd::min(hit_distance, ed_cameraSystemMaxOrbitDistance); - nextCamera.m_lookDist = -hit_distance; - nextCamera.m_lookAt = targetCamera.Translation() + targetCamera.Rotation().GetBasisY() * hit_distance; - } - else - { - nextCamera.m_lookDist = -ed_cameraSystemMinOrbitDistance; - nextCamera.m_lookAt = - targetCamera.Translation() + targetCamera.Rotation().GetBasisY() * ed_cameraSystemMinOrbitDistance; - } - } + nextCamera.m_pivot = m_pivotFn(targetCamera.Translation(), targetCamera.Rotation().GetBasisY()); + nextCamera.m_offset = nextCamera.View().TransformPoint(targetCamera.Translation()); } if (Active()) { - nextCamera = m_orbitCameras.StepCamera(nextCamera, cursorDelta, scrollDelta, deltaTime); + MovePivotDetached(nextCamera, m_pivotFn(targetCamera.Translation(), targetCamera.Rotation().GetBasisY())); + nextCamera = m_pivotCameras.StepCamera(nextCamera, cursorDelta, scrollDelta, deltaTime); } if (Ending()) { - m_orbitCameras.Reset(); + m_pivotCameras.Reset(); - nextCamera.m_lookAt = nextCamera.Translation(); - nextCamera.m_lookDist = 0.0f; + nextCamera.m_pivot = nextCamera.Translation(); + nextCamera.m_offset = AZ::Vector3::CreateZero(); } return nextCamera; } - void OrbitCameraInput::SetOrbitInputChannelId(const InputChannelId& orbitChanneId) + void PivotCameraInput::SetPivotInputChannelId(const InputChannelId& pivotChanneId) { - m_orbitChannelId = orbitChanneId; + m_pivotChannelId = pivotChanneId; } - OrbitDollyScrollCameraInput::OrbitDollyScrollCameraInput() + PivotDollyScrollCameraInput::PivotDollyScrollCameraInput() { m_scrollSpeedFn = []() constexpr { @@ -654,7 +608,7 @@ namespace AzFramework }; } - bool OrbitDollyScrollCameraInput::HandleEvents( + bool PivotDollyScrollCameraInput::HandleEvents( const InputEvent& event, [[maybe_unused]] const ScreenVector& cursorDelta, [[maybe_unused]] const float scrollDelta) { if (const auto* scroll = AZStd::get_if(&event)) @@ -665,46 +619,61 @@ namespace AzFramework return !Idle(); } - Camera OrbitDollyScrollCameraInput::StepCamera( + static Camera PivotDolly(const Camera& targetCamera, const float delta) + { + Camera nextCamera = targetCamera; + + const auto pivotDirection = targetCamera.m_offset.GetNormalized(); + nextCamera.m_offset -= pivotDirection * delta; + const auto pivotDot = targetCamera.m_offset.Dot(nextCamera.m_offset); + const auto distance = nextCamera.m_offset.GetLength() * AZ::GetSign(pivotDot); + + const auto minDistance = 0.01f; + if (distance < minDistance || pivotDot < 0.0f) + { + nextCamera.m_offset = pivotDirection * minDistance; + } + + return nextCamera; + } + + Camera PivotDollyScrollCameraInput::StepCamera( const Camera& targetCamera, [[maybe_unused]] const ScreenVector& cursorDelta, const float scrollDelta, [[maybe_unused]] const float deltaTime) { - Camera nextCamera = targetCamera; - nextCamera.m_lookDist = AZ::GetMin(nextCamera.m_lookDist + scrollDelta * m_scrollSpeedFn(), 0.0f); + const auto nextCamera = PivotDolly(targetCamera, aznumeric_cast(scrollDelta) * m_scrollSpeedFn()); EndActivation(); return nextCamera; } - OrbitDollyCursorMoveCameraInput::OrbitDollyCursorMoveCameraInput(const InputChannelId& dollyChannelId) + PivotDollyMotionCameraInput::PivotDollyMotionCameraInput(const InputChannelId& dollyChannelId) : m_dollyChannelId(dollyChannelId) { - m_cursorSpeedFn = []() constexpr + m_motionSpeedFn = []() constexpr { return 0.01f; }; } - bool OrbitDollyCursorMoveCameraInput::HandleEvents( + bool PivotDollyMotionCameraInput::HandleEvents( const InputEvent& event, [[maybe_unused]] const ScreenVector& cursorDelta, [[maybe_unused]] const float scrollDelta) { HandleActivationEvents(event, m_dollyChannelId, cursorDelta, m_clickDetector, *this); return CameraInputUpdatingAfterMotion(*this); } - Camera OrbitDollyCursorMoveCameraInput::StepCamera( + Camera PivotDollyMotionCameraInput::StepCamera( const Camera& targetCamera, const ScreenVector& cursorDelta, [[maybe_unused]] const float scrollDelta, [[maybe_unused]] const float deltaTime) { - Camera nextCamera = targetCamera; - nextCamera.m_lookDist = AZ::GetMin(nextCamera.m_lookDist + float(cursorDelta.m_y) * m_cursorSpeedFn(), 0.0f); - return nextCamera; + return PivotDolly(targetCamera, aznumeric_cast(cursorDelta.m_y) * m_motionSpeedFn()); } - void OrbitDollyCursorMoveCameraInput::SetDollyInputChannelId(const InputChannelId& dollyChannelId) + void PivotDollyMotionCameraInput::SetDollyInputChannelId(const InputChannelId& dollyChannelId) { m_dollyChannelId = dollyChannelId; } @@ -739,7 +708,7 @@ namespace AzFramework const auto translation_basis = LookTranslation(nextCamera); const auto axisY = translation_basis.GetBasisY(); - nextCamera.m_lookAt += axisY * scrollDelta * m_scrollSpeedFn(); + nextCamera.m_pivot += axisY * scrollDelta * m_scrollSpeedFn(); EndActivation(); @@ -790,13 +759,13 @@ namespace AzFramework { const float moveRate = AZStd::exp2(cameraProps.m_translateSmoothnessFn()); const float moveTime = AZStd::exp2(-moveRate * deltaTime); - camera.m_lookDist = AZ::Lerp(targetCamera.m_lookDist, currentCamera.m_lookDist, moveTime); - camera.m_lookAt = targetCamera.m_lookAt.Lerp(currentCamera.m_lookAt, moveTime); + camera.m_pivot = targetCamera.m_pivot.Lerp(currentCamera.m_pivot, moveTime); + camera.m_offset = targetCamera.m_offset.Lerp(currentCamera.m_offset, moveTime); } else { - camera.m_lookDist = targetCamera.m_lookDist; - camera.m_lookAt = targetCamera.m_lookAt; + camera.m_pivot = targetCamera.m_pivot; + camera.m_offset = targetCamera.m_offset; } return camera; diff --git a/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.h b/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.h index 69e8b66434..c44d951292 100644 --- a/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.h +++ b/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.h @@ -29,17 +29,15 @@ namespace AzFramework //! @note Order of rotation is Z, Y, X. AZ::Vector3 EulerAngles(const AZ::Matrix3x3& orientation); - //! A simple camera representation using spherical coordinates as input (pitch, yaw and look distance). + //! A simple camera representation using spherical coordinates as input (pitch, yaw, pivot and offset). //! The cameras transform and view can be obtained through accessor functions that use the internal //! spherical coordinates to calculate the position and orientation. struct Camera { - AZ::Vector3 m_lookAt = AZ::Vector3::CreateZero(); //!< Position of camera when m_lookDist is zero, - //!< or position of m_lookAt when m_lookDist is greater - //!< than zero. - float m_yaw{ 0.0 }; //!< Yaw rotation of camera (stored in radians) usually clamped to 0-360 degrees (0-2Pi radians). - float m_pitch{ 0.0 }; //!< Pitch rotation of the camera (stored in radians) usually clamped to +/-90 degrees (-Pi/2 - Pi/2 radians). - float m_lookDist{ 0.0 }; //!< Zero gives first person free look, otherwise orbit about m_lookAt + AZ::Vector3 m_pivot = AZ::Vector3::CreateZero(); //!< Pivot point to rotate about (modified in world space). + AZ::Vector3 m_offset = AZ::Vector3::CreateZero(); //!< Offset relative to pivot (modified in camera space). + float m_yaw = 0.0f; //!< Yaw rotation of camera (stored in radians) usually clamped to 0-360 degrees (0-2Pi radians). + float m_pitch = 0.0f; //!< Pitch rotation of the camera (stored in radians) usually clamped to +/-90 degrees (-Pi/2 - Pi/2 radians). //! View camera transform (V in model-view-projection matrix (MVP)). AZ::Transform View() const; @@ -51,6 +49,15 @@ namespace AzFramework AZ::Vector3 Translation() const; }; + //! Helper to allow the pivot to be positioned without altering the camera's position. + inline void MovePivotDetached(Camera& camera, const AZ::Vector3& pivot) + { + const auto& view = camera.View(); + const auto delta = view.TransformPoint(pivot) - view.TransformPoint(camera.m_pivot); + camera.m_offset -= delta; + camera.m_pivot = pivot; + } + inline AZ::Transform Camera::View() const { return Transform().GetInverse(); @@ -58,8 +65,8 @@ namespace AzFramework inline AZ::Transform Camera::Transform() const { - return AZ::Transform::CreateTranslation(m_lookAt) * AZ::Transform::CreateRotationZ(m_yaw) * - AZ::Transform::CreateRotationX(m_pitch) * AZ::Transform::CreateTranslation(AZ::Vector3::CreateAxisY(m_lookDist)); + return AZ::Transform::CreateTranslation(m_pivot) * AZ::Transform::CreateRotationZ(m_yaw) * AZ::Transform::CreateRotationX(m_pitch) * + AZ::Transform::CreateTranslation(m_offset); } inline AZ::Matrix3x3 Camera::Rotation() const @@ -279,21 +286,37 @@ namespace AzFramework public: bool HandleEvents(const InputEvent& event); Camera StepCamera(const Camera& targetCamera, float deltaTime); - bool HandlingEvents() const - { - return m_handlingEvents; - } + bool HandlingEvents() const; Cameras m_cameras; //!< Represents a collection of camera inputs that together provide a camera controller. private: - ScreenVector m_motionDelta; //!< The delta used for look/orbit/pan (rotation + translation) - two dimensional. + ScreenVector m_motionDelta; //!< The delta used for look/pivot/pan (rotation + translation) - two dimensional. CursorState m_cursorState; //!< The current and previous position of the cursor (used to calculate movement delta). float m_scrollDelta = 0.0f; //!< The delta used for dolly/movement (translation) - one dimensional. bool m_handlingEvents = false; //!< Is the camera system currently handling events (events are consumed and not propagated). }; - //! A camera input to handle motion deltas that can rotate or orbit the camera. + inline bool CameraSystem::HandlingEvents() const + { + return m_handlingEvents; + } + + //! Clamps pitch to be +/-90 degrees (-Pi/2, Pi/2). + //! @param pitch Pitch angle in radians. + inline float ClampPitchRotation(const float pitch) + { + return AZ::GetClamp(pitch, -AZ::Constants::HalfPi, AZ::Constants::HalfPi); + } + + //! Ensures yaw wraps between 0 and 360 degrees (0, 2Pi). + //! @param yaw Yaw angle in radians. + inline float WrapYawRotation(const float yaw) + { + return AZStd::fmod(yaw + AZ::Constants::TwoPi, AZ::Constants::TwoPi); + } + + //! A camera input to handle motion deltas that can rotate or pivot the camera. class RotateCameraInput : public CameraInput { public: @@ -332,8 +355,8 @@ namespace AzFramework return { orientation.GetBasisX(), orientation.GetBasisZ() }; } - //! PanAxes to use while in 'orbit' camera behavior. - inline PanAxes OrbitPan(const Camera& camera) + //! PanAxes to use while in 'pivot' camera behavior. + inline PanAxes PivotPan(const Camera& camera) { const AZ::Matrix3x3 orientation = camera.Rotation(); @@ -347,11 +370,23 @@ namespace AzFramework return { basisX, basisY }; } + using TranslationDeltaFn = AZStd::function; + + inline void TranslatePivot(Camera& camera, const AZ::Vector3& delta) + { + camera.m_pivot += delta; + } + + inline void TranslateOffset(Camera& camera, const AZ::Vector3& delta) + { + camera.m_offset += camera.View().TransformVector(delta); + } + //! A camera input to handle motion deltas that can pan the camera (translate in two axes). class PanCameraInput : public CameraInput { public: - PanCameraInput(const InputChannelId& panChannelId, PanAxesFn panAxesFn); + PanCameraInput(const InputChannelId& panChannelId, PanAxesFn panAxesFn, TranslationDeltaFn translationDeltaFn); // CameraInput overrides ... bool HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta) override; @@ -365,6 +400,7 @@ namespace AzFramework private: PanAxesFn m_panAxesFn; //!< Builder for the particular pan axes (provided in the constructor). + TranslationDeltaFn m_translationDeltaFn; //!< How to apply the translation delta to the camera offset or pivot. InputChannelId m_panChannelId; //!< Input channel to begin the pan camera input. ClickDetector m_clickDetector; //!< Used to determine when a sufficient motion delta has occurred after an initial discrete input //!< event has started (press and move event). @@ -385,8 +421,8 @@ namespace AzFramework return AZ::Matrix3x3::CreateFromColumns(basisX, basisY, basisZ); } - //! TranslationAxes to use while in 'orbit' camera behavior. - inline AZ::Matrix3x3 OrbitTranslation(const Camera& camera) + //! TranslationAxes to use while in 'pivot' camera behavior. + inline AZ::Matrix3x3 PivotTranslation(const Camera& camera) { const AZ::Matrix3x3 orientation = camera.Rotation(); @@ -417,8 +453,10 @@ namespace AzFramework class TranslateCameraInput : public CameraInput { public: - explicit TranslateCameraInput( - TranslationAxesFn translationAxesFn, const TranslateCameraInputChannelIds& translateCameraInputChannelIds); + TranslateCameraInput( + const TranslateCameraInputChannelIds& translateCameraInputChannelIds, + TranslationAxesFn translationAxesFn, + TranslationDeltaFn translateDeltaFn); // CameraInput overrides ... bool HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta) override; @@ -492,15 +530,16 @@ namespace AzFramework TranslationType m_translation = TranslationType::Nil; //!< Types of translation the camera input is under. TranslationAxesFn m_translationAxesFn; //!< Builder for translation axes. + TranslationDeltaFn m_translateDeltaFn; //!< How to apply the translation delta to the camera offset or pivot. TranslateCameraInputChannelIds m_translateCameraInputChannelIds; //!< Input channel ids that map to internal translation types. bool m_boost = false; //!< Is the translation speed currently being multiplied/scaled upwards. }; - //! A camera input to handle discrete scroll events that can modify the camera look distance. - class OrbitDollyScrollCameraInput : public CameraInput + //! A camera input to handle discrete scroll events that can modify the camera pivot distance. + class PivotDollyScrollCameraInput : public CameraInput { public: - OrbitDollyScrollCameraInput(); + PivotDollyScrollCameraInput(); // CameraInput overrides ... bool HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta) override; @@ -509,11 +548,11 @@ namespace AzFramework AZStd::function m_scrollSpeedFn; }; - //! A camera input to handle motion deltas that can modify the camera look distance. - class OrbitDollyCursorMoveCameraInput : public CameraInput + //! A camera input to handle motion deltas that can modify the camera pivot distance. + class PivotDollyMotionCameraInput : public CameraInput { public: - explicit OrbitDollyCursorMoveCameraInput(const InputChannelId& dollyChannelId); + explicit PivotDollyMotionCameraInput(const InputChannelId& dollyChannelId); // CameraInput overrides ... bool HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta) override; @@ -521,7 +560,7 @@ namespace AzFramework void SetDollyInputChannelId(const InputChannelId& dollyChannelId); - AZStd::function m_cursorSpeedFn; + AZStd::function m_motionSpeedFn; private: InputChannelId m_dollyChannelId; //!< Input channel to begin the dolly cursor camera input. @@ -544,36 +583,36 @@ namespace AzFramework //! A camera input that doubles as its own set of camera inputs. //! It is 'exclusive', so does not overlap with other sibling camera inputs - it runs its own set of camera inputs as 'children'. - class OrbitCameraInput : public CameraInput + class PivotCameraInput : public CameraInput { public: - using LookAtFn = AZStd::function(const AZ::Vector3& position, const AZ::Vector3& direction)>; + using PivotFn = AZStd::function; - explicit OrbitCameraInput(const InputChannelId& orbitChannelId); + explicit PivotCameraInput(const InputChannelId& pivotChannelId); // CameraInput overrides ... bool HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta) override; Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime) override; bool Exclusive() const override; - void SetOrbitInputChannelId(const InputChannelId& orbitChanneId); + void SetPivotInputChannelId(const InputChannelId& pivotChanneId); - Cameras m_orbitCameras; //!< The camera inputs to run when this camera input is active (only these will run as it is exclusive). + Cameras m_pivotCameras; //!< The camera inputs to run when this camera input is active (only these will run as it is exclusive). - //! Override the default behavior for how a look-at point is calculated. - void SetLookAtFn(const LookAtFn& lookAtFn); + //! Override the default behavior for how a pivot point is calculated. + void SetPivotFn(PivotFn pivotFn); private: - InputChannelId m_orbitChannelId; //!< Input channel to begin the orbit camera input. - LookAtFn m_lookAtFn; //!< The look-at behavior to use for this orbit camera (how is the look-at point calculated/retrieved). + InputChannelId m_pivotChannelId; //!< Input channel to begin the pivot camera input. + PivotFn m_pivotFn; //!< The pivot position to use for this pivot camera (how is the pivot point calculated/retrieved). }; - inline void OrbitCameraInput::SetLookAtFn(const LookAtFn& lookAtFn) + inline void PivotCameraInput::SetPivotFn(PivotFn pivotFn) { - m_lookAtFn = lookAtFn; + m_pivotFn = AZStd::move(pivotFn); } - inline bool OrbitCameraInput::Exclusive() const + inline bool PivotCameraInput::Exclusive() const { return true; } diff --git a/Code/Framework/AzFramework/Tests/CameraInputTests.cpp b/Code/Framework/AzFramework/Tests/CameraInputTests.cpp index df7d22f7ca..1e0c805587 100644 --- a/Code/Framework/AzFramework/Tests/CameraInputTests.cpp +++ b/Code/Framework/AzFramework/Tests/CameraInputTests.cpp @@ -26,7 +26,8 @@ namespace UnitTest { constexpr float deltaTime = 0.01666f; // 60fps const bool consumed = m_cameraSystem->HandleEvents(event); - m_camera = m_cameraSystem->StepCamera(m_targetCamera, deltaTime); + m_targetCamera = m_cameraSystem->StepCamera(m_targetCamera, deltaTime); + m_camera = m_targetCamera; // no smoothing return consumed; } @@ -45,20 +46,38 @@ namespace UnitTest m_translateCameraInputChannelIds.m_boostChannelId = AzFramework::InputChannelId("keyboard_key_modifier_shift_l"); m_firstPersonRotateCamera = AZStd::make_shared(AzFramework::InputDeviceMouse::Button::Right); - m_firstPersonTranslateCamera = - AZStd::make_shared(AzFramework::LookTranslation, m_translateCameraInputChannelIds); + // set rotate speed to be a value that will scale motion delta (pixels moved) by a thousandth. + m_firstPersonRotateCamera->m_rotateSpeedFn = []() + { + return 0.001f; + }; - m_orbitCamera = AZStd::make_shared(m_orbitChannelId); - auto orbitRotateCamera = AZStd::make_shared(AzFramework::InputDeviceMouse::Button::Left); - auto orbitTranslateCamera = - AZStd::make_shared(AzFramework::OrbitTranslation, m_translateCameraInputChannelIds); + m_firstPersonTranslateCamera = AZStd::make_shared( + m_translateCameraInputChannelIds, AzFramework::LookTranslation, AzFramework::TranslatePivot); - m_orbitCamera->m_orbitCameras.AddCamera(orbitRotateCamera); - m_orbitCamera->m_orbitCameras.AddCamera(orbitTranslateCamera); + m_pivotCamera = AZStd::make_shared(m_pivotChannelId); + m_pivotCamera->SetPivotFn( + [this](const AZ::Vector3&, const AZ::Vector3&) + { + return m_pivot; + }); + + auto pivotRotateCamera = AZStd::make_shared(AzFramework::InputDeviceMouse::Button::Left); + // set rotate speed to be a value that will scale motion delta (pixels moved) by a thousandth. + pivotRotateCamera->m_rotateSpeedFn = []() + { + return 0.001f; + }; + + auto pivotTranslateCamera = AZStd::make_shared( + m_translateCameraInputChannelIds, AzFramework::PivotTranslation, AzFramework::TranslateOffset); + + m_pivotCamera->m_pivotCameras.AddCamera(pivotRotateCamera); + m_pivotCamera->m_pivotCameras.AddCamera(pivotTranslateCamera); m_cameraSystem->m_cameras.AddCamera(m_firstPersonRotateCamera); m_cameraSystem->m_cameras.AddCamera(m_firstPersonTranslateCamera); - m_cameraSystem->m_cameras.AddCamera(m_orbitCamera); + m_cameraSystem->m_cameras.AddCamera(m_pivotCamera); // these tests rely on using motion delta, not cursor positions (default is true) AzFramework::ed_cameraSystemUseCursor = false; @@ -68,7 +87,7 @@ namespace UnitTest { AzFramework::ed_cameraSystemUseCursor = true; - m_orbitCamera.reset(); + m_pivotCamera.reset(); m_firstPersonRotateCamera.reset(); m_firstPersonTranslateCamera.reset(); @@ -78,24 +97,29 @@ namespace UnitTest AllocatorsTestFixture::TearDown(); } - AzFramework::InputChannelId m_orbitChannelId = AzFramework::InputChannelId("keyboard_key_modifier_alt_l"); + AzFramework::InputChannelId m_pivotChannelId = AzFramework::InputChannelId("keyboard_key_modifier_alt_l"); AzFramework::TranslateCameraInputChannelIds m_translateCameraInputChannelIds; AZStd::shared_ptr m_firstPersonRotateCamera; AZStd::shared_ptr m_firstPersonTranslateCamera; - AZStd::shared_ptr m_orbitCamera; + AZStd::shared_ptr m_pivotCamera; + AZ::Vector3 m_pivot = AZ::Vector3::CreateZero(); + + //! This is approximately Pi/2 * 1000 - this can be used to rotate the camera 90 degrees (pitch or yaw based + //! on vertical or horizontal motion) as the rotate speed function is set to be 1/1000. + inline static const int PixelMotionDelta = 1570; }; - TEST_F(CameraInputFixture, BeginAndEndOrbitCameraInputConsumesCorrectEvents) + TEST_F(CameraInputFixture, BeginAndEndPivotCameraInputConsumesCorrectEvents) { - // begin orbit camera + // begin pivot camera const bool consumed1 = HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ AzFramework::InputDeviceKeyboard::Key::ModifierAltL, AzFramework::InputChannel::State::Began }); - // begin listening for orbit rotate (click detector) - event is not consumed + // begin listening for pivot rotate (click detector) - event is not consumed const bool consumed2 = HandleEventAndUpdate( AzFramework::DiscreteInputEvent{ AzFramework::InputDeviceMouse::Button::Left, AzFramework::InputChannel::State::Began }); - // begin orbit rotate (mouse has moved sufficient distance to initiate) + // begin pivot rotate (mouse has moved sufficient distance to initiate) const bool consumed3 = HandleEventAndUpdate(AzFramework::HorizontalMotionEvent{ 5 }); - // end orbit (mouse up) - event is not consumed + // end pivot (mouse up) - event is not consumed const bool consumed4 = HandleEventAndUpdate( AzFramework::DiscreteInputEvent{ AzFramework::InputDeviceMouse::Button::Left, AzFramework::InputChannel::State::Ended }); @@ -236,29 +260,110 @@ namespace UnitTest EXPECT_TRUE(activationEnded); } - TEST_F(CameraInputFixture, OrbitCameraInputHandlesLookAtPointAndSelfAtSamePositionWhenOrbiting) + TEST_F(CameraInputFixture, PivotCameraInputHandlesLookAtPointAndSelfAtSamePositionWhenPivoting) { // create pathological lookAtFn that just returns the same position as the camera - m_orbitCamera->SetLookAtFn( + m_pivotCamera->SetPivotFn( [](const AZ::Vector3& position, [[maybe_unused]] const AZ::Vector3& direction) { return position; }); + const auto expectedCameraPosition = AZ::Vector3(10.0f, 10.0f, 10.0f); AzFramework::UpdateCameraFromTransform( m_targetCamera, AZ::Transform::CreateFromQuaternionAndTranslation( - AZ::Quaternion::CreateFromEulerAnglesDegrees(AZ::Vector3(0.0f, 0.0f, 90.0f)), AZ::Vector3(10.0f, 10.0f, 10.0f))); + AZ::Quaternion::CreateFromEulerAnglesDegrees(AZ::Vector3(0.0f, 0.0f, 90.0f)), expectedCameraPosition)); - m_camera = m_targetCamera; + HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_pivotChannelId, AzFramework::InputChannel::State::Began }); - HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_orbitChannelId, AzFramework::InputChannel::State::Began }); + // verify the camera yaw has not changed and pivot point matches the expected camera position + using ::testing::FloatNear; + EXPECT_THAT(m_camera.m_yaw, FloatNear(AZ::DegToRad(90.0f), 0.001f)); + EXPECT_THAT(m_camera.m_pitch, FloatNear(0.0f, 0.001f)); + EXPECT_THAT(m_camera.m_offset, IsClose(AZ::Vector3::CreateZero())); + EXPECT_THAT(m_camera.m_pivot, IsClose(expectedCameraPosition)); + } - // verify the camera yaw has not changed and the look at point - // does not match that of the camera translation - using ::testing::Eq; - using ::testing::Not; - EXPECT_THAT(m_camera.m_yaw, Eq(AZ::DegToRad(90.0f))); - EXPECT_THAT(m_camera.m_lookAt, Not(IsClose(m_camera.Translation()))); + TEST_F(CameraInputFixture, FirstPersonRotateCameraInputRotatesYawByNinetyDegreesWithRequiredPixelDelta) + { + const auto cameraStartingPosition = AZ::Vector3::CreateAxisY(-10.0f); + m_targetCamera.m_pivot = cameraStartingPosition; + + HandleEventAndUpdate( + AzFramework::DiscreteInputEvent{ AzFramework::InputDeviceMouse::Button::Right, AzFramework::InputChannel::State::Began }); + HandleEventAndUpdate(AzFramework::HorizontalMotionEvent{ PixelMotionDelta }); + + const float expectedYaw = AzFramework::WrapYawRotation(-AZ::Constants::HalfPi); + + using ::testing::FloatNear; + EXPECT_THAT(m_camera.m_yaw, FloatNear(expectedYaw, 0.001f)); + EXPECT_THAT(m_camera.m_pitch, FloatNear(0.0f, 0.001f)); + EXPECT_THAT(m_camera.m_pivot, IsClose(cameraStartingPosition)); + EXPECT_THAT(m_camera.m_offset, IsClose(AZ::Vector3::CreateZero())); + } + + TEST_F(CameraInputFixture, FirstPersonRotateCameraInputRotatesPitchByNinetyDegreesWithRequiredPixelDelta) + { + const auto cameraStartingPosition = AZ::Vector3::CreateAxisY(-10.0f); + m_targetCamera.m_pivot = cameraStartingPosition; + + HandleEventAndUpdate( + AzFramework::DiscreteInputEvent{ AzFramework::InputDeviceMouse::Button::Right, AzFramework::InputChannel::State::Began }); + HandleEventAndUpdate(AzFramework::VerticalMotionEvent{ PixelMotionDelta }); + + const float expectedPitch = AzFramework::ClampPitchRotation(-AZ::Constants::HalfPi); + + using ::testing::FloatNear; + EXPECT_THAT(m_camera.m_yaw, FloatNear(0.0f, 0.001f)); + EXPECT_THAT(m_camera.m_pitch, FloatNear(expectedPitch, 0.001f)); + EXPECT_THAT(m_camera.m_pivot, IsClose(cameraStartingPosition)); + EXPECT_THAT(m_camera.m_offset, IsClose(AZ::Vector3::CreateZero())); + } + + TEST_F(CameraInputFixture, PivotRotateCameraInputRotatesPitchOffsetByNinetyDegreesWithRequiredPixelDelta) + { + const auto cameraStartingPosition = AZ::Vector3::CreateAxisY(-20.0f); + m_targetCamera.m_pivot = cameraStartingPosition; + + m_pivot = AZ::Vector3::CreateAxisY(-10.0f); + + HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_pivotChannelId, AzFramework::InputChannel::State::Began }); + HandleEventAndUpdate( + AzFramework::DiscreteInputEvent{ AzFramework::InputDeviceMouse::Button::Left, AzFramework::InputChannel::State::Began }); + HandleEventAndUpdate(AzFramework::VerticalMotionEvent{ PixelMotionDelta }); + + const auto expectedCameraEndingPosition = AZ::Vector3(0.0f, -10.0f, 10.0f); + const float expectedPitch = AzFramework::ClampPitchRotation(-AZ::Constants::HalfPi); + + using ::testing::FloatNear; + EXPECT_THAT(m_camera.m_yaw, FloatNear(0.0f, 0.001f)); + EXPECT_THAT(m_camera.m_pitch, FloatNear(expectedPitch, 0.001f)); + EXPECT_THAT(m_camera.m_pivot, IsClose(m_pivot)); + EXPECT_THAT(m_camera.m_offset, IsClose(AZ::Vector3::CreateAxisY(-10.0f))); + EXPECT_THAT(m_camera.Translation(), IsCloseTolerance(expectedCameraEndingPosition, 0.01f)); + } + + TEST_F(CameraInputFixture, PivotRotateCameraInputRotatesYawOffsetByNinetyDegreesWithRequiredPixelDelta) + { + const auto cameraStartingPosition = AZ::Vector3(15.0f, -20.0f, 0.0f); + m_targetCamera.m_pivot = cameraStartingPosition; + + m_pivot = AZ::Vector3(10.0f, -10.0f, 0.0f); + + HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_pivotChannelId, AzFramework::InputChannel::State::Began }); + HandleEventAndUpdate( + AzFramework::DiscreteInputEvent{ AzFramework::InputDeviceMouse::Button::Left, AzFramework::InputChannel::State::Began }); + HandleEventAndUpdate(AzFramework::HorizontalMotionEvent{ -PixelMotionDelta }); + + const auto expectedCameraEndingPosition = AZ::Vector3(20.0f, -5.0f, 0.0f); + const float expectedYaw = AzFramework::WrapYawRotation(AZ::Constants::HalfPi); + + using ::testing::FloatNear; + EXPECT_THAT(m_camera.m_yaw, FloatNear(expectedYaw, 0.001f)); + EXPECT_THAT(m_camera.m_pitch, FloatNear(0.0f, 0.001f)); + EXPECT_THAT(m_camera.m_pivot, IsClose(m_pivot)); + EXPECT_THAT(m_camera.m_offset, IsClose(AZ::Vector3(5.0f, -10.0f, 0.0f))); + EXPECT_THAT(m_camera.Translation(), IsCloseTolerance(expectedCameraEndingPosition, 0.01f)); } } // namespace UnitTest diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/ModularViewportCameraController.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/ModularViewportCameraController.h index 4956fbc1dc..32897ab4d9 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/ModularViewportCameraController.h +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/ModularViewportCameraController.h @@ -10,7 +10,6 @@ #include #include -#include #include #include @@ -103,7 +102,6 @@ namespace AtomToolsFramework class ModularViewportCameraControllerInstance final : public AzFramework::MultiViewportControllerInstanceInterface , public ModularViewportCameraControllerRequestBus::Handler - , private AzFramework::ViewportDebugDisplayEventBus::Handler { public: explicit ModularViewportCameraControllerInstance(AzFramework::ViewportId viewportId, ModularViewportCameraController* controller); @@ -121,9 +119,6 @@ namespace AtomToolsFramework void ClearReferenceFrame() override; private: - // AzFramework::ViewportDebugDisplayEventBus overrides ... - void DisplayViewport(const AzFramework::ViewportInfo& viewportInfo, AzFramework::DebugDisplayRequests& debugDisplay) override; - //! Update the reference frame after a change has been made to the camera //! view without updating the internal camera via user input. void RefreshReferenceFrame(); diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/ModularViewportCameraController.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/ModularViewportCameraController.cpp index bcc9a08f77..0bdd6fb55c 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/ModularViewportCameraController.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/ModularViewportCameraController.cpp @@ -21,15 +21,6 @@ namespace AtomToolsFramework { - AZ_CVAR( - AZ::Color, - ed_cameraSystemOrbitPointColor, - AZ::Color::CreateFromRgba(255, 255, 255, 255), - nullptr, - AZ::ConsoleFunctorFlags::Null, - ""); - AZ_CVAR(float, ed_cameraSystemOrbitPointSize, 0.1f, nullptr, AZ::ConsoleFunctorFlags::Null, ""); - AZ::Transform TransformFromMatrix4x4(const AZ::Matrix4x4& matrix) { const auto rotation = AZ::Matrix3x3::CreateFromMatrix4x4(matrix); @@ -200,14 +191,12 @@ namespace AtomToolsFramework m_cameraViewMatrixChangeHandler = AZ::RPI::ViewportContext::MatrixChangedEvent::Handler(handleCameraChange); m_modularCameraViewportContext->ConnectViewMatrixChangedHandler(m_cameraViewMatrixChangeHandler); - AzFramework::ViewportDebugDisplayEventBus::Handler::BusConnect(AzToolsFramework::GetEntityContextId()); ModularViewportCameraControllerRequestBus::Handler::BusConnect(viewportId); } ModularViewportCameraControllerInstance::~ModularViewportCameraControllerInstance() { ModularViewportCameraControllerRequestBus::Handler::BusDisconnect(); - AzFramework::ViewportDebugDisplayEventBus::Handler::BusDisconnect(); } bool ModularViewportCameraControllerInstance::HandleInputChannelEvent(const AzFramework::ViewportControllerInputEvent& event) @@ -272,7 +261,8 @@ namespace AtomToolsFramework const AZ::Vector3 eulerAngles = AzFramework::EulerAngles(AZ::Matrix3x3::CreateFromTransform(current)); m_camera.m_pitch = eulerAngles.GetX(); m_camera.m_yaw = eulerAngles.GetZ(); - m_camera.m_lookAt = current.GetTranslation(); + m_camera.m_pivot = current.GetTranslation(); + m_camera.m_offset = AZ::Vector3::CreateZero(); m_targetCamera = m_camera; m_modularCameraViewportContext->SetCameraTransform(current); @@ -287,17 +277,6 @@ namespace AtomToolsFramework m_updatingTransformInternally = false; } - void ModularViewportCameraControllerInstance::DisplayViewport( - [[maybe_unused]] const AzFramework::ViewportInfo& viewportInfo, AzFramework::DebugDisplayRequests& debugDisplay) - { - if (const float alpha = AZStd::min(-m_camera.m_lookDist / 5.0f, 1.0f); alpha > AZ::Constants::FloatEpsilon) - { - const AZ::Color orbitPointColor = ed_cameraSystemOrbitPointColor; - debugDisplay.SetColor(orbitPointColor.GetR(), orbitPointColor.GetG(), orbitPointColor.GetB(), alpha); - debugDisplay.DrawWireSphere(m_camera.m_lookAt, ed_cameraSystemOrbitPointSize); - } - } - void ModularViewportCameraControllerInstance::InterpolateToTransform(const AZ::Transform& worldFromLocal, const float lookAtDistance) { m_cameraMode = CameraMode::Animation; @@ -325,8 +304,8 @@ namespace AtomToolsFramework m_referenceFrameOverride = worldFromLocal; m_targetCamera.m_pitch = 0.0f; m_targetCamera.m_yaw = 0.0f; - m_targetCamera.m_lookAt = AZ::Vector3::CreateZero(); - m_targetCamera.m_lookDist = 0.0f; + m_targetCamera.m_offset = AZ::Vector3::CreateZero(); + m_targetCamera.m_pivot = AZ::Vector3::CreateZero(); m_camera = m_targetCamera; } From 6b75c3b9d71fcd454757ba119e94832a02c8f4fe Mon Sep 17 00:00:00 2001 From: nggieber Date: Wed, 29 Sep 2021 08:55:04 -0700 Subject: [PATCH 09/19] Fixed non-unity compile error Signed-off-by: nggieber --- Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.h b/Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.h index 38b9bf68eb..4ca469098e 100644 --- a/Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.h +++ b/Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.h @@ -9,7 +9,7 @@ #pragma once #if !defined(Q_MOC_RUN) -#include +#include #endif namespace O3DE::ProjectManager From bdc5cb1fff53955836044c0ac333e34b4232cab1 Mon Sep 17 00:00:00 2001 From: Artur K <96597+nemerle@users.noreply.github.com> Date: Wed, 29 Sep 2021 18:30:38 +0200 Subject: [PATCH 10/19] Replace PROFILE define with AZ_PROFILE_BUILD It now follows the schema defined by `AZ_DEBUG_BUILD` define instead. Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> --- .../Execution/Interpreted/ExecutionInterpretedAPI.cpp | 2 +- cmake/Platform/Common/Configurations_common.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Execution/Interpreted/ExecutionInterpretedAPI.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Execution/Interpreted/ExecutionInterpretedAPI.cpp index 8d324e95c0..4d7c8a2cda 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Execution/Interpreted/ExecutionInterpretedAPI.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Execution/Interpreted/ExecutionInterpretedAPI.cpp @@ -503,7 +503,7 @@ namespace ScriptCanvas void InitializeInterpretedStatics(const RuntimeData& runtimeData) { -#if defined(PROFILE) || defined(AZ_DEBUG_BUILD) +#if defined(AZ_PROFILE_BUILD) || defined(AZ_DEBUG_BUILD) Execution::InitializeFromLuaStackFunctions(const_cast(runtimeData.m_debugMap)); #endif if (runtimeData.RequiresStaticInitialization()) diff --git a/cmake/Platform/Common/Configurations_common.cmake b/cmake/Platform/Common/Configurations_common.cmake index 15f7344958..d16dfa3eea 100644 --- a/cmake/Platform/Common/Configurations_common.cmake +++ b/cmake/Platform/Common/Configurations_common.cmake @@ -36,7 +36,7 @@ ly_append_configurations_options( AZ_BUILD_CONFIGURATION_TYPE="${LY_BUILD_CONFIGURATION_TYPE_DEBUG}" DEFINES_PROFILE _PROFILE - PROFILE + AZ_PROFILE_BUILD=1 NDEBUG AZ_ENABLE_TRACING AZ_ENABLE_DEBUG_TOOLS From f44169f7fad4a9a82aded47aeb5f47c3731fd5a6 Mon Sep 17 00:00:00 2001 From: Artur K <96597+nemerle@users.noreply.github.com> Date: Wed, 29 Sep 2021 18:31:01 +0200 Subject: [PATCH 11/19] Cleanup SerializeContext.h pt.1 (#4264) * Remove AssetSerializer inclusion from SerializeContext header Moved a few Reflect methods to new cpp files. In addition, some preparations for further header dependency reductions. Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * Fix smoke test lua failures. Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * Windows build fixes. Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * Missing license headers Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * Fix white-space issues. Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * Code review fix for AzToolsFramework/AssetEditor/AssetEditorBus.h Co-authored-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * Fix inheritance list wrapping broken by older clang-format Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> Co-authored-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> --- .../AssetEditor/AssetEditorRequestsHandler.h | 1 - Code/Editor/AssetEditor/AssetEditorWindow.h | 1 - .../ReflectedPropertyCtrl.cpp | 3 + .../ReflectedPropertyCtrl.h | 1 - .../ReflectedPropertyControl/ReflectedVar.h | 2 +- .../EditorPreferencesTreeWidgetItem.cpp | 3 + Code/Editor/MainWindow.cpp | 5 +- Code/Editor/PythonEditorFuncs.cpp | 1 + .../Editor/TrackView/TrackViewPythonFuncs.cpp | 1 + Code/Editor/ViewportTitleDlg.cpp | 3 +- .../AzCore/Asset/AssetManagerComponent.cpp | 1 + .../AzCore/AzCore/Asset/AssetSerializer.cpp | 1 + .../AzCore/AzCore/Component/EntityUtils.h | 6 +- .../AzCore/AzCore/Name/NameSerializer.cpp | 1 + .../AzCore/AzCore/Script/ScriptProperty.cpp | 2 + .../AzCore/AzCore/Script/ScriptProperty.h | 4 +- .../AzCore/AzCore/Serialization/DataPatch.cpp | 1 + .../Serialization/Json/JsonDeserializer.cpp | 1 + .../Serialization/Json/JsonSerializer.cpp | 2 + .../Serialization/Json/MapSerializer.cpp | 1 + .../AzCore/Serialization/ObjectStream.cpp | 1 + .../AzCore/Serialization/ObjectStream.h | 3 +- .../AzCore/Serialization/SerializeContext.cpp | 2 + .../AzCore/Serialization/SerializeContext.h | 19 +- .../AzCore/AzCore/Slice/SliceComponent.cpp | 1 + .../AzCore/Statistics/StatisticalProfiler.h | 3 +- .../Tests/AZStd/VariantSerialization.cpp | 1 + .../Tests/Asset/AssetManagerLoadingTests.cpp | 1 + .../Asset/AssetManagerStreamingTests.cpp | 1 + .../Tests/Asset/BaseAssetManagerTest.cpp | 1 + .../AzCore/Tests/AssetJsonSerializerTests.cpp | 1 + Code/Framework/AzCore/Tests/AssetManager.cpp | 1 + Code/Framework/AzCore/Tests/Serialization.cpp | 1 + .../AzFramework/Asset/AssetBundleManifest.h | 5 +- .../AzFramework/Asset/AssetSeedList.cpp | 1 + .../AzFramework/Asset/AssetSeedList.h | 1 - .../Asset/Benchmark/BenchmarkAsset.cpp | 1 + .../AzFramework/Asset/SimpleAsset.cpp | 33 +++ .../AzFramework/Asset/SimpleAsset.h | 34 +-- .../AzFramework/Asset/XmlSchemaAsset.h | 1 + .../Entity/EntityOwnershipServiceBus.h | 5 + .../AzFramework/Physics/ClassConverters.cpp | 1 + .../Physics/Collision/CollisionEvents.cpp | 1 + .../Physics/Collision/CollisionGroups.cpp | 2 + .../Physics/Common/PhysicsSceneQueries.cpp | 1 + .../Configuration/SystemConfiguration.cpp | 1 + .../AzFramework/Physics/Material.cpp | 2 + .../AzFramework/Physics/PhysicsScene.cpp | 1 + .../AzFramework/Physics/PhysicsSystem.cpp | 2 + .../AzFramework/AzFramework/Physics/Shape.h | 1 - .../Physics/ShapeConfiguration.cpp | 2 + .../AzFramework/Physics/ShapeConfiguration.h | 1 + .../AzFramework/AzFramework/Physics/Utils.cpp | 4 +- .../AzFramework/Script/ScriptComponent.cpp | 1 + .../Spawnable/SpawnableSystemComponent.cpp | 1 + .../StreamingInstall/StreamingInstall.cpp | 1 + .../StreamingInstallRequests.h | 2 - .../Serialization/ISerializer.inl | 2 +- .../Gallery/ReflectedPropertyEditorPage.cpp | 1 + .../AzToolsFramework/API/EditorEntityAPI.h | 1 + .../Application/ToolsApplication.cpp | 1 + .../Asset/AssetSystemComponent.cpp | 2 + .../AssetBundle/AssetBundleComponent.cpp | 1 + .../AssetEditor/AssetEditorBus.cpp | 24 ++ .../AssetEditor/AssetEditorBus.h | 18 +- .../AssetEditor/AssetEditorWidget.cpp | 1 + .../Entity/EditorEntityHelpers.cpp | 1 + .../Prefab/EditorPrefabComponent.cpp | 1 + .../Prefab/EditorPrefabComponent.h | 1 - .../Prefab/PrefabPublicRequestHandler.cpp | 2 + .../Spawnable/PrefabConversionPipeline.cpp | 1 + .../PropertyTreeEditor/PropertyTreeEditor.h | 1 + .../ToolsComponents/EditorLayerComponent.cpp | 1 + .../ToolsComponents/ScriptEditorComponent.cpp | 1 + .../UI/PropertyEditor/PropertyAssetCtrl.cpp | 1 + .../UI/PropertyEditor/PropertyAssetCtrl.hxx | 1 + .../aztoolsframework_files.cmake | 1 + .../Tests/PropertyTreeEditorTests.cpp | 1 + .../Maestro/Bus/SequenceComponentBus.h | 1 + .../AssetBuilderSDK/AssetBuilderSDK.cpp | 1 + .../SerializationDependencies.cpp | 1 + .../native/AssetManager/AssetCatalog.cpp | 1 + .../AssetManager/AssetRequestHandler.cpp | 3 +- .../SettingsRegistryBuilder.cpp | 1 + .../SerializationDependenciesTests.cpp | 1 + .../Importers/AssImpBlendShapeImporter.cpp | 1 + .../SceneCore/Containers/GraphObjectProxy.h | 4 + .../SceneCore/Containers/SceneManifest.cpp | 1 + Code/Tools/SceneAPI/SceneCore/DllMain.cpp | 1 + .../Behaviors/ScriptProcessorRuleBehavior.cpp | 1 + .../SceneData/GraphData/BlendShapeData.cpp | 1 + .../SceneData/GraphData/MaterialData.cpp | 1 + .../Code/Source/AWSCoreSystemComponent.cpp | 1 + .../Code/Tests/AWSCoreSystemComponentTest.cpp | 1 + .../AWSCoreEditorSystemComponentTest.cpp | 1 + ...AWSGameLiftCreateSessionOnQueueRequest.cpp | 5 +- .../AWSGameLiftCreateSessionRequest.cpp | 5 +- .../Request/AWSGameLiftJoinSessionRequest.cpp | 4 +- .../AWSGameLiftSearchSessionsRequest.cpp | 7 +- .../Source/ArcBallControllerComponent.cpp | 1 + .../SkinnedMesh/SkinnedMeshVertexStreams.h | 1 - .../DisplayMapperConfigurationDescriptor.cpp | 1 + .../Source/Material/MaterialAssignment.cpp | 2 + .../Code/Source/Utils/LightingPreset.cpp | 1 + .../Common/Code/Source/Utils/ModelPreset.cpp | 3 + .../Code/Include/Atom/RHI.Reflect/Handle.h | 1 + .../Source/RHI.Reflect/ShaderSemantic.cpp | 2 + .../Include/Atom/RPI.Public/Model/Model.h | 2 + .../Shader/ShaderVariantListSourceData.cpp | 3 +- .../Code/Source/RPI.Public/Model/Model.cpp | 1 + .../Source/RPI.Public/Model/ModelLodUtils.cpp | 2 + .../Source/RPI.Public/Model/ModelSystem.cpp | 2 + .../Source/RPI.Reflect/Buffer/BufferAsset.cpp | 1 + .../RPI.Reflect/Buffer/BufferAssetView.cpp | 1 + .../RPI.Reflect/Image/StreamingImageAsset.cpp | 1 + .../Image/StreamingImagePoolAsset.cpp | 1 + .../Material/LuaMaterialFunctor.cpp | 1 + .../RPI.Reflect/Material/MaterialAsset.cpp | 1 + .../Material/MaterialPropertyValue.cpp | 1 + .../RPI.Reflect/Material/ShaderCollection.cpp | 1 + .../Source/RPI.Reflect/Model/ModelAsset.cpp | 1 + .../RPI.Reflect/Model/ModelMaterialSlot.cpp | 1 + .../Model/MorphTargetMetaAsset.cpp | 1 + .../Source/RPI.Reflect/Shader/ShaderAsset.cpp | 1 + .../Document/AtomToolsDocumentRequestBus.h | 1 + .../InspectorPropertyGroupWidget.cpp | 1 + .../MaterialEditorViewportInputController.cpp | 1 + .../ViewportSettingsInspector.cpp | 1 + .../Utils/Code/Include/Atom/Utils/Utils.h | 1 + .../Source/Animation/AttachmentComponent.cpp | 1 + .../Animation/EditorAttachmentComponent.cpp | 1 + .../Decals/DecalComponentController.cpp | 1 + .../DiffuseProbeGridComponentController.cpp | 1 + .../EditorDiffuseProbeGridComponent.cpp | 1 + .../ImageBasedLightComponentConfig.cpp | 1 + .../Material/EditorMaterialComponentSlot.cpp | 1 + .../Material/MaterialComponentController.cpp | 9 +- .../Source/Mesh/MeshComponentController.cpp | 1 + .../DisplayMapperComponentConfig.cpp | 1 + .../EditorDisplayMapperComponent.cpp | 3 +- .../GradientWeightModifierComponent.cpp | 2 + .../LookModificationComponentConfig.cpp | 1 + .../LookModificationComponentController.cpp | 1 + .../RadiusWeightModifierComponent.cpp | 2 + .../ShapeWeightModifierComponent.cpp | 2 + ...ShapeWeightModifierComponentController.cpp | 1 + .../EditorReflectionProbeComponent.cpp | 2 + .../ReflectionProbeComponentController.cpp | 1 + .../SkyBox/HDRiSkyboxComponentConfig.cpp | 1 + .../Components/BlastFamilyComponent.cpp | 5 +- .../Components/BlastMeshDataComponent.cpp | 1 + .../Components/BlastSystemComponent.cpp | 1 + .../Editor/EditorBlastFamilyComponent.cpp | 1 + .../Editor/EditorBlastMeshDataComponent.cpp | 1 + .../AnimGraphFollowerParameterAction.cpp | 1 + .../Source/AnimGraphReferenceNode.cpp | 1 + ...imGraphSymbolicFollowerParameterAction.cpp | 1 + .../Integration/Components/ActorComponent.cpp | 1 + .../Components/AnimGraphComponent.cpp | 1 + .../Components/SimpleMotionComponent.cpp | 1 + .../Components/EditorActorComponent.cpp | 1 + .../Components/EditorAnimGraphComponent.cpp | 1 + .../Code/Tests/EMotionFXBuilderTests.cpp | 1 + .../Code/Tests/PythonAssetTypesTests.cpp | 1 + .../Tests/PythonReflectionComponentTests.cpp | 1 + .../Components/ImageGradientComponent.cpp | 1 + .../Source/Translation/TranslationAsset.cpp | 2 + .../LYCommonMenu/ImGuiLYEntityOutliner.cpp | 1 + .../Builders/LuaBuilder/LuaBuilderWorker.h | 16 +- .../Scripting/EditorSpawnerComponent.cpp | 1 + .../Source/Scripting/SpawnerComponent.cpp | 1 + .../Code/Tests/Builders/SliceBuilderTests.cpp | 1 + .../Code/Source/UiSpawnerComponent.cpp | 1 + .../Source/Components/NetBindComponent.cpp | 1 + .../Source/MultiplayerSystemComponent.cpp | 1 + .../NetworkSpawnableHolderComponent.cpp | 1 + .../Code/Source/Components/ClothComponent.cpp | 1 + .../ClothComponentMesh/ClothComponentMesh.cpp | 3 + .../Components/EditorClothComponent.cpp | 1 + .../Code/Source/Editor/MeshNodeHandler.cpp | 1 + .../Code/Source/Editor/MeshNodeHandler.h | 1 + .../Code/Source/Utils/MeshAssetHelper.cpp | 1 + .../Code/Editor/EditorClassConverters.cpp | 1 + .../Code/Source/EditorColliderComponent.cpp | 2 + .../Components/CharacterGameplayComponent.cpp | 1 + .../PrefabBuilder/PrefabBuilderTests.cpp | 1 + .../Source/PythonBuilderNotificationHandler.h | 1 + .../Code/Source/PythonBuilderWorker.cpp | 3 +- .../SceneProcessingConfigSystemComponent.cpp | 1 + .../Code/Builder/ScriptCanvasBuilder.cpp | 1 + Gems/ScriptCanvas/Code/Editor/Settings.h | 1 + .../View/Widgets/AssetGraphSceneDataBus.h | 1 + .../ScriptCanvas/Asset/RuntimeAsset.cpp | 1 + .../AutoGen/ScriptCanvasGrammar_Source.jinja | 1 + .../AutoGen/ScriptCanvasNodeable_Source.jinja | 1 + .../Libraries/Core/FunctionDefinitionNode.cpp | 1 + .../ScriptCanvas/Utils/VersionConverters.cpp | 1 + .../Code/Tests/ScriptCanvasBuilderTests.cpp | 1 + .../Nodes/BehaviorContextObjectTestNode.h | 3 + .../ScriptEventBroadcast.h | 5 +- .../ScriptEventMethod.h | 7 +- .../Include/ScriptEvents/ScriptEventMethod.h | 216 +++++------------- .../ScriptEvents/ScriptEventParameter.h | 107 +-------- .../Include/ScriptEvents/ScriptEventTypes.h | 8 + .../ScriptEvents/ScriptEventsAssetRef.h | 125 +--------- .../Source/Editor/ScriptEventsEditorGem.cpp | 1 + .../Code/Source/ScriptEventMethod.cpp | 167 ++++++++++++++ .../Code/Source/ScriptEventParameter.cpp | 122 ++++++++++ .../Code/Source/ScriptEventsAssetRef.cpp | 135 +++++++++++ .../Code/scriptevents_common_files.cmake | 3 + .../Source/InputConfigurationComponent.cpp | 7 +- .../Components/DescriptorListComponent.cpp | 1 + .../Components/MeshBlockerComponent.cpp | 1 + .../Source/DynamicSliceInstanceSpawner.cpp | 1 + .../Code/Source/PrefabInstanceSpawner.cpp | 1 + Gems/Vegetation/Code/Tests/VegetationMocks.h | 1 + .../Source/Asset/EditorWhiteBoxMeshAsset.cpp | 1 + .../Code/Source/EditorWhiteBoxComponent.cpp | 1 + 218 files changed, 861 insertions(+), 488 deletions(-) create mode 100644 Code/Framework/AzToolsFramework/AzToolsFramework/AssetEditor/AssetEditorBus.cpp create mode 100644 Gems/ScriptEvents/Code/Source/ScriptEventMethod.cpp create mode 100644 Gems/ScriptEvents/Code/Source/ScriptEventParameter.cpp create mode 100644 Gems/ScriptEvents/Code/Source/ScriptEventsAssetRef.cpp diff --git a/Code/Editor/AssetEditor/AssetEditorRequestsHandler.h b/Code/Editor/AssetEditor/AssetEditorRequestsHandler.h index ebfa84249d..bbe55e216a 100644 --- a/Code/Editor/AssetEditor/AssetEditorRequestsHandler.h +++ b/Code/Editor/AssetEditor/AssetEditorRequestsHandler.h @@ -7,7 +7,6 @@ */ #pragma once -#include #include #include diff --git a/Code/Editor/AssetEditor/AssetEditorWindow.h b/Code/Editor/AssetEditor/AssetEditorWindow.h index 2cf73ac282..63347d6ff3 100644 --- a/Code/Editor/AssetEditor/AssetEditorWindow.h +++ b/Code/Editor/AssetEditor/AssetEditorWindow.h @@ -9,7 +9,6 @@ #if !defined(Q_MOC_RUN) #include -#include #include #include #include diff --git a/Code/Editor/Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.cpp b/Code/Editor/Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.cpp index 40ea71f577..1151137bfc 100644 --- a/Code/Editor/Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.cpp +++ b/Code/Editor/Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.cpp @@ -26,6 +26,9 @@ #include #include +//AzCore +#include + // Editor #include "Clipboard.h" diff --git a/Code/Editor/Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.h b/Code/Editor/Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.h index 64a4341096..ed5d1915ac 100644 --- a/Code/Editor/Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.h +++ b/Code/Editor/Controls/ReflectedPropertyControl/ReflectedPropertyCtrl.h @@ -12,7 +12,6 @@ #if !defined(Q_MOC_RUN) #include -#include #include #include "Include/EditorCoreAPI.h" #include "ReflectedPropertyItem.h" diff --git a/Code/Editor/Controls/ReflectedPropertyControl/ReflectedVar.h b/Code/Editor/Controls/ReflectedPropertyControl/ReflectedVar.h index a15f8326d1..7c38465c5e 100644 --- a/Code/Editor/Controls/ReflectedPropertyControl/ReflectedVar.h +++ b/Code/Editor/Controls/ReflectedPropertyControl/ReflectedVar.h @@ -10,10 +10,10 @@ #define CRYINCLUDE_EDITOR_UTILS_REFLECTEDVAR_H #pragma once -#include #include #include #include "Util/VariablePropertyType.h" +#include #include #include #include diff --git a/Code/Editor/EditorPreferencesTreeWidgetItem.cpp b/Code/Editor/EditorPreferencesTreeWidgetItem.cpp index 7adc298c2c..09578e72ee 100644 --- a/Code/Editor/EditorPreferencesTreeWidgetItem.cpp +++ b/Code/Editor/EditorPreferencesTreeWidgetItem.cpp @@ -9,6 +9,9 @@ #include "EditorPreferencesTreeWidgetItem.h" +// AzCore +#include + // AzToolsFramework #include diff --git a/Code/Editor/MainWindow.cpp b/Code/Editor/MainWindow.cpp index beb338b732..05477bb0c7 100644 --- a/Code/Editor/MainWindow.cpp +++ b/Code/Editor/MainWindow.cpp @@ -27,10 +27,11 @@ AZ_POP_DISABLE_WARNING #endif // AzCore -#include #include -#include #include +#include +#include +#include #include // AzFramework diff --git a/Code/Editor/PythonEditorFuncs.cpp b/Code/Editor/PythonEditorFuncs.cpp index 455cdfa17d..1b731a3d5f 100644 --- a/Code/Editor/PythonEditorFuncs.cpp +++ b/Code/Editor/PythonEditorFuncs.cpp @@ -18,6 +18,7 @@ #include // AzToolsFramework +#include #include #include diff --git a/Code/Editor/TrackView/TrackViewPythonFuncs.cpp b/Code/Editor/TrackView/TrackViewPythonFuncs.cpp index 72da1e0b18..dc55411f80 100644 --- a/Code/Editor/TrackView/TrackViewPythonFuncs.cpp +++ b/Code/Editor/TrackView/TrackViewPythonFuncs.cpp @@ -19,6 +19,7 @@ // Editor #include "AnimationContext.h" +#include namespace { diff --git a/Code/Editor/ViewportTitleDlg.cpp b/Code/Editor/ViewportTitleDlg.cpp index 65d6de8944..0d05e0bf44 100644 --- a/Code/Editor/ViewportTitleDlg.cpp +++ b/Code/Editor/ViewportTitleDlg.cpp @@ -36,8 +36,9 @@ #include "MathConversion.h" #include "EditorViewportSettings.h" -#include +#include #include +#include #include #include diff --git a/Code/Framework/AzCore/AzCore/Asset/AssetManagerComponent.cpp b/Code/Framework/AzCore/AzCore/Asset/AssetManagerComponent.cpp index 93315c9c81..b40c36bc6b 100644 --- a/Code/Framework/AzCore/AzCore/Asset/AssetManagerComponent.cpp +++ b/Code/Framework/AzCore/AzCore/Asset/AssetManagerComponent.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include diff --git a/Code/Framework/AzCore/AzCore/Asset/AssetSerializer.cpp b/Code/Framework/AzCore/AzCore/Asset/AssetSerializer.cpp index ee594c585b..b5cc6c5df4 100644 --- a/Code/Framework/AzCore/AzCore/Asset/AssetSerializer.cpp +++ b/Code/Framework/AzCore/AzCore/Asset/AssetSerializer.cpp @@ -8,6 +8,7 @@ #include #include +#include #include namespace AZ { diff --git a/Code/Framework/AzCore/AzCore/Component/EntityUtils.h b/Code/Framework/AzCore/AzCore/Component/EntityUtils.h index ce258bc637..5c02a3fe74 100644 --- a/Code/Framework/AzCore/AzCore/Component/EntityUtils.h +++ b/Code/Framework/AzCore/AzCore/Component/EntityUtils.h @@ -5,8 +5,7 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ -#ifndef AZCORE_ENTITY_UTILS_H -#define AZCORE_ENTITY_UTILS_H +#pragma once #include #include @@ -217,6 +216,3 @@ namespace AZ } // namespace EntityUtils } // namespace AZ - -#endif // AZCORE_ENTITY_UTILS_H -#pragma once diff --git a/Code/Framework/AzCore/AzCore/Name/NameSerializer.cpp b/Code/Framework/AzCore/AzCore/Name/NameSerializer.cpp index bf3cad7178..581e11ff04 100644 --- a/Code/Framework/AzCore/AzCore/Name/NameSerializer.cpp +++ b/Code/Framework/AzCore/AzCore/Name/NameSerializer.cpp @@ -7,6 +7,7 @@ */ #include +#include namespace AZ { diff --git a/Code/Framework/AzCore/AzCore/Script/ScriptProperty.cpp b/Code/Framework/AzCore/AzCore/Script/ScriptProperty.cpp index dbccda4de2..578bbcf271 100644 --- a/Code/Framework/AzCore/AzCore/Script/ScriptProperty.cpp +++ b/Code/Framework/AzCore/AzCore/Script/ScriptProperty.cpp @@ -5,11 +5,13 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ +#include #include #include #include #include #include +#include namespace AZ { diff --git a/Code/Framework/AzCore/AzCore/Script/ScriptProperty.h b/Code/Framework/AzCore/AzCore/Script/ScriptProperty.h index f38931127d..6b7275dfeb 100644 --- a/Code/Framework/AzCore/AzCore/Script/ScriptProperty.h +++ b/Code/Framework/AzCore/AzCore/Script/ScriptProperty.h @@ -5,8 +5,7 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ -#ifndef AZCORE_SCRIPT_SCRIPTPROPERTY_H -#define AZCORE_SCRIPT_SCRIPTPROPERTY_H +#pragma once #include #include @@ -490,5 +489,4 @@ namespace AZ }; } -#endif diff --git a/Code/Framework/AzCore/AzCore/Serialization/DataPatch.cpp b/Code/Framework/AzCore/AzCore/Serialization/DataPatch.cpp index 01a98667fa..6f1635148c 100644 --- a/Code/Framework/AzCore/AzCore/Serialization/DataPatch.cpp +++ b/Code/Framework/AzCore/AzCore/Serialization/DataPatch.cpp @@ -8,6 +8,7 @@ #include +#include #include #include #include diff --git a/Code/Framework/AzCore/AzCore/Serialization/Json/JsonDeserializer.cpp b/Code/Framework/AzCore/AzCore/Serialization/Json/JsonDeserializer.cpp index 324df7c141..a741294544 100644 --- a/Code/Framework/AzCore/AzCore/Serialization/Json/JsonDeserializer.cpp +++ b/Code/Framework/AzCore/AzCore/Serialization/Json/JsonDeserializer.cpp @@ -9,6 +9,7 @@ #include "AzCore/RTTI/TypeInfo.h" #include #include +#include #include #include #include diff --git a/Code/Framework/AzCore/AzCore/Serialization/Json/JsonSerializer.cpp b/Code/Framework/AzCore/AzCore/Serialization/Json/JsonSerializer.cpp index f06fb36be8..8b6c1d154c 100644 --- a/Code/Framework/AzCore/AzCore/Serialization/Json/JsonSerializer.cpp +++ b/Code/Framework/AzCore/AzCore/Serialization/Json/JsonSerializer.cpp @@ -6,7 +6,9 @@ * */ +#include #include +#include #include #include #include diff --git a/Code/Framework/AzCore/AzCore/Serialization/Json/MapSerializer.cpp b/Code/Framework/AzCore/AzCore/Serialization/Json/MapSerializer.cpp index 7978b8104b..196ce28216 100644 --- a/Code/Framework/AzCore/AzCore/Serialization/Json/MapSerializer.cpp +++ b/Code/Framework/AzCore/AzCore/Serialization/Json/MapSerializer.cpp @@ -7,6 +7,7 @@ */ #include +#include #include #include #include diff --git a/Code/Framework/AzCore/AzCore/Serialization/ObjectStream.cpp b/Code/Framework/AzCore/AzCore/Serialization/ObjectStream.cpp index 6251a2e6de..746c80f3ea 100644 --- a/Code/Framework/AzCore/AzCore/Serialization/ObjectStream.cpp +++ b/Code/Framework/AzCore/AzCore/Serialization/ObjectStream.cpp @@ -7,6 +7,7 @@ */ #include +#include #include #include #include diff --git a/Code/Framework/AzCore/AzCore/Serialization/ObjectStream.h b/Code/Framework/AzCore/AzCore/Serialization/ObjectStream.h index 5d920045f8..9f9b3fc9f0 100644 --- a/Code/Framework/AzCore/AzCore/Serialization/ObjectStream.h +++ b/Code/Framework/AzCore/AzCore/Serialization/ObjectStream.h @@ -37,7 +37,8 @@ namespace AZ class GenericStream; } - namespace ObjectStreamInternal { + namespace ObjectStreamInternal + { class ObjectStreamImpl; } diff --git a/Code/Framework/AzCore/AzCore/Serialization/SerializeContext.cpp b/Code/Framework/AzCore/AzCore/Serialization/SerializeContext.cpp index b74039c876..81546f4f28 100644 --- a/Code/Framework/AzCore/AzCore/Serialization/SerializeContext.cpp +++ b/Code/Framework/AzCore/AzCore/Serialization/SerializeContext.cpp @@ -7,6 +7,8 @@ */ #include + +#include #include #include #include diff --git a/Code/Framework/AzCore/AzCore/Serialization/SerializeContext.h b/Code/Framework/AzCore/AzCore/Serialization/SerializeContext.h index 3d7f3c00f8..a37780029e 100644 --- a/Code/Framework/AzCore/AzCore/Serialization/SerializeContext.h +++ b/Code/Framework/AzCore/AzCore/Serialization/SerializeContext.h @@ -5,8 +5,7 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ -#ifndef AZCORE_SERIALIZE_CONTEXT_H -#define AZCORE_SERIALIZE_CONTEXT_H +#pragma once #include @@ -43,6 +42,12 @@ namespace AZ { + namespace Data + { + template + class Asset; + } + class EditContext; class ObjectStream; @@ -2562,11 +2567,13 @@ namespace AZ #include #include -/// include asset generics -#include +// Forward declare asset serialization helper specialization +namespace AZ +{ + template + struct SerializeGenericTypeInfo< Data::Asset >; +} /// include implementation of SerializeContext::EnumBuilder #include -#endif // AZCORE_SERIALIZE_CONTEXT_H -#pragma once diff --git a/Code/Framework/AzCore/AzCore/Slice/SliceComponent.cpp b/Code/Framework/AzCore/AzCore/Slice/SliceComponent.cpp index 82a9175cf9..0b410369f0 100644 --- a/Code/Framework/AzCore/AzCore/Slice/SliceComponent.cpp +++ b/Code/Framework/AzCore/AzCore/Slice/SliceComponent.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include diff --git a/Code/Framework/AzCore/AzCore/Statistics/StatisticalProfiler.h b/Code/Framework/AzCore/AzCore/Statistics/StatisticalProfiler.h index 2d8823c6e8..681635cd1c 100644 --- a/Code/Framework/AzCore/AzCore/Statistics/StatisticalProfiler.h +++ b/Code/Framework/AzCore/AzCore/Statistics/StatisticalProfiler.h @@ -10,6 +10,7 @@ #include //Just to get AZ::NullMutex #include #include +#include #include namespace AZ @@ -243,7 +244,7 @@ namespace AZ //! This one is needed because running statistics are collected many times across //! several frames. This value is used to calculate a per frame sample for @m_totalTimePerFrameStat, - //! by subtracting @m_prevAccumulatedSums from the accumulated sum in @m_statisticsManager. + //! by subtracting @m_prevAccumulatedSums from the accumulated sum in @m_statisticsManager. double m_prevAccumulatedSums; }; diff --git a/Code/Framework/AzCore/Tests/AZStd/VariantSerialization.cpp b/Code/Framework/AzCore/Tests/AZStd/VariantSerialization.cpp index a87aa70d8c..a4f2d1f1e4 100644 --- a/Code/Framework/AzCore/Tests/AZStd/VariantSerialization.cpp +++ b/Code/Framework/AzCore/Tests/AZStd/VariantSerialization.cpp @@ -8,6 +8,7 @@ #include +#include #include #include #include diff --git a/Code/Framework/AzCore/Tests/Asset/AssetManagerLoadingTests.cpp b/Code/Framework/AzCore/Tests/Asset/AssetManagerLoadingTests.cpp index 8ce3747620..caa4cda8f5 100644 --- a/Code/Framework/AzCore/Tests/Asset/AssetManagerLoadingTests.cpp +++ b/Code/Framework/AzCore/Tests/Asset/AssetManagerLoadingTests.cpp @@ -6,6 +6,7 @@ * */ #include +#include #include #include #include diff --git a/Code/Framework/AzCore/Tests/Asset/AssetManagerStreamingTests.cpp b/Code/Framework/AzCore/Tests/Asset/AssetManagerStreamingTests.cpp index a683f9630e..3e9ea42f22 100644 --- a/Code/Framework/AzCore/Tests/Asset/AssetManagerStreamingTests.cpp +++ b/Code/Framework/AzCore/Tests/Asset/AssetManagerStreamingTests.cpp @@ -6,6 +6,7 @@ * */ #include +#include #include #include #include diff --git a/Code/Framework/AzCore/Tests/Asset/BaseAssetManagerTest.cpp b/Code/Framework/AzCore/Tests/Asset/BaseAssetManagerTest.cpp index ba47064998..4dbd3c0e1e 100644 --- a/Code/Framework/AzCore/Tests/Asset/BaseAssetManagerTest.cpp +++ b/Code/Framework/AzCore/Tests/Asset/BaseAssetManagerTest.cpp @@ -7,6 +7,7 @@ */ #include +#include #include #include #include diff --git a/Code/Framework/AzCore/Tests/AssetJsonSerializerTests.cpp b/Code/Framework/AzCore/Tests/AssetJsonSerializerTests.cpp index e968ee28fc..e04c5190f9 100644 --- a/Code/Framework/AzCore/Tests/AssetJsonSerializerTests.cpp +++ b/Code/Framework/AzCore/Tests/AssetJsonSerializerTests.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/Code/Framework/AzCore/Tests/AssetManager.cpp b/Code/Framework/AzCore/Tests/AssetManager.cpp index c5f249cf21..1e875d61dc 100644 --- a/Code/Framework/AzCore/Tests/AssetManager.cpp +++ b/Code/Framework/AzCore/Tests/AssetManager.cpp @@ -6,6 +6,7 @@ * */ #include +#include #include #include #include diff --git a/Code/Framework/AzCore/Tests/Serialization.cpp b/Code/Framework/AzCore/Tests/Serialization.cpp index e554945b55..f1d5edc490 100644 --- a/Code/Framework/AzCore/Tests/Serialization.cpp +++ b/Code/Framework/AzCore/Tests/Serialization.cpp @@ -9,6 +9,7 @@ #include "FileIOBaseTestTypes.h" #include +#include #include #include diff --git a/Code/Framework/AzFramework/AzFramework/Asset/AssetBundleManifest.h b/Code/Framework/AzFramework/AzFramework/Asset/AssetBundleManifest.h index 9e05263c57..9760482231 100644 --- a/Code/Framework/AzFramework/AzFramework/Asset/AssetBundleManifest.h +++ b/Code/Framework/AzFramework/AzFramework/Asset/AssetBundleManifest.h @@ -8,7 +8,10 @@ #pragma once -#include +#include +#include +#include +#include namespace AZ { diff --git a/Code/Framework/AzFramework/AzFramework/Asset/AssetSeedList.cpp b/Code/Framework/AzFramework/AzFramework/Asset/AssetSeedList.cpp index d16f4bf459..b95efc4dff 100644 --- a/Code/Framework/AzFramework/AzFramework/Asset/AssetSeedList.cpp +++ b/Code/Framework/AzFramework/AzFramework/Asset/AssetSeedList.cpp @@ -8,6 +8,7 @@ */ #include +#include namespace AzFramework { diff --git a/Code/Framework/AzFramework/AzFramework/Asset/AssetSeedList.h b/Code/Framework/AzFramework/AzFramework/Asset/AssetSeedList.h index 2ad895596b..e982cb54e1 100644 --- a/Code/Framework/AzFramework/AzFramework/Asset/AssetSeedList.h +++ b/Code/Framework/AzFramework/AzFramework/Asset/AssetSeedList.h @@ -8,7 +8,6 @@ */ #pragma once -#include #include #include #include diff --git a/Code/Framework/AzFramework/AzFramework/Asset/Benchmark/BenchmarkAsset.cpp b/Code/Framework/AzFramework/AzFramework/Asset/Benchmark/BenchmarkAsset.cpp index cea1cb1d8e..351eb97245 100644 --- a/Code/Framework/AzFramework/AzFramework/Asset/Benchmark/BenchmarkAsset.cpp +++ b/Code/Framework/AzFramework/AzFramework/Asset/Benchmark/BenchmarkAsset.cpp @@ -7,6 +7,7 @@ */ #include +#include namespace AzFramework { diff --git a/Code/Framework/AzFramework/AzFramework/Asset/SimpleAsset.cpp b/Code/Framework/AzFramework/AzFramework/Asset/SimpleAsset.cpp index 87e603015a..29cfdc5ca7 100644 --- a/Code/Framework/AzFramework/AzFramework/Asset/SimpleAsset.cpp +++ b/Code/Framework/AzFramework/AzFramework/Asset/SimpleAsset.cpp @@ -7,6 +7,7 @@ */ #include +#include #include namespace AzFramework @@ -36,4 +37,36 @@ namespace AzFramework return ""; } + void SimpleAssetReferenceBase::Reflect(AZ::ReflectContext *context) + { + if (auto serializeContext = azrtti_cast(context)) + { + serializeContext->Class() + ->Version(1) + ->Field("AssetPath", &SimpleAssetReferenceBase::m_assetPath); + + AZ::EditContext* edit = serializeContext->GetEditContext(); + if (edit) + { + edit->Class("Asset path", "Asset reference as a project-relative path") + ->ClassElement(AZ::Edit::ClassElements::EditorData, "") + ->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::Hide) + ; + } + } + + if (auto behaviorContext = azrtti_cast(context)) + { + behaviorContext->Class() + ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) + ->Attribute(AZ::Script::Attributes::Category, "Asset") + ->Attribute(AZ::Script::Attributes::Module, "asset") + ->Property("assetPath", &SimpleAssetReferenceBase::GetAssetPath, nullptr) + ->Property("assetType", &SimpleAssetReferenceBase::GetAssetType, nullptr) + ->Property("fileFilter", &SimpleAssetReferenceBase::GetFileFilter, nullptr) + ->Method("SetAssetPath", &SimpleAssetReferenceBase::SetAssetPath) + ->Attribute(AZ::Script::Attributes::Alias, "set_asset_path") + ; + } + } } // namespace AzFramework diff --git a/Code/Framework/AzFramework/AzFramework/Asset/SimpleAsset.h b/Code/Framework/AzFramework/AzFramework/Asset/SimpleAsset.h index 7c7a1b4fb2..a7525e90bd 100644 --- a/Code/Framework/AzFramework/AzFramework/Asset/SimpleAsset.h +++ b/Code/Framework/AzFramework/AzFramework/Asset/SimpleAsset.h @@ -42,7 +42,6 @@ */ #include -#include #include #include #include @@ -74,38 +73,7 @@ namespace AzFramework virtual AZ::Data::AssetType GetAssetType() const = 0; virtual const char* GetFileFilter() const = 0; - static void Reflect(AZ::ReflectContext* context) - { - if (auto serializeContext = azrtti_cast(context)) - { - serializeContext->Class() - ->Version(1) - ->Field("AssetPath", &SimpleAssetReferenceBase::m_assetPath); - - AZ::EditContext* edit = serializeContext->GetEditContext(); - if (edit) - { - edit->Class("Asset path", "Asset reference as a project-relative path") - ->ClassElement(AZ::Edit::ClassElements::EditorData, "") - ->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::Hide) - ; - } - } - - if (auto behaviorContext = azrtti_cast(context)) - { - behaviorContext->Class() - ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) - ->Attribute(AZ::Script::Attributes::Category, "Asset") - ->Attribute(AZ::Script::Attributes::Module, "asset") - ->Property("assetPath", &SimpleAssetReferenceBase::GetAssetPath, nullptr) - ->Property("assetType", &SimpleAssetReferenceBase::GetAssetType, nullptr) - ->Property("fileFilter", &SimpleAssetReferenceBase::GetFileFilter, nullptr) - ->Method("SetAssetPath", &SimpleAssetReferenceBase::SetAssetPath) - ->Attribute(AZ::Script::Attributes::Alias, "set_asset_path") - ; - } - } + static void Reflect(AZ::ReflectContext* context); protected: diff --git a/Code/Framework/AzFramework/AzFramework/Asset/XmlSchemaAsset.h b/Code/Framework/AzFramework/AzFramework/Asset/XmlSchemaAsset.h index 81338d3843..45004fd7cf 100644 --- a/Code/Framework/AzFramework/AzFramework/Asset/XmlSchemaAsset.h +++ b/Code/Framework/AzFramework/AzFramework/Asset/XmlSchemaAsset.h @@ -9,6 +9,7 @@ #pragma once #include +#include #include #include #include diff --git a/Code/Framework/AzFramework/AzFramework/Entity/EntityOwnershipServiceBus.h b/Code/Framework/AzFramework/AzFramework/Entity/EntityOwnershipServiceBus.h index a8c0779529..08200afb9e 100644 --- a/Code/Framework/AzFramework/AzFramework/Entity/EntityOwnershipServiceBus.h +++ b/Code/Framework/AzFramework/AzFramework/Entity/EntityOwnershipServiceBus.h @@ -10,6 +10,11 @@ #include +namespace AZ +{ + class Entity; +} + namespace AzFramework { using EntityContextId = AZ::Uuid; diff --git a/Code/Framework/AzFramework/AzFramework/Physics/ClassConverters.cpp b/Code/Framework/AzFramework/AzFramework/Physics/ClassConverters.cpp index 9c1a8c83ca..7e918ee364 100644 --- a/Code/Framework/AzFramework/AzFramework/Physics/ClassConverters.cpp +++ b/Code/Framework/AzFramework/AzFramework/Physics/ClassConverters.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include diff --git a/Code/Framework/AzFramework/AzFramework/Physics/Collision/CollisionEvents.cpp b/Code/Framework/AzFramework/AzFramework/Physics/Collision/CollisionEvents.cpp index e98bbcc21a..9c1646fa08 100644 --- a/Code/Framework/AzFramework/AzFramework/Physics/Collision/CollisionEvents.cpp +++ b/Code/Framework/AzFramework/AzFramework/Physics/Collision/CollisionEvents.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include diff --git a/Code/Framework/AzFramework/AzFramework/Physics/Collision/CollisionGroups.cpp b/Code/Framework/AzFramework/AzFramework/Physics/Collision/CollisionGroups.cpp index 2100b0c394..13f7dbc672 100644 --- a/Code/Framework/AzFramework/AzFramework/Physics/Collision/CollisionGroups.cpp +++ b/Code/Framework/AzFramework/AzFramework/Physics/Collision/CollisionGroups.cpp @@ -9,6 +9,8 @@ #include #include +#include +#include #include #include diff --git a/Code/Framework/AzFramework/AzFramework/Physics/Common/PhysicsSceneQueries.cpp b/Code/Framework/AzFramework/AzFramework/Physics/Common/PhysicsSceneQueries.cpp index ff79f097de..28e3762223 100644 --- a/Code/Framework/AzFramework/AzFramework/Physics/Common/PhysicsSceneQueries.cpp +++ b/Code/Framework/AzFramework/AzFramework/Physics/Common/PhysicsSceneQueries.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include diff --git a/Code/Framework/AzFramework/AzFramework/Physics/Configuration/SystemConfiguration.cpp b/Code/Framework/AzFramework/AzFramework/Physics/Configuration/SystemConfiguration.cpp index f55c430a2e..4a2a7f99af 100644 --- a/Code/Framework/AzFramework/AzFramework/Physics/Configuration/SystemConfiguration.cpp +++ b/Code/Framework/AzFramework/AzFramework/Physics/Configuration/SystemConfiguration.cpp @@ -8,6 +8,7 @@ #include +#include #include #include #include diff --git a/Code/Framework/AzFramework/AzFramework/Physics/Material.cpp b/Code/Framework/AzFramework/AzFramework/Physics/Material.cpp index 4ac97cf041..222bc48dda 100644 --- a/Code/Framework/AzFramework/AzFramework/Physics/Material.cpp +++ b/Code/Framework/AzFramework/AzFramework/Physics/Material.cpp @@ -5,6 +5,8 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ + +#include #include #include #include diff --git a/Code/Framework/AzFramework/AzFramework/Physics/PhysicsScene.cpp b/Code/Framework/AzFramework/AzFramework/Physics/PhysicsScene.cpp index 62a3916e9e..a5ebdd04c6 100644 --- a/Code/Framework/AzFramework/AzFramework/Physics/PhysicsScene.cpp +++ b/Code/Framework/AzFramework/AzFramework/Physics/PhysicsScene.cpp @@ -9,6 +9,7 @@ #include #include +#include namespace AzPhysics diff --git a/Code/Framework/AzFramework/AzFramework/Physics/PhysicsSystem.cpp b/Code/Framework/AzFramework/AzFramework/Physics/PhysicsSystem.cpp index 2fda459e20..2ff4780c9e 100644 --- a/Code/Framework/AzFramework/AzFramework/Physics/PhysicsSystem.cpp +++ b/Code/Framework/AzFramework/AzFramework/Physics/PhysicsSystem.cpp @@ -8,6 +8,8 @@ #include +#include + namespace AzPhysics { void SystemInterface::Reflect(AZ::ReflectContext* context) diff --git a/Code/Framework/AzFramework/AzFramework/Physics/Shape.h b/Code/Framework/AzFramework/AzFramework/Physics/Shape.h index 6549269c77..0a766473e1 100644 --- a/Code/Framework/AzFramework/AzFramework/Physics/Shape.h +++ b/Code/Framework/AzFramework/AzFramework/Physics/Shape.h @@ -9,7 +9,6 @@ #pragma once #include -#include #include #include #include diff --git a/Code/Framework/AzFramework/AzFramework/Physics/ShapeConfiguration.cpp b/Code/Framework/AzFramework/AzFramework/Physics/ShapeConfiguration.cpp index ab5cb90616..e90c9d4eed 100644 --- a/Code/Framework/AzFramework/AzFramework/Physics/ShapeConfiguration.cpp +++ b/Code/Framework/AzFramework/AzFramework/Physics/ShapeConfiguration.cpp @@ -7,9 +7,11 @@ */ #include +#include #include #include #include +#include namespace Physics { diff --git a/Code/Framework/AzFramework/AzFramework/Physics/ShapeConfiguration.h b/Code/Framework/AzFramework/AzFramework/Physics/ShapeConfiguration.h index 07845e95b9..b40a8b1edd 100644 --- a/Code/Framework/AzFramework/AzFramework/Physics/ShapeConfiguration.h +++ b/Code/Framework/AzFramework/AzFramework/Physics/ShapeConfiguration.h @@ -10,6 +10,7 @@ #include #include +#include #include namespace Physics diff --git a/Code/Framework/AzFramework/AzFramework/Physics/Utils.cpp b/Code/Framework/AzFramework/AzFramework/Physics/Utils.cpp index 81af7b5840..3dcb37c541 100644 --- a/Code/Framework/AzFramework/AzFramework/Physics/Utils.cpp +++ b/Code/Framework/AzFramework/AzFramework/Physics/Utils.cpp @@ -10,12 +10,14 @@ #include "Utils.h" #include "Material.h" #include "Shape.h" + +#include +#include #include #include #include #include #include -#include #include #include #include diff --git a/Code/Framework/AzFramework/AzFramework/Script/ScriptComponent.cpp b/Code/Framework/AzFramework/AzFramework/Script/ScriptComponent.cpp index e11dc6dace..bfd7c5ac4c 100644 --- a/Code/Framework/AzFramework/AzFramework/Script/ScriptComponent.cpp +++ b/Code/Framework/AzFramework/AzFramework/Script/ScriptComponent.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include diff --git a/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableSystemComponent.cpp b/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableSystemComponent.cpp index cb1e657edd..f6130c9e31 100644 --- a/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableSystemComponent.cpp +++ b/Code/Framework/AzFramework/AzFramework/Spawnable/SpawnableSystemComponent.cpp @@ -7,6 +7,7 @@ */ #include +#include #include #include #include diff --git a/Code/Framework/AzFramework/AzFramework/StreamingInstall/StreamingInstall.cpp b/Code/Framework/AzFramework/AzFramework/StreamingInstall/StreamingInstall.cpp index e1e193abfd..e90dcc17a1 100644 --- a/Code/Framework/AzFramework/AzFramework/StreamingInstall/StreamingInstall.cpp +++ b/Code/Framework/AzFramework/AzFramework/StreamingInstall/StreamingInstall.cpp @@ -7,6 +7,7 @@ */ #include +#include #include "StreamingInstall.h" namespace AzFramework diff --git a/Code/Framework/AzFramework/AzFramework/StreamingInstall/StreamingInstallRequests.h b/Code/Framework/AzFramework/AzFramework/StreamingInstall/StreamingInstallRequests.h index dba2a78f3c..201f9007c5 100644 --- a/Code/Framework/AzFramework/AzFramework/StreamingInstall/StreamingInstallRequests.h +++ b/Code/Framework/AzFramework/AzFramework/StreamingInstall/StreamingInstallRequests.h @@ -9,10 +9,8 @@ #pragma once #include -#include #include #include -#include namespace AzFramework { diff --git a/Code/Framework/AzNetworking/AzNetworking/Serialization/ISerializer.inl b/Code/Framework/AzNetworking/AzNetworking/Serialization/ISerializer.inl index 0d705629f3..56cbb52049 100644 --- a/Code/Framework/AzNetworking/AzNetworking/Serialization/ISerializer.inl +++ b/Code/Framework/AzNetworking/AzNetworking/Serialization/ISerializer.inl @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Gallery/ReflectedPropertyEditorPage.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Gallery/ReflectedPropertyEditorPage.cpp index 7655a2076c..2be0428d63 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Gallery/ReflectedPropertyEditorPage.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Gallery/ReflectedPropertyEditorPage.cpp @@ -9,6 +9,7 @@ #include "ReflectedPropertyEditorPage.h" #include +#include #include #include #include diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/API/EditorEntityAPI.h b/Code/Framework/AzToolsFramework/AzToolsFramework/API/EditorEntityAPI.h index f2808eb0e7..3b5e5c9dc3 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/API/EditorEntityAPI.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/API/EditorEntityAPI.h @@ -8,6 +8,7 @@ #pragma once +#include #include #include diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Application/ToolsApplication.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Application/ToolsApplication.cpp index 91a916ae70..717e0c6f8a 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Application/ToolsApplication.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Application/ToolsApplication.cpp @@ -8,6 +8,7 @@ #include +#include #include #include #include diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Asset/AssetSystemComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Asset/AssetSystemComponent.cpp index 5a1e491b01..cc3153ed8e 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Asset/AssetSystemComponent.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Asset/AssetSystemComponent.cpp @@ -15,7 +15,9 @@ #include #include #include +#include #include +#include namespace AzToolsFramework { diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBundle/AssetBundleComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBundle/AssetBundleComponent.cpp index ee3669a7ba..7083737cf7 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBundle/AssetBundleComponent.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBundle/AssetBundleComponent.cpp @@ -7,6 +7,7 @@ */ #include +#include #include #include #include diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetEditor/AssetEditorBus.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetEditor/AssetEditorBus.cpp new file mode 100644 index 0000000000..43c950cd00 --- /dev/null +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetEditor/AssetEditorBus.cpp @@ -0,0 +1,24 @@ +/* + * 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 "AssetEditorBus.h" +#include +#include + +namespace AzToolsFramework::AssetEditor +{ + void AssetEditorWindowSettings::Reflect(AZ::ReflectContext* context) + { + if (AZ::SerializeContext* serializeContext = azrtti_cast(context)) + { + serializeContext->Class() + ->Field("m_openAssets", &AssetEditorWindowSettings::m_openAssets) + ; + } + } +} // namespace AzToolsFramework::AssetEditor diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetEditor/AssetEditorBus.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetEditor/AssetEditorBus.h index 4d14e5c1bf..becdba44ea 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetEditor/AssetEditorBus.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetEditor/AssetEditorBus.h @@ -8,12 +8,14 @@ #pragma once #include +#include #include -#include #include -#include -namespace AZ { namespace Data { class AssetData; } } +namespace AZ::Data +{ + class AssetData; +} namespace AZStd { @@ -45,15 +47,7 @@ namespace AzToolsFramework static constexpr const char* s_name = "AssetEditorWindowSettings"; - static void Reflect(AZ::ReflectContext* context) - { - if (AZ::SerializeContext* serializeContext = azrtti_cast(context)) - { - serializeContext->Class() - ->Field("m_openAssets", &AssetEditorWindowSettings::m_openAssets) - ; - } - } + static void Reflect(AZ::ReflectContext* context); }; // External interaction with Asset Editor diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetEditor/AssetEditorWidget.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetEditor/AssetEditorWidget.cpp index 95dc0f36c4..e09dd183f8 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetEditor/AssetEditorWidget.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetEditor/AssetEditorWidget.cpp @@ -22,6 +22,7 @@ AZ_POP_DISABLE_WARNING #include #include +#include #include #include #include diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityHelpers.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityHelpers.cpp index 6ed133c830..7789070209 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityHelpers.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityHelpers.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/EditorPrefabComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/EditorPrefabComponent.cpp index 7aa5967a44..d95a704e84 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/EditorPrefabComponent.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/EditorPrefabComponent.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/EditorPrefabComponent.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/EditorPrefabComponent.h index 75b68c859d..8873787bd3 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/EditorPrefabComponent.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/EditorPrefabComponent.h @@ -8,7 +8,6 @@ #pragma once #include -#include namespace AzToolsFramework { diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicRequestHandler.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicRequestHandler.cpp index ad171dc6f4..0aaf81c4c9 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicRequestHandler.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicRequestHandler.cpp @@ -10,6 +10,8 @@ #include +#include + namespace AzToolsFramework { namespace Prefab diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Spawnable/PrefabConversionPipeline.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Spawnable/PrefabConversionPipeline.cpp index 8e0d7fcd42..ac3ada7557 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Spawnable/PrefabConversionPipeline.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Spawnable/PrefabConversionPipeline.cpp @@ -7,6 +7,7 @@ */ #include +#include #include #include diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/PropertyTreeEditor/PropertyTreeEditor.h b/Code/Framework/AzToolsFramework/AzToolsFramework/PropertyTreeEditor/PropertyTreeEditor.h index 7e416c3cc0..648a39fe76 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/PropertyTreeEditor/PropertyTreeEditor.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/PropertyTreeEditor/PropertyTreeEditor.h @@ -12,6 +12,7 @@ #include #include +#include #include #include diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/EditorLayerComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/EditorLayerComponent.cpp index cca0071a4d..f58f273f11 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/EditorLayerComponent.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/EditorLayerComponent.cpp @@ -7,6 +7,7 @@ */ #include "EditorLayerComponent.h" #include +#include #include #include #include diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/ScriptEditorComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/ScriptEditorComponent.cpp index cc350c8107..be29af5c0f 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/ScriptEditorComponent.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/ScriptEditorComponent.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyAssetCtrl.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyAssetCtrl.cpp index c07191fda2..ba84e662c1 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyAssetCtrl.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyAssetCtrl.cpp @@ -33,6 +33,7 @@ AZ_POP_DISABLE_WARNING #include #include #include +#include #include #include #include diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyAssetCtrl.hxx b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyAssetCtrl.hxx index 33619f9f62..cc4aff5649 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyAssetCtrl.hxx +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyAssetCtrl.hxx @@ -16,6 +16,7 @@ #include #include "PropertyEditorAPI.h" #include +#include #include #include #include diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake b/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake index 88febef8c2..209eadf59e 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake @@ -7,6 +7,7 @@ # set(FILES + AssetEditor/AssetEditorBus.cpp AssetEditor/AssetEditorBus.h AssetEditor/AssetEditorToolbar.ui AssetEditor/AssetEditorStatusBar.ui diff --git a/Code/Framework/AzToolsFramework/Tests/PropertyTreeEditorTests.cpp b/Code/Framework/AzToolsFramework/Tests/PropertyTreeEditorTests.cpp index 91e53f1650..5def9e6bad 100644 --- a/Code/Framework/AzToolsFramework/Tests/PropertyTreeEditorTests.cpp +++ b/Code/Framework/AzToolsFramework/Tests/PropertyTreeEditorTests.cpp @@ -6,6 +6,7 @@ * */ +#include #include #include #include diff --git a/Code/Legacy/CryCommon/Maestro/Bus/SequenceComponentBus.h b/Code/Legacy/CryCommon/Maestro/Bus/SequenceComponentBus.h index ba3d7bdcb6..9a3619b89e 100644 --- a/Code/Legacy/CryCommon/Maestro/Bus/SequenceComponentBus.h +++ b/Code/Legacy/CryCommon/Maestro/Bus/SequenceComponentBus.h @@ -7,6 +7,7 @@ */ #pragma once +#include #include #include #include diff --git a/Code/Tools/AssetProcessor/AssetBuilderSDK/AssetBuilderSDK/AssetBuilderSDK.cpp b/Code/Tools/AssetProcessor/AssetBuilderSDK/AssetBuilderSDK/AssetBuilderSDK.cpp index d6c4661c15..62b063c83b 100644 --- a/Code/Tools/AssetProcessor/AssetBuilderSDK/AssetBuilderSDK/AssetBuilderSDK.cpp +++ b/Code/Tools/AssetProcessor/AssetBuilderSDK/AssetBuilderSDK/AssetBuilderSDK.cpp @@ -20,6 +20,7 @@ #include #include #include // For slice asset sub ids +#include ////////////////////////////////////////////////////////////////////////// namespace AssetBuilderSDK diff --git a/Code/Tools/AssetProcessor/AssetBuilderSDK/AssetBuilderSDK/SerializationDependencies.cpp b/Code/Tools/AssetProcessor/AssetBuilderSDK/AssetBuilderSDK/SerializationDependencies.cpp index 9e826faabb..09c6fc7cb4 100644 --- a/Code/Tools/AssetProcessor/AssetBuilderSDK/AssetBuilderSDK/SerializationDependencies.cpp +++ b/Code/Tools/AssetProcessor/AssetBuilderSDK/AssetBuilderSDK/SerializationDependencies.cpp @@ -7,6 +7,7 @@ */ #include +#include namespace AssetBuilderSDK { diff --git a/Code/Tools/AssetProcessor/native/AssetManager/AssetCatalog.cpp b/Code/Tools/AssetProcessor/native/AssetManager/AssetCatalog.cpp index f570a1ccb4..6eee3d6f2b 100644 --- a/Code/Tools/AssetProcessor/native/AssetManager/AssetCatalog.cpp +++ b/Code/Tools/AssetProcessor/native/AssetManager/AssetCatalog.cpp @@ -8,6 +8,7 @@ #include "native/AssetManager/AssetCatalog.h" +#include #include #include #include diff --git a/Code/Tools/AssetProcessor/native/AssetManager/AssetRequestHandler.cpp b/Code/Tools/AssetProcessor/native/AssetManager/AssetRequestHandler.cpp index 60873ae1af..c3530c768a 100644 --- a/Code/Tools/AssetProcessor/native/AssetManager/AssetRequestHandler.cpp +++ b/Code/Tools/AssetProcessor/native/AssetManager/AssetRequestHandler.cpp @@ -8,9 +8,10 @@ #include "AssetRequestHandler.h" +#include +#include #include #include -#include using namespace AssetProcessor; diff --git a/Code/Tools/AssetProcessor/native/InternalBuilders/SettingsRegistryBuilder.cpp b/Code/Tools/AssetProcessor/native/InternalBuilders/SettingsRegistryBuilder.cpp index e6d9894116..c65ab24aed 100644 --- a/Code/Tools/AssetProcessor/native/InternalBuilders/SettingsRegistryBuilder.cpp +++ b/Code/Tools/AssetProcessor/native/InternalBuilders/SettingsRegistryBuilder.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include diff --git a/Code/Tools/AssetProcessor/native/tests/assetBuilderSDK/SerializationDependenciesTests.cpp b/Code/Tools/AssetProcessor/native/tests/assetBuilderSDK/SerializationDependenciesTests.cpp index 86c363075d..71d11b19eb 100644 --- a/Code/Tools/AssetProcessor/native/tests/assetBuilderSDK/SerializationDependenciesTests.cpp +++ b/Code/Tools/AssetProcessor/native/tests/assetBuilderSDK/SerializationDependenciesTests.cpp @@ -7,6 +7,7 @@ */ #include +#include #include #include diff --git a/Code/Tools/SceneAPI/SceneBuilder/Importers/AssImpBlendShapeImporter.cpp b/Code/Tools/SceneAPI/SceneBuilder/Importers/AssImpBlendShapeImporter.cpp index 8e447f9d79..2dd7fff8e2 100644 --- a/Code/Tools/SceneAPI/SceneBuilder/Importers/AssImpBlendShapeImporter.cpp +++ b/Code/Tools/SceneAPI/SceneBuilder/Importers/AssImpBlendShapeImporter.cpp @@ -7,6 +7,7 @@ */ #include +#include #include #include #include diff --git a/Code/Tools/SceneAPI/SceneCore/Containers/GraphObjectProxy.h b/Code/Tools/SceneAPI/SceneCore/Containers/GraphObjectProxy.h index 5b6178a63d..ded12e4051 100644 --- a/Code/Tools/SceneAPI/SceneCore/Containers/GraphObjectProxy.h +++ b/Code/Tools/SceneAPI/SceneCore/Containers/GraphObjectProxy.h @@ -12,6 +12,10 @@ namespace AZ { + struct BehaviorParameter; + struct BehaviorValueParameter; + class BehaviorClass; + namespace Python { class PythonBehaviorInfo; diff --git a/Code/Tools/SceneAPI/SceneCore/Containers/SceneManifest.cpp b/Code/Tools/SceneAPI/SceneCore/Containers/SceneManifest.cpp index d68b6c52d4..664c5f1272 100644 --- a/Code/Tools/SceneAPI/SceneCore/Containers/SceneManifest.cpp +++ b/Code/Tools/SceneAPI/SceneCore/Containers/SceneManifest.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include diff --git a/Code/Tools/SceneAPI/SceneCore/DllMain.cpp b/Code/Tools/SceneAPI/SceneCore/DllMain.cpp index 408b516f84..ad875f5538 100644 --- a/Code/Tools/SceneAPI/SceneCore/DllMain.cpp +++ b/Code/Tools/SceneAPI/SceneCore/DllMain.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include diff --git a/Code/Tools/SceneAPI/SceneData/Behaviors/ScriptProcessorRuleBehavior.cpp b/Code/Tools/SceneAPI/SceneData/Behaviors/ScriptProcessorRuleBehavior.cpp index 8924f10115..2e6503d195 100644 --- a/Code/Tools/SceneAPI/SceneData/Behaviors/ScriptProcessorRuleBehavior.cpp +++ b/Code/Tools/SceneAPI/SceneData/Behaviors/ScriptProcessorRuleBehavior.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/Code/Tools/SceneAPI/SceneData/GraphData/BlendShapeData.cpp b/Code/Tools/SceneAPI/SceneData/GraphData/BlendShapeData.cpp index fa81ea2826..066129f974 100644 --- a/Code/Tools/SceneAPI/SceneData/GraphData/BlendShapeData.cpp +++ b/Code/Tools/SceneAPI/SceneData/GraphData/BlendShapeData.cpp @@ -10,6 +10,7 @@ #include #include #include +#include namespace AZ { diff --git a/Code/Tools/SceneAPI/SceneData/GraphData/MaterialData.cpp b/Code/Tools/SceneAPI/SceneData/GraphData/MaterialData.cpp index 117a1196f8..b6b87fecc7 100644 --- a/Code/Tools/SceneAPI/SceneData/GraphData/MaterialData.cpp +++ b/Code/Tools/SceneAPI/SceneData/GraphData/MaterialData.cpp @@ -6,6 +6,7 @@ * */ +#include #include #include #include diff --git a/Gems/AWSCore/Code/Source/AWSCoreSystemComponent.cpp b/Gems/AWSCore/Code/Source/AWSCoreSystemComponent.cpp index 92a5aa493f..294462e654 100644 --- a/Gems/AWSCore/Code/Source/AWSCoreSystemComponent.cpp +++ b/Gems/AWSCore/Code/Source/AWSCoreSystemComponent.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include diff --git a/Gems/AWSCore/Code/Tests/AWSCoreSystemComponentTest.cpp b/Gems/AWSCore/Code/Tests/AWSCoreSystemComponentTest.cpp index 730fc97f49..f9fff631f4 100644 --- a/Gems/AWSCore/Code/Tests/AWSCoreSystemComponentTest.cpp +++ b/Gems/AWSCore/Code/Tests/AWSCoreSystemComponentTest.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/Gems/AWSCore/Code/Tests/Editor/AWSCoreEditorSystemComponentTest.cpp b/Gems/AWSCore/Code/Tests/Editor/AWSCoreEditorSystemComponentTest.cpp index 07a6c8ae08..0cd01b4245 100644 --- a/Gems/AWSCore/Code/Tests/Editor/AWSCoreEditorSystemComponentTest.cpp +++ b/Gems/AWSCore/Code/Tests/Editor/AWSCoreEditorSystemComponentTest.cpp @@ -6,6 +6,7 @@ * */ +#include #include #include #include diff --git a/Gems/AWSGameLift/Code/AWSGameLiftClient/Source/Request/AWSGameLiftCreateSessionOnQueueRequest.cpp b/Gems/AWSGameLift/Code/AWSGameLiftClient/Source/Request/AWSGameLiftCreateSessionOnQueueRequest.cpp index 4f178f4655..a6cb024ba8 100644 --- a/Gems/AWSGameLift/Code/AWSGameLiftClient/Source/Request/AWSGameLiftCreateSessionOnQueueRequest.cpp +++ b/Gems/AWSGameLift/Code/AWSGameLiftClient/Source/Request/AWSGameLiftCreateSessionOnQueueRequest.cpp @@ -6,11 +6,12 @@ * */ +#include + +#include #include #include -#include - namespace AWSGameLift { void AWSGameLiftCreateSessionOnQueueRequest::Reflect(AZ::ReflectContext* context) diff --git a/Gems/AWSGameLift/Code/AWSGameLiftClient/Source/Request/AWSGameLiftCreateSessionRequest.cpp b/Gems/AWSGameLift/Code/AWSGameLiftClient/Source/Request/AWSGameLiftCreateSessionRequest.cpp index 4e21c0e711..1c9669e474 100644 --- a/Gems/AWSGameLift/Code/AWSGameLiftClient/Source/Request/AWSGameLiftCreateSessionRequest.cpp +++ b/Gems/AWSGameLift/Code/AWSGameLiftClient/Source/Request/AWSGameLiftCreateSessionRequest.cpp @@ -6,11 +6,12 @@ * */ +#include + +#include #include #include -#include - namespace AWSGameLift { void AWSGameLiftCreateSessionRequest::Reflect(AZ::ReflectContext* context) diff --git a/Gems/AWSGameLift/Code/AWSGameLiftClient/Source/Request/AWSGameLiftJoinSessionRequest.cpp b/Gems/AWSGameLift/Code/AWSGameLiftClient/Source/Request/AWSGameLiftJoinSessionRequest.cpp index 4007093175..7d23a4b581 100644 --- a/Gems/AWSGameLift/Code/AWSGameLiftClient/Source/Request/AWSGameLiftJoinSessionRequest.cpp +++ b/Gems/AWSGameLift/Code/AWSGameLiftClient/Source/Request/AWSGameLiftJoinSessionRequest.cpp @@ -5,12 +5,12 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ +#include +#include #include #include -#include - namespace AWSGameLift { void AWSGameLiftJoinSessionRequest::Reflect(AZ::ReflectContext* context) diff --git a/Gems/AWSGameLift/Code/AWSGameLiftClient/Source/Request/AWSGameLiftSearchSessionsRequest.cpp b/Gems/AWSGameLift/Code/AWSGameLiftClient/Source/Request/AWSGameLiftSearchSessionsRequest.cpp index f484a0b357..b78320dc32 100644 --- a/Gems/AWSGameLift/Code/AWSGameLiftClient/Source/Request/AWSGameLiftSearchSessionsRequest.cpp +++ b/Gems/AWSGameLift/Code/AWSGameLiftClient/Source/Request/AWSGameLiftSearchSessionsRequest.cpp @@ -6,13 +6,14 @@ * */ +#include +#include + +#include #include #include #include -#include -#include - namespace AWSGameLift { void AWSGameLiftSearchSessionsRequest::Reflect(AZ::ReflectContext* context) diff --git a/Gems/Atom/Component/DebugCamera/Code/Source/ArcBallControllerComponent.cpp b/Gems/Atom/Component/DebugCamera/Code/Source/ArcBallControllerComponent.cpp index 040338ab6f..904d6e0c2f 100644 --- a/Gems/Atom/Component/DebugCamera/Code/Source/ArcBallControllerComponent.cpp +++ b/Gems/Atom/Component/DebugCamera/Code/Source/ArcBallControllerComponent.cpp @@ -9,6 +9,7 @@ #include +#include #include #include #include diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/SkinnedMesh/SkinnedMeshVertexStreams.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/SkinnedMesh/SkinnedMeshVertexStreams.h index 5be3bece5e..aedfb73396 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/SkinnedMesh/SkinnedMeshVertexStreams.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/SkinnedMesh/SkinnedMeshVertexStreams.h @@ -8,7 +8,6 @@ #pragma once -#include #include #include #include diff --git a/Gems/Atom/Feature/Common/Code/Source/DisplayMapper/DisplayMapperConfigurationDescriptor.cpp b/Gems/Atom/Feature/Common/Code/Source/DisplayMapper/DisplayMapperConfigurationDescriptor.cpp index a9ee46dd2c..9e29070e71 100644 --- a/Gems/Atom/Feature/Common/Code/Source/DisplayMapper/DisplayMapperConfigurationDescriptor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/DisplayMapper/DisplayMapperConfigurationDescriptor.cpp @@ -7,6 +7,7 @@ */ +#include #include #include diff --git a/Gems/Atom/Feature/Common/Code/Source/Material/MaterialAssignment.cpp b/Gems/Atom/Feature/Common/Code/Source/Material/MaterialAssignment.cpp index 4d437be244..5b90ed7f06 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Material/MaterialAssignment.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Material/MaterialAssignment.cpp @@ -7,6 +7,8 @@ */ #include +#include +#include #include #include #include diff --git a/Gems/Atom/Feature/Common/Code/Source/Utils/LightingPreset.cpp b/Gems/Atom/Feature/Common/Code/Source/Utils/LightingPreset.cpp index 36c604c931..8984747b74 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Utils/LightingPreset.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Utils/LightingPreset.cpp @@ -9,6 +9,7 @@ #undef RC_INVOKED #include +#include #include #include #include diff --git a/Gems/Atom/Feature/Common/Code/Source/Utils/ModelPreset.cpp b/Gems/Atom/Feature/Common/Code/Source/Utils/ModelPreset.cpp index 156fca3b7e..c684b3cc89 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Utils/ModelPreset.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Utils/ModelPreset.cpp @@ -9,8 +9,11 @@ #undef RC_INVOKED #include +#include #include #include +#include +#include namespace AZ { diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/Handle.h b/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/Handle.h index 01e1fab7cc..3e0c3335a0 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/Handle.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/Handle.h @@ -9,6 +9,7 @@ #include #include +#include namespace AZ { diff --git a/Gems/Atom/RHI/Code/Source/RHI.Reflect/ShaderSemantic.cpp b/Gems/Atom/RHI/Code/Source/RHI.Reflect/ShaderSemantic.cpp index 3cb4bd05a5..718604d750 100644 --- a/Gems/Atom/RHI/Code/Source/RHI.Reflect/ShaderSemantic.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI.Reflect/ShaderSemantic.cpp @@ -7,6 +7,8 @@ */ #include + +#include #include #include #include diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Model/Model.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Model/Model.h index a19c985f2d..b94d2169bf 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Model/Model.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Model/Model.h @@ -24,6 +24,8 @@ namespace AZ { namespace RPI { + class ModelAsset; + class Model final : public Data::InstanceData { diff --git a/Gems/Atom/RPI/Code/Source/RPI.Edit/Shader/ShaderVariantListSourceData.cpp b/Gems/Atom/RPI/Code/Source/RPI.Edit/Shader/ShaderVariantListSourceData.cpp index b6a2132b89..6cd38f65bc 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Edit/Shader/ShaderVariantListSourceData.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Edit/Shader/ShaderVariantListSourceData.cpp @@ -8,9 +8,10 @@ #include #include - +#include #include + namespace AZ { namespace RPI diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Model/Model.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Model/Model.cpp index 50da470ec4..1ba17deb91 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Model/Model.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Model/Model.cpp @@ -7,6 +7,7 @@ */ #include +#include #include diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Model/ModelLodUtils.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Model/ModelLodUtils.cpp index a1651defbc..3cbb20b9e9 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Model/ModelLodUtils.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Model/ModelLodUtils.cpp @@ -10,7 +10,9 @@ #include #include +#include +#include #include #include diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Model/ModelSystem.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Model/ModelSystem.cpp index 1ed81f8e16..775d02f7ab 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Model/ModelSystem.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Model/ModelSystem.cpp @@ -11,6 +11,8 @@ #include #include +#include +#include #include #include diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Buffer/BufferAsset.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Buffer/BufferAsset.cpp index 180ce6d5a7..95f47d7393 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Buffer/BufferAsset.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Buffer/BufferAsset.cpp @@ -8,6 +8,7 @@ #include +#include #include #include diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Buffer/BufferAssetView.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Buffer/BufferAssetView.cpp index a88d4f10e4..2b3aabdba2 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Buffer/BufferAssetView.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Buffer/BufferAssetView.cpp @@ -7,6 +7,7 @@ */ #include +#include namespace AZ { diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Image/StreamingImageAsset.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Image/StreamingImageAsset.cpp index 1caba9dba8..59f359e474 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Image/StreamingImageAsset.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Image/StreamingImageAsset.cpp @@ -8,6 +8,7 @@ #include +#include #include namespace AZ diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Image/StreamingImagePoolAsset.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Image/StreamingImagePoolAsset.cpp index fda4c31b08..056002f527 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Image/StreamingImagePoolAsset.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Image/StreamingImagePoolAsset.cpp @@ -9,6 +9,7 @@ #include #include +#include namespace AZ { diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/LuaMaterialFunctor.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/LuaMaterialFunctor.cpp index 9338d52cb2..c33409f687 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/LuaMaterialFunctor.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/LuaMaterialFunctor.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialAsset.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialAsset.cpp index c3e0221192..5c7af601fb 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialAsset.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialAsset.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include #include diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialPropertyValue.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialPropertyValue.cpp index 13ecea52dc..d1017139fc 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialPropertyValue.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/MaterialPropertyValue.cpp @@ -7,6 +7,7 @@ */ #include +#include #include #include diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/ShaderCollection.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/ShaderCollection.cpp index 7b3b6b7a28..87076891dd 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/ShaderCollection.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Material/ShaderCollection.cpp @@ -7,6 +7,7 @@ */ #include +#include #include #include #include diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelAsset.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelAsset.cpp index 8e2d1bdd7e..9a432643d7 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelAsset.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelAsset.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelMaterialSlot.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelMaterialSlot.cpp index b9d9200aaf..4485359cf9 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelMaterialSlot.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelMaterialSlot.cpp @@ -6,6 +6,7 @@ */ #include +#include #include #include diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/MorphTargetMetaAsset.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/MorphTargetMetaAsset.cpp index 228ef67025..bcdc91abda 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/MorphTargetMetaAsset.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/MorphTargetMetaAsset.cpp @@ -6,6 +6,7 @@ * */ +#include #include #include #include diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Shader/ShaderAsset.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Shader/ShaderAsset.cpp index 49ef457311..692087d93b 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Shader/ShaderAsset.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Shader/ShaderAsset.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Document/AtomToolsDocumentRequestBus.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Document/AtomToolsDocumentRequestBus.h index a8ef7852ea..6a21a8a2df 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Document/AtomToolsDocumentRequestBus.h +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Document/AtomToolsDocumentRequestBus.h @@ -10,6 +10,7 @@ #include #include #include +#include namespace AtomToolsFramework { diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Inspector/InspectorPropertyGroupWidget.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Inspector/InspectorPropertyGroupWidget.cpp index e1f8573bb3..86ac4a3df1 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Inspector/InspectorPropertyGroupWidget.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Inspector/InspectorPropertyGroupWidget.cpp @@ -9,6 +9,7 @@ #include #include #include +#include namespace AtomToolsFramework { diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Viewport/InputController/MaterialEditorViewportInputController.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Viewport/InputController/MaterialEditorViewportInputController.cpp index 7571738597..932e2e7436 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Viewport/InputController/MaterialEditorViewportInputController.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Viewport/InputController/MaterialEditorViewportInputController.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include 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 d4269c2438..04c53457ae 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/ViewportSettingsInspector/ViewportSettingsInspector.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/ViewportSettingsInspector/ViewportSettingsInspector.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/Gems/Atom/Utils/Code/Include/Atom/Utils/Utils.h b/Gems/Atom/Utils/Code/Include/Atom/Utils/Utils.h index 73a61b2345..25b96319c5 100644 --- a/Gems/Atom/Utils/Code/Include/Atom/Utils/Utils.h +++ b/Gems/Atom/Utils/Code/Include/Atom/Utils/Utils.h @@ -9,6 +9,7 @@ #pragma once #include +#include #include #include diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Animation/AttachmentComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Animation/AttachmentComponent.cpp index ac37e293b9..ee66518779 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Animation/AttachmentComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Animation/AttachmentComponent.cpp @@ -6,6 +6,7 @@ * */ #include "AttachmentComponent.h" +#include #include #include #include diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Animation/EditorAttachmentComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Animation/EditorAttachmentComponent.cpp index 878eb51efb..b10a3e6695 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Animation/EditorAttachmentComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Animation/EditorAttachmentComponent.cpp @@ -12,6 +12,7 @@ #include #include #include +#include namespace AZ { diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Decals/DecalComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Decals/DecalComponentController.cpp index 49b31388ad..5d16164d92 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Decals/DecalComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Decals/DecalComponentController.cpp @@ -8,6 +8,7 @@ #include +#include #include #include #include diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGridComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGridComponentController.cpp index 8aec22e22c..8b864613c4 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGridComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGridComponentController.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/DiffuseGlobalIllumination/EditorDiffuseProbeGridComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/DiffuseGlobalIllumination/EditorDiffuseProbeGridComponent.cpp index 013a8ee1b4..7f676e4c10 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/DiffuseGlobalIllumination/EditorDiffuseProbeGridComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/DiffuseGlobalIllumination/EditorDiffuseProbeGridComponent.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ImageBasedLights/ImageBasedLightComponentConfig.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ImageBasedLights/ImageBasedLightComponentConfig.cpp index c98d5be5ef..8ddd727076 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ImageBasedLights/ImageBasedLightComponentConfig.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ImageBasedLights/ImageBasedLightComponentConfig.cpp @@ -7,6 +7,7 @@ */ #include +#include #include namespace AZ diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/EditorMaterialComponentSlot.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/EditorMaterialComponentSlot.cpp index 363221d3fc..c4d21ba599 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/EditorMaterialComponentSlot.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/EditorMaterialComponentSlot.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialComponentController.cpp index 1d9f1e81dd..bd148c8ba4 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/MaterialComponentController.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -142,7 +143,7 @@ namespace AZ { InitializeMaterialInstance(asset); } - + void MaterialComponentController::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time) { AZStd::unordered_set propertyOverrides; @@ -193,7 +194,7 @@ namespace AZ materialInstance->Compile(); } - // Only disconnect from tick bus and send notification after all pending properties have been applied + // Only disconnect from tick bus and send notification after all pending properties have been applied if (m_queuedPropertyOverrides.empty()) { if (m_queuedMaterialUpdateNotification) @@ -229,7 +230,7 @@ namespace AZ ReleaseMaterials(); } } - + void MaterialComponentController::InitializeMaterialInstance(const Data::Asset& asset) { bool allReady = true; @@ -334,7 +335,7 @@ namespace AZ // this function is called twice once material asset is changed, a temp variable is // needed to prevent material asset going out of scope during second call // before LoadMaterials() is called [LYN-2249] - auto temp = m_configuration.m_materials; + auto temp = m_configuration.m_materials; m_configuration.m_materials = materials; LoadMaterials(); } diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp index 9e0c285001..2dc3b9134a 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Mesh/MeshComponentController.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/DisplayMapper/DisplayMapperComponentConfig.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/DisplayMapper/DisplayMapperComponentConfig.cpp index 9c137f5b72..f9a427a3a0 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/DisplayMapper/DisplayMapperComponentConfig.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/DisplayMapper/DisplayMapperComponentConfig.cpp @@ -7,6 +7,7 @@ */ #include +#include #include #include diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/DisplayMapper/EditorDisplayMapperComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/DisplayMapper/EditorDisplayMapperComponent.cpp index d06bc981fe..e10a8b14c9 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/DisplayMapper/EditorDisplayMapperComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/DisplayMapper/EditorDisplayMapperComponent.cpp @@ -6,9 +6,10 @@ * */ -#include #include #include +#include +#include namespace AZ { diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/GradientWeightModifier/GradientWeightModifierComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/GradientWeightModifier/GradientWeightModifierComponent.cpp index d38130bef6..3318f84905 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/GradientWeightModifier/GradientWeightModifierComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/GradientWeightModifier/GradientWeightModifierComponent.cpp @@ -8,6 +8,8 @@ #include +#include + namespace AZ { namespace Render diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/LookModification/LookModificationComponentConfig.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/LookModification/LookModificationComponentConfig.cpp index f77f67635f..4b1665895f 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/LookModification/LookModificationComponentConfig.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/LookModification/LookModificationComponentConfig.cpp @@ -7,6 +7,7 @@ */ #include +#include #include #include #include diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/LookModification/LookModificationComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/LookModification/LookModificationComponentController.cpp index aedb25bb36..4f321ed8b1 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/LookModification/LookModificationComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/LookModification/LookModificationComponentController.cpp @@ -7,6 +7,7 @@ */ #include +#include #include diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/RadiusWeightModifier/RadiusWeightModifierComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/RadiusWeightModifier/RadiusWeightModifierComponent.cpp index 53b508c619..d668533807 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/RadiusWeightModifier/RadiusWeightModifierComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/RadiusWeightModifier/RadiusWeightModifierComponent.cpp @@ -8,6 +8,8 @@ #include +#include + namespace AZ { namespace Render diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/ShapeWeightModifier/ShapeWeightModifierComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/ShapeWeightModifier/ShapeWeightModifierComponent.cpp index fd3063fe98..bc3f6f8719 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/ShapeWeightModifier/ShapeWeightModifierComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/ShapeWeightModifier/ShapeWeightModifierComponent.cpp @@ -8,6 +8,8 @@ #include +#include + namespace AZ { namespace Render diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/ShapeWeightModifier/ShapeWeightModifierComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/ShapeWeightModifier/ShapeWeightModifierComponentController.cpp index 42898cd188..d4761efa96 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/ShapeWeightModifier/ShapeWeightModifierComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/PostProcess/ShapeWeightModifier/ShapeWeightModifierComponentController.cpp @@ -9,6 +9,7 @@ #include #include #include +#include namespace AZ { diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ReflectionProbe/EditorReflectionProbeComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ReflectionProbe/EditorReflectionProbeComponent.cpp index aa68333108..d7fcd124d0 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ReflectionProbe/EditorReflectionProbeComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ReflectionProbe/EditorReflectionProbeComponent.cpp @@ -13,7 +13,9 @@ #include #include #include +#include #include +#include #include AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ReflectionProbe/ReflectionProbeComponentController.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ReflectionProbe/ReflectionProbeComponentController.cpp index 764741a5cf..4022dfda9b 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ReflectionProbe/ReflectionProbeComponentController.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ReflectionProbe/ReflectionProbeComponentController.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/SkyBox/HDRiSkyboxComponentConfig.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/SkyBox/HDRiSkyboxComponentConfig.cpp index b86cccf341..288892cddf 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/SkyBox/HDRiSkyboxComponentConfig.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/SkyBox/HDRiSkyboxComponentConfig.cpp @@ -7,6 +7,7 @@ */ #include +#include #include #include diff --git a/Gems/Blast/Code/Source/Components/BlastFamilyComponent.cpp b/Gems/Blast/Code/Source/Components/BlastFamilyComponent.cpp index c2fb81e86a..8c6c0a8e05 100644 --- a/Gems/Blast/Code/Source/Components/BlastFamilyComponent.cpp +++ b/Gems/Blast/Code/Source/Components/BlastFamilyComponent.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -208,7 +209,7 @@ namespace Blast itr.second.Disconnect(); } m_collisionHandlers.clear(); - + BlastFamilyDamageRequestBus::MultiHandler::BusDisconnect(); BlastFamilyComponentRequestBus::Handler::BusDisconnect(); @@ -546,7 +547,7 @@ namespace Blast } m_solver->notifyActorCreated(*actor.GetTkActor().getActorLL()); - + if (auto* physicsSystem = AZ::Interface::Get()) { AZStd::pair foundBody = physicsSystem->FindAttachedBodyHandleFromEntityId(actor.GetEntity()->GetId()); diff --git a/Gems/Blast/Code/Source/Components/BlastMeshDataComponent.cpp b/Gems/Blast/Code/Source/Components/BlastMeshDataComponent.cpp index 17848a53d3..a9f079dd65 100644 --- a/Gems/Blast/Code/Source/Components/BlastMeshDataComponent.cpp +++ b/Gems/Blast/Code/Source/Components/BlastMeshDataComponent.cpp @@ -7,6 +7,7 @@ */ #include +#include #include namespace Blast diff --git a/Gems/Blast/Code/Source/Components/BlastSystemComponent.cpp b/Gems/Blast/Code/Source/Components/BlastSystemComponent.cpp index 851cb4460b..0c697f12b6 100644 --- a/Gems/Blast/Code/Source/Components/BlastSystemComponent.cpp +++ b/Gems/Blast/Code/Source/Components/BlastSystemComponent.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include diff --git a/Gems/Blast/Code/Source/Editor/EditorBlastFamilyComponent.cpp b/Gems/Blast/Code/Source/Editor/EditorBlastFamilyComponent.cpp index 3bc6da4297..90f530895a 100644 --- a/Gems/Blast/Code/Source/Editor/EditorBlastFamilyComponent.cpp +++ b/Gems/Blast/Code/Source/Editor/EditorBlastFamilyComponent.cpp @@ -8,6 +8,7 @@ #include +#include #include #include #include diff --git a/Gems/Blast/Code/Source/Editor/EditorBlastMeshDataComponent.cpp b/Gems/Blast/Code/Source/Editor/EditorBlastMeshDataComponent.cpp index 9d0e4fe2ff..83085b5f9c 100644 --- a/Gems/Blast/Code/Source/Editor/EditorBlastMeshDataComponent.cpp +++ b/Gems/Blast/Code/Source/Editor/EditorBlastMeshDataComponent.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/AnimGraphFollowerParameterAction.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/AnimGraphFollowerParameterAction.cpp index 1355e2b0e5..3d8add320a 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/AnimGraphFollowerParameterAction.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/AnimGraphFollowerParameterAction.cpp @@ -6,6 +6,7 @@ * */ +#include #include #include #include diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/AnimGraphReferenceNode.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/AnimGraphReferenceNode.cpp index 605810c5cc..16f192615d 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/AnimGraphReferenceNode.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/AnimGraphReferenceNode.cpp @@ -6,6 +6,7 @@ * */ +#include #include #include #include diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/AnimGraphSymbolicFollowerParameterAction.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/AnimGraphSymbolicFollowerParameterAction.cpp index fda679b8d0..e1f15c1ab2 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/AnimGraphSymbolicFollowerParameterAction.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/AnimGraphSymbolicFollowerParameterAction.cpp @@ -6,6 +6,7 @@ * */ +#include #include #include #include diff --git a/Gems/EMotionFX/Code/Source/Integration/Components/ActorComponent.cpp b/Gems/EMotionFX/Code/Source/Integration/Components/ActorComponent.cpp index da4c72b70a..ab55f909c2 100644 --- a/Gems/EMotionFX/Code/Source/Integration/Components/ActorComponent.cpp +++ b/Gems/EMotionFX/Code/Source/Integration/Components/ActorComponent.cpp @@ -6,6 +6,7 @@ * */ +#include #include #include #include diff --git a/Gems/EMotionFX/Code/Source/Integration/Components/AnimGraphComponent.cpp b/Gems/EMotionFX/Code/Source/Integration/Components/AnimGraphComponent.cpp index 704b746e3f..c47c18ba7d 100644 --- a/Gems/EMotionFX/Code/Source/Integration/Components/AnimGraphComponent.cpp +++ b/Gems/EMotionFX/Code/Source/Integration/Components/AnimGraphComponent.cpp @@ -6,6 +6,7 @@ * */ +#include #include #include #include diff --git a/Gems/EMotionFX/Code/Source/Integration/Components/SimpleMotionComponent.cpp b/Gems/EMotionFX/Code/Source/Integration/Components/SimpleMotionComponent.cpp index dd7fdeea50..6876051c63 100644 --- a/Gems/EMotionFX/Code/Source/Integration/Components/SimpleMotionComponent.cpp +++ b/Gems/EMotionFX/Code/Source/Integration/Components/SimpleMotionComponent.cpp @@ -6,6 +6,7 @@ * */ +#include #include #include #include diff --git a/Gems/EMotionFX/Code/Source/Integration/Editor/Components/EditorActorComponent.cpp b/Gems/EMotionFX/Code/Source/Integration/Editor/Components/EditorActorComponent.cpp index ed4edda891..94e52a172f 100644 --- a/Gems/EMotionFX/Code/Source/Integration/Editor/Components/EditorActorComponent.cpp +++ b/Gems/EMotionFX/Code/Source/Integration/Editor/Components/EditorActorComponent.cpp @@ -7,6 +7,7 @@ */ #include +#include #include #include #include diff --git a/Gems/EMotionFX/Code/Source/Integration/Editor/Components/EditorAnimGraphComponent.cpp b/Gems/EMotionFX/Code/Source/Integration/Editor/Components/EditorAnimGraphComponent.cpp index 8721acbf3d..9833fcc87a 100644 --- a/Gems/EMotionFX/Code/Source/Integration/Editor/Components/EditorAnimGraphComponent.cpp +++ b/Gems/EMotionFX/Code/Source/Integration/Editor/Components/EditorAnimGraphComponent.cpp @@ -7,6 +7,7 @@ */ #include +#include #include #include #include diff --git a/Gems/EMotionFX/Code/Tests/EMotionFXBuilderTests.cpp b/Gems/EMotionFX/Code/Tests/EMotionFXBuilderTests.cpp index acdd78fc0f..0155b38da2 100644 --- a/Gems/EMotionFX/Code/Tests/EMotionFXBuilderTests.cpp +++ b/Gems/EMotionFX/Code/Tests/EMotionFXBuilderTests.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include #include diff --git a/Gems/EditorPythonBindings/Code/Tests/PythonAssetTypesTests.cpp b/Gems/EditorPythonBindings/Code/Tests/PythonAssetTypesTests.cpp index 9940a01b7a..688eff7671 100644 --- a/Gems/EditorPythonBindings/Code/Tests/PythonAssetTypesTests.cpp +++ b/Gems/EditorPythonBindings/Code/Tests/PythonAssetTypesTests.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include #include diff --git a/Gems/EditorPythonBindings/Code/Tests/PythonReflectionComponentTests.cpp b/Gems/EditorPythonBindings/Code/Tests/PythonReflectionComponentTests.cpp index 8d472945cc..f68bef1c93 100644 --- a/Gems/EditorPythonBindings/Code/Tests/PythonReflectionComponentTests.cpp +++ b/Gems/EditorPythonBindings/Code/Tests/PythonReflectionComponentTests.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include #include diff --git a/Gems/GradientSignal/Code/Source/Components/ImageGradientComponent.cpp b/Gems/GradientSignal/Code/Source/Components/ImageGradientComponent.cpp index 9e01b690e0..6fe8d32484 100644 --- a/Gems/GradientSignal/Code/Source/Components/ImageGradientComponent.cpp +++ b/Gems/GradientSignal/Code/Source/Components/ImageGradientComponent.cpp @@ -8,6 +8,7 @@ #include "ImageGradientComponent.h" #include +#include #include #include #include diff --git a/Gems/GraphCanvas/Code/Source/Translation/TranslationAsset.cpp b/Gems/GraphCanvas/Code/Source/Translation/TranslationAsset.cpp index fbd7bdfd22..a461866c46 100644 --- a/Gems/GraphCanvas/Code/Source/Translation/TranslationAsset.cpp +++ b/Gems/GraphCanvas/Code/Source/Translation/TranslationAsset.cpp @@ -8,6 +8,8 @@ #include +#include + #include #include diff --git a/Gems/ImGui/Code/Source/LYCommonMenu/ImGuiLYEntityOutliner.cpp b/Gems/ImGui/Code/Source/LYCommonMenu/ImGuiLYEntityOutliner.cpp index 2df6c9984b..1bf9d26fdf 100644 --- a/Gems/ImGui/Code/Source/LYCommonMenu/ImGuiLYEntityOutliner.cpp +++ b/Gems/ImGui/Code/Source/LYCommonMenu/ImGuiLYEntityOutliner.cpp @@ -11,6 +11,7 @@ #ifdef IMGUI_ENABLED #include +#include #include #include #include diff --git a/Gems/LmbrCentral/Code/Source/Builders/LuaBuilder/LuaBuilderWorker.h b/Gems/LmbrCentral/Code/Source/Builders/LuaBuilder/LuaBuilderWorker.h index 1d3a61626b..6f2aeecb8f 100644 --- a/Gems/LmbrCentral/Code/Source/Builders/LuaBuilder/LuaBuilderWorker.h +++ b/Gems/LmbrCentral/Code/Source/Builders/LuaBuilder/LuaBuilderWorker.h @@ -7,10 +7,14 @@ */ #pragma once -#include -#include #include #include +#include +#include +namespace AZ +{ + class ScriptContext; +} namespace LuaBuilder { @@ -39,6 +43,10 @@ namespace LuaBuilder JobStepOutcome RunCompileJob(const AssetBuilderSDK::ProcessJobRequest& request); JobStepOutcome RunCopyJob(const AssetBuilderSDK::ProcessJobRequest& request); - JobStepOutcome WriteAssetInfo(const AssetBuilderSDK::ProcessJobRequest& request, AZStd::string_view destFileName, AZStd::string_view debugName, AZ::ScriptContext& scriptContext); + JobStepOutcome WriteAssetInfo( + const AssetBuilderSDK::ProcessJobRequest& request, + AZStd::string_view destFileName, + AZStd::string_view debugName, + AZ::ScriptContext& scriptContext); }; -} +} // namespace LuaBuilder diff --git a/Gems/LmbrCentral/Code/Source/Scripting/EditorSpawnerComponent.cpp b/Gems/LmbrCentral/Code/Source/Scripting/EditorSpawnerComponent.cpp index 315480c869..f43b69f703 100644 --- a/Gems/LmbrCentral/Code/Source/Scripting/EditorSpawnerComponent.cpp +++ b/Gems/LmbrCentral/Code/Source/Scripting/EditorSpawnerComponent.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include diff --git a/Gems/LmbrCentral/Code/Source/Scripting/SpawnerComponent.cpp b/Gems/LmbrCentral/Code/Source/Scripting/SpawnerComponent.cpp index 5305a68d84..f79dc3f598 100644 --- a/Gems/LmbrCentral/Code/Source/Scripting/SpawnerComponent.cpp +++ b/Gems/LmbrCentral/Code/Source/Scripting/SpawnerComponent.cpp @@ -6,6 +6,7 @@ * */ +#include #include #include #include diff --git a/Gems/LmbrCentral/Code/Tests/Builders/SliceBuilderTests.cpp b/Gems/LmbrCentral/Code/Tests/Builders/SliceBuilderTests.cpp index 647a5dedef..73ef7143c8 100644 --- a/Gems/LmbrCentral/Code/Tests/Builders/SliceBuilderTests.cpp +++ b/Gems/LmbrCentral/Code/Tests/Builders/SliceBuilderTests.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/Gems/LyShine/Code/Source/UiSpawnerComponent.cpp b/Gems/LyShine/Code/Source/UiSpawnerComponent.cpp index e9e4e4539f..6eb04b3684 100644 --- a/Gems/LyShine/Code/Source/UiSpawnerComponent.cpp +++ b/Gems/LyShine/Code/Source/UiSpawnerComponent.cpp @@ -7,6 +7,7 @@ */ #include "UiSpawnerComponent.h" +#include #include #include #include diff --git a/Gems/Multiplayer/Code/Source/Components/NetBindComponent.cpp b/Gems/Multiplayer/Code/Source/Components/NetBindComponent.cpp index 634cac74b2..7b7cb52fe1 100644 --- a/Gems/Multiplayer/Code/Source/Components/NetBindComponent.cpp +++ b/Gems/Multiplayer/Code/Source/Components/NetBindComponent.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include diff --git a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp index e66eb8d3a3..023c5ea3af 100644 --- a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp +++ b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include diff --git a/Gems/Multiplayer/Code/Source/Pipeline/NetworkSpawnableHolderComponent.cpp b/Gems/Multiplayer/Code/Source/Pipeline/NetworkSpawnableHolderComponent.cpp index 5d677c6101..198deebbe3 100644 --- a/Gems/Multiplayer/Code/Source/Pipeline/NetworkSpawnableHolderComponent.cpp +++ b/Gems/Multiplayer/Code/Source/Pipeline/NetworkSpawnableHolderComponent.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include diff --git a/Gems/NvCloth/Code/Source/Components/ClothComponent.cpp b/Gems/NvCloth/Code/Source/Components/ClothComponent.cpp index 0bbe52faf1..b252d3b5e6 100644 --- a/Gems/NvCloth/Code/Source/Components/ClothComponent.cpp +++ b/Gems/NvCloth/Code/Source/Components/ClothComponent.cpp @@ -8,6 +8,7 @@ #include #include +#include #include diff --git a/Gems/NvCloth/Code/Source/Components/ClothComponentMesh/ClothComponentMesh.cpp b/Gems/NvCloth/Code/Source/Components/ClothComponentMesh/ClothComponentMesh.cpp index ecf2bd0a54..9a211290e3 100644 --- a/Gems/NvCloth/Code/Source/Components/ClothComponentMesh/ClothComponentMesh.cpp +++ b/Gems/NvCloth/Code/Source/Components/ClothComponentMesh/ClothComponentMesh.cpp @@ -27,6 +27,9 @@ #include #include #include +#include +#include +#include namespace NvCloth { diff --git a/Gems/NvCloth/Code/Source/Components/EditorClothComponent.cpp b/Gems/NvCloth/Code/Source/Components/EditorClothComponent.cpp index 113d660b32..420c6f3a5c 100644 --- a/Gems/NvCloth/Code/Source/Components/EditorClothComponent.cpp +++ b/Gems/NvCloth/Code/Source/Components/EditorClothComponent.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include diff --git a/Gems/NvCloth/Code/Source/Editor/MeshNodeHandler.cpp b/Gems/NvCloth/Code/Source/Editor/MeshNodeHandler.cpp index d42277ebb4..9f874f7765 100644 --- a/Gems/NvCloth/Code/Source/Editor/MeshNodeHandler.cpp +++ b/Gems/NvCloth/Code/Source/Editor/MeshNodeHandler.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include diff --git a/Gems/NvCloth/Code/Source/Editor/MeshNodeHandler.h b/Gems/NvCloth/Code/Source/Editor/MeshNodeHandler.h index 76161aa838..be4ac2ae36 100644 --- a/Gems/NvCloth/Code/Source/Editor/MeshNodeHandler.h +++ b/Gems/NvCloth/Code/Source/Editor/MeshNodeHandler.h @@ -10,6 +10,7 @@ #if !defined(Q_MOC_RUN) #include +#include #include #include #endif diff --git a/Gems/NvCloth/Code/Source/Utils/MeshAssetHelper.cpp b/Gems/NvCloth/Code/Source/Utils/MeshAssetHelper.cpp index c95c8896ab..b72a5594e8 100644 --- a/Gems/NvCloth/Code/Source/Utils/MeshAssetHelper.cpp +++ b/Gems/NvCloth/Code/Source/Utils/MeshAssetHelper.cpp @@ -7,6 +7,7 @@ */ #include +#include #include diff --git a/Gems/PhysX/Code/Editor/EditorClassConverters.cpp b/Gems/PhysX/Code/Editor/EditorClassConverters.cpp index e55ac6bbda..c9f5626dab 100644 --- a/Gems/PhysX/Code/Editor/EditorClassConverters.cpp +++ b/Gems/PhysX/Code/Editor/EditorClassConverters.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include diff --git a/Gems/PhysX/Code/Source/EditorColliderComponent.cpp b/Gems/PhysX/Code/Source/EditorColliderComponent.cpp index 566903d84a..7c07ca207c 100644 --- a/Gems/PhysX/Code/Source/EditorColliderComponent.cpp +++ b/Gems/PhysX/Code/Source/EditorColliderComponent.cpp @@ -6,6 +6,7 @@ * */ +#include #include #include #include @@ -31,6 +32,7 @@ #include #include #include +#include #include #include diff --git a/Gems/PhysX/Code/Source/PhysXCharacters/Components/CharacterGameplayComponent.cpp b/Gems/PhysX/Code/Source/PhysXCharacters/Components/CharacterGameplayComponent.cpp index bb32f707be..4a4f12558d 100644 --- a/Gems/PhysX/Code/Source/PhysXCharacters/Components/CharacterGameplayComponent.cpp +++ b/Gems/PhysX/Code/Source/PhysXCharacters/Components/CharacterGameplayComponent.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/Gems/Prefab/PrefabBuilder/PrefabBuilderTests.cpp b/Gems/Prefab/PrefabBuilder/PrefabBuilderTests.cpp index 7d3096a6da..ab6770c3fe 100644 --- a/Gems/Prefab/PrefabBuilder/PrefabBuilderTests.cpp +++ b/Gems/Prefab/PrefabBuilder/PrefabBuilderTests.cpp @@ -7,6 +7,7 @@ */ #include "PrefabBuilderTests.h" +#include #include #include #include diff --git a/Gems/PythonAssetBuilder/Code/Source/PythonBuilderNotificationHandler.h b/Gems/PythonAssetBuilder/Code/Source/PythonBuilderNotificationHandler.h index 669ef21914..099bc9d587 100644 --- a/Gems/PythonAssetBuilder/Code/Source/PythonBuilderNotificationHandler.h +++ b/Gems/PythonAssetBuilder/Code/Source/PythonBuilderNotificationHandler.h @@ -9,6 +9,7 @@ #include #include +#include namespace PythonAssetBuilder { diff --git a/Gems/PythonAssetBuilder/Code/Source/PythonBuilderWorker.cpp b/Gems/PythonAssetBuilder/Code/Source/PythonBuilderWorker.cpp index 0e05c5e7bf..f06b4a22d7 100644 --- a/Gems/PythonAssetBuilder/Code/Source/PythonBuilderWorker.cpp +++ b/Gems/PythonAssetBuilder/Code/Source/PythonBuilderWorker.cpp @@ -8,6 +8,7 @@ #include +#include #include #include #include @@ -56,7 +57,7 @@ namespace PythonAssetBuilder { this->ProcessJob(request, response); }; - + // connect to the shutdown signal handler AssetBuilderCommandBus::Handler::BusConnect(m_assetBuilderDesc->m_busId); diff --git a/Gems/SceneProcessing/Code/Source/Config/Components/SceneProcessingConfigSystemComponent.cpp b/Gems/SceneProcessing/Code/Source/Config/Components/SceneProcessingConfigSystemComponent.cpp index ea0c3520bf..281def11b5 100644 --- a/Gems/SceneProcessing/Code/Source/Config/Components/SceneProcessingConfigSystemComponent.cpp +++ b/Gems/SceneProcessing/Code/Source/Config/Components/SceneProcessingConfigSystemComponent.cpp @@ -7,6 +7,7 @@ */ #include +#include #include #include diff --git a/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilder.cpp b/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilder.cpp index 9c3cdca3e8..3c168855d8 100644 --- a/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilder.cpp +++ b/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilder.cpp @@ -12,6 +12,7 @@ #include #include #include +#include namespace ScriptCanvasBuilderCpp { diff --git a/Gems/ScriptCanvas/Code/Editor/Settings.h b/Gems/ScriptCanvas/Code/Editor/Settings.h index 7eff40ec43..eefb7454c3 100644 --- a/Gems/ScriptCanvas/Code/Editor/Settings.h +++ b/Gems/ScriptCanvas/Code/Editor/Settings.h @@ -8,6 +8,7 @@ #pragma once +#include #include #include diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/AssetGraphSceneDataBus.h b/Gems/ScriptCanvas/Code/Editor/View/Widgets/AssetGraphSceneDataBus.h index 2b53cf9fd5..cbb8ef12d6 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/AssetGraphSceneDataBus.h +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/AssetGraphSceneDataBus.h @@ -8,6 +8,7 @@ #pragma once +#include #include #include diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Asset/RuntimeAsset.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Asset/RuntimeAsset.cpp index e708efc71f..0dcd8ebbbd 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Asset/RuntimeAsset.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Asset/RuntimeAsset.cpp @@ -9,6 +9,7 @@ #include "RuntimeAsset.h" #include +#include namespace ScriptCanvasRuntimeAssetCpp { diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/AutoGen/ScriptCanvasGrammar_Source.jinja b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/AutoGen/ScriptCanvasGrammar_Source.jinja index 64e92c1ac7..1ddffe3de9 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/AutoGen/ScriptCanvasGrammar_Source.jinja +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/AutoGen/ScriptCanvasGrammar_Source.jinja @@ -14,6 +14,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT {% endmacro %} #include #include +#include #include #include diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/AutoGen/ScriptCanvasNodeable_Source.jinja b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/AutoGen/ScriptCanvasNodeable_Source.jinja index 236866ffeb..f80c932735 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/AutoGen/ScriptCanvasNodeable_Source.jinja +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/AutoGen/ScriptCanvasNodeable_Source.jinja @@ -15,6 +15,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +#include #include #include #include diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Core/FunctionDefinitionNode.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Core/FunctionDefinitionNode.cpp index 6cda0b75dd..542fc2f0c1 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Core/FunctionDefinitionNode.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Core/FunctionDefinitionNode.cpp @@ -14,6 +14,7 @@ #include #include +#include namespace FunctionDefinitionNodeCpp { diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Utils/VersionConverters.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Utils/VersionConverters.cpp index 2998b3c2ee..23e4a8cc7a 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Utils/VersionConverters.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Utils/VersionConverters.cpp @@ -7,6 +7,7 @@ */ #include "VersionConverters.h" +#include #include #include diff --git a/Gems/ScriptCanvas/Code/Tests/ScriptCanvasBuilderTests.cpp b/Gems/ScriptCanvas/Code/Tests/ScriptCanvasBuilderTests.cpp index 5b38b640ca..cba14feac6 100644 --- a/Gems/ScriptCanvas/Code/Tests/ScriptCanvasBuilderTests.cpp +++ b/Gems/ScriptCanvas/Code/Tests/ScriptCanvasBuilderTests.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include diff --git a/Gems/ScriptCanvasTesting/Code/Source/Nodes/BehaviorContextObjectTestNode.h b/Gems/ScriptCanvasTesting/Code/Source/Nodes/BehaviorContextObjectTestNode.h index 2093912dd9..cc7bda1c95 100644 --- a/Gems/ScriptCanvasTesting/Code/Source/Nodes/BehaviorContextObjectTestNode.h +++ b/Gems/ScriptCanvasTesting/Code/Source/Nodes/BehaviorContextObjectTestNode.h @@ -10,6 +10,9 @@ #include +#include +#include + namespace ScriptCanvasTestingNodes { //! This object is used to test the use of BehaviorContext classes diff --git a/Gems/ScriptEvents/Code/Include/ScriptEvents/Internal/BehaviorContextBinding/ScriptEventBroadcast.h b/Gems/ScriptEvents/Code/Include/ScriptEvents/Internal/BehaviorContextBinding/ScriptEventBroadcast.h index de2563c6ad..d29bf5910c 100644 --- a/Gems/ScriptEvents/Code/Include/ScriptEvents/Internal/BehaviorContextBinding/ScriptEventBroadcast.h +++ b/Gems/ScriptEvents/Code/Include/ScriptEvents/Internal/BehaviorContextBinding/ScriptEventBroadcast.h @@ -9,6 +9,7 @@ #pragma once #include +#include #include #include @@ -38,8 +39,8 @@ namespace ScriptEvents void ReserveArguments(size_t numArguments); - size_t GetNumArguments() const override { return m_behaviorParameters.size(); } - const AZ::BehaviorParameter* GetArgument(size_t index) const override + size_t GetNumArguments() const override { return m_behaviorParameters.size(); } + const AZ::BehaviorParameter* GetArgument(size_t index) const override { if (index >= m_behaviorParameters.size()) { diff --git a/Gems/ScriptEvents/Code/Include/ScriptEvents/Internal/BehaviorContextBinding/ScriptEventMethod.h b/Gems/ScriptEvents/Code/Include/ScriptEvents/Internal/BehaviorContextBinding/ScriptEventMethod.h index 0ff8194e56..a0893417fc 100644 --- a/Gems/ScriptEvents/Code/Include/ScriptEvents/Internal/BehaviorContextBinding/ScriptEventMethod.h +++ b/Gems/ScriptEvents/Code/Include/ScriptEvents/Internal/BehaviorContextBinding/ScriptEventMethod.h @@ -9,6 +9,7 @@ #pragma once #include +#include #include #include @@ -38,8 +39,8 @@ namespace ScriptEvents void ReserveArguments(size_t numArguments); - size_t GetNumArguments() const override { return m_behaviorParameters.size(); } - const AZ::BehaviorParameter* GetArgument(size_t index) const override + size_t GetNumArguments() const override { return m_behaviorParameters.size(); } + const AZ::BehaviorParameter* GetArgument(size_t index) const override { if (index >= m_behaviorParameters.size()) { @@ -47,7 +48,7 @@ namespace ScriptEvents return nullptr; } - return &m_behaviorParameters[index]; + return &m_behaviorParameters[index]; } const AZStd::string* GetArgumentName(size_t index) const override { return &m_argumentNames[index]; } diff --git a/Gems/ScriptEvents/Code/Include/ScriptEvents/ScriptEventMethod.h b/Gems/ScriptEvents/Code/Include/ScriptEvents/ScriptEventMethod.h index a04b5969bf..77f8d1cbd4 100644 --- a/Gems/ScriptEvents/Code/Include/ScriptEvents/ScriptEventMethod.h +++ b/Gems/ScriptEvents/Code/Include/ScriptEvents/ScriptEventMethod.h @@ -9,10 +9,12 @@ #pragma once #include -#include -#include #include +namespace AZ +{ + class ReflectContext; +} namespace ScriptEvents { //! Holds the versioned definition for each of a script events. @@ -21,7 +23,6 @@ namespace ScriptEvents class Method { public: - AZ_TYPE_INFO(Method, "{E034EA83-C798-413D-ACE8-4923C51CF4F7}"); Method() @@ -67,29 +68,7 @@ namespace ScriptEvents FromScript(dc); } - void FromScript(AZ::ScriptDataContext& dc) - { - if (dc.GetNumArguments() > 0) - { - AZStd::string name; - if (dc.IsString(0) && dc.ReadArg(0, name)) - { - m_name.Set(name.c_str()); - } - - if (dc.GetNumArguments() > 1) - { - AZ::Uuid returnType; - if (dc.ReadArg(1, returnType)) - { - m_returnType.Set(returnType); - } - } - } - - //AZ_TracePrintf("Script Events", "Added Script Method: %s (return type: %s)\n", GetName().c_str(), m_returnType.IsEmpty() ? "none" : GetReturnType().ToString().c_str()); - - } + void FromScript(AZ::ScriptDataContext& dc); ~Method() { @@ -111,150 +90,71 @@ namespace ScriptEvents return m_parameters.back(); } - static void Reflect(AZ::ReflectContext* context) + static void Reflect(AZ::ReflectContext* context); + + AZStd::string GetName() const { - if (AZ::SerializeContext* serializeContext = azrtti_cast(context)) - { - serializeContext->Class() - ->Field("m_name", &Method::m_name) - ->Field("m_tooltip", &Method::m_tooltip) - ->Field("m_returnType", &Method::m_returnType) - ->Field("m_parameters", &Method::m_parameters) - ; - - if (AZ::EditContext* editContext = serializeContext->GetEditContext()) - { - editContext->Class("Script Event", "A script event's definition") - ->DataElement(AZ::Edit::UIHandlers::Default, &Method::m_name, "Name", "The specified name for this event, represents a callable function (i.e. MyScriptEvent())") - ->DataElement(AZ::Edit::UIHandlers::Default, &Method::m_tooltip, "Tooltip", "A description of this event") - ->DataElement(AZ::Edit::UIHandlers::ComboBox, &Method::m_returnType, "Return value type", "the typeid of the return value, ex. AZ::type_info::Uuid foo()") - ->Attribute(AZ::Edit::Attributes::GenericValueList, &Types::GetValidReturnTypes) - ->DataElement(AZ::Edit::UIHandlers::Default, &Method::m_parameters, "Parameters", "A list of parameters for the EBus event, ex. void foo(Parameter1, Parameter2)") - ; - } - } - - if (AZ::BehaviorContext* behaviorContext = azrtti_cast(context)) - { - behaviorContext->Class("Method") - ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All) - ->Method("AddParameter", &Method::AddParameter) - ->Property("Name", BehaviorValueProperty(&Method::m_name)) - ->Property("ReturnType", BehaviorValueProperty(&Method::m_returnType)) - ->Property("Parameters", BehaviorValueProperty(&Method::m_parameters)) - ; - } + return m_name.Get() ? *m_name.Get() : ""; + } + AZStd::string GetTooltip() const + { + return m_tooltip.Get() ? *m_tooltip.Get() : ""; } - AZStd::string GetName() const { return m_name.Get() ? *m_name.Get() : ""; } - AZStd::string GetTooltip() const { return m_tooltip.Get() ? *m_tooltip.Get() : ""; } - const AZ::Uuid GetReturnType() const { return m_returnType.Get() ? *m_returnType.Get() : AZ::Uuid::CreateNull(); } - const AZStd::vector& GetParameters() const { return m_parameters; } + const AZ::Uuid GetReturnType() const + { + return m_returnType.Get() ? *m_returnType.Get() : AZ::Uuid::CreateNull(); + } - ScriptEventData::VersionedProperty& GetNameProperty() { return m_name; } - ScriptEventData::VersionedProperty& GetTooltipProperty() { return m_tooltip; } - ScriptEventData::VersionedProperty& GetReturnTypeProperty() { return m_returnType; } + const AZStd::vector& GetParameters() const + { + return m_parameters; + } - const ScriptEventData::VersionedProperty& GetNameProperty() const { return m_name; } - const ScriptEventData::VersionedProperty& GetTooltipProperty() const { return m_tooltip; } - const ScriptEventData::VersionedProperty& GetReturnTypeProperty() const { return m_returnType; } + ScriptEventData::VersionedProperty& GetNameProperty() + { + return m_name; + } - AZ::Crc32 GetEventId() const { return AZ::Crc32(GetNameProperty().GetId().ToString().c_str()); } + ScriptEventData::VersionedProperty& GetTooltipProperty() + { + return m_tooltip; + } + ScriptEventData::VersionedProperty& GetReturnTypeProperty() + { + return m_returnType; + } + + const ScriptEventData::VersionedProperty& GetNameProperty() const + { + return m_name; + } + + const ScriptEventData::VersionedProperty& GetTooltipProperty() const + { + return m_tooltip; + } + + const ScriptEventData::VersionedProperty& GetReturnTypeProperty() const + { + return m_returnType; + } + + AZ::Crc32 GetEventId() const + { + return AZ::Crc32(GetNameProperty().GetId().ToString().c_str()); + } //! Validates that the asset data being stored is valid and supported. - AZ::Outcome Validate() const - { - const AZStd::string name = GetName(); - const AZ::Uuid returnType = GetReturnType(); - - // Validate address type - if (!Types::IsValidReturnType(returnType)) - { - return AZ::Failure(AZStd::string::format("The specified type %s is not valid as return type for Script Event: %s", returnType.ToString().c_str(), name.c_str())); - } - - // Definition name cannot be empty - if (name.empty()) - { - return AZ::Failure(AZStd::string("Definition name cannot be empty")); - } - - // Name cannot start with a number - if (isdigit(name.at(0))) - { - return AZ::Failure(AZStd::string::format("%s, names cannot start with a number", name.c_str())); - } - - // Conform to valid function names - AZStd::smatch match; - - // Ascii-only - AZStd::regex asciionly_regex("[^\x0A\x0D\x20-\x7E]"); - AZStd::regex_match(name, match, asciionly_regex); - if (!match.empty()) - { - return AZ::Failure(AZStd::string::format("%s, invalid name, names may only contain ASCII characters", name.c_str())); - } - - AZStd::regex validate_regex("[_[:alpha:]][_[:alnum:]]*"); - AZStd::regex_match(name, match, validate_regex); - if (match.empty()) - { - return AZ::Failure(AZStd::string::format("%s, invalid name specified", name.c_str())); - } - - AZStd::string parameterName; - int parameterIndex = 0; - for (const Parameter& parameter : m_parameters) - { - auto outcome = parameter.Validate(); - if (!outcome.IsSuccess()) - { - return outcome; - } - - if (parameter.GetName().compare(parameterName) == 0) - { - return AZ::Failure(AZStd::string::format("Cannot have duplicate parameter names (%d: %s) make sure each parameter name is unique", parameterIndex, parameterName.c_str())); - } - - parameterName = parameter.GetName(); - ++parameterIndex; - } - - return AZ::Success(true); - } - - void PreSave() - { - m_name.PreSave(); - m_tooltip.PreSave(); - m_returnType.PreSave(); - - for (Parameter parameter : m_parameters) - { - parameter.PreSave(); - } - } - - void Flatten() - { - m_name.Flatten(); - m_tooltip.Flatten(); - m_returnType.Flatten(); - for (Parameter& parameter : m_parameters) - { - parameter.Flatten(); - } - } + AZ::Outcome Validate() const; + void PreSave(); + void Flatten(); private: - ScriptEventData::VersionedProperty m_name; ScriptEventData::VersionedProperty m_tooltip; ScriptEventData::VersionedProperty m_returnType; AZStd::vector m_parameters; + }; - }; - -} +} // namespace ScriptEvents diff --git a/Gems/ScriptEvents/Code/Include/ScriptEvents/ScriptEventParameter.h b/Gems/ScriptEvents/Code/Include/ScriptEvents/ScriptEventParameter.h index 3871a04be5..ad5b872d79 100644 --- a/Gems/ScriptEvents/Code/Include/ScriptEvents/ScriptEventParameter.h +++ b/Gems/ScriptEvents/Code/Include/ScriptEvents/ScriptEventParameter.h @@ -9,10 +9,7 @@ #pragma once #include -#include #include -#include -#include namespace ScriptEvents { @@ -45,109 +42,11 @@ namespace ScriptEvents FromScript(dc); } - void FromScript(AZ::ScriptDataContext& dc) - { - if (dc.GetNumArguments() > 0) - { - AZStd::string name; - if (dc.ReadArg(0, name)) - { - m_name.Set(name.c_str()); - } + void FromScript(AZ::ScriptDataContext& dc); - if (dc.GetNumArguments() > 1) - { - AZ::Uuid parameterType; - if (dc.ReadArg(1, parameterType)) - { - m_type.Set(parameterType); - } - } - } - - //AZ_TracePrintf("Script Events", "Added Parameter: %s (type: %s)\n", GetName().c_str(), GetType().ToString() .c_str()); - - } - - static void Reflect(AZ::ReflectContext* context) - { - if (AZ::SerializeContext* serializeContext = azrtti_cast(context)) - { - serializeContext->Class() - ->Field("m_name", &Parameter::m_name) - ->Field("m_tooltip", &Parameter::m_tooltip) - ->Field("m_type", &Parameter::m_type) - ; - - if (AZ::EditContext* editContext = serializeContext->GetEditContext()) - { - editContext->Class("A Script Event's method parameter", "A parameter to a Script Event's event definition") - ->DataElement(AZ::Edit::UIHandlers::Default, &Parameter::m_name, "Name", "Name of the parameter, ex. void foo(int thisIsTheParameterName)") - ->DataElement(AZ::Edit::UIHandlers::Default, &Parameter::m_tooltip, "Tooltip", "A description of this parameter") - ->DataElement(AZ::Edit::UIHandlers::ComboBox, &Parameter::m_type, "Type", "The typeid of the parameter, ex. void foo(AZ::type_info::Uuid())") - ->Attribute(AZ::Edit::Attributes::GenericValueList, &Types::GetValidParameterTypes) - ; - } - } - - if (AZ::BehaviorContext* behaviorContext = azrtti_cast(context)) - { - behaviorContext->Class("Parameter") - ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All) - ->Property("Name", BehaviorValueProperty(&Parameter::m_name)) - ->Property("Type", BehaviorValueProperty(&Parameter::m_type)) - ; - } - } - - AZ::Outcome Validate() const - { - const AZStd::string& name = GetName(); - const AZ::Uuid* parameterType = m_type.Get(); - - AZ_Assert(parameterType && !parameterType->IsNull(), "The Parameter type should not be null"); - - // Validate address type - if (!Types::IsValidParameterType(*parameterType)) - { - return AZ::Failure(AZStd::string::format("The specified type %s is not valid as parameter type for Script Event: %s", (*parameterType).ToString().c_str(), name.c_str())); - } - - // Definition name cannot be empty - if (name.empty()) - { - return AZ::Failure(AZStd::string("Definition name cannot be empty")); - } - - // Name cannot start with a number - if (isdigit(name.at(0))) - { - return AZ::Failure(AZStd::string::format("%s, names cannot start with a number", name.c_str())); - } - - // Conform to valid function names - AZStd::smatch match; - - // Ascii-only - AZStd::regex asciionly_regex("[^\x0A\x0D\x20-\x7E]"); - AZStd::regex_match(name, match, asciionly_regex); - if (match.size() > 0) - { - return AZ::Failure(AZStd::string::format("%s, invalid name, names may only contain ASCII characters", name.c_str())); - } - - // Function name syntax - AZStd::regex validate_regex("[_[:alpha:]][_[:alnum:]]*"); - AZStd::regex_match(name, match, validate_regex); - if (match.size() == 0) - { - return AZ::Failure(AZStd::string::format("%s, invalid name specified", name.c_str())); - } - - return AZ::Success(true); - - } + static void Reflect(AZ::ReflectContext* context); + AZ::Outcome Validate() const; AZStd::string GetName() const { return m_name.Get() ? *m_name.Get() : ""; } AZStd::string GetTooltip() const { return m_tooltip.Get() ? *m_tooltip.Get() : ""; } AZ::Uuid GetType() const { return m_type.Get() ? *m_type.Get() : AZ::Uuid::CreateNull(); } diff --git a/Gems/ScriptEvents/Code/Include/ScriptEvents/ScriptEventTypes.h b/Gems/ScriptEvents/Code/Include/ScriptEvents/ScriptEventTypes.h index a523d932ea..96233e5867 100644 --- a/Gems/ScriptEvents/Code/Include/ScriptEvents/ScriptEventTypes.h +++ b/Gems/ScriptEvents/Code/Include/ScriptEvents/ScriptEventTypes.h @@ -10,6 +10,14 @@ #include +#include + +namespace AZ +{ + class BehaviorClass; + class BehaviorMethod; +} + namespace ScriptEvents { namespace Types diff --git a/Gems/ScriptEvents/Code/Include/ScriptEvents/ScriptEventsAssetRef.h b/Gems/ScriptEvents/Code/Include/ScriptEvents/ScriptEventsAssetRef.h index 619dd42483..526a36f6b9 100644 --- a/Gems/ScriptEvents/Code/Include/ScriptEvents/ScriptEventsAssetRef.h +++ b/Gems/ScriptEvents/Code/Include/ScriptEvents/ScriptEventsAssetRef.h @@ -9,12 +9,10 @@ #include #include -#include #include #include #include #include -#include #include @@ -38,40 +36,7 @@ namespace ScriptEvents using AssetChangedCB = AZStd::function&, void* userData)>; - static void Reflect(AZ::ReflectContext* context) - { - if (AZ::SerializeContext* serializeContext = azrtti_cast(context)) - { - serializeContext->Class() - ->Version(0) - ->Field("Asset", &ScriptEventsAssetRef::m_asset) - ; - - if (AZ::EditContext* editContext = serializeContext->GetEditContext()) - { - editContext->Class("Script Event Asset", "") - ->ClassElement(AZ::Edit::ClassElements::EditorData, "") - ->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly) - ->DataElement(AZ::Edit::UIHandlers::Default, &ScriptEventsAssetRef::m_asset, "Script Event Asset", "") - ->Attribute(AZ::Edit::Attributes::ChangeNotify, &ScriptEventsAssetRef::OnAssetChanged) - //TODO #lsempe: hook up to open Asset Editor when ready - //->Attribute("EditButton", "") - //->Attribute("EditDescription", "Open in Script Canvas Editor") - //->Attribute("EditCallback", &ScriptEventsAssetRef::LaunchScriptCanvasEditor) - ; - } - } - - if (AZ::BehaviorContext* behaviorContext = azrtti_cast(context)) - { - behaviorContext->Class() - ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All) - ->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value) - ->Attribute(AZ::Script::Attributes::ConstructibleFromNil, false) - ->Method("Get", &ScriptEventsAssetRef::GetDefinition) - ; - } - } + static void Reflect(AZ::ReflectContext* context); ScriptEventsAssetRef() = default; @@ -100,98 +65,22 @@ namespace ScriptEvents return nullptr; } - void SetAsset(const AZ::Data::Asset& asset) - { - m_asset = asset; - - if (m_asset.IsReady()) - { - if (ScriptEventsAsset* scriptEventAsset = m_asset.GetAs()) - { - scriptEventAsset->m_definition.RegisterInternal(); - } - } - else - { - if (AZ::Data::AssetBus::Handler::BusIsConnectedId(m_asset.GetId())) - { - AZ::Data::AssetBus::Handler::BusDisconnect(m_asset.GetId()); - } - - AZ::Data::AssetBus::Handler::BusConnect(m_asset.GetId()); - } - } + void SetAsset(const AZ::Data::Asset& asset); AZ::Data::Asset GetAsset() const { return m_asset; } - void Load(bool loadBlocking /*= false*/) - { - if (!m_asset.IsReady()) - { - AZ::Data::AssetInfo assetInfo; - AZ::Data::AssetCatalogRequestBus::BroadcastResult(assetInfo, &AZ::Data::AssetCatalogRequests::GetAssetInfoById, m_asset.GetId()); - if (assetInfo.m_assetId.IsValid()) - { - auto& assetManager = AZ::Data::AssetManager::Instance(); - m_asset = assetManager.GetAsset(m_asset.GetId(), azrtti_typeid(), m_asset.GetAutoLoadBehavior()); - - if(loadBlocking) - { - m_asset.BlockUntilLoadComplete(); - } - } - } - } - - AZ::u32 OnAssetChanged() - { - SetAsset(m_asset); - Load(false); - - if (m_assetNotifyCallback) - { - m_assetNotifyCallback(m_asset, m_userData); - } - - return AZ::Edit::PropertyRefreshLevels::None; - } + void Load(bool loadBlocking /*= false*/); + AZ::u32 OnAssetChanged(); //===================================================================== // AZ::Data::AssetBus - void OnAssetReady(AZ::Data::Asset asset) override - { - if (ScriptEventsAsset* scriptEventAsset = m_asset.GetAs()) - { - scriptEventAsset->m_definition.RegisterInternal(); - } - } - - void OnAssetReloaded(AZ::Data::Asset asset) override - { - SetAsset(asset); - - if (m_assetNotifyCallback) - { - m_assetNotifyCallback(m_asset, m_userData); - } - } - - void OnAssetUnloaded([[maybe_unused]] const AZ::Data::AssetId assetId, [[maybe_unused]] const AZ::Data::AssetType assetType) override - { - if (ScriptEventsAsset* ebusAsset = m_asset.GetAs()) - { - bool isRegistered = false; - //ScriptEventsLegacy::RegistrationRequestBus::BroadcastResult(isRegistered, &ScriptEventsLegacy::RegistrationRequestBus::Events::IsBusRegistered, ebusAsset->m_scriptEventsDefinition.m_name); - if (isRegistered) - { - //ScriptEventsLegacy::RegistrationRequestBus::Broadcast(&ScriptEventsLegacy::RegistrationRequestBus::Events::Unregister, ebusAsset->m_scriptEventsDefinition.m_name); - } - } - } + void OnAssetReady(AZ::Data::Asset asset) override; + void OnAssetReloaded(AZ::Data::Asset asset) override; + void OnAssetUnloaded(const AZ::Data::AssetId assetId, const AZ::Data::AssetType assetType) override; void OnAssetSaved(AZ::Data::Asset asset, [[maybe_unused]] bool isSuccessful) override { diff --git a/Gems/ScriptEvents/Code/Source/Editor/ScriptEventsEditorGem.cpp b/Gems/ScriptEvents/Code/Source/Editor/ScriptEventsEditorGem.cpp index 8ac100c01f..8ab014ec15 100644 --- a/Gems/ScriptEvents/Code/Source/Editor/ScriptEventsEditorGem.cpp +++ b/Gems/ScriptEvents/Code/Source/Editor/ScriptEventsEditorGem.cpp @@ -13,6 +13,7 @@ #include #include +#include #if defined(SCRIPTEVENTS_EDITOR) namespace ScriptEvents diff --git a/Gems/ScriptEvents/Code/Source/ScriptEventMethod.cpp b/Gems/ScriptEvents/Code/Source/ScriptEventMethod.cpp new file mode 100644 index 0000000000..5b7bb590af --- /dev/null +++ b/Gems/ScriptEvents/Code/Source/ScriptEventMethod.cpp @@ -0,0 +1,167 @@ +/* + * 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 "ScriptEvents/ScriptEventMethod.h" + +#include +#include +#include + +namespace ScriptEvents +{ + void Method::FromScript(AZ::ScriptDataContext& dc) + { + if (dc.GetNumArguments() > 0) + { + AZStd::string name; + if (dc.IsString(0) && dc.ReadArg(0, name)) + { + m_name.Set(name.c_str()); + } + + if (dc.GetNumArguments() > 1) + { + AZ::Uuid returnType; + if (dc.ReadArg(1, returnType)) + { + m_returnType.Set(returnType); + } + } + } + + // AZ_TracePrintf("Script Events", "Added Script Method: %s (return type: %s)\n", GetName().c_str(), m_returnType.IsEmpty() ? "none" + // : GetReturnType().ToString().c_str()); + } + void Method::Reflect(AZ::ReflectContext* context) + { + if (AZ::SerializeContext* serializeContext = azrtti_cast(context)) + { + serializeContext->Class() + ->Field("m_name", &Method::m_name) + ->Field("m_tooltip", &Method::m_tooltip) + ->Field("m_returnType", &Method::m_returnType) + ->Field("m_parameters", &Method::m_parameters); + + if (AZ::EditContext* editContext = serializeContext->GetEditContext()) + { + editContext->Class("Script Event", "A script event's definition") + ->DataElement( + AZ::Edit::UIHandlers::Default, &Method::m_name, "Name", + "The specified name for this event, represents a callable function (i.e. MyScriptEvent())") + ->DataElement(AZ::Edit::UIHandlers::Default, &Method::m_tooltip, "Tooltip", "A description of this event") + ->DataElement( + AZ::Edit::UIHandlers::ComboBox, &Method::m_returnType, "Return value type", + "the typeid of the return value, ex. AZ::type_info::Uuid foo()") + ->Attribute(AZ::Edit::Attributes::GenericValueList, &Types::GetValidReturnTypes) + ->DataElement( + AZ::Edit::UIHandlers::Default, &Method::m_parameters, "Parameters", + "A list of parameters for the EBus event, ex. void foo(Parameter1, Parameter2)"); + } + } + + if (AZ::BehaviorContext* behaviorContext = azrtti_cast(context)) + { + behaviorContext->Class("Method") + ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All) + ->Method("AddParameter", &Method::AddParameter) + ->Property("Name", BehaviorValueProperty(&Method::m_name)) + ->Property("ReturnType", BehaviorValueProperty(&Method::m_returnType)) + ->Property("Parameters", BehaviorValueProperty(&Method::m_parameters)); + } + } + + AZ::Outcome Method::Validate() const + { + const AZStd::string name = GetName(); + const AZ::Uuid returnType = GetReturnType(); + + // Validate address type + if (!Types::IsValidReturnType(returnType)) + { + return AZ::Failure(AZStd::string::format( + "The specified type %s is not valid as return type for Script Event: %s", returnType.ToString().c_str(), + name.c_str())); + } + + // Definition name cannot be empty + if (name.empty()) + { + return AZ::Failure(AZStd::string("Definition name cannot be empty")); + } + + // Name cannot start with a number + if (isdigit(name.at(0))) + { + return AZ::Failure(AZStd::string::format("%s, names cannot start with a number", name.c_str())); + } + + // Conform to valid function names + AZStd::smatch match; + + // Ascii-only + AZStd::regex asciionly_regex("[^\x0A\x0D\x20-\x7E]"); + AZStd::regex_match(name, match, asciionly_regex); + if (!match.empty()) + { + return AZ::Failure(AZStd::string::format("%s, invalid name, names may only contain ASCII characters", name.c_str())); + } + + AZStd::regex validate_regex("[_[:alpha:]][_[:alnum:]]*"); + AZStd::regex_match(name, match, validate_regex); + if (match.empty()) + { + return AZ::Failure(AZStd::string::format("%s, invalid name specified", name.c_str())); + } + + AZStd::string parameterName; + int parameterIndex = 0; + for (const Parameter& parameter : m_parameters) + { + auto outcome = parameter.Validate(); + if (!outcome.IsSuccess()) + { + return outcome; + } + + if (parameter.GetName().compare(parameterName) == 0) + { + return AZ::Failure(AZStd::string::format( + "Cannot have duplicate parameter names (%d: %s) make sure each parameter name is unique", parameterIndex, + parameterName.c_str())); + } + + parameterName = parameter.GetName(); + ++parameterIndex; + } + + return AZ::Success(true); + } + + void Method::PreSave() + { + m_name.PreSave(); + m_tooltip.PreSave(); + m_returnType.PreSave(); + + for (Parameter parameter : m_parameters) + { + parameter.PreSave(); + } + } + + void Method::Flatten() + { + m_name.Flatten(); + m_tooltip.Flatten(); + m_returnType.Flatten(); + for (Parameter& parameter : m_parameters) + { + parameter.Flatten(); + } + } +} // namespace ScriptEvents diff --git a/Gems/ScriptEvents/Code/Source/ScriptEventParameter.cpp b/Gems/ScriptEvents/Code/Source/ScriptEventParameter.cpp new file mode 100644 index 0000000000..1f888de10f --- /dev/null +++ b/Gems/ScriptEvents/Code/Source/ScriptEventParameter.cpp @@ -0,0 +1,122 @@ +/* + * 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 "ScriptEvents/ScriptEventParameter.h" + +#include +#include +#include +#include + +namespace ScriptEvents +{ + void Parameter::FromScript(AZ::ScriptDataContext& dc) + { + if (dc.GetNumArguments() > 0) + { + AZStd::string name; + if (dc.ReadArg(0, name)) + { + m_name.Set(name.c_str()); + } + + if (dc.GetNumArguments() > 1) + { + AZ::Uuid parameterType; + if (dc.ReadArg(1, parameterType)) + { + m_type.Set(parameterType); + } + } + } + + // AZ_TracePrintf("Script Events", "Added Parameter: %s (type: %s)\n", GetName().c_str(), GetType().ToString() + // .c_str()); + } + + void Parameter::Reflect(AZ::ReflectContext* context) + { + if (AZ::SerializeContext* serializeContext = azrtti_cast(context)) + { + serializeContext->Class() + ->Field("m_name", &Parameter::m_name) + ->Field("m_tooltip", &Parameter::m_tooltip) + ->Field("m_type", &Parameter::m_type); + + if (AZ::EditContext* editContext = serializeContext->GetEditContext()) + { + editContext->Class("A Script Event's method parameter", "A parameter to a Script Event's event definition") + ->DataElement( + AZ::Edit::UIHandlers::Default, &Parameter::m_name, "Name", + "Name of the parameter, ex. void foo(int thisIsTheParameterName)") + ->DataElement(AZ::Edit::UIHandlers::Default, &Parameter::m_tooltip, "Tooltip", "A description of this parameter") + ->DataElement( + AZ::Edit::UIHandlers::ComboBox, &Parameter::m_type, "Type", + "The typeid of the parameter, ex. void foo(AZ::type_info::Uuid())") + ->Attribute(AZ::Edit::Attributes::GenericValueList, &Types::GetValidParameterTypes); + } + } + + if (AZ::BehaviorContext* behaviorContext = azrtti_cast(context)) + { + behaviorContext->Class("Parameter") + ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All) + ->Property("Name", BehaviorValueProperty(&Parameter::m_name)) + ->Property("Type", BehaviorValueProperty(&Parameter::m_type)); + } + } + + AZ::Outcome Parameter::Validate() const + { + const AZStd::string& name = GetName(); + const AZ::Uuid* parameterType = m_type.Get(); + + AZ_Assert(parameterType && !parameterType->IsNull(), "The Parameter type should not be null"); + + // Validate address type + if (!Types::IsValidParameterType(*parameterType)) + { + return AZ::Failure(AZStd::string::format( + "The specified type %s is not valid as parameter type for Script Event: %s", + (*parameterType).ToString().c_str(), name.c_str())); + } + + // Definition name cannot be empty + if (name.empty()) + { + return AZ::Failure(AZStd::string("Definition name cannot be empty")); + } + + // Name cannot start with a number + if (isdigit(name.at(0))) + { + return AZ::Failure(AZStd::string::format("%s, names cannot start with a number", name.c_str())); + } + + // Conform to valid function names + AZStd::smatch match; + + // Ascii-only + AZStd::regex asciionly_regex("[^\x0A\x0D\x20-\x7E]"); + AZStd::regex_match(name, match, asciionly_regex); + if (match.size() > 0) + { + return AZ::Failure(AZStd::string::format("%s, invalid name, names may only contain ASCII characters", name.c_str())); + } + + // Function name syntax + AZStd::regex validate_regex("[_[:alpha:]][_[:alnum:]]*"); + AZStd::regex_match(name, match, validate_regex); + if (match.size() == 0) + { + return AZ::Failure(AZStd::string::format("%s, invalid name specified", name.c_str())); + } + + return AZ::Success(true); + } +} // namespace ScriptEvents diff --git a/Gems/ScriptEvents/Code/Source/ScriptEventsAssetRef.cpp b/Gems/ScriptEvents/Code/Source/ScriptEventsAssetRef.cpp new file mode 100644 index 0000000000..d0aa4e1b10 --- /dev/null +++ b/Gems/ScriptEvents/Code/Source/ScriptEventsAssetRef.cpp @@ -0,0 +1,135 @@ +/* + * 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 "ScriptEvents/ScriptEventsAssetRef.h" + +#include +#include +#include + +namespace ScriptEvents +{ + void ScriptEventsAssetRef::Reflect(AZ::ReflectContext* context) + { + if (AZ::SerializeContext* serializeContext = azrtti_cast(context)) + { + serializeContext->Class()->Version(0)->Field("Asset", &ScriptEventsAssetRef::m_asset); + + if (AZ::EditContext* editContext = serializeContext->GetEditContext()) + { + editContext->Class("Script Event Asset", "") + ->ClassElement(AZ::Edit::ClassElements::EditorData, "") + ->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly) + ->DataElement(AZ::Edit::UIHandlers::Default, &ScriptEventsAssetRef::m_asset, "Script Event Asset", "") + ->Attribute(AZ::Edit::Attributes::ChangeNotify, &ScriptEventsAssetRef::OnAssetChanged) + // TODO #lsempe: hook up to open Asset Editor when ready + //->Attribute("EditButton", "") + //->Attribute("EditDescription", "Open in Script Canvas Editor") + //->Attribute("EditCallback", &ScriptEventsAssetRef::LaunchScriptCanvasEditor) + ; + } + } + + if (AZ::BehaviorContext* behaviorContext = azrtti_cast(context)) + { + behaviorContext->Class() + ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All) + ->Attribute(AZ::Script::Attributes::Storage, AZ::Script::Attributes::StorageType::Value) + ->Attribute(AZ::Script::Attributes::ConstructibleFromNil, false) + ->Method("Get", &ScriptEventsAssetRef::GetDefinition); + } + } + + void ScriptEventsAssetRef::SetAsset(const AZ::Data::Asset& asset) + { + m_asset = asset; + + if (m_asset.IsReady()) + { + if (ScriptEventsAsset* scriptEventAsset = m_asset.GetAs()) + { + scriptEventAsset->m_definition.RegisterInternal(); + } + } + else + { + if (AZ::Data::AssetBus::Handler::BusIsConnectedId(m_asset.GetId())) + { + AZ::Data::AssetBus::Handler::BusDisconnect(m_asset.GetId()); + } + + AZ::Data::AssetBus::Handler::BusConnect(m_asset.GetId()); + } + } + + void ScriptEventsAssetRef::Load(bool loadBlocking /*= false*/) + { + if (!m_asset.IsReady()) + { + AZ::Data::AssetInfo assetInfo; + AZ::Data::AssetCatalogRequestBus::BroadcastResult(assetInfo, &AZ::Data::AssetCatalogRequests::GetAssetInfoById, m_asset.GetId()); + if (assetInfo.m_assetId.IsValid()) + { + auto& assetManager = AZ::Data::AssetManager::Instance(); + m_asset = assetManager.GetAsset(m_asset.GetId(), azrtti_typeid(), m_asset.GetAutoLoadBehavior()); + + if(loadBlocking) + { + m_asset.BlockUntilLoadComplete(); + } + } + } + } + + AZ::u32 ScriptEventsAssetRef::OnAssetChanged() + { + SetAsset(m_asset); + Load(false); + + if (m_assetNotifyCallback) + { + m_assetNotifyCallback(m_asset, m_userData); + } + + return AZ::Edit::PropertyRefreshLevels::None; + } + + void ScriptEventsAssetRef::OnAssetReady(AZ::Data::Asset asset) + { + if (ScriptEventsAsset* scriptEventAsset = m_asset.GetAs()) + { + scriptEventAsset->m_definition.RegisterInternal(); + } + } + + void ScriptEventsAssetRef::OnAssetReloaded(AZ::Data::Asset asset) + { + SetAsset(asset); + + if (m_assetNotifyCallback) + { + m_assetNotifyCallback(m_asset, m_userData); + } + } + + void ScriptEventsAssetRef::OnAssetUnloaded( + [[maybe_unused]] const AZ::Data::AssetId assetId, [[maybe_unused]] const AZ::Data::AssetType assetType) + { + if (ScriptEventsAsset* ebusAsset = m_asset.GetAs()) + { + bool isRegistered = false; + // ScriptEventsLegacy::RegistrationRequestBus::BroadcastResult(isRegistered, + // &ScriptEventsLegacy::RegistrationRequestBus::Events::IsBusRegistered, ebusAsset->m_scriptEventsDefinition.m_name); + if (isRegistered) + { + // ScriptEventsLegacy::RegistrationRequestBus::Broadcast(&ScriptEventsLegacy::RegistrationRequestBus::Events::Unregister, + // ebusAsset->m_scriptEventsDefinition.m_name); + } + } + } +} // namespace ScriptEvents diff --git a/Gems/ScriptEvents/Code/scriptevents_common_files.cmake b/Gems/ScriptEvents/Code/scriptevents_common_files.cmake index c83518db32..5938050f5d 100644 --- a/Gems/ScriptEvents/Code/scriptevents_common_files.cmake +++ b/Gems/ScriptEvents/Code/scriptevents_common_files.cmake @@ -9,6 +9,9 @@ set(FILES Source/ScriptEventsSystemComponent.h Source/ScriptEventsSystemComponent.cpp + Source/ScriptEventParameter.cpp + Source/ScriptEventMethod.cpp + Source/ScriptEventsAssetRef.cpp Include/ScriptEvents/ScriptEventsGem.h Include/ScriptEvents/ScriptEventsAsset.h Include/ScriptEvents/ScriptEventsAsset.cpp diff --git a/Gems/StartingPointInput/Code/Source/InputConfigurationComponent.cpp b/Gems/StartingPointInput/Code/Source/InputConfigurationComponent.cpp index 42fa05473c..215efd4656 100644 --- a/Gems/StartingPointInput/Code/Source/InputConfigurationComponent.cpp +++ b/Gems/StartingPointInput/Code/Source/InputConfigurationComponent.cpp @@ -7,11 +7,12 @@ */ #include "InputConfigurationComponent.h" +#include #include -#include -#include -#include #include +#include +#include +#include #include namespace StartingPointInput diff --git a/Gems/Vegetation/Code/Source/Components/DescriptorListComponent.cpp b/Gems/Vegetation/Code/Source/Components/DescriptorListComponent.cpp index 96bef0abda..de2078e2e5 100644 --- a/Gems/Vegetation/Code/Source/Components/DescriptorListComponent.cpp +++ b/Gems/Vegetation/Code/Source/Components/DescriptorListComponent.cpp @@ -8,6 +8,7 @@ #include "DescriptorListComponent.h" #include +#include #include #include #include diff --git a/Gems/Vegetation/Code/Source/Components/MeshBlockerComponent.cpp b/Gems/Vegetation/Code/Source/Components/MeshBlockerComponent.cpp index dc205079fd..9c7fa34dac 100644 --- a/Gems/Vegetation/Code/Source/Components/MeshBlockerComponent.cpp +++ b/Gems/Vegetation/Code/Source/Components/MeshBlockerComponent.cpp @@ -19,6 +19,7 @@ #include #include #include +#include namespace Vegetation { diff --git a/Gems/Vegetation/Code/Source/DynamicSliceInstanceSpawner.cpp b/Gems/Vegetation/Code/Source/DynamicSliceInstanceSpawner.cpp index 0186bba89d..8e6bbf0ed8 100644 --- a/Gems/Vegetation/Code/Source/DynamicSliceInstanceSpawner.cpp +++ b/Gems/Vegetation/Code/Source/DynamicSliceInstanceSpawner.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/Gems/Vegetation/Code/Source/PrefabInstanceSpawner.cpp b/Gems/Vegetation/Code/Source/PrefabInstanceSpawner.cpp index efeb60d598..b386f17cab 100644 --- a/Gems/Vegetation/Code/Source/PrefabInstanceSpawner.cpp +++ b/Gems/Vegetation/Code/Source/PrefabInstanceSpawner.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include diff --git a/Gems/Vegetation/Code/Tests/VegetationMocks.h b/Gems/Vegetation/Code/Tests/VegetationMocks.h index ee620c81a2..ec3760057c 100644 --- a/Gems/Vegetation/Code/Tests/VegetationMocks.h +++ b/Gems/Vegetation/Code/Tests/VegetationMocks.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include diff --git a/Gems/WhiteBox/Code/Source/Asset/EditorWhiteBoxMeshAsset.cpp b/Gems/WhiteBox/Code/Source/Asset/EditorWhiteBoxMeshAsset.cpp index 00f5c0e4f4..a02f0e3c6b 100644 --- a/Gems/WhiteBox/Code/Source/Asset/EditorWhiteBoxMeshAsset.cpp +++ b/Gems/WhiteBox/Code/Source/Asset/EditorWhiteBoxMeshAsset.cpp @@ -11,6 +11,7 @@ #include "EditorWhiteBoxMeshAsset.h" #include "Util/WhiteBoxEditorUtil.h" +#include #include #include #include diff --git a/Gems/WhiteBox/Code/Source/EditorWhiteBoxComponent.cpp b/Gems/WhiteBox/Code/Source/EditorWhiteBoxComponent.cpp index f18b69393c..849e2272a2 100644 --- a/Gems/WhiteBox/Code/Source/EditorWhiteBoxComponent.cpp +++ b/Gems/WhiteBox/Code/Source/EditorWhiteBoxComponent.cpp @@ -16,6 +16,7 @@ #include "Util/WhiteBoxEditorUtil.h" #include "WhiteBoxComponent.h" +#include #include #include #include From 02987d90102e361d179c4d20f8d83a0146c758c0 Mon Sep 17 00:00:00 2001 From: nggieber Date: Wed, 29 Sep 2021 09:34:21 -0700 Subject: [PATCH 12/19] Fixed another non-unity build error Signed-off-by: nggieber --- Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.cpp b/Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.cpp index 9e40a2b231..1839948e80 100644 --- a/Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.cpp +++ b/Code/Tools/ProjectManager/Source/GemRepo/GemRepoAddDialog.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include From b79c2f385d52afa5ff146f41a4ca3508bc12cf65 Mon Sep 17 00:00:00 2001 From: Tommy Walton <82672795+amzn-tommy@users.noreply.github.com> Date: Wed, 29 Sep 2021 11:08:05 -0700 Subject: [PATCH 13/19] Adding a temporary Orphan function to the InstanceDatabase (#4297) * Adding a temporary Orphan function to the InstanceDatabase, which will remove an instance from the database so it will not be found using Find or FindOrCreate. The instance will still persist until its use-count drops to 0, at which point it will be deleted. This is to enable the model asset to remove existing buffer/modellod/model instances and replace them with new instances that have the up to date data. Added unit tests for testing. Signed-off-by: amzn-tommy * Fix an incorrect ceil and update ParallelInstance test cases for readability Signed-off-by: amzn-tommy --- .../AtomCore/AtomCore/Instance/InstanceData.h | 3 + .../AtomCore/Instance/InstanceDatabase.h | 30 ++++ .../AtomCore/Tests/InstanceDatabase.cpp | 169 +++++++++++++++--- 3 files changed, 179 insertions(+), 23 deletions(-) diff --git a/Code/Framework/AtomCore/AtomCore/Instance/InstanceData.h b/Code/Framework/AtomCore/AtomCore/Instance/InstanceData.h index 33fc93c0f5..6b07d12e9c 100644 --- a/Code/Framework/AtomCore/AtomCore/Instance/InstanceData.h +++ b/Code/Framework/AtomCore/AtomCore/Instance/InstanceData.h @@ -89,6 +89,9 @@ namespace AZ // Tracks the asset type used to create the instance. AssetType m_assetType; + + // Boolean to indicate if the instance has been orphaned from the instance database + bool m_isOrphaned = false; }; /// @cond EXCLUDE_DOCS diff --git a/Code/Framework/AtomCore/AtomCore/Instance/InstanceDatabase.h b/Code/Framework/AtomCore/AtomCore/Instance/InstanceDatabase.h index ac97af3629..4b4ad572c2 100644 --- a/Code/Framework/AtomCore/AtomCore/Instance/InstanceDatabase.h +++ b/Code/Framework/AtomCore/AtomCore/Instance/InstanceDatabase.h @@ -203,6 +203,16 @@ namespace AZ //! Calls FindOrCreate using a random InstanceId Data::Instance Create(const Asset& asset, const AZStd::any* param = nullptr); + /** + * Removes the instance data from the database. Does not release it. + * References to existing instances will remain valid, but new calls to Create/FindOrCreate will create a new instance + * This function is temporary, to provide functionality needed for Model hot-reloading, but will be removed + * once the Model class does not need it anymore. + * + * @param id The id of the instance to remove + */ + void TEMPOrphan(const InstanceId& id); + private: InstanceDatabase(const AssetType& assetType); ~InstanceDatabase(); @@ -356,6 +366,20 @@ namespace AZ return FindOrCreate(Data::InstanceId::CreateRandom(), asset, param); } + template + void InstanceDatabase::TEMPOrphan(const InstanceId& id) + { + AZStd::scoped_lock lock(m_databaseMutex); + // Check if the instance is still in the database, in case it was orphaned twice + auto instanceItr = m_database.find(id); + if (instanceItr != m_database.end()) + { + // Mark the instance as orphaned, and remove it from the database + instanceItr->second->m_isOrphaned = true; + m_database.erase(instanceItr); + } + } + template void InstanceDatabase::ReleaseInstance(InstanceData* instance, const InstanceId& instanceId) { @@ -374,6 +398,12 @@ namespace AZ m_database.erase(instance->GetId()); m_instanceHandler.m_deleteFunction(static_cast(instance)); } + else if (instance->m_isOrphaned && instance->m_useCount.compare_exchange_strong(expectedRefCount, -1)) + { + // If the instance was orphaned, it has already been removed from the database, + // but still needs to be deleted when the refcount drops to 0 + m_instanceHandler.m_deleteFunction(static_cast(instance)); + } } template diff --git a/Code/Framework/AtomCore/Tests/InstanceDatabase.cpp b/Code/Framework/AtomCore/Tests/InstanceDatabase.cpp index 5d1edc5a09..6a5c65ac7a 100644 --- a/Code/Framework/AtomCore/Tests/InstanceDatabase.cpp +++ b/Code/Framework/AtomCore/Tests/InstanceDatabase.cpp @@ -181,7 +181,76 @@ namespace UnitTest EXPECT_EQ(instance, instance3); } - void ParallelInstanceCreateHelper(size_t threadCountMax, size_t assetIdCount, size_t durationSeconds) + TEST_F(InstanceDatabaseTest, InstanceOrphan) + { + auto& assetManager = AssetManager::Instance(); + auto& instanceDatabase = InstanceDatabase::Instance(); + + Asset someAsset = assetManager.CreateAsset(s_assetId0, AZ::Data::AssetLoadBehavior::Default); + + Instance orphanedInstance = instanceDatabase.FindOrCreate(s_instanceId0, someAsset); + EXPECT_NE(orphanedInstance, nullptr); + + instanceDatabase.TEMPOrphan(s_instanceId0); + // After orphan, the instance should not be found in the database, but it should still be valid + EXPECT_EQ(instanceDatabase.Find(s_instanceId0), nullptr); + EXPECT_NE(orphanedInstance, nullptr); + + instanceDatabase.TEMPOrphan(s_instanceId0); + // Orphaning twice should be a no-op + EXPECT_EQ(instanceDatabase.Find(s_instanceId0), nullptr); + EXPECT_NE(orphanedInstance, nullptr); + + Instance instance2 = instanceDatabase.FindOrCreate(s_instanceId0, someAsset); + // Creating another instance with the same id should return a different instance than the one that was orphaned + EXPECT_NE(orphanedInstance, instance2); + } + + enum class ParallelInstanceTestCases + { + Create, + CreateAndDeferRemoval, + CreateAndOrphan, + CreateDeferRemovalAndOrphan + }; + + enum class ParralleInstanceCurrentAction + { + Create, + DeferredRemoval, + Orphan + }; + + ParralleInstanceCurrentAction ParallelInstanceGetCurrentAction(ParallelInstanceTestCases testCase) + { + switch (testCase) + { + case ParallelInstanceTestCases::CreateAndDeferRemoval: + switch (rand() % 2) + { + case 0: return ParralleInstanceCurrentAction::Create; + case 1: return ParralleInstanceCurrentAction::DeferredRemoval; + } + case ParallelInstanceTestCases::CreateAndOrphan: + switch (rand() % 2) + { + case 0: return ParralleInstanceCurrentAction::Create; + case 1: return ParralleInstanceCurrentAction::Orphan; + } + case ParallelInstanceTestCases::CreateDeferRemovalAndOrphan: + switch (rand() % 3) + { + case 0: return ParralleInstanceCurrentAction::Create; + case 1: return ParralleInstanceCurrentAction::DeferredRemoval; + case 2: return ParralleInstanceCurrentAction::Orphan; + } + case ParallelInstanceTestCases::Create: + default: + return ParralleInstanceCurrentAction::Create; + } + } + + void ParallelInstanceCreateHelper(size_t threadCountMax, size_t assetIdCount, float durationSeconds, ParallelInstanceTestCases testCase) { printf("Testing threads=%zu assetIds=%zu ... ", threadCountMax, assetIdCount); @@ -192,6 +261,7 @@ namespace UnitTest auto& instanceManager = InstanceDatabase::Instance(); AZStd::vector guids; + AZStd::vector> instances; AZStd::vector> assets; for (size_t i = 0; i < assetIdCount; ++i) @@ -199,6 +269,7 @@ namespace UnitTest Uuid guid = Uuid::CreateRandom(); guids.emplace_back(guid); + instances.emplace_back(nullptr); // Pre-create asset so we don't attempt to load it from the catalog. assets.emplace_back(assetManager.CreateAsset(guid, AZ::Data::AssetLoadBehavior::Default)); @@ -206,6 +277,7 @@ namespace UnitTest AZStd::vector threads; AZStd::mutex mutex; + AZStd::mutex referenceTableMutex; AZStd::atomic threadCount((int)threadCountMax); AZStd::condition_variable cv; AZStd::atomic_bool keepDispatching(true); @@ -225,11 +297,15 @@ namespace UnitTest for (size_t i = 0; i < threadCountMax; ++i) { threads.emplace_back( - [&instanceManager, &threadCount, &cv, &guids, &assets, &durationSeconds]() + [&instanceManager, &threadCount, &cv, &guids, &instances, &assets, &durationSeconds, &testCase, &referenceTableMutex]() { AZ::Debug::Timer timer; timer.Stamp(); + bool deferRemoval = testCase == ParallelInstanceTestCases::CreateAndDeferRemoval || + testCase == ParallelInstanceTestCases::CreateDeferRemovalAndOrphan + ? true : false; + while (timer.GetDeltaTimeInSeconds() < durationSeconds) { const size_t index = rand() % guids.size(); @@ -237,11 +313,36 @@ namespace UnitTest const InstanceId instanceId{ uuid }; const AssetId assetId{ uuid }; - Instance instance = - instanceManager.FindOrCreate(instanceId, Asset(assetId, azrtti_typeid())); - EXPECT_NE(instance, nullptr); - EXPECT_EQ(instance->GetId(), instanceId); - EXPECT_EQ(instance->m_asset, assets[index]); + ParralleInstanceCurrentAction currentAction = ParallelInstanceGetCurrentAction(testCase); + + if (currentAction == ParralleInstanceCurrentAction::Orphan) + { + // Orphan the instance, but don't decrease its refcount + instanceManager.TEMPOrphan(instanceId); + } + else if (currentAction == ParralleInstanceCurrentAction::DeferredRemoval) + { + // Drop the refcount to zero so the instance will be released + referenceTableMutex.lock(); + instances[index] = nullptr; + referenceTableMutex.unlock(); + } + else + { + // Otherwise, add a new instance + Instance instance = instanceManager.FindOrCreate(instanceId, assets[index]); + EXPECT_NE(instance, nullptr); + EXPECT_EQ(instance->GetId(), instanceId); + EXPECT_EQ(instance->m_asset, assets[index]); + + if (deferRemoval) + { + // Keep a reference to the instance alive so it can be removed later + referenceTableMutex.lock(); + instances[index] = instance; + referenceTableMutex.unlock(); + } + } } threadCount--; @@ -254,10 +355,12 @@ namespace UnitTest // Used to detect a deadlock. If we wait for more than 10 seconds, it's likely a deadlock has occurred while (threadCount > 0 && !timedOut) { + size_t durationSecondsRoundedUp = static_cast(std::ceil(durationSeconds)); + AZStd::unique_lock lock(mutex); timedOut = (AZStd::cv_status::timeout == - cv.wait_until(lock, AZStd::chrono::system_clock::now() + AZStd::chrono::seconds(durationSeconds * 2))); + cv.wait_until(lock, AZStd::chrono::system_clock::now() + AZStd::chrono::seconds(durationSecondsRoundedUp * 2))); } EXPECT_TRUE(threadCount == 0) << "One or more threads appear to be deadlocked at " << timer.GetDeltaTimeInSeconds() << " seconds"; @@ -273,11 +376,11 @@ namespace UnitTest printf("Took %f seconds\n", timer.GetDeltaTimeInSeconds()); } - TEST_F(InstanceDatabaseTest, ParallelInstanceCreate) + void ParallelCreateTest(ParallelInstanceTestCases testCase) { // This is the original test scenario from when InstanceDatabase was first implemented // threads, AssetIds, seconds - ParallelInstanceCreateHelper(8, 100, 5); + ParallelInstanceCreateHelper(8, 100, 5, testCase); // This value is checked in as 1 so this test doesn't take too much time, but can be increased locally to soak the test. const size_t attempts = 1; @@ -289,11 +392,11 @@ namespace UnitTest // The idea behind this series of tests is that there are two threads sharing one Instance, and both threads try to // create or release that instance at the same time. // At the time, this set of scenarios has something like a 10% failure rate. - const size_t duration = 2; + const float duration = 2.0f; // threads, AssetIds, seconds - ParallelInstanceCreateHelper(2, 1, duration); - ParallelInstanceCreateHelper(4, 1, duration); - ParallelInstanceCreateHelper(8, 1, duration); + ParallelInstanceCreateHelper(2, 1, duration, testCase); + ParallelInstanceCreateHelper(4, 1, duration, testCase); + ParallelInstanceCreateHelper(8, 1, duration, testCase); } for (size_t i = 0; i < attempts; ++i) @@ -301,19 +404,39 @@ namespace UnitTest printf("Attempt %zu of %zu... \n", i, attempts); // Here we try a bunch of different threadCount:assetCount ratios to be thorough - const size_t duration = 2; + const float duration = 2.0f; // threads, AssetIds, seconds - ParallelInstanceCreateHelper(2, 1, duration); - ParallelInstanceCreateHelper(4, 1, duration); - ParallelInstanceCreateHelper(4, 2, duration); - ParallelInstanceCreateHelper(4, 4, duration); - ParallelInstanceCreateHelper(8, 1, duration); - ParallelInstanceCreateHelper(8, 2, duration); - ParallelInstanceCreateHelper(8, 3, duration); - ParallelInstanceCreateHelper(8, 4, duration); + ParallelInstanceCreateHelper(2, 1, duration, testCase); + ParallelInstanceCreateHelper(4, 1, duration, testCase); + ParallelInstanceCreateHelper(4, 2, duration, testCase); + ParallelInstanceCreateHelper(4, 4, duration, testCase); + ParallelInstanceCreateHelper(8, 1, duration, testCase); + ParallelInstanceCreateHelper(8, 2, duration, testCase); + ParallelInstanceCreateHelper(8, 3, duration, testCase); + ParallelInstanceCreateHelper(8, 4, duration, testCase); } } + TEST_F(InstanceDatabaseTest, ParallelInstanceCreate) + { + ParallelCreateTest(ParallelInstanceTestCases::Create); + } + + TEST_F(InstanceDatabaseTest, ParallelInstanceCreateAndDeferRemoval) + { + ParallelCreateTest(ParallelInstanceTestCases::CreateAndDeferRemoval); + } + + TEST_F(InstanceDatabaseTest, ParallelInstanceCreateAndOrphan) + { + ParallelCreateTest(ParallelInstanceTestCases::CreateAndOrphan); + } + + TEST_F(InstanceDatabaseTest, ParallelInstanceCreateDeferRemovalAndOrphan) + { + ParallelCreateTest(ParallelInstanceTestCases::CreateDeferRemovalAndOrphan); + } + TEST_F(InstanceDatabaseTest, InstanceCreateNoDatabase) { bool m_deleted = false; From 0f4a9d70b523722d5c7dda2cbf63a9152bc29576 Mon Sep 17 00:00:00 2001 From: jiaweig <51759646+jiaweig-amzn@users.noreply.github.com> Date: Wed, 29 Sep 2021 15:46:35 -0700 Subject: [PATCH 14/19] Fix 3p path setting to the upper level (#4399) Signed-off-by: jiaweig --- cmake/Tools/Platform/Android/generate_android_project.py | 1 - 1 file changed, 1 deletion(-) diff --git a/cmake/Tools/Platform/Android/generate_android_project.py b/cmake/Tools/Platform/Android/generate_android_project.py index a508329d02..d8f1021590 100755 --- a/cmake/Tools/Platform/Android/generate_android_project.py +++ b/cmake/Tools/Platform/Android/generate_android_project.py @@ -368,7 +368,6 @@ def main(args): if not third_party_path.is_dir(): raise common.LmbrCmdError(f"Invalid --third-party-path '{parsed_args.third_party_path}'.", common.ERROR_CODE_INVALID_PARAMETER) - third_party_path = third_party_path.parent build_dir = parsed_args.build_dir From 816a623c97aa9abef13557ba13ac5f7db73e1ad7 Mon Sep 17 00:00:00 2001 From: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> Date: Wed, 29 Sep 2021 17:49:02 -0500 Subject: [PATCH 15/19] Added missing EntityId.h include to FocusModeInterface.h (#4396) * Added missing EntityId.h include to FocusModeInterface.h Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Non-unity build fix Adding missing BehaviorContext.h includes to Multiplayer Gem Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Added missing BehaviorContext.h include to NetworkCharacterComponent Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> --- .../AzNetworking/Framework/NetworkingSystemComponent.cpp | 1 + .../AzToolsFramework/FocusMode/FocusModeInterface.h | 1 + .../Code/Source/Components/NetworkCharacterComponent.cpp | 9 +++++---- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Code/Framework/AzNetworking/AzNetworking/Framework/NetworkingSystemComponent.cpp b/Code/Framework/AzNetworking/AzNetworking/Framework/NetworkingSystemComponent.cpp index 83588f4acb..16e4e26f67 100644 --- a/Code/Framework/AzNetworking/AzNetworking/Framework/NetworkingSystemComponent.cpp +++ b/Code/Framework/AzNetworking/AzNetworking/Framework/NetworkingSystemComponent.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include namespace AzNetworking diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/FocusMode/FocusModeInterface.h b/Code/Framework/AzToolsFramework/AzToolsFramework/FocusMode/FocusModeInterface.h index a4b90f95b7..a2b23fa8d6 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/FocusMode/FocusModeInterface.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/FocusMode/FocusModeInterface.h @@ -8,6 +8,7 @@ #pragma once +#include #include #include diff --git a/Gems/Multiplayer/Code/Source/Components/NetworkCharacterComponent.cpp b/Gems/Multiplayer/Code/Source/Components/NetworkCharacterComponent.cpp index 33eb26653a..9e15ae6ce0 100644 --- a/Gems/Multiplayer/Code/Source/Components/NetworkCharacterComponent.cpp +++ b/Gems/Multiplayer/Code/Source/Components/NetworkCharacterComponent.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -19,7 +20,7 @@ namespace Multiplayer { - + bool CollisionLayerBasedControllerFilter(const physx::PxController& controllerA, const physx::PxController& controllerB) { PHYSX_SCENE_READ_LOCK(controllerA.getActor()->getScene()); @@ -82,7 +83,7 @@ namespace Multiplayer return physx::PxQueryHitType::eNONE; } - + void NetworkCharacterComponent::Reflect(AZ::ReflectContext* context) { AZ::SerializeContext* serializeContext = azrtti_cast(context); @@ -116,7 +117,7 @@ namespace Multiplayer callbackManager->SetObjectPreFilter(CollisionLayerBasedObjectPreFilter); } } - + if (!HasController()) { GetNetworkTransformComponent()->TranslationAddEvent(m_translationEventHandler); @@ -134,7 +135,7 @@ namespace Multiplayer } void NetworkCharacterComponent::OnSyncRewind() - { + { if (m_physicsCharacter == nullptr) { return; From 090aa8f05339fe7ce2988bc882b818c194c7a34b Mon Sep 17 00:00:00 2001 From: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> Date: Wed, 29 Sep 2021 18:13:37 -0500 Subject: [PATCH 16/19] Removed ununeeded includes from EBus EBus.h and Policies.h (#4256) * Removed ununeeded includes from EBus EBus.h and Policies.h Updated the locations which needed those includes Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Adding missing include for to AWsClientAuthBus.h Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Remove the while true loop in the EBusQueuePolicy Execute() function The while true loop in Execute was for allowing additional functions to be queued in the middle of execution of current list of functions. That functionality was dangerous, because if a queued function added itself during execution unconditionally, then it would result in an infinite loop Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Updated the AssetManager::DispatchEvents function to pump the AssetBus event queue until empty Queued Events on the AssetBus is able to queue additional events on that Bus during execution of those events. Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Changed the AssetManager::DispatchEvents function to only execute the AssetBus queued events once Changed the AssetJobsFloodTest.AssetWithNoLoadReference_LoadDependencies_BehaviorObeyed test to dispatch events until the OnAssetContainerReady callback is signaled. This happens after every asset load to make sure that the expiring AssetContainer instances are removed from `AssetManager::m_ownedAssetContainer` container before retrying to load the same asset. Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Added a MaxTimeoutSeconds constant for the maximum amount of the time to run a single DispatchEvents loop Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> --- .../AzCore/AzCore/Asset/AssetManager.cpp | 8 ++ .../AzCore/AzCore/Component/Component.h | 1 + .../AzCore/AzCore/Debug/AssetTracking.h | 1 + Code/Framework/AzCore/AzCore/EBus/EBus.h | 17 ++- .../AzCore/AzCore/EBus/IEventScheduler.h | 1 + Code/Framework/AzCore/AzCore/EBus/Policies.h | 37 +++--- .../AzCore/AzCore/RTTI/BehaviorContext.h | 1 + .../Tests/Asset/AssetManagerLoadingTests.cpp | 116 ++++++++++++++---- Code/Framework/AzCore/Tests/UUIDTests.cpp | 1 + .../AzFramework/Archive/ZipDirCache.h | 1 + .../AzFramework/Logging/MissingAssetLogger.h | 1 + .../Render/GeometryIntersectionStructures.h | 1 + .../AzFramework/Windowing/NativeWindow.h | 1 + .../UdpTransport/UdpConnectionSet.h | 1 + .../Entries/AssetBrowserEntryCache.h | 1 + .../Entries/RootAssetBrowserEntry.h | 1 + .../Manipulators/BaseManipulator.h | 2 +- .../SourceControl/SourceControlAPI.h | 1 + .../AzToolsFramework/ViewportUi/ButtonGroup.h | 1 + .../unittests/AssetProcessorServerUnitTests.h | 1 + .../ProjectManager/Source/PythonBindings.cpp | 1 + .../Source/LUA/LUAEditorStyleMessages.h | 1 + .../Code/Include/Private/AWSClientAuthBus.h | 2 + .../Private/Editor/UI/AWSCoreEditorMenu.h | 1 + .../Code/Source/AssetMemoryAnalyzer.cpp | 1 + .../Include/Atom/RHI/ThreadLocalContext.h | 1 + .../Window/MaterialEditorWindowSettings.h | 1 + .../Atom/Utils/AssetCollectionAsyncLoader.h | 1 + .../Utils/StateControllers/StateController.h | 1 + .../EditorAutomation/EditorAutomationTest.h | 1 + 30 files changed, 148 insertions(+), 58 deletions(-) diff --git a/Code/Framework/AzCore/AzCore/Asset/AssetManager.cpp b/Code/Framework/AzCore/AzCore/Asset/AssetManager.cpp index 98182a9568..8eb620f69e 100644 --- a/Code/Framework/AzCore/AzCore/Asset/AssetManager.cpp +++ b/Code/Framework/AzCore/AzCore/Asset/AssetManager.cpp @@ -340,6 +340,14 @@ namespace AZ // (Load jobs will attempt to reuse blocked threads before spinning off new job threads) ProcessLoadJob(); } + + // Pump the AssetBus function queue once more after the load has completed in case additional + // functions have been queued between the last call to DispatchEvents and the completion + // of the current load job + if (m_shouldDispatchEvents) + { + AssetManager::Instance().DispatchEvents(); + } } void Finish() diff --git a/Code/Framework/AzCore/AzCore/Component/Component.h b/Code/Framework/AzCore/AzCore/Component/Component.h index 3cbb9b5a86..677517d896 100644 --- a/Code/Framework/AzCore/AzCore/Component/Component.h +++ b/Code/Framework/AzCore/AzCore/Component/Component.h @@ -22,6 +22,7 @@ #include #include // Used as the allocator for most components. #include +#include namespace AZ { diff --git a/Code/Framework/AzCore/AzCore/Debug/AssetTracking.h b/Code/Framework/AzCore/AzCore/Debug/AssetTracking.h index 5c3c835271..615634c05a 100644 --- a/Code/Framework/AzCore/AzCore/Debug/AssetTracking.h +++ b/Code/Framework/AzCore/AzCore/Debug/AssetTracking.h @@ -8,6 +8,7 @@ #pragma once +#include #include #include diff --git a/Code/Framework/AzCore/AzCore/EBus/EBus.h b/Code/Framework/AzCore/AzCore/EBus/EBus.h index 58754ff9b8..ff8966e8e0 100644 --- a/Code/Framework/AzCore/AzCore/EBus/EBus.h +++ b/Code/Framework/AzCore/AzCore/EBus/EBus.h @@ -19,14 +19,11 @@ #pragma once #include +#include #include #include - // Included for backwards compatibility purposes -#include -#include #include -// End backwards compat #include #include @@ -90,14 +87,14 @@ namespace AZ * For available settings, see AZ::EBusHandlerPolicy. * By default, an EBus supports any number of handlers. */ - static const EBusHandlerPolicy HandlerPolicy = EBusHandlerPolicy::Multiple; + static constexpr EBusHandlerPolicy HandlerPolicy = EBusHandlerPolicy::Multiple; /** * Defines how many addresses exist on the EBus. * For available settings, see AZ::EBusAddressPolicy. * By default, an EBus uses a single address. */ - static const EBusAddressPolicy AddressPolicy = EBusAddressPolicy::Single; + static constexpr EBusAddressPolicy AddressPolicy = EBusAddressPolicy::Single; /** * The type of ID that is used to address the EBus. @@ -152,14 +149,14 @@ namespace AZ * `::ExecuteQueuedEvents()`. * By default, the event queue is disabled. */ - static const bool EnableEventQueue = false; + static constexpr bool EnableEventQueue = false; /** * Specifies whether the bus should accept queued messages by default or not. * If set to false, Bus::AllowFunctionQueuing(true) must be called before events are accepted. * Used only when #EnableEventQueue is true. */ - static const bool EventQueueingActiveByDefault = true; + static constexpr bool EventQueueingActiveByDefault = true; /** * Specifies whether the EBus supports queueing functions which take reference @@ -168,7 +165,7 @@ namespace AZ * You should only use this if you know that the data being passed as arguments will * outlive the dispatch of the queued event. */ - static const bool EnableQueuedReferences = false; + static constexpr bool EnableQueuedReferences = false; /** * Locking primitive that is used when adding and removing @@ -197,7 +194,7 @@ namespace AZ * to do. * By default, the standard policy is used, which locks around all dispatches */ - static const bool LocklessDispatch = false; + static constexpr bool LocklessDispatch = false; /** * Specifies where EBus data is stored. diff --git a/Code/Framework/AzCore/AzCore/EBus/IEventScheduler.h b/Code/Framework/AzCore/AzCore/EBus/IEventScheduler.h index 5c1bbf6dab..021e8edfab 100644 --- a/Code/Framework/AzCore/AzCore/EBus/IEventScheduler.h +++ b/Code/Framework/AzCore/AzCore/EBus/IEventScheduler.h @@ -13,6 +13,7 @@ #include #include #include +#include namespace AZ { diff --git a/Code/Framework/AzCore/AzCore/EBus/Policies.h b/Code/Framework/AzCore/AzCore/EBus/Policies.h index db11043ef8..86cbe5d02f 100644 --- a/Code/Framework/AzCore/AzCore/EBus/Policies.h +++ b/Code/Framework/AzCore/AzCore/EBus/Policies.h @@ -18,9 +18,8 @@ #include #include #include +#include -#include -#include namespace AZ { @@ -251,29 +250,21 @@ namespace AZ void Execute() { AZ_Warning("System", m_isActive, "You are calling execute queued functions on a bus which has not activated its function queuing! Call YourBus::AllowFunctionQueuing(true)!"); - while (true) + + MessageQueueType localMessages; + + // Swap the current list of queue functions with a local instance { - BusMessageCall invoke; + AZStd::scoped_lock lock(m_messagesMutex); + AZStd::swap(localMessages, m_messages); + } - ////////////////////////////////////////////////////////////////////////// - // Pop element from the queue. - { - AZStd::lock_guard lock(m_messagesMutex); - size_t numMessages = m_messages.size(); - if (numMessages == 0) - { - break; - } - AZStd::swap(invoke, m_messages.front()); - m_messages.pop(); - if (numMessages == 1) - { - m_messages = {}; - } - } - ////////////////////////////////////////////////////////////////////////// - - invoke(); + // Execute the queue functions safely now that are owned by the function + while (!localMessages.empty()) + { + const BusMessageCall& localMessage = localMessages.front(); + localMessage(); + localMessages.pop(); } } diff --git a/Code/Framework/AzCore/AzCore/RTTI/BehaviorContext.h b/Code/Framework/AzCore/AzCore/RTTI/BehaviorContext.h index 0a1af21213..7f48f301aa 100644 --- a/Code/Framework/AzCore/AzCore/RTTI/BehaviorContext.h +++ b/Code/Framework/AzCore/AzCore/RTTI/BehaviorContext.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include diff --git a/Code/Framework/AzCore/Tests/Asset/AssetManagerLoadingTests.cpp b/Code/Framework/AzCore/Tests/Asset/AssetManagerLoadingTests.cpp index caa4cda8f5..3e6376323c 100644 --- a/Code/Framework/AzCore/Tests/Asset/AssetManagerLoadingTests.cpp +++ b/Code/Framework/AzCore/Tests/Asset/AssetManagerLoadingTests.cpp @@ -366,6 +366,42 @@ namespace UnitTest }; + static constexpr AZStd::chrono::seconds MaxDispatchTimeoutSeconds = BaseAssetManagerTest::DefaultTimeoutSeconds * 12; + + template + bool DispatchEventsUntilCondition(AZ::Data::AssetManager& assetManager, Pred&& conditionPredicate, + AZStd::chrono::seconds logIntervalSeconds = BaseAssetManagerTest::DefaultTimeoutSeconds, + AZStd::chrono::seconds maxTimeoutSeconds = MaxDispatchTimeoutSeconds) + { + // If the Max Timeout is hit the test will be marked as a failure + + AZStd::chrono::time_point dispatchEventTimeStart = AZStd::chrono::system_clock::now(); + AZStd::chrono::seconds dispatchEventNextLogTime = logIntervalSeconds; + + while (!conditionPredicate()) + { + AZStd::chrono::time_point currentTime = AZStd::chrono::system_clock::now(); + if (AZStd::chrono::seconds elapsedTime{ currentTime - dispatchEventTimeStart }; + elapsedTime >= dispatchEventNextLogTime) + { + const testing::TestInfo* test_info = ::testing::UnitTest::GetInstance()->current_test_info(); + AZ_Printf("AssetManagerLoadingTest", "The DispatchEventsUntiTimeout function has been waiting for %llu seconds" + " in test %s.%s", elapsedTime.count(), test_info->test_case_name(), test_info->name()); + // Update the next log time to be the next multiple of DefaultTimeout Seconds + // after current elapsed time + dispatchEventNextLogTime = elapsedTime + logIntervalSeconds - ((elapsedTime + logIntervalSeconds) % logIntervalSeconds); + if (elapsedTime >= maxTimeoutSeconds) + { + return false; + } + } + assetManager.DispatchEvents(); + AZStd::this_thread::yield(); + } + + return true; + } + #if AZ_TRAIT_DISABLE_FAILED_ASSET_MANAGER_TESTS || AZ_TRAIT_DISABLE_ASSET_MANAGER_FLOOD_TEST TEST_F(AssetJobsFloodTest, DISABLED_FloodTest) #else @@ -1358,42 +1394,74 @@ namespace UnitTest m_assetHandlerAndCatalog->m_numCreations = 0; m_assetHandlerAndCatalog->m_numDestructions = 0; { + ContainerReadyListener containerLoadingCompleteListener(NoLoadAssetId); OnAssetReadyListener readyListener(NoLoadAssetId, azrtti_typeid()); - OnAssetReadyListener depenencyListener(MyAsset2Id, azrtti_typeid()); + OnAssetReadyListener dependencyListener(MyAsset2Id, azrtti_typeid()); + + SCOPED_TRACE("LoadDependencies_BehaviorObeyed"); + + auto AssetOnlyReady = [&readyListener]() -> bool + { + return readyListener.m_ready; + }; + auto AssetAndDependencyReady = [&readyListener, &dependencyListener]() -> bool + { + return readyListener.m_ready && dependencyListener.m_ready; + }; + auto AssetContainerReady = [&containerLoadingCompleteListener]() -> bool + { + return containerLoadingCompleteListener.m_ready; + }; auto noLoadRef = m_testAssetManager->GetAsset(NoLoadAssetId, azrtti_typeid(), AZ::Data::AssetLoadBehavior::Default); - auto maxTimeout = AZStd::chrono::system_clock::now() + DefaultTimeoutSeconds; + // Dispatch AssetBus events until the NoLoadAssetId has signaled an OnAssetReady + // event or the timeout has been reached + EXPECT_TRUE(DispatchEventsUntilCondition(*m_testAssetManager, AssetOnlyReady)) + << "The DispatchEventsUntiTimeout function has not completed in " + << MaxDispatchTimeoutSeconds.count() << " seconds. The test will be marked as a failure\n"; + + // Dispatch AssetBus events until the asset container used to load + // NoLoadAssetId has signaled an OnAssetContainerReady event + // or the timeout has been reached + // Wait until the current asset container has finished loading the NoLoadAssetId + // before trigger another load + // If the wait does not occur here, most likely what would occur is + // the AssetManager::m_ownedAssetContainers object is still loading the NoLoadAssetId + // using the default AssetLoadParameters + // If a call to GetAsset occurs at this point while the Asset is still loading + // it will ignore the new loadParams below and instead just re-use the existing + // AssetContainerReader instance, resulting in the dependent MyAsset2Id not + // being loaded + // The function that can return an existing AssetContainer instance is the + // AssetManager::GetAssetContainer. Since it can be in the middle of a load, + // updating the AssetLoadParams would have an effect on the current in progress + // load + EXPECT_TRUE(DispatchEventsUntilCondition(*m_testAssetManager, AssetContainerReady)) + << "The DispatchEventsUntiTimeout function has not completed in " + << MaxDispatchTimeoutSeconds.count() << " seconds. The test will be marked as a failure\n"; + + // Reset the ContainerLoadingComplete ready status back to 0 + containerLoadingCompleteListener.m_ready = 0; - while (!readyListener.m_ready) - { - m_testAssetManager->DispatchEvents(); - if (AZStd::chrono::system_clock::now() > maxTimeout) - { - break; - } - AZStd::this_thread::yield(); - } - EXPECT_EQ(readyListener.m_ready, 1); - EXPECT_EQ(depenencyListener.m_ready, 0); - AZ::Data::AssetLoadParameters loadParams(nullptr, AZ::Data::AssetDependencyLoadRules::LoadAll); loadParams.m_reloadMissingDependencies = true; auto loadDependencyRef = m_testAssetManager->GetAsset(NoLoadAssetId, azrtti_typeid(), AZ::Data::AssetLoadBehavior::Default, loadParams); - while (!depenencyListener.m_ready || !readyListener.m_ready) - { - m_testAssetManager->DispatchEvents(); - if (AZStd::chrono::system_clock::now() > maxTimeout) - { - break; - } - AZStd::this_thread::yield(); - } + // Dispatch AssetBus events until the NoLoadAssetId and the MyAsset2Id has signaled + // an OnAssetReady event or the timeout has been reached + EXPECT_TRUE(DispatchEventsUntilCondition(*m_testAssetManager, AssetAndDependencyReady)) + << "The DispatchEventsUntiTimeout function has not completed in " + << MaxDispatchTimeoutSeconds.count() << " seconds. The test will be marked as a failure\n"; + EXPECT_EQ(readyListener.m_ready, 1); - EXPECT_EQ(depenencyListener.m_ready, 1); + EXPECT_EQ(dependencyListener.m_ready, 1); + + EXPECT_TRUE(DispatchEventsUntilCondition(*m_testAssetManager, AssetContainerReady)) + << "The DispatchEventsUntiTimeout function has not completed in " + << MaxDispatchTimeoutSeconds.count() << " seconds. The test will be marked as a failure\n"; } CheckFinishedCreationsAndDestructions(); diff --git a/Code/Framework/AzCore/Tests/UUIDTests.cpp b/Code/Framework/AzCore/Tests/UUIDTests.cpp index 5d4fb7a711..a18dc33c4f 100644 --- a/Code/Framework/AzCore/Tests/UUIDTests.cpp +++ b/Code/Framework/AzCore/Tests/UUIDTests.cpp @@ -7,6 +7,7 @@ */ #include #include +#include using namespace AZ; diff --git a/Code/Framework/AzFramework/AzFramework/Archive/ZipDirCache.h b/Code/Framework/AzFramework/AzFramework/Archive/ZipDirCache.h index 646410f8db..ae1e3dfa9c 100644 --- a/Code/Framework/AzFramework/AzFramework/Archive/ZipDirCache.h +++ b/Code/Framework/AzFramework/AzFramework/Archive/ZipDirCache.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include diff --git a/Code/Framework/AzFramework/AzFramework/Logging/MissingAssetLogger.h b/Code/Framework/AzFramework/AzFramework/Logging/MissingAssetLogger.h index 9434ca80ae..b49609d820 100644 --- a/Code/Framework/AzFramework/AzFramework/Logging/MissingAssetLogger.h +++ b/Code/Framework/AzFramework/AzFramework/Logging/MissingAssetLogger.h @@ -8,6 +8,7 @@ #pragma once +#include #include namespace AzFramework { class LogFile; } diff --git a/Code/Framework/AzFramework/AzFramework/Render/GeometryIntersectionStructures.h b/Code/Framework/AzFramework/AzFramework/Render/GeometryIntersectionStructures.h index 11c3fedb2b..9d6cd48102 100644 --- a/Code/Framework/AzFramework/AzFramework/Render/GeometryIntersectionStructures.h +++ b/Code/Framework/AzFramework/AzFramework/Render/GeometryIntersectionStructures.h @@ -11,6 +11,7 @@ #include #include #include +#include #include //! Common structures for Render geometry queries diff --git a/Code/Framework/AzFramework/AzFramework/Windowing/NativeWindow.h b/Code/Framework/AzFramework/AzFramework/Windowing/NativeWindow.h index 7479b0d1e1..0eb699475f 100644 --- a/Code/Framework/AzFramework/AzFramework/Windowing/NativeWindow.h +++ b/Code/Framework/AzFramework/AzFramework/Windowing/NativeWindow.h @@ -9,6 +9,7 @@ #pragma once #include +#include #include diff --git a/Code/Framework/AzNetworking/AzNetworking/UdpTransport/UdpConnectionSet.h b/Code/Framework/AzNetworking/AzNetworking/UdpTransport/UdpConnectionSet.h index 8594bf87db..7fa66b0470 100644 --- a/Code/Framework/AzNetworking/AzNetworking/UdpTransport/UdpConnectionSet.h +++ b/Code/Framework/AzNetworking/AzNetworking/UdpTransport/UdpConnectionSet.h @@ -11,6 +11,7 @@ #include #include #include +#include namespace AzNetworking { diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/AssetBrowserEntryCache.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/AssetBrowserEntryCache.h index e2929c0d3e..7b94108a91 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/AssetBrowserEntryCache.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/AssetBrowserEntryCache.h @@ -9,6 +9,7 @@ #pragma once #include +#include #include #include diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/RootAssetBrowserEntry.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/RootAssetBrowserEntry.h index d765d4e1e5..685770dd20 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/RootAssetBrowserEntry.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/RootAssetBrowserEntry.h @@ -7,6 +7,7 @@ */ #pragma once +#include #include #include #include diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/BaseManipulator.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/BaseManipulator.h index a2b004763b..06e9c82e55 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/BaseManipulator.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/BaseManipulator.h @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/SourceControl/SourceControlAPI.h b/Code/Framework/AzToolsFramework/AzToolsFramework/SourceControl/SourceControlAPI.h index df9b136752..5eb4a31ffb 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/SourceControl/SourceControlAPI.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/SourceControl/SourceControlAPI.h @@ -10,6 +10,7 @@ #include #include +#include #include namespace AzToolsFramework diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportUi/ButtonGroup.h b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportUi/ButtonGroup.h index 0500a80c36..888be6b3e0 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportUi/ButtonGroup.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ViewportUi/ButtonGroup.h @@ -8,6 +8,7 @@ #pragma once +#include #include namespace AzToolsFramework::ViewportUi::Internal diff --git a/Code/Tools/AssetProcessor/native/unittests/AssetProcessorServerUnitTests.h b/Code/Tools/AssetProcessor/native/unittests/AssetProcessorServerUnitTests.h index 209897fd6e..8358bc3d2e 100644 --- a/Code/Tools/AssetProcessor/native/unittests/AssetProcessorServerUnitTests.h +++ b/Code/Tools/AssetProcessor/native/unittests/AssetProcessorServerUnitTests.h @@ -11,6 +11,7 @@ #if !defined(Q_MOC_RUN) #include "UnitTestRunner.h" #include "native/utilities/IniConfiguration.h" +#include #include #endif diff --git a/Code/Tools/ProjectManager/Source/PythonBindings.cpp b/Code/Tools/ProjectManager/Source/PythonBindings.cpp index 9ae3cc2c87..b9369b5bb0 100644 --- a/Code/Tools/ProjectManager/Source/PythonBindings.cpp +++ b/Code/Tools/ProjectManager/Source/PythonBindings.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #include diff --git a/Code/Tools/Standalone/Source/LUA/LUAEditorStyleMessages.h b/Code/Tools/Standalone/Source/LUA/LUAEditorStyleMessages.h index 6ddc462e94..cf27245682 100644 --- a/Code/Tools/Standalone/Source/LUA/LUAEditorStyleMessages.h +++ b/Code/Tools/Standalone/Source/LUA/LUAEditorStyleMessages.h @@ -8,6 +8,7 @@ #include #include +#include #include #include #include diff --git a/Gems/AWSClientAuth/Code/Include/Private/AWSClientAuthBus.h b/Gems/AWSClientAuth/Code/Include/Private/AWSClientAuthBus.h index 4e625a563c..63d5bb2a83 100644 --- a/Gems/AWSClientAuth/Code/Include/Private/AWSClientAuthBus.h +++ b/Gems/AWSClientAuth/Code/Include/Private/AWSClientAuthBus.h @@ -9,6 +9,8 @@ #include +#include + namespace Aws { namespace CognitoIdentityProvider diff --git a/Gems/AWSCore/Code/Include/Private/Editor/UI/AWSCoreEditorMenu.h b/Gems/AWSCore/Code/Include/Private/Editor/UI/AWSCoreEditorMenu.h index f0b9b45aff..39e96517a7 100644 --- a/Gems/AWSCore/Code/Include/Private/Editor/UI/AWSCoreEditorMenu.h +++ b/Gems/AWSCore/Code/Include/Private/Editor/UI/AWSCoreEditorMenu.h @@ -9,6 +9,7 @@ #include #include +#include #include diff --git a/Gems/AssetMemoryAnalyzer/Code/Source/AssetMemoryAnalyzer.cpp b/Gems/AssetMemoryAnalyzer/Code/Source/AssetMemoryAnalyzer.cpp index f111b972e4..798da14aa1 100644 --- a/Gems/AssetMemoryAnalyzer/Code/Source/AssetMemoryAnalyzer.cpp +++ b/Gems/AssetMemoryAnalyzer/Code/Source/AssetMemoryAnalyzer.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include /////////////////////////////////////////////////////////////////////////////// diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI/ThreadLocalContext.h b/Gems/Atom/RHI/Code/Include/Atom/RHI/ThreadLocalContext.h index dbea45c54a..4d3534b845 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI/ThreadLocalContext.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI/ThreadLocalContext.h @@ -11,6 +11,7 @@ #include #include +#include namespace AZ { diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Include/Atom/Window/MaterialEditorWindowSettings.h b/Gems/Atom/Tools/MaterialEditor/Code/Include/Atom/Window/MaterialEditorWindowSettings.h index dd42f79106..c56da58ff1 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Include/Atom/Window/MaterialEditorWindowSettings.h +++ b/Gems/Atom/Tools/MaterialEditor/Code/Include/Atom/Window/MaterialEditorWindowSettings.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #endif diff --git a/Gems/Atom/Utils/Code/Include/Atom/Utils/AssetCollectionAsyncLoader.h b/Gems/Atom/Utils/Code/Include/Atom/Utils/AssetCollectionAsyncLoader.h index 2d05a68771..d1027daa36 100644 --- a/Gems/Atom/Utils/Code/Include/Atom/Utils/AssetCollectionAsyncLoader.h +++ b/Gems/Atom/Utils/Code/Include/Atom/Utils/AssetCollectionAsyncLoader.h @@ -7,6 +7,7 @@ */ #pragma once +#include #include #include #include diff --git a/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Utils/StateControllers/StateController.h b/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Utils/StateControllers/StateController.h index 053ed98978..54dccb8ae0 100644 --- a/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Utils/StateControllers/StateController.h +++ b/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Utils/StateControllers/StateController.h @@ -8,6 +8,7 @@ #pragma once #include +#include // A configurable queue that allows for multiple sources to try to control a single value in a configurable way // such that each object can control the object independently of the other systems, while still maintaining a reasonable state. diff --git a/Gems/ScriptCanvasDeveloper/Code/Editor/Include/ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationTest.h b/Gems/ScriptCanvasDeveloper/Code/Editor/Include/ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationTest.h index 4a3ba89832..1e4fb27831 100644 --- a/Gems/ScriptCanvasDeveloper/Code/Editor/Include/ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationTest.h +++ b/Gems/ScriptCanvasDeveloper/Code/Editor/Include/ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationTest.h @@ -11,6 +11,7 @@ #include #include +#include #include #include From 19bd934a43b5d7988c86d48cf16f3399943903ca Mon Sep 17 00:00:00 2001 From: Steve Pham Date: Wed, 29 Sep 2021 17:56:06 -0700 Subject: [PATCH 17/19] Fix missing include for AZStd::unordered_set in AssetEditorBus.h Signed-off-by: Steve Pham --- .../AzToolsFramework/AssetEditor/AssetEditorBus.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetEditor/AssetEditorBus.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetEditor/AssetEditorBus.h index becdba44ea..9b12ea27d4 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetEditor/AssetEditorBus.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetEditor/AssetEditorBus.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include namespace AZ::Data { From acea5b7da857a06c4da1cf592b120149fa18511f Mon Sep 17 00:00:00 2001 From: Benjamin Jillich <43751992+amzn-jillich@users.noreply.github.com> Date: Thu, 30 Sep 2021 09:12:41 +0200 Subject: [PATCH 18/19] Animation Editor: Creating Motion Sets does not increment them correctly (#4368) Signed-off-by: Benjamin Jillich --- Gems/EMotionFX/Code/EMotionFX/Source/MotionSet.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/MotionSet.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/MotionSet.cpp index d8880f6fcc..56f7ee567e 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/MotionSet.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/MotionSet.cpp @@ -726,10 +726,12 @@ namespace EMotionFX { MCore::LockGuardRecursive lock(m_mutex); - return AZStd::accumulate(begin(m_childSets), end(m_childSets), size_t{0}, [](size_t total, const MotionSet* motionSet) + size_t result = 0; + for (const MotionSet* motionSet : m_childSets) { - return total + motionSet->GetIsOwnedByRuntime(); - }); + result += !motionSet->GetIsOwnedByRuntime(); + } + return result; } From ab0aa4973f2ec40f1a02ad1476521e55f95d8091 Mon Sep 17 00:00:00 2001 From: hultonha <82228511+hultonha@users.noreply.github.com> Date: Thu, 30 Sep 2021 08:43:48 +0100 Subject: [PATCH 19/19] Remove camera LookAtAfterInterpolation (#4391) Signed-off-by: hultonha --- .../EditorModularViewportCameraComposer.cpp | 18 +++------------- Code/Editor/EditorViewportCamera.cpp | 2 +- .../Lib/Tests/Camera/test_EditorCamera.cpp | 4 ++-- .../SandboxIntegration.cpp | 3 +-- .../ModularViewportCameraController.h | 8 +++---- ...odularViewportCameraControllerRequestBus.h | 6 +----- .../ModularViewportCameraController.cpp | 21 +------------------ 7 files changed, 12 insertions(+), 50 deletions(-) diff --git a/Code/Editor/EditorModularViewportCameraComposer.cpp b/Code/Editor/EditorModularViewportCameraComposer.cpp index 600f2089e6..29cf348ab5 100644 --- a/Code/Editor/EditorModularViewportCameraComposer.cpp +++ b/Code/Editor/EditorModularViewportCameraComposer.cpp @@ -175,27 +175,15 @@ namespace SandboxEditor m_pivotCamera = AZStd::make_shared(SandboxEditor::CameraPivotChannelId()); m_pivotCamera->SetPivotFn( - [viewportId = m_viewportId]([[maybe_unused]] const AZ::Vector3& position, [[maybe_unused]] const AZ::Vector3& direction) + []([[maybe_unused]] const AZ::Vector3& position, [[maybe_unused]] const AZ::Vector3& direction) { - AZStd::optional lookAtAfterInterpolation; - AtomToolsFramework::ModularViewportCameraControllerRequestBus::EventResult( - lookAtAfterInterpolation, viewportId, - &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::LookAtAfterInterpolation); - - // initially attempt to use the last set look at point after an interpolation has finished - // note: ignore this if it is the same location as the camera (e.g. after go to position) - if (lookAtAfterInterpolation.has_value() && !lookAtAfterInterpolation->IsClose(position)) - { - return *lookAtAfterInterpolation; - } - - // otherwise fall back to the selected entity pivot + // use the manipulator transform as the pivot point AZStd::optional entityPivot; AzToolsFramework::EditorTransformComponentSelectionRequestBus::EventResult( entityPivot, AzToolsFramework::GetEntityContextId(), &AzToolsFramework::EditorTransformComponentSelectionRequestBus::Events::GetManipulatorTransform); - // finally just use the identity + // otherwise just use the identity return entityPivot.value_or(AZ::Transform::CreateIdentity()).GetTranslation(); }); diff --git a/Code/Editor/EditorViewportCamera.cpp b/Code/Editor/EditorViewportCamera.cpp index 0c7a1559d1..b25e7072ff 100644 --- a/Code/Editor/EditorViewportCamera.cpp +++ b/Code/Editor/EditorViewportCamera.cpp @@ -48,7 +48,7 @@ namespace SandboxEditor { AtomToolsFramework::ModularViewportCameraControllerRequestBus::Event( viewportContext->GetId(), &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::InterpolateToTransform, - AZ::Transform::CreateFromQuaternionAndTranslation(CameraRotation(pitch, yaw), position), 0.0f); + AZ::Transform::CreateFromQuaternionAndTranslation(CameraRotation(pitch, yaw), position)); } } diff --git a/Code/Editor/Lib/Tests/Camera/test_EditorCamera.cpp b/Code/Editor/Lib/Tests/Camera/test_EditorCamera.cpp index affe5794cc..1a44d43370 100644 --- a/Code/Editor/Lib/Tests/Camera/test_EditorCamera.cpp +++ b/Code/Editor/Lib/Tests/Camera/test_EditorCamera.cpp @@ -167,7 +167,7 @@ namespace UnitTest AZ::Quaternion::CreateRotationZ(AZ::DegToRad(90.0f)), AZ::Vector3(20.0f, 40.0f, 60.0f)); AtomToolsFramework::ModularViewportCameraControllerRequestBus::Event( TestViewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::InterpolateToTransform, - transformToInterpolateTo, 0.0f); + transformToInterpolateTo); // simulate interpolation m_controllerList->UpdateViewport({ TestViewportId, AzFramework::FloatSeconds(0.5f), AZ::ScriptTimePoint() }); @@ -193,7 +193,7 @@ namespace UnitTest // When AtomToolsFramework::ModularViewportCameraControllerRequestBus::Event( TestViewportId, &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::InterpolateToTransform, - transformToInterpolateTo, 0.0f); + transformToInterpolateTo); // simulate interpolation m_controllerList->UpdateViewport({ TestViewportId, AzFramework::FloatSeconds(0.5f), AZ::ScriptTimePoint() }); diff --git a/Code/Editor/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp b/Code/Editor/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp index 47bd214b8d..666700a874 100644 --- a/Code/Editor/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp +++ b/Code/Editor/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp @@ -1739,8 +1739,7 @@ void SandboxIntegrationManager::GoToEntitiesInViewports(const AzToolsFramework:: AtomToolsFramework::ModularViewportCameraControllerRequestBus::Event( viewportContext->GetId(), - &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::InterpolateToTransform, nextCameraTransform, - distanceToLookAt); + &AtomToolsFramework::ModularViewportCameraControllerRequestBus::Events::InterpolateToTransform, nextCameraTransform); } } } diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/ModularViewportCameraController.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/ModularViewportCameraController.h index 32897ab4d9..1200cb3d79 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/ModularViewportCameraController.h +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/ModularViewportCameraController.h @@ -112,8 +112,7 @@ namespace AtomToolsFramework void UpdateViewport(const AzFramework::ViewportControllerUpdateEvent& event) override; // ModularViewportCameraControllerRequestBus overrides ... - void InterpolateToTransform(const AZ::Transform& worldFromLocal, float lookAtDistance) override; - AZStd::optional LookAtAfterInterpolation() const override; + void InterpolateToTransform(const AZ::Transform& worldFromLocal) override; AZ::Transform GetReferenceFrame() const override; void SetReferenceFrame(const AZ::Transform& worldFromLocal) override; void ClearReferenceFrame() override; @@ -149,9 +148,8 @@ namespace AtomToolsFramework CameraAnimation m_cameraAnimation; //!< Camera animation state (used during CameraMode::Animation). CameraMode m_cameraMode = CameraMode::Control; //!< The current mode the camera is operating in. - AZStd::optional m_lookAtAfterInterpolation; //!< The look at point after an interpolation has finished. - //!< Will be cleared when the view changes (camera looks away). - AZ::Transform m_referenceFrameOverride = AZ::Transform::CreateIdentity(); //!< + //! An additional reference frame the camera can operate in (identity has no effect). + AZ::Transform m_referenceFrameOverride = AZ::Transform::CreateIdentity(); //! Flag to prevent circular updates of the camera transform (while the viewport transform is being updated internally). bool m_updatingTransformInternally = false; //! Listen for camera view changes outside of the camera controller. diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/ModularViewportCameraControllerRequestBus.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/ModularViewportCameraControllerRequestBus.h index 388d24164a..ab397692e4 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/ModularViewportCameraControllerRequestBus.h +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/ModularViewportCameraControllerRequestBus.h @@ -29,11 +29,7 @@ namespace AtomToolsFramework //! Begin a smooth transition of the camera to the requested transform. //! @param worldFromLocal The transform of where the camera should end up. - //! @param lookAtDistance The distance between the camera transform and the imagined look at point. - virtual void InterpolateToTransform(const AZ::Transform& worldFromLocal, float lookAtDistance) = 0; - - //! Look at point after an interpolation has finished and no translation has occurred. - virtual AZStd::optional LookAtAfterInterpolation() const = 0; + virtual void InterpolateToTransform(const AZ::Transform& worldFromLocal) = 0; //! Return the current reference frame. //! @note If a reference frame has not been set or a frame has been cleared, this is just the identity. diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/ModularViewportCameraController.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/ModularViewportCameraController.cpp index 0bdd6fb55c..a92bfdbcdb 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/ModularViewportCameraController.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/ModularViewportCameraController.cpp @@ -227,19 +227,6 @@ namespace AtomToolsFramework { m_targetCamera = m_cameraSystem.StepCamera(m_targetCamera, event.m_deltaTime.count()); m_camera = AzFramework::SmoothCamera(m_camera, m_targetCamera, m_cameraProps, event.m_deltaTime.count()); - - // if there has been an interpolation, only clear the look at point if it is no longer - // centered in the view (the camera has looked away from it) - if (m_lookAtAfterInterpolation.has_value()) - { - if (const float lookDirection = - (*m_lookAtAfterInterpolation - m_camera.Translation()).GetNormalized().Dot(m_camera.Transform().GetBasisY()); - !AZ::IsCloseMag(lookDirection, 1.0f, 0.001f)) - { - m_lookAtAfterInterpolation = {}; - } - } - m_modularCameraViewportContext->SetCameraTransform(m_referenceFrameOverride * m_camera.Transform()); } else if (m_cameraMode == CameraMode::Animation) @@ -277,16 +264,10 @@ namespace AtomToolsFramework m_updatingTransformInternally = false; } - void ModularViewportCameraControllerInstance::InterpolateToTransform(const AZ::Transform& worldFromLocal, const float lookAtDistance) + void ModularViewportCameraControllerInstance::InterpolateToTransform(const AZ::Transform& worldFromLocal) { m_cameraMode = CameraMode::Animation; m_cameraAnimation = CameraAnimation{ m_referenceFrameOverride * m_camera.Transform(), worldFromLocal, 0.0f }; - m_lookAtAfterInterpolation = worldFromLocal.GetTranslation() + worldFromLocal.GetBasisY() * lookAtDistance; - } - - AZStd::optional ModularViewportCameraControllerInstance::LookAtAfterInterpolation() const - { - return m_lookAtAfterInterpolation; } AZ::Transform ModularViewportCameraControllerInstance::GetReferenceFrame() const