diff --git a/.gitignore b/.gitignore index b73c89b1d9..c28f6ab123 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ __pycache__ AssetProcessorTemp/** [Bb]uild/** [Oo]ut/** +CMakeUserPresets.json [Cc]ache/ /install/ Editor/EditorEventLog.xml diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_GPUTests.py b/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_GPUTests.py index 7be1ed1b12..047f46a40f 100644 --- a/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_GPUTests.py +++ b/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_GPUTests.py @@ -181,3 +181,39 @@ class TestPerformanceBenchmarkSuite(object): aggregator = BenchmarkDataAggregator(workspace, logger, 'periodic') aggregator.upload_metrics(rhi) + + +@pytest.mark.parametrize("project", ["AutomatedTesting"]) +@pytest.mark.parametrize("launcher_platform", ['windows_generic']) +@pytest.mark.system +class TestMaterialEditor(object): + + @pytest.mark.parametrize("cfg_args", ["-rhi=dx12", "-rhi=Vulkan"]) + @pytest.mark.parametrize("exe_file_name", ["MaterialEditor"]) + def test_MaterialEditorLaunch_AllRHIOptionsSucceed( + self, request, workspace, project, launcher_platform, generic_launcher, exe_file_name, cfg_args): + """ + Tests each valid RHI option (Null RHI excluded) can be launched with the MaterialEditor. + Checks for the "Finished loading viewport configurtions." success message post lounch. + """ + expected_lines = ["Finished loading viewport configurtions."] + unexpected_lines = [ + # "Trace::Assert", + # "Trace::Error", + "Traceback (most recent call last):", + ] + + hydra.launch_and_validate_results( + request, + TEST_DIRECTORY, + generic_launcher, + editor_script="", + run_python="--runpython", + timeout=30, + expected_lines=expected_lines, + unexpected_lines=unexpected_lines, + halt_on_unexpected=False, + null_renderer=False, + cfg_args=[cfg_args], + log_file_name="MaterialEditor.log" + ) diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_MainSuite.py b/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_MainSuite.py index 55c049b929..bb7a16ad6b 100644 --- a/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_MainSuite.py +++ b/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_MainSuite.py @@ -303,5 +303,6 @@ class TestMaterialEditorBasicTests(object): expected_lines=expected_lines, unexpected_lines=unexpected_lines, halt_on_unexpected=True, + null_renderer=True, log_file_name="MaterialEditor.log", ) diff --git a/Code/Editor/AnimationContext.cpp b/Code/Editor/AnimationContext.cpp index 6e146faacb..fce1150878 100644 --- a/Code/Editor/AnimationContext.cpp +++ b/Code/Editor/AnimationContext.cpp @@ -628,7 +628,7 @@ void CAnimationContext::GoToFrameCmd(IConsoleCmdArgs* pArgs) float targetFrame = (float)atof(pArgs->GetArg(1)); if (pSeq->GetTimeRange().start > targetFrame || targetFrame > pSeq->GetTimeRange().end) { - gEnv->pLog->LogError("GoToFrame: requested time %f is outside the range of sequence %s (%f, %f)", targetFrame, pSeq->GetName(), pSeq->GetTimeRange().start, pSeq->GetTimeRange().end); + gEnv->pLog->LogError("GoToFrame: requested time %f is outside the range of sequence %s (%f, %f)", targetFrame, pSeq->GetName().c_str(), pSeq->GetTimeRange().start, pSeq->GetTimeRange().end); return; } GetIEditor()->GetAnimation()->m_currTime = targetFrame; diff --git a/Code/Editor/AzAssetBrowser/AzAssetBrowserRequestHandler.cpp b/Code/Editor/AzAssetBrowser/AzAssetBrowserRequestHandler.cpp index b164323238..1c2be16a3d 100644 --- a/Code/Editor/AzAssetBrowser/AzAssetBrowserRequestHandler.cpp +++ b/Code/Editor/AzAssetBrowser/AzAssetBrowserRequestHandler.cpp @@ -327,7 +327,7 @@ void AzAssetBrowserRequestHandler::AddContextMenuActions(QWidget* caller, QMenu* if (!vetoOpenerFound) { // if we found no valid openers and no veto openers then just allow it to be opened with the operating system itself. - menu->addAction(QObject::tr("Open with associated application..."), [this, fullFilePath]() + menu->addAction(QObject::tr("Open with associated application..."), [fullFilePath]() { OpenWithOS(fullFilePath); }); diff --git a/Code/Editor/Controls/ColorGradientCtrl.h b/Code/Editor/Controls/ColorGradientCtrl.h index 80d8b966f4..a3f95fcd8c 100644 --- a/Code/Editor/Controls/ColorGradientCtrl.h +++ b/Code/Editor/Controls/ColorGradientCtrl.h @@ -130,7 +130,6 @@ private: private: ISplineInterpolator* m_pSpline; - bool m_bAutoDelete; bool m_bNoZoom; QRect m_rcClipRect; diff --git a/Code/Editor/Controls/ConsoleSCB.cpp b/Code/Editor/Controls/ConsoleSCB.cpp index dbe7ba3472..aed148976f 100644 --- a/Code/Editor/Controls/ConsoleSCB.cpp +++ b/Code/Editor/Controls/ConsoleSCB.cpp @@ -298,7 +298,6 @@ Lines CConsoleSCB::s_pendingLines; CConsoleSCB::CConsoleSCB(QWidget* parent) : QWidget(parent) , ui(new Ui::Console()) - , m_richEditTextLength(0) , m_backgroundTheme(gSettings.consoleBackgroundColorTheme) { m_lines = s_pendingLines; diff --git a/Code/Editor/Controls/ConsoleSCB.h b/Code/Editor/Controls/ConsoleSCB.h index f51786e2a5..051f3ea4e7 100644 --- a/Code/Editor/Controls/ConsoleSCB.h +++ b/Code/Editor/Controls/ConsoleSCB.h @@ -191,7 +191,6 @@ private: void OnEditorNotifyEvent(EEditorNotifyEvent event) override; QScopedPointer ui; - int m_richEditTextLength; Lines m_lines; static Lines s_pendingLines; diff --git a/Code/Editor/Controls/ImageHistogramCtrl.cpp b/Code/Editor/Controls/ImageHistogramCtrl.cpp index 252bf4f09b..48bc7a70d2 100644 --- a/Code/Editor/Controls/ImageHistogramCtrl.cpp +++ b/Code/Editor/Controls/ImageHistogramCtrl.cpp @@ -30,12 +30,6 @@ namespace ImageHistogram const QColor kGreenSectionColor = QColor(220, 255, 220); const QColor kBlueSectionColor = QColor(220, 220, 255); const QColor kSplitSeparatorColor = QColor(100, 100, 0); - const QColor kButtonBackColor = QColor(20, 20, 20); - const QColor kBtnLightColor(200, 200, 200); - const QColor kBtnShadowColor(50, 50, 50); - const int kButtonWidth = 40; - const QColor kButtonTextColor(255, 255, 0); - const int kTextLeftSpacing = 4; const int kTextFontSize = 70; const char* kTextFontFace = "Arial"; const QColor kTextColor(255, 255, 255); diff --git a/Code/Editor/Controls/SplineCtrl.cpp b/Code/Editor/Controls/SplineCtrl.cpp index 80d30b37ad..8ccf103c25 100644 --- a/Code/Editor/Controls/SplineCtrl.cpp +++ b/Code/Editor/Controls/SplineCtrl.cpp @@ -123,8 +123,6 @@ void CSplineCtrl::paintEvent(QPaintEvent* event) { QPainter painter(this); - QRect rcClient = rect(); - if (m_pSpline) { m_bSelectedKeys.resize(m_pSpline->GetKeyCount()); diff --git a/Code/Editor/Controls/SplineCtrlEx.cpp b/Code/Editor/Controls/SplineCtrlEx.cpp index f299ce185d..9e0a954c79 100644 --- a/Code/Editor/Controls/SplineCtrlEx.cpp +++ b/Code/Editor/Controls/SplineCtrlEx.cpp @@ -819,8 +819,6 @@ void SplineWidget::DrawSpline(QPainter* painter, SSplineInfo& splineInfo, float { const QPen pOldPen = painter->pen(); - const QRect rcClip = painter->clipBoundingRect().intersected(m_rcSpline).toRect(); - ////////////////////////////////////////////////////////////////////////// ISplineInterpolator* pSpline = splineInfo.pSpline; ISplineInterpolator* pDetailSpline = splineInfo.pDetailSpline; diff --git a/Code/Editor/Controls/TimelineCtrl.cpp b/Code/Editor/Controls/TimelineCtrl.cpp index 8159084784..aa30c326ac 100644 --- a/Code/Editor/Controls/TimelineCtrl.cpp +++ b/Code/Editor/Controls/TimelineCtrl.cpp @@ -18,11 +18,6 @@ #include "ScopedVariableSetter.h" #include "GridUtils.h" - -static const QColor timeMarkerCol = QColor(255, 0, 255); -static const QColor textCol = QColor(0, 0, 0); -static const QColor ltgrayCol = QColor(110, 110, 110); - QColor InterpolateColor(const QColor& c1, const QColor& c2, float fraction) { const int r = static_cast(static_cast(c2.red() - c1.red()) * fraction + c1.red()); diff --git a/Code/Editor/Controls/TimelineCtrl.h b/Code/Editor/Controls/TimelineCtrl.h index 015704460a..f87bdf3410 100644 --- a/Code/Editor/Controls/TimelineCtrl.h +++ b/Code/Editor/Controls/TimelineCtrl.h @@ -136,7 +136,6 @@ protected: void DrawFrameTicks(QPainter* dc); private: - bool m_bAutoDelete; QRect m_rcClient; QRect m_rcTimeline; float m_fTimeMarker; diff --git a/Code/Editor/Controls/WndGridHelper.h b/Code/Editor/Controls/WndGridHelper.h index 158ffca508..e983c69192 100644 --- a/Code/Editor/Controls/WndGridHelper.h +++ b/Code/Editor/Controls/WndGridHelper.h @@ -14,6 +14,7 @@ #include #include #include "Cry_Vector2.h" +#include ////////////////////////////////////////////////////////////////////////// class CWndGridHelper @@ -81,8 +82,6 @@ public: newzoom.y = 0.01f; } - Vec2 prevz = zoom; - // Zoom to mouse position. float ofsx = origin.x; float ofsy = origin.y; diff --git a/Code/Editor/Core/LevelEditorMenuHandler.cpp b/Code/Editor/Core/LevelEditorMenuHandler.cpp index 3724993604..e568f05167 100644 --- a/Code/Editor/Core/LevelEditorMenuHandler.cpp +++ b/Code/Editor/Core/LevelEditorMenuHandler.cpp @@ -41,8 +41,6 @@ using namespace AZ; using namespace AzToolsFramework; static const char* const s_LUAEditorName = "Lua Editor"; -static const char* const s_shortTimeInterval = "debug"; -static const char* const s_assetImporterMetricsIdentifier = "AssetImporter"; // top level menu ids static const char* const s_fileMenuId = "FileMenu"; @@ -50,7 +48,6 @@ static const char* const s_editMenuId = "EditMenu"; static const char* const s_gameMenuId = "GameMenu"; static const char* const s_toolMenuId = "ToolMenu"; static const char* const s_viewMenuId = "ViewMenu"; -static const char* const s_awsMenuId = "AwsMenu"; static const char* const s_helpMenuId = "HelpMenu"; static bool CompareLayoutNames(const QString& name1, const QString& name2) @@ -157,13 +154,11 @@ namespace } } -LevelEditorMenuHandler::LevelEditorMenuHandler( - MainWindow* mainWindow, QtViewPaneManager* const viewPaneManager, QSettings& settings) +LevelEditorMenuHandler::LevelEditorMenuHandler(MainWindow* mainWindow, QtViewPaneManager* const viewPaneManager) : QObject(mainWindow) , m_mainWindow(mainWindow) , m_viewPaneManager(viewPaneManager) , m_actionManager(mainWindow->GetActionManager()) - , m_settings(settings) { #if defined(AZ_PLATFORM_MAC) // Hide the non-native toolbar, then setNativeMenuBar to ensure it is always visible on macOS. diff --git a/Code/Editor/Core/LevelEditorMenuHandler.h b/Code/Editor/Core/LevelEditorMenuHandler.h index 4cf1569c59..5ac8e63786 100644 --- a/Code/Editor/Core/LevelEditorMenuHandler.h +++ b/Code/Editor/Core/LevelEditorMenuHandler.h @@ -33,7 +33,7 @@ class LevelEditorMenuHandler { Q_OBJECT public: - LevelEditorMenuHandler(MainWindow* mainWindow, QtViewPaneManager* const viewPaneManager, QSettings& settings); + LevelEditorMenuHandler(MainWindow* mainWindow, QtViewPaneManager* const viewPaneManager); ~LevelEditorMenuHandler(); void Initialize(); @@ -106,7 +106,6 @@ private: ActionManager::MenuWrapper m_toolsMenu; QMenu* m_mostRecentLevelsMenu = nullptr; - QMenu* m_mostRecentProjectsMenu = nullptr; QMenu* m_editmenu = nullptr; ActionManager::MenuWrapper m_viewPanesMenu; @@ -117,7 +116,6 @@ private: int m_viewPaneVersion = 0; QList m_topLevelMenus; - QSettings& m_settings; }; #endif // LEVELEDITORMENUHANDLER_H diff --git a/Code/Editor/Core/QtEditorApplication.cpp b/Code/Editor/Core/QtEditorApplication.cpp index dd784ce10d..a4aab24be4 100644 --- a/Code/Editor/Core/QtEditorApplication.cpp +++ b/Code/Editor/Core/QtEditorApplication.cpp @@ -425,7 +425,7 @@ namespace Editor AZStd::array rawInputBytesArray; LPBYTE rawInputBytes = rawInputBytesArray.data(); - const UINT bytesCopied = GetRawInputData((HRAWINPUT)msg->lParam, RID_INPUT, rawInputBytes, &rawInputSize, rawInputHeaderSize); + [[maybe_unused]] const UINT bytesCopied = GetRawInputData((HRAWINPUT)msg->lParam, RID_INPUT, rawInputBytes, &rawInputSize, rawInputHeaderSize); CRY_ASSERT(bytesCopied == rawInputSize); RAWINPUT* rawInput = (RAWINPUT*)rawInputBytes; diff --git a/Code/Editor/CryEdit.cpp b/Code/Editor/CryEdit.cpp index f943265ec5..f0cc5c6264 100644 --- a/Code/Editor/CryEdit.cpp +++ b/Code/Editor/CryEdit.cpp @@ -78,7 +78,6 @@ AZ_POP_DISABLE_WARNING // CryCommon #include -#include #include // Editor diff --git a/Code/Editor/CryEditDoc.cpp b/Code/Editor/CryEditDoc.cpp index 647732a895..9a7e7cc846 100644 --- a/Code/Editor/CryEditDoc.cpp +++ b/Code/Editor/CryEditDoc.cpp @@ -342,7 +342,7 @@ void CCryEditDoc::Load(TDocMultiArchive& arrXmlAr, const QString& szFilename) // Register this level and its content hash as version GetIEditor()->GetSettingsManager()->AddToolVersion(fileName, levelHash); GetIEditor()->GetSettingsManager()->RegisterEvent(loadEvent); - LOADING_TIME_PROFILE_SECTION(gEnv->pSystem); + CAutoDocNotReady autoDocNotReady; HEAP_CHECK @@ -1018,14 +1018,6 @@ bool CCryEditDoc::AfterSaveDocument([[maybe_unused]] const QString& lpszPathName return bSaved; } - -static void GetUserSettingsFile(const QString& levelFolder, QString& userSettings) -{ - const char* pUserName = GetISystem()->GetUserName(); - QString fileName = QStringLiteral("%1_usersettings.editor_xml").arg(pUserName); - userSettings = Path::Make(levelFolder, fileName); -} - static bool TryRenameFile(const QString& oldPath, const QString& newPath, int retryAttempts=10) { QFile(newPath).setPermissions(QFile::ReadOther | QFile::WriteOther); diff --git a/Code/Editor/CryEditPy.cpp b/Code/Editor/CryEditPy.cpp index 2477cd2f35..10fd56c134 100644 --- a/Code/Editor/CryEditPy.cpp +++ b/Code/Editor/CryEditPy.cpp @@ -97,11 +97,6 @@ namespace } } - const char* PyGetGameFolder() - { - return Path::GetEditingGameDataFolder().c_str(); - } - AZStd::string PyGetGameFolderAsString() { return Path::GetEditingGameDataFolder(); diff --git a/Code/Editor/EditMode/SubObjectSelectionReferenceFrameCalculator.cpp b/Code/Editor/EditMode/SubObjectSelectionReferenceFrameCalculator.cpp deleted file mode 100644 index 80368d3ec1..0000000000 --- a/Code/Editor/EditMode/SubObjectSelectionReferenceFrameCalculator.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - - -// Description : Calculate the reference frame for sub-object selections. - -#include "EditorDefs.h" - -#include "SubObjectSelectionReferenceFrameCalculator.h" - -SubObjectSelectionReferenceFrameCalculator::SubObjectSelectionReferenceFrameCalculator(ESubObjElementType selectionType) - : m_anySelected(false) - , pos(0.0f, 0.0f, 0.0f) - , normal(0.0f, 0.0f, 0.0f) - , nNormals(0) - , selectionType(selectionType) - , bUseExplicitFrame(false) - , bExplicitAnySelected(false) -{ -} - -void SubObjectSelectionReferenceFrameCalculator::SetExplicitFrame(bool bAnySelected, const Matrix34& refFrame) -{ - this->m_refFrame = refFrame; - this->bUseExplicitFrame = true; - this->bExplicitAnySelected = bAnySelected; -} - -bool SubObjectSelectionReferenceFrameCalculator::GetFrame(Matrix34& refFrame) -{ - if (this->bUseExplicitFrame) - { - refFrame = this->m_refFrame; - return this->bExplicitAnySelected; - } - else - { - refFrame.SetIdentity(); - - if (this->nNormals > 0) - { - this->normal = this->normal / static_cast(this->nNormals); - if (!this->normal.IsZero()) - { - this->normal.Normalize(); - } - - // Average position. - this->pos = this->pos / static_cast(this->nNormals); - refFrame.SetTranslation(this->pos); - } - - if (this->m_anySelected) - { - if (!this->normal.IsZero()) - { - Vec3 xAxis(1, 0, 0), yAxis(0, 1, 0), zAxis(0, 0, 1); - if (this->normal.IsEquivalent(zAxis) || normal.IsEquivalent(-zAxis)) - { - zAxis = xAxis; - } - xAxis = this->normal.Cross(zAxis).GetNormalized(); - yAxis = xAxis.Cross(this->normal).GetNormalized(); - refFrame.SetFromVectors(xAxis, yAxis, normal, pos); - } - } - - return m_anySelected; - } -} diff --git a/Code/Editor/EditMode/SubObjectSelectionReferenceFrameCalculator.h b/Code/Editor/EditMode/SubObjectSelectionReferenceFrameCalculator.h deleted file mode 100644 index 7c0d6f40c6..0000000000 --- a/Code/Editor/EditMode/SubObjectSelectionReferenceFrameCalculator.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - - -// Description : Calculate the reference frame for sub-object selections. - - -#ifndef CRYINCLUDE_EDITOR_EDITMODE_SUBOBJECTSELECTIONREFERENCEFRAMECALCULATOR_H -#define CRYINCLUDE_EDITOR_EDITMODE_SUBOBJECTSELECTIONREFERENCEFRAMECALCULATOR_H -#pragma once - - -#include "ISubObjectSelectionReferenceFrameCalculator.h" -#include "Objects/SubObjSelection.h" - -class SubObjectSelectionReferenceFrameCalculator - : public ISubObjectSelectionReferenceFrameCalculator -{ -public: - SubObjectSelectionReferenceFrameCalculator(ESubObjElementType selectionType); - - virtual void SetExplicitFrame(bool bAnySelected, const Matrix34& refFrame); - bool GetFrame(Matrix34& refFrame); - -private: - bool m_anySelected; - Vec3 pos; - Vec3 normal; - int nNormals; - ESubObjElementType selectionType; - std::vector positions; - Matrix34 m_refFrame; - bool bUseExplicitFrame; - bool bExplicitAnySelected; -}; - -#endif // CRYINCLUDE_EDITOR_EDITMODE_SUBOBJECTSELECTIONREFERENCEFRAMECALCULATOR_H diff --git a/Code/Editor/EditorModularViewportCameraComposer.cpp b/Code/Editor/EditorModularViewportCameraComposer.cpp new file mode 100644 index 0000000000..498d6f3353 --- /dev/null +++ b/Code/Editor/EditorModularViewportCameraComposer.cpp @@ -0,0 +1,286 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#include + +#include +#include +#include +#include +#include + +namespace SandboxEditor +{ + static AzFramework::TranslateCameraInputChannelIds BuildTranslateCameraInputChannelIds() + { + AzFramework::TranslateCameraInputChannelIds translateCameraInputChannelIds; + translateCameraInputChannelIds.m_leftChannelId = SandboxEditor::CameraTranslateLeftChannelId(); + translateCameraInputChannelIds.m_rightChannelId = SandboxEditor::CameraTranslateRightChannelId(); + translateCameraInputChannelIds.m_forwardChannelId = SandboxEditor::CameraTranslateForwardChannelId(); + translateCameraInputChannelIds.m_backwardChannelId = SandboxEditor::CameraTranslateBackwardChannelId(); + translateCameraInputChannelIds.m_upChannelId = SandboxEditor::CameraTranslateUpChannelId(); + translateCameraInputChannelIds.m_downChannelId = SandboxEditor::CameraTranslateDownChannelId(); + translateCameraInputChannelIds.m_boostChannelId = SandboxEditor::CameraTranslateBoostChannelId(); + + return translateCameraInputChannelIds; + } + + EditorModularViewportCameraComposer::EditorModularViewportCameraComposer(const AzFramework::ViewportId viewportId) + : m_viewportId(viewportId) + { + EditorModularViewportCameraComposerNotificationBus::Handler::BusConnect(viewportId); + } + + EditorModularViewportCameraComposer::~EditorModularViewportCameraComposer() + { + EditorModularViewportCameraComposerNotificationBus::Handler::BusDisconnect(); + } + + AZStd::shared_ptr EditorModularViewportCameraComposer:: + CreateModularViewportCameraController() + { + SetupCameras(); + + auto controller = AZStd::make_shared(); + + controller->SetCameraViewportContextBuilderCallback( + [viewportId = m_viewportId](AZStd::unique_ptr& cameraViewportContext) + { + cameraViewportContext = AZStd::make_unique(viewportId); + }); + + controller->SetCameraPriorityBuilderCallback( + [](AtomToolsFramework::CameraControllerPriorityFn& cameraControllerPriorityFn) + { + cameraControllerPriorityFn = AtomToolsFramework::DefaultCameraControllerPriority; + }); + + controller->SetCameraPropsBuilderCallback( + [](AzFramework::CameraProps& cameraProps) + { + cameraProps.m_rotateSmoothnessFn = [] + { + return SandboxEditor::CameraRotateSmoothness(); + }; + + cameraProps.m_translateSmoothnessFn = [] + { + return SandboxEditor::CameraTranslateSmoothness(); + }; + + cameraProps.m_rotateSmoothingEnabledFn = [] + { + return SandboxEditor::CameraRotateSmoothingEnabled(); + }; + + cameraProps.m_translateSmoothingEnabledFn = [] + { + return SandboxEditor::CameraTranslateSmoothingEnabled(); + }; + }); + + controller->SetCameraListBuilderCallback( + [this](AzFramework::Cameras& cameras) + { + cameras.AddCamera(m_firstPersonRotateCamera); + cameras.AddCamera(m_firstPersonPanCamera); + cameras.AddCamera(m_firstPersonTranslateCamera); + cameras.AddCamera(m_firstPersonScrollCamera); + cameras.AddCamera(m_orbitCamera); + }); + + return controller; + } + + void EditorModularViewportCameraComposer::SetupCameras() + { + const auto hideCursor = [viewportId = m_viewportId] + { + if (SandboxEditor::CameraCaptureCursorForLook()) + { + AzToolsFramework::ViewportInteraction::ViewportMouseCursorRequestBus::Event( + viewportId, &AzToolsFramework::ViewportInteraction::ViewportMouseCursorRequestBus::Events::BeginCursorCapture); + } + }; + const auto showCursor = [viewportId = m_viewportId] + { + if (SandboxEditor::CameraCaptureCursorForLook()) + { + AzToolsFramework::ViewportInteraction::ViewportMouseCursorRequestBus::Event( + viewportId, &AzToolsFramework::ViewportInteraction::ViewportMouseCursorRequestBus::Events::EndCursorCapture); + } + }; + + m_firstPersonRotateCamera = AZStd::make_shared(SandboxEditor::CameraFreeLookChannelId()); + + m_firstPersonRotateCamera->m_rotateSpeedFn = [] + { + return SandboxEditor::CameraRotateSpeed(); + }; + + // default behavior is to hide the cursor but this can be disabled (useful for remote desktop) + // note: See CaptureCursorLook in the Settings Registry + m_firstPersonRotateCamera->SetActivationBeganFn(hideCursor); + m_firstPersonRotateCamera->SetActivationEndedFn(showCursor); + + m_firstPersonPanCamera = + AZStd::make_shared(SandboxEditor::CameraFreePanChannelId(), AzFramework::LookPan); + + m_firstPersonPanCamera->m_panSpeedFn = [] + { + return SandboxEditor::CameraPanSpeed(); + }; + + m_firstPersonPanCamera->m_invertPanXFn = [] + { + return SandboxEditor::CameraPanInvertedX(); + }; + + m_firstPersonPanCamera->m_invertPanYFn = [] + { + return SandboxEditor::CameraPanInvertedY(); + }; + + const auto translateCameraInputChannelIds = BuildTranslateCameraInputChannelIds(); + + m_firstPersonTranslateCamera = + AZStd::make_shared(AzFramework::LookTranslation, translateCameraInputChannelIds); + + m_firstPersonTranslateCamera->m_translateSpeedFn = [] + { + return SandboxEditor::CameraTranslateSpeed(); + }; + + m_firstPersonTranslateCamera->m_boostMultiplierFn = [] + { + return SandboxEditor::CameraBoostMultiplier(); + }; + + m_firstPersonScrollCamera = AZStd::make_shared(); + + m_firstPersonScrollCamera->m_scrollSpeedFn = [] + { + return SandboxEditor::CameraScrollSpeed(); + }; + + m_orbitCamera = AZStd::make_shared(SandboxEditor::CameraOrbitChannelId()); + + m_orbitCamera->SetLookAtFn( + [viewportId = m_viewportId](const AZ::Vector3& position, const AZ::Vector3& direction) -> AZStd::optional + { + 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 + if (lookAtAfterInterpolation.has_value()) + { + 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; + + 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 {}; + }); + + m_orbitRotateCamera = AZStd::make_shared(SandboxEditor::CameraOrbitLookChannelId()); + + m_orbitRotateCamera->m_rotateSpeedFn = [] + { + return SandboxEditor::CameraRotateSpeed(); + }; + + m_orbitRotateCamera->m_invertYawFn = [] + { + return SandboxEditor::CameraOrbitYawRotationInverted(); + }; + + m_orbitTranslateCamera = + AZStd::make_shared(AzFramework::OrbitTranslation, translateCameraInputChannelIds); + + m_orbitTranslateCamera->m_translateSpeedFn = [] + { + return SandboxEditor::CameraTranslateSpeed(); + }; + + m_orbitTranslateCamera->m_boostMultiplierFn = [] + { + return SandboxEditor::CameraBoostMultiplier(); + }; + + m_orbitDollyScrollCamera = AZStd::make_shared(); + + m_orbitDollyScrollCamera->m_scrollSpeedFn = [] + { + return SandboxEditor::CameraScrollSpeed(); + }; + + m_orbitDollyMoveCamera = + AZStd::make_shared(SandboxEditor::CameraOrbitDollyChannelId()); + + m_orbitDollyMoveCamera->m_cursorSpeedFn = [] + { + return SandboxEditor::CameraDollyMotionSpeed(); + }; + + m_orbitPanCamera = AZStd::make_shared(SandboxEditor::CameraOrbitPanChannelId(), AzFramework::OrbitPan); + + m_orbitPanCamera->m_panSpeedFn = [] + { + return SandboxEditor::CameraPanSpeed(); + }; + + m_orbitPanCamera->m_invertPanXFn = [] + { + return SandboxEditor::CameraPanInvertedX(); + }; + + m_orbitPanCamera->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); + } + + 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()); + } +} // namespace SandboxEditor diff --git a/Code/Editor/EditorModularViewportCameraComposer.h b/Code/Editor/EditorModularViewportCameraComposer.h new file mode 100644 index 0000000000..cb223d39e6 --- /dev/null +++ b/Code/Editor/EditorModularViewportCameraComposer.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#pragma once + +#include +#include +#include +#include + +namespace SandboxEditor +{ + //! Type responsible for building the editor's modular viewport camera controller. + class EditorModularViewportCameraComposer : private EditorModularViewportCameraComposerNotificationBus::Handler + { + public: + SANDBOX_API explicit EditorModularViewportCameraComposer(AzFramework::ViewportId viewportId); + SANDBOX_API ~EditorModularViewportCameraComposer(); + + //! Build a ModularViewportCameraController from the associated camera inputs. + SANDBOX_API AZStd::shared_ptr CreateModularViewportCameraController(); + + private: + //! Setup all internal camera inputs. + void SetupCameras(); + + // EditorModularViewportCameraComposerNotificationBus overrides ... + void OnEditorModularViewportCameraComposerSettingsChanged() override; + + AZStd::shared_ptr m_firstPersonRotateCamera; + 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; + + AzFramework::ViewportId m_viewportId; + }; +} // namespace SandboxEditor diff --git a/Code/Editor/EditorModularViewportCameraComposerBus.h b/Code/Editor/EditorModularViewportCameraComposerBus.h new file mode 100644 index 0000000000..ac760b8a9a --- /dev/null +++ b/Code/Editor/EditorModularViewportCameraComposerBus.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#pragma once + +#include +#include +#include + +namespace SandboxEditor +{ + //! Notifications for changes to the editor modular viewport camera controller. + class EditorModularViewportCameraComposerNotifications + { + public: + //! Notify any listeners when changes have been made to the modular viewport camera settings. + //! @note This is used to update any cached input channels when controls are modified. + virtual void OnEditorModularViewportCameraComposerSettingsChanged() = 0; + + protected: + ~EditorModularViewportCameraComposerNotifications() = default; + }; + + using EditorModularViewportCameraComposerNotificationBus = + AZ::EBus; +} // namespace SandboxEditor diff --git a/Code/Editor/EditorPreferencesPageViewportMovement.cpp b/Code/Editor/EditorPreferencesPageViewportMovement.cpp index 988b4954d1..74abb3f207 100644 --- a/Code/Editor/EditorPreferencesPageViewportMovement.cpp +++ b/Code/Editor/EditorPreferencesPageViewportMovement.cpp @@ -5,51 +5,220 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ + #include "EditorDefs.h" #include "EditorPreferencesPageViewportMovement.h" +#include +#include +#include +#include #include +#include // Editor -#include "Settings.h" #include "EditorViewportSettings.h" +#include "Settings.h" + +static AZStd::vector GetInputNamesByDevice(const AzFramework::InputDeviceId inputDeviceId) +{ + AzFramework::InputDeviceRequests::InputChannelIdSet availableInputChannelIds; + AzFramework::InputDeviceRequestBus::Event( + inputDeviceId, &AzFramework::InputDeviceRequests::GetInputChannelIds, availableInputChannelIds); + + AZStd::vector inputChannelNames; + for (const AzFramework::InputChannelId& inputChannelId : availableInputChannelIds) + { + inputChannelNames.push_back(inputChannelId.GetName()); + } + + AZStd::sort(inputChannelNames.begin(), inputChannelNames.end()); + + return inputChannelNames; +} + +static AZStd::vector GetEditorInputNames() +{ + // function static to defer having to call GetInputNamesByDevice for every CameraInputSettings member + static bool inputNamesGenerated = false; + static AZStd::vector inputNames; + + if (!inputNamesGenerated) + { + AZStd::vector keyboardInputNames = GetInputNamesByDevice(AzFramework::InputDeviceKeyboard::Id); + AZStd::vector mouseInputNames = GetInputNamesByDevice(AzFramework::InputDeviceMouse::Id); + + inputNames.insert(inputNames.end(), mouseInputNames.begin(), mouseInputNames.end()); + inputNames.insert(inputNames.end(), keyboardInputNames.begin(), keyboardInputNames.end()); + + inputNamesGenerated = true; + } + + return inputNames; +} void CEditorPreferencesPage_ViewportMovement::Reflect(AZ::SerializeContext& serialize) { serialize.Class() - ->Version(1) - ->Field("MoveSpeed", &CameraMovementSettings::m_moveSpeed) + ->Version(2) + ->Field("TranslateSpeed", &CameraMovementSettings::m_translateSpeed) ->Field("RotateSpeed", &CameraMovementSettings::m_rotateSpeed) - ->Field("FastMoveSpeed", &CameraMovementSettings::m_fastMoveSpeed) - ->Field("WheelZoomSpeed", &CameraMovementSettings::m_wheelZoomSpeed) - ->Field("InvertYAxis", &CameraMovementSettings::m_invertYRotation) - ->Field("InvertPan", &CameraMovementSettings::m_invertPan); + ->Field("BoostMultiplier", &CameraMovementSettings::m_boostMultiplier) + ->Field("ScrollSpeed", &CameraMovementSettings::m_scrollSpeed) + ->Field("DollySpeed", &CameraMovementSettings::m_dollySpeed) + ->Field("PanSpeed", &CameraMovementSettings::m_panSpeed) + ->Field("RotateSmoothing", &CameraMovementSettings::m_rotateSmoothing) + ->Field("RotateSmoothness", &CameraMovementSettings::m_rotateSmoothness) + ->Field("TranslateSmoothing", &CameraMovementSettings::m_translateSmoothing) + ->Field("TranslateSmoothness", &CameraMovementSettings::m_translateSmoothness) + ->Field("CaptureCursorLook", &CameraMovementSettings::m_captureCursorLook) + ->Field("OrbitYawRotationInverted", &CameraMovementSettings::m_orbitYawRotationInverted) + ->Field("PanInvertedX", &CameraMovementSettings::m_panInvertedX) + ->Field("PanInvertedY", &CameraMovementSettings::m_panInvertedY); + + serialize.Class() + ->Version(1) + ->Field("TranslateForward", &CameraInputSettings::m_translateForwardChannelId) + ->Field("TranslateBackward", &CameraInputSettings::m_translateBackwardChannelId) + ->Field("TranslateLeft", &CameraInputSettings::m_translateLeftChannelId) + ->Field("TranslateRight", &CameraInputSettings::m_translateRightChannelId) + ->Field("TranslateUp", &CameraInputSettings::m_translateUpChannelId) + ->Field("TranslateDown", &CameraInputSettings::m_translateDownChannelId) + ->Field("Boost", &CameraInputSettings::m_boostChannelId) + ->Field("Orbit", &CameraInputSettings::m_orbitChannelId) + ->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); serialize.Class() ->Version(1) - ->Field("CameraMovementSettings", &CEditorPreferencesPage_ViewportMovement::m_cameraMovementSettings); + ->Field("CameraMovementSettings", &CEditorPreferencesPage_ViewportMovement::m_cameraMovementSettings) + ->Field("CameraInputSettings", &CEditorPreferencesPage_ViewportMovement::m_cameraInputSettings); - - AZ::EditContext* editContext = serialize.GetEditContext(); - if (editContext) + if (AZ::EditContext* editContext = serialize.GetEditContext()) { editContext->Class("Camera Movement Settings", "") - ->DataElement(AZ::Edit::UIHandlers::SpinBox, &CameraMovementSettings::m_moveSpeed, "Camera Movement Speed", "Camera Movement Speed") - ->DataElement(AZ::Edit::UIHandlers::SpinBox, &CameraMovementSettings::m_rotateSpeed, "Camera Rotation Speed", "Camera Rotation Speed") - ->DataElement(AZ::Edit::UIHandlers::SpinBox, &CameraMovementSettings::m_fastMoveSpeed, "Fast Movement Scale", "Fast Movement Scale (holding shift") - ->DataElement(AZ::Edit::UIHandlers::SpinBox, &CameraMovementSettings::m_wheelZoomSpeed, "Wheel Zoom Speed", "Wheel Zoom Speed") - ->DataElement(AZ::Edit::UIHandlers::CheckBox, &CameraMovementSettings::m_invertYRotation, "Invert Y Axis", "Invert Y Rotation (holding RMB)") - ->DataElement(AZ::Edit::UIHandlers::CheckBox, &CameraMovementSettings::m_invertPan, "Invert Pan", "Invert Pan (holding MMB)"); + ->DataElement( + AZ::Edit::UIHandlers::SpinBox, &CameraMovementSettings::m_translateSpeed, "Camera Movement Speed", "Camera movement speed") + ->Attribute(AZ::Edit::Attributes::Min, 0.01f) + ->DataElement( + AZ::Edit::UIHandlers::SpinBox, &CameraMovementSettings::m_rotateSpeed, "Camera Rotation Speed", "Camera rotation speed") + ->Attribute(AZ::Edit::Attributes::Min, 0.01f) + ->DataElement( + AZ::Edit::UIHandlers::SpinBox, &CameraMovementSettings::m_boostMultiplier, "Camera Boost Multiplier", + "Camera boost multiplier to apply to movement speed") + ->Attribute(AZ::Edit::Attributes::Min, 0.01f) + ->DataElement( + AZ::Edit::UIHandlers::SpinBox, &CameraMovementSettings::m_scrollSpeed, "Camera Scroll Speed", + "Camera movement speed while using scroll/wheel input") + ->Attribute(AZ::Edit::Attributes::Min, 0.01f) + ->DataElement( + AZ::Edit::UIHandlers::SpinBox, &CameraMovementSettings::m_dollySpeed, "Camera Dolly Speed", + "Camera movement speed while using mouse motion to move in and out") + ->Attribute(AZ::Edit::Attributes::Min, 0.01f) + ->DataElement( + AZ::Edit::UIHandlers::SpinBox, &CameraMovementSettings::m_panSpeed, "Camera Pan Speed", + "Camera movement speed while panning using the mouse") + ->Attribute(AZ::Edit::Attributes::Min, 0.01f) + ->DataElement( + AZ::Edit::UIHandlers::CheckBox, &CameraMovementSettings::m_rotateSmoothing, "Camera Rotate Smoothing", + "Is camera rotation smoothing enabled or disabled") + ->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ::Edit::PropertyRefreshLevels::EntireTree) + ->DataElement( + AZ::Edit::UIHandlers::SpinBox, &CameraMovementSettings::m_rotateSmoothness, "Camera Rotate Smoothness", + "Amount of camera smoothing to apply while rotating the camera") + ->Attribute(AZ::Edit::Attributes::Min, 0.01f) + ->Attribute(AZ::Edit::Attributes::Visibility, &CameraMovementSettings::RotateSmoothingVisibility) + ->DataElement( + AZ::Edit::UIHandlers::CheckBox, &CameraMovementSettings::m_translateSmoothing, "Camera Translate Smoothing", + "Is camera translation smoothing enabled or disabled") + ->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ::Edit::PropertyRefreshLevels::EntireTree) + ->DataElement( + AZ::Edit::UIHandlers::SpinBox, &CameraMovementSettings::m_translateSmoothness, "Camera Translate Smoothness", + "Amount of camera smoothing to apply while translating the camera") + ->Attribute(AZ::Edit::Attributes::Min, 0.01f) + ->Attribute(AZ::Edit::Attributes::Visibility, &CameraMovementSettings::TranslateSmoothingVisibility) + ->DataElement( + AZ::Edit::UIHandlers::CheckBox, &CameraMovementSettings::m_orbitYawRotationInverted, "Camera Orbit Yaw Inverted", + "Inverted yaw rotation while orbiting") + ->DataElement( + AZ::Edit::UIHandlers::CheckBox, &CameraMovementSettings::m_panInvertedX, "Invert Pan X", + "Invert direction of pan in local X axis") + ->DataElement( + AZ::Edit::UIHandlers::CheckBox, &CameraMovementSettings::m_panInvertedY, "Invert Pan Y", + "Invert direction of pan in local Y axis") + ->DataElement( + AZ::Edit::UIHandlers::CheckBox, &CameraMovementSettings::m_captureCursorLook, "Camera Capture Look Cursor", + "Should the cursor be captured (hidden) while performing free look"); - editContext->Class("Gizmo Movement Preferences", "Gizmo Movement Preferences") + editContext->Class("Camera Input Settings", "") + ->DataElement( + AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_translateForwardChannelId, "Translate Forward", + "Key/button to move the camera forward") + ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames) + ->DataElement( + AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_translateBackwardChannelId, "Translate Backward", + "Key/button to move the camera backward") + ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames) + ->DataElement( + AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_translateLeftChannelId, "Translate Left", + "Key/button to move the camera left") + ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames) + ->DataElement( + AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_translateRightChannelId, "Translate Right", + "Key/button to move the camera right") + ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames) + ->DataElement( + AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_translateUpChannelId, "Translate Up", + "Key/button to move the camera up") + ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames) + ->DataElement( + AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_translateDownChannelId, "Translate Down", + "Key/button to move the camera down") + ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames) + ->DataElement( + AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_boostChannelId, "Boost", + "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") + ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames) + ->DataElement( + AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_freeLookChannelId, "Free Look", + "Key/button to begin camera free look") + ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames) + ->DataElement( + 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") + ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames) + ->DataElement( + AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_orbitDollyChannelId, "Orbit Dolly", + "Key/button to begin camera orbit dolly") + ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames) + ->DataElement( + AZ::Edit::UIHandlers::ComboBox, &CameraInputSettings::m_orbitPanChannelId, "Orbit Pan", + "Key/button to begin camera orbit pan") + ->Attribute(AZ::Edit::Attributes::StringList, &GetEditorInputNames); + + editContext->Class("Viewport Preferences", "Viewport Preferences") ->ClassElement(AZ::Edit::ClassElements::EditorData, "") ->Attribute(AZ::Edit::Attributes::Visibility, AZ_CRC("PropertyVisibility_ShowChildrenOnly", 0xef428f20)) - ->DataElement(AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_ViewportMovement::m_cameraMovementSettings, "Camera Movement Settings", "Camera Movement Settings"); + ->DataElement( + AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_ViewportMovement::m_cameraMovementSettings, + "Camera Movement Settings", "Camera Movement Settings") + ->DataElement( + AZ::Edit::UIHandlers::Default, &CEditorPreferencesPage_ViewportMovement::m_cameraInputSettings, "Camera Input Settings", + "Camera Input Settings"); } } - CEditorPreferencesPage_ViewportMovement::CEditorPreferencesPage_ViewportMovement() { InitializeSettings(); @@ -68,21 +237,67 @@ QIcon& CEditorPreferencesPage_ViewportMovement::GetIcon() void CEditorPreferencesPage_ViewportMovement::OnApply() { - SandboxEditor::SetCameraTranslateSpeed(m_cameraMovementSettings.m_moveSpeed); + SandboxEditor::SetCameraTranslateSpeed(m_cameraMovementSettings.m_translateSpeed); SandboxEditor::SetCameraRotateSpeed(m_cameraMovementSettings.m_rotateSpeed); - SandboxEditor::SetCameraBoostMultiplier(m_cameraMovementSettings.m_fastMoveSpeed); - SandboxEditor::SetCameraScrollSpeed(m_cameraMovementSettings.m_wheelZoomSpeed); - SandboxEditor::SetCameraOrbitYawRotationInverted(m_cameraMovementSettings.m_invertYRotation); - SandboxEditor::SetCameraPanInvertedX(m_cameraMovementSettings.m_invertPan); - SandboxEditor::SetCameraPanInvertedY(m_cameraMovementSettings.m_invertPan); + SandboxEditor::SetCameraBoostMultiplier(m_cameraMovementSettings.m_boostMultiplier); + SandboxEditor::SetCameraScrollSpeed(m_cameraMovementSettings.m_scrollSpeed); + SandboxEditor::SetCameraDollyMotionSpeed(m_cameraMovementSettings.m_dollySpeed); + SandboxEditor::SetCameraPanSpeed(m_cameraMovementSettings.m_panSpeed); + SandboxEditor::SetCameraRotateSmoothness(m_cameraMovementSettings.m_rotateSmoothness); + SandboxEditor::SetCameraRotateSmoothingEnabled(m_cameraMovementSettings.m_rotateSmoothing); + 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::SetCameraPanInvertedX(m_cameraMovementSettings.m_panInvertedX); + SandboxEditor::SetCameraPanInvertedY(m_cameraMovementSettings.m_panInvertedY); + + SandboxEditor::SetCameraTranslateForwardChannelId(m_cameraInputSettings.m_translateForwardChannelId); + SandboxEditor::SetCameraTranslateBackwardChannelId(m_cameraInputSettings.m_translateBackwardChannelId); + SandboxEditor::SetCameraTranslateLeftChannelId(m_cameraInputSettings.m_translateLeftChannelId); + SandboxEditor::SetCameraTranslateRightChannelId(m_cameraInputSettings.m_translateRightChannelId); + 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::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::EditorModularViewportCameraComposerNotificationBus::Broadcast( + &SandboxEditor::EditorModularViewportCameraComposerNotificationBus::Events::OnEditorModularViewportCameraComposerSettingsChanged); } void CEditorPreferencesPage_ViewportMovement::InitializeSettings() { - m_cameraMovementSettings.m_moveSpeed = SandboxEditor::CameraTranslateSpeed(); + m_cameraMovementSettings.m_translateSpeed = SandboxEditor::CameraTranslateSpeed(); m_cameraMovementSettings.m_rotateSpeed = SandboxEditor::CameraRotateSpeed(); - m_cameraMovementSettings.m_fastMoveSpeed = SandboxEditor::CameraBoostMultiplier(); - m_cameraMovementSettings.m_wheelZoomSpeed = SandboxEditor::CameraScrollSpeed(); - m_cameraMovementSettings.m_invertYRotation = SandboxEditor::CameraOrbitYawRotationInverted(); - m_cameraMovementSettings.m_invertPan = SandboxEditor::CameraPanInvertedX() && SandboxEditor::CameraPanInvertedY(); + m_cameraMovementSettings.m_boostMultiplier = SandboxEditor::CameraBoostMultiplier(); + m_cameraMovementSettings.m_scrollSpeed = SandboxEditor::CameraScrollSpeed(); + m_cameraMovementSettings.m_dollySpeed = SandboxEditor::CameraDollyMotionSpeed(); + m_cameraMovementSettings.m_panSpeed = SandboxEditor::CameraPanSpeed(); + m_cameraMovementSettings.m_rotateSmoothness = SandboxEditor::CameraRotateSmoothness(); + m_cameraMovementSettings.m_rotateSmoothing = SandboxEditor::CameraRotateSmoothingEnabled(); + 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_panInvertedX = SandboxEditor::CameraPanInvertedX(); + m_cameraMovementSettings.m_panInvertedY = SandboxEditor::CameraPanInvertedY(); + + m_cameraInputSettings.m_translateForwardChannelId = SandboxEditor::CameraTranslateForwardChannelId().GetName(); + m_cameraInputSettings.m_translateBackwardChannelId = SandboxEditor::CameraTranslateBackwardChannelId().GetName(); + m_cameraInputSettings.m_translateLeftChannelId = SandboxEditor::CameraTranslateLeftChannelId().GetName(); + m_cameraInputSettings.m_translateRightChannelId = SandboxEditor::CameraTranslateRightChannelId().GetName(); + 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_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(); } diff --git a/Code/Editor/EditorPreferencesPageViewportMovement.h b/Code/Editor/EditorPreferencesPageViewportMovement.h index 1373260e62..b7482fb048 100644 --- a/Code/Editor/EditorPreferencesPageViewportMovement.h +++ b/Code/Editor/EditorPreferencesPageViewportMovement.h @@ -5,17 +5,21 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ + #pragma once #include "Include/IPreferencesPage.h" -#include -#include #include +#include +#include #include +inline AZ::Crc32 EditorPropertyVisibility(const bool enabled) +{ + return enabled ? AZ::Edit::PropertyVisibility::Show : AZ::Edit::PropertyVisibility::Hide; +} -class CEditorPreferencesPage_ViewportMovement - : public IPreferencesPage +class CEditorPreferencesPage_ViewportMovement : public IPreferencesPage { public: AZ_RTTI(CEditorPreferencesPage_ViewportMovement, "{BC593332-7EAF-4171-8A35-1C5DE5B40909}", IPreferencesPage) @@ -25,12 +29,22 @@ public: CEditorPreferencesPage_ViewportMovement(); virtual ~CEditorPreferencesPage_ViewportMovement() = default; - virtual const char* GetCategory() override { return "Viewports"; } + virtual const char* GetCategory() override + { + return "Viewports"; + } + virtual const char* GetTitle(); virtual QIcon& GetIcon() override; virtual void OnApply() override; - virtual void OnCancel() override {} - virtual bool OnQueryCancel() override { return true; } + virtual void OnCancel() override + { + } + + virtual bool OnQueryCancel() override + { + return true; + } private: void InitializeSettings(); @@ -39,16 +53,53 @@ private: { AZ_TYPE_INFO(CameraMovementSettings, "{60B8C07E-5F48-4171-A50B-F45558B5CCA1}") - float m_moveSpeed; + float m_translateSpeed; float m_rotateSpeed; - float m_fastMoveSpeed; - float m_wheelZoomSpeed; - bool m_invertYRotation; - bool m_invertPan; + float m_scrollSpeed; + float m_dollySpeed; + float m_panSpeed; + float m_boostMultiplier; + float m_rotateSmoothness; + bool m_rotateSmoothing; + float m_translateSmoothness; + bool m_translateSmoothing; + bool m_captureCursorLook; + bool m_orbitYawRotationInverted; + bool m_panInvertedX; + bool m_panInvertedY; + + AZ::Crc32 RotateSmoothingVisibility() const + { + return EditorPropertyVisibility(m_rotateSmoothing); + } + + AZ::Crc32 TranslateSmoothingVisibility() const + { + return EditorPropertyVisibility(m_translateSmoothing); + } + }; + + struct CameraInputSettings + { + AZ_TYPE_INFO(struct CameraInputSettings, "{A250FAD4-662E-4896-B030-D4ED03679377}") + + AZStd::string m_translateForwardChannelId; + AZStd::string m_translateBackwardChannelId; + AZStd::string m_translateLeftChannelId; + AZStd::string m_translateRightChannelId; + AZStd::string m_translateUpChannelId; + AZStd::string m_translateDownChannelId; + AZStd::string m_boostChannelId; + AZStd::string m_orbitChannelId; + AZStd::string m_freeLookChannelId; + AZStd::string m_freePanChannelId; + AZStd::string m_orbitLookChannelId; + AZStd::string m_orbitDollyChannelId; + AZStd::string m_orbitPanChannelId; }; CameraMovementSettings m_cameraMovementSettings; + CameraInputSettings m_cameraInputSettings; + QIcon m_icon; }; - - diff --git a/Code/Editor/EditorViewportSettings.cpp b/Code/Editor/EditorViewportSettings.cpp index 38831a1de4..872454412d 100644 --- a/Code/Editor/EditorViewportSettings.cpp +++ b/Code/Editor/EditorViewportSettings.cpp @@ -63,7 +63,11 @@ namespace SandboxEditor AZStd::remove_cvref_t value = AZStd::forward(defaultValue); if (const auto* registry = AZ::SettingsRegistry::Get()) { - registry->Get(value, setting); + T potentialValue; + if (registry->Get(potentialValue, setting)) + { + value = AZStd::move(potentialValue); + } } return value; @@ -363,7 +367,7 @@ namespace SandboxEditor void SetCameraTranslateBoostChannelId(AZStd::string_view cameraTranslateBoostId) { - SetRegistry(CameraTranslateDownIdSetting, cameraTranslateBoostId); + SetRegistry(CameraTranslateBoostIdSetting, cameraTranslateBoostId); } AzFramework::InputChannelId CameraOrbitChannelId() @@ -371,7 +375,7 @@ namespace SandboxEditor return AzFramework::InputChannelId(GetRegistry(CameraOrbitIdSetting, AZStd::string("keyboard_key_modifier_alt_l")).c_str()); } - void SetCameraOrbitChannelChannelId(AZStd::string_view cameraOrbitId) + void SetCameraOrbitChannelId(AZStd::string_view cameraOrbitId) { SetRegistry(CameraOrbitIdSetting, cameraOrbitId); } diff --git a/Code/Editor/EditorViewportSettings.h b/Code/Editor/EditorViewportSettings.h index 83004d52af..3da8c465fb 100644 --- a/Code/Editor/EditorViewportSettings.h +++ b/Code/Editor/EditorViewportSettings.h @@ -111,7 +111,7 @@ namespace SandboxEditor SANDBOX_API void SetCameraTranslateBoostChannelId(AZStd::string_view cameraTranslateBoostId); SANDBOX_API AzFramework::InputChannelId CameraOrbitChannelId(); - SANDBOX_API void SetCameraOrbitChannelChannelId(AZStd::string_view cameraOrbitId); + SANDBOX_API void SetCameraOrbitChannelId(AZStd::string_view cameraOrbitId); SANDBOX_API AzFramework::InputChannelId CameraFreeLookChannelId(); SANDBOX_API void SetCameraFreeLookChannelId(AZStd::string_view cameraFreeLookId); diff --git a/Code/Editor/EditorViewportWidget.cpp b/Code/Editor/EditorViewportWidget.cpp index c15fc0363e..44ac159c87 100644 --- a/Code/Editor/EditorViewportWidget.cpp +++ b/Code/Editor/EditorViewportWidget.cpp @@ -50,10 +50,11 @@ // AtomToolsFramework #include -#include // CryCommon #include +#include +#include // AzFramework #include @@ -739,9 +740,13 @@ void EditorViewportWidget::OnBeginPrepareRender() RenderAll(); // Draw 2D helpers. +#ifdef LYSHINE_ATOM_TODO TransformationMatrices backupSceneMatrices; +#endif m_debugDisplay->DepthTestOff(); - //m_renderer->Set2DMode(m_rcClient.right(), m_rcClient.bottom(), backupSceneMatrices); +#ifdef LYSHINE_ATOM_TODO + m_renderer->Set2DMode(m_rcClient.right(), m_rcClient.bottom(), backupSceneMatrices); +#endif auto prevState = m_debugDisplay->GetState(); m_debugDisplay->SetState(e_Mode3D | e_AlphaBlended | e_FillModeSolid | e_CullModeBack | e_DepthWriteOn | e_DepthTestOn); @@ -1024,220 +1029,6 @@ bool EditorViewportWidget::ShowingWorldSpace() return BuildKeyboardModifiers(QGuiApplication::queryKeyboardModifiers()).Shift(); } -AZStd::shared_ptr CreateModularViewportCameraController( - const AzFramework::ViewportId viewportId) -{ - auto controller = AZStd::make_shared(); - - controller->SetCameraViewportContextBuilderCallback( - [viewportId](AZStd::unique_ptr& cameraViewportContext) - { - cameraViewportContext = AZStd::make_unique(viewportId); - }); - - controller->SetCameraPriorityBuilderCallback( - [](AtomToolsFramework::CameraControllerPriorityFn& cameraControllerPriorityFn) - { - cameraControllerPriorityFn = AtomToolsFramework::DefaultCameraControllerPriority; - }); - - controller->SetCameraPropsBuilderCallback( - [](AzFramework::CameraProps& cameraProps) - { - cameraProps.m_rotateSmoothnessFn = [] - { - return SandboxEditor::CameraRotateSmoothness(); - }; - - cameraProps.m_translateSmoothnessFn = [] - { - return SandboxEditor::CameraTranslateSmoothness(); - }; - - cameraProps.m_rotateSmoothingEnabledFn = [] - { - return SandboxEditor::CameraRotateSmoothingEnabled(); - }; - - cameraProps.m_translateSmoothingEnabledFn = [] - { - return SandboxEditor::CameraTranslateSmoothingEnabled(); - }; - }); - - controller->SetCameraListBuilderCallback( - [viewportId](AzFramework::Cameras& cameras) - { - const auto hideCursor = [viewportId] - { - if (SandboxEditor::CameraCaptureCursorForLook()) - { - AzToolsFramework::ViewportInteraction::ViewportMouseCursorRequestBus::Event( - viewportId, &AzToolsFramework::ViewportInteraction::ViewportMouseCursorRequestBus::Events::BeginCursorCapture); - } - }; - const auto showCursor = [viewportId] - { - if (SandboxEditor::CameraCaptureCursorForLook()) - { - AzToolsFramework::ViewportInteraction::ViewportMouseCursorRequestBus::Event( - viewportId, &AzToolsFramework::ViewportInteraction::ViewportMouseCursorRequestBus::Events::EndCursorCapture); - } - }; - - auto firstPersonRotateCamera = AZStd::make_shared(SandboxEditor::CameraFreeLookChannelId()); - firstPersonRotateCamera->m_rotateSpeedFn = [] - { - return SandboxEditor::CameraRotateSpeed(); - }; - - // default behavior is to hide the cursor but this can be disabled (useful for remote desktop) - // note: See CaptureCursorLook in the Settings Registry - firstPersonRotateCamera->SetActivationBeganFn(hideCursor); - firstPersonRotateCamera->SetActivationEndedFn(showCursor); - - auto firstPersonPanCamera = - AZStd::make_shared(SandboxEditor::CameraFreePanChannelId(), AzFramework::LookPan); - firstPersonPanCamera->m_panSpeedFn = [] - { - return SandboxEditor::CameraPanSpeed(); - }; - firstPersonPanCamera->m_invertPanXFn = [] - { - return SandboxEditor::CameraPanInvertedX(); - }; - firstPersonPanCamera->m_invertPanYFn = [] - { - return SandboxEditor::CameraPanInvertedY(); - }; - - AzFramework::TranslateCameraInputChannels translateCameraInputChannels; - translateCameraInputChannels.m_leftChannelId = SandboxEditor::CameraTranslateLeftChannelId(); - translateCameraInputChannels.m_rightChannelId = SandboxEditor::CameraTranslateRightChannelId(); - translateCameraInputChannels.m_forwardChannelId = SandboxEditor::CameraTranslateForwardChannelId(); - translateCameraInputChannels.m_backwardChannelId = SandboxEditor::CameraTranslateBackwardChannelId(); - translateCameraInputChannels.m_upChannelId = SandboxEditor::CameraTranslateUpChannelId(); - translateCameraInputChannels.m_downChannelId = SandboxEditor::CameraTranslateDownChannelId(); - translateCameraInputChannels.m_boostChannelId = SandboxEditor::CameraTranslateBoostChannelId(); - - auto firstPersonTranslateCamera = - AZStd::make_shared(AzFramework::LookTranslation, translateCameraInputChannels); - firstPersonTranslateCamera->m_translateSpeedFn = [] - { - return SandboxEditor::CameraTranslateSpeed(); - }; - firstPersonTranslateCamera->m_boostMultiplierFn = [] - { - return SandboxEditor::CameraBoostMultiplier(); - }; - - auto firstPersonWheelCamera = AZStd::make_shared(); - firstPersonWheelCamera->m_scrollSpeedFn = [] - { - return SandboxEditor::CameraScrollSpeed(); - }; - - auto orbitCamera = AZStd::make_shared(SandboxEditor::CameraOrbitChannelId()); - orbitCamera->SetLookAtFn( - [viewportId](const AZ::Vector3& position, const AZ::Vector3& direction) -> AZStd::optional - { - 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 - if (lookAtAfterInterpolation.has_value()) - { - 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; - - 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 {}; - }); - - auto orbitRotateCamera = AZStd::make_shared(SandboxEditor::CameraOrbitLookChannelId()); - orbitRotateCamera->m_rotateSpeedFn = [] - { - return SandboxEditor::CameraRotateSpeed(); - }; - orbitRotateCamera->m_invertYawFn = [] - { - return SandboxEditor::CameraOrbitYawRotationInverted(); - }; - - auto orbitTranslateCamera = - AZStd::make_shared(AzFramework::OrbitTranslation, translateCameraInputChannels); - orbitTranslateCamera->m_translateSpeedFn = [] - { - return SandboxEditor::CameraTranslateSpeed(); - }; - orbitTranslateCamera->m_boostMultiplierFn = [] - { - return SandboxEditor::CameraBoostMultiplier(); - }; - - auto orbitDollyWheelCamera = AZStd::make_shared(); - orbitDollyWheelCamera->m_scrollSpeedFn = [] - { - return SandboxEditor::CameraScrollSpeed(); - }; - - auto orbitDollyMoveCamera = - AZStd::make_shared(SandboxEditor::CameraOrbitDollyChannelId()); - orbitDollyMoveCamera->m_cursorSpeedFn = [] - { - return SandboxEditor::CameraDollyMotionSpeed(); - }; - - auto orbitPanCamera = AZStd::make_shared(SandboxEditor::CameraOrbitPanChannelId(), AzFramework::OrbitPan); - orbitPanCamera->m_panSpeedFn = [] - { - return SandboxEditor::CameraPanSpeed(); - }; - orbitPanCamera->m_invertPanXFn = [] - { - return SandboxEditor::CameraPanInvertedX(); - }; - orbitPanCamera->m_invertPanYFn = [] - { - return SandboxEditor::CameraPanInvertedY(); - }; - - orbitCamera->m_orbitCameras.AddCamera(orbitRotateCamera); - orbitCamera->m_orbitCameras.AddCamera(orbitTranslateCamera); - orbitCamera->m_orbitCameras.AddCamera(orbitDollyWheelCamera); - orbitCamera->m_orbitCameras.AddCamera(orbitDollyMoveCamera); - orbitCamera->m_orbitCameras.AddCamera(orbitPanCamera); - - cameras.AddCamera(firstPersonRotateCamera); - cameras.AddCamera(firstPersonPanCamera); - cameras.AddCamera(firstPersonTranslateCamera); - cameras.AddCamera(firstPersonWheelCamera); - cameras.AddCamera(orbitCamera); - }); - - return controller; -} - void EditorViewportWidget::SetViewportId(int id) { CViewport::SetViewportId(id); @@ -1282,8 +1073,9 @@ void EditorViewportWidget::SetViewportId(int id) m_renderViewport->GetControllerList()->Add(AZStd::make_shared()); - m_renderViewport->GetControllerList()->Add(CreateModularViewportCameraController(AzFramework::ViewportId(id))); - + m_editorModularViewportCameraComposer = AZStd::make_unique(AzFramework::ViewportId(id)); + m_renderViewport->GetControllerList()->Add(m_editorModularViewportCameraComposer->CreateModularViewportCameraController()); + m_renderViewport->SetViewportSettings(&g_EditorViewportSettings); UpdateScene(); @@ -1643,7 +1435,7 @@ void EditorViewportWidget::SetViewTM(const Matrix34& camMatrix, bool bMoveOnly) { // Should be impossible anyways AZ_Assert(false, "Internal logic error - view entity Id and view source type out of sync. Please report this as a bug"); - return ShouldUpdateObject::No; + return ShouldUpdateObject::No; } // Check that the current view is the same view as the view entity view @@ -1970,12 +1762,12 @@ Vec3 EditorViewportWidget::ViewToWorld( { AZ_PROFILE_FUNCTION(Editor); - AZ_UNUSED(collideWithTerrain) - AZ_UNUSED(onlyTerrain) - AZ_UNUSED(bTestRenderMesh) - AZ_UNUSED(bSkipVegetation) - AZ_UNUSED(bSkipVegetation) - AZ_UNUSED(collideWithObject) + AZ_UNUSED(collideWithTerrain); + AZ_UNUSED(onlyTerrain); + AZ_UNUSED(bTestRenderMesh); + AZ_UNUSED(bSkipVegetation); + AZ_UNUSED(bSkipVegetation); + AZ_UNUSED(collideWithObject); auto ray = m_renderViewport->ViewportScreenToWorldRay(AzToolsFramework::ViewportInteraction::ScreenPointFromQPoint(vp)); if (!ray.has_value()) @@ -1999,82 +1791,15 @@ Vec3 EditorViewportWidget::ViewToWorld( ////////////////////////////////////////////////////////////////////////// Vec3 EditorViewportWidget::ViewToWorldNormal(const QPoint& vp, bool onlyTerrain, bool bTestRenderMesh) { - AZ_UNUSED(vp) - AZ_UNUSED(onlyTerrain) - AZ_UNUSED(bTestRenderMesh) + AZ_UNUSED(vp); + AZ_UNUSED(onlyTerrain); + AZ_UNUSED(bTestRenderMesh); AZ_PROFILE_FUNCTION(Editor); return Vec3(0, 0, 1); } -////////////////////////////////////////////////////////////////////////// -bool EditorViewportWidget::AdjustObjectPosition(const ray_hit& hit, Vec3& outNormal, Vec3& outPos) const -{ - Matrix34A objMat, objMatInv; - Matrix33 objRot, objRotInv; - - if (hit.pCollider->GetiForeignData() != PHYS_FOREIGN_ID_STATIC) - { - return false; - } - - IRenderNode* pNode = (IRenderNode*) hit.pCollider->GetForeignData(PHYS_FOREIGN_ID_STATIC); - if (!pNode || !pNode->GetEntityStatObj()) - { - return false; - } - - IStatObj* pEntObject = pNode->GetEntityStatObj(hit.partid, 0, &objMat, false); - if (!pEntObject || !pEntObject->GetRenderMesh()) - { - return false; - } - - objRot = Matrix33(objMat); - objRot.NoScale(); // No scale. - objRotInv = objRot; - objRotInv.Invert(); - - float fWorldScale = objMat.GetColumn(0).GetLength(); // GetScale - float fWorldScaleInv = 1.0f / fWorldScale; - - // transform decal into object space - objMatInv = objMat; - objMatInv.Invert(); - - // put into normal object space hit direction of projection - Vec3 invhitn = -(hit.n); - Vec3 vOS_HitDir = objRotInv.TransformVector(invhitn).GetNormalized(); - - // put into position object space hit position - Vec3 vOS_HitPos = objMatInv.TransformPoint(hit.pt); - vOS_HitPos -= vOS_HitDir * RENDER_MESH_TEST_DISTANCE * fWorldScaleInv; - - IRenderMesh* pRM = pEntObject->GetRenderMesh(); - - AABB aabbRNode; - pRM->GetBBox(aabbRNode.min, aabbRNode.max); - Vec3 vOut(0, 0, 0); - if (!Intersect::Ray_AABB(Ray(vOS_HitPos, vOS_HitDir), aabbRNode, vOut)) - { - return false; - } - - if (!pRM || !pRM->GetVerticesCount()) - { - return false; - } - - if (RayRenderMeshIntersection(pRM, vOS_HitPos, vOS_HitDir, outPos, outNormal)) - { - outNormal = objRot.TransformVector(outNormal).GetNormalized(); - outPos = objMat.TransformPoint(outPos); - return true; - } - return false; -} - ////////////////////////////////////////////////////////////////////////// bool EditorViewportWidget::RayRenderMeshIntersection(IRenderMesh* pRenderMesh, const Vec3& vInPos, const Vec3& vInDir, Vec3& vOutPos, Vec3& vOutNormal) const { @@ -2507,7 +2232,7 @@ void EditorViewportWidget::SetViewFromEntityPerspective(const AZ::EntityId& enti void EditorViewportWidget::SetViewAndMovementLockFromEntityPerspective(const AZ::EntityId& entityId, [[maybe_unused]] bool lockCameraMovement) { // This is an editor event, so is only serviced during edit mode, not play game mode - // + // if (m_playInEditorState != PlayInEditorState::Editor) { AZ_Warning("EditorViewportWidget", false, diff --git a/Code/Editor/EditorViewportWidget.h b/Code/Editor/EditorViewportWidget.h index a75928b353..9da5e3f9a1 100644 --- a/Code/Editor/EditorViewportWidget.h +++ b/Code/Editor/EditorViewportWidget.h @@ -19,6 +19,7 @@ #include "Undo/Undo.h" #include "Util/PredefinedAspectRatios.h" #include "EditorViewportSettings.h" +#include "EditorModularViewportCameraComposer.h" #include #include @@ -220,7 +221,6 @@ private: // Draw a selected region if it has been selected void RenderSelectedRegion(); - bool AdjustObjectPosition(const ray_hit& hit, Vec3& outNormal, Vec3& outPos) const; bool RayRenderMeshIntersection(IRenderMesh* pRenderMesh, const Vec3& vInPos, const Vec3& vInDir, Vec3& vOutPos, Vec3& vOutNormal) const; bool AddCameraMenuItems(QMenu* menu); @@ -370,6 +370,8 @@ private: // This widget holds a reference to the manipulator manage because its responsible for drawing manipulators AZStd::shared_ptr m_manipulatorManager; + AZStd::unique_ptr m_editorModularViewportCameraComposer; + // Helper for getting EditorEntityNotificationBus events AZStd::unique_ptr m_editorEntityNotifications; @@ -390,7 +392,3 @@ private: AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING }; - -//! Creates a modular camera controller in the configuration used by the editor viewport. -SANDBOX_API AZStd::shared_ptr CreateModularViewportCameraController( - const AzFramework::ViewportId viewportId); diff --git a/Code/Editor/Export/ExportManager.cpp b/Code/Editor/Export/ExportManager.cpp index 7601740033..220c341f5c 100644 --- a/Code/Editor/Export/ExportManager.cpp +++ b/Code/Editor/Export/ExportManager.cpp @@ -622,7 +622,7 @@ bool CExportManager::ShowFBXExportDialog() if (pivotObjectNode && !pivotObjectNode->IsGroupNode()) { - m_pivotEntityObject = static_cast(GetIEditor()->GetObjectManager()->FindObject(pivotObjectNode->GetName())); + m_pivotEntityObject = static_cast(GetIEditor()->GetObjectManager()->FindObject(pivotObjectNode->GetName().c_str())); if (m_pivotEntityObject) { @@ -807,7 +807,7 @@ void CExportManager::FillAnimTimeNode(XmlNodeRef writeNode, CTrackViewAnimNode* if (numAllTracks > 0) { - XmlNodeRef objNode = writeNode->createNode(CleanXMLText(pObjectNode->GetName()).toUtf8().data()); + XmlNodeRef objNode = writeNode->createNode(CleanXMLText(pObjectNode->GetName().c_str()).toUtf8().data()); writeNode->setAttr("time", m_animTimeExportPrimarySequenceCurrentTime); for (unsigned int trackID = 0; trackID < numAllTracks; ++trackID) @@ -818,7 +818,7 @@ void CExportManager::FillAnimTimeNode(XmlNodeRef writeNode, CTrackViewAnimNode* if (trackType == AnimParamType::Animation || trackType == AnimParamType::Sound) { - QString childName = CleanXMLText(childTrack->GetName()); + QString childName = CleanXMLText(childTrack->GetName().c_str()); if (childName.isEmpty()) { @@ -976,7 +976,7 @@ bool CExportManager::AddObjectsFromSequence(CTrackViewSequence* pSequence, XmlNo else { // In case of exporting animation/sound times data - const QString sequenceName = pSubSequence->GetName(); + const QString sequenceName = QString::fromUtf8(pSubSequence->GetName().c_str()); XmlNodeRef subSeqNode2 = seqNode->createNode(sequenceName.toUtf8().data()); if (sequenceName == m_animTimeExportPrimarySequenceName) @@ -1253,14 +1253,14 @@ void CExportManager::SaveNodeKeysTimeToXML() m_soundKeyTimeExport = exportDialog.IsSoundExportChecked(); QString filters = "All files (*.xml)"; - QString defaultName = QString(pSequence->GetName()) + ".xml"; + QString defaultName = QString::fromUtf8(pSequence->GetName().c_str()) + ".xml"; QtUtil::QtMFCScopedHWNDCapture cap; CAutoDirectoryRestoreFileDialog dlg(QFileDialog::AcceptSave, QFileDialog::AnyFile, "xml", defaultName, filters, {}, {}, cap); if (dlg.exec()) { - m_animTimeNode = XmlHelpers::CreateXmlNode(pSequence->GetName()); - m_animTimeExportPrimarySequenceName = pSequence->GetName(); + m_animTimeNode = XmlHelpers::CreateXmlNode(pSequence->GetName().c_str()); + m_animTimeExportPrimarySequenceName = QString::fromUtf8(pSequence->GetName().c_str()); m_data.Clear(); m_animTimeExportPrimarySequenceCurrentTime = 0.0; diff --git a/Code/Editor/FBXExporterDialog.cpp b/Code/Editor/FBXExporterDialog.cpp index bae4b9bf7e..b080362b97 100644 --- a/Code/Editor/FBXExporterDialog.cpp +++ b/Code/Editor/FBXExporterDialog.cpp @@ -17,12 +17,6 @@ AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING #include AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING - -namespace -{ - const uint kDefaultFPS = 30u; -} - CFBXExporterDialog::CFBXExporterDialog(bool bDisplayOnlyFPSSetting, QWidget* pParent) : QDialog(pParent) , m_ui(new Ui::FBXExporterDialog) diff --git a/Code/Editor/GameEngine.cpp b/Code/Editor/GameEngine.cpp index 137d14c844..4b463efe0a 100644 --- a/Code/Editor/GameEngine.cpp +++ b/Code/Editor/GameEngine.cpp @@ -497,8 +497,7 @@ bool CGameEngine::LoadLevel( [[maybe_unused]] bool bDeleteAIGraph, bool bReleaseResources) { - LOADING_TIME_PROFILE_SECTION(GetIEditor()->GetSystem()); - m_bLevelLoaded = false; + m_bLevelLoaded = false; CLogFile::FormatLine("Loading map '%s' into engine...", m_levelPath.toUtf8().data()); // Switch the current directory back to the Primary CD folder first. // The engine might have trouble to find some files when the current diff --git a/Code/Editor/GameExporter.h b/Code/Editor/GameExporter.h index 3e3c57fb4c..19ec601ff7 100644 --- a/Code/Editor/GameExporter.h +++ b/Code/Editor/GameExporter.h @@ -102,7 +102,6 @@ private: AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING bool m_bAutoExportMode; - int m_numExportedMaterials; static CGameExporter* m_pCurrentExporter; }; diff --git a/Code/Editor/IconManager.cpp b/Code/Editor/IconManager.cpp index dc9eb56b88..7732ae8155 100644 --- a/Code/Editor/IconManager.cpp +++ b/Code/Editor/IconManager.cpp @@ -27,19 +27,6 @@ namespace { - // Object names in this array must correspond to EObject enumeration. - const char* g_ObjectNames[eStatObject_COUNT] = - { - "Objects/Arrow.cgf", - "Objects/Axis.cgf", - "Objects/Sphere.cgf", - "Objects/Anchor.cgf", - "Objects/entrypoint.cgf", - "Objects/hidepoint.cgf", - "Objects/hidepoint_sec.cgf", - "Objects/reinforcement_point.cgf", - }; - const char* g_IconNames[eIcon_COUNT] = { "Icons/ScaleWarning.png", diff --git a/Code/Editor/IconManager.h b/Code/Editor/IconManager.h index d6684f4cc3..7183f036ed 100644 --- a/Code/Editor/IconManager.h +++ b/Code/Editor/IconManager.h @@ -15,9 +15,6 @@ #pragma once -struct IStatObj; -struct IMaterial; - #include "Include/IIconManager.h" // for IIconManager #include "IEditor.h" // for IDocListener diff --git a/Code/Editor/Include/IEditorMaterial.h b/Code/Editor/Include/IEditorMaterial.h index a117020d19..487246eb60 100644 --- a/Code/Editor/Include/IEditorMaterial.h +++ b/Code/Editor/Include/IEditorMaterial.h @@ -6,8 +6,6 @@ * */ #pragma once -#ifndef CRYINCLUDE_EDITOR_INCLUDE_IEDITORMATERIAL_H -#define CRYINCLUDE_EDITOR_INCLUDE_IEDITORMATERIAL_H #include "BaseLibraryItem.h" @@ -20,5 +18,3 @@ struct IEditorMaterial virtual _smart_ptr GetMatInfo(bool bUseExistingEngineMaterial = false) = 0; virtual void DisableHighlightForFrame() = 0; }; - -#endif diff --git a/Code/Editor/Include/ISubObjectSelectionReferenceFrameCalculator.h b/Code/Editor/Include/ISubObjectSelectionReferenceFrameCalculator.h deleted file mode 100644 index ff82b57de1..0000000000 --- a/Code/Editor/Include/ISubObjectSelectionReferenceFrameCalculator.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - - -// Description : Calculate the reference frame for sub-object selections. - - -#ifndef CRYINCLUDE_EDITOR_INCLUDE_ISUBOBJECTSELECTIONREFERENCEFRAMECALCULATOR_H -#define CRYINCLUDE_EDITOR_INCLUDE_ISUBOBJECTSELECTIONREFERENCEFRAMECALCULATOR_H -#pragma once - - -class ISubObjectSelectionReferenceFrameCalculator -{ -public: - virtual void SetExplicitFrame(bool bAnySelected, const Matrix34& refFrame) = 0; -}; - -#endif // CRYINCLUDE_EDITOR_INCLUDE_ISUBOBJECTSELECTIONREFERENCEFRAMECALCULATOR_H diff --git a/Code/Editor/LayoutWnd.cpp b/Code/Editor/LayoutWnd.cpp index 7f73c313d9..aa2a008844 100644 --- a/Code/Editor/LayoutWnd.cpp +++ b/Code/Editor/LayoutWnd.cpp @@ -183,7 +183,6 @@ void CLayoutWnd::MaximizeViewport(int paneId) QString viewClass = m_viewType[paneId]; - const QRect rc = rect(); if (!m_bMaximized) { CLayoutViewPane* pViewPane = GetViewPane(paneId); diff --git a/Code/Editor/LevelFileDialog.cpp b/Code/Editor/LevelFileDialog.cpp index c0c2b96c59..3f3077a2c4 100644 --- a/Code/Editor/LevelFileDialog.cpp +++ b/Code/Editor/LevelFileDialog.cpp @@ -32,22 +32,6 @@ static const char lastLoadPathFilename[] = "lastLoadPath.preset"; // Folder in which levels are stored static const char kLevelsFolder[] = "Levels"; -// List of folder names that are used to detect a level folder -static const char* kLevelFolderNames[] = -{ - "Layers", - "Minimap", - "LevelData" -}; - -// List of files that are used to detect a level folder -static const char* kLevelFileNames[] = -{ - "level.pak", - "filelist.xml", - "levelshadercache.pak", -}; - CLevelFileDialog::CLevelFileDialog(bool openDialog, QWidget* parent) : QDialog(parent) , m_bOpenDialog(openDialog) diff --git a/Code/Editor/LevelFileDialog.h b/Code/Editor/LevelFileDialog.h index 93d8e4eb9b..6347eb946a 100644 --- a/Code/Editor/LevelFileDialog.h +++ b/Code/Editor/LevelFileDialog.h @@ -64,7 +64,6 @@ private: QString m_fileName; QString m_filter; const bool m_bOpenDialog; - bool m_initialized = false; LevelTreeModel* const m_model; LevelTreeModelFilter* const m_filterModel; }; diff --git a/Code/Editor/Lib/Tests/test_ModularViewportCameraController.cpp b/Code/Editor/Lib/Tests/test_ModularViewportCameraController.cpp index 7309110c4d..ce5564c7f6 100644 --- a/Code/Editor/Lib/Tests/test_ModularViewportCameraController.cpp +++ b/Code/Editor/Lib/Tests/test_ModularViewportCameraController.cpp @@ -139,7 +139,8 @@ namespace UnitTest m_viewportMouseCursorRequests.Connect(TestViewportId, m_inputChannelMapper.get()); // create editor modular camera - auto controller = CreateModularViewportCameraController(TestViewportId); + m_editorModularViewportCameraComposer = AZStd::make_unique(TestViewportId); + auto controller = m_editorModularViewportCameraComposer->CreateModularViewportCameraController(); // set some overrides for the test controller->SetCameraViewportContextBuilderCallback( @@ -169,6 +170,7 @@ namespace UnitTest void HaltCollaborators() { + m_editorModularViewportCameraComposer.reset(); m_mockWindowRequests.Disconnect(); m_viewportMouseCursorRequests.Disconnect(); m_cameraViewportContextView = nullptr; @@ -212,6 +214,7 @@ namespace UnitTest ViewportMouseCursorRequestImpl m_viewportMouseCursorRequests; AtomToolsFramework::ModularCameraViewportContext* m_cameraViewportContextView = nullptr; AZStd::unique_ptr m_settingsRegistry; + AZStd::unique_ptr m_editorModularViewportCameraComposer; }; const AzFramework::ViewportId ModularViewportCameraControllerFixture::TestViewportId = AzFramework::ViewportId(0); diff --git a/Code/Editor/LogFile.cpp b/Code/Editor/LogFile.cpp index 5978356781..92186901d7 100644 --- a/Code/Editor/LogFile.cpp +++ b/Code/Editor/LogFile.cpp @@ -179,19 +179,17 @@ void CLogFile::FormatLineV(const char * format, va_list argList) void CLogFile::AboutSystem() { - char szBuffer[MAX_LOGBUFFER_SIZE]; - wchar_t szBufferW[MAX_LOGBUFFER_SIZE]; #if defined(AZ_PLATFORM_WINDOWS) || defined(AZ_PLATFORM_LINUX) ////////////////////////////////////////////////////////////////////// // Write the system informations to the log ////////////////////////////////////////////////////////////////////// - - wchar_t szLanguageBufferW[64]; + char szBuffer[MAX_LOGBUFFER_SIZE]; //wchar_t szCPUModel[64]; MEMORYSTATUS MemoryStatus; #endif // defined(AZ_PLATFORM_WINDOWS) || defined(AZ_PLATFORM_LINUX) #if defined(AZ_PLATFORM_WINDOWS) + wchar_t szLanguageBufferW[64]; DEVMODE DisplayConfig; OSVERSIONINFO OSVerInfo; OSVerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); @@ -288,7 +286,7 @@ AZ_POP_DISABLE_WARNING str += "Version Unknown"; } } - azsnprintf(szBuffer, MAX_LOGBUFFER_SIZE, " %d.%d", OSVerInfo.dwMajorVersion, OSVerInfo.dwMinorVersion); + azsnprintf(szBuffer, MAX_LOGBUFFER_SIZE, " %ld.%ld", OSVerInfo.dwMajorVersion, OSVerInfo.dwMinorVersion); str += szBuffer; ////////////////////////////////////////////////////////////////////// @@ -296,6 +294,7 @@ AZ_POP_DISABLE_WARNING ////////////////////////////////////////////////////////////////////// str += " ("; + wchar_t szBufferW[MAX_LOGBUFFER_SIZE]; GetWindowsDirectoryW(szBufferW, sizeof(szBufferW)); AZStd::to_string(szBuffer, MAX_LOGBUFFER_SIZE, szBufferW); str += szBuffer; @@ -338,7 +337,7 @@ AZ_POP_DISABLE_WARNING str += " "; azstrdate(szBuffer); str += szBuffer; - azsnprintf(szBuffer, MAX_LOGBUFFER_SIZE, ", system running for %d minutes", GetTickCount() / 60000); + azsnprintf(szBuffer, MAX_LOGBUFFER_SIZE, ", system running for %ld minutes", GetTickCount() / 60000); str += szBuffer; CryLog("%s", str.toUtf8().data()); #else @@ -388,7 +387,7 @@ AZ_POP_DISABLE_WARNING L"(Unknown graphics card)", szLanguageBufferW, sizeof(szLanguageBufferW), L"system.ini"); AZStd::to_string(szLanguageBuffer, szLanguageBufferW); - azsnprintf(szBuffer, MAX_LOGBUFFER_SIZE, "Current display mode is %dx%dx%d, %s", + azsnprintf(szBuffer, MAX_LOGBUFFER_SIZE, "Current display mode is %ldx%ldx%ld, %s", DisplayConfig.dmPelsWidth, DisplayConfig.dmPelsHeight, DisplayConfig.dmBitsPerPel, szLanguageBuffer.c_str()); CryLog("%s", szBuffer); diff --git a/Code/Editor/MainStatusBar.cpp b/Code/Editor/MainStatusBar.cpp index a1e51ec553..f955035bd8 100644 --- a/Code/Editor/MainStatusBar.cpp +++ b/Code/Editor/MainStatusBar.cpp @@ -15,6 +15,7 @@ // AzQtComponents #include #include +#include // Qt #include @@ -209,7 +210,7 @@ MainStatusBar::MainStatusBar(QWidget* parent) addPermanentWidget(new StatusBarItem(QStringLiteral("connection"), true, this, true), 1); - addPermanentWidget(new StatusBarItem(QStringLiteral("game_info"), this, true), 1); + addPermanentWidget(new GameInfoItem(QStringLiteral("game_info"), this), 1); addPermanentWidget(new MemoryStatusItem(QStringLiteral("memory"), this), 1); } @@ -221,11 +222,6 @@ void MainStatusBar::Init() 500 }; //in ms, so 2 FPS - AZ::IO::FixedMaxPathString projectPath = AZ::Utils::GetProjectPath(); - QString strGameInfo; - strGameInfo = tr("GameFolder: '%1'").arg(projectPath.c_str()); - SetItem(QStringLiteral("game_info"), strGameInfo, tr("Game Info"), QPixmap()); - //ask for updates for items regularly. This is basically what MFC does auto timer = new QTimer(this); timer->setInterval(statusbarTimerUpdateInterval); @@ -436,5 +432,29 @@ QString GeneralStatusItem::CurrentText() const return StatusBarItem::CurrentText(); } +GameInfoItem::GameInfoItem(QString name, MainStatusBar* parent) + : StatusBarItem(name, parent, true) +{ + m_projectPath = QString::fromUtf8(AZ::Utils::GetProjectPath().c_str()); + + SetText(QObject::tr("GameFolder: '%1'").arg(m_projectPath)); + SetToolTip(QObject::tr("Game Info")); + + setContextMenuPolicy(Qt::CustomContextMenu); + QObject::connect(this, &QWidget::customContextMenuRequested, this, &GameInfoItem::OnShowContextMenu); +} + +void GameInfoItem::OnShowContextMenu(const QPoint& pos) +{ + QMenu contextMenu(this); + + // Context menu action to open the project folder in file browser + contextMenu.addAction(AzQtComponents::fileBrowserActionName(), this, [this]() { + AzQtComponents::ShowFileOnDesktop(m_projectPath); + }); + + contextMenu.exec(mapToGlobal(pos)); +} + #include #include diff --git a/Code/Editor/MainStatusBarItems.h b/Code/Editor/MainStatusBarItems.h index 2a3a21e72a..5f8d618dca 100644 --- a/Code/Editor/MainStatusBarItems.h +++ b/Code/Editor/MainStatusBarItems.h @@ -71,3 +71,17 @@ public: private: void updateStatus(); }; + +class GameInfoItem + : public StatusBarItem +{ + Q_OBJECT +public: + GameInfoItem(QString name, MainStatusBar* parent); + +private Q_SLOTS: + void OnShowContextMenu(const QPoint& pos); + +private: + QString m_projectPath; +}; diff --git a/Code/Editor/MainWindow.cpp b/Code/Editor/MainWindow.cpp index fa2e792cc8..beb338b732 100644 --- a/Code/Editor/MainWindow.cpp +++ b/Code/Editor/MainWindow.cpp @@ -108,12 +108,6 @@ using namespace AzToolsFramework; #define LAYOUTS_WILDCARD "*.layout" #define DUMMY_LAYOUT_NAME "Dummy_Layout" -static const char* g_openViewPaneEventName = "OpenViewPaneEvent"; //Sent when users open view panes; -static const char* g_viewPaneAttributeName = "ViewPaneName"; //Name of the current view pane -static const char* g_openLocationAttributeName = "OpenLocation"; //Indicates where the current view pane is opened from - -static const char* g_assetImporterName = "AssetImporter"; - class CEditorOpenViewCommand : public _i_reference_target_t { @@ -303,7 +297,7 @@ MainWindow::MainWindow(QWidget* parent) , m_settings("O3DE", "O3DE") , m_toolbarManager(new ToolbarManager(m_actionManager, this)) , m_assetImporterManager(new AssetImporterManager(this)) - , m_levelEditorMenuHandler(new LevelEditorMenuHandler(this, m_viewPaneManager, m_settings)) + , m_levelEditorMenuHandler(new LevelEditorMenuHandler(this, m_viewPaneManager)) , m_sourceControlNotifHandler(new AzToolsFramework::QtSourceControlNotificationHandler(this)) , m_viewPaneHost(nullptr) , m_autoSaveTimer(nullptr) diff --git a/Code/Editor/Objects/BaseObject.h b/Code/Editor/Objects/BaseObject.h index 47dba99ab7..ece0bf67c3 100644 --- a/Code/Editor/Objects/BaseObject.h +++ b/Code/Editor/Objects/BaseObject.h @@ -33,7 +33,6 @@ class CGizmo; class CObjectArchive; struct SSubObjSelectionModifyContext; struct SRayHitInfo; -class ISubObjectSelectionReferenceFrameCalculator; class CPopupMenuItem; class QMenu; struct IRenderNode; @@ -571,7 +570,6 @@ public: // Return true if object support selecting of this sub object element type. virtual bool StartSubObjSelection([[maybe_unused]] int elemType) { return false; }; virtual void EndSubObjectSelection() {}; - virtual void CalculateSubObjectSelectionReferenceFrame([[maybe_unused]] ISubObjectSelectionReferenceFrameCalculator* pCalculator) { }; virtual void ModifySubObjSelection([[maybe_unused]] SSubObjSelectionModifyContext& modCtx) {}; virtual void AcceptSubObjectModify() {}; diff --git a/Code/Editor/Objects/DisplayContext.h b/Code/Editor/Objects/DisplayContext.h index 47fd450220..a78e35cdba 100644 --- a/Code/Editor/Objects/DisplayContext.h +++ b/Code/Editor/Objects/DisplayContext.h @@ -63,7 +63,6 @@ struct SANDBOX_API DisplayContext CDisplaySettings* settings; IDisplayViewport* view; - IRenderer* renderer; IRenderAuxGeom* pRenderAuxGeom; IIconManager* pIconManager; CCamera* camera; diff --git a/Code/Editor/Objects/DisplayContextShared.inl b/Code/Editor/Objects/DisplayContextShared.inl index 90c6ba09b0..df0b1f82a1 100644 --- a/Code/Editor/Objects/DisplayContextShared.inl +++ b/Code/Editor/Objects/DisplayContextShared.inl @@ -26,7 +26,6 @@ DisplayContext::DisplayContext() { view = 0; - renderer = 0; flags = 0; settings = 0; pIconManager = 0; @@ -1083,7 +1082,10 @@ void DisplayContext::DrawTerrainLine(Vec3 worldPos1, Vec3 worldPos2) ////////////////////////////////////////////////////////////////////////// void DisplayContext::DrawTextLabel(const Vec3& pos, float size, const char* text, const bool bCenter, [[maybe_unused]] int srcOffsetX, [[maybe_unused]] int scrOffsetY) { - ColorF col(m_color4b.r * (1.0f / 255.0f), m_color4b.g * (1.0f / 255.0f), m_color4b.b * (1.0f / 255.0f), m_color4b.a * (1.0f / 255.0f)); + AZ_ErrorOnce(nullptr, false, "DisplayContext::DrawTextLabel needs to be removed/ported to use Atom"); + +#if 0 + ColorF col(m_color4b.r * (1.0f / 255.0f), m_color4b.g * (1.0f / 255.0f), m_color4b.b * (1.0f / 255.0f), m_color4b.a * (1.0f / 255.0f)); float fCol[4] = { col.r, col.g, col.b, col.a }; if (flags & DISPLAY_2D) @@ -1096,13 +1098,28 @@ void DisplayContext::DrawTextLabel(const Vec3& pos, float size, const char* text { renderer->DrawLabelEx(pos, size, fCol, true, true, text); } +#else + AZ_UNUSED(pos); + AZ_UNUSED(size); + AZ_UNUSED(text); + AZ_UNUSED(bCenter); +#endif } ////////////////////////////////////////////////////////////////////////// void DisplayContext::Draw2dTextLabel(float x, float y, float size, const char* text, bool bCenter) { + AZ_ErrorOnce(nullptr, false, "DisplayContext::Draw2dTextLabel needs to be removed/ported to use Atom"); +#if 0 float col[4] = { m_color4b.r * (1.0f / 255.0f), m_color4b.g * (1.0f / 255.0f), m_color4b.b * (1.0f / 255.0f), m_color4b.a * (1.0f / 255.0f) }; renderer->Draw2dLabel(x, y, size, col, bCenter, "%s", text); +#else + AZ_UNUSED(x); + AZ_UNUSED(y); + AZ_UNUSED(size); + AZ_UNUSED(text); + AZ_UNUSED(bCenter); +#endif } ////////////////////////////////////////////////////////////////////////// @@ -1269,6 +1286,9 @@ void DisplayContext::Flush2D() int rcw, rch; view->GetDimensions(&rcw, &rch); + AZ_ErrorOnce(nullptr, false, "DisplayContext::Flush2D needs to be removed/ported to use Atom"); +#if 0 + TransformationMatrices backupSceneMatrices; renderer->Set2DMode(rcw, rch, backupSceneMatrices, 0.0f, 1.0f); @@ -1310,6 +1330,7 @@ void DisplayContext::Flush2D() } renderer->Unset2DMode(backupSceneMatrices); +#endif m_textureLabels.clear(); } diff --git a/Code/Editor/Objects/ObjectManager.cpp b/Code/Editor/Objects/ObjectManager.cpp index aec5835565..f8eebb1b19 100644 --- a/Code/Editor/Objects/ObjectManager.cpp +++ b/Code/Editor/Objects/ObjectManager.cpp @@ -1555,11 +1555,8 @@ void CObjectManager::DeleteSelection() // Make sure to unlock selection. GetIEditor()->LockSelection(false); - GUID bID = GUID_NULL; - - int i; CSelectionGroup objects; - for (i = 0; i < m_currSelection->GetCount(); i++) + for (int i = 0; i < m_currSelection->GetCount(); i++) { // Check condition(s) if object could be deleted if (!IsObjectDeletionAllowed(m_currSelection->GetObject(i))) @@ -2899,17 +2896,6 @@ namespace return AZ::Vector3(position.x, position.y, position.z); } - AZ::Vector3 PyGetWorldObjectPosition(const char* pName) - { - CBaseObject* pObject = GetIEditor()->GetObjectManager()->FindObject(pName); - if (!pObject) - { - throw std::logic_error((QString("\"") + pName + "\" is an invalid object.").toUtf8().data()); - } - Vec3 position = pObject->GetWorldPos(); - return AZ::Vector3(position.x, position.y, position.z); - } - void PySetObjectPosition(const char* pName, float fValueX, float fValueY, float fValueZ) { CBaseObject* pObject = GetIEditor()->GetObjectManager()->FindObject(pName); diff --git a/Code/Editor/Objects/SelectionGroup.cpp b/Code/Editor/Objects/SelectionGroup.cpp index f2b7b9ddaf..06d881d607 100644 --- a/Code/Editor/Objects/SelectionGroup.cpp +++ b/Code/Editor/Objects/SelectionGroup.cpp @@ -316,8 +316,6 @@ void CSelectionGroup::Rotate(const Ang3& angles, int referenceCoordSys) // return; // Rotate selection about selection center. - Vec3 center = GetCenter(); - Matrix34 rotateTM = Matrix34::CreateRotationXYZ(DEG2RAD(angles)); Rotate(rotateTM, referenceCoordSys); } diff --git a/Code/Editor/Objects/TrackGizmo.cpp b/Code/Editor/Objects/TrackGizmo.cpp index 8cbd7df2e5..3b753e737a 100644 --- a/Code/Editor/Objects/TrackGizmo.cpp +++ b/Code/Editor/Objects/TrackGizmo.cpp @@ -27,9 +27,11 @@ ////////////////////////////////////////////////////////////////////////// #define AXIS_SIZE 0.1f +#if 0 namespace { int s_highlightAxis = 0; } +#endif ////////////////////////////////////////////////////////////////////////// CTrackGizmo::CTrackGizmo() @@ -175,13 +177,15 @@ void CTrackGizmo::DrawAxis(DisplayContext& dc, const Vec3& org) y = y * fScreenScale; z = z * fScreenScale; + Vec3 colX(1, 0, 0), colY(0, 1, 0), colZ(0, 0, 1); + + AZ_ErrorOnce(nullptr, false, "CTrackGizmo::DrawAxis needs to be removed/ported to use Atom"); +#if 0 float col[4] = { 1, 1, 1, 1 }; - float hcol[4] = { 1, 0, 0, 1 }; dc.renderer->DrawLabelEx(org + x, 1.2f, col, true, true, "X"); dc.renderer->DrawLabelEx(org + y, 1.2f, col, true, true, "Y"); dc.renderer->DrawLabelEx(org + z, 1.2f, col, true, true, "Z"); - Vec3 colX(1, 0, 0), colY(0, 1, 0), colZ(0, 0, 1); if (s_highlightAxis) { float col2[4] = { 1, 0, 0, 1 }; @@ -201,6 +205,7 @@ void CTrackGizmo::DrawAxis(DisplayContext& dc, const Vec3& org) dc.renderer->DrawLabelEx(org + z, 1.2f, col2, true, true, "Z"); } } +#endif x = x * 0.8f; y = y * 0.8f; diff --git a/Code/Editor/Platform/Mac/main_dummy.cpp b/Code/Editor/Platform/Mac/main_dummy.cpp index fb4a431295..814cbfde66 100644 --- a/Code/Editor/Platform/Mac/main_dummy.cpp +++ b/Code/Editor/Platform/Mac/main_dummy.cpp @@ -66,8 +66,8 @@ int main(int argc, char* argv[]) processLaunchInfo.m_environmentVariables = &envVars; processLaunchInfo.m_showWindow = true; - AzFramework::ProcessWatcher* processWatcher = AzFramework::ProcessWatcher::LaunchProcess(processLaunchInfo, AzFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_NONE); - + AZStd::unique_ptr processWatcher(AzFramework::ProcessWatcher::LaunchProcess(processLaunchInfo, AzFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_NONE)); + application.Destroy(); return 0; diff --git a/Code/Editor/Plugin.h b/Code/Editor/Plugin.h index 1ad6a1496f..5fa45ac140 100644 --- a/Code/Editor/Plugin.h +++ b/Code/Editor/Plugin.h @@ -13,6 +13,7 @@ #include "Include/IEditorClassFactory.h" #include "Util/GuidUtil.h" +#include //! Derive from this class to decrease the amount of work for creating a new class description //! Provides standard reference counter implementation for IUnknown diff --git a/Code/Editor/Plugins/ComponentEntityEditorPlugin/Objects/ComponentEntityObject.cpp b/Code/Editor/Plugins/ComponentEntityEditorPlugin/Objects/ComponentEntityObject.cpp index c91bf58074..29ced334ef 100644 --- a/Code/Editor/Plugins/ComponentEntityEditorPlugin/Objects/ComponentEntityObject.cpp +++ b/Code/Editor/Plugins/ComponentEntityEditorPlugin/Objects/ComponentEntityObject.cpp @@ -40,6 +40,7 @@ #include #include +#include #include #include #include @@ -49,11 +50,6 @@ * Scalars for icon drawing behavior. */ static const int s_kIconSize = 36; /// Icon display size (in pixels) -static const float s_kIconMaxWorldDist = 200.f; /// Icons are culled past this range -static const float s_kIconMinScale = 0.1f; /// Minimum scale for icons in the distance -static const float s_kIconMaxScale = 1.0f; /// Maximum scale for icons near the camera -static const float s_kIconCloseDist = 3.f; /// Distance at which icons are at maximum scale -static const float s_kIconFarDist = 40.f; /// Distance at which icons are at minimum scale CComponentEntityObject::CComponentEntityObject() : m_hasIcon(false) diff --git a/Code/Editor/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp b/Code/Editor/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp index 429fbd923c..47bd214b8d 100644 --- a/Code/Editor/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp +++ b/Code/Editor/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.cpp @@ -528,7 +528,6 @@ void SandboxIntegrationManager::EntityParentChanged( oldAncestor = nextParentId; } while (oldAncestor.IsValid()); - AZ::EntityId newAncestors = newParentId; AZ::EntityId newAncestor = newParentId; bool isGoingToRootScene = false; @@ -721,7 +720,7 @@ void SandboxIntegrationManager::PopulateEditorGlobalContextMenu(QMenu* menu, con if (selected.size() > 0) { action = menu->addAction(QObject::tr("Find in Entity Outliner")); - QObject::connect(action, &QAction::triggered, [this, selected] + QObject::connect(action, &QAction::triggered, [selected] { AzToolsFramework::EditorEntityContextNotificationBus::Broadcast(&EditorEntityContextNotification::OnFocusInEntityOutliner, selected); }); @@ -842,7 +841,7 @@ void SandboxIntegrationManager::SetupLayerContextMenu(QMenu* menu) QAction* findLayerAssetAction = menu->addAction(QObject::tr("Find layer in Asset Browser")); findLayerAssetAction->setToolTip(QObject::tr("Selects this layer in the Asset Browser")); - QObject::connect(findLayerAssetAction, &QAction::triggered, [this, fullFilePath] { + QObject::connect(findLayerAssetAction, &QAction::triggered, [fullFilePath] { QtViewPaneManager::instance()->OpenPane(LyViewPane::AssetBrowser); AzToolsFramework::AssetBrowser::AssetBrowserViewRequestBus::Broadcast( diff --git a/Code/Editor/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.h b/Code/Editor/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.h index d14ba80bce..f2764681b2 100644 --- a/Code/Editor/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.h +++ b/Code/Editor/Plugins/ComponentEntityEditorPlugin/SandboxIntegration.h @@ -280,7 +280,6 @@ private: private: AZ::Vector2 m_contextMenuViewPoint; - AZ::Vector3 m_sliceWorldPos; int m_inObjectPickMode; short m_startedUndoRecordingNestingLevel; // used in OnBegin/EndUndo to ensure we only accept undo's we started recording @@ -298,8 +297,6 @@ private: const AZStd::string m_defaultComponentViewportIconLocation = "Icons/Components/Viewport/Component_Placeholder.svg"; const AZStd::string m_defaultEntityIconLocation = "Icons/Components/Viewport/Transform.svg"; - bool m_debugDisplayBusImplementationActive = false; - AzToolsFramework::Prefab::PrefabIntegrationManager* m_prefabIntegrationManager = nullptr; AzToolsFramework::EditorEntityUiInterface* m_editorEntityUiInterface = nullptr; diff --git a/Code/Editor/Plugins/ComponentEntityEditorPlugin/UI/Outliner/OutlinerListModel.cpp b/Code/Editor/Plugins/ComponentEntityEditorPlugin/UI/Outliner/OutlinerListModel.cpp index 9ec81cdb3b..c25248d4f6 100644 --- a/Code/Editor/Plugins/ComponentEntityEditorPlugin/UI/Outliner/OutlinerListModel.cpp +++ b/Code/Editor/Plugins/ComponentEntityEditorPlugin/UI/Outliner/OutlinerListModel.cpp @@ -1234,8 +1234,6 @@ bool OutlinerListModel::ReparentEntities(const AZ::EntityId& newParentId, const QMimeData* OutlinerListModel::mimeData(const QModelIndexList& indexes) const { AZ_PROFILE_FUNCTION(AzToolsFramework); - AZ::TypeId uuid1 = AZ::AzTypeInfo::Uuid(); - AZ::TypeId uuid2 = AZ::AzTypeInfo::Uuid(); AzToolsFramework::EditorEntityIdContainer entityIdList; for (const QModelIndex& index : indexes) @@ -1462,13 +1460,11 @@ void OutlinerListModel::OnEntityRuntimeActivationChanged(AZ::EntityId entityId, QueueEntityUpdate(entityId); } -void OutlinerListModel::OnEntityInfoUpdatedRemoveChildBegin(AZ::EntityId parentId, AZ::EntityId childId) +void OutlinerListModel::OnEntityInfoUpdatedRemoveChildBegin([[maybe_unused]] AZ::EntityId parentId, [[maybe_unused]] AZ::EntityId childId) { //add/remove operations trigger selection change signals which assert and break undo/redo operations in progress in inspector etc. //so disallow selection updates until change is complete emit EnableSelectionUpdates(false); - auto parentIndex = GetIndexFromEntity(parentId); - auto childIndex = GetIndexFromEntity(childId); beginResetModel(); } diff --git a/Code/Editor/PythonEditorFuncs.cpp b/Code/Editor/PythonEditorFuncs.cpp index dff41c0a86..342cc607d7 100644 --- a/Code/Editor/PythonEditorFuncs.cpp +++ b/Code/Editor/PythonEditorFuncs.cpp @@ -33,18 +33,6 @@ namespace { - ////////////////////////////////////////////////////////////////////////// - const char* PyGetCVar(const char* pName) - { - ICVar* pCVar = GetIEditor()->GetSystem()->GetIConsole()->GetCVar(pName); - if (!pCVar) - { - Warning("PyGetCVar: Attempt to access non-existent CVar '%s'", pName ? pName : "(null)"); - throw std::logic_error((QString("\"") + pName + "\" is an invalid cvar.").toUtf8().data()); - } - return pCVar->GetString(); - } - ////////////////////////////////////////////////////////////////////////// const char* PyGetCVarAsString(const char* pName) { @@ -212,52 +200,6 @@ namespace return GetIEditor()->IsInSimulationMode(); } - ////////////////////////////////////////////////////////////////////////// - QString PyNewObject(const char* typeName, const char* fileName, const char* name, float x, float y, float z) - { - CBaseObject* object = GetIEditor()->NewObject(typeName, fileName, name, x, y, z); - if (object) - { - return object->GetName(); - } - else - { - return ""; - } - } - - ////////////////////////////////////////////////////////////////////////// - QString PyNewObjectAtCursor(const char* typeName, const char* fileName, const char* name) - { - CUndo undo("Create new object"); - - Vec3 pos(0, 0, 0); - - QPoint p = QCursor::pos(); - CViewport* viewport = GetIEditor()->GetViewManager()->GetViewportAtPoint(p); - if (viewport) - { - viewport->ScreenToClient(p); - if (GetIEditor()->GetAxisConstrains() != AXIS_TERRAIN) - { - pos = viewport->MapViewToCP(p); - } - else - { - // Snap to terrain. - bool hitTerrain; - pos = viewport->ViewToWorld(p, &hitTerrain); - if (hitTerrain) - { - pos.z = GetIEditor()->GetTerrainElevation(pos.x, pos.y) + 1.0f; - } - pos = viewport->SnapToGrid(pos); - } - } - - return PyNewObject(typeName, fileName, name, pos.x, pos.y, pos.z); - } - ////////////////////////////////////////////////////////////////////////// void PyRunConsole(const char* text) { diff --git a/Code/Editor/QtViewPaneManager.cpp b/Code/Editor/QtViewPaneManager.cpp index 022bb6ecd9..eff3a7331e 100644 --- a/Code/Editor/QtViewPaneManager.cpp +++ b/Code/Editor/QtViewPaneManager.cpp @@ -240,14 +240,13 @@ static bool SkipTitleBarOverdraw(QtViewPane* pane) return !pane->m_options.isDockable; } -DockWidget::DockWidget(QWidget* widget, QtViewPane* pane, QSettings* settings, QMainWindow* parent, AzQtComponents::FancyDocking* advancedDockManager) +DockWidget::DockWidget(QWidget* widget, QtViewPane* pane, [[maybe_unused]] QSettings* settings, QMainWindow* parent, AzQtComponents::FancyDocking* advancedDockManager) : AzQtComponents::StyledDockWidget(pane->m_name, SkipTitleBarOverdraw(pane), #if AZ_TRAIT_OS_PLATFORM_APPLE pane->m_options.detachedWindow ? nullptr : parent) #else parent) #endif - , m_settings(settings) , m_mainWindow(parent) , m_pane(pane) , m_advancedDockManager(advancedDockManager) diff --git a/Code/Editor/QtViewPaneManager.h b/Code/Editor/QtViewPaneManager.h index 49440068a0..3ad1cc9cf7 100644 --- a/Code/Editor/QtViewPaneManager.h +++ b/Code/Editor/QtViewPaneManager.h @@ -67,7 +67,6 @@ private: void reparentToMainWindowFix(); QRect ProperGeometry() const; QString settingsKey() const; - QSettings* const m_settings; QMainWindow* const m_mainWindow; QtViewPane* const m_pane; AzQtComponents::FancyDocking* m_advancedDockManager; diff --git a/Code/Editor/RenderHelpers/AxisHelperShared.inl b/Code/Editor/RenderHelpers/AxisHelperShared.inl index 2ceac98eae..24cd2ef9f5 100644 --- a/Code/Editor/RenderHelpers/AxisHelperShared.inl +++ b/Code/Editor/RenderHelpers/AxisHelperShared.inl @@ -191,7 +191,6 @@ void CAxisHelper::DrawAxis(const Matrix34& worldTM, const SGizmoParameters& setu { if (axis) { - float col[4] = { 1, 0, 0, 1 }; if (axis == AXIS_X || axis == AXIS_XY || axis == AXIS_XZ || axis == AXIS_XYZ) { colX = colSelected; @@ -436,7 +435,6 @@ void CAxisHelper::DrawAxis(const Matrix34& worldTM, const SGizmoParameters& setu { dc.SetColor(QColor(128, 32, 32), 0.4f); } - Vec3 org = worldTM.GetTranslation(); dc.DrawBall(Vec3(0.0f), m_size * kSelectionBallScale); } diff --git a/Code/Editor/SettingsManager.cpp b/Code/Editor/SettingsManager.cpp index d567da4c26..7455d9134f 100644 --- a/Code/Editor/SettingsManager.cpp +++ b/Code/Editor/SettingsManager.cpp @@ -987,7 +987,7 @@ QString CSettingsManager::GenerateContentHash(XmlNodeRef& node, QString sourceNa return sourceName; } - uint32 hash = CCrc32::ComputeLowercase(node->getXML(0)); + uint32 hash = AZ::Crc32(node->getXML(0)); hashStr = QString::number(hash); return hashStr; diff --git a/Code/Editor/StartupTraceHandler.cpp b/Code/Editor/StartupTraceHandler.cpp index ae525eb4e3..498bf10e31 100644 --- a/Code/Editor/StartupTraceHandler.cpp +++ b/Code/Editor/StartupTraceHandler.cpp @@ -168,7 +168,7 @@ namespace SandboxEditor void StartupTraceHandler::ShowMessageBox(const QString& message) { - AZ::SystemTickBus::QueueFunction([this, message]() + AZ::SystemTickBus::QueueFunction([message]() { // Parent to the main window, so that the error dialog doesn't // show up as a separate window when alt-tabbing. diff --git a/Code/Editor/ToolbarManager.cpp b/Code/Editor/ToolbarManager.cpp index 1831fe6a55..00b7992ef0 100644 --- a/Code/Editor/ToolbarManager.cpp +++ b/Code/Editor/ToolbarManager.cpp @@ -1217,7 +1217,6 @@ void EditableQToolBar::dropEvent(QDropEvent* ev) return; } - const int actionId = action->data().toInt(); QWidget* beforeWidget = insertPositionForDrop(ev->pos()); QAction* beforeAction = beforeWidget ? ActionForWidget(beforeWidget) : nullptr; diff --git a/Code/Editor/ToolsConfigPage.cpp b/Code/Editor/ToolsConfigPage.cpp index 1871dc763f..50001dc2f0 100644 --- a/Code/Editor/ToolsConfigPage.cpp +++ b/Code/Editor/ToolsConfigPage.cpp @@ -39,8 +39,6 @@ namespace QColor COLOR_FOR_CONSOLE_COMMAND = QColor(0, 0, 255); QColor COLOR_FOR_TOGGLE_COMMAND = QColor(128, 0, 255); QColor COLOR_FOR_INVALID_COMMAND = QColor(255, 0, 0); - - UINT CONSOLE_CMD_DROP_LIST_HEIGHT = 300; }; class IconListModel diff --git a/Code/Editor/TopRendererWnd.cpp b/Code/Editor/TopRendererWnd.cpp index 541e967dd0..5f25a6b4c5 100644 --- a/Code/Editor/TopRendererWnd.cpp +++ b/Code/Editor/TopRendererWnd.cpp @@ -26,27 +26,6 @@ #define GL_RGBA 0x1908 #define GL_BGRA 0x80E1 -// Used to give each static object type a different color -static uint32 sVegetationColors[16] = -{ - 0xFFFF0000, - 0xFF00FF00, - 0xFF0000FF, - 0xFFFFFFFF, - 0xFFFF00FF, - 0xFFFFFF00, - 0xFF00FFFF, - 0xFF7F00FF, - 0xFF7FFF7F, - 0xFFFF7F00, - 0xFF00FF7F, - 0xFF7F7F7F, - 0xFFFF0000, - 0xFF00FF00, - 0xFF0000FF, - 0xFFFFFFFF, -}; - ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// diff --git a/Code/Editor/TrackView/CommentNodeAnimator.cpp b/Code/Editor/TrackView/CommentNodeAnimator.cpp index 2dd2cfbb22..c49504509c 100644 --- a/Code/Editor/TrackView/CommentNodeAnimator.cpp +++ b/Code/Editor/TrackView/CommentNodeAnimator.cpp @@ -13,6 +13,7 @@ // CryCommon #include +#include // Editor #include "Settings.h" diff --git a/Code/Editor/TrackView/DirectorNodeAnimator.cpp b/Code/Editor/TrackView/DirectorNodeAnimator.cpp index 3e2a1d5626..01663fbf69 100644 --- a/Code/Editor/TrackView/DirectorNodeAnimator.cpp +++ b/Code/Editor/TrackView/DirectorNodeAnimator.cpp @@ -19,10 +19,8 @@ //////////////////////////////////////////////////////////////////////////// -CDirectorNodeAnimator::CDirectorNodeAnimator(CTrackViewAnimNode* pDirectorNode) - : m_pDirectorNode(pDirectorNode) +CDirectorNodeAnimator::CDirectorNodeAnimator([[maybe_unused]] CTrackViewAnimNode* pDirectorNode) { - assert(m_pDirectorNode != nullptr); } //////////////////////////////////////////////////////////////////////////// @@ -139,7 +137,6 @@ void CDirectorNodeAnimator::ForEachActiveSequence(const SAnimContext& ac, CTrack const bool bHandleOtherKeys, std::function animateFunction, std::function resetFunction) { - const float time = ac.time; const unsigned int numKeys = pSequenceTrack->GetKeyCount(); if (bHandleOtherKeys) diff --git a/Code/Editor/TrackView/DirectorNodeAnimator.h b/Code/Editor/TrackView/DirectorNodeAnimator.h index d2bde01c54..87d72bf5c8 100644 --- a/Code/Editor/TrackView/DirectorNodeAnimator.h +++ b/Code/Editor/TrackView/DirectorNodeAnimator.h @@ -34,7 +34,5 @@ private: void ForEachActiveSequence(const SAnimContext& ac, CTrackViewTrack* pSequenceTrack, const bool bHandleOtherKeys, std::function animateFunction, std::function resetFunction); - - CTrackViewAnimNode* m_pDirectorNode; }; #endif // CRYINCLUDE_EDITOR_TRACKVIEW_DIRECTORNODEANIMATOR_H diff --git a/Code/Editor/TrackView/TVCustomizeTrackColorsDlg.cpp b/Code/Editor/TrackView/TVCustomizeTrackColorsDlg.cpp index ae1080a9c1..b30f655b0b 100644 --- a/Code/Editor/TrackView/TVCustomizeTrackColorsDlg.cpp +++ b/Code/Editor/TrackView/TVCustomizeTrackColorsDlg.cpp @@ -106,7 +106,6 @@ namespace { AnimParamType::User, "Muted", QColor(255, 224, 224) }, }; - const int kButtonsIdBase = 0x7fff; const int kMaxRows = 20; const int kColumnWidth = 300; const int kRowHeight = 24; diff --git a/Code/Editor/TrackView/TVEventsDialog.cpp b/Code/Editor/TrackView/TVEventsDialog.cpp index 86b4c1f6bc..dbaaf4b530 100644 --- a/Code/Editor/TrackView/TVEventsDialog.cpp +++ b/Code/Editor/TrackView/TVEventsDialog.cpp @@ -29,12 +29,6 @@ AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING // CTVEventsDialog dialog -namespace -{ - const int kCountSubItemIndex = 1; - const int kTimeSubItemIndex = 2; -} - class TVEventsModel : public QAbstractTableModel { diff --git a/Code/Editor/TrackView/TVSequenceProps.cpp b/Code/Editor/TrackView/TVSequenceProps.cpp index d4e06d0c94..0abab65645 100644 --- a/Code/Editor/TrackView/TVSequenceProps.cpp +++ b/Code/Editor/TrackView/TVSequenceProps.cpp @@ -53,7 +53,7 @@ CTVSequenceProps::~CTVSequenceProps() // CTVSequenceProps message handlers bool CTVSequenceProps::OnInitDialog() { - ui->NAME->setText(m_pSequence->GetName()); + ui->NAME->setText(m_pSequence->GetName().c_str()); int seqFlags = m_pSequence->GetFlags(); ui->ALWAYS_PLAY->setChecked((seqFlags & IAnimSequence::eSeqFlags_PlayOnReset)); @@ -141,7 +141,7 @@ void CTVSequenceProps::UpdateSequenceProps(const QString& name) ac->UpdateTimeRange(); } - QString seqName = m_pSequence->GetName(); + QString seqName = QString::fromUtf8(m_pSequence->GetName().c_str()); if (name != seqName) { // Rename sequence. diff --git a/Code/Editor/TrackView/TrackViewAnimNode.cpp b/Code/Editor/TrackView/TrackViewAnimNode.cpp index 4b599859e9..2119bf849f 100644 --- a/Code/Editor/TrackView/TrackViewAnimNode.cpp +++ b/Code/Editor/TrackView/TrackViewAnimNode.cpp @@ -423,7 +423,7 @@ CTrackViewAnimNode* CTrackViewAnimNode::CreateSubNode( AZStd::string::format( "Failed to add '%s' to sequence '%s', could not find associated entity. " "Please try adding the entity associated with '%s'.", - originalNameStr.constData(), director->GetName(), originalNameStr.constData())); + originalNameStr.constData(), director->GetName().c_str(), originalNameStr.constData())); return nullptr; } @@ -472,7 +472,7 @@ CTrackViewAnimNode* CTrackViewAnimNode::CreateSubNode( { GetIEditor()->GetMovieSystem()->LogUserNotificationMsg( AZStd::string::format("'%s' already exists in sequence '%s', skipping...", - originalNameStr.constData(), director2->GetName())); + originalNameStr.constData(), director2->GetName().c_str())); return nullptr; } @@ -488,7 +488,7 @@ CTrackViewAnimNode* CTrackViewAnimNode::CreateSubNode( if (!newAnimNode) { GetIEditor()->GetMovieSystem()->LogUserNotificationMsg( - AZStd::string::format("Failed to add '%s' to sequence '%s'.", nameStr.constData(), director->GetName())); + AZStd::string::format("Failed to add '%s' to sequence '%s'.", nameStr.constData(), director->GetName().c_str())); return nullptr; } @@ -1195,7 +1195,7 @@ CTrackViewAnimNodeBundle CTrackViewAnimNode::GetAnimNodesByName(const char* pNam { CTrackViewAnimNodeBundle bundle; - QString nodeName = GetName(); + QString nodeName = QString::fromUtf8(GetName().c_str()); if (GetNodeType() == eTVNT_AnimNode && QString::compare(pName, nodeName, Qt::CaseInsensitive) == 0) { bundle.AppendAnimNode(this); @@ -1215,10 +1215,9 @@ CTrackViewAnimNodeBundle CTrackViewAnimNode::GetAnimNodesByName(const char* pNam } ////////////////////////////////////////////////////////////////////////// -const char* CTrackViewAnimNode::GetParamName(const CAnimParamType& paramType) const +AZStd::string CTrackViewAnimNode::GetParamName(const CAnimParamType& paramType) const { - const char* pName = m_animNode->GetParamName(paramType); - return pName ? pName : ""; + return m_animNode->GetParamName(paramType); } ////////////////////////////////////////////////////////////////////////// @@ -1274,7 +1273,7 @@ CTrackViewAnimNodeBundle CTrackViewAnimNode::AddSelectedEntities(const AZStd::ve if (existingNode->GetDirector() == GetDirector()) { GetIEditor()->GetMovieSystem()->LogUserNotificationMsg(AZStd::string::format( - "'%s' was already added to '%s', skipping...", entity->GetName().c_str(), GetDirector()->GetName())); + "'%s' was already added to '%s', skipping...", entity->GetName().c_str(), GetDirector()->GetName().c_str())); continue; } @@ -1377,7 +1376,7 @@ void CTrackViewAnimNode::UpdateDynamicParams() void CTrackViewAnimNode::CopyKeysToClipboard(XmlNodeRef& xmlNode, const bool bOnlySelectedKeys, const bool bOnlyFromSelectedTracks) { XmlNodeRef childNode = xmlNode->createNode("Node"); - childNode->setAttr("name", GetName()); + childNode->setAttr("name", GetName().c_str()); childNode->setAttr("type", static_cast(GetType())); for (auto iter = m_childNodes.begin(); iter != m_childNodes.end(); ++iter) @@ -1683,7 +1682,7 @@ bool CTrackViewAnimNode::IsValidReparentingTo(CTrackViewAnimNode* pNewParent) } // Check if the new parent already contains a node with this name - CTrackViewAnimNodeBundle foundNodes = pNewParent->GetAnimNodesByName(GetName()); + CTrackViewAnimNodeBundle foundNodes = pNewParent->GetAnimNodesByName(GetName().c_str()); if (foundNodes.GetCount() > 1 || (foundNodes.GetCount() == 1 && foundNodes.GetNode(0) != this)) { return false; @@ -1820,7 +1819,6 @@ bool CTrackViewAnimNode::IsDisabled() const ////////////////////////////////////////////////////////////////////////// void CTrackViewAnimNode::SetPos(const Vec3& position) { - const float time = GetSequence()->GetTime(); CTrackViewTrack* track = GetTrackForParameter(AnimParamType::Position); if (track) diff --git a/Code/Editor/TrackView/TrackViewAnimNode.h b/Code/Editor/TrackView/TrackViewAnimNode.h index 466e60bcf0..aa6474ccdb 100644 --- a/Code/Editor/TrackView/TrackViewAnimNode.h +++ b/Code/Editor/TrackView/TrackViewAnimNode.h @@ -124,7 +124,7 @@ public: virtual void SetAsViewCamera(); // Name setter/getter - virtual const char* GetName() const override { return m_animNode->GetName(); } + AZStd::string GetName() const override { return m_animNode->GetName(); } virtual bool SetName(const char* pName) override; virtual bool CanBeRenamed() const override; @@ -187,7 +187,7 @@ public: // Param unsigned int GetParamCount() const; CAnimParamType GetParamType(unsigned int index) const; - const char* GetParamName(const CAnimParamType& paramType) const; + AZStd::string GetParamName(const CAnimParamType& paramType) const; bool IsParamValid(const CAnimParamType& param) const; IAnimNode::ESupportedParamFlags GetParamFlags(const CAnimParamType& paramType) const; AnimValueType GetParamValueType(const CAnimParamType& paramType) const; diff --git a/Code/Editor/TrackView/TrackViewDialog.cpp b/Code/Editor/TrackView/TrackViewDialog.cpp index f1701f9e20..cfaa82fdb4 100644 --- a/Code/Editor/TrackView/TrackViewDialog.cpp +++ b/Code/Editor/TrackView/TrackViewDialog.cpp @@ -77,9 +77,6 @@ inline namespace TrackViewInternal const int s_kMinimumFrameSnappingFPS = 1; const int s_kMaximumFrameSnappingFPS = 120; - const int TRACKVIEW_LAYOUT_VERSION = 0x0001; // Bump this up on every substantial pane layout change - const int TRACKVIEW_REBAR_VERSION = 0x0002; // Bump this up on every substantial rebar change - CTrackViewSequence* GetSequenceByEntityIdOrName(const CTrackViewSequenceManager* pSequenceManager, const char* entityIdOrName) { // the "name" string will be an AZ::EntityId in string form if this was called from @@ -1125,7 +1122,7 @@ void CTrackViewDialog::ReloadSequencesComboBox() { CTrackViewSequence* sequence = pSequenceManager->GetSequenceByIndex(k); QString entityIdString = GetEntityIdAsString(sequence->GetSequenceComponentEntityId()); - m_sequencesComboBox->addItem(sequence->GetName(), entityIdString); + m_sequencesComboBox->addItem(QString::fromUtf8(sequence->GetName().c_str()), entityIdString); } } @@ -2033,7 +2030,7 @@ void CTrackViewDialog::UpdateTracksToolBar() continue; } - name = pAnimNode->GetParamName(paramType); + name = QString::fromUtf8(pAnimNode->GetParamName(paramType).c_str()); QString sToolTipText("Add " + name + " Track"); QIcon hIcon = m_wndNodesCtrl->GetIconForTrack(pTrack); @@ -2309,7 +2306,7 @@ void CTrackViewDialog::SaveCurrentSequenceToFBX() return; } - QString selectedSequenceFBXStr = QString(sequence->GetName()) + ".fbx"; + QString selectedSequenceFBXStr = QString::fromUtf8(sequence->GetName().c_str()) + ".fbx"; CExportManager* pExportManager = static_cast(GetIEditor()->GetExportManager()); const char szFilters[] = "FBX Files (*.fbx)"; diff --git a/Code/Editor/TrackView/TrackViewDopeSheetBase.cpp b/Code/Editor/TrackView/TrackViewDopeSheetBase.cpp index d0034b2da4..a14da0ae09 100644 --- a/Code/Editor/TrackView/TrackViewDopeSheetBase.cpp +++ b/Code/Editor/TrackView/TrackViewDopeSheetBase.cpp @@ -199,7 +199,6 @@ void CTrackViewDopeSheetBase::SetTimeRange(float start, float end) void CTrackViewDopeSheetBase::SetTimeScale(float timeScale, float fAnchorTime) { const double fOldOffset = -fAnchorTime * m_timeScale; - const double fOldScale = m_timeScale; timeScale = std::max(timeScale, 0.001f); timeScale = std::min(timeScale, 100000.0f); @@ -1426,8 +1425,6 @@ void CTrackViewDopeSheetBase::OnCaptureChanged() ////////////////////////////////////////////////////////////////////////// bool CTrackViewDopeSheetBase::IsOkToAddKeyHere(const CTrackViewTrack* pTrack, float time) const { - const float timeEpsilon = 0.05f; - for (unsigned int i = 0; i < pTrack->GetKeyCount(); ++i) { const CTrackViewKeyConstHandle& keyHandle = pTrack->GetKey(i); @@ -2152,8 +2149,6 @@ void CTrackViewDopeSheetBase::AcceptUndo() { if (CUndo::IsRecording()) { - const QPoint mousePos = mapFromGlobal(QCursor::pos()); - CTrackViewSequence* sequence = GetIEditor()->GetAnimation()->GetSequence(); if (m_mouseMode == eTVMouseMode_Paste) @@ -2623,7 +2618,6 @@ void CTrackViewDopeSheetBase::DrawBoolTrack(const Range& timeRange, QPainter* pa { int x0 = TimeToClient(timeRange.start); float t0 = timeRange.start; - QRect trackRect; const QBrush prevBrush = painter->brush(); painter->setBrush(m_visibilityBrush); @@ -2752,7 +2746,6 @@ void CTrackViewDopeSheetBase::DrawKeys(CTrackViewTrack* pTrack, QPainter* painte } int x1 = x + kDefaultWidthForDescription; - CTrackViewKeyHandle nextKey = keyHandle.GetNextKey(); int nextKeyIndex = i + 1; @@ -3453,7 +3446,7 @@ void CTrackViewDopeSheetBase::DrawNodeTrack(CTrackViewAnimNode* animNode, QPaint const QRect textRect = trackRect.adjusted(4, 0, -4, 0); - QString sAnimNodeName = animNode->GetName(); + QString sAnimNodeName = QString::fromUtf8(animNode->GetName().c_str()); const bool hasObsoleteTrack = animNode->HasObsoleteTrack(); if (hasObsoleteTrack) diff --git a/Code/Editor/TrackView/TrackViewNode.cpp b/Code/Editor/TrackView/TrackViewNode.cpp index d8507d9b0a..208210f1e7 100644 --- a/Code/Editor/TrackView/TrackViewNode.cpp +++ b/Code/Editor/TrackView/TrackViewNode.cpp @@ -22,16 +22,12 @@ //////////////////////////////////////////////////////////////////////////// void CTrackViewKeyConstHandle::GetKey(IKey* pKey) const { - assert(m_bIsValid); - m_pTrack->GetKey(m_keyIndex, pKey); } //////////////////////////////////////////////////////////////////////////// float CTrackViewKeyConstHandle::GetTime() const { - assert(m_bIsValid); - return m_pTrack->GetKeyTime(m_keyIndex); } @@ -626,7 +622,7 @@ bool CTrackViewNode::operator<(const CTrackViewNode& otherNode) const if (thisTypeOrder == otherTypeOrder) { // Same node type, sort by name - return azstricmp(thisAnimNode.GetName(), otherAnimNode.GetName()) < 0; + return thisAnimNode.GetName() < otherAnimNode.GetName(); } return thisTypeOrder < otherTypeOrder; @@ -638,7 +634,7 @@ bool CTrackViewNode::operator<(const CTrackViewNode& otherNode) const if (thisTrack.GetParameterType() == otherTrack.GetParameterType()) { // Same parameter type, sort by name - return azstricmp(thisTrack.GetName(), otherTrack.GetName()) < 0; + return thisTrack.GetName() < otherTrack.GetName(); } return thisTrack.GetParameterType() < otherTrack.GetParameterType(); diff --git a/Code/Editor/TrackView/TrackViewNode.h b/Code/Editor/TrackView/TrackViewNode.h index 2c289049e9..59df06750b 100644 --- a/Code/Editor/TrackView/TrackViewNode.h +++ b/Code/Editor/TrackView/TrackViewNode.h @@ -22,13 +22,11 @@ class CTrackViewKeyConstHandle { public: CTrackViewKeyConstHandle() - : m_bIsValid(false) - , m_keyIndex(0) + : m_keyIndex(0) , m_pTrack(nullptr) {} CTrackViewKeyConstHandle(const CTrackViewTrack* pTrack, unsigned int keyIndex) - : m_bIsValid(true) - , m_keyIndex(keyIndex) + : m_keyIndex(keyIndex) , m_pTrack(pTrack) {} void GetKey(IKey* pKey) const; @@ -36,7 +34,6 @@ public: const CTrackViewTrack* GetTrack() const { return m_pTrack; } private: - bool m_bIsValid; unsigned int m_keyIndex; const CTrackViewTrack* m_pTrack; }; @@ -159,7 +156,7 @@ public: virtual ~CTrackViewNode() {} // Name - virtual const char* GetName() const = 0; + virtual AZStd::string GetName() const = 0; virtual bool SetName([[maybe_unused]] const char* pName) { return false; }; virtual bool CanBeRenamed() const { return false; } diff --git a/Code/Editor/TrackView/TrackViewNodes.cpp b/Code/Editor/TrackView/TrackViewNodes.cpp index ae38323cc3..e3b994c488 100644 --- a/Code/Editor/TrackView/TrackViewNodes.cpp +++ b/Code/Editor/TrackView/TrackViewNodes.cpp @@ -616,7 +616,7 @@ CTrackViewNodesCtrl::CRecord* CTrackViewNodesCtrl::AddAnimNodeRecord(CRecord* pP { CRecord* pNewRecord = new CRecord(animNode); - pNewRecord->setText(0, animNode->GetName()); + pNewRecord->setText(0, QString::fromUtf8(animNode->GetName().c_str())); UpdateAnimNodeRecord(pNewRecord, animNode); pParentRecord->insertChild(GetInsertPosition(pParentRecord, animNode), pNewRecord); FillNodesRec(pNewRecord, animNode); @@ -629,7 +629,7 @@ CTrackViewNodesCtrl::CRecord* CTrackViewNodesCtrl::AddTrackRecord(CRecord* pPare { CRecord* pNewTrackRecord = new CRecord(pTrack); pNewTrackRecord->setSizeHint(0, QSize(30, 18)); - pNewTrackRecord->setText(0, pTrack->GetName()); + pNewTrackRecord->setText(0, QString::fromUtf8(pTrack->GetName().c_str())); UpdateTrackRecord(pNewTrackRecord, pTrack); pParentRecord->insertChild(GetInsertPosition(pParentRecord, pTrack), pNewTrackRecord); FillNodesRec(pNewTrackRecord, pTrack); @@ -860,7 +860,7 @@ void CTrackViewNodesCtrl::OnFillItems() m_nodeToRecordMap.clear(); CRecord* pRootGroupRec = new CRecord(sequence); - pRootGroupRec->setText(0, sequence->GetName()); + pRootGroupRec->setText(0, QString::fromUtf8(sequence->GetName().c_str())); QFont f = font(); f.setBold(true); pRootGroupRec->setData(0, Qt::FontRole, f); @@ -1032,8 +1032,8 @@ void CTrackViewNodesCtrl::OnNMRclick(QPoint point) return; } - QString file = QString(sequence2->GetName()) + QString(".fbx"); - QString selectedSequenceFBXStr = QString(sequence2->GetName()) + ".fbx"; + QString file = QString::fromUtf8(sequence2->GetName().c_str()) + QString(".fbx"); + QString selectedSequenceFBXStr = QString::fromUtf8(sequence2->GetName().c_str()) + ".fbx"; if (numSelectedNodes > 1) { @@ -1041,7 +1041,7 @@ void CTrackViewNodesCtrl::OnNMRclick(QPoint point) } else { - file = QString(selectedNodes.GetNode(0)->GetName()) + QString(".fbx"); + file = QString::fromUtf8(selectedNodes.GetNode(0)->GetName().c_str()) + QString(".fbx"); } QString path = QFileDialog::getSaveFileName(this, tr("Export Selected Nodes To FBX File"), QString(), tr("FBX Files (*.fbx)")); @@ -1338,7 +1338,7 @@ void CTrackViewNodesCtrl::OnNMRclick(QPoint point) if (animNode || groupNode) { CTrackViewAnimNode* animNode2 = static_cast(pNode); - QString oldName = animNode2->GetName(); + QString oldName = QString::fromUtf8(animNode2->GetName().c_str()); StringDlg dlg(tr("Rename Node")); dlg.SetString(oldName); @@ -1494,7 +1494,7 @@ void CTrackViewNodesCtrl::OnNMRclick(QPoint point) if (animNode) { QString matName; - GetMatNameAndSubMtlIndexFromName(matName, animNode->GetName()); + GetMatNameAndSubMtlIndexFromName(matName, animNode->GetName().c_str()); QString newMatName; newMatName = tr("%1.[%2]").arg(matName).arg(cmd - eMI_SelectSubmaterialBase + 1); CUndo undo("Rename TrackView node"); @@ -1576,7 +1576,7 @@ CTrackViewTrack* CTrackViewNodesCtrl::GetTrackViewTrack(const Export::EntityAnim for (unsigned int trackID = 0; trackID < trackBundle.GetCount(); ++trackID) { CTrackViewTrack* pTrack = trackBundle.GetTrack(trackID); - const QString bundleTrackName = pTrack->GetAnimNode()->GetName(); + const QString bundleTrackName = QString::fromUtf8(pTrack->GetAnimNode()->GetName().c_str()); if (bundleTrackName.compare(nodeName, Qt::CaseInsensitive) != 0) { @@ -2164,7 +2164,7 @@ int CTrackViewNodesCtrl::ShowPopupMenuSingleSelection(SContextMenu& contextMenu, if (bOnNode && !pNode->IsGroupNode()) { AddMenuSeperatorConditional(contextMenu.main, bAppended); - QString string = QString("%1 Tracks").arg(animNode->GetName()); + QString string = QString("%1 Tracks").arg(animNode->GetName().c_str()); contextMenu.main.addAction(string)->setEnabled(false); bool bAppendedTrackFlag = false; @@ -2182,7 +2182,7 @@ int CTrackViewNodesCtrl::ShowPopupMenuSingleSelection(SContextMenu& contextMenu, continue; } - QAction* a = contextMenu.main.addAction(QString(" %1").arg(pTrack2->GetName())); + QAction* a = contextMenu.main.addAction(QString(" %1").arg(pTrack2->GetName().c_str())); a->setData(eMI_ShowHideBase + childIndex); a->setCheckable(true); a->setChecked(!pTrack2->IsHidden()); @@ -2348,13 +2348,12 @@ bool CTrackViewNodesCtrl::FillAddTrackMenu(STrackMenuTreeNode& menuAddTrack, con continue; } } - name = animNode->GetParamName(paramType); - QStringList splittedName = name.split("/", Qt::SkipEmptyParts); + name = QString::fromUtf8(animNode->GetParamName(paramType).c_str()); + QStringList splitName = name.split("/", Qt::SkipEmptyParts); STrackMenuTreeNode* pCurrentNode = &menuAddTrack; - for (int j = 0; j < splittedName.size() - 1; ++j) + for (const QString& segment : splitName) { - const QString& segment = splittedName[j]; auto findIter = pCurrentNode->children.find(segment); if (findIter != pCurrentNode->children.end()) { @@ -2370,10 +2369,10 @@ bool CTrackViewNodesCtrl::FillAddTrackMenu(STrackMenuTreeNode& menuAddTrack, con // only add tracks to the that STrackMenuTreeNode tree that haven't already been added CTrackViewTrackBundle matchedTracks = animNode->GetTracksByParam(paramType); - if (matchedTracks.GetCount() == 0) + if (matchedTracks.GetCount() == 0 && !splitName.isEmpty()) { STrackMenuTreeNode* pParamNode = new STrackMenuTreeNode; - pCurrentNode->children[splittedName.back()] = std::unique_ptr(pParamNode); + pCurrentNode->children[splitName.back()] = std::unique_ptr(pParamNode); pParamNode->paramType = paramType; bTracksToAdd = true; @@ -2464,7 +2463,7 @@ void CTrackViewNodesCtrl::FillAutoCompletionListForFilter() for (unsigned int i = 0; i < animNodeCount; ++i) { - strings << animNodes.GetNode(i)->GetName(); + strings << QString::fromUtf8(animNodes.GetNode(i)->GetName().c_str()); } } else @@ -2580,10 +2579,10 @@ void CTrackViewNodesCtrl::Update() { const CTrackViewAnimNode* track = static_cast(node); if (track) - { - record->setText(0, track->GetName()); + { + record->setText(0, QString::fromUtf8(track->GetName().c_str())); } - } + } } } } @@ -2855,7 +2854,7 @@ void CTrackViewNodesCtrl::OnNodeRenamed(CTrackViewNode* pNode, [[maybe_unused]] if (!m_bIgnoreNotifications) { CRecord* pNodeRecord = GetNodeRecord(pNode); - pNodeRecord->setText(0, pNode->GetName()); + pNodeRecord->setText(0, QString::fromUtf8(pNode->GetName().c_str())); update(); } diff --git a/Code/Editor/TrackView/TrackViewNodes.h b/Code/Editor/TrackView/TrackViewNodes.h index d6ed95b88d..64f96fee78 100644 --- a/Code/Editor/TrackView/TrackViewNodes.h +++ b/Code/Editor/TrackView/TrackViewNodes.h @@ -66,7 +66,7 @@ public: CRecord(CTrackViewNode* pNode = nullptr); CTrackViewNode* GetNode() const { return m_pNode; } bool IsGroup() const { return m_pNode->GetChildCount() != 0; } - const QString GetName() const { return m_pNode->GetName(); } + const QString GetName() const { return QString::fromUtf8(m_pNode->GetName().c_str()); } // Workaround: CXTPReportRecord::IsVisible is // unreliable after the last visible element @@ -202,7 +202,6 @@ private: // Drag and drop CTrackViewAnimNodeBundle m_draggedNodes; - CTrackViewAnimNode* m_pDragTarget; std::unordered_map m_menuParamTypeMap; std::unordered_map m_nodeToRecordMap; diff --git a/Code/Editor/TrackView/TrackViewPythonFuncs.cpp b/Code/Editor/TrackView/TrackViewPythonFuncs.cpp index d50060269b..72da1e0b18 100644 --- a/Code/Editor/TrackView/TrackViewPythonFuncs.cpp +++ b/Code/Editor/TrackView/TrackViewPythonFuncs.cpp @@ -293,8 +293,8 @@ namespace CTrackViewTrack* pTrack = pNode->GetTrackForParameter(paramType); if (!pTrack || (paramFlags & IAnimNode::eSupportedParamFlags_MultipleTracks)) { - const char* name = pNode->GetParamName(paramType); - if (_stricmp(name, paramName) == 0) + AZStd::string name = pNode->GetParamName(paramType); + if (name == paramName) { CUndo undo("Create track"); if (!pNode->CreateTrack(paramType)) diff --git a/Code/Editor/TrackView/TrackViewPythonFuncs.h b/Code/Editor/TrackView/TrackViewPythonFuncs.h index 8be1bd140c..6442145ee3 100644 --- a/Code/Editor/TrackView/TrackViewPythonFuncs.h +++ b/Code/Editor/TrackView/TrackViewPythonFuncs.h @@ -35,7 +35,7 @@ namespace AzToolsFramework : public AZ::Component , public EditorLayerTrackViewRequestBus::Handler { - AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING + AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING public: AZ_COMPONENT(TrackViewComponent, "{3CF943CC-6F10-4B19-88FC-CFB697558FFD}") diff --git a/Code/Editor/TrackView/TrackViewSequence.cpp b/Code/Editor/TrackView/TrackViewSequence.cpp index f66e5276cd..519f7a44d0 100644 --- a/Code/Editor/TrackView/TrackViewSequence.cpp +++ b/Code/Editor/TrackView/TrackViewSequence.cpp @@ -135,9 +135,7 @@ CTrackViewKeyHandle CTrackViewSequence::FindSingleSelectedKey() ////////////////////////////////////////////////////////////////////////// void CTrackViewSequence::OnEntityComponentPropertyChanged(AZ::ComponentId changedComponentId) -{ - const AZ::EntityId entityId = *AzToolsFramework::PropertyEditorEntityChangeNotificationBus::GetCurrentBusId(); - +{ // find the component node for this changeComponentId if it exists for (int i = m_pAnimSequence->GetNodeCount(); --i >= 0;) { @@ -894,14 +892,14 @@ bool CTrackViewSequence::SetName(const char* name) return false; } - const char* oldName = GetName(); - if (0 != strcmp(name, oldName)) + AZStd::string oldName = GetName(); + if (name != oldName) { m_pAnimSequence->SetName(name); MarkAsModified(); AzToolsFramework::ScopedUndoBatch undoBatch("Rename Sequence"); - GetSequence()->OnNodeRenamed(this, oldName); + GetSequence()->OnNodeRenamed(this, oldName.c_str()); undoBatch.MarkEntityDirty(m_pAnimSequence->GetSequenceEntityId()); } diff --git a/Code/Editor/TrackView/TrackViewSequence.h b/Code/Editor/TrackView/TrackViewSequence.h index 66412360f2..69858adf8f 100644 --- a/Code/Editor/TrackView/TrackViewSequence.h +++ b/Code/Editor/TrackView/TrackViewSequence.h @@ -102,7 +102,7 @@ public: // ITrackViewNode virtual ETrackViewNodeType GetNodeType() const override { return eTVNT_Sequence; } - virtual const char* GetName() const override { return m_pAnimSequence->GetName(); } + virtual AZStd::string GetName() const override { return m_pAnimSequence->GetName(); } virtual bool SetName(const char* pName) override; virtual bool CanBeRenamed() const override { return true; } diff --git a/Code/Editor/TrackView/TrackViewSequenceManager.cpp b/Code/Editor/TrackView/TrackViewSequenceManager.cpp index 780c8f04ce..d7c1e3c709 100644 --- a/Code/Editor/TrackView/TrackViewSequenceManager.cpp +++ b/Code/Editor/TrackView/TrackViewSequenceManager.cpp @@ -75,7 +75,7 @@ CTrackViewSequence* CTrackViewSequenceManager::GetSequenceByName(QString name) c { CTrackViewSequence* sequence = (*iter).get(); - if (sequence->GetName() == name) + if (QString::fromUtf8(sequence->GetName().c_str()) == name) { return sequence; } @@ -371,8 +371,8 @@ void CTrackViewSequenceManager::SortSequences() std::stable_sort(m_sequences.begin(), m_sequences.end(), [](const std::unique_ptr& a, const std::unique_ptr& b) -> bool { - QString aName = a.get()->GetName(); - QString bName = b.get()->GetName(); + QString aName = QString::fromUtf8(a.get()->GetName().c_str()); + QString bName = QString::fromUtf8(b.get()->GetName().c_str()); return aName < bName; }); } diff --git a/Code/Editor/TrackView/TrackViewSplineCtrl.cpp b/Code/Editor/TrackView/TrackViewSplineCtrl.cpp index 4911297985..352f2f3699 100644 --- a/Code/Editor/TrackView/TrackViewSplineCtrl.cpp +++ b/Code/Editor/TrackView/TrackViewSplineCtrl.cpp @@ -611,7 +611,6 @@ void CTrackViewSplineCtrl::mouseMoveEvent(QMouseEvent* event) CTrackViewSequenceNotificationContext context(pSequence); - QPoint cMousePosPrev = m_cMousePos; m_cMousePos = point; if (m_editMode == NothingMode) diff --git a/Code/Editor/TrackView/TrackViewTrack.cpp b/Code/Editor/TrackView/TrackViewTrack.cpp index 64fd252534..27d6bbee54 100644 --- a/Code/Editor/TrackView/TrackViewTrack.cpp +++ b/Code/Editor/TrackView/TrackViewTrack.cpp @@ -472,7 +472,7 @@ void CTrackViewTrack::RestoreFromMemento(const CTrackViewTrackMemento& memento) } ////////////////////////////////////////////////////////////////////////// -const char* CTrackViewTrack::GetName() const +AZStd::string CTrackViewTrack::GetName() const { CTrackViewNode* pParentNode = GetParentNode(); @@ -810,7 +810,7 @@ void CTrackViewTrack::CopyKeysToClipboard(XmlNodeRef& xmlNode, const bool bOnlyS } XmlNodeRef childNode = xmlNode->newChild("Track"); - childNode->setAttr("name", GetName()); + childNode->setAttr("name", GetName().c_str()); GetParameterType().SaveToXml(childNode); childNode->setAttr("valueType", static_cast(GetValueType())); diff --git a/Code/Editor/TrackView/TrackViewTrack.h b/Code/Editor/TrackView/TrackViewTrack.h index bbe81f6377..1eef9c60e9 100644 --- a/Code/Editor/TrackView/TrackViewTrack.h +++ b/Code/Editor/TrackView/TrackViewTrack.h @@ -80,7 +80,7 @@ public: CTrackViewAnimNode* GetAnimNode() const; // Name getter - virtual const char* GetName() const; + AZStd::string GetName() const override; // CTrackViewNode virtual ETrackViewNodeType GetNodeType() const override { return eTVNT_Track; } diff --git a/Code/Editor/TrackView/TrackViewUndo.cpp b/Code/Editor/TrackView/TrackViewUndo.cpp index c9cdc62bc3..ee31dfe2bf 100644 --- a/Code/Editor/TrackView/TrackViewUndo.cpp +++ b/Code/Editor/TrackView/TrackViewUndo.cpp @@ -75,7 +75,7 @@ CTrackViewTrack* CUndoComponentEntityTrackObject::FindTrack(CTrackViewSequence* CTrackViewTrack* curTrack = allTracks.GetTrack(trackIndex); if (curTrack->GetAnimNode() && curTrack->GetAnimNode()->GetComponentId() == m_trackComponentId) { - if (0 == azstricmp(curTrack->GetName(), m_trackName.c_str())) + if (curTrack->GetName() == m_trackName) { CTrackViewAnimNode* parentAnimNode = static_cast(curTrack->GetAnimNode()->GetParentNode()); if (parentAnimNode && parentAnimNode->GetAzEntityId() == m_entityId) diff --git a/Code/Editor/TrackViewNewSequenceDialog.cpp b/Code/Editor/TrackViewNewSequenceDialog.cpp index 287f69df47..e922f345cc 100644 --- a/Code/Editor/TrackViewNewSequenceDialog.cpp +++ b/Code/Editor/TrackViewNewSequenceDialog.cpp @@ -81,7 +81,7 @@ void CTVNewSequenceDialog::OnOK() for (unsigned int k = 0; k < GetIEditor()->GetSequenceManager()->GetCount(); ++k) { CTrackViewSequence* pSequence = GetIEditor()->GetSequenceManager()->GetSequenceByIndex(k); - QString fullname = pSequence->GetName(); + QString fullname = QString::fromUtf8(pSequence->GetName().c_str()); if (fullname.compare(m_sequenceName, Qt::CaseInsensitive) == 0) { diff --git a/Code/Editor/Util/ColorUtils.cpp b/Code/Editor/Util/ColorUtils.cpp index 4e240bc51b..02e3c9b615 100644 --- a/Code/Editor/Util/ColorUtils.cpp +++ b/Code/Editor/Util/ColorUtils.cpp @@ -24,7 +24,7 @@ QColor ColorLinearToGamma(ColorF col) g = (float)(g <= 0.0031308 ? (12.92 * g) : (1.055 * pow((double)g, 1.0 / 2.4) - 0.055)); b = (float)(b <= 0.0031308 ? (12.92 * b) : (1.055 * pow((double)b, 1.0 / 2.4) - 0.055)); - return QColor(FtoI(r * 255.0f), FtoI(g * 255.0f), FtoI(b * 255.0f), FtoI(a * 255.0f)); + return QColor(int(r * 255.0f), int(g * 255.0f), int(b * 255.0f), int(a * 255.0f)); } ////////////////////////////////////////////////////////////////////////// diff --git a/Code/Editor/Util/ColumnGroupTreeView.h b/Code/Editor/Util/ColumnGroupTreeView.h index c9226df8d0..3c7dea91c3 100644 --- a/Code/Editor/Util/ColumnGroupTreeView.h +++ b/Code/Editor/Util/ColumnGroupTreeView.h @@ -71,7 +71,6 @@ private: ColumnGroupHeaderView* m_header; ColumnGroupProxyModel* m_groupModel; QSet m_openNodes; - bool m_showGroups; }; #endif // COLUMNGROUPTREEVIEW_H diff --git a/Code/Editor/Util/EditorUtils.cpp b/Code/Editor/Util/EditorUtils.cpp index de06a95a62..adae34773a 100644 --- a/Code/Editor/Util/EditorUtils.cpp +++ b/Code/Editor/Util/EditorUtils.cpp @@ -205,7 +205,7 @@ QColor ColorLinearToGamma(ColorF col) g = (float)(g <= 0.0031308 ? (12.92 * g) : (1.055 * pow((double)g, 1.0 / 2.4) - 0.055)); b = (float)(b <= 0.0031308 ? (12.92 * b) : (1.055 * pow((double)b, 1.0 / 2.4) - 0.055)); - return QColor(FtoI(r * 255.0f), FtoI(g * 255.0f), FtoI(b * 255.0f), FtoI(a * 255.0f)); + return QColor(int(r * 255.0f), int(g * 255.0f), int(b * 255.0f), int(a * 255.0f)); } ////////////////////////////////////////////////////////////////////////// diff --git a/Code/Editor/Util/FileUtil.cpp b/Code/Editor/Util/FileUtil.cpp index 435ec67a99..610a9c6e16 100644 --- a/Code/Editor/Util/FileUtil.cpp +++ b/Code/Editor/Util/FileUtil.cpp @@ -1221,15 +1221,14 @@ bool CFileUtil::CreatePath(const QString& strPath) if (!strDriveLetter.isEmpty()) { strCurrentDirectoryPath = strDriveLetter; - strCurrentDirectoryPath += "\\"; + strCurrentDirectoryPath += AZ_CORRECT_FILESYSTEM_SEPARATOR_STRING; } - nTotalPathQueueElements = cstrDirectoryQueue.size(); for (nCurrentPathQueue = 0; nCurrentPathQueue < nTotalPathQueueElements; ++nCurrentPathQueue) { strCurrentDirectoryPath += cstrDirectoryQueue[static_cast(nCurrentPathQueue)]; - strCurrentDirectoryPath += "\\"; + strCurrentDirectoryPath += AZ_CORRECT_FILESYSTEM_SEPARATOR_STRING; // The value which will go out of this loop is the result of the attempt to create the // last directory, only. @@ -2158,7 +2157,6 @@ uint32 CFileUtil::GetAttributes(const char* filename, bool bUseSourceControl /*= return SCC_FILE_ATTRIBUTE_READONLY | SCC_FILE_ATTRIBUTE_INPAK; } - const char* adjustedFile = file.GetAdjustedFilename(); if (!AZ::IO::SystemFile::Exists(adjustedFile)) { diff --git a/Code/Editor/Util/GuidUtil.h b/Code/Editor/Util/GuidUtil.h index 9952d6b4ed..de2bad8759 100644 --- a/Code/Editor/Util/GuidUtil.h +++ b/Code/Editor/Util/GuidUtil.h @@ -48,7 +48,7 @@ inline bool GuidUtil::IsEmpty(REFGUID guid) inline const char* GuidUtil::ToString(REFGUID guid) { static char guidString[64]; - sprintf_s(guidString, "{%.8X-%.4X-%.4X-%.2X%.2X-%.2X%.2X%.2X%.2X%.2X%.2X}", guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1], + sprintf_s(guidString, "{%.8" GUID_FORMAT_DATA1 "-%.4X-%.4X-%.2X%.2X-%.2X%.2X%.2X%.2X%.2X%.2X}", guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]); return guidString; } @@ -62,7 +62,7 @@ inline GUID GuidUtil::FromString(const char* guidString) guid.Data1 = 0; guid.Data2 = 0; guid.Data3 = 0; - azsscanf(guidString, "{%8" SCNx32 "-%4hX-%4hX-%2X%2X-%2X%2X%2X%2X%2X%2X}", + azsscanf(guidString, "{%8" GUID_FORMAT_DATA1 "-%4hX-%4hX-%2X%2X-%2X%2X%2X%2X%2X%2X}", &guid.Data1, &guid.Data2, &guid.Data3, &d[0], &d[1], &d[2], &d[3], &d[4], &d[5], &d[6], &d[7]); guid.Data4[0] = static_cast(d[0]); guid.Data4[1] = static_cast(d[1]); diff --git a/Code/Editor/Util/Image.h b/Code/Editor/Util/Image.h index 8886598c43..a6d36673cb 100644 --- a/Code/Editor/Util/Image.h +++ b/Code/Editor/Util/Image.h @@ -178,7 +178,6 @@ public: ////////////////////////////////////////////////////////////////////////// void GetSubImage(int x1, int y1, int width, int height, TImage& img) const { - int size = width * height; img.Allocate(width, height); for (int y = 0; y < height; y++) { diff --git a/Code/Editor/Util/ImageASC.cpp b/Code/Editor/Util/ImageASC.cpp index c166917a68..a72ea8b9fd 100644 --- a/Code/Editor/Util/ImageASC.cpp +++ b/Code/Editor/Util/ImageASC.cpp @@ -99,7 +99,7 @@ bool CImageASC::Load(const QString& fileName, CFloatImage& image) // Break all of the values in the file apart into tokens. - char* nextToken = nullptr; + [[maybe_unused]] char* nextToken = nullptr; token = azstrtok(str, 0, seps, &nextToken); // ncols = grid width diff --git a/Code/Editor/Util/ImageGif.cpp b/Code/Editor/Util/ImageGif.cpp index a9ab4efdaf..67c5911344 100644 --- a/Code/Editor/Util/ImageGif.cpp +++ b/Code/Editor/Util/ImageGif.cpp @@ -76,8 +76,6 @@ static int numused; const char* id87 = "GIF87a"; const char* id89 = "GIF89a"; -static int log2 (int); - /* Fetch the next code from the raster data stream. The codes can be * any length from 3 to 12 bits, packed into 8-bit bytes, so we have to * maintain our location in the Raster array as a BIT Offset. We compute diff --git a/Code/Editor/Util/ImageUtil.cpp b/Code/Editor/Util/ImageUtil.cpp index 00e33162cf..c8432a3d1a 100644 --- a/Code/Editor/Util/ImageUtil.cpp +++ b/Code/Editor/Util/ImageUtil.cpp @@ -145,7 +145,7 @@ bool CImageUtil::LoadPGM(const QString& fileName, CImageEx& image) char* str = new char[fileSize]; fread(str, fileSize, 1, file); - char* nextToken = nullptr; + [[maybe_unused]] char* nextToken = nullptr; token = azstrtok(str, 0, seps, &nextToken); while (token != nullptr && token[0] == '#') diff --git a/Code/Editor/Util/Math.h b/Code/Editor/Util/Math.h index 34fb77e434..10402876e6 100644 --- a/Code/Editor/Util/Math.h +++ b/Code/Editor/Util/Math.h @@ -14,6 +14,7 @@ #pragma once #include +#include //! Half PI #define PI_HALF (3.1415926535897932384626433832795f / 2.0f) diff --git a/Code/Editor/Util/StringHelpers.cpp b/Code/Editor/Util/StringHelpers.cpp index d0999d6ae2..9ef3e86e7a 100644 --- a/Code/Editor/Util/StringHelpers.cpp +++ b/Code/Editor/Util/StringHelpers.cpp @@ -9,6 +9,7 @@ #include "StringHelpers.h" #include "Util.h" +#include int StringHelpers::CompareIgnoreCase(const AZStd::string& str0, const AZStd::string& str1) { diff --git a/Code/Editor/ViewPane.h b/Code/Editor/ViewPane.h index 5771a687c0..8cc9170e5f 100644 --- a/Code/Editor/ViewPane.h +++ b/Code/Editor/ViewPane.h @@ -118,7 +118,6 @@ private: int m_id; int m_nBorder; - int m_titleHeight; QWidget* m_viewport; QScrollArea* m_viewportScrollArea = nullptr; diff --git a/Code/Editor/editor_lib_files.cmake b/Code/Editor/editor_lib_files.cmake index 6c5096a8f5..24634b245d 100644 --- a/Code/Editor/editor_lib_files.cmake +++ b/Code/Editor/editor_lib_files.cmake @@ -290,7 +290,6 @@ set(FILES Include/IPreferencesPage.h Include/IRenderListener.h Include/ISourceControl.h - Include/ISubObjectSelectionReferenceFrameCalculator.h Include/ITextureDatabaseUpdater.h Include/ITransformManipulator.h Include/IViewPane.h @@ -460,8 +459,6 @@ set(FILES Dialogs/PythonScriptsDialog.ui Dialogs/Generic/UserOptions.cpp Dialogs/Generic/UserOptions.h - EditMode/SubObjectSelectionReferenceFrameCalculator.cpp - EditMode/SubObjectSelectionReferenceFrameCalculator.h Export/ExportManager.cpp Export/ExportManager.h Export/OBJExporter.cpp @@ -790,6 +787,9 @@ set(FILES EditorViewportSettings.h EditorViewportCamera.cpp EditorViewportCamera.h + EditorModularViewportCameraComposer.cpp + EditorModularViewportCameraComposer.h + EditorModularViewportCameraComposerBus.h ViewportManipulatorController.cpp ViewportManipulatorController.h TopRendererWnd.cpp diff --git a/Code/Framework/AtomCore/Tests/InstanceDatabase.cpp b/Code/Framework/AtomCore/Tests/InstanceDatabase.cpp index 7b47a9b99e..5d1edc5a09 100644 --- a/Code/Framework/AtomCore/Tests/InstanceDatabase.cpp +++ b/Code/Framework/AtomCore/Tests/InstanceDatabase.cpp @@ -324,7 +324,7 @@ namespace UnitTest // Tests whether the deleter actually calls delete properly without // a parent database. - instance->m_onDeleteCallback = [this, &m_deleted]() + instance->m_onDeleteCallback = [&m_deleted]() { m_deleted = true; }; diff --git a/Code/Framework/AzCore/AzCore/Component/ComponentApplication.cpp b/Code/Framework/AzCore/AzCore/Component/ComponentApplication.cpp index 383da71653..eda08401a2 100644 --- a/Code/Framework/AzCore/AzCore/Component/ComponentApplication.cpp +++ b/Code/Framework/AzCore/AzCore/Component/ComponentApplication.cpp @@ -1266,7 +1266,7 @@ namespace AZ void Visit(AZStd::string_view path, AZStd::string_view, AZ::SettingsRegistryInterface::Type, AZStd::string_view value) override { // Remove last path segment and check if the key corresponds to the Modules array - AZStd::optional moduleIndex = AZ::StringFunc::TokenizeLast(path, "/"); + AZ::StringFunc::TokenizeLast(path, "/"); if (path.ends_with("/Modules")) { // Remove the "Modules" path segment to be at the GemName key diff --git a/Code/Framework/AzCore/AzCore/Component/EntitySerializer.cpp b/Code/Framework/AzCore/AzCore/Component/EntitySerializer.cpp index 64ba9b2c2c..803daf1373 100644 --- a/Code/Framework/AzCore/AzCore/Component/EntitySerializer.cpp +++ b/Code/Framework/AzCore/AzCore/Component/EntitySerializer.cpp @@ -94,12 +94,9 @@ namespace AZ result.Combine(componentLoadResult); } - { - JSR::ResultCode runtimeActiveLoadResult = - ContinueLoadingFromJsonObjectField(&entityInstance->m_isRuntimeActiveByDefault, - azrtti_typeidm_isRuntimeActiveByDefault)>(), - inputValue, "IsRuntimeActive", context); - } + ContinueLoadingFromJsonObjectField(&entityInstance->m_isRuntimeActiveByDefault, + azrtti_typeidm_isRuntimeActiveByDefault)>(), + inputValue, "IsRuntimeActive", context); return context.Report( result, diff --git a/Code/Framework/AzCore/AzCore/Component/EntityUtils.cpp b/Code/Framework/AzCore/AzCore/Component/EntityUtils.cpp index 8241400aac..fcc8cd6424 100644 --- a/Code/Framework/AzCore/AzCore/Component/EntityUtils.cpp +++ b/Code/Framework/AzCore/AzCore/Component/EntityUtils.cpp @@ -165,7 +165,7 @@ namespace AZ AZStd::fixed_vector knownBaseClasses = { typeToExamine }; // avoid allocating heap here if possible. 64 types are 64*sizeof(Uuid) which is only 1k. bool foundBaseClass = false; - auto enumerateBaseVisitor = [&foundBaseClass, &baseClassVisitor, &knownBaseClasses](const AZ::SerializeContext::ClassData* classData, const TypeId& examineTypeId) + auto enumerateBaseVisitor = [&baseClassVisitor, &knownBaseClasses](const AZ::SerializeContext::ClassData* classData, const TypeId& examineTypeId) { if (!classData) { diff --git a/Code/Framework/AzCore/AzCore/Debug/BudgetTracker.cpp b/Code/Framework/AzCore/AzCore/Debug/BudgetTracker.cpp index 255a740e32..2dac9a566e 100644 --- a/Code/Framework/AzCore/AzCore/Debug/BudgetTracker.cpp +++ b/Code/Framework/AzCore/AzCore/Debug/BudgetTracker.cpp @@ -17,8 +17,6 @@ namespace AZ::Debug { - constexpr static const char* BudgetTrackerEnvName = "budgetTrackerEnv"; - struct BudgetTracker::BudgetTrackerImpl { AZStd::unordered_map m_budgets; diff --git a/Code/Framework/AzCore/AzCore/Debug/EventTraceDriller.cpp b/Code/Framework/AzCore/AzCore/Debug/EventTraceDriller.cpp index 1fdd249138..658021b018 100644 --- a/Code/Framework/AzCore/AzCore/Debug/EventTraceDriller.cpp +++ b/Code/Framework/AzCore/AzCore/Debug/EventTraceDriller.cpp @@ -26,7 +26,6 @@ namespace AZ const u32 Timestamp = AZ_CRC("Timestamp", 0xa5d6e63e); const u32 Duration = AZ_CRC("Duration", 0x865f80c0); const u32 Instant = AZ_CRC("Instant", 0x0e9047ad); - const u32 InstantScope = AZ_CRC("InstantScope", 0xed4bfb0e); } EventTraceDriller::EventTraceDriller() diff --git a/Code/Framework/AzCore/AzCore/Debug/Profiler.h b/Code/Framework/AzCore/AzCore/Debug/Profiler.h index c8911a6ac4..8af48e47f6 100644 --- a/Code/Framework/AzCore/AzCore/Debug/Profiler.h +++ b/Code/Framework/AzCore/AzCore/Debug/Profiler.h @@ -77,11 +77,4 @@ namespace AZ::Debug }; } // namespace AZ::Debug -#ifdef USE_PIX -// The pix3 header unfortunately brings in other Windows macros we need to undef -#undef DeleteFile -#undef LoadImage -#undef GetCurrentTime -#endif - #include diff --git a/Code/Framework/AzCore/AzCore/Debug/Trace.cpp b/Code/Framework/AzCore/AzCore/Debug/Trace.cpp index bd3b12a3b8..74ecee40e5 100644 --- a/Code/Framework/AzCore/AzCore/Debug/Trace.cpp +++ b/Code/Framework/AzCore/AzCore/Debug/Trace.cpp @@ -66,7 +66,6 @@ namespace AZ static const int assertLevel_log = 1; static const int assertLevel_nativeUI = 2; static const int assertLevel_crash = 3; - static const int logLevel_errorWarning = 1; static const int logLevel_full = 2; static AZ::EnvironmentVariable> g_ignoredAsserts; static AZ::EnvironmentVariable g_assertVerbosityLevel; diff --git a/Code/Framework/AzCore/AzCore/EBus/BusImpl.h b/Code/Framework/AzCore/AzCore/EBus/BusImpl.h index 882deaad01..8e655c0525 100644 --- a/Code/Framework/AzCore/AzCore/EBus/BusImpl.h +++ b/Code/Framework/AzCore/AzCore/EBus/BusImpl.h @@ -655,7 +655,7 @@ namespace AZ static void Validate() {} }; - template > + template struct ArgumentValidatorHelper { constexpr static void Validate() @@ -674,13 +674,6 @@ namespace AZ } }; - // bind has already copied/bound its arguments, we can't validate them further in any reasonable way - template - struct ArgumentValidatorHelper - { - constexpr static void Validate() {} - }; - template struct QueueFunctionArgumentValidator { diff --git a/Code/Framework/AzCore/AzCore/Math/Guid.h b/Code/Framework/AzCore/AzCore/Math/Guid.h index 53bab4d7ed..325866dad5 100644 --- a/Code/Framework/AzCore/AzCore/Math/Guid.h +++ b/Code/Framework/AzCore/AzCore/Math/Guid.h @@ -8,25 +8,21 @@ #ifndef AZ_CORE_GUID_H #define AZ_CORE_GUID_H 1 -#ifndef GUID_DEFINED +#if defined(GUID_DEFINED) +#define GUID_FORMAT_DATA1 "lX" +#else #define GUID_DEFINED -typedef struct _GUID { - _GUID(unsigned long d1, unsigned short d2, unsigned short d3, std::initializer_list d4) - : Data1(d1), - Data2(d2), - Data3(d3) - { - for (auto it = d4.begin(); it != d4.end(); ++it) - Data4[it - d4.begin()] = *it; - } - _GUID() = default; +#include - uint32_t Data1; +struct _GUID { + uint32_t Data1; unsigned short Data2; unsigned short Data3; - unsigned char Data4[ 8 ]; -} GUID; + AZStd::array Data4; +}; +using GUID = _GUID; +#define GUID_FORMAT_DATA1 "X" #endif // GUID_DEFINED #if !defined _SYS_GUID_OPERATOR_EQ_ && !defined _NO_SYS_GUID_OPERATOR_EQ_ @@ -36,7 +32,7 @@ static bool inline operator==(const _GUID& lhs, const _GUID& rhs) return lhs.Data1 == rhs.Data1 && lhs.Data2 == rhs.Data2 && lhs.Data3 == rhs.Data3 && - memcmp(lhs.Data4, rhs.Data4, 8) == 0; + lhs.Data4 == rhs.Data4; } static bool inline operator!=(const _GUID& lhs, const _GUID& rhs) { @@ -66,10 +62,9 @@ typedef const GUID& REFIID; const GUID name \ = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } -static REFGUID GUID_NULL() +inline constexpr GUID GUID_NULL() { - static const GUID guid = { 0x00000000L, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; - return guid; + return { 0x00000000L, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; } #define GUID_NULL GUID_NULL() diff --git a/Code/Framework/AzCore/AzCore/Math/Internal/SimdMathCommon_simd.inl b/Code/Framework/AzCore/AzCore/Math/Internal/SimdMathCommon_simd.inl index b27abf120f..86ea0280ab 100644 --- a/Code/Framework/AzCore/AzCore/Math/Internal/SimdMathCommon_simd.inl +++ b/Code/Framework/AzCore/AzCore/Math/Internal/SimdMathCommon_simd.inl @@ -339,7 +339,6 @@ namespace AZ { const typename VecType::FloatType x_eq_0 = VecType::CmpEq(x, VecType::ZeroFloat()); const typename VecType::FloatType x_ge_0 = VecType::CmpGtEq(x, VecType::ZeroFloat()); - const typename VecType::FloatType x_le_0 = VecType::CmpLtEq(x, VecType::ZeroFloat()); const typename VecType::FloatType x_lt_0 = VecType::CmpLt(x, VecType::ZeroFloat()); const typename VecType::FloatType y_eq_0 = VecType::CmpEq(y, VecType::ZeroFloat()); @@ -363,7 +362,6 @@ namespace AZ typename VecType::FloatType swap_sign_mask_offset = VecType::And(x_lt_0, y_lt_0); swap_sign_mask_offset = VecType::And(swap_sign_mask_offset, VecType::CastToFloat(FastLoadConstant(Simd::g_negateMask))); - const typename VecType::FloatType offset0 = VecType::ZeroFloat(); typename VecType::FloatType offset1 = FastLoadConstant(g_Pi); offset1 = VecType::Xor(offset1, swap_sign_mask_offset); diff --git a/Code/Framework/AzCore/AzCore/Math/Internal/SimdMathVec4_scalar.inl b/Code/Framework/AzCore/AzCore/Math/Internal/SimdMathVec4_scalar.inl index 484351c799..68d4f103fe 100644 --- a/Code/Framework/AzCore/AzCore/Math/Internal/SimdMathVec4_scalar.inl +++ b/Code/Framework/AzCore/AzCore/Math/Internal/SimdMathVec4_scalar.inl @@ -867,7 +867,6 @@ namespace AZ const FloatType cols0 = {{ rows[0].v[0], rows[1].v[0], rows[2].v[0], 0.0f }}; const FloatType cols1 = {{ rows[0].v[1], rows[1].v[1], rows[2].v[1], 0.0f }}; const FloatType cols2 = {{ rows[0].v[2], rows[1].v[2], rows[2].v[2], 0.0f }}; - const FloatType cols3 = {{ rows[0].v[3], rows[1].v[3], rows[2].v[3], 1.0f }}; out[0] = cols0; out[1] = cols1; out[2] = cols2; diff --git a/Code/Framework/AzCore/AzCore/Memory/AllocatorScope.h b/Code/Framework/AzCore/AzCore/Memory/AllocatorScope.h index 3d97a3042d..4f9aabb4be 100644 --- a/Code/Framework/AzCore/AzCore/Memory/AllocatorScope.h +++ b/Code/Framework/AzCore/AzCore/Memory/AllocatorScope.h @@ -20,9 +20,7 @@ namespace AZ public: void ActivateAllocators() { - // Note the parameter pack expansion, this creates the equivalent of a fold expression - // For each type, call InitAllocator(), then put 0 in the initializer list - std::initializer_list init{(InitAllocator(), 0)...}; + (InitAllocator(), ...); } void DeactivateAllocators() diff --git a/Code/Framework/AzCore/AzCore/RTTI/BehaviorContext.h b/Code/Framework/AzCore/AzCore/RTTI/BehaviorContext.h index 1c81a15bda..f02c37492b 100644 --- a/Code/Framework/AzCore/AzCore/RTTI/BehaviorContext.h +++ b/Code/Framework/AzCore/AzCore/RTTI/BehaviorContext.h @@ -3774,8 +3774,7 @@ namespace AZ template inline void OnDemandReflectFunctions(OnDemandReflectionOwner* onDemandReflection, AZStd::Internal::pack_traits_arg_sequence) { - using PackExpander = bool[]; - PackExpander{ true, (BehaviorOnDemandReflectHelper::raw_fp_type>::QueueReflect(onDemandReflection), true)... }; + (BehaviorOnDemandReflectHelper::raw_fp_type>::QueueReflect(onDemandReflection), ...); } // Assumes parameters array is big enough to store all parameters diff --git a/Code/Framework/AzCore/AzCore/RTTI/RTTI.h b/Code/Framework/AzCore/AzCore/RTTI/RTTI.h index 1f133c3256..fa081a9497 100644 --- a/Code/Framework/AzCore/AzCore/RTTI/RTTI.h +++ b/Code/Framework/AzCore/AzCore/RTTI/RTTI.h @@ -493,7 +493,7 @@ namespace AZ const void* result = GetTypeId() == asType ? instance : nullptr; using dummy = bool[]; - dummy{ true, (CastInternal(result, instance, asType), true)... }; + [[maybe_unused]] dummy d { true, (CastInternal(result, instance, asType), true)... }; return result; } @@ -517,7 +517,7 @@ namespace AZ bool result = GetTypeId() == id; using dummy = bool[]; - dummy{ true, (IsTypeOfInternal(result, id), true)... }; + [[maybe_unused]] dummy d = { true, (IsTypeOfInternal(result, id), true)... }; return result; } @@ -534,7 +534,7 @@ namespace AZ callback(GetActualUuid(instance), instance); using dummy = bool[]; - dummy{ true, (RttiHelper{}.EnumHierarchy(callback, instance), true)... }; + [[maybe_unused]] dummy d = { true, (RttiHelper{}.EnumHierarchy(callback, instance), true)... }; } TypeTraits GetTypeTraits() const override { diff --git a/Code/Framework/AzCore/AzCore/Serialization/AZStdContainers.inl b/Code/Framework/AzCore/AzCore/Serialization/AZStdContainers.inl index 9eb65dec76..bae79a6fe7 100644 --- a/Code/Framework/AzCore/AzCore/Serialization/AZStdContainers.inl +++ b/Code/Framework/AzCore/AzCore/Serialization/AZStdContainers.inl @@ -1320,7 +1320,7 @@ namespace AZ (void)classElement; void* reserveElement{}; using DummyArray = bool[]; - DummyArray{ true, (ReserveElementTuple(tupleRef, classElement, reserveElement))... }; + [[maybe_unused]] DummyArray dummy = { true, (ReserveElementTuple(tupleRef, classElement, reserveElement))... }; return reserveElement; } diff --git a/Code/Framework/AzCore/AzCore/Serialization/DataPatch.cpp b/Code/Framework/AzCore/AzCore/Serialization/DataPatch.cpp index edc0e8398b..01a98667fa 100644 --- a/Code/Framework/AzCore/AzCore/Serialization/DataPatch.cpp +++ b/Code/Framework/AzCore/AzCore/Serialization/DataPatch.cpp @@ -135,7 +135,6 @@ namespace AZ AZStd::list m_dynamicClassElements; ///< Storage for class elements that represent dynamic serializable fields. }; - static bool ConvertLegacyBoolToEnum(AZ::SerializeContext& context, AZStd::any& patchAny, const DataNode& sourceNode); static void ReportDataPatchMismatch(SerializeContext* context, const SerializeContext::ClassElement* classElement, const TypeId& patchDataTypeId); //========================================================================= diff --git a/Code/Framework/AzCore/AzCore/Serialization/Json/JsonSerializer.cpp b/Code/Framework/AzCore/AzCore/Serialization/Json/JsonSerializer.cpp index 80a81181e5..f06fb36be8 100644 --- a/Code/Framework/AzCore/AzCore/Serialization/Json/JsonSerializer.cpp +++ b/Code/Framework/AzCore/AzCore/Serialization/Json/JsonSerializer.cpp @@ -161,7 +161,6 @@ namespace AZ using namespace JsonSerializationResult; StoreTypeId storeTypeId = StoreTypeId::No; - Uuid resolvedTypeId = classData.m_typeId; const SerializeContext::ClassData* resolvedClassData = &classData; AZStd::any defaultPointerObject; diff --git a/Code/Framework/AzCore/AzCore/Serialization/Json/JsonUtils.cpp b/Code/Framework/AzCore/AzCore/Serialization/Json/JsonUtils.cpp index d04c23f536..8f2ebaba8d 100644 --- a/Code/Framework/AzCore/AzCore/Serialization/Json/JsonUtils.cpp +++ b/Code/Framework/AzCore/AzCore/Serialization/Json/JsonUtils.cpp @@ -32,7 +32,6 @@ namespace AZ static const char* FileType = "JsonSerialization"; static const char* VersionTag = "Version"; static const char* ClassNameTag = "ClassName"; - static const char* ClassIdTag = "ClassId"; static const char* ClassDataTag = "ClassData"; AZ::Outcome WriteJsonString(const rapidjson::Document& document, AZStd::string& jsonText, WriteJsonSettings settings) diff --git a/Code/Framework/AzCore/AzCore/Serialization/std/VariantReflection.inl b/Code/Framework/AzCore/AzCore/Serialization/std/VariantReflection.inl index 391133dd9f..70972bb846 100644 --- a/Code/Framework/AzCore/AzCore/Serialization/std/VariantReflection.inl +++ b/Code/Framework/AzCore/AzCore/Serialization/std/VariantReflection.inl @@ -483,9 +483,9 @@ namespace AZ } private: static void ObjectStreamWriter(SerializeContext::EnumerateInstanceCallContext& callContext, const void* variantPtr, - const SerializeContext::ClassData& variantClassData, const SerializeContext::ClassElement* variantClassElement) + [[maybe_unused]] const SerializeContext::ClassData& variantClassData, const SerializeContext::ClassElement* variantClassElement) { - auto alternativeVisitor = [&callContext, &variantClassData, variantClassElement](auto&& elementAlt) + auto alternativeVisitor = [&callContext, variantClassElement](auto&& elementAlt) { using AltType = AZStd::remove_cvref_t; const SerializeContext& context = *callContext.m_context; diff --git a/Code/Framework/AzCore/AzCore/base.h b/Code/Framework/AzCore/AzCore/base.h index 20f5c17b27..f6ae39dcda 100644 --- a/Code/Framework/AzCore/AzCore/base.h +++ b/Code/Framework/AzCore/AzCore/base.h @@ -293,7 +293,7 @@ namespace AZ #define AZ_DEFAULT_COPY_MOVE(_Class) AZ_DEFAULT_COPY(_Class) AZ_DEFAULT_MOVE(_Class) // Macro that can be used to avoid unreferenced variable warnings -#define AZ_UNUSED(x) (void)x; +#define AZ_UNUSED(x) (void)x #define AZ_DEFINE_ENUM_BITWISE_OPERATORS(EnumType) \ inline constexpr EnumType operator | (EnumType a, EnumType b) \ diff --git a/Code/Framework/AzCore/AzCore/std/string/string_view.h b/Code/Framework/AzCore/AzCore/std/string/string_view.h index 4ded44644f..b2390c293a 100644 --- a/Code/Framework/AzCore/AzCore/std/string/string_view.h +++ b/Code/Framework/AzCore/AzCore/std/string/string_view.h @@ -9,6 +9,7 @@ #include #include +#include namespace AZStd @@ -875,22 +876,7 @@ namespace AZStd for (; first != last; ++first) { hash ^= static_cast(*first); -#if AZ_COMPILER_MSVC < 1924 - // Workaround for integer overflow warning for hash function when used in a constexpr context - // The warning must be disabled at the call site and is a compiler bug that has been fixed - // with Visual Studio 2019 version 16.4 - // https://developercommunity.visualstudio.com/content/problem/211134/unsigned-integer-overflows-in-constexpr-functionsa.html?childToView=211580#comment-211580 - constexpr size_t fnvPrimeHigh{ 0x100ULL }; - constexpr size_t fnvPrimeLow{ 0x000001b3 }; - const uint64_t hashHigh{ hash >> 32 }; - const uint64_t hashLow{ hash & 0xFFFF'FFFF }; - const uint64_t lowResult{ hashLow * fnvPrimeLow }; - const uint64_t fnvPrimeHighResult{ hashLow * fnvPrimeHigh }; - const uint64_t hashHighResult{ hashHigh * fnvPrimeLow }; - hash = (lowResult & 0xffff'ffff) + (((lowResult >> 32) + (fnvPrimeHighResult & 0xffff'ffff) + (hashHighResult & 0xffff'ffff)) << 32); -#else hash *= fnvPrime; -#endif } return hash; } diff --git a/Code/Framework/AzCore/Platform/Common/UnixLike/AzCore/Debug/StackTracer_UnixLike.cpp b/Code/Framework/AzCore/Platform/Common/UnixLike/AzCore/Debug/StackTracer_UnixLike.cpp index abfabbbd54..f66a9d3b18 100644 --- a/Code/Framework/AzCore/Platform/Common/UnixLike/AzCore/Debug/StackTracer_UnixLike.cpp +++ b/Code/Framework/AzCore/Platform/Common/UnixLike/AzCore/Debug/StackTracer_UnixLike.cpp @@ -57,7 +57,7 @@ StackRecorder::Record(StackFrame* frames, unsigned int maxNumOfFrames, unsigned int skip = static_cast((suppressCount == 0) ? 1 : suppressCount); // Skip at least this function while ((unw_step(&cursor) > 0) && (count < maxNumOfFrames)) { - unw_word_t offset, pc; + unw_word_t pc; unw_get_reg(&cursor, UNW_REG_IP, &pc); if (pc == 0) { diff --git a/Code/Framework/AzCore/Platform/Common/WinAPI/AzCore/Debug/Trace_WinAPI.cpp b/Code/Framework/AzCore/Platform/Common/WinAPI/AzCore/Debug/Trace_WinAPI.cpp index 99ea10e4bc..02c1988215 100644 --- a/Code/Framework/AzCore/Platform/Common/WinAPI/AzCore/Debug/Trace_WinAPI.cpp +++ b/Code/Framework/AzCore/Platform/Common/WinAPI/AzCore/Debug/Trace_WinAPI.cpp @@ -145,7 +145,7 @@ namespace AZ char message[g_maxMessageLength]; Debug::Trace::Instance().Output(nullptr, "==================================================================\n"); - azsnprintf(message, g_maxMessageLength, "Exception : 0x%X - '%s' [%p]\n", ExceptionInfo->ExceptionRecord->ExceptionCode, GetExeptionName(ExceptionInfo->ExceptionRecord->ExceptionCode), ExceptionInfo->ExceptionRecord->ExceptionAddress); + azsnprintf(message, g_maxMessageLength, "Exception : 0x%lX - '%s' [%p]\n", ExceptionInfo->ExceptionRecord->ExceptionCode, GetExeptionName(ExceptionInfo->ExceptionRecord->ExceptionCode), ExceptionInfo->ExceptionRecord->ExceptionAddress); Debug::Trace::Instance().Output(nullptr, message); EBUS_EVENT(Debug::TraceMessageDrillerBus, OnException, message); diff --git a/Code/Framework/AzCore/Platform/Windows/AzCore/Debug/StackTracer_Windows.cpp b/Code/Framework/AzCore/Platform/Windows/AzCore/Debug/StackTracer_Windows.cpp index f8f94ea2b3..b2a1410bf5 100644 --- a/Code/Framework/AzCore/Platform/Windows/AzCore/Debug/StackTracer_Windows.cpp +++ b/Code/Framework/AzCore/Platform/Windows/AzCore/Debug/StackTracer_Windows.cpp @@ -478,7 +478,7 @@ namespace AZ { DWORD displacement; if (g_SymGetLineFromAddr64(g_currentProcess, pc, &displacement, &line) && line.FileName[0] != 0) { - azsnprintf(textLine, textLineSize, "%s (%d) : ", line.FileName, line.LineNumber); + azsnprintf(textLine, textLineSize, "%s (%ld) : ", line.FileName, line.LineNumber); } else { diff --git a/Code/Framework/AzCore/Platform/Windows/AzCore/IO/Streamer/StreamerConfiguration_Windows.cpp b/Code/Framework/AzCore/Platform/Windows/AzCore/IO/Streamer/StreamerConfiguration_Windows.cpp index 0813d2d057..fe6d83b7a4 100644 --- a/Code/Framework/AzCore/Platform/Windows/AzCore/IO/Streamer/StreamerConfiguration_Windows.cpp +++ b/Code/Framework/AzCore/Platform/Windows/AzCore/IO/Streamer/StreamerConfiguration_Windows.cpp @@ -14,6 +14,9 @@ #include #include #include + +// https://developercommunity.visualstudio.com/t/windows-sdk-100177630-pragma-push-pop-mismatch-in/386142 +#define _NTDDSCM_H_ #include namespace AZ::IO diff --git a/Code/Framework/AzCore/Platform/Windows/AzCore/PlatformIncl_Windows.h b/Code/Framework/AzCore/Platform/Windows/AzCore/PlatformIncl_Windows.h index f58e772155..d2eaa3446f 100644 --- a/Code/Framework/AzCore/Platform/Windows/AzCore/PlatformIncl_Windows.h +++ b/Code/Framework/AzCore/Platform/Windows/AzCore/PlatformIncl_Windows.h @@ -34,7 +34,6 @@ ////#define NOMB //- MB_* and MessageBox() //#define NOMEMMGR //- GMEM_*, LMEM_*, GHND, LHND, associated routines //#define NOMETAFILE //- typedef METAFILEPICT -////#define NOMINMAX //- Macros min(a,b) and max(a,b) //#define NOMSG //- typedef MSG and associated routines //#define NOOPENFILE //- OpenFile(), OemToAnsi, AnsiToOem, and OF_* //#define NOSCROLL //- SB_* and scrolling routines @@ -50,27 +49,34 @@ //#define NODEFERWINDOWPOS //- DeferWindowPos routines //#define NOMCX //- Modem Configuration Extensions -// //declare intrinsics to make sure we get the inline intrinsic versions and not a function call #if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0602) -# undef _WIN32_WINNT -# define _WIN32_WINNT 0x0602 // Windows Server 2012 and later + #undef _WIN32_WINNT + #define _WIN32_WINNT 0x0602 // Windows Server 2012 and later #endif -#ifdef NOMINMAX -# include -# include -#else -# define NOMINMAX -# include -# include -# undef NOMINMAX +#if !defined(NOMINMAX) + #define NOMINMAX // - Dont define Macros min(a,b) and max(a,b) #endif + +#include +#include + // Undef common function names that Windows.h defines #if defined(SetJob) -#undef SetJob + #undef SetJob #endif #if defined(GetObject) -#undef GetObject + #undef GetObject #endif #if defined(GetCommandLine) -#undef GetCommandLine + #undef GetCommandLine #endif +#if defined(LoadImage) +#undef LoadImage +#endif +#if defined(DeleteFile) +#undef DeleteFile +#endif +#if defined(GetCurrentTime) +#undef GetCurrentTime +#endif + diff --git a/Code/Framework/AzCore/Tests/AZStd/Algorithms.cpp b/Code/Framework/AzCore/Tests/AZStd/Algorithms.cpp index 2bb799e627..a1c9e5d79e 100644 --- a/Code/Framework/AzCore/Tests/AZStd/Algorithms.cpp +++ b/Code/Framework/AzCore/Tests/AZStd/Algorithms.cpp @@ -1032,7 +1032,7 @@ namespace UnitTest auto CreateArray = []() constexpr -> AZStd::array { AZStd::array localArray = { {1, 2, 3} }; - auto resultFunc = AZStd::for_each(localArray.begin(), localArray.end(), [](int& element) { ++element; }); + AZStd::for_each(localArray.begin(), localArray.end(), [](int& element) { ++element; }); return localArray; }; constexpr AZStd::array testArray = CreateArray(); @@ -1271,7 +1271,6 @@ namespace UnitTest TEST_F(Algorithms, Unique_Compile_WhenUsedInConstexpr) { - constexpr AZStd::array testList = { { 1, 2, 3 } }; auto TestUnique = []() constexpr { AZStd::array localArray{ { 1, 2, 2, 5, 5, 6} }; diff --git a/Code/Framework/AzCore/Tests/AZStd/FunctorsBind.cpp b/Code/Framework/AzCore/Tests/AZStd/FunctorsBind.cpp index b720257f18..58ab71096b 100644 --- a/Code/Framework/AzCore/Tests/AZStd/FunctorsBind.cpp +++ b/Code/Framework/AzCore/Tests/AZStd/FunctorsBind.cpp @@ -940,9 +940,10 @@ namespace UnitTest // 64 Byte buffer is used to prevent AZStd::function for storing the // lambda internal storage using the small buffer optimization // Therefore causing the supplied allocator to be used - AZStd::aligned_storage_t<64, 1> bufferToAvoidSmallBufferOptimization; + [[maybe_unused]] AZStd::aligned_storage_t<64, 1> bufferToAvoidSmallBufferOptimization; auto xValueAndConstXValueFunc = [bufferToAvoidSmallBufferOptimization](int lhs, int rhs) -> int { + AZ_UNUSED(bufferToAvoidSmallBufferOptimization); return lhs + rhs; }; diff --git a/Code/Framework/AzCore/Tests/AZStd/ListsIntrusive.cpp b/Code/Framework/AzCore/Tests/AZStd/ListsIntrusive.cpp index 511a4e479e..9e238b3d7d 100644 --- a/Code/Framework/AzCore/Tests/AZStd/ListsIntrusive.cpp +++ b/Code/Framework/AzCore/Tests/AZStd/ListsIntrusive.cpp @@ -997,7 +997,7 @@ namespace UnitTest myclass_base_list.clear(); auto reverseIterBegin = myclass_base_list.rbegin(); auto reverseIterEnd = myclass_base_list.rend(); - EXPECT_EQ(reverseIterEnd, reverseIterEnd); + EXPECT_EQ(reverseIterBegin, reverseIterEnd); } } } diff --git a/Code/Framework/AzCore/Tests/AZStd/Pair.cpp b/Code/Framework/AzCore/Tests/AZStd/Pair.cpp index 53786d20da..213cb8b17d 100644 --- a/Code/Framework/AzCore/Tests/AZStd/Pair.cpp +++ b/Code/Framework/AzCore/Tests/AZStd/Pair.cpp @@ -68,7 +68,6 @@ namespace UnitTest static constexpr size_t max_expected_size = MaxExpectedSize; }; - constexpr size_t pairSize = sizeof(AZStd::compressed_pair); using CompressedPairTestConfigs = ::testing::Types< CompressedPairTestConfig , CompressedPairTestConfig diff --git a/Code/Framework/AzCore/Tests/AZStd/SetsIntrusive.cpp b/Code/Framework/AzCore/Tests/AZStd/SetsIntrusive.cpp index 61f9144452..6cae83c3ad 100644 --- a/Code/Framework/AzCore/Tests/AZStd/SetsIntrusive.cpp +++ b/Code/Framework/AzCore/Tests/AZStd/SetsIntrusive.cpp @@ -287,7 +287,7 @@ namespace UnitTest myclass_base_set.clear(); auto reverseIterBegin = myclass_base_set.rbegin(); auto reverseIterEnd = myclass_base_set.rend(); - EXPECT_EQ(reverseIterEnd, reverseIterEnd); + EXPECT_EQ(reverseIterBegin, reverseIterEnd); } } } diff --git a/Code/Framework/AzCore/Tests/AZStd/String.cpp b/Code/Framework/AzCore/Tests/AZStd/String.cpp index 0ff12a352c..4c6687b00d 100644 --- a/Code/Framework/AzCore/Tests/AZStd/String.cpp +++ b/Code/Framework/AzCore/Tests/AZStd/String.cpp @@ -1229,7 +1229,7 @@ namespace UnitTest string_view subView2 = view2.substr(10); EXPECT_EQ("Haystack", subView2); AZ_TEST_START_TRACE_SUPPRESSION; - string_view assertSubView = view2.substr(view2.size() + 1); + [[maybe_unused]] string_view assertSubView = view2.substr(view2.size() + 1); AZ_TEST_STOP_TRACE_SUPPRESSION(1); // compare @@ -1472,7 +1472,7 @@ namespace UnitTest class WrappedInt { - int val; + [[maybe_unused]] int val; }; using ValidFormatArg = AZStd::string::_Format_Internal::ValidFormatArg; @@ -1751,6 +1751,7 @@ namespace UnitTest static constexpr basic_string_view elementView1(compileTimeString1); static constexpr basic_string_view elementView2(compileTimeString2); static_assert(elementView1.data(), "string_view.data() should be non-nullptr"); + static_assert(elementView2.data(), "string_view.data() should be non-nullptr"); } TYPED_TEST(BasicStringViewConstexprFixture, StringView_SizeOperatorsConstexpr) @@ -1779,7 +1780,7 @@ namespace UnitTest { using TypeParam = char; // null terminated compile time string - auto MakeCompileTimeString1 = []() constexpr -> const TypeParam* + [[maybe_unused]] auto MakeCompileTimeString1 = []() constexpr -> const TypeParam* { return "HelloWorld"; }; @@ -2131,7 +2132,6 @@ namespace UnitTest constexpr AZStd::fixed_string<128> test3{ AZStd::fixed_string<128>{}.insert(0, "Brown") }; constexpr AZStd::fixed_string<128> test4{ AZStd::fixed_string<128>{ "App" }.insert(0, AZStd::string_view("Blue")) }; constexpr AZStd::fixed_string<128> test5{ AZStd::fixed_string<128>{ "App" }.insert(0, test1, 2, 2) }; - constexpr AZStd::string_view redView("Red"); constexpr AZStd::fixed_string<128> test6{ AZStd::fixed_string<128>{ "App" }.insert(size_t(0), 5, 'X') }; constexpr AZStd::fixed_string<128> test7{ AZStd::fixed_string<128>{ "App" }.insert(0, "GreenTea", 5) }; auto MakeFixedStringWithInsertWithIteratorPos1 = []() constexpr diff --git a/Code/Framework/AzCore/Tests/AZStd/Variant.cpp b/Code/Framework/AzCore/Tests/AZStd/Variant.cpp index 824a99fa88..700574323c 100644 --- a/Code/Framework/AzCore/Tests/AZStd/Variant.cpp +++ b/Code/Framework/AzCore/Tests/AZStd/Variant.cpp @@ -318,8 +318,6 @@ namespace UnitTest using TestVariant2 = AZStd::variant; static_assert(sizeof(TestVariant1) == sizeof(TestVariant2), "with different permutations variants of same types should be the same size"); using UnorderedVariant3 = AZStd::variant, TestAlignedStorage>; - constexpr size_t testVariant1Size = sizeof(TestVariant1); - constexpr size_t unorderedVariant3Size = sizeof(UnorderedVariant3); static_assert(sizeof(TestVariant1) == sizeof(UnorderedVariant3), "with different permutations variants of same types should be the same size"); } diff --git a/Code/Framework/AzCore/Tests/Asset/AssetDataStreamTests.cpp b/Code/Framework/AzCore/Tests/Asset/AssetDataStreamTests.cpp index efcc62682a..27903495f1 100644 --- a/Code/Framework/AzCore/Tests/Asset/AssetDataStreamTests.cpp +++ b/Code/Framework/AzCore/Tests/Asset/AssetDataStreamTests.cpp @@ -297,7 +297,7 @@ TEST_F(AssetDataStreamTest, IsFullyLoaded_FileDoesNotReadAllData_DataIsNotFullyL using ::testing::_; ON_CALL(m_mockStreamer, GetReadRequestResult(_, _, _, _)) - .WillByDefault([this, incompleteAssetSize]( + .WillByDefault([this]( [[maybe_unused]] FileRequestHandle request, void*& buffer, AZ::u64& numBytesRead, diff --git a/Code/Framework/AzCore/Tests/Asset/AssetManagerStreamingTests.cpp b/Code/Framework/AzCore/Tests/Asset/AssetManagerStreamingTests.cpp index 0fd792b444..46ff4ff3e7 100644 --- a/Code/Framework/AzCore/Tests/Asset/AssetManagerStreamingTests.cpp +++ b/Code/Framework/AzCore/Tests/Asset/AssetManagerStreamingTests.cpp @@ -72,7 +72,7 @@ namespace UnitTest }); ON_CALL(m_mockStreamer, GetRequestStatus(_)) - .WillByDefault([this]([[maybe_unused]] FileRequestHandle request) + .WillByDefault([]([[maybe_unused]] FileRequestHandle request) { // Return whatever request status has been set in this class return IO::IStreamerTypes::RequestStatus::Completed; diff --git a/Code/Framework/AzCore/Tests/Debug/LocalFileEventLoggerTests.cpp b/Code/Framework/AzCore/Tests/Debug/LocalFileEventLoggerTests.cpp index 11f32de42f..242ac0e65d 100644 --- a/Code/Framework/AzCore/Tests/Debug/LocalFileEventLoggerTests.cpp +++ b/Code/Framework/AzCore/Tests/Debug/LocalFileEventLoggerTests.cpp @@ -226,8 +226,10 @@ namespace AZ::Debug AZStd::thread threads[totalThreads]; for (size_t threadIndex = 0; threadIndex < totalThreads; ++threadIndex) { - threads[threadIndex] = AZStd::thread([&startLogging, &totalRecordsWritten, &message, recordsPerThreadCount]() + threads[threadIndex] = AZStd::thread([&startLogging, &message, &totalRecordsWritten]() { + AZ_UNUSED(message); + while (!startLogging) { AZStd::this_thread::yield(); diff --git a/Code/Framework/AzCore/Tests/EBus.cpp b/Code/Framework/AzCore/Tests/EBus.cpp index c30c9ed62d..10216a0485 100644 --- a/Code/Framework/AzCore/Tests/EBus.cpp +++ b/Code/Framework/AzCore/Tests/EBus.cpp @@ -2837,7 +2837,7 @@ namespace UnitTest handlerList.emplace_back(i, maxSleep); } - auto work = [maxSleep, threadCount]() + auto work = []() { char sentinel[64] = { 0 }; char* end = sentinel + AZ_ARRAY_SIZE(sentinel); @@ -2923,7 +2923,7 @@ namespace UnitTest MyEventGroupImpl handler; - auto work = [maxSleep, &handler]() + auto work = [&handler]() { for (int i = 1; i < cycleCount; ++i) { diff --git a/Code/Framework/AzCore/Tests/EnumTests.cpp b/Code/Framework/AzCore/Tests/EnumTests.cpp index 7f123a23b4..4c19d3f574 100644 --- a/Code/Framework/AzCore/Tests/EnumTests.cpp +++ b/Code/Framework/AzCore/Tests/EnumTests.cpp @@ -81,7 +81,7 @@ namespace UnitTest auto EnumerateTestEnum = []() constexpr -> bool { int count = 0; - for (TestEnumEnumeratorValueAndString enumMember : TestEnumMembers) + for ([[maybe_unused]] TestEnumEnumeratorValueAndString enumMember : TestEnumMembers) { ++count; } diff --git a/Code/Framework/AzCore/Tests/GenericStreamTests.cpp b/Code/Framework/AzCore/Tests/GenericStreamTests.cpp index 5f6190ac76..4f21c1e593 100644 --- a/Code/Framework/AzCore/Tests/GenericStreamTests.cpp +++ b/Code/Framework/AzCore/Tests/GenericStreamTests.cpp @@ -62,7 +62,7 @@ public: // Reroute the mock stream to our output MemoryStream for writing. ON_CALL(m_mockGenericStream, Write(_, _)) - .WillByDefault([this, &outputStream](AZ::IO::SizeType bytes, const void* buffer) + .WillByDefault([&outputStream](AZ::IO::SizeType bytes, const void* buffer) { return outputStream.Write(bytes, buffer); }); diff --git a/Code/Framework/AzCore/Tests/Jobs.cpp b/Code/Framework/AzCore/Tests/Jobs.cpp index 0eb46a0051..b88e1f5b32 100644 --- a/Code/Framework/AzCore/Tests/Jobs.cpp +++ b/Code/Framework/AzCore/Tests/Jobs.cpp @@ -1361,7 +1361,7 @@ namespace UnitTest AZ::JobCompletion completion; // Push a parent job that pushes the work as child jobs (requires the current job, so this is a real world test of "functor with current job as param") - AZ::Job* parentJob = AZ::CreateJobFunction([this, &jobData, JobCount](AZ::Job& thisJob) + AZ::Job* parentJob = AZ::CreateJobFunction([this, &jobData](AZ::Job& thisJob) { EXPECT_EQ(m_jobManager->GetCurrentJob(), &thisJob); diff --git a/Code/Framework/AzCore/Tests/Math/CrcTests.cpp b/Code/Framework/AzCore/Tests/Math/CrcTests.cpp index 04d2e3d8cb..0255c1ad6d 100644 --- a/Code/Framework/AzCore/Tests/Math/CrcTests.cpp +++ b/Code/Framework/AzCore/Tests/Math/CrcTests.cpp @@ -56,7 +56,7 @@ namespace Benchmark // This function only exist to calculate AZ::Crc32 values at compile time for (auto _ : state) { - constexpr auto resultArray = Crc32Internal::GenerateTestCrc32Values(); + [[maybe_unused]] constexpr auto resultArray = Crc32Internal::GenerateTestCrc32Values(); } } diff --git a/Code/Framework/AzCore/Tests/Math/ShapeIntersectionTests.cpp b/Code/Framework/AzCore/Tests/Math/ShapeIntersectionTests.cpp index 659febf564..e7980af781 100644 --- a/Code/Framework/AzCore/Tests/Math/ShapeIntersectionTests.cpp +++ b/Code/Framework/AzCore/Tests/Math/ShapeIntersectionTests.cpp @@ -117,9 +117,6 @@ namespace UnitTest EXPECT_TRUE(AZ::ShapeIntersection::Classify(frustum, s2) == AZ::IntersectResult::Exterior); } - AZ::Vector3 axisX = AZ::Vector3::CreateAxisX(); - AZ::Vector3 axisY = AZ::Vector3::CreateAxisY(); - AZ::Vector3 axisZ = AZ::Vector3::CreateAxisZ(); { AZ::Obb obb = AZ::Obb::CreateFromPositionRotationAndHalfLengths( AZ::Vector3(0.0f, -3.9f, 0.0f), AZ::Quaternion::CreateIdentity(), AZ::Vector3::CreateOne()); diff --git a/Code/Framework/AzCore/Tests/Math/SimdMathTests.cpp b/Code/Framework/AzCore/Tests/Math/SimdMathTests.cpp index 4570d79b83..b7b3c9c952 100644 --- a/Code/Framework/AzCore/Tests/Math/SimdMathTests.cpp +++ b/Code/Framework/AzCore/Tests/Math/SimdMathTests.cpp @@ -1414,7 +1414,6 @@ namespace UnitTest typename VectorType::Int32Type testVector = VectorType::ConvertToInt(sourceVector); VectorType::StoreUnaligned(testStoreValues, testVector); - int32_t results[4] = { 0, 1, -1, 2 }; for (int32_t i = 0; i < VectorType::ElementCount; ++i) { EXPECT_THAT(testStoreValues[i], testWholeLoadValues[i]); @@ -1476,7 +1475,6 @@ namespace UnitTest typename VectorType::Int32Type testVector = VectorType::ConvertToIntNearest(sourceVector); VectorType::StoreUnaligned(testStoreValues, testVector); - int32_t results[4] = { 0, 1, -1, 2 }; for (int32_t i = 0; i < VectorType::ElementCount; ++i) { EXPECT_THAT(testStoreValues[i], testWholeLoadValues[i]); diff --git a/Code/Framework/AzCore/Tests/Memory/LeakDetection.cpp b/Code/Framework/AzCore/Tests/Memory/LeakDetection.cpp index ce94ce14f2..b4f129bb48 100644 --- a/Code/Framework/AzCore/Tests/Memory/LeakDetection.cpp +++ b/Code/Framework/AzCore/Tests/Memory/LeakDetection.cpp @@ -76,7 +76,6 @@ namespace UnitTest return true; } - AZ::Debug::DrillerManager* m_drillerManager = nullptr; bool m_leakDetected = false; bool m_leakExpected = false; }; diff --git a/Code/Framework/AzCore/Tests/Name/NameTests.cpp b/Code/Framework/AzCore/Tests/Name/NameTests.cpp index 3db77ac4c4..5417d36051 100644 --- a/Code/Framework/AzCore/Tests/Name/NameTests.cpp +++ b/Code/Framework/AzCore/Tests/Name/NameTests.cpp @@ -599,7 +599,6 @@ namespace UnitTest TEST_F(NameTest, ConcurrencyDataTest_EachThreadCreatesOneName_NoCollision) { - const uint32_t maxUniqueHashes = std::numeric_limits::max(); AZ::NameDictionary::Destroy(); AZ::NameDictionary::Create(); @@ -609,7 +608,6 @@ namespace UnitTest TEST_F(NameTest, ConcurrencyDataTest_EachThreadCreatesOneName_HighCollisions) { - const uint32_t maxUniqueHashes = 25; AZ::NameDictionary::Destroy(); AZ::NameDictionary::Create(); @@ -619,7 +617,6 @@ namespace UnitTest TEST_F(NameTest, ConcurrencyDataTest_EachThreadRepeatedlyCreatesAndReleasesOneName_NoCollision) { - const uint32_t maxUniqueHashes = std::numeric_limits::max(); AZ::NameDictionary::Destroy(); AZ::NameDictionary::Create(); @@ -630,7 +627,6 @@ namespace UnitTest TEST_F(NameTest, ConcurrencyDataTest_EachThreadRepeatedlyCreatesAndReleasesOneName_HighCollisions) { - const uint32_t maxUniqueHashes = 25; AZ::NameDictionary::Destroy(); AZ::NameDictionary::Create(); diff --git a/Code/Framework/AzCore/Tests/Platform/Windows/Tests/IO/Streamer/StorageDriveTests_Windows.cpp b/Code/Framework/AzCore/Tests/Platform/Windows/Tests/IO/Streamer/StorageDriveTests_Windows.cpp index a842626e18..6d572a02a3 100644 --- a/Code/Framework/AzCore/Tests/Platform/Windows/Tests/IO/Streamer/StorageDriveTests_Windows.cpp +++ b/Code/Framework/AzCore/Tests/Platform/Windows/Tests/IO/Streamer/StorageDriveTests_Windows.cpp @@ -639,7 +639,7 @@ namespace AZ::IO path.InitFromAbsolutePath(m_dummyFilepath); request->CreateRead(nullptr, buffer, unalignedSize + 4, path, unalignedOffset, unalignedSize); - auto callback = [&fileSize, unalignedOffset, unalignedSize, this](const FileRequest& request) + auto callback = [unalignedOffset, unalignedSize, this](const FileRequest& request) { EXPECT_EQ(request.GetStatus(), AZ::IO::IStreamerTypes::RequestStatus::Completed); auto& readRequest = AZStd::get(request.GetCommand()); diff --git a/Code/Framework/AzCore/Tests/Rtti.cpp b/Code/Framework/AzCore/Tests/Rtti.cpp index 862482d10a..935df848c2 100644 --- a/Code/Framework/AzCore/Tests/Rtti.cpp +++ b/Code/Framework/AzCore/Tests/Rtti.cpp @@ -171,7 +171,6 @@ namespace UnitTest AZ_TEST_ASSERT(AzGenericTypeInfo::Uuid() == templateUuid); // Check all combinations return a valid id. - Uuid nullId = Uuid::CreateNull(); AZ_TEST_ASSERT(AzGenericTypeInfo::Uuid() == AZ::Uuid("{911B2EA8-CCB1-4F0C-A535-540AD00173AE}")); AZ_TEST_ASSERT(AzGenericTypeInfo::Uuid() == AZ::Uuid("{6BAE9836-EC49-466A-85F2-F4B1B70839FB}")); AZ_TEST_ASSERT(AzGenericTypeInfo::Uuid() == AZ::Uuid("{C9F9C644-CCC3-4F77-A792-F5B5DBCA746E}")); @@ -460,8 +459,8 @@ namespace UnitTest TEST_F(Rtti, IsAbstract) { // compile time proof that the two non-abstract classes are not abstract at compile time: - ExampleFullImplementationClass one; - ExampleCombined two; + [[maybe_unused]] ExampleFullImplementationClass one; + [[maybe_unused]] ExampleCombined two; ASSERT_NE(GetRttiHelper(), nullptr); ASSERT_NE(GetRttiHelper(), nullptr); diff --git a/Code/Framework/AzCore/Tests/Serialization/Json/BasicContainerSerializerTests.cpp b/Code/Framework/AzCore/Tests/Serialization/Json/BasicContainerSerializerTests.cpp index 6839afac6d..3bc574c2ce 100644 --- a/Code/Framework/AzCore/Tests/Serialization/Json/BasicContainerSerializerTests.cpp +++ b/Code/Framework/AzCore/Tests/Serialization/Json/BasicContainerSerializerTests.cpp @@ -144,11 +144,6 @@ namespace JsonSerializationTests { return false; } - - auto compare = [](const int* lhs, const int* rhs) -> bool - { - return *lhs == *rhs; - }; return AZStd::equal(lhs.begin(), lhs.end(), rhs.begin(), SimplePointerTestDescriptionCompare{}); } }; diff --git a/Code/Framework/AzCore/Tests/Serialization/Json/IntSerializerTests.cpp b/Code/Framework/AzCore/Tests/Serialization/Json/IntSerializerTests.cpp index c971535f0b..9aca0b8e47 100644 --- a/Code/Framework/AzCore/Tests/Serialization/Json/IntSerializerTests.cpp +++ b/Code/Framework/AzCore/Tests/Serialization/Json/IntSerializerTests.cpp @@ -544,6 +544,7 @@ namespace JsonSerializationTests ResultCode result = this->m_serializer->Store(convertedValue, &value, nullptr, azrtti_typeid::DataType>(), *this->m_jsonSerializationContext); + EXPECT_EQ(Outcomes::Success, result.GetOutcome()); if constexpr (AZStd::is_signed::DataType>::value) { diff --git a/Code/Framework/AzCore/Tests/Serialization/Json/JsonSerializationTests.cpp b/Code/Framework/AzCore/Tests/Serialization/Json/JsonSerializationTests.cpp index 76624a0d44..20d956cd8a 100644 --- a/Code/Framework/AzCore/Tests/Serialization/Json/JsonSerializationTests.cpp +++ b/Code/Framework/AzCore/Tests/Serialization/Json/JsonSerializationTests.cpp @@ -560,7 +560,6 @@ namespace JsonSerializationTests { using namespace AZ::JsonSerializationResult; - TemplatedClass instance; ResultCode result = AZ::JsonSerialization::Store(*m_jsonDocument, m_jsonDocument->GetAllocator(), nullptr, nullptr, azrtti_typeid(), *m_serializationSettings); diff --git a/Code/Framework/AzCore/Tests/Serialization/Json/MathMatrixSerializerTests.cpp b/Code/Framework/AzCore/Tests/Serialization/Json/MathMatrixSerializerTests.cpp index 1126aeb662..3cb316f472 100644 --- a/Code/Framework/AzCore/Tests/Serialization/Json/MathMatrixSerializerTests.cpp +++ b/Code/Framework/AzCore/Tests/Serialization/Json/MathMatrixSerializerTests.cpp @@ -469,6 +469,7 @@ namespace JsonSerializationTests *this->m_jsonDocument, *this->m_jsonDeserializationContext); + ASSERT_EQ(Outcomes::DefaultsUsed, result.GetOutcome()); EXPECT_TRUE(defaultValue == output); } @@ -503,7 +504,6 @@ namespace JsonSerializationTests using namespace AZ::JsonSerializationResult; using Descriptor = typename JsonMathMatrixSerializerTests::Descriptor; - const auto defaultValue = Descriptor::MatrixType::CreateIdentity(); rapidjson::Value& objectValue = this->m_jsonDocument->SetObject(); auto input = Descriptor::MatrixType::CreateIdentity(); DataHelper::AddData(objectValue, input, this->m_jsonDocument->GetAllocator()); diff --git a/Code/Framework/AzCore/Tests/Streamer/StreamStackEntryConformityTests.h b/Code/Framework/AzCore/Tests/Streamer/StreamStackEntryConformityTests.h index e6084fe115..7162b6efa0 100644 --- a/Code/Framework/AzCore/Tests/Streamer/StreamStackEntryConformityTests.h +++ b/Code/Framework/AzCore/Tests/Streamer/StreamStackEntryConformityTests.h @@ -250,7 +250,7 @@ namespace AZ::IO constexpr s32 minValue = std::numeric_limits::min(); EXPECT_CALL(*mock, UpdateStatus(_)) - .WillOnce([minValue](StreamStackEntry::Status& status) + .WillOnce([](StreamStackEntry::Status& status) { status.m_numAvailableSlots = minValue; }); diff --git a/Code/Framework/AzCore/Tests/TaskTests.cpp b/Code/Framework/AzCore/Tests/TaskTests.cpp index f2ca484df3..f65dffcd99 100644 --- a/Code/Framework/AzCore/Tests/TaskTests.cpp +++ b/Code/Framework/AzCore/Tests/TaskTests.cpp @@ -225,6 +225,7 @@ namespace UnitTest defaultTD, [td = AZStd::move(td)] { + AZ_UNUSED(td); }); task.Invoke(); // Destructor should not have run yet (except on moved-from instances) diff --git a/Code/Framework/AzFramework/AzFramework/Application/Application.cpp b/Code/Framework/AzFramework/AzFramework/Application/Application.cpp index e967fd6af1..fa0f14ac74 100644 --- a/Code/Framework/AzFramework/AzFramework/Application/Application.cpp +++ b/Code/Framework/AzFramework/AzFramework/Application/Application.cpp @@ -627,6 +627,9 @@ namespace AzFramework static void CreateUserCache(const AZ::IO::FixedMaxPath& cacheUserPath, AZ::IO::FileIOBase& fileIoBase) { + constexpr const char* userCachePathFilename{ "Cache" }; + AZ::IO::FixedMaxPath userCachePath = cacheUserPath / userCachePathFilename; +#if AZ_TRAIT_OS_IS_HOST_OS_PLATFORM // The number of max attempts ultimately dictates the number of Lumberyard instances that can run // simultaneously. This should be a reasonably high number so that it doesn't artificially limit // the number of instances (ex: parallel level exports via multiple Editor runs). It also shouldn't @@ -635,9 +638,6 @@ namespace AzFramework // 128 seems like a reasonable compromise. constexpr int maxAttempts = 128; - constexpr const char* userCachePathFilename{ "Cache" }; - AZ::IO::FixedMaxPath userCachePath = cacheUserPath / userCachePathFilename; -#if AZ_TRAIT_OS_IS_HOST_OS_PLATFORM int attemptNumber; for (attemptNumber = 0; attemptNumber < maxAttempts; ++attemptNumber) { diff --git a/Code/Framework/AzFramework/AzFramework/Archive/Archive.cpp b/Code/Framework/AzFramework/AzFramework/Archive/Archive.cpp index 5bcdc3d719..8688f6b878 100644 --- a/Code/Framework/AzFramework/AzFramework/Archive/Archive.cpp +++ b/Code/Framework/AzFramework/AzFramework/Archive/Archive.cpp @@ -2330,7 +2330,6 @@ namespace AZ::IO // we only want to record ASSET access // assets are identified as things which start with no alias, or with the @assets@ alias auto assetPath = AZ::IO::FileIOBase::GetInstance()->ConvertToAlias(szFilename); - constexpr AZStd::string_view assetsAlias{ "@assets@" }; if (assetPath && assetPath->Native().starts_with("@assets@")) { IResourceList* pList = GetResourceList(m_eRecordFileOpenList); diff --git a/Code/Framework/AzFramework/AzFramework/Archive/ArchiveFileIO.cpp b/Code/Framework/AzFramework/AzFramework/Archive/ArchiveFileIO.cpp index c5e3bc9315..55f7640785 100644 --- a/Code/Framework/AzFramework/AzFramework/Archive/ArchiveFileIO.cpp +++ b/Code/Framework/AzFramework/AzFramework/Archive/ArchiveFileIO.cpp @@ -16,7 +16,6 @@ namespace AZ::IO { - constexpr size_t ArchiveFileiOMaxBuffersize = 16 * 1024; ArchiveFileIO::ArchiveFileIO(IArchive* archive) : m_archive(archive) { diff --git a/Code/Framework/AzFramework/AzFramework/Archive/ZipDirCache.cpp b/Code/Framework/AzFramework/AzFramework/Archive/ZipDirCache.cpp index d74f69e27b..81f26d78b8 100644 --- a/Code/Framework/AzFramework/AzFramework/Archive/ZipDirCache.cpp +++ b/Code/Framework/AzFramework/AzFramework/Archive/ZipDirCache.cpp @@ -887,7 +887,6 @@ namespace AZ::IO::ZipDir { FileRecordList arrFiles(GetRoot()); arrFiles.SortByFileOffset(); - FileRecordList::ZipStats Stats = arrFiles.GetStats(); // we back up our file entries, because we'll need to restore them // in case the operation fails diff --git a/Code/Framework/AzFramework/AzFramework/Archive/ZipDirStructures.cpp b/Code/Framework/AzFramework/AzFramework/Archive/ZipDirStructures.cpp index 5f0d58a4cb..1d09705900 100644 --- a/Code/Framework/AzFramework/AzFramework/Archive/ZipDirStructures.cpp +++ b/Code/Framework/AzFramework/AzFramework/Archive/ZipDirStructures.cpp @@ -419,9 +419,9 @@ namespace AZ::IO::ZipDir } // defining file attributes for opening files using constants to avoid the need to include windows headers - constexpr int FileFlagNoBufferinf = 0x20000000; + constexpr int FileFlagNoBuffering = 0x20000000; constexpr int FileAttributeNormal = 0x00000080; - if (m_unbufferedFile.Open(filename, AZ::IO::SystemFile::OpenMode::SF_OPEN_READ_ONLY, FileAttributeNormal | FileAttributeNormal)) + if (m_unbufferedFile.Open(filename, AZ::IO::SystemFile::OpenMode::SF_OPEN_READ_ONLY, FileFlagNoBuffering | FileAttributeNormal)) { m_nSize = aznumeric_cast(m_unbufferedFile.Length()); return true; diff --git a/Code/Framework/AzFramework/AzFramework/FileTag/FileTag.cpp b/Code/Framework/AzFramework/AzFramework/FileTag/FileTag.cpp index 87866581d3..f820ee56ed 100644 --- a/Code/Framework/AzFramework/AzFramework/FileTag/FileTag.cpp +++ b/Code/Framework/AzFramework/AzFramework/FileTag/FileTag.cpp @@ -366,7 +366,7 @@ namespace AzFramework AZStd::set tags; AZStd::string resolvedFilePath = ResolveFilePath(filePath); - auto found = AZStd::find_if(m_fileTagsMap.begin(), m_fileTagsMap.end(), [filePath, resolvedFilePath, this](auto& entry) -> bool + auto found = AZStd::find_if(m_fileTagsMap.begin(), m_fileTagsMap.end(), [resolvedFilePath](auto& entry) -> bool { return resolvedFilePath == ResolveFilePath(entry.first); }); diff --git a/Code/Framework/AzFramework/AzFramework/IO/LocalFileIO.cpp b/Code/Framework/AzFramework/AzFramework/IO/LocalFileIO.cpp index d779ac8b49..076cce4965 100644 --- a/Code/Framework/AzFramework/AzFramework/IO/LocalFileIO.cpp +++ b/Code/Framework/AzFramework/AzFramework/IO/LocalFileIO.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -283,11 +284,18 @@ namespace AZ void LocalFileIO::CheckInvalidWrite([[maybe_unused]] const char* path) { #if defined(AZ_ENABLE_TRACING) - const char* assetsAlias = GetAlias("@assets@"); - if (path && assetsAlias && AZ::IO::PathView(path).IsRelativeTo(assetsAlias)) + const char* assetAliasPath = GetAlias("@assets@"); + if (path && assetAliasPath) { - AZ_Error("FileIO", false, "You may not alter data inside the asset cache. Please check the call stack and consider writing into the source asset folder instead.\n" - "Attempted write location: %s", path); + AZStd::string assetsAlias(assetAliasPath); + AZStd::string pathString = path; + AZStd::to_lower(assetsAlias.begin(), assetsAlias.end()); + AZStd::to_lower(pathString.begin(), pathString.end()); + if (AZ::IO::PathView(pathString.c_str()).IsRelativeTo(assetsAlias.c_str())) + { + AZ_Error("FileIO", false, "You may not alter data inside the asset cache. Please check the call stack and consider writing into the source asset folder instead.\n" + "Attempted write location: %s", path); + } } #endif } @@ -543,28 +551,12 @@ namespace AZ char fullPath[AZ_MAX_PATH_LEN]; ConvertToAbsolutePath(path, fullPath, AZ_MAX_PATH_LEN); - const auto it = AZStd::find_if(m_aliases.begin(), m_aliases.end(), [key](const AliasType& alias) - { - return alias.first.compare(key) == 0; - }); - - if (it != m_aliases.end()) - { - it->second = fullPath; - } - else - { - m_aliases.emplace_back(key, fullPath); - } + m_aliases[key] = fullPath; } const char* LocalFileIO::GetAlias(const char* key) const { - const auto it = AZStd::find_if(m_aliases.begin(), m_aliases.end(), [key](const AliasType& alias) - { - return alias.first.compare(key) == 0; - }); - + const auto it = m_aliases.find(key); if (it != m_aliases.end()) { return it->second.c_str(); @@ -574,10 +566,7 @@ namespace AZ void LocalFileIO::ClearAlias(const char* key) { - m_aliases.erase(AZStd::remove_if(m_aliases.begin(), m_aliases.end(), [key](const AliasType& alias) - { - return alias.first.compare(key) == 0; - }), m_aliases.end()); + m_aliases.erase(key); } AZStd::optional LocalFileIO::ConvertToAliasBuffer(char* outBuffer, AZ::u64 outBufferLength, AZStd::string_view inBuffer) const @@ -682,55 +671,67 @@ namespace AZ bool LocalFileIO::ResolveAliases(const char* path, char* resolvedPath, AZ::u64 resolvedPathSize) const { - AZ_Assert(path != resolvedPath && resolvedPathSize > strlen(path), "Resolved path is incorrect"); AZ_Assert(path && path[0] != '%', "%% is deprecated, @ is the only valid alias token"); - + AZStd::string_view pathView(path); + AZStd::string_view aliasKey; + AZStd::string_view aliasValue; + for (const auto& alias : m_aliases) + { + AZStd::string_view key{ alias.first }; + if (AZ::StringFunc::StartsWith(pathView, key)) // we only support aliases at the front of the path + { + aliasKey = key; + aliasValue = alias.second; + break; + } + } + size_t requiredResolvedPathSize = pathView.size() - aliasKey.size() + aliasValue.size() + 1; + AZ_Assert(path != resolvedPath && resolvedPathSize >= requiredResolvedPathSize, "Resolved path is incorrect"); // we assert above, but we also need to properly handle the case when the resolvedPath buffer size // is too small to copy the source into. - size_t pathLen = strlen(path) + 1; // account for null - if (path == resolvedPath || (resolvedPathSize < pathLen)) + if (path == resolvedPath || (resolvedPathSize < requiredResolvedPathSize)) { return false; } - azstrncpy(resolvedPath, resolvedPathSize, path, pathLen); - for (const auto& alias : m_aliases) + // Skip past the alias key in the pathView + // must ensure that we are replacing the entire folder name, not a partial (e.g. @GAME01@/ vs @GAME0@/) + if (AZStd::string_view postAliasView = pathView.substr(aliasKey.size()); + !aliasKey.empty() && (postAliasView.empty() || postAliasView.starts_with('/') || postAliasView.starts_with('\\'))) { - const char* key = alias.first.c_str(); - size_t keyLen = alias.first.length(); - if (azstrnicmp(resolvedPath, key, keyLen) == 0) // we only support aliases at the front of the path + // Copy over resolved alias path first + size_t resolvedPathLen = 0; + aliasValue.copy(resolvedPath, aliasValue.size()); + resolvedPathLen += aliasValue.size(); + // Append the post alias path next + postAliasView.copy(resolvedPath + resolvedPathLen, postAliasView.size()); + resolvedPathLen += postAliasView.size(); + // Null-Terminated the resolved path + resolvedPath[resolvedPathLen] = '\0'; + // If the path started with one of the "asset cache" path aliases, lowercase the path + const char* assetAliasPath = GetAlias("@assets@"); + const char* rootAliasPath = GetAlias("@root@"); + const char* projectPlatformCacheAliasPath = GetAlias("@projectplatformcache@"); + const bool lowercasePath = (assetAliasPath != nullptr && AZ::StringFunc::StartsWith(resolvedPath, assetAliasPath)) || + (rootAliasPath != nullptr && AZ::StringFunc::StartsWith(resolvedPath, rootAliasPath)) || + (projectPlatformCacheAliasPath != nullptr && AZ::StringFunc::StartsWith(resolvedPath, projectPlatformCacheAliasPath)); + if (lowercasePath) { - [[maybe_unused]] bool lowercasePath = LowerIfBeginsWith(resolvedPath, resolvedPathSize, "@assets@") - || LowerIfBeginsWith(resolvedPath, resolvedPathSize, "@root@") - || LowerIfBeginsWith(resolvedPath, resolvedPathSize, "@projectplatformcache@"); - - const char* dest = alias.second.c_str(); - size_t destLen = alias.second.length(); - char* afterKey = resolvedPath + keyLen; - size_t afterKeyLen = pathLen - keyLen; - // must ensure that we are replacing the entire folder name, not a partial (e.g. @GAME01@/ vs @GAME0@/) - if (*afterKey == '/' || *afterKey == '\\' || *afterKey == 0) - { - if (afterKeyLen + destLen + 1 < resolvedPathSize)//if after replacing the alias the length is greater than the max path size than skip - { - // scoot the right hand side of the replacement over to make room - memmove(resolvedPath + destLen, afterKey, afterKeyLen + 1); // make sure null is copied - memcpy(resolvedPath, dest, destLen); // insert replacement - pathLen -= keyLen; - pathLen += destLen; - - AZStd::replace(resolvedPath, resolvedPath + resolvedPathSize, '\\', '/'); - return true; - } - } + AZStd::to_lower(resolvedPath, resolvedPath + resolvedPathLen); } + // Replace any backslashes with posix slashes + AZStd::replace(resolvedPath, resolvedPath + resolvedPathLen, AZ::IO::WindowsPathSeparator, AZ::IO::PosixPathSeparator); + return true; + } + else + { + // The input path doesn't start with an available, copy it directly to the resolved path + pathView.copy(resolvedPath, pathView.size()); + // Null-Terminated the resolved path + resolvedPath[pathView.size()] = '\0'; } - // warn on failing to resolve an alias - AZ_Warning( - "LocalFileIO::ResolveAlias", path && path[0] != '@', - "Failed to resolve an alias: %s", path ? path : "(null)"); - + AZ_Warning("LocalFileIO::ResolveAlias", path && path[0] != '@', "Failed to resolve an alias: %s", path ? path : "(null)"); return false; } @@ -803,7 +804,7 @@ namespace AZ return false; } - AZ::OSString LocalFileIO::RemoveTrailingSlash(const AZ::OSString& pathStr) + AZStd::string LocalFileIO::RemoveTrailingSlash(const AZStd::string& pathStr) { if (pathStr.empty() || (pathStr[pathStr.length() - 1] != '/' && pathStr[pathStr.length() - 1] != '\\')) { @@ -813,7 +814,7 @@ namespace AZ return pathStr.substr(0, pathStr.length() - 1); } - AZ::OSString LocalFileIO::CheckForTrailingSlash(const AZ::OSString& pathStr) + AZStd::string LocalFileIO::CheckForTrailingSlash(const AZStd::string& pathStr) { if (pathStr.empty() || pathStr[pathStr.length() - 1] == '/') { diff --git a/Code/Framework/AzFramework/AzFramework/IO/LocalFileIO.h b/Code/Framework/AzFramework/AzFramework/IO/LocalFileIO.h index b02372d8c3..a9db55b320 100644 --- a/Code/Framework/AzFramework/AzFramework/IO/LocalFileIO.h +++ b/Code/Framework/AzFramework/AzFramework/IO/LocalFileIO.h @@ -8,16 +8,12 @@ #pragma once #include -#include -#include -#include -#include +#include #include #include -#include #include -#include #include +#include // This header file and CPP handles the platform specific implementation of code as defined by the FileIOBase interface class. // In order to make your code portable and functional with both this and the RemoteFileIO class, use the interface to access @@ -33,7 +29,7 @@ namespace AZ { public: AZ_RTTI(LocalFileIO, "{87A8D32B-F695-4105-9A4D-D99BE15DFD50}", FileIOBase); - AZ_CLASS_ALLOCATOR(LocalFileIO, OSAllocator, 0); + AZ_CLASS_ALLOCATOR(LocalFileIO, SystemAllocator, 0); LocalFileIO(); ~LocalFileIO(); @@ -77,8 +73,6 @@ namespace AZ bool ConvertToAbsolutePath(const char* path, char* absolutePath, AZ::u64 maxLength) const; private: - typedef AZStd::pair AliasType; - SystemFile* GetFilePointerFromHandle(HandleType fileHandle); HandleType GetNextHandle(); @@ -90,13 +84,13 @@ namespace AZ bool LowerIfBeginsWith(char* inOutBuffer, AZ::u64 bufferLen, const char* alias) const; private: - static AZ::OSString RemoveTrailingSlash(const AZ::OSString& pathStr); - static AZ::OSString CheckForTrailingSlash(const AZ::OSString& pathStr); + static AZStd::string RemoveTrailingSlash(const AZStd::string& pathStr); + static AZStd::string CheckForTrailingSlash(const AZStd::string& pathStr); mutable AZStd::recursive_mutex m_openFileGuard; AZStd::atomic m_nextHandle; - AZStd::map, AZ::OSStdAllocator> m_openFiles; - AZStd::vector m_aliases; + AZStd::unordered_map m_openFiles; + AZStd::unordered_map m_aliases; void CheckInvalidWrite(const char* path); }; diff --git a/Code/Framework/AzFramework/AzFramework/IO/RemoteFileIO.cpp b/Code/Framework/AzFramework/AzFramework/IO/RemoteFileIO.cpp index 25bc31b760..3ac1b91144 100644 --- a/Code/Framework/AzFramework/AzFramework/IO/RemoteFileIO.cpp +++ b/Code/Framework/AzFramework/AzFramework/IO/RemoteFileIO.cpp @@ -27,7 +27,9 @@ namespace AZ const char* const NetworkFileIOChannel = "NetworkFileIO"; #ifndef REMOTEFILEIO_IS_NETWORKFILEIO const char* const RemoteFileIOChannel = "RemoteFileIO"; + #ifdef REMOTEFILEIO_SYNC_CHECK const char* const RemoteFileCacheChannel = "RemoteFileCache"; + #endif #endif const size_t READ_CHUNK_SIZE = 1024 * 256; diff --git a/Code/Framework/AzFramework/AzFramework/Script/ScriptComponent.cpp b/Code/Framework/AzFramework/AzFramework/Script/ScriptComponent.cpp index 4aa2e6c9e3..e11dc6dace 100644 --- a/Code/Framework/AzFramework/AzFramework/Script/ScriptComponent.cpp +++ b/Code/Framework/AzFramework/AzFramework/Script/ScriptComponent.cpp @@ -292,7 +292,7 @@ namespace AzFramework namespace Internal { - static AZStd::string PrintLuaValue(lua_State* lua, int stackIdx, int depth = 0) + AZStd::string PrintLuaValue(lua_State* lua, int stackIdx, int depth = 0) { constexpr int MaxDepth = 4; if (depth > MaxDepth) diff --git a/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp b/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp index fac1e45920..89338a355f 100644 --- a/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp +++ b/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.cpp @@ -332,6 +332,11 @@ namespace AzFramework return nextCamera; } + void RotateCameraInput::SetRotateInputChannelId(const InputChannelId& rotateChannelId) + { + m_rotateChannelId = rotateChannelId; + } + PanCameraInput::PanCameraInput(const InputChannelId& panChannelId, PanAxesFn panAxesFn) : m_panAxesFn(AZStd::move(panAxesFn)) , m_panChannelId(panChannelId) @@ -379,35 +384,40 @@ namespace AzFramework return nextCamera; } - TranslateCameraInput::TranslationType TranslateCameraInput::TranslationFromKey( - const InputChannelId& channelId, const TranslateCameraInputChannels& translateCameraInputChannels) + void PanCameraInput::SetPanInputChannelId(const InputChannelId& panChannelId) { - if (channelId == translateCameraInputChannels.m_forwardChannelId) + m_panChannelId = panChannelId; + } + + TranslateCameraInput::TranslationType TranslateCameraInput::TranslationFromKey( + const InputChannelId& channelId, const TranslateCameraInputChannelIds& translateCameraInputChannelIds) + { + if (channelId == translateCameraInputChannelIds.m_forwardChannelId) { return TranslationType::Forward; } - if (channelId == translateCameraInputChannels.m_backwardChannelId) + if (channelId == translateCameraInputChannelIds.m_backwardChannelId) { return TranslationType::Backward; } - if (channelId == translateCameraInputChannels.m_leftChannelId) + if (channelId == translateCameraInputChannelIds.m_leftChannelId) { return TranslationType::Left; } - if (channelId == translateCameraInputChannels.m_rightChannelId) + if (channelId == translateCameraInputChannelIds.m_rightChannelId) { return TranslationType::Right; } - if (channelId == translateCameraInputChannels.m_downChannelId) + if (channelId == translateCameraInputChannelIds.m_downChannelId) { return TranslationType::Down; } - if (channelId == translateCameraInputChannels.m_upChannelId) + if (channelId == translateCameraInputChannelIds.m_upChannelId) { return TranslationType::Up; } @@ -416,9 +426,9 @@ namespace AzFramework } TranslateCameraInput::TranslateCameraInput( - TranslationAxesFn translationAxesFn, const TranslateCameraInputChannels& translateCameraInputChannels) + TranslationAxesFn translationAxesFn, const TranslateCameraInputChannelIds& translateCameraInputChannelIds) : m_translationAxesFn(AZStd::move(translationAxesFn)) - , m_translateCameraInputChannels(translateCameraInputChannels) + , m_translateCameraInputChannelIds(translateCameraInputChannelIds) { m_translateSpeedFn = []() constexpr { @@ -438,13 +448,13 @@ namespace AzFramework { if (input->m_state == InputChannel::State::Began) { - m_translation |= TranslationFromKey(input->m_channelId, m_translateCameraInputChannels); + m_translation |= TranslationFromKey(input->m_channelId, m_translateCameraInputChannelIds); if (m_translation != TranslationType::Nil) { BeginActivation(); } - if (input->m_channelId == m_translateCameraInputChannels.m_boostChannelId) + if (input->m_channelId == m_translateCameraInputChannelIds.m_boostChannelId) { m_boost = true; } @@ -452,12 +462,12 @@ namespace AzFramework // ensure we don't process end events in the idle state else if (input->m_state == InputChannel::State::Ended && !Idle()) { - m_translation &= ~(TranslationFromKey(input->m_channelId, m_translateCameraInputChannels)); + m_translation &= ~(TranslationFromKey(input->m_channelId, m_translateCameraInputChannelIds)); if (m_translation == TranslationType::Nil) { EndActivation(); } - if (input->m_channelId == m_translateCameraInputChannels.m_boostChannelId) + if (input->m_channelId == m_translateCameraInputChannelIds.m_boostChannelId) { m_boost = false; } @@ -529,6 +539,11 @@ namespace AzFramework m_boost = false; } + void TranslateCameraInput::SetTranslateCameraInputChannelIds(const TranslateCameraInputChannelIds& translateCameraInputChannelIds) + { + m_translateCameraInputChannelIds = translateCameraInputChannelIds; + } + OrbitCameraInput::OrbitCameraInput(const InputChannelId& orbitChannelId) : m_orbitChannelId(orbitChannelId) { @@ -620,6 +635,11 @@ namespace AzFramework return nextCamera; } + void OrbitCameraInput::SetOrbitInputChannelId(const InputChannelId& orbitChanneId) + { + m_orbitChannelId = orbitChanneId; + } + OrbitDollyScrollCameraInput::OrbitDollyScrollCameraInput() { m_scrollSpeedFn = []() constexpr @@ -678,6 +698,11 @@ namespace AzFramework return nextCamera; } + void OrbitDollyCursorMoveCameraInput::SetDollyInputChannelId(const InputChannelId& dollyChannelId) + { + m_dollyChannelId = dollyChannelId; + } + ScrollTranslationCameraInput::ScrollTranslationCameraInput() { m_scrollSpeedFn = []() constexpr diff --git a/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.h b/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.h index ec383fa8ef..69e8b66434 100644 --- a/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.h +++ b/Code/Framework/AzFramework/AzFramework/Viewport/CameraInput.h @@ -303,6 +303,8 @@ namespace AzFramework bool HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta) override; Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime) override; + void SetRotateInputChannelId(const InputChannelId& rotateChannelId); + AZStd::function m_rotateSpeedFn; AZStd::function m_invertPitchFn; AZStd::function m_invertYawFn; @@ -355,6 +357,8 @@ namespace AzFramework bool HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta) override; Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime) override; + void SetPanInputChannelId(const InputChannelId& panChannelId); + AZStd::function m_panSpeedFn; AZStd::function m_invertPanXFn; AZStd::function m_invertPanYFn; @@ -398,7 +402,7 @@ namespace AzFramework } //! Groups all camera translation inputs. - struct TranslateCameraInputChannels + struct TranslateCameraInputChannelIds { InputChannelId m_forwardChannelId; InputChannelId m_backwardChannelId; @@ -414,13 +418,15 @@ namespace AzFramework { public: explicit TranslateCameraInput( - TranslationAxesFn translationAxesFn, const TranslateCameraInputChannels& translateCameraInputChannels); + TranslationAxesFn translationAxesFn, const TranslateCameraInputChannelIds& translateCameraInputChannelIds); // 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; void ResetImpl() override; + void SetTranslateCameraInputChannelIds(const TranslateCameraInputChannelIds& translateCameraInputChannelIds); + AZStd::function m_translateSpeedFn; AZStd::function m_boostMultiplierFn; @@ -482,11 +488,11 @@ namespace AzFramework //! Converts from a generic input channel id to a concrete translation type (based on the user's key mappings). TranslationType TranslationFromKey( - const InputChannelId& channelId, const TranslateCameraInputChannels& translateCameraInputChannels); + const InputChannelId& channelId, const TranslateCameraInputChannelIds& translateCameraInputChannelIds); TranslationType m_translation = TranslationType::Nil; //!< Types of translation the camera input is under. TranslationAxesFn m_translationAxesFn; //!< Builder for translation axes. - TranslateCameraInputChannels m_translateCameraInputChannels; //!< Input channel ids that map to internal translation types. + 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. }; @@ -513,6 +519,8 @@ namespace AzFramework bool HandleEvents(const InputEvent& event, const ScreenVector& cursorDelta, float scrollDelta) override; Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime) override; + void SetDollyInputChannelId(const InputChannelId& dollyChannelId); + AZStd::function m_cursorSpeedFn; private: @@ -548,6 +556,8 @@ namespace AzFramework Camera StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, float scrollDelta, float deltaTime) override; bool Exclusive() const override; + void SetOrbitInputChannelId(const InputChannelId& orbitChanneId); + Cameras m_orbitCameras; //!< 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. diff --git a/Code/Framework/AzFramework/AzFramework/Visibility/EntityVisibilityBoundsUnionSystem.cpp b/Code/Framework/AzFramework/AzFramework/Visibility/EntityVisibilityBoundsUnionSystem.cpp index 520667d90c..4a6b29b95c 100644 --- a/Code/Framework/AzFramework/AzFramework/Visibility/EntityVisibilityBoundsUnionSystem.cpp +++ b/Code/Framework/AzFramework/AzFramework/Visibility/EntityVisibilityBoundsUnionSystem.cpp @@ -56,9 +56,6 @@ namespace AzFramework if (auto instance_it = m_entityVisibilityBoundsUnionInstanceMapping.find(entity); instance_it == m_entityVisibilityBoundsUnionInstanceMapping.end()) { - AZ::TransformInterface* transformInterface = entity->GetTransform(); - const AZ::Vector3 entityPosition = transformInterface->GetWorldTranslation(); - EntityVisibilityBoundsUnionInstance instance; instance.m_localEntityBoundsUnion = CalculateEntityLocalBoundsUnion(entity); instance.m_visibilityEntry.m_typeFlags = VisibilityEntry::TYPE_Entity; diff --git a/Code/Framework/AzFramework/Platform/Android/AzFramework/IO/LocalFileIO_Android.cpp b/Code/Framework/AzFramework/Platform/Android/AzFramework/IO/LocalFileIO_Android.cpp index f6908142b4..b88c7cf25b 100644 --- a/Code/Framework/AzFramework/Platform/Android/AzFramework/IO/LocalFileIO_Android.cpp +++ b/Code/Framework/AzFramework/Platform/Android/AzFramework/IO/LocalFileIO_Android.cpp @@ -100,7 +100,7 @@ namespace AZ char resolvedPath[AZ_MAX_PATH_LEN]; ResolvePath(filePath, resolvedPath, AZ_MAX_PATH_LEN); - AZ::OSString pathWithoutSlash = RemoveTrailingSlash(resolvedPath); + AZStd::string pathWithoutSlash = RemoveTrailingSlash(resolvedPath); bool isInAPK = AZ::Android::Utils::IsApkPath(pathWithoutSlash.c_str()); if (isInAPK) @@ -115,7 +115,7 @@ namespace AZ // Skip over the current and parent directory paths if (filenameView != "." && filenameView != ".." && NameMatchesFilter(name, filter)) { - AZ::OSString foundFilePath = CheckForTrailingSlash(resolvedPath); + AZStd::string foundFilePath = CheckForTrailingSlash(resolvedPath); foundFilePath += name; // if aliased, de-alias! azstrcpy(tempBuffer, AZ_MAX_PATH_LEN, foundFilePath.c_str()); @@ -150,7 +150,7 @@ namespace AZ // Skip over the current and parent directory paths if (filenameView != "." && filenameView != ".." && NameMatchesFilter(entry->d_name, filter)) { - AZ::OSString foundFilePath = CheckForTrailingSlash(resolvedPath); + AZStd::string foundFilePath = CheckForTrailingSlash(resolvedPath); foundFilePath += entry->d_name; // if aliased, de-alias! azstrcpy(tempBuffer, AZ_MAX_PATH_LEN, foundFilePath.c_str()); @@ -199,7 +199,7 @@ namespace AZ } // make directories from bottom to top. - AZ::OSString pathBuffer; + AZStd::string pathBuffer; size_t pathLength = strlen(resolvedPath); pathBuffer.reserve(pathLength); for (size_t pathPos = 0; pathPos < pathLength; ++pathPos) diff --git a/Code/Framework/AzFramework/Platform/Common/UnixLike/AzFramework/IO/LocalFileIO_UnixLike.cpp b/Code/Framework/AzFramework/Platform/Common/UnixLike/AzFramework/IO/LocalFileIO_UnixLike.cpp index bf913e1818..c9cbdfbe7d 100644 --- a/Code/Framework/AzFramework/Platform/Common/UnixLike/AzFramework/IO/LocalFileIO_UnixLike.cpp +++ b/Code/Framework/AzFramework/Platform/Common/UnixLike/AzFramework/IO/LocalFileIO_UnixLike.cpp @@ -61,7 +61,7 @@ namespace AZ char resolvedPath[AZ_MAX_PATH_LEN] = {0}; ResolvePath(filePath, resolvedPath, AZ_MAX_PATH_LEN); - AZ::OSString withoutSlash = RemoveTrailingSlash(resolvedPath); + AZStd::string withoutSlash = RemoveTrailingSlash(resolvedPath); DIR* dir = opendir(withoutSlash.c_str()); if (dir != nullptr) @@ -80,7 +80,7 @@ namespace AZ // Skip over the current and parent directory paths if (filenameView != "." && filenameView != ".." && NameMatchesFilter(entry->d_name, filter)) { - AZ::OSString foundFilePath = CheckForTrailingSlash(resolvedPath); + AZStd::string foundFilePath = CheckForTrailingSlash(resolvedPath); foundFilePath += entry->d_name; // if aliased, dealias! azstrcpy(tempBuffer, AZ_MAX_PATH_LEN, foundFilePath.c_str()); @@ -116,7 +116,7 @@ namespace AZ } // make directories from bottom to top. - AZ::OSString buf; + AZStd::string buf; size_t pathLength = strlen(resolvedPath); buf.reserve(pathLength); for (size_t pos = 0; pos < pathLength; ++pos) diff --git a/Code/Framework/AzFramework/Platform/Common/WinAPI/AzFramework/IO/LocalFileIO_WinAPI.cpp b/Code/Framework/AzFramework/Platform/Common/WinAPI/AzFramework/IO/LocalFileIO_WinAPI.cpp index 61957fced0..5a56a360a8 100644 --- a/Code/Framework/AzFramework/Platform/Common/WinAPI/AzFramework/IO/LocalFileIO_WinAPI.cpp +++ b/Code/Framework/AzFramework/Platform/Common/WinAPI/AzFramework/IO/LocalFileIO_WinAPI.cpp @@ -128,7 +128,7 @@ namespace AZ } // make directories from bottom to top. - AZ::OSString buf; + AZStd::string buf; size_t pathLength = strlen(resolvedPath); buf.reserve(pathLength); for (size_t pos = 0; pos < pathLength; ++pos) diff --git a/Code/Framework/AzFramework/Platform/Linux/AzFramework/Process/ProcessWatcher_Linux.cpp b/Code/Framework/AzFramework/Platform/Linux/AzFramework/Process/ProcessWatcher_Linux.cpp index 8deed820d3..eb60b8e6ae 100644 --- a/Code/Framework/AzFramework/Platform/Linux/AzFramework/Process/ProcessWatcher_Linux.cpp +++ b/Code/Framework/AzFramework/Platform/Linux/AzFramework/Process/ProcessWatcher_Linux.cpp @@ -202,8 +202,6 @@ namespace AzFramework bool ProcessLauncher::LaunchProcess(const ProcessLaunchInfo& processLaunchInfo, ProcessData& processData) { - bool result = false; - // note that the convention here is that it uses windows-shell style escaping of combined args with spaces in it // (so surrounding with quotes like param="hello world") // this is so that the callers (which could be numerous) do not have to worry about this and sprinkle ifdefs diff --git a/Code/Framework/AzFramework/Platform/Mac/AzFramework/Process/ProcessWatcher_Mac.cpp b/Code/Framework/AzFramework/Platform/Mac/AzFramework/Process/ProcessWatcher_Mac.cpp index 4099443913..1ba9ff3067 100644 --- a/Code/Framework/AzFramework/Platform/Mac/AzFramework/Process/ProcessWatcher_Mac.cpp +++ b/Code/Framework/AzFramework/Platform/Mac/AzFramework/Process/ProcessWatcher_Mac.cpp @@ -205,8 +205,6 @@ namespace AzFramework bool ProcessLauncher::LaunchProcess(const ProcessLaunchInfo& processLaunchInfo, ProcessData& processData) { - bool result = false; - // note that the convention here is that it uses windows-shell style escaping of combined args with spaces in it // (so surrounding with quotes like param="hello world") // this is so that the callers (which could be numerous) do not have to worry about this and sprinkle ifdefs diff --git a/Code/Framework/AzFramework/Platform/Windows/AzFramework/Windowing/NativeWindow_Windows.cpp b/Code/Framework/AzFramework/Platform/Windows/AzFramework/Windowing/NativeWindow_Windows.cpp index 8312f9fa63..3f2b29a7bb 100644 --- a/Code/Framework/AzFramework/Platform/Windows/AzFramework/Windowing/NativeWindow_Windows.cpp +++ b/Code/Framework/AzFramework/Platform/Windows/AzFramework/Windowing/NativeWindow_Windows.cpp @@ -234,7 +234,7 @@ namespace AzFramework GetRawInputData((HRAWINPUT)lParam, RID_INPUT, NULL, &rawInputSize, rawInputHeaderSize); LPBYTE rawInputBytes = new BYTE[rawInputSize]; - const UINT bytesCopied = GetRawInputData((HRAWINPUT)lParam, RID_INPUT, rawInputBytes, &rawInputSize, rawInputHeaderSize); + GetRawInputData((HRAWINPUT)lParam, RID_INPUT, rawInputBytes, &rawInputSize, rawInputHeaderSize); RAWINPUT* rawInput = (RAWINPUT*)rawInputBytes; AzFramework::RawInputNotificationBusWindows::Broadcast( diff --git a/Code/Framework/AzFramework/Tests/ArchiveTests.cpp b/Code/Framework/AzFramework/Tests/ArchiveTests.cpp index 11495ec5d7..2caaf6ee71 100644 --- a/Code/Framework/AzFramework/Tests/ArchiveTests.cpp +++ b/Code/Framework/AzFramework/Tests/ArchiveTests.cpp @@ -84,7 +84,7 @@ namespace UnitTest for (AZ::u32 threadIdx = 0; threadIdx < numThreads; ++threadIdx) { - auto threadFunctor = [&testFunction, testIteration, threadIdx, &successCount]() + auto threadFunctor = [&testFunction, &successCount]() { // Add some variability to thread timing by yielding each thread AZStd::this_thread::yield(); @@ -769,7 +769,6 @@ namespace UnitTest AZStd::intrusive_ptr pArchive = archive->OpenArchive(testArchivePath, nullptr, AZ::IO::INestedArchive::FLAGS_CREATE_NEW); EXPECT_NE(nullptr, pArchive); - char fillBuffer[32] = "Test"; EXPECT_EQ(0, pArchive->UpdateFile("foundit.dat", const_cast("test"), 4, AZ::IO::INestedArchive::METHOD_COMPRESS, AZ::IO::INestedArchive::LEVEL_BEST)); pArchive.reset(); diff --git a/Code/Framework/AzFramework/Tests/CameraInputTests.cpp b/Code/Framework/AzFramework/Tests/CameraInputTests.cpp index ef340a41a5..486cca2af0 100644 --- a/Code/Framework/AzFramework/Tests/CameraInputTests.cpp +++ b/Code/Framework/AzFramework/Tests/CameraInputTests.cpp @@ -35,23 +35,23 @@ namespace UnitTest m_cameraSystem = AZStd::make_shared(); - m_translateCameraInputChannels.m_leftChannelId = AzFramework::InputChannelId("keyboard_key_alphanumeric_A"); - m_translateCameraInputChannels.m_rightChannelId = AzFramework::InputChannelId("keyboard_key_alphanumeric_D"); - m_translateCameraInputChannels.m_forwardChannelId = AzFramework::InputChannelId("keyboard_key_alphanumeric_W"); - m_translateCameraInputChannels.m_backwardChannelId = AzFramework::InputChannelId("keyboard_key_alphanumeric_S"); - m_translateCameraInputChannels.m_upChannelId = AzFramework::InputChannelId("keyboard_key_alphanumeric_E"); - m_translateCameraInputChannels.m_downChannelId = AzFramework::InputChannelId("keyboard_key_alphanumeric_Q"); - m_translateCameraInputChannels.m_boostChannelId = AzFramework::InputChannelId("keyboard_key_modifier_shift_l"); + m_translateCameraInputChannelIds.m_leftChannelId = AzFramework::InputChannelId("keyboard_key_alphanumeric_A"); + m_translateCameraInputChannelIds.m_rightChannelId = AzFramework::InputChannelId("keyboard_key_alphanumeric_D"); + m_translateCameraInputChannelIds.m_forwardChannelId = AzFramework::InputChannelId("keyboard_key_alphanumeric_W"); + m_translateCameraInputChannelIds.m_backwardChannelId = AzFramework::InputChannelId("keyboard_key_alphanumeric_S"); + m_translateCameraInputChannelIds.m_upChannelId = AzFramework::InputChannelId("keyboard_key_alphanumeric_E"); + m_translateCameraInputChannelIds.m_downChannelId = AzFramework::InputChannelId("keyboard_key_alphanumeric_Q"); + 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_translateCameraInputChannels); + AZStd::make_shared(AzFramework::LookTranslation, m_translateCameraInputChannelIds); auto orbitCamera = AZStd::make_shared(AzFramework::InputChannelId("keyboard_key_modifier_alt_l")); auto orbitRotateCamera = AZStd::make_shared(AzFramework::InputDeviceMouse::Button::Left); auto orbitTranslateCamera = - AZStd::make_shared(AzFramework::OrbitTranslation, m_translateCameraInputChannels); + AZStd::make_shared(AzFramework::OrbitTranslation, m_translateCameraInputChannelIds); orbitCamera->m_orbitCameras.AddCamera(orbitRotateCamera); orbitCamera->m_orbitCameras.AddCamera(orbitTranslateCamera); @@ -77,7 +77,7 @@ namespace UnitTest AllocatorsTestFixture::TearDown(); } - AzFramework::TranslateCameraInputChannels m_translateCameraInputChannels; + AzFramework::TranslateCameraInputChannelIds m_translateCameraInputChannelIds; AZStd::shared_ptr m_firstPersonRotateCamera; AZStd::shared_ptr m_firstPersonTranslateCamera; }; @@ -112,7 +112,7 @@ namespace UnitTest }); HandleEventAndUpdate( - AzFramework::DiscreteInputEvent{ m_translateCameraInputChannels.m_forwardChannelId, AzFramework::InputChannel::State::Began }); + AzFramework::DiscreteInputEvent{ m_translateCameraInputChannelIds.m_forwardChannelId, AzFramework::InputChannel::State::Began }); EXPECT_TRUE(activationBegan); } @@ -208,9 +208,9 @@ namespace UnitTest }); HandleEventAndUpdate( - AzFramework::DiscreteInputEvent{ m_translateCameraInputChannels.m_forwardChannelId, AzFramework::InputChannel::State::Began }); + AzFramework::DiscreteInputEvent{ m_translateCameraInputChannelIds.m_forwardChannelId, AzFramework::InputChannel::State::Began }); HandleEventAndUpdate( - AzFramework::DiscreteInputEvent{ m_translateCameraInputChannels.m_forwardChannelId, AzFramework::InputChannel::State::Ended }); + AzFramework::DiscreteInputEvent{ m_translateCameraInputChannelIds.m_forwardChannelId, AzFramework::InputChannel::State::Ended }); EXPECT_TRUE(activationBegan); EXPECT_TRUE(activationEnded); @@ -226,7 +226,7 @@ namespace UnitTest }); HandleEventAndUpdate( - AzFramework::DiscreteInputEvent{ m_translateCameraInputChannels.m_forwardChannelId, AzFramework::InputChannel::State::Began }); + AzFramework::DiscreteInputEvent{ m_translateCameraInputChannelIds.m_forwardChannelId, AzFramework::InputChannel::State::Began }); m_cameraSystem->m_cameras.Clear(); diff --git a/Code/Framework/AzFramework/Tests/FileIO.cpp b/Code/Framework/AzFramework/Tests/FileIO.cpp index 7be14bbbb7..7a01ba991b 100644 --- a/Code/Framework/AzFramework/Tests/FileIO.cpp +++ b/Code/Framework/AzFramework/Tests/FileIO.cpp @@ -752,7 +752,9 @@ namespace UnitTest // Test that sending in a too small output path fails, // if the output buffer is too small to hold the resolved path size_t SMALLER_THAN_FINAL_RESOLVED_PATH = expectedResolvedPath.length() - 1; + AZ_TEST_START_TRACE_SUPPRESSION; resolveDidWork = local.ResolvePath(aliasTestPath, aliasResolvedPath, SMALLER_THAN_FINAL_RESOLVED_PATH); + AZ_TEST_STOP_TRACE_SUPPRESSION(1); AZ_TEST_ASSERT(!resolveDidWork); // test clearing an alias diff --git a/Code/Framework/AzFramework/Tests/Scene.cpp b/Code/Framework/AzFramework/Tests/Scene.cpp index 0f701f3190..31df6e6774 100644 --- a/Code/Framework/AzFramework/Tests/Scene.cpp +++ b/Code/Framework/AzFramework/Tests/Scene.cpp @@ -230,7 +230,7 @@ namespace SceneUnitTest // Check to make sure there are no more active scenes. size_t index = 0; - m_sceneSystem->IterateActiveScenes([&index, &scenes](const AZStd::shared_ptr&) + m_sceneSystem->IterateActiveScenes([&index](const AZStd::shared_ptr&) { index++; return true; @@ -251,7 +251,7 @@ namespace SceneUnitTest scenes[i].reset(); } index = 0; - m_sceneSystem->IterateZombieScenes([&index, &scenes](Scene&) { + m_sceneSystem->IterateZombieScenes([&index](Scene&) { index++; return true; }); diff --git a/Code/Framework/AzFramework/Tests/Spawnable/SpawnableEntitiesManagerTests.cpp b/Code/Framework/AzFramework/Tests/Spawnable/SpawnableEntitiesManagerTests.cpp index f68af08f4a..407ab1d21f 100644 --- a/Code/Framework/AzFramework/Tests/Spawnable/SpawnableEntitiesManagerTests.cpp +++ b/Code/Framework/AzFramework/Tests/Spawnable/SpawnableEntitiesManagerTests.cpp @@ -313,7 +313,7 @@ namespace UnitTest FillSpawnable(NumEntities); CreateEntityReferences(refScheme); - auto callback = [this, refScheme, NumEntities] + auto callback = [this, refScheme] (AzFramework::EntitySpawnTicket::Id, AzFramework::SpawnableConstEntityContainerView entities) { ValidateEntityReferences(refScheme, NumEntities, entities); @@ -346,7 +346,7 @@ namespace UnitTest FillSpawnable(NumEntities); CreateEntityReferences(refScheme); - auto callback = [this, refScheme, NumEntities] + auto callback = [this, refScheme] (AzFramework::EntitySpawnTicket::Id, AzFramework::SpawnableConstEntityContainerView entities) { ValidateEntityReferences(refScheme, NumEntities, entities); @@ -572,6 +572,8 @@ namespace UnitTest auto callback = [this, refScheme, NumEntities](AzFramework::EntitySpawnTicket::Id, AzFramework::SpawnableConstEntityContainerView entities) { + AZ_UNUSED(refScheme); + AZ_UNUSED(NumEntities); ValidateEntityReferences(refScheme, NumEntities, entities); }; @@ -592,6 +594,8 @@ namespace UnitTest auto callback = [this, refScheme, NumEntities](AzFramework::EntitySpawnTicket::Id, AzFramework::SpawnableConstEntityContainerView entities) { + AZ_UNUSED(refScheme); + AZ_UNUSED(NumEntities); ValidateEntityReferences(refScheme, NumEntities, entities); }; @@ -617,7 +621,7 @@ namespace UnitTest CreateEntityReferences(refScheme); auto callback = - [this, refScheme, NumEntities](AzFramework::EntitySpawnTicket::Id, AzFramework::SpawnableConstEntityContainerView entities) + [](AzFramework::EntitySpawnTicket::Id, AzFramework::SpawnableConstEntityContainerView entities) { size_t numElements = entities.size(); @@ -671,7 +675,7 @@ namespace UnitTest CreateEntityReferences(refScheme); auto callback = - [this, refScheme, NumEntities](AzFramework::EntitySpawnTicket::Id, AzFramework::SpawnableConstEntityContainerView entities) + [](AzFramework::EntitySpawnTicket::Id, AzFramework::SpawnableConstEntityContainerView entities) { size_t numElements = entities.size(); @@ -719,6 +723,8 @@ namespace UnitTest auto callback = [this, refScheme, NumEntities](AzFramework::EntitySpawnTicket::Id, AzFramework::SpawnableConstEntityContainerView entities) { + AZ_UNUSED(refScheme); + AZ_UNUSED(NumEntities); ValidateEntityReferences(refScheme, NumEntities, entities); }; diff --git a/Code/Framework/AzManipulatorTestFramework/Tests/GridSnappingTest.cpp b/Code/Framework/AzManipulatorTestFramework/Tests/GridSnappingTest.cpp index c824ddc766..12b2a6546c 100644 --- a/Code/Framework/AzManipulatorTestFramework/Tests/GridSnappingTest.cpp +++ b/Code/Framework/AzManipulatorTestFramework/Tests/GridSnappingTest.cpp @@ -71,7 +71,7 @@ namespace UnitTest // callback to update the manipulator's current position linearManipulator->InstallMouseMoveCallback( - [this, linearManipulator](const AzToolsFramework::LinearManipulator::Action& action) + [linearManipulator](const AzToolsFramework::LinearManipulator::Action& action) { linearManipulator->SetLocalPosition(action.LocalPosition()); }); diff --git a/Code/Framework/AzNetworking/AzNetworking/TcpTransport/TcpListenThread.cpp b/Code/Framework/AzNetworking/AzNetworking/TcpTransport/TcpListenThread.cpp index 758cff3337..e65f01509e 100644 --- a/Code/Framework/AzNetworking/AzNetworking/TcpTransport/TcpListenThread.cpp +++ b/Code/Framework/AzNetworking/AzNetworking/TcpTransport/TcpListenThread.cpp @@ -64,7 +64,7 @@ namespace AzNetworking { --m_listenPortCount; - auto visitor = [this, &tcpNetworkInterface](ListenPort& listenPort) + auto visitor = [&tcpNetworkInterface](ListenPort& listenPort) { if (listenPort.m_tcpNetworkInterface == &tcpNetworkInterface) { @@ -118,9 +118,9 @@ namespace AzNetworking const int32_t connectionLength = aznumeric_cast(sizeof(newConnection)); memset(&newConnection, 0, connectionLength); - auto readCallback = [this, newConnection, connectionLength](SocketFd socketFd) + auto readCallback = [this, newConnection](SocketFd socketFd) { - auto visitor = [this, newConnection, connectionLength, socketFd](ListenPort& listenPort) + auto visitor = [this, newConnection, socketFd](ListenPort& listenPort) { if (listenPort.m_listenSocket.GetSocketFd() == socketFd) { @@ -132,7 +132,7 @@ namespace AzNetworking auto writeCallback = [](SocketFd) {}; m_tcpSocketManager.ProcessEvents(updateRateMs, readCallback, writeCallback); - auto cleanupUnused = [this](AZ::ThreadSafeDeque::DequeType& deque) + auto cleanupUnused = [](AZ::ThreadSafeDeque::DequeType& deque) { AZStd::remove_if(deque.begin(), deque.end(), [](ListenPort& listenPort) { return listenPort.m_tcpNetworkInterface == nullptr; }); }; diff --git a/Code/Framework/AzNetworking/AzNetworking/UdpTransport/DtlsSocket.cpp b/Code/Framework/AzNetworking/AzNetworking/UdpTransport/DtlsSocket.cpp index 1944995bac..ee784b6ffb 100644 --- a/Code/Framework/AzNetworking/AzNetworking/UdpTransport/DtlsSocket.cpp +++ b/Code/Framework/AzNetworking/AzNetworking/UdpTransport/DtlsSocket.cpp @@ -86,7 +86,7 @@ namespace AzNetworking #if AZ_TRAIT_USE_OPENSSL uint8_t encrpytedSendBuffer[MaxUdpTransmissionUnit]; // Write out the packet we were requested to send - const int32_t sentBytesRaw = SSL_write(dtlsEndpoint.m_sslSocket, data, size); + SSL_write(dtlsEndpoint.m_sslSocket, data, size); const int32_t sentBytesEnc = BIO_read(dtlsEndpoint.m_writeBio, encrpytedSendBuffer, sizeof(encrpytedSendBuffer)); // Track encryption metrics diff --git a/Code/Framework/AzNetworking/AzNetworking/UdpTransport/UdpSocket.cpp b/Code/Framework/AzNetworking/AzNetworking/UdpTransport/UdpSocket.cpp index 997fc323a9..44f6562c84 100644 --- a/Code/Framework/AzNetworking/AzNetworking/UdpTransport/UdpSocket.cpp +++ b/Code/Framework/AzNetworking/AzNetworking/UdpTransport/UdpSocket.cpp @@ -160,7 +160,6 @@ namespace AzNetworking const AZ::TimeMs jitterMs = aznumeric_cast(m_random.GetRandom()) % (connectionQuality.m_varianceMs > AZ::TimeMs{ 0 } ? connectionQuality.m_varianceMs : AZ::TimeMs{ 1 }); - const AZ::TimeMs currTimeMs = AZ::GetElapsedTimeMs(); const AZ::TimeMs deferTimeMs = (connectionQuality.m_latencyMs) + jitterMs; DeferredData deferred = DeferredData(address, data, size, encrypt, dtlsEndpoint); diff --git a/Code/Framework/AzNetworking/AzNetworking/Utilities/EncryptionCommon.cpp b/Code/Framework/AzNetworking/AzNetworking/Utilities/EncryptionCommon.cpp index 216342a6c5..57badcee4e 100644 --- a/Code/Framework/AzNetworking/AzNetworking/Utilities/EncryptionCommon.cpp +++ b/Code/Framework/AzNetworking/AzNetworking/Utilities/EncryptionCommon.cpp @@ -25,7 +25,7 @@ #if defined(OPENSSL_THREADS) // thread support enabled -#else +#elif AZ_TRAIT_USE_OPENSSL # error OpenSSL threading support is not enabled #endif diff --git a/Code/Framework/AzNetworking/AzNetworking/Utilities/Endian.h b/Code/Framework/AzNetworking/AzNetworking/Utilities/Endian.h index 08ca785f72..74bcd53877 100644 --- a/Code/Framework/AzNetworking/AzNetworking/Utilities/Endian.h +++ b/Code/Framework/AzNetworking/AzNetworking/Utilities/Endian.h @@ -14,14 +14,14 @@ #include #if AZ_TRAIT_NEEDS_HTONLL -static const uint64_t htonll(uint64_t value) +inline const uint64_t htonll(uint64_t value) { const uint32_t hiValue = htonl(static_cast(value >> 32)); const uint32_t loValue = htonl(static_cast(value & 0x00000000FFFFFFFF)); return static_cast(hiValue) << 32 | static_cast(loValue); } -static const uint64_t ntohll(uint64_t value) +inline const uint64_t ntohll(uint64_t value) { return htonll(value); } diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/DockBarButton.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Components/DockBarButton.cpp index 113516c350..e48121c118 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Components/DockBarButton.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/DockBarButton.cpp @@ -141,7 +141,6 @@ namespace AzQtComponents } QRect buttonRect = style->subControlRect(QStyle::CC_ToolButton, option, QStyle::SC_ToolButton, widget); - QRect menuRect = style->subControlRect(QStyle::CC_ToolButton, option, QStyle::SC_ToolButtonMenu, widget); painter->save(); diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/DockTabBar.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Components/DockTabBar.cpp index 2574e1b05a..127163f056 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Components/DockTabBar.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/DockTabBar.cpp @@ -31,8 +31,6 @@ static const int g_closeButtonOffset = g_closeButtonWidth + AzQtComponents::Dock static const QColor g_tabIndicatorUnderlayColor(Qt::black); // Constant for the opacity of our tab indicator underlay static const qreal g_tabIndicatorUnderlayOpacity = 0.75; -// Constant for the duration of our tab animations (in milliseconds) -static const int g_tabAnimationDurationMS = 250; namespace AzQtComponents diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/FilteredSearchWidget.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Components/FilteredSearchWidget.cpp index b924eb9776..7fb9942032 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Components/FilteredSearchWidget.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/FilteredSearchWidget.cpp @@ -852,7 +852,7 @@ namespace AzQtComponents { FilterCriteriaButton* button = createCriteriaButton(filter, index); connect(button, &FilterCriteriaButton::RequestClose, this, [this, index]() { SetFilterStateByIndex(index, false); }); - connect(button, &FilterCriteriaButton::ExtraButtonClicked, this, [this, index](FilterCriteriaButton::ExtraButtonType type) + connect(button, &FilterCriteriaButton::ExtraButtonClicked, this, [](FilterCriteriaButton::ExtraButtonType type) { switch (type) { diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/Widgets/Card.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Components/Widgets/Card.cpp index a4ab3c5e5d..40c0a1d55a 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Components/Widgets/Card.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/Widgets/Card.cpp @@ -25,11 +25,6 @@ namespace AzQtComponents { - namespace CardConstants - { - static const char* kPropertySelected = "selected"; - } - static QPixmap ApplyAlphaToPixmap(const QPixmap& pixmap, float alpha) { QImage image = pixmap.toImage().convertToFormat(QImage::Format_ARGB32); diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/Widgets/ColorPicker/PaletteCardCollection.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Components/Widgets/ColorPicker/PaletteCardCollection.cpp index 40b95af321..fea843a565 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Components/Widgets/ColorPicker/PaletteCardCollection.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/Widgets/ColorPicker/PaletteCardCollection.cpp @@ -208,7 +208,7 @@ namespace AzQtComponents QString PaletteCardCollection::uniquePaletteName(QSharedPointer card, const QString& name) const { - const auto paletteNameExists = [this, card](const QString& name) + const auto paletteNameExists = [this](const QString& name) { auto it = std::find_if(m_paletteCards.begin(), m_paletteCards.end(), [&name](QSharedPointer card) diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/Widgets/Eyedropper.h b/Code/Framework/AzQtComponents/AzQtComponents/Components/Widgets/Eyedropper.h index 68627f534a..741a22e47e 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Components/Widgets/Eyedropper.h +++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/Widgets/Eyedropper.h @@ -72,7 +72,7 @@ namespace AzQtComponents void release(bool selected); - QToolButton* m_button; + [[maybe_unused]] QToolButton* m_button; int m_contextSize; int m_sampleSize; diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/Widgets/GradientSlider.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Components/Widgets/GradientSlider.cpp index a1ebd6c16c..1ffff57ade 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Components/Widgets/GradientSlider.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/Widgets/GradientSlider.cpp @@ -30,7 +30,7 @@ GradientSlider::GradientSlider(Qt::Orientation orientation, QWidget* parent) setMouseTracking(true); - m_colorFunction = [this](qreal value) { + m_colorFunction = [](qreal value) { return QColor::fromRgbF(value, value, value); }; @@ -115,7 +115,6 @@ void GradientSlider::mouseMoveEvent(QMouseEvent* event) int intValue = Slider::valueFromPosition(this, event->pos(), width(), height(), rect().bottom()); qreal value = (aznumeric_cast(intValue - minimum()) / aznumeric_cast(maximum() - minimum())); - QColor rgb = m_colorFunction(value); const QString toolTipText = m_toolTipFunction(value); diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/Widgets/Slider.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Components/Widgets/Slider.cpp index f5de3c0c30..14ac2010bc 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Components/Widgets/Slider.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/Widgets/Slider.cpp @@ -490,11 +490,11 @@ QRect Slider::sliderGrooveRect(const Style* style, const QStyleOptionSlider* opt return {}; } -bool Slider::polish(Style* style, QWidget* widget, const Slider::Config& config) +bool Slider::polish([[maybe_unused]] Style* style, QWidget* widget, const Slider::Config& config) { Q_UNUSED(config); - auto polishSlider = [style](auto slider) + auto polishSlider = [](auto slider) { // Qt's stylesheet parsing doesn't set custom properties on things specified via // pseudo-states, such as horizontal/vertical, so we implement our own diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Components/WindowDecorationWrapper.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Components/WindowDecorationWrapper.cpp index 5561ec0c0f..804ea841dd 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Components/WindowDecorationWrapper.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Components/WindowDecorationWrapper.cpp @@ -65,7 +65,6 @@ namespace AzQtComponents return false; } - const quint16 currentMajorVersion = 2; quint16 majorVersion = 0; quint16 minorVersion = 0; diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Gallery/SpinBoxPage.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Gallery/SpinBoxPage.cpp index 0ee5d90d38..1ee8daf786 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Gallery/SpinBoxPage.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Gallery/SpinBoxPage.cpp @@ -146,7 +146,7 @@ AzQtComponents::SpinBox::setHasError(doubleSpinBox, true); { QAction* action = new QAction("Up", this); action->setShortcut(QKeySequence(Qt::Key_Up)); - connect(action, &QAction::triggered, [this]() + connect(action, &QAction::triggered, []() { qDebug() << "Up pressed"; }); @@ -155,7 +155,7 @@ AzQtComponents::SpinBox::setHasError(doubleSpinBox, true); { QAction* action = new QAction("Down", this); action->setShortcut(QKeySequence(Qt::Key_Down)); - connect(action, &QAction::triggered, [this]() + connect(action, &QAction::triggered, []() { qDebug() << "Down pressed"; }); @@ -171,7 +171,7 @@ template void SpinBoxPage::track(SpinBoxType* spinBox) { // connect to changes in the spinboxes and listen for the undo state - QObject::connect(spinBox, &SpinBoxType::valueChangeBegan, this, [this, spinBox]() { + QObject::connect(spinBox, &SpinBoxType::valueChangeBegan, this, [spinBox]() { ValueType oldValue = spinBox->value(); spinBox->setProperty("OldValue", oldValue); }); diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Gallery/TabWidgetPage.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Gallery/TabWidgetPage.cpp index 9059e910a3..6e553e7436 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Gallery/TabWidgetPage.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Gallery/TabWidgetPage.cpp @@ -36,17 +36,17 @@ TabWidgetPage::TabWidgetPage(QWidget* parent) menu->addAction("Action 4 (No-op)"); actionMenu->setMenu(menu); - connect(action1, &QAction::triggered, this, [this]() { + connect(action1, &QAction::triggered, this, []() { QMessageBox messageBox({}, "Action 1 triggered", "Action 1 has been triggered", QMessageBox::Ok); messageBox.exec(); }); - connect(action2, &QAction::triggered, this, [this]() { + connect(action2, &QAction::triggered, this, []() { QMessageBox messageBox({}, "Action 2 triggered", "Action 2 has been triggered", QMessageBox::Ok); messageBox.exec(); }); - connect(action3, &QAction::triggered, this, [this]() { + connect(action3, &QAction::triggered, this, []() { QMessageBox messageBox({}, "Action 3 triggered", "Action 3 has been triggered", QMessageBox::Ok); messageBox.exec(); }); diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Utilities/ScreenGrabber.h b/Code/Framework/AzQtComponents/AzQtComponents/Utilities/ScreenGrabber.h index b5bbdb6ade..a32aeda3fc 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Utilities/ScreenGrabber.h +++ b/Code/Framework/AzQtComponents/AzQtComponents/Utilities/ScreenGrabber.h @@ -31,7 +31,7 @@ namespace AzQtComponents private: QSize m_size; - Eyedropper* m_owner; + [[maybe_unused]] Eyedropper* m_owner; QScopedPointer m_internal; }; diff --git a/Code/Framework/AzQtComponents/AzQtComponents/Utilities/ScreenGrabber_win.cpp b/Code/Framework/AzQtComponents/AzQtComponents/Utilities/ScreenGrabber_win.cpp index 56d0663f88..ba23bea557 100644 --- a/Code/Framework/AzQtComponents/AzQtComponents/Utilities/ScreenGrabber_win.cpp +++ b/Code/Framework/AzQtComponents/AzQtComponents/Utilities/ScreenGrabber_win.cpp @@ -217,7 +217,7 @@ namespace AzQtComponents } ScreenGrabber::ScreenGrabber(const QSize size, Eyedropper* parent /* = nullptr */) - : QObject(static_cast(parent)) + : QObject(parent) , m_size(size) , m_owner(parent) { diff --git a/Code/Framework/AzTest/AzTest/Utils.cpp b/Code/Framework/AzTest/AzTest/Utils.cpp index 0fe701ca5a..7c2c964504 100644 --- a/Code/Framework/AzTest/AzTest/Utils.cpp +++ b/Code/Framework/AzTest/AzTest/Utils.cpp @@ -121,7 +121,7 @@ namespace AZ char** SplitCommandLine(int& size, char* const cmdLine) { std::vector tokens; - char* next_token = nullptr; + [[maybe_unused]] char* next_token = nullptr; char* tok = azstrtok(cmdLine, 0, " ", &next_token); while (tok != NULL) { diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Application/ToolsApplication.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Application/ToolsApplication.cpp index 3e895465e5..a3a79402ad 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Application/ToolsApplication.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Application/ToolsApplication.cpp @@ -70,7 +70,7 @@ #include AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") // 4251: 'QFileInfo::d_ptr': class 'QSharedDataPointer' needs to have dll-interface to be used by clients of class 'QFileInfo' #include -AZ_POP_DISABLE_OVERRIDE_WARNING +AZ_POP_DISABLE_WARNING #include #include #include @@ -87,11 +87,6 @@ namespace AzToolsFramework { namespace Internal { - static const char* s_engineConfigFileName = "engine.json"; - static const char* s_engineConfigEngineVersionKey = "O3DEVersion"; - - static const char* s_startupLogWindow = "Startup"; - template void DeleteEntities(const IdContainerType& entityIds) { diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Archive/ArchiveComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Archive/ArchiveComponent.cpp index 2a09ba0471..5004108132 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Archive/ArchiveComponent.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Archive/ArchiveComponent.cpp @@ -236,7 +236,7 @@ namespace AzToolsFramework { AZStd::string commandLineArgs = Platform::GetListFilesInArchiveCommand(archivePath); - auto parseOutput = [respCallback, taskHandle, &fileEntries](bool exitCode, AZStd::string consoleOutput) + auto parseOutput = [respCallback, &fileEntries](bool exitCode, AZStd::string consoleOutput) { Platform::ParseConsoleOutputFromListFilesInArchive(consoleOutput, fileEntries); AZ::TickBus::QueueFunction(respCallback, exitCode, AZStd::move(consoleOutput)); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp index c729ac4d6f..0601a34cf5 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp @@ -134,7 +134,7 @@ namespace AzToolsFramework { const auto& subFilters = compFilter->GetSubFilters(); const auto& compFilterIter = AZStd::find_if(subFilters.cbegin(), subFilters.cend(), - [subFilters](FilterConstType filter) -> bool + [](FilterConstType filter) -> bool { const auto assetTypeFilter = qobject_cast>(filter); return !assetTypeFilter.isNull(); @@ -146,7 +146,7 @@ namespace AzToolsFramework } const auto& compositeStringFilterIter = AZStd::find_if(subFilters.cbegin(), subFilters.cend(), - [subFilters](FilterConstType filter) -> bool + [](FilterConstType filter) -> bool { // The real StringFilter is really a CompositeFilter with just one StringFilter in its subfilter list // To know if it is actually a StringFilter we have to get that subfilter and check if it is a Stringfilter. diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserFolderWidget.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserFolderWidget.cpp index 7e2b0859a6..d918cad2a2 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserFolderWidget.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserFolderWidget.cpp @@ -81,7 +81,7 @@ namespace AzToolsFramework mainLayout->addWidget(m_viewStack); - connect(actionGroup, &QActionGroup::triggered, this, [this, thumbnailViewAction, listViewAction, sizeComboBox](QAction* action) { + connect(actionGroup, &QActionGroup::triggered, this, [this, thumbnailViewAction, sizeComboBox](QAction* action) { if (action == thumbnailViewAction) { m_viewStack->setCurrentWidget(m_thumbnailView); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetDatabase/AssetDatabaseConnection.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetDatabase/AssetDatabaseConnection.cpp index 7daf573c99..2e8e4ef639 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetDatabase/AssetDatabaseConnection.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetDatabase/AssetDatabaseConnection.cpp @@ -939,6 +939,34 @@ namespace AzToolsFramework jobinfo.m_warningCount = jobDatabaseEntry.m_warningCount; jobinfo.m_errorCount = jobDatabaseEntry.m_errorCount; } + + bool GetDatabaseInfoResult(const char* callName, SQLite::Statement* statement, AssetDatabaseConnection::databaseInfoHandler handler); + bool GetScanFolderResult(const char* callName, SQLite::Statement* statement, AssetDatabaseConnection::scanFolderHandler handler); + bool GetSourceResult(const char* callName, SQLite::Statement* statement, AssetDatabaseConnection::sourceHandler handler); + bool GetSourceAndScanfolderResult(const char* callName, SQLite::Statement* statement, AssetDatabaseConnection::combinedSourceScanFolderHandler handler); + bool GetSourceDependencyResult(const char* callName, SQLite::Statement* statement, AssetDatabaseConnection::sourceFileDependencyHandler handler); + bool GetJobResultSimple(const char* name, SQLite::Statement* statement, AssetDatabaseConnection::jobHandler handler); + bool GetJobResult( + const char* callName, + SQLite::Statement* statement, + AssetDatabaseConnection::jobHandler handler, + AZ::Uuid builderGuid = AZ::Uuid::CreateNull(), + const char* jobKey = nullptr, + AssetSystem::JobStatus status = AssetSystem::JobStatus::Any); + bool GetProductResultSimple(const char* name, SQLite::Statement* statement, AssetDatabaseConnection::productHandler handler); + bool GetProductResult( + const char* callName, + SQLite::Statement* statement, + AssetDatabaseConnection::productHandler handler, + AZ::Uuid builderGuid = AZ::Uuid::CreateNull(), + const char* jobKey = nullptr, + AssetSystem::JobStatus status = AssetSystem::JobStatus::Any); + bool GetLegacySubIDsResult(const char* callname, SQLite::Statement* statement, AssetDatabaseConnection::legacySubIDsHandler handler); + bool GetProductDependencyResult(const char* callName, SQLite::Statement* statement, AssetDatabaseConnection::productDependencyHandler handler); + bool GetProductDependencyAndPathResult(const char* callName, SQLite::Statement* statement, AssetDatabaseConnection::productDependencyAndPathHandler handler); + bool GetMissingProductDependencyResult(const char* callName, SQLite::Statement* statement, AssetDatabaseConnection::missingProductDependencyHandler handler); + bool GetCombinedDependencyResult(const char* callName, SQLite::Statement* statement, AssetDatabaseConnection::combinedProductDependencyHandler handler); + bool GetFileResult(const char* callName, SQLite::Statement* statement, AssetDatabaseConnection::fileHandler handler); } ////////////////////////////////////////////////////////////////////////// diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetDatabase/AssetDatabaseConnection.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetDatabase/AssetDatabaseConnection.h index 8672ad4a15..a59dbfbda4 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetDatabase/AssetDatabaseConnection.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetDatabase/AssetDatabaseConnection.h @@ -655,26 +655,6 @@ namespace AzToolsFramework // before every query, since validating it essentially must makes sure it exists. AZStd::unordered_set m_validatedTables; }; - - namespace - { - //boiler plate - bool GetDatabaseInfoResult(const char* callName, SQLite::Statement* statement, AssetDatabaseConnection::databaseInfoHandler handler); - bool GetScanFolderResult(const char* callName, SQLite::Statement* statement, AssetDatabaseConnection::scanFolderHandler handler); - bool GetSourceResult(const char* callName, SQLite::Statement* statement, AssetDatabaseConnection::sourceHandler handler); - bool GetSourceAndScanfolderResult(const char* callName, SQLite::Statement* statement, AssetDatabaseConnection::combinedSourceScanFolderHandler handler); - bool GetSourceDependencyResult(const char* callName, SQLite::Statement* statement, AssetDatabaseConnection::sourceFileDependencyHandler handler); - bool GetJobResultSimple(const char* name, SQLite::Statement* statement, AssetDatabaseConnection::jobHandler handler); - bool GetJobResult(const char* callName, SQLite::Statement* statement, AssetDatabaseConnection::jobHandler handler, AZ::Uuid builderGuid = AZ::Uuid::CreateNull(), const char* jobKey = nullptr, AssetSystem::JobStatus status = AssetSystem::JobStatus::Any); - bool GetProductResultSimple(const char* name, SQLite::Statement* statement, AssetDatabaseConnection::productHandler handler); - bool GetProductResult(const char* callName, SQLite::Statement* statement, AssetDatabaseConnection::productHandler handler, AZ::Uuid builderGuid = AZ::Uuid::CreateNull(), const char* jobKey = nullptr, AssetSystem::JobStatus status = AssetSystem::JobStatus::Any); - bool GetLegacySubIDsResult(const char* callname, SQLite::Statement* statement, AssetDatabaseConnection::legacySubIDsHandler handler); - bool GetProductDependencyResult(const char* callName, SQLite::Statement* statement, AssetDatabaseConnection::productDependencyHandler handler); - bool GetProductDependencyAndPathResult(const char* callName, SQLite::Statement* statement, AssetDatabaseConnection::productDependencyAndPathHandler handler); - bool GetMissingProductDependencyResult(const char* callName, SQLite::Statement* statement, AssetDatabaseConnection::missingProductDependencyHandler handler); - bool GetCombinedDependencyResult(const char* callName, SQLite::Statement* statement, AssetDatabaseConnection::combinedProductDependencyHandler handler); - bool GetFileResult(const char* callName, SQLite::Statement* statement, AssetDatabaseConnection::fileHandler handler); - } } // namespace AssetDatabase }// namespace AzToolsFramework diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetEditor/AssetEditorWidget.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetEditor/AssetEditorWidget.cpp index 744b87d753..7198ed1be8 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetEditor/AssetEditorWidget.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetEditor/AssetEditorWidget.cpp @@ -57,7 +57,7 @@ namespace AzToolsFramework { using AssetCheckoutCallback = AZStd::function; - void AssetCheckoutCommon(const AZ::Data::AssetId& id, AZ::Data::Asset asset, AZ::SerializeContext* serializeContext, AssetCheckoutCallback assetCheckoutAndSaveCallback) + void AssetCheckoutCommon(const AZ::Data::AssetId& id, AZ::Data::Asset asset, [[maybe_unused]] AZ::SerializeContext* serializeContext, AssetCheckoutCallback assetCheckoutAndSaveCallback) { AZStd::string assetPath; AZ::Data::AssetCatalogRequestBus::BroadcastResult(assetPath, &AZ::Data::AssetCatalogRequests::GetAssetPathById, id); @@ -74,7 +74,7 @@ namespace AzToolsFramework { using SCCommandBus = SourceControlCommandBus; SCCommandBus::Broadcast(&SCCommandBus::Events::RequestEdit, assetFullPath.c_str(), true, - [id, asset, assetFullPath, serializeContext, assetCheckoutAndSaveCallback](bool /*success*/, const SourceControlFileInfo& info) + [id, asset, assetFullPath, assetCheckoutAndSaveCallback](bool /*success*/, const SourceControlFileInfo& info) { if (!info.IsReadOnly()) { @@ -360,7 +360,7 @@ namespace AzToolsFramework if (savedCallback) { auto conn = AZStd::make_shared(); - *conn = connect(this, &AssetEditorWidget::OnAssetSavedSignal, this, [this, conn, savedCallback]() + *conn = connect(this, &AssetEditorWidget::OnAssetSavedSignal, this, [conn, savedCallback]() { disconnect(*conn); savedCallback(); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Component/EditorComponentAPIComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Component/EditorComponentAPIComponent.cpp index 68ea0119d9..30a7c603bd 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Component/EditorComponentAPIComponent.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Component/EditorComponentAPIComponent.cpp @@ -262,7 +262,7 @@ namespace AzToolsFramework m_serializeContext->EnumerateDerived( [&typeNameList, entityType](const AZ::SerializeContext::ClassData* componentClass, const AZ::Uuid& knownType) -> bool { - AZ_UNUSED(knownType) + AZ_UNUSED(knownType); if (!componentClass->m_editData) { diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityHelpers.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityHelpers.cpp index 0b0358d613..6ed133c830 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityHelpers.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityHelpers.cpp @@ -1324,7 +1324,7 @@ namespace AzToolsFramework AZ::SliceComponent::EntityAncestorList::const_iterator ancestorIter = ancestors.begin(); // Skip the first, that would be a regular slice root and not a subslice root, which was already checked. ++ancestorIter; - for (ancestorIter; ancestorIter != ancestors.end(); ++ancestorIter) + for (; ancestorIter != ancestors.end(); ++ancestorIter) { const AZ::SliceComponent::Ancestor& ancestor = *ancestorIter; if (!ancestor.m_entity || !SliceUtilities::IsRootEntity(*ancestor.m_entity)) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/SliceEditorEntityOwnershipService.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/SliceEditorEntityOwnershipService.cpp index 7ac3b7be8f..9e7e48cbaa 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/SliceEditorEntityOwnershipService.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/SliceEditorEntityOwnershipService.cpp @@ -98,7 +98,6 @@ namespace AzToolsFramework void SliceEditorEntityOwnershipService::OnSlicePreInstantiate(const AZ::Data::AssetId& sliceAssetId, const AZ::SliceComponent::SliceInstanceAddress& sliceAddress) { AZ_PROFILE_FUNCTION(AzToolsFramework); - const AzFramework::SliceInstantiationTicket ticket = *AzFramework::SliceInstantiationResultBus::GetCurrentBusId(); // Start an undo that will wrap the entire slice instantiation event (unable to do this at a higher level since this is queued up by AzFramework and there's no undo concept at that level) ToolsApplicationRequests::Bus::Broadcast(&ToolsApplicationRequests::Bus::Events::BeginUndoBatch, "Slice Instantiation"); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/EditorVertexSelection.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/EditorVertexSelection.cpp index f49df5d029..81f573672b 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/EditorVertexSelection.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Manipulators/EditorVertexSelection.cpp @@ -895,7 +895,7 @@ namespace AzToolsFramework // calculate average position of selected vertices for translation manipulator MidpointCalculator midpointCalculator; m_translationManipulator->Process( - [this, &midpointCalculator, fixedVertices](typename IndexedTranslationManipulator::VertexLookup& vertex) + [&midpointCalculator, fixedVertices](typename IndexedTranslationManipulator::VertexLookup& vertex) { Vertex v; bool found = false; @@ -1306,7 +1306,7 @@ namespace AzToolsFramework void EditorVertexSelectionVariable::PrepareActions() { ActionOverride deleteAction = CreateDeleteAction( - s_deleteVerticesTitle, s_duplicateVerticesDesc, + s_deleteVerticesTitle, s_deleteVerticesDesc, [this]() { DestroySelected(); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/InstanceToTemplatePropagator.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/InstanceToTemplatePropagator.cpp index 36b39f3a72..6b281bcbae 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/InstanceToTemplatePropagator.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/InstanceToTemplatePropagator.cpp @@ -262,8 +262,6 @@ namespace AzToolsFramework void InstanceToTemplatePropagator::AddPatchesToLink(const PrefabDom& patches, Link& link) { PrefabDom& linkDom = link.GetLinkDom(); - PrefabDomValueReference linkPatchesReference = - PrefabDomUtils::FindPrefabDomValue(linkDom, PrefabDomUtils::PatchesName); /* If the original allocator the patches were created with gets destroyed, then the patches would become garbage in the diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.cpp index cdb1e9a2ad..24cd0f0252 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.cpp @@ -1298,9 +1298,6 @@ namespace AzToolsFramework command->RunRedo(); } - const auto instanceTemplateId = instancePtr->GetTemplateId(); - auto parentContainerEntityId = parentInstance.GetContainerEntityId(); - instancePtr->DetachNestedInstances( [&](AZStd::unique_ptr detachedNestedInstance) { diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Slice/SliceUtilities.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Slice/SliceUtilities.cpp index 02fc2c2c40..aca667b9aa 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Slice/SliceUtilities.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Slice/SliceUtilities.cpp @@ -461,7 +461,7 @@ namespace AzToolsFramework msgBox.setStandardButtons(QMessageBox::Cancel); msgBox.setDefaultButton(QMessageBox::Yes); msgBox.setDetailedText(message.c_str()); - const int response = msgBox.exec(); + msgBox.exec(); if (msgBox.clickedButton() == moveButton) { @@ -2043,7 +2043,7 @@ namespace AzToolsFramework QAction* confirmSelected = new QAction(detachMenu); confirmationMessageBox->addAction(confirmSelected); - QObject::connect(reassignToAction, &QAction::triggered, [reassignToAction, confirmationMessageBox, selectedEntity, ancestors, currentAncestorIndex]() mutable + QObject::connect(reassignToAction, &QAction::triggered, [confirmationMessageBox, ancestors, currentAncestorIndex]() mutable { if (confirmationMessageBox->exec() == QDialog::Accepted) { @@ -4094,7 +4094,7 @@ namespace AzToolsFramework using SCCommandBus = AzToolsFramework::SourceControlCommandBus; SCCommandBus::Broadcast(&SCCommandBus::Events::RequestEdit, fullFilePath.c_str(), true, - [sliceEntity, fullFilePath, tmpFileName, tmpFilesaved](bool /*success*/, const AzToolsFramework::SourceControlFileInfo& info) + [fullFilePath, tmpFileName, tmpFilesaved](bool /*success*/, const AzToolsFramework::SourceControlFileInfo& info) { if (!info.IsReadOnly()) { @@ -4200,8 +4200,6 @@ namespace AzToolsFramework if (canPush) { - AZ::Data::AssetId targetSliceAssetId = sliceAncestryToPushTo.at(0).m_sliceAddress.GetReference()->GetSliceAsset().GetId(); - //remember we're trying to push to this root, so we don't try to push to any others size_t ancestrySize = sliceAncestryToPushTo.size(); rootAncestorPushList.push_back(sliceAncestryToPushTo[ancestrySize-1].m_sliceAddress.GetReference()->GetSliceAsset().GetId()); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/LoadingThumbnail.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/LoadingThumbnail.cpp index 91f70f619a..6b8f331de7 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/LoadingThumbnail.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/LoadingThumbnail.cpp @@ -23,7 +23,6 @@ namespace AzToolsFramework LoadingThumbnail::LoadingThumbnail() : Thumbnail(MAKE_TKEY(ThumbnailKey)) - , m_angle(0) { auto absoluteIconPath = AZ::IO::FixedMaxPath(AZ::Utils::GetEnginePath()) / LoadingIconPath; m_loadingMovie.setFileName(absoluteIconPath.c_str()); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/LoadingThumbnail.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/LoadingThumbnail.h index 811e2e09b7..cbf7ec5489 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/LoadingThumbnail.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Thumbnails/LoadingThumbnail.h @@ -37,7 +37,6 @@ namespace AzToolsFramework void OnTick(float deltaTime, AZ::ScriptTimePoint /*time*/) override; private: - float m_angle; QMovie m_loadingMovie; }; } // namespace Thumbnailer diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Layer/LayerUiHandler.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Layer/LayerUiHandler.cpp index d3dd556ae2..b0eee96abc 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Layer/LayerUiHandler.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Layer/LayerUiHandler.cpp @@ -111,9 +111,6 @@ namespace AzToolsFramework painter, option.rect.left() - 1, option.rect.top(), option.rect.bottom(), m_layerBorderBottomColor, layerColor); } - QModelIndex nameColumn = index.sibling(index.row(), EntityOutlinerListModel::Column::ColumnName); - QModelIndex sibling = index.sibling(index.row() + 1, index.column()); - QPoint lineBottomLeft(option.rect.bottomLeft()); QPoint lineTopLeft(option.rect.topLeft()); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/LegacyFramework/Core/EditorFrameworkApplication.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/LegacyFramework/Core/EditorFrameworkApplication.cpp index 5b2638da1e..33562421e9 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/LegacyFramework/Core/EditorFrameworkApplication.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/LegacyFramework/Core/EditorFrameworkApplication.cpp @@ -48,7 +48,7 @@ AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") // 'QFileInfo::d_ptr': class 'QSharedDataPointer' needs to have dll-interface to be used by clients of class 'QFileInfo' #include -AZ_POP_DISABLE_OVERRIDE_WARNING +AZ_POP_DISABLE_WARNING #include #include #include diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Logging/LogPanel_Panel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Logging/LogPanel_Panel.cpp index 55c42e2535..4fabdfad12 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Logging/LogPanel_Panel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Logging/LogPanel_Panel.cpp @@ -657,7 +657,6 @@ namespace AzToolsFramework // if we have any elements, the last element is top right aligned: QLayoutItem* pItem = m_children[m_children.size() - 1]; QSize lastItemSize = pItem->minimumSize(); - QPoint topRight = effectiveRect.topRight(); QRect topRightCorner(effectiveRect.topRight() - QPoint(lastItemSize.width(), 0), lastItemSize); pItem->setGeometry(topRightCorner); } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp index 380d6876da..b9180f8ef6 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Outliner/EntityOutlinerListModel.cpp @@ -1106,8 +1106,6 @@ namespace AzToolsFramework QMimeData* EntityOutlinerListModel::mimeData(const QModelIndexList& indexes) const { AZ_PROFILE_FUNCTION(AzToolsFramework); - AZ::TypeId uuid1 = AZ::AzTypeInfo::Uuid(); - AZ::TypeId uuid2 = AZ::AzTypeInfo::Uuid(); EditorEntityIdContainer entityIdList; for (const QModelIndex& index : indexes) @@ -1334,13 +1332,11 @@ namespace AzToolsFramework QueueEntityUpdate(entityId); } - void EntityOutlinerListModel::OnEntityInfoUpdatedRemoveChildBegin(AZ::EntityId parentId, AZ::EntityId childId) + void EntityOutlinerListModel::OnEntityInfoUpdatedRemoveChildBegin([[maybe_unused]] AZ::EntityId parentId, [[maybe_unused]] AZ::EntityId childId) { //add/remove operations trigger selection change signals which assert and break undo/redo operations in progress in inspector etc. //so disallow selection updates until change is complete emit EnableSelectionUpdates(false); - auto parentIndex = GetIndexFromEntity(parentId); - auto childIndex = GetIndexFromEntity(childId); beginResetModel(); } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/PrefabIntegrationManager.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/PrefabIntegrationManager.cpp index c17b96411e..d7fdb604fe 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/PrefabIntegrationManager.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Prefab/PrefabIntegrationManager.cpp @@ -157,7 +157,7 @@ namespace AzToolsFramework QAction* createAction = menu->addAction(QObject::tr("Create Prefab...")); createAction->setToolTip(QObject::tr("Creates a prefab out of the currently selected entities.")); - QObject::connect(createAction, &QAction::triggered, createAction, [this, selectedEntities] { + QObject::connect(createAction, &QAction::triggered, createAction, [selectedEntities] { ContextMenu_CreatePrefab(selectedEntities); }); } @@ -171,7 +171,7 @@ namespace AzToolsFramework instantiateAction->setToolTip(QObject::tr("Instantiates a prefab file in the scene.")); QObject::connect( - instantiateAction, &QAction::triggered, instantiateAction, [this] { ContextMenu_InstantiatePrefab(); }); + instantiateAction, &QAction::triggered, instantiateAction, [] { ContextMenu_InstantiatePrefab(); }); } menu->addSeparator(); @@ -196,7 +196,7 @@ namespace AzToolsFramework QAction* editAction = menu->addAction(QObject::tr("Edit Prefab")); editAction->setToolTip(QObject::tr("Edit the prefab in focus mode.")); - QObject::connect(editAction, &QAction::triggered, editAction, [this, selectedEntity] { + QObject::connect(editAction, &QAction::triggered, editAction, [selectedEntity] { ContextMenu_EditPrefab(selectedEntity); }); @@ -213,7 +213,7 @@ namespace AzToolsFramework QAction* saveAction = menu->addAction(QObject::tr("Save Prefab to file")); saveAction->setToolTip(QObject::tr("Save the changes to the prefab to disk.")); - QObject::connect(saveAction, &QAction::triggered, saveAction, [this, selectedEntity] { + QObject::connect(saveAction, &QAction::triggered, saveAction, [selectedEntity] { ContextMenu_SavePrefab(selectedEntity); }); @@ -229,7 +229,7 @@ namespace AzToolsFramework } QAction* deleteAction = menu->addAction(QObject::tr("Delete")); - QObject::connect(deleteAction, &QAction::triggered, deleteAction, [this] { ContextMenu_DeleteSelected(); }); + QObject::connect(deleteAction, &QAction::triggered, deleteAction, [] { ContextMenu_DeleteSelected(); }); if (selectedEntities.size() == 0 || (selectedEntities.size() == 1 && s_prefabPublicInterface->IsLevelInstanceContainerEntity(selectedEntities[0]))) { @@ -247,7 +247,7 @@ namespace AzToolsFramework QAction* detachPrefabAction = menu->addAction(QObject::tr("Detach Prefab...")); QObject::connect( detachPrefabAction, &QAction::triggered, detachPrefabAction, - [this, selectedEntity] + [selectedEntity] { ContextMenu_DetachPrefab(selectedEntity); }); @@ -994,7 +994,7 @@ namespace AzToolsFramework msgBox.setStandardButtons(QMessageBox::Cancel); msgBox.setDefaultButton(QMessageBox::Yes); msgBox.setDetailedText(message.c_str()); - const int response = msgBox.exec(); + msgBox.exec(); if (msgBox.clickedButton() == moveButton) { diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/ComponentEditor.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/ComponentEditor.cpp index fbbf55d0ad..85676df243 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/ComponentEditor.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/ComponentEditor.cpp @@ -397,7 +397,7 @@ namespace AzToolsFramework AzQtComponents::CardNotification * notification = CreateNotification(message); const QPushButton * featureButton = notification->addButtonFeature(tr("Continue")); - connect(featureButton, &QPushButton::clicked, this, [this, notification]() + connect(featureButton, &QPushButton::clicked, this, [notification]() { notification->close(); }); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/ComponentEditor.hxx b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/ComponentEditor.hxx index bd44d513fd..b2140868da 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/ComponentEditor.hxx +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/ComponentEditor.hxx @@ -135,7 +135,6 @@ namespace AzToolsFramework QIcon m_warningIcon; ReflectedPropertyEditor* m_propertyEditor = nullptr; - QVBoxLayout* m_mainLayout = nullptr; AZ::SerializeContext* m_serializeContext; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/EntityPropertyEditor.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/EntityPropertyEditor.cpp index 223a573c55..001cd12349 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/EntityPropertyEditor.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/EntityPropertyEditor.cpp @@ -2491,7 +2491,7 @@ namespace AzToolsFramework QAction* revertAction = revertMenu->addAction(QObject::tr("Entity")); revertAction->setToolTip(QObject::tr("This will revert all component properties on this entity to the last saved.")); - QObject::connect(revertAction, &QAction::triggered, [this, relevantEntities] + QObject::connect(revertAction, &QAction::triggered, [relevantEntities] { SliceEditorEntityOwnershipServiceRequestBus::Broadcast( &SliceEditorEntityOwnershipServiceRequests::ResetEntitiesToSliceDefaults, relevantEntities); @@ -4394,7 +4394,6 @@ namespace AzToolsFramework { ResetDrag(event); - Qt::MouseButtons realButtons = QApplication::mouseButtons(); if (QApplication::overrideCursor() && !(event->buttons() & Qt::LeftButton)) { QApplication::restoreOverrideCursor(); @@ -4606,7 +4605,6 @@ namespace AzToolsFramework bool EntityPropertyEditor::GetComponentsAtDropEventPosition(QDropEvent* event, AZ::Entity::ComponentArrayType& targetComponents) { const QPoint globalPos(mapToGlobal(event->pos())); - const QRect globalRect(GetInflatedRectFromPoint(globalPos, kComponentEditorDropTargetPrecision)); //get component editor(s) where drop will occur ComponentEditor* targetComponentEditor = GetReorderDropTarget( diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyAssetCtrl.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyAssetCtrl.cpp index 4d95479e33..ee43eb7e2c 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyAssetCtrl.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyAssetCtrl.cpp @@ -548,7 +548,7 @@ namespace AzToolsFramework // Connect pressed to opening the error dialog // Must capture this for call to QObject::connect - connect(m_errorButton, &QPushButton::pressed, this, [this, errorLog]() { + connect(m_errorButton, &QPushButton::pressed, this, [errorLog]() { // Create the dialog for the log panel, and set the layout QDialog* logDialog = new QDialog(); logDialog->setMinimumSize(1024, 400); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyBoolComboBoxCtrl.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyBoolComboBoxCtrl.cpp index 094204e5a6..4a1e969e41 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyBoolComboBoxCtrl.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyBoolComboBoxCtrl.cpp @@ -93,24 +93,24 @@ namespace AzToolsFramework void BoolPropertyComboBoxHandler::ConsumeAttribute(PropertyBoolComboBoxCtrl* GUI, AZ::u32 attrib, PropertyAttributeReader* attrValue, const char* debugName) { - (void)GUI; - (void)attrib; - (void)attrValue; - (void)debugName; + AZ_UNUSED(GUI); + AZ_UNUSED(attrib); + AZ_UNUSED(attrValue); + AZ_UNUSED(debugName); } void BoolPropertyComboBoxHandler::WriteGUIValuesIntoProperty(size_t index, PropertyBoolComboBoxCtrl* GUI, property_t& instance, InstanceDataNode* node) { - (int)index; - (void)node; + AZ_UNUSED(index); + AZ_UNUSED(node); bool val = GUI->value(); instance = static_cast(val); } bool BoolPropertyComboBoxHandler::ReadValuesIntoGUI(size_t index, PropertyBoolComboBoxCtrl* GUI, const property_t& instance, InstanceDataNode* node) { - (int)index; - (void)node; + AZ_UNUSED(index); + AZ_UNUSED(node); bool val = instance; GUI->setValue(val); return false; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyCRCCtrl.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyCRCCtrl.cpp index 84d7d37585..6a1f1404a1 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyCRCCtrl.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyCRCCtrl.cpp @@ -173,16 +173,16 @@ namespace AzToolsFramework void U32CRCHandler::WriteGUIValuesIntoProperty(size_t index, PropertyCRCCtrl* GUI, AZ::u32& instance, InstanceDataNode* node) { - (int)index; - (void)node; + AZ_UNUSED(index); + AZ_UNUSED(node); AZ::u32 val = GUI->value(); instance = static_cast(val); } bool U32CRCHandler::ReadValuesIntoGUI(size_t index, PropertyCRCCtrl* GUI, const AZ::u32& instance, InstanceDataNode* node) { - (int)index; - (void)node; + AZ_UNUSED(index); + AZ_UNUSED(node); GUI->setValue(instance); return false; } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyColorCtrl.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyColorCtrl.cpp index 2534df50b6..13c5c8bfac 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyColorCtrl.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyColorCtrl.cpp @@ -373,8 +373,8 @@ namespace AzToolsFramework void AZColorPropertyHandler::WriteGUIValuesIntoProperty(size_t index, PropertyColorCtrl* GUI, property_t& instance, InstanceDataNode* node) { - (int)index; - (void)node; + AZ_UNUSED(index); + AZ_UNUSED(node); QColor val = GUI->value(); AZ::Color asAZColor((float)val.redF(), (float)val.greenF(), (float)val.blueF(), (float)val.alphaF()); instance = static_cast(asAZColor); @@ -382,8 +382,8 @@ namespace AzToolsFramework bool AZColorPropertyHandler::ReadValuesIntoGUI(size_t index, PropertyColorCtrl* GUI, const property_t& instance, InstanceDataNode* node) { - (int)index; - (void)node; + AZ_UNUSED(index); + AZ_UNUSED(node); AZ::Vector4 asVector4 = static_cast(instance); QColor asQColor; asQColor.setRedF((qreal)asVector4.GetX()); @@ -410,8 +410,8 @@ namespace AzToolsFramework } void Vector3ColorPropertyHandler::WriteGUIValuesIntoProperty(size_t index, PropertyColorCtrl* GUI, property_t& instance, InstanceDataNode* node) { - (int)index; - (void)node; + AZ_UNUSED(index); + AZ_UNUSED(node); QColor val = GUI->value(); AZ::Vector3 asVector3((float)val.redF(), (float)val.greenF(), (float)val.blueF()); instance = static_cast(asVector3); @@ -419,8 +419,8 @@ namespace AzToolsFramework bool Vector3ColorPropertyHandler::ReadValuesIntoGUI(size_t index, PropertyColorCtrl* GUI, const property_t& instance, InstanceDataNode* node) { - (int)index; - (void)node; + AZ_UNUSED(index); + AZ_UNUSED(node); AZ::Vector3 asVector3 = static_cast(instance); QColor asQColor; asQColor.setRedF((qreal)asVector3.GetX()); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyDoubleSliderCtrl.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyDoubleSliderCtrl.cpp index 0b9120bcce..64ba3b604b 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyDoubleSliderCtrl.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyDoubleSliderCtrl.cpp @@ -305,24 +305,24 @@ namespace AzToolsFramework void doublePropertySliderHandler::WriteGUIValuesIntoProperty(size_t index, PropertyDoubleSliderCtrl* GUI, property_t& instance, InstanceDataNode* node) { - (int)index; - (void)node; + AZ_UNUSED(index); + AZ_UNUSED(node); double val = GUI->value(); instance = static_cast(val); } void floatPropertySliderHandler::WriteGUIValuesIntoProperty(size_t index, PropertyDoubleSliderCtrl* GUI, property_t& instance, InstanceDataNode* node) { - (int)index; - (void)node; + AZ_UNUSED(index); + AZ_UNUSED(node); double val = GUI->value(); instance = static_cast(val); } bool doublePropertySliderHandler::ReadValuesIntoGUI(size_t index, PropertyDoubleSliderCtrl* GUI, const property_t& instance, InstanceDataNode* node) { - (int)index; - (void)node; + AZ_UNUSED(index); + AZ_UNUSED(node); GUI->blockSignals(true); GUI->setValue(instance); GUI->blockSignals(false); @@ -331,8 +331,8 @@ namespace AzToolsFramework bool floatPropertySliderHandler::ReadValuesIntoGUI(size_t index, PropertyDoubleSliderCtrl* GUI, const property_t& instance, InstanceDataNode* node) { - (int)index; - (void)node; + AZ_UNUSED(index); + AZ_UNUSED(node); GUI->blockSignals(true); GUI->setValue(instance); GUI->blockSignals(false); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyDoubleSpinCtrl.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyDoubleSpinCtrl.cpp index 58f1192f7c..6842b50d80 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyDoubleSpinCtrl.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyDoubleSpinCtrl.cpp @@ -363,32 +363,32 @@ namespace AzToolsFramework void doublePropertySpinboxHandler::WriteGUIValuesIntoProperty(size_t index, PropertyDoubleSpinCtrl* GUI, property_t& instance, InstanceDataNode* node) { - (int)index; - (void)node; + AZ_UNUSED(index); + AZ_UNUSED(node); double val = GUI->value() / GUI->multiplier(); instance = static_cast(val); } void floatPropertySpinboxHandler::WriteGUIValuesIntoProperty(size_t index, PropertyDoubleSpinCtrl* GUI, property_t& instance, InstanceDataNode* node) { - (int)index; - (void)node; + AZ_UNUSED(index); + AZ_UNUSED(node); double val = GUI->value() / GUI->multiplier(); instance = static_cast(val); } bool doublePropertySpinboxHandler::ReadValuesIntoGUI(size_t index, PropertyDoubleSpinCtrl* GUI, const property_t& instance, InstanceDataNode* node) { - (int)index; - (void)node; + AZ_UNUSED(index); + AZ_UNUSED(node); GUI->setValue(instance * GUI->multiplier()); return false; } bool floatPropertySpinboxHandler::ReadValuesIntoGUI(size_t index, PropertyDoubleSpinCtrl* GUI, const property_t& instance, InstanceDataNode* node) { - (int)index; - (void)node; + AZ_UNUSED(index); + AZ_UNUSED(node); GUI->setValue(instance * GUI->multiplier()); return false; } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyEntityIdCtrl.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyEntityIdCtrl.cpp index 424a110c49..f98638fd69 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyEntityIdCtrl.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyEntityIdCtrl.cpp @@ -518,8 +518,8 @@ namespace AzToolsFramework void EntityIdPropertyHandler::WriteGUIValuesIntoProperty(size_t index, PropertyEntityIdCtrl* GUI, property_t& instance, InstanceDataNode* node) { - (int)index; - (void)node; + AZ_UNUSED(index); + AZ_UNUSED(node); instance = GUI->GetEntityId(); } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyStringLineEditCtrl.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyStringLineEditCtrl.cpp index ea02e93c96..feb2a9e2ad 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyStringLineEditCtrl.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyStringLineEditCtrl.cpp @@ -142,16 +142,16 @@ namespace AzToolsFramework void StringPropertyLineEditHandler::WriteGUIValuesIntoProperty(size_t index, PropertyStringLineEditCtrl* GUI, property_t& instance, InstanceDataNode* node) { - (int)index; - (void)node; + AZ_UNUSED(index); + AZ_UNUSED(node); AZStd::string val = GUI->value(); instance = static_cast(val); } bool StringPropertyLineEditHandler::ReadValuesIntoGUI(size_t index, PropertyStringLineEditCtrl* GUI, const property_t& instance, InstanceDataNode* node) { - (int)index; - (void)node; + AZ_UNUSED(index); + AZ_UNUSED(node); AZStd::string val = instance; GUI->setValue(val); return false; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/ReflectedPropertyEditor.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/ReflectedPropertyEditor.cpp index 87df1eff1b..c87f0e03ba 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/ReflectedPropertyEditor.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/ReflectedPropertyEditor.cpp @@ -2141,7 +2141,7 @@ namespace AzToolsFramework AZStd::shared_ptr keyToAdd(nullptr); bool createdElement = pContainerNode->CreateContainerElement(CreateContainerElementSelectClassCallback, - [this, pContainerNode, promptForValue, &keyToAdd](void* dataPtr, const AZ::SerializeContext::ClassElement* classElement, bool noDefaultData, AZ::SerializeContext*) -> bool + [pContainerNode, promptForValue, &keyToAdd](void* dataPtr, const AZ::SerializeContext::ClassElement* classElement, bool noDefaultData, AZ::SerializeContext*) -> bool { bool handled = false; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Slice/SlicePushWidget.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Slice/SlicePushWidget.cpp index 04754ac8a4..c276fc5c5a 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Slice/SlicePushWidget.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Slice/SlicePushWidget.cpp @@ -2529,7 +2529,7 @@ namespace AzToolsFramework AZ_Warning("SlicePush", levelSlice, "SlicePushWidget::CalculateReferenceCount could not find root slice, displayed counts will be inaccurate!"); size_t instanceCount = 0; AZ::Data::AssetBus::EnumerateHandlersId(assetId, - [&instanceCount, assetId, levelSlice] (AZ::Data::AssetEvents* handler) -> bool + [&instanceCount, assetId] (AZ::Data::AssetEvents* handler) -> bool { AZ::SliceComponent* component = azrtti_cast(handler); if (component) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Slice/SliceRelationshipWidget.hxx b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Slice/SliceRelationshipWidget.hxx index 64debe12bb..496f8b439f 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Slice/SliceRelationshipWidget.hxx +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/Slice/SliceRelationshipWidget.hxx @@ -111,7 +111,6 @@ namespace AzToolsFramework QTreeWidget* m_sliceDependentsTree; ///< Tree widget for fields (left side) QTreeWidget* m_sliceDependencyTree; ///< Tree widget for slice targets (right side) - QLabel* m_infoLabel; ///< Label above slice tree describing selection QVBoxLayout* m_bottomLayout; ///< Bottom layout containing optional status messages, legend and buttons }; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/UICore/QTreeViewStateSaver.hxx b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/UICore/QTreeViewStateSaver.hxx index 408791558a..f0f6711cda 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/UICore/QTreeViewStateSaver.hxx +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/UICore/QTreeViewStateSaver.hxx @@ -132,7 +132,6 @@ namespace AzToolsFramework QPointer m_dataModel; QPointer m_selectionModel; AZStd::intrusive_ptr m_data; - bool m_defaultToExpandIndexes = false; Q_DISABLE_COPY(QTreeViewStateSaver) }; diff --git a/Code/Framework/AzToolsFramework/Tests/EditorTransformComponentSelectionTests.cpp b/Code/Framework/AzToolsFramework/Tests/EditorTransformComponentSelectionTests.cpp index e95f7aa271..c1c158d0f9 100644 --- a/Code/Framework/AzToolsFramework/Tests/EditorTransformComponentSelectionTests.cpp +++ b/Code/Framework/AzToolsFramework/Tests/EditorTransformComponentSelectionTests.cpp @@ -1579,7 +1579,7 @@ namespace UnitTest /////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Given AZ::Entity* entity = nullptr; - const AZ::EntityId entityId = CreateDefaultEditorEntity("Entity", &entity); + CreateDefaultEditorEntity("Entity", &entity); entity->Deactivate(); const auto* entityInfoComponent = entity->CreateComponent(); diff --git a/Code/Framework/AzToolsFramework/Tests/Prefab/PrefabEntityAliasTests.cpp b/Code/Framework/AzToolsFramework/Tests/Prefab/PrefabEntityAliasTests.cpp index 78be56e6ba..6158394f20 100644 --- a/Code/Framework/AzToolsFramework/Tests/Prefab/PrefabEntityAliasTests.cpp +++ b/Code/Framework/AzToolsFramework/Tests/Prefab/PrefabEntityAliasTests.cpp @@ -160,9 +160,6 @@ namespace UnitTest ASSERT_TRUE(secondRootInstance); - // Find the new instances versions of the new and referenced entities using the aliases we saved - AZ::EntityId secondNewEntityId = secondRootInstance->GetEntityId(newEntityAlias); - InstanceOptionalReference secondNestedInstance = secondRootInstance->FindNestedInstance(nestedAlias); ASSERT_TRUE(secondNestedInstance); AZ::EntityId secondReferencedEntityId = secondNestedInstance->get().GetEntityId(referencedEntityAlias); diff --git a/Code/Framework/AzToolsFramework/Tests/Prefab/PrefabInstantiateTests.cpp b/Code/Framework/AzToolsFramework/Tests/Prefab/PrefabInstantiateTests.cpp index 11efe07e90..09aac8dcf5 100644 --- a/Code/Framework/AzToolsFramework/Tests/Prefab/PrefabInstantiateTests.cpp +++ b/Code/Framework/AzToolsFramework/Tests/Prefab/PrefabInstantiateTests.cpp @@ -33,7 +33,8 @@ namespace UnitTest CompareInstances(*firstInstance, *secondInstance, true, false); } - TEST_F(PrefabInstantiateTest, PrefabInstantiate_TripleNestingTemplate_InstantiateSucceeds) + // TODO: Issue #3398 will re-enable + TEST_F(PrefabInstantiateTest, DISABLED_PrefabInstantiate_TripleNestingTemplate_InstantiateSucceeds) { AZ::Entity* newEntity = CreateEntity("New Entity"); AzToolsFramework::EditorEntityContextRequestBus::Broadcast( diff --git a/Code/Framework/AzToolsFramework/Tests/Prefab/PrefabTestDomUtils.cpp b/Code/Framework/AzToolsFramework/Tests/Prefab/PrefabTestDomUtils.cpp index b8d2ce63f5..334f01fc3a 100644 --- a/Code/Framework/AzToolsFramework/Tests/Prefab/PrefabTestDomUtils.cpp +++ b/Code/Framework/AzToolsFramework/Tests/Prefab/PrefabTestDomUtils.cpp @@ -132,7 +132,7 @@ namespace UnitTest PrefabDomUtils::FindPrefabDomValue(valueADom, PrefabDomUtils::LinkIdName); PrefabDomValueConstReference expectedNestedInstanceDomLinkId = PrefabDomUtils::FindPrefabDomValue(valueBDom, PrefabDomUtils::LinkIdName); - ComparePrefabDomValues(actualNestedInstanceDomLinkId, actualNestedInstanceDomLinkId); + ComparePrefabDomValues(actualNestedInstanceDomLinkId, expectedNestedInstanceDomLinkId); } if (shouldCompareContainerEntities) diff --git a/Code/Framework/AzToolsFramework/Tests/Prefab/PrefabUndoTests.cpp b/Code/Framework/AzToolsFramework/Tests/Prefab/PrefabUndoTests.cpp index 912f642118..5c68b30e8f 100644 --- a/Code/Framework/AzToolsFramework/Tests/Prefab/PrefabUndoTests.cpp +++ b/Code/Framework/AzToolsFramework/Tests/Prefab/PrefabUndoTests.cpp @@ -99,7 +99,6 @@ namespace UnitTest //create single entity AZ::Entity* newEntity = CreateEntity("New Entity", false); ASSERT_TRUE(newEntity); - AZ::EntityId entityId = newEntity->GetId(); //create a first instance where the entity will be added AZStd::unique_ptr testInstance = m_prefabSystemComponent->CreatePrefab({}, {}, "test/path"); diff --git a/Code/Framework/AzToolsFramework/Tests/Slice.cpp b/Code/Framework/AzToolsFramework/Tests/Slice.cpp index dd374826a5..1723fbed8b 100644 --- a/Code/Framework/AzToolsFramework/Tests/Slice.cpp +++ b/Code/Framework/AzToolsFramework/Tests/Slice.cpp @@ -225,7 +225,7 @@ namespace UnitTest tempAssetEntity = aznew AZ::Entity("TestEntity1"); tempAssetEntity->CreateComponent(); - AZ::Data::AssetId sliceAssetId1 = SaveAsSlice(tempAssetEntity); + SaveAsSlice(tempAssetEntity); tempAssetEntity = nullptr; AZ::SliceComponent::EntityList slice1EntitiesA = InstantiateSlice(sliceAssetId0); diff --git a/Code/Framework/AzToolsFramework/Tests/ToolsComponents/EditorLayerComponentTests.cpp b/Code/Framework/AzToolsFramework/Tests/ToolsComponents/EditorLayerComponentTests.cpp index 19cf1ad325..2f1d93c109 100644 --- a/Code/Framework/AzToolsFramework/Tests/ToolsComponents/EditorLayerComponentTests.cpp +++ b/Code/Framework/AzToolsFramework/Tests/ToolsComponents/EditorLayerComponentTests.cpp @@ -401,7 +401,7 @@ namespace AzToolsFramework TEST_F(EditorLayerComponentTest, LayerTests_TwoLayersUniqueNames_LayerNameIsValid) { - EntityAndLayerComponent secondLayer = CreateEntityWithLayer("UniqueLayerName"); + CreateEntityWithLayer("UniqueLayerName"); bool isLayerNameValid = true; AzToolsFramework::Layers::EditorLayerComponentRequestBus::EventResult( isLayerNameValid, @@ -412,7 +412,7 @@ namespace AzToolsFramework TEST_F(EditorLayerComponentTest, LayerTests_TwoLayersConflictingNames_LayerNameIsNotValid) { - EntityAndLayerComponent secondLayer = CreateEntityWithLayer(m_entityName); + CreateEntityWithLayer(m_entityName); bool isLayerNameValid = true; AzToolsFramework::Layers::EditorLayerComponentRequestBus::EventResult( isLayerNameValid, diff --git a/Code/Framework/AzToolsFramework/Tests/TransformComponent.cpp b/Code/Framework/AzToolsFramework/Tests/TransformComponent.cpp index 57ba0f998b..4fbebc8526 100644 --- a/Code/Framework/AzToolsFramework/Tests/TransformComponent.cpp +++ b/Code/Framework/AzToolsFramework/Tests/TransformComponent.cpp @@ -713,7 +713,6 @@ namespace UnitTest TransformBus::Event(m_childId, &TransformBus::Events::SetParentRelative, AZ::EntityId()); - childLocalPos; TransformBus::EventResult(childLocalPos, m_childId, &TransformBus::Events::GetLocalTranslation); EXPECT_TRUE(childLocalPos == expectedChildLocalPos); diff --git a/Code/Framework/AzToolsFramework/Tests/Viewport/ViewportUiManagerTests.cpp b/Code/Framework/AzToolsFramework/Tests/Viewport/ViewportUiManagerTests.cpp index 16a49577d1..91100b18c5 100644 --- a/Code/Framework/AzToolsFramework/Tests/Viewport/ViewportUiManagerTests.cpp +++ b/Code/Framework/AzToolsFramework/Tests/Viewport/ViewportUiManagerTests.cpp @@ -168,7 +168,7 @@ namespace UnitTest m_viewportManagerWrapper.GetMockRenderOverlay()->setVisible(true); auto clusterId = m_viewportManagerWrapper.GetViewportManager()->CreateCluster(AzToolsFramework::ViewportUi::Alignment::TopLeft); - auto buttonId = m_viewportManagerWrapper.GetViewportManager()->CreateClusterButton(clusterId, ""); + m_viewportManagerWrapper.GetViewportManager()->CreateClusterButton(clusterId, ""); m_viewportManagerWrapper.GetViewportManager()->Update(); m_viewportManagerWrapper.GetViewportManager()->SetClusterVisible(clusterId, false); diff --git a/Code/Framework/GridMate/GridMate/Carrier/SecureSocketDriver.cpp b/Code/Framework/GridMate/GridMate/Carrier/SecureSocketDriver.cpp index 031e8561ec..630f81d89f 100644 --- a/Code/Framework/GridMate/GridMate/Carrier/SecureSocketDriver.cpp +++ b/Code/Framework/GridMate/GridMate/Carrier/SecureSocketDriver.cpp @@ -151,16 +151,6 @@ namespace GridMate writeBuffer.Write(PackByte(value)); } - AZ_INLINE static AZ::u32 CalculatePeerCRC32(const SecureSocketDriver::AddrPtr& from) - { - // Calculate CRC32 from remote address - AZ::u32 port = from->GetPort(); - AZ::Crc32 crc; - crc.Add(from->GetIP().c_str()); - crc.Add(&port, sizeof(port)); - return crc; - } - // Structures // struct RecordHeader // 13 bytes = DTLS1_RT_HEADER_LENGTH diff --git a/Code/Framework/GridMate/Tests/Carrier.cpp b/Code/Framework/GridMate/Tests/Carrier.cpp index 8d3ec4eef6..9a18eb9a2c 100644 --- a/Code/Framework/GridMate/Tests/Carrier.cpp +++ b/Code/Framework/GridMate/Tests/Carrier.cpp @@ -1707,7 +1707,7 @@ TEST_F(GridMateCarrierTestFixture, Test_GetSocketErrorString) static constexpr char posixErrorWouldBlockPosixErrStr[] = "Resource temporarily unavailable"; azsnprintf(expectedBuffer.data(), expectedBuffer.size()-1 , "%s", posixErrorWouldBlockPosixErrStr); #else - azsnprintf(expectedBuffer.data(), expectedBuffer.size()-1 , "%d", AZ_EWOULDBLOCK); + azsnprintf(expectedBuffer.data(), expectedBuffer.size()-1 , "%ld", AZ_EWOULDBLOCK); #endif // !AZ_TRAIT_USE_POSIX_STRERROR_R EXPECT_STREQ(expectedBuffer.data(), socketErrorString); EXPECT_STREQ(expectedBuffer.data(), buffer.data()); diff --git a/Code/Framework/GridMate/Tests/ReplicaSmall.cpp b/Code/Framework/GridMate/Tests/ReplicaSmall.cpp index ede2a9a195..3b3942e8f3 100644 --- a/Code/Framework/GridMate/Tests/ReplicaSmall.cpp +++ b/Code/Framework/GridMate/Tests/ReplicaSmall.cpp @@ -388,7 +388,7 @@ public: // If data set was not changed it should remain as non-dirty even after several PrepareData calls for (auto i = 0; i < 10; ++i) { - auto pdr = chunk->Data1.PrepareData(EndianType::BigEndian, 0); + [[maybe_unused]] auto pdr = chunk->Data1.PrepareData(EndianType::BigEndian, 0); AZ_TEST_ASSERT(chunk->Data1.IsDefaultValue() == true); } diff --git a/Code/LauncherUnified/Launcher.cpp b/Code/LauncherUnified/Launcher.cpp index 30db54dab2..07da69cbe9 100644 --- a/Code/LauncherUnified/Launcher.cpp +++ b/Code/LauncherUnified/Launcher.cpp @@ -451,8 +451,6 @@ namespace O3DELauncher // The command line overrides are stored in the following fixed strings // until the ComponentApplication constructor can parse the command line parameters FixedValueString projectNameOptionOverride; - FixedValueString projectPathOptionOverride; - FixedValueString enginePathOptionOverride; // Insert the project_name option to the front const AZStd::string_view launcherProjectName = GetProjectName(); @@ -467,6 +465,8 @@ namespace O3DELauncher // Non-host platforms cannot use the project path that is #defined within the launcher. // In this case the the result of AZ::Utils::GetDefaultAppRoot is used instead #if !AZ_TRAIT_OS_IS_HOST_OS_PLATFORM + FixedValueString projectPathOptionOverride; + FixedValueString enginePathOptionOverride; AZStd::string_view projectPath; // Make sure the defaultAppRootPath variable is in scope long enough until the projectPath string_view is used below AZStd::optional defaultAppRootPath = AZ::Utils::GetDefaultAppRootPath(); diff --git a/Code/Legacy/CryCommon/CMakeLists.txt b/Code/Legacy/CryCommon/CMakeLists.txt index ce89757b5c..1556c6a099 100644 --- a/Code/Legacy/CryCommon/CMakeLists.txt +++ b/Code/Legacy/CryCommon/CMakeLists.txt @@ -6,15 +6,21 @@ # # +ly_get_list_relative_pal_filename(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME}) + ly_add_target( NAME CryCommon STATIC NAMESPACE Legacy FILES_CMAKE crycommon_files.cmake + ${pal_dir}/crycommon_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake # Required for restricted platforms + PLATFORM_INCLUDE_FILES + ${pal_dir}/crycommon_${PAL_PLATFORM_NAME_LOWERCASE}.cmake # Required for restricted platforms INCLUDE_DIRECTORIES PUBLIC . # Lots of code without CryCommon/ .. # Dangerous since exports Legacy's path (client code can do CrySystem/ without depending on that target) + ${pal_dir} # Required for restricted platforms BUILD_DEPENDENCIES PUBLIC AZ::AzCore diff --git a/Code/Legacy/CryCommon/CryLibrary.h b/Code/Legacy/CryCommon/CryLibrary.h index a034a2a04b..995ba0abc5 100644 --- a/Code/Legacy/CryCommon/CryLibrary.h +++ b/Code/Legacy/CryCommon/CryLibrary.h @@ -92,23 +92,21 @@ using DetachEnvironmentFunction = void(*)(); #define HMODULE void* static const char* gEnvName("MODULE_PATH"); -static const char* GetModulePath() +inline const char* GetModulePath() { return getenv(gEnvName); } -static void SetModulePath(const char* pModulePath) +inline void SetModulePath(const char* pModulePath) { setenv(gEnvName, pModulePath ? pModulePath : "", true); } // bInModulePath is only ever set to false in RC, because rc needs to load dlls from a $PATH that // it has modified to include .. -static HMODULE CryLoadLibrary(const char* libName, bool bLazy = false, bool bInModulePath = true) +inline HMODULE CryLoadLibrary(const char* libName, bool bLazy = false, bool bInModulePath = true) { const char* libPath = nullptr; - char pathBuffer[MAX_PATH] = {0}; - libPath = libName; #if !defined(AZ_PLATFORM_ANDROID) @@ -135,6 +133,7 @@ static HMODULE CryLoadLibrary(const char* libName, bool bLazy = false, bool bInM } #endif } + char pathBuffer[MAX_PATH] = {0}; sprintf_s(pathBuffer, "%s/%s", modulePath, libName); libPath = pathBuffer; } @@ -161,7 +160,7 @@ static HMODULE CryLoadLibrary(const char* libName, bool bLazy = false, bool bInM return module; } -static bool CryFreeLibrary(void* lib) +inline bool CryFreeLibrary(void* lib) { if (lib) { diff --git a/Code/Legacy/CryCommon/CryName.h b/Code/Legacy/CryCommon/CryName.h deleted file mode 100644 index b9b3799dd7..0000000000 --- a/Code/Legacy/CryCommon/CryName.h +++ /dev/null @@ -1,564 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - - -#ifndef CRYINCLUDE_CRYCOMMON_CRYNAME_H -#define CRYINCLUDE_CRYCOMMON_CRYNAME_H -#pragma once - -#include -#include -#include -#include -#include - -class CNameTable; - - -struct INameTable -{ - virtual ~INameTable(){} - - // Name entry header, immediately after this header in memory starts actual string data. - struct SNameEntry - { - enum - { - TAG = 0xdeadbeef - }; - - int nTag; // tag to ensure that this is actually a name entry - // Reference count of this string. - int nRefCount; - // Current length of string. - int nLength; - // Size of memory allocated at the end of this class. - int nAllocSize; - // Here in memory starts character buffer of size nAllocSize. - //char data[nAllocSize] - - const char* GetStr() { return (char*)(this + 1); } - void AddRef() { nRefCount++; /*InterlockedIncrement(&_header()->nRefCount);*/}; - int Release() { return --nRefCount; }; - int GetMemoryUsage() { return static_cast(sizeof(SNameEntry) + strlen(GetStr())); } - int GetLength(){return nLength; } - }; - - - // Finds an existing name table entry, or creates a new one if not found. - virtual INameTable::SNameEntry* GetEntry(const char* str) = 0; - // Only finds an existing name table entry, return 0 if not found. - virtual INameTable::SNameEntry* FindEntry(const char* str) = 0; - // Release existing name table entry. - virtual void Release(SNameEntry* pEntry) = 0; - virtual int GetMemoryUsage() = 0; - virtual int GetNumberOfEntries() = 0; - - // Output all names from the table to log. - virtual void LogNames() = 0; - - virtual void GetMemoryUsage(ICrySizer* pSizer) const = 0; -}; - -////////////////////////////////////////////////////////////////////////// -class CNameTable - : public INameTable -{ -private: - typedef AZStd::unordered_map, stl::equality_string_caseless > NameMap; - NameMap m_nameMap; - -public: - CNameTable() - { - // Ensure that SNameEntry is an aligned size - static_assert(sizeof(INameTable::SNameEntry) % sizeof(void*) == 0, "SNameEntry must be an aligned size"); - } - - ~CNameTable() - { - for (NameMap::iterator it = m_nameMap.begin(); it != m_nameMap.end(); ++it) - { - CryModuleFree(it->second); - } - } - - // Only finds an existing name table entry, return 0 if not found. - virtual INameTable::SNameEntry* FindEntry(const char* str) - { - SNameEntry* pEntry = stl::find_in_map(m_nameMap, str, 0); - return pEntry; - } - - // Finds an existing name table entry, or creates a new one if not found. - virtual INameTable::SNameEntry* GetEntry(const char* str) - { - SNameEntry* pEntry = FindEntry(str); - if (!pEntry) - { - // Create a new entry. - size_t nLen = strlen(str); - size_t allocLen = sizeof(SNameEntry) + (nLen + 1) * sizeof(char); - pEntry = (SNameEntry*)CryModuleMalloc(allocLen); - assert(pEntry != NULL); - pEntry->nTag = SNameEntry::TAG; - pEntry->nRefCount = 0; - pEntry->nLength = static_cast(nLen); - pEntry->nAllocSize = static_cast(allocLen); - // Copy string to the end of name entry. - char* pEntryStr = const_cast(pEntry->GetStr()); - memcpy(pEntryStr, str, nLen + 1); - // put in map. - //m_nameMap.insert( NameMap::value_type(pEntry->GetStr(),pEntry) ); - m_nameMap[pEntry->GetStr()] = pEntry; - } - return pEntry; - } - - // Release existing name table entry. - virtual void Release(SNameEntry* pEntry) - { - assert(pEntry); - m_nameMap.erase(pEntry->GetStr()); - CryModuleFree(pEntry); - } - virtual int GetMemoryUsage() - { - int nSize = 0; - NameMap::iterator it; - int n = 0; - for (it = m_nameMap.begin(); it != m_nameMap.end(); it++) - { - nSize += static_cast(strlen(it->first)); - nSize += it->second->GetMemoryUsage(); - n++; - } - nSize += n * 8; - - return nSize; - } - virtual void GetMemoryUsage(ICrySizer* pSizer) const - { - pSizer->AddObject(this, sizeof(*this)); - pSizer->AddContainer(m_nameMap); - } - virtual int GetNumberOfEntries() - { - return static_cast(m_nameMap.size()); - } - - // Log all names inside CryName table. - virtual void LogNames() - { - NameMap::iterator it; - for (it = m_nameMap.begin(); it != m_nameMap.end(); ++it) - { - SNameEntry* pNameEntry = it->second; - CryLog("[%4d] %s", pNameEntry->nLength, pNameEntry->GetStr()); - } - } -}; - -/////////////////////////////////////////////////////////////////////////////// -// Class CCryName. -////////////////////////////////////////////////////////////////////////// -class CCryName -{ -public: - CCryName(); - CCryName(const CCryName& n); - explicit CCryName(const char* s); - CCryName(const char* s, bool bOnlyFind); - ~CCryName(); - - CCryName& operator=(const CCryName& n); - CCryName& operator=(const char* s); - - bool operator==(const CCryName& n) const; - bool operator!=(const CCryName& n) const; - - bool operator==(const char* s) const; - bool operator!=(const char* s) const; - - bool operator<(const CCryName& n) const; - bool operator>(const CCryName& n) const; - - bool empty() const { return !m_str || !m_str[0]; } - void reset() { _release(m_str); m_str = 0; } - void addref() { _addref(m_str); } - - const char* c_str() const - { - return (m_str) ? m_str : ""; - } - int length() const { return _length(); }; - - static bool find(const char* str) { return GetNameTable()->FindEntry(str) != 0; } - void GetMemoryUsage(ICrySizer* pSizer) const - { - //pSizer->AddObject(m_str); - pSizer->AddObject(GetNameTable()); // cause for slowness? - } - static int GetMemoryUsage() - { -#ifdef USE_STATIC_NAME_TABLE - CNameTable* pTable = GetNameTable(); -#else - INameTable* pTable = GetNameTable(); -#endif - return pTable->GetMemoryUsage(); - } - static int GetNumberOfEntries() - { -#ifdef USE_STATIC_NAME_TABLE - CNameTable* pTable = GetNameTable(); -#else - INameTable* pTable = GetNameTable(); -#endif - return pTable->GetNumberOfEntries(); - } - - // Compare functor for sorting CCryNames lexically. - struct CmpLex - { - bool operator () (const CCryName& n1, const CCryName& n2) const - { - return strcmp(n1.c_str(), n2.c_str()) < 0; - } - }; - -private: - typedef INameTable::SNameEntry SNameEntry; - -#ifdef USE_STATIC_NAME_TABLE - static CNameTable* GetNameTable() - { - // Note: can not use a 'static CNameTable sTable' here, because that - // implies a static destruction order depenency - the name table is - // accessed from static destructor calls. - static CNameTable* table = NULL; - - if (table == NULL) - { - table = new CNameTable(); - } - return table; - } -#else - //static INameTable* GetNameTable() { return GetISystem()->GetINameTable(); } - static INameTable* GetNameTable() - { - assert(gEnv && gEnv->pNameTable); - return gEnv->pNameTable; - } -#endif - - SNameEntry* _entry(const char* pBuffer) const - { - CRY_ASSERT(pBuffer); - CRY_ASSERT((((SNameEntry*)pBuffer) - 1)->nTag == SNameEntry::TAG); - return ((SNameEntry*)pBuffer) - 1; - } - void _release(const char* pBuffer) - { - if (pBuffer && _entry(pBuffer)->Release() <= 0 && gEnv) - { - GetNameTable()->Release(_entry(pBuffer)); - } - } - int _length() const { return (m_str) ? _entry(m_str)->nLength : 0; }; - void _addref(const char* pBuffer) - { - if (pBuffer) - { - _entry(pBuffer)->AddRef(); - } - } - - - const char* m_str; -}; - -////////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////////// -// CryName -////////////////////////////////////////////////////////////////////////// -inline CCryName::CCryName() -{ - m_str = 0; -} - -////////////////////////////////////////////////////////////////////////// -inline CCryName::CCryName(const CCryName& n) -{ - _addref(n.m_str); - m_str = n.m_str; -} - -////////////////////////////////////////////////////////////////////////// -inline CCryName::CCryName(const char* s) -{ - m_str = 0; - *this = s; -} - -////////////////////////////////////////////////////////////////////////// -inline CCryName::CCryName(const char* s, [[maybe_unused]] bool bOnlyFind) -{ - assert(s); - m_str = 0; - if (*s) // if not empty - { - SNameEntry* pNameEntry = GetNameTable()->FindEntry(s); - if (pNameEntry) - { - m_str = pNameEntry->GetStr(); - _addref(m_str); - } - } -} - -inline CCryName::~CCryName() -{ - _release(m_str); -} - -////////////////////////////////////////////////////////////////////////// -inline CCryName& CCryName::operator=(const CCryName& n) -{ - if (m_str != n.m_str) - { - _release(m_str); - m_str = n.m_str; - _addref(m_str); - } - return *this; -} - -////////////////////////////////////////////////////////////////////////// -inline CCryName& CCryName::operator=(const char* s) -{ - assert(s); - const char* pBuf = 0; - if (s && *s) // if not empty - { - pBuf = GetNameTable()->GetEntry(s)->GetStr(); - } - if (m_str != pBuf) - { - _release(m_str); - m_str = pBuf; - _addref(m_str); - } - return *this; -} - - -////////////////////////////////////////////////////////////////////////// -inline bool CCryName::operator==(const CCryName& n) const -{ - return m_str == n.m_str; -} - -inline bool CCryName::operator!=(const CCryName& n) const -{ - return !(*this == n); -} - -inline bool CCryName::operator==(const char* str) const -{ - return m_str && _stricmp(m_str, str) == 0; -} - -inline bool CCryName::operator!=(const char* str) const -{ - if (!m_str) - { - return true; - } - return _stricmp(m_str, str) != 0; -} - -inline bool CCryName::operator<(const CCryName& n) const -{ - return m_str < n.m_str; -} - -inline bool CCryName::operator>(const CCryName& n) const -{ - return m_str > n.m_str; -} - -inline bool operator==(const AZStd::string& s, const CCryName& n) -{ - return s == n.c_str(); -} -inline bool operator!=(const AZStd::string& s, const CCryName& n) -{ - return s != n.c_str(); -} - -inline bool operator==(const char* s, const CCryName& n) -{ - return n == s; -} -inline bool operator!=(const char* s, const CCryName& n) -{ - return n != s; -} - - -/////////////////////////////////////////////////////////////////////////////// -// Class CCryNameCRC. -////////////////////////////////////////////////////////////////////////// -class CCryNameCRC -{ -public: - CCryNameCRC(); - CCryNameCRC(const CCryNameCRC& n); - CCryNameCRC(const char* s); - CCryNameCRC(const char* s, bool bOnlyFind); - explicit CCryNameCRC(uint32 n) { m_nID = n; } // We use "explicit" to prevent comparison of strings with ints due to implicit conversion. - ~CCryNameCRC(); - - CCryNameCRC& operator=(const CCryNameCRC& n); - CCryNameCRC& operator=(const char* s); - - bool operator==(const CCryNameCRC& n) const; - bool operator!=(const CCryNameCRC& n) const; - - bool operator==(const char* s) const; - bool operator!=(const char* s) const; - - bool operator<(const CCryNameCRC& n) const; - bool operator>(const CCryNameCRC& n) const; - - bool empty() const { return m_nID == 0; } - void reset() { m_nID = 0; } - uint32 get() const { return m_nID; } - void add(int nAdd) { m_nID += nAdd; } - - AUTO_STRUCT_INFO - - void GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer) const { /*nothing*/} -private: - - uint32 m_nID; -}; - -////////////////////////////////////////////////////////////////////////// -// CCryNameCRC -////////////////////////////////////////////////////////////////////////// -inline CCryNameCRC::CCryNameCRC() -{ - m_nID = 0; -} - -////////////////////////////////////////////////////////////////////////// -inline CCryNameCRC::CCryNameCRC(const CCryNameCRC& n) -{ - m_nID = n.m_nID; -} - -////////////////////////////////////////////////////////////////////////// -inline CCryNameCRC::CCryNameCRC(const char* s) -{ - m_nID = 0; - *this = s; -} - -inline CCryNameCRC::~CCryNameCRC() -{ - m_nID = 0; -} - -////////////////////////////////////////////////////////////////////////// -inline CCryNameCRC& CCryNameCRC::operator=(const CCryNameCRC& n) -{ - m_nID = n.m_nID; - return *this; -} - -////////////////////////////////////////////////////////////////////////// -inline CCryNameCRC& CCryNameCRC::operator=(const char* s) -{ - assert(s); - if (*s) // if not empty - { - m_nID = CCrc32::ComputeLowercase(s); - } - return *this; -} - - -////////////////////////////////////////////////////////////////////////// -inline bool CCryNameCRC::operator==(const CCryNameCRC& n) const -{ - return m_nID == n.m_nID; -} - -inline bool CCryNameCRC::operator!=(const CCryNameCRC& n) const -{ - return !(*this == n); -} - -inline bool CCryNameCRC::operator==(const char* str) const -{ - assert(str); - if (*str) // if not empty - { - uint32 nID = CCrc32::ComputeLowercase(str); - return m_nID == nID; - } - return m_nID == 0; -} - -inline bool CCryNameCRC::operator!=(const char* str) const -{ - if (!m_nID) - { - return true; - } - if (*str) // if not empty - { - uint32 nID = CCrc32::ComputeLowercase(str); - return m_nID != nID; - } - return false; -} - -inline bool CCryNameCRC::operator<(const CCryNameCRC& n) const -{ - return m_nID < n.m_nID; -} - -inline bool CCryNameCRC::operator>(const CCryNameCRC& n) const -{ - return m_nID > n.m_nID; -} - -inline bool operator==(const AZStd::string& s, const CCryNameCRC& n) -{ - return n == s.c_str(); -} -inline bool operator!=(const AZStd::string& s, const CCryNameCRC& n) -{ - return n != s.c_str(); -} - -inline bool operator==(const char* s, const CCryNameCRC& n) -{ - return n == s; -} -inline bool operator!=(const char* s, const CCryNameCRC& n) -{ - return n != s; -} - -#endif // CRYINCLUDE_CRYCOMMON_CRYNAME_H diff --git a/Code/Legacy/CryCommon/CryTypeInfo.h b/Code/Legacy/CryCommon/CryTypeInfo.h index 0bd734492a..dbc3fdb642 100644 --- a/Code/Legacy/CryCommon/CryTypeInfo.h +++ b/Code/Legacy/CryCommon/CryTypeInfo.h @@ -21,10 +21,6 @@ class ICrySizer; -class CCryName; -AZStd::string ToString(CCryName const& val); -bool FromString(CCryName& val, const char* s); - //--------------------------------------------------------------------------- // Specify options for converting data to/from strings struct FToString diff --git a/Code/Legacy/CryCommon/CryVersion.h b/Code/Legacy/CryCommon/CryVersion.h index 0f84e02b6b..e6ed15408d 100644 --- a/Code/Legacy/CryCommon/CryVersion.h +++ b/Code/Legacy/CryCommon/CryVersion.h @@ -43,7 +43,7 @@ struct SFileVersion t[len] = 0; char* p; - char* next = nullptr; + [[maybe_unused]] char* next = nullptr; [[maybe_unused]] size_t strmax = sizeof(t); p = azstrtok(t, &strmax, ".", &next); if (!p) diff --git a/Code/Legacy/CryCommon/Cry_Camera.h b/Code/Legacy/CryCommon/Cry_Camera.h index d80a3d120c..4d33260c44 100644 --- a/Code/Legacy/CryCommon/Cry_Camera.h +++ b/Code/Legacy/CryCommon/Cry_Camera.h @@ -18,7 +18,6 @@ #include #include #include -#include //DOC-IGNORE-END ////////////////////////////////////////////////////////////////////// @@ -557,9 +556,6 @@ public: ILINE Vec3 GetPosition() const { return m_Matrix.GetTranslation(); } ILINE void SetPosition(const Vec3& p) { m_Matrix.SetTranslation(p); UpdateFrustum(); } ILINE void SetPositionNoUpdate(const Vec3& p) { m_Matrix.SetTranslation(p); } - ILINE bool Project(const Vec3& p, Vec3& result, Vec2i topLeft = Vec2i(0, 0), Vec2i widthHeight = Vec2i(0, 0)) const; - ILINE bool Unproject(const Vec3& viewportPos, Vec3& result, Vec2i topLeft = Vec2i(0, 0), Vec2i widthHeight = Vec2i(0, 0)) const; - ILINE void CalcScreenBounds(int* vOut, const AABB* pAABB, int nWidth, int nHeight) const; ILINE Vec3 GetUp() const { return m_Matrix.GetColumn2(); } //------------------------------------------------------------ @@ -894,190 +890,6 @@ ILINE Vec3 CCamera::CreateViewdir(const Ang3& ypr) return Vec3(-sz * cx, cz * cx, sx); //calculate the view-direction } -// Description -//
-//p=world space position
-//result=spreen space pos
-//retval=is visible on screen
-// 
-ILINE bool CCamera::Project(const Vec3& p, Vec3& result, Vec2i topLeft, Vec2i widthHeight) const -{ - Matrix44A mProj, mView; - Vec4 in, transformed, projected; - - mathMatrixPerspectiveFov(&mProj, GetFov(), GetProjRatio(), GetNearPlane(), GetFarPlane()); - - mathMatrixLookAt(&mView, GetPosition(), GetPosition() + GetViewdir(), GetUp()); - - int pViewport[4] = {0, 0, GetViewSurfaceX(), GetViewSurfaceZ()}; - - if (!topLeft.IsZero() || !widthHeight.IsZero()) - { - pViewport[0] = topLeft.x; - pViewport[1] = topLeft.y; - pViewport[2] = widthHeight.x; - pViewport[3] = widthHeight.y; - } - - in.x = p.x; - in.y = p.y; - in.z = p.z; - in.w = 1.0f; - mathVec4Transform((f32*)&transformed, (f32*)&mView, (f32*)&in); - - bool visible = transformed.z < 0.0f; - - mathVec4Transform((f32*)&projected, (f32*)&mProj, (f32*)&transformed); - - if (projected.w == 0.0f) - { - result = Vec3(0.f, 0.f, 0.f); - return false; - } - - projected.x /= projected.w; - projected.y /= projected.w; - projected.z /= projected.w; - - visible = visible && (fabs_tpl(projected.x) <= 1.0f) && (fabs_tpl(projected.y) <= 1.0f); - - //output coords - result.x = pViewport[0] + (1 + projected.x) * pViewport[2] / 2; - result.y = pViewport[1] + (1 - projected.y) * pViewport[3] / 2; //flip coords for y axis - result.z = projected.z; - - return visible; -} - -ILINE bool CCamera::Unproject(const Vec3& viewportPos, Vec3& result, Vec2i topLeft, Vec2i widthHeight) const -{ - Matrix44A mProj, mView; - - mathMatrixPerspectiveFov(&mProj, GetFov(), GetProjRatio(), GetNearPlane(), GetFarPlane()); - mathMatrixLookAt(&mView, GetPosition(), GetPosition() + GetViewdir(), Vec3(0, 0, 1)); - - int viewport[4] = {0, 0, GetViewSurfaceX(), GetViewSurfaceZ()}; - - if (!topLeft.IsZero() || !widthHeight.IsZero()) - { - viewport[0] = topLeft.x; - viewport[1] = topLeft.y; - viewport[2] = widthHeight.x; - viewport[3] = widthHeight.y; - } - - Vec4 vIn; - vIn.x = (viewportPos.x - viewport[0]) * 2 / viewport[2] - 1.0f; - vIn.y = (viewportPos.y - viewport[1]) * 2 / viewport[3] - 1.0f; - vIn.z = viewportPos.z; - vIn.w = 1.0; - - Matrix44A m; - const float* proj = mProj.GetData(); - const float* view = mView.GetData(); - float* mdata = m.GetData(); - for (int i = 0; i < 4; i++) - { - float ai0 = proj[i], ai1 = proj[4 + i], ai2 = proj[8 + i], ai3 = proj[12 + i]; - mdata[i] = ai0 * view[0] + ai1 * view[1] + ai2 * view[2] + ai3 * view[3]; - mdata[4 + i] = ai0 * view[4] + ai1 * view[5] + ai2 * view[6] + ai3 * view[7]; - mdata[8 + i] = ai0 * view[8] + ai1 * view[9] + ai2 * view[10] + ai3 * view[11]; - mdata[12 + i] = ai0 * view[12] + ai1 * view[13] + ai2 * view[14] + ai3 * view[15]; - } - - m.Invert(); - if (!m.IsValid()) - { - return false; - } - - Vec4 vOut = vIn * m; - if (vOut.w == 0.0) - { - return false; - } - - result = Vec3(vOut.x / vOut.w, vOut.y / vOut.w, vOut.z / vOut.w); - - return true; -} - -ILINE void CCamera::CalcScreenBounds(int* vOut, const AABB* pAABB, int nWidth, int nHeight) const -{ - Matrix44A mProj, mView, mVP; - mathMatrixPerspectiveFov(&mProj, GetFov(), GetProjRatio(), GetNearPlane(), GetFarPlane()); - mathMatrixLookAt(&mView, GetPosition(), GetPosition() + GetViewdir(), GetMatrix().GetColumn2()); - mVP = mView * mProj; - - Vec3 verts[8]; - - Vec2i topLeft = Vec2i(0, 0); - Vec2i widthHeight = Vec2i(nWidth, nHeight); - float pViewport[4] = {0.0f, 0.0f, (float)widthHeight.x, (float)widthHeight.y}; - - float x0 = 9999.9f, x1 = -9999.9f, y0 = 9999.9f, y1 = -9999.9f; - float fIntersect = 1.0f; - - Vec3 vDir = GetViewdir(); - Vec3 vPos = GetPosition(); - float d = vPos.Dot(vDir); - - verts[0] = Vec3(pAABB->min.x, pAABB->min.y, pAABB->min.z); - verts[1] = Vec3(pAABB->max.x, pAABB->min.y, pAABB->min.z); - verts[2] = Vec3(pAABB->min.x, pAABB->max.y, pAABB->min.z); - verts[3] = Vec3(pAABB->max.x, pAABB->max.y, pAABB->min.z); - verts[4] = Vec3(pAABB->min.x, pAABB->min.y, pAABB->max.z); - verts[5] = Vec3(pAABB->max.x, pAABB->min.y, pAABB->max.z); - verts[6] = Vec3(pAABB->min.x, pAABB->max.y, pAABB->max.z); - verts[7] = Vec3(pAABB->max.x, pAABB->max.y, pAABB->max.z); - - for (int i = 0; i < 8; i++) - { - float fDist = verts[i].Dot(vDir) - d; - fDist = (float)fsel(fDist, 0.0f, -fDist); - - //Project(verts[i],vertsOut[i], topLeft, widthHeight); - - Vec3 result = Vec3(0.0f, 0.0f, 0.0f); - Vec4 transformed, projected, vIn; - - vIn = Vec4(verts[i].x, verts[i].y, verts[i].z, 1.0f); - - mathVec4Transform((f32*)&projected, (f32*)&mVP, (f32*)&vIn); - - fIntersect = (float)fsel(-projected.w, 0.0f, 1.0f); - - if (!fzero(fIntersect) && !fzero(projected.w)) - { - projected.x /= projected.w; - projected.y /= projected.w; - projected.z /= projected.w; - - //output coords - result.x = pViewport[0] + (1.0f + projected.x) * pViewport[2] / 2.0f; - result.y = pViewport[1] + (1.0f - projected.y) * pViewport[3] / 2.0f; //flip coords for y axis - result.z = projected.z; - } - else - { - vOut[0] = topLeft.x; - vOut[1] = topLeft.y; - vOut[2] = widthHeight.x; - vOut[3] = widthHeight.y; - return; - } - - x0 = min(x0, result.x); - x1 = max(x1, result.x); - y0 = min(y0, result.y); - y1 = max(y1, result.y); - } - - vOut[0] = (int)max(0.0f, min(pViewport[2], x0)); - vOut[1] = (int)max(0.0f, min(pViewport[3], y0)); - vOut[2] = (int)max(0.0f, min(pViewport[2], x1)); - vOut[3] = (int)max(0.0f, min(pViewport[3], y1)); -} //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- diff --git a/Code/Legacy/CryCommon/Cry_Geo.h b/Code/Legacy/CryCommon/Cry_Geo.h index 0df130f1e6..f8a356c66f 100644 --- a/Code/Legacy/CryCommon/Cry_Geo.h +++ b/Code/Legacy/CryCommon/Cry_Geo.h @@ -1067,20 +1067,6 @@ public: } }; -////////////////////////////////////////////////////////////////////////// -#include "Cry_GeoDistance.h" -#include "Cry_GeoOverlap.h" -#include "Cry_GeoIntersect.h" - - - - - - - - - - ///////////////////////////////////////////////////////////////////////// //this is some special engine stuff, should be moved to a better location ///////////////////////////////////////////////////////////////////////// diff --git a/Code/Legacy/CryCommon/Cry_GeoDistance.h b/Code/Legacy/CryCommon/Cry_GeoDistance.h index c85845466c..46a863d68c 100644 --- a/Code/Legacy/CryCommon/Cry_GeoDistance.h +++ b/Code/Legacy/CryCommon/Cry_GeoDistance.h @@ -8,605 +8,16 @@ // Description : Common distance-computations - - -#ifndef CRYINCLUDE_CRYCOMMON_CRY_GEODISTANCE_H -#define CRYINCLUDE_CRYCOMMON_CRY_GEODISTANCE_H #pragma once #include -#include #include #ifdef max #undef max #endif -namespace Intersect -{ - bool Lineseg_Triangle(const Lineseg& lineseg, const Vec3& v0, const Vec3& v1, const Vec3& v2, Vec3& output, float* outT); -} - namespace Distance { - template - ILINE F Point_Point(const Vec3_tpl& p1, const Vec3_tpl& p2) - { - return sqrt_tpl(square(p1.x - p2.x) + square(p1.y - p2.y) + square(p1.z - p2.z)); - } - - template - ILINE F Point_PointSq(const Vec3_tpl& p1, const Vec3_tpl& p2) - { - return square(p1.x - p2.x) + square(p1.y - p2.y) + square(p1.z - p2.z); - } - - template - ILINE F Point_Point2DSq(const Vec3_tpl& p1, const Vec3_tpl& p2) - { - return square(p1.x - p2.x) + square(p1.y - p2.y); - } - - template - ILINE F Point_Point2D(const Vec3_tpl& p1, const Vec3_tpl& p2) - { - return sqrt_tpl(square(p1.x - p2.x) + square(p1.y - p2.y)); - } - - // Description: - // Distance: Origin_Triangle2D. - // Calculate the closest distance of a triangle in XY-plane to the coordinate origin. - // it is assumed that the z-values of the triangle are all in the same plane. - // Return Value: - // The 3d-position of the closest point on the triangle. - // Example: - // Vec3 result = Distance::Origin_Triangle2D( triangle ); - template - ILINE Vec3_tpl Origin_Triangle2D(const Triangle_tpl& t) - { - Vec3_tpl a = t.v0; - Vec3_tpl b = t.v1; - Vec3_tpl c = t.v2; - //check if (0,0,0) is inside or in fron of any triangle sides. - uint32 flag = ((a.x * (a.y - b.y) - a.y * (a.x - b.x)) < 0) | (((b.x * (b.y - c.y) - b.y * (b.x - c.x)) < 0) << 1) | (((c.x * (c.y - a.y) - c.y * (c.x - a.x)) < 0) << 2); - switch (flag) - { - case 0: - return Vec3_tpl(0, 0, a.z); //center is inside of triangle - case 1: - if ((a | (b - a)) > 0.0f) - { - flag = 5; - } - else if ((b | (a - b)) > 0.0f) - { - flag = 3; - } - break; - case 2: - if ((b | (c - b)) > 0.0f) - { - flag = 3; - } - else if ((c | (b - c)) > 0.0f) - { - flag = 6; - } - break; - case 3: - return b; //vertex B is closed - case 4: - if ((c | (a - c)) > 0.0f) - { - flag = 6; - } - else if ((a | (c - a)) > 0.0f) - { - flag = 5; - } - break; - case 5: - return a; //vertex A is closed - case 6: - return c; //vertex C is closed - } - //check again using expanded area - switch (flag) - { - case 1: - { - Vec3_tpl n = (b - a).GetNormalized(); - return n * (-a | n) + a; - } - case 2: - { - Vec3_tpl n = (c - b).GetNormalized(); - return n * (-b | n) + b; - } - case 3: - return b; - case 4: - { - Vec3_tpl n = (a - c).GetNormalized(); - return n * (-c | n) + c; - } - case 5: - return a; - case 6: - return c; - } - return Vec3_tpl(0, 0, 0); - } - - ILINE hwvec3 Origin_Triangle2D(const hwvec3& a, const hwvec3& b, const hwvec3& c) - { - const hwvec3 vZero = HWV3Zero(); - const hwvec3 aNeg = HWV3Negate(a); - const hwvec3 bNeg = HWV3Negate(b); - const hwvec3 cNeg = HWV3Negate(c); - - const hwvec3 vASubB = HWVSub(a, b); - const hwvec3 vBSubA = HWVSub(b, a); - const hwvec3 vASubC = HWVSub(a, c); - const hwvec3 vCSubA = HWVSub(c, a); - const hwvec3 vBSubC = HWVSub(b, c); - const hwvec3 vCSubB = HWVSub(c, b); - - HWV4PermuteControl(vSwapXY, HWV_PERMUTE_0Y, HWV_PERMUTE_0X, HWV_PERMUTE_0Z, HWV_PERMUTE_0W); - - const hwvec3 aPerm = HWV3PermuteWord(a, a, vSwapXY); - const hwvec3 vACombined = HWVMultiply(aPerm, vASubB); - - //Yes, this is the right way around, check the non-vectorized version below :) - const simdf vAY = HWV3SplatXToSIMDF(vACombined); - const simdf vAX = HWV3SplatYToSIMDF(vACombined); - - - const hwvec3 bPerm = HWV3PermuteWord(b, b, vSwapXY); - const hwvec3 vBCombined = HWVMultiply(bPerm, vBSubC); - - const simdf vBY = HWV3SplatXToSIMDF(vBCombined); - const simdf vBX = HWV3SplatYToSIMDF(vBCombined); - - - const hwvec3 cPerm = HWV3PermuteWord(c, c, vSwapXY); - const hwvec3 vCCombined = HWVMultiply(cPerm, vCSubA); - - const simdf vCY = HWV3SplatXToSIMDF(vCCombined); - const simdf vCX = HWV3SplatYToSIMDF(vCCombined); - - - //check if (0,0,0) is inside or in front of any triangle sides. - bool subflag0 = SIMDFLessThanB(vAX, vAY); - bool subflag1 = SIMDFLessThanB(vBX, vBY); - bool subflag2 = SIMDFLessThanB(vCX, vCY); - - uint32 flag = ((uint32)subflag0) | ((uint32)(subflag1 << 1)) | ((uint32)(subflag2 << 2)); - - switch (flag) - { - case 0: - { - HWV4PermuteControl(selectz, HWV_PERMUTE_1X, HWV_PERMUTE_1Y, HWV_PERMUTE_0Z, HWV_PERMUTE_1W); - return HWV3PermuteWord(a, vZero, selectz); //center is inside of triangle - } - case 1: - { - if (SIMDFLessThanB(HWV3AsSIMDF(vZero), HWV3Dot(a, vBSubA))) - { - flag = 5; - } - else if (SIMDFLessThanB(HWV3AsSIMDF(vZero), HWV3Dot(b, vASubB))) - { - flag = 3; - } - break; - } - case 2: - { - if (SIMDFLessThanB(HWV3AsSIMDF(vZero), HWV3Dot(b, vCSubB))) - { - flag = 3; - } - else if (SIMDFLessThanB(HWV3AsSIMDF(vZero), HWV3Dot(c, vBSubC))) - { - flag = 6; - } - break; - } - case 3: - return b; //vertex B is closed - case 4: - { - if (SIMDFLessThanB(HWV3AsSIMDF(vZero), HWV3Dot(c, vASubC))) - { - flag = 6; - } - else if (SIMDFLessThanB(HWV3AsSIMDF(vZero), HWV3Dot(a, vCSubA))) - { - flag = 5; - } - break; - } - case 5: - return a; //vertex A is closed - case 6: - return c; //vertex C is closed - } - - switch (flag) - { - case 1: - { - //hwvec3 n = HWV3Normalize(vBSubA); - simdf nLengthSq = HWV3Dot(vBSubA, vBSubA); - simdf invLengthSq = SIMDFReciprocal(nLengthSq); - return HWVMultiplySIMDFAdd(vBSubA, SIMDFMult(HWV3Dot(aNeg, vBSubA), invLengthSq), a); - } - case 2: - { - simdf nLengthSq = HWV3Dot(vCSubB, vCSubB); - simdf invLengthSq = SIMDFReciprocal(nLengthSq); - return HWVMultiplySIMDFAdd(vCSubB, SIMDFMult(HWV3Dot(bNeg, vCSubB), invLengthSq), b); - } - case 3: - return b; - case 4: - { - simdf nLengthSq = HWV3Dot(vASubC, vASubC); - simdf invLengthSq = SIMDFReciprocal(nLengthSq); - return HWVMultiplySIMDFAdd(vASubC, SIMDFMult(HWV3Dot(cNeg, vASubC), invLengthSq), c); - } - case 5: - return a; - case 6: - return c; - } - - // switch (flag) { - // case 1: { Vec3_tpl n=(b-a).GetNormalized(); return n*(-a|n)+a; } - // case 2: { Vec3_tpl n=(c-b).GetNormalized(); return n*(-b|n)+b; } - // case 3: return b; - // case 4: { Vec3_tpl n=(a-c).GetNormalized(); return n*(-c|n)+c; } - // case 5: return a; - // case 6: return c; - // } - - return vZero; - } - - - // Description: - // Distance: Point_Triangle. - // Calculate the closest distance of a point to a triangle in 3d-space. - // Return value: - // The squared distance. - // Example: - // float result = Distance::Point_Triangle( pos, triangle ); - template - ILINE F Point_TriangleSq(const Vec3_tpl& p, const Triangle_tpl& t) - { - //translate triangle into origin - Vec3_tpl a = t.v0 - p; - Vec3_tpl b = t.v1 - p; - Vec3_tpl c = t.v2 - p; - //transform triangle into XY-plane to simplify the test - Matrix33_tpl r33 = Matrix33_tpl::CreateRotationV0V1(((b - a) % (a - c)).GetNormalized(), Vec3(0, 0, 1)); - Vec3_tpl h = Origin_Triangle2D(Triangle_tpl(r33 * a, r33 * b, r33 * c)); - return (h | h); //return squared distance - } - - inline simdf Point_TriangleByPointsSq(const hwvec3& p, const hwvec3& t0, const hwvec3& t1, const hwvec3& t2) - { - //translate triangle into origin - - HWV3Constant(kUp, 0.0f, 0.0f, 1.0f); - - const hwvec3 a = HWVSub(t0, p); - const hwvec3 b = HWVSub(t1, p); - const hwvec3 c = HWVSub(t2, p); - - const hwvec3 baDiff = HWVSub(b, a); - const hwvec3 acDiff = HWVSub(a, c); - - const hwvec3 cross = HWVCross(baDiff, acDiff); - - const hwvec3 crossNormalized = HWV3Normalize(cross); - - hwmtx33 r33 = HWMtx33CreateRotationV0V1(crossNormalized, kUp); - - hwmtx33 r33opt = HWMtx33GetOptimized(r33); - - //transform triangle into XY-plane to simplify the test - const hwvec3 aRot = HWMtx33RotateVecOpt(r33opt, a); - const hwvec3 bRot = HWMtx33RotateVecOpt(r33opt, b); - const hwvec3 cRot = HWMtx33RotateVecOpt(r33opt, c); - - hwvec3 h = Origin_Triangle2D(aRot, bRot, cRot); - - return HWV3Dot(h, h); - } - - template - ILINE F Point_Triangle(const Vec3_tpl& p, const Triangle_tpl& t) - { - return sqrt_tpl(Point_TriangleSq(p, t)); - } - - // Description: - // Distance: Point_Triangle. - // Calculate the closest distance of a point to a triangle in 3d-space. - // The function returns the squared distance and the 3d-position of the - // closest point on the triangle. - // Example: - // float result = Distance::Point_Triangle( pos, triangle, output ); - template - ILINE F Point_TriangleSq(const Vec3_tpl& p, const Triangle_tpl& t, Vec3_tpl& output) - { - //translate triangle into origin - Vec3_tpl a = t.v0 - p; - Vec3_tpl b = t.v1 - p; - Vec3_tpl c = t.v2 - p; - //transform triangle into XY-plane to simplify the test - Matrix33_tpl r33 = Matrix33_tpl::CreateRotationV0V1(((b - a) % (a - c)).GetNormalized(), Vec3_tpl(0, 0, 1)); - Vec3_tpl h = Origin_Triangle2D(Triangle_tpl(r33 * a, r33 * b, r33 * c)); - output = h * r33 + p; - return (h | h); //return squared distance - } - - template - ILINE F Point_Triangle(const Vec3_tpl& p, const Triangle_tpl& t, Vec3_tpl& output) - { - return sqrt_tpl(Point_TriangleSq(p, t, output)); - } - - // Description: - // Squared distance from point to triangle, optionally returning the triangle position in - // parameteric form. - template - ILINE F Point_TriangleSq(const Vec3_tpl& point, const Triangle_tpl& triangle, F* pT0, F* pT1) - { - Vec3 diff = triangle.v0 - point; - const Vec3 edge0 = triangle.v1 - triangle.v0; - const Vec3 edge1 = triangle.v2 - triangle.v0; - F fA00 = edge0.GetLengthSquared(); - F fA01 = edge0.Dot(edge1); - F fA11 = edge1.GetLengthSquared(); - F fB0 = diff.Dot(edge0); - F fB1 = diff.Dot(edge1); - F fC = diff.GetLengthSquared(); - F fDet = abs(fA00 * fA11 - fA01 * fA01); - F fS = fA01 * fB1 - fA11 * fB0; - F fT = fA01 * fB0 - fA00 * fB1; - F fSqrDist; - - if (fS + fT <= fDet) - { - if (fS < (F)0.0) - { - if (fT < (F)0.0) // region 4 - { - if (fB0 < (F)0.0) - { - fT = (F)0.0; - if (-fB0 >= fA00) - { - fS = (F)1.0; - fSqrDist = fA00 + ((F)2.0) * fB0 + fC; - } - else - { - fS = -fB0 / fA00; - fSqrDist = fB0 * fS + fC; - } - } - else - { - fS = (F)0.0; - if (fB1 >= (F)0.0) - { - fT = (F)0.0; - fSqrDist = fC; - } - else if (-fB1 >= fA11) - { - fT = (F)1.0; - fSqrDist = fA11 + ((F)2.0) * fB1 + fC; - } - else - { - fT = -fB1 / fA11; - fSqrDist = fB1 * fT + fC; - } - } - } - else // region 3 - { - fS = (F)0.0; - if (fB1 >= (F)0.0) - { - fT = (F)0.0; - fSqrDist = fC; - } - else if (-fB1 >= fA11) - { - fT = (F)1.0; - fSqrDist = fA11 + ((F)2.0) * fB1 + fC; - } - else - { - fT = -fB1 / fA11; - fSqrDist = fB1 * fT + fC; - } - } - } - else if (fT < (F)0.0) // region 5 - { - fT = (F)0.0; - if (fB0 >= (F)0.0) - { - fS = (F)0.0; - fSqrDist = fC; - } - else if (-fB0 >= fA00) - { - fS = (F)1.0; - fSqrDist = fA00 + ((F)2.0) * fB0 + fC; - } - else - { - fS = -fB0 / fA00; - fSqrDist = fB0 * fS + fC; - } - } - else // region 0 - { - // minimum at interior point - F fInvDet = ((F)1.0) / fDet; - fS *= fInvDet; - fT *= fInvDet; - fSqrDist = fS * (fA00 * fS + fA01 * fT + ((F)2.0) * fB0) + - fT * (fA01 * fS + fA11 * fT + ((F)2.0) * fB1) + fC; - } - } - else - { - F fTmp0, fTmp1, fNumer, fDenom; - - if (fS < (F)0.0) // region 2 - { - fTmp0 = fA01 + fB0; - fTmp1 = fA11 + fB1; - if (fTmp1 > fTmp0) - { - fNumer = fTmp1 - fTmp0; - fDenom = fA00 - 2.0f * fA01 + fA11; - if (fNumer >= fDenom) - { - fS = (F)1.0; - fT = (F)0.0; - fSqrDist = fA00 + ((F)2.0) * fB0 + fC; - } - else - { - fS = fNumer / fDenom; - fT = (F)1.0 - fS; - fSqrDist = fS * (fA00 * fS + fA01 * fT + 2.0f * fB0) + - fT * (fA01 * fS + fA11 * fT + ((F)2.0) * fB1) + fC; - } - } - else - { - fS = (F)0.0; - if (fTmp1 <= (F)0.0) - { - fT = (F)1.0; - fSqrDist = fA11 + ((F)2.0) * fB1 + fC; - } - else if (fB1 >= (F)0.0) - { - fT = (F)0.0; - fSqrDist = fC; - } - else - { - fT = -fB1 / fA11; - fSqrDist = fB1 * fT + fC; - } - } - } - else if (fT < (F)0.0) // region 6 - { - fTmp0 = fA01 + fB1; - fTmp1 = fA00 + fB0; - if (fTmp1 > fTmp0) - { - fNumer = fTmp1 - fTmp0; - fDenom = fA00 - ((F)2.0) * fA01 + fA11; - if (fNumer >= fDenom) - { - fT = (F)1.0; - fS = (F)0.0; - fSqrDist = fA11 + ((F)2.0) * fB1 + fC; - } - else - { - fT = fNumer / fDenom; - fS = (F)1.0 - fT; - fSqrDist = fS * (fA00 * fS + fA01 * fT + ((F)2.0) * fB0) + - fT * (fA01 * fS + fA11 * fT + ((F)2.0) * fB1) + fC; - } - } - else - { - fT = (F)0.0; - if (fTmp1 <= (F)0.0) - { - fS = (F)1.0; - fSqrDist = fA00 + ((F)2.0) * fB0 + fC; - } - else if (fB0 >= (F)0.0) - { - fS = (F)0.0; - fSqrDist = fC; - } - else - { - fS = -fB0 / fA00; - fSqrDist = fB0 * fS + fC; - } - } - } - else // region 1 - { - fNumer = fA11 + fB1 - fA01 - fB0; - if (fNumer <= (F)0.0) - { - fS = (F)0.0; - fT = (F)1.0; - fSqrDist = fA11 + ((F)2.0) * fB1 + fC; - } - else - { - fDenom = fA00 - 2.0f * fA01 + fA11; - if (fNumer >= fDenom) - { - fS = (F)1.0; - fT = (F)0.0; - fSqrDist = fA00 + ((F)2.0) * fB0 + fC; - } - else - { - fS = fNumer / fDenom; - fT = (F)1.0 - fS; - fSqrDist = fS * (fA00 * fS + fA01 * fT + ((F)2.0) * fB0) + - fT * (fA01 * fS + fA11 * fT + ((F)2.0) * fB1) + fC; - } - } - } - } - - if (pT0) - { - *pT0 = fS; - } - - if (pT1) - { - *pT1 = fT; - } - - return abs(fSqrDist); - } - - // Description: - // Distance from point to triangle, optionally returning the triangle position in - // parameteric form. - template - ILINE F Point_Triangle(const Vec3_tpl& point, const Triangle_tpl& triangle, F* pT0, F* pT1) - { - return sqrt_tpl(Point_TriangleSq(point, triangle, pT0, pT1)); - } - //---------------------------------------------------------------------------------- /// Returns squared distance from a point to a line segment and also the "t value" (from 0 to 1) of the /// closest point on the line segment @@ -648,264 +59,6 @@ namespace Distance { return sqrt_tpl(Point_LinesegSq(p, lineseg, fT)); } - - //---------------------------------------------------------------------------------- - /// Returns squared distance from a point to a line segment, ignoring the z coordinates - //---------------------------------------------------------------------------------- - template - ILINE F Point_Lineseg2DSq(const Vec3_tpl& p, const Lineseg& lineseg) - { - F dspx = p.x - lineseg.start.x, dspy = p.y - lineseg.start.y; - F dsex = lineseg.end.x - lineseg.start.x, dsey = lineseg.end.y - lineseg.start.y; - - F denom = (dsex * dsex + dsey * dsey); - F t; - if (denom > 1e-7) - { - t = (F)(dspx * dsex + dspy * dsey) / denom; - t = clamp_tpl(t, 0.0f, 1.0f); - } - else - { - t = 0; - } - - F dx = dsex * t - dspx; - F dy = dsey * t - dspy; - - return dx * dx + dy * dy; - } - - //---------------------------------------------------------------------------------- - /// Returns squared distance from a point to a line segment and also the "t value" (from 0 to 1) of the - /// closest point on the line segment, ignoring the z coordinates - //---------------------------------------------------------------------------------- - template - ILINE F Point_Lineseg2DSq(Vec3_tpl p, Lineseg lineseg, F& fT) - { - p.z = 0.0f; - lineseg.start.z = 0.0f; - lineseg.end.z = 0.0f; - return Point_LinesegSq(p, lineseg, fT); - } - - /// Returns distance from a point to a line segment, ignoring the z coordinates - template - ILINE F Point_Lineseg2D(const Vec3_tpl& p, const Lineseg& lineseg, F& fT) - { - return sqrt_tpl(Point_Lineseg2DSq(p, lineseg, fT)); - } - - /// Returns the squared distance from a point to a line as defined by two points (for accuracy - /// in some situations), and also the closest position on the line - template - ILINE F Point_LineSq(const Vec3_tpl& vPoint, - const Vec3_tpl& vLineStart, const Vec3_tpl& vLineEnd, Vec3_tpl& linePt) - { - Vec3_tpl dir; - Vec3_tpl pointVector; - - if ((vPoint - vLineStart).GetLengthSquared() > (vPoint - vLineEnd).GetLengthSquared()) - { - dir = vLineStart - vLineEnd; - pointVector = vPoint - vLineEnd; - linePt = vLineEnd; - } - else - { - dir = vLineEnd - vLineStart; - pointVector = vPoint - vLineStart; - linePt = vLineStart; - } - - F dirLen2 = dir.GetLengthSquared(); - if (dirLen2 <= 0.0f) - { - return pointVector.GetLengthSquared(); - } - dir /= sqrt_tpl(dirLen2); - - F t0 = pointVector.Dot(dir); - linePt += t0 * dir; - return (vPoint - linePt).GetLengthSquared(); - } - - /// Returns the distance from a point to a line as defined by two points (for accuracy - /// in some situations) - template - ILINE F Point_Line(const Vec3_tpl& vPoint, - const Vec3_tpl& vLineStart, const Vec3_tpl& vLineEnd, Vec3_tpl& linePt) - { - return sqrt_tpl(Point_LineSq(vPoint, vLineStart, vLineEnd, linePt)); - } - - /// In 2D. The returned linePt will have 0 z value - template - ILINE F Point_Line2DSq(Vec3_tpl vPoint, - Vec3_tpl vLineStart, Vec3_tpl vLineEnd, Vec3_tpl& linePt) - { - vPoint.z = 0.0f; - vLineStart.z = 0.0f; - vLineEnd.z = 0.0f; - return Point_LineSq(vPoint, vLineStart, vLineEnd, linePt); - } - - /// In 2D. The returned linePt will have 0 z value - template - ILINE F Point_Line2D(const Vec3_tpl& vPoint, - const Vec3_tpl& vLineStart, const Vec3_tpl& vLineEnd, Vec3_tpl& linePt) - { - return sqrt_tpl(Point_Line2DSq(vPoint, vLineStart, vLineEnd, linePt)); - } - - - /// Returns squared distance from a point to a polygon _edge_, together with the closest point on - /// the edge of the polygon. Can use the same point in/out - template - inline F Point_Polygon2DSq(const Vec3_tpl p, const VecContainer& polygon, Vec3_tpl& polyPos, Vec3_tpl* pNormal = NULL) - { - typename VecContainer::const_iterator li = polygon.begin(); - typename VecContainer::const_iterator liend = polygon.end(); - polyPos.x = polyPos.y = polyPos.z = 0.f; - float bestDist = std::numeric_limits::max(); - for (; li != liend; ++li) - { - typename VecContainer::const_iterator linext = li; - ++linext; - if (linext == liend) - { - linext = polygon.begin(); - } - const Vec3_tpl& l0 = *li; - const Vec3_tpl& l1 = *linext; - - float f; - float thisDist = Distance::Point_Lineseg2DSq(p, Lineseg(l0, l1), f); - if (thisDist < bestDist) - { - bestDist = thisDist; - polyPos = l0 + f * (l1 - l0); - if (pNormal) - { - Vec3_tpl vPolyseg = l1 - l0; - Vec3_tpl vIntSeg = (polyPos - p); - pNormal->x = vPolyseg.y; - pNormal->y = -vPolyseg.x; - pNormal->z = 0; - pNormal->NormalizeSafe(); - // returns the normal towards the start point of the intersecting segment - if ((vIntSeg.Dot(*pNormal)) > 0) - { - pNormal->x = -pNormal->x; - pNormal->y = -pNormal->y; - } - } - } - } - return bestDist; - } - - //---------------------------------------------------------------------------------- - /// Calculate squared distance between two line segments - //---------------------------------------------------------------------------------- - template - ILINE F Lineseg_Lineseg2DSq(const Lineseg& seg0, const Lineseg& seg1) - { - const F Epsilon = (F)0.0000001; - - Vec3_tpl delta = seg1.start - seg0.start; - - Vec3_tpl dir0 = seg0.end - seg0.start; - Vec3_tpl dir1 = seg1.end - seg1.start; - - F det = dir0.x * dir1.y - dir0.y * dir1.x; - F det0 = delta.x * dir1.y - delta.y * dir1.x; - F det1 = delta.x * dir0.y - delta.y * dir0.x; - - F absDet = fabs_tpl(det); - - if (absDet >= Epsilon) - { - F invDet = (F)1.0 / det; - - F a = det0 * invDet; - F b = det1 * invDet; - - if ((a <= (F)1.0) && (a >= (F)0.0) && (b <= (F)1.0) && (b >= (F)0.0)) - { - return (F)0.0; - } - } - - return min(Distance::Point_Lineseg2DSq(seg0.start, seg1), min(Distance::Point_Lineseg2DSq(seg0.end, seg1), - min(Distance::Point_Lineseg2DSq(seg1.start, seg0), Distance::Point_Lineseg2DSq(seg1.end, seg0)))); - } - - /// Returns squared distance from a lineseg to a polygon, together with the closest point on - /// the edge of the polygon. Can use the same point in/out - template - inline float Lineseg_Polygon2DSq(const Lineseg& line, const VecContainer& polygon) - { - typename VecContainer::const_iterator li = polygon.begin(); - typename VecContainer::const_iterator liend = polygon.end(); - - float bestDistSq = std::numeric_limits::max(); - for (; li != liend; ++li) - { - typename VecContainer::const_iterator linext = li; - ++linext; - if (linext == liend) - { - linext = polygon.begin(); - } - - float thisDistSq = Distance::Lineseg_Lineseg2DSq(line, Lineseg(*li, *linext)); - if (thisDistSq < bestDistSq) - { - bestDistSq = thisDistSq; - } - } - - return bestDistSq; - } - - /// Returns distance from a point to a polygon _edge_, together with the closest point on - /// the edge of the polygon - template - inline F Point_Polygon2D(const Vec3_tpl p, const VecContainer& polygon, Vec3_tpl& polyPos, Vec3_tpl* pNormal = NULL) - { - return sqrt_tpl(Point_Polygon2DSq(p, polygon, polyPos, pNormal)); - } - - - //! \brief Get the distance squared from a point to an OBB. - //! \param point Vec3 indicating the point to test - //! \param obb OBB indicating the Obb to test - //! \return float Closest distance squared from the point to the obb. - template - AZ_INLINE F Point_OBBSq(const Vec3_tpl& point, const OBB& obb) - { - F distanceSquared = 0; - const Vec3 v = point - obb.c; // box center to point - for (int i = 0; i < 3; ++i) - { - F d = v.Dot(obb.m33.GetColumn(i)); - F ex = 0; - F halfLength = obb.h[i]; - if (d < -halfLength) - { - ex = d + halfLength; - } - else if (d > halfLength) - { - ex = d - halfLength; - } - distanceSquared += sqr(ex); - } - - return distanceSquared; - } - //! \brief Get the distance squared from a Point to a Cylinder. //! \param point AZ::Vector3 The point to test distance against the cylinder //! \param cylinderAxisEndA AZ::Vector3 One end of the cylinder axis (centered in the circle) @@ -917,7 +70,7 @@ namespace Distance { const AZ::Vector3& cylinderAxisEndA, const AZ::Vector3& cylinderAxisEndB, float radius - ) + ) { // Use the cylinder axis' center point to determine distance by // splitting into Voronoi regions and using symmetry. @@ -972,723 +125,4 @@ namespace Distance { return distanceSquared; } - //---------------------------------------------------------------------------------- - // Distance: Point_AABB - //---------------------------------------------------------------------------------- - // Calculate the closest distance of a point to a AABB in 3d-space. - // The function returns the squared distance. - // optionally the closest point on the hull is calculated - // - // Example: - // float result = Distance::Point_AABBSq( pos, aabb ); - //---------------------------------------------------------------------------------- - template - ILINE F Point_AABBSq(const Vec3_tpl& vPoint, const AABB& aabb) - { - F fDist2 = 0; - - F min0Diff = (F)aabb.min[0] - (F)vPoint[0]; - fDist2 = (F)fsel(min0Diff, fDist2 + sqr(min0Diff), fDist2); - F max0Diff = (F)vPoint[0] - (F)aabb.max[0]; - fDist2 = (F)fsel(max0Diff, fDist2 + sqr(max0Diff), fDist2); - - F min1Diff = (F)aabb.min[1] - (F)vPoint[1]; - fDist2 = (F)fsel(min1Diff, fDist2 + sqr(min1Diff), fDist2); - F max1Diff = (F)vPoint[1] - (F)aabb.max[1]; - fDist2 = (F)fsel(max1Diff, fDist2 + sqr(max1Diff), fDist2); - - F min2Diff = (F)aabb.min[2] - (F)vPoint[2]; - fDist2 = (F)fsel(min2Diff, fDist2 + sqr(min2Diff), fDist2); - F max2Diff = (F)vPoint[2] - (F)aabb.max[2]; - fDist2 = (F)fsel(max2Diff, fDist2 + sqr(max2Diff), fDist2); - - return fDist2; - } - - template - ILINE F Point_AABBSq(const Vec3_tpl& vPoint, const AABB& aabb, Vec3_tpl& vClosest) - { - F fDist2 = Point_AABBSq(vPoint, aabb); - - vClosest = vPoint; - if (!iszero(fDist2)) - { - // vPoint is outside the AABB - vClosest.x = max(vClosest.x, aabb.min.x); - vClosest.x = min(vClosest.x, aabb.max.x); - vClosest.y = max(vClosest.y, aabb.min.y); - vClosest.y = min(vClosest.y, aabb.max.y); - vClosest.z = max(vClosest.z, aabb.min.z); - vClosest.z = min(vClosest.z, aabb.max.z); - } - else - { - // vPoint is inside the AABB - uint16 nSubBox = 0; - F fHalf = 2; - - F fMiddleX = ((aabb.max.x - aabb.min.x) / fHalf) + aabb.min.x; - F fMiddleY = ((aabb.max.y - aabb.min.y) / fHalf) + aabb.min.y; - F fMiddleZ = ((aabb.max.z - aabb.min.z) / fHalf) + aabb.min.z; - - if (vPoint.x < fMiddleX) - { - nSubBox |= 0x001; // Is Left - } - if (vPoint.y < fMiddleY) - { - nSubBox |= 0x010; // Is Rear - } - if (vPoint.z < fMiddleZ) - { - nSubBox |= 0x100; // Is Low - } - F fDistanceToX = 0; - F fDistanceToY = 0; - F fDistanceToZ = 0; - - F fNewX, fNewY, fNewZ; - - switch (nSubBox & 0xFFF) - { - case 0x000: - // Is Right/Front/Top - fDistanceToX = aabb.max.x - vPoint.x; - fDistanceToY = aabb.max.y - vPoint.y; - fDistanceToZ = aabb.max.z - vPoint.z; - - fNewX = aabb.max.x; - fNewY = aabb.max.y; - fNewZ = aabb.max.z; - - break; - case 0x001: - // Is Left/Front/Top - fDistanceToX = vPoint.x - aabb.min.x; - fDistanceToY = aabb.max.y - vPoint.y; - fDistanceToZ = aabb.max.z - vPoint.z; - - fNewX = aabb.min.x; - fNewY = aabb.max.y; - fNewZ = aabb.max.z; - - break; - case 0x010: - // Is Right/Rear/Top - fDistanceToX = aabb.max.x - vPoint.x; - fDistanceToY = vPoint.y - aabb.min.y; - fDistanceToZ = aabb.max.z - vPoint.z; - - fNewX = aabb.max.x; - fNewY = aabb.min.y; - fNewZ = aabb.max.z; - - break; - case 0x011: - // Is Left/Rear/Top - fDistanceToX = vPoint.x - aabb.min.x; - fDistanceToY = vPoint.y - aabb.min.y; - fDistanceToZ = aabb.max.z - vPoint.z; - - fNewX = aabb.min.x; - fNewY = aabb.min.y; - fNewZ = aabb.max.z; - - break; - case 0x100: - // Is Right/Front/Low - fDistanceToX = aabb.max.x - vPoint.x; - fDistanceToY = aabb.max.y - vPoint.y; - fDistanceToZ = vPoint.z - aabb.min.z; - - fNewX = aabb.max.x; - fNewY = aabb.max.y; - fNewZ = aabb.min.z; - - break; - case 0x101: - // Is Left/Front/Low - fDistanceToX = vPoint.x - aabb.min.x; - fDistanceToY = aabb.max.y - vPoint.y; - fDistanceToZ = vPoint.z - aabb.min.z; - - fNewX = aabb.min.x; - fNewY = aabb.max.y; - fNewZ = aabb.min.z; - - break; - case 0x110: - // Is Right/Rear/Low - fDistanceToX = aabb.max.x - vPoint.x; - fDistanceToY = vPoint.y - aabb.min.y; - fDistanceToZ = vPoint.z - aabb.min.z; - - fNewX = aabb.max.x; - fNewY = aabb.min.y; - fNewZ = aabb.min.z; - - break; - case 0x111: - // Is Left/Rear/Low - fDistanceToX = vPoint.x - aabb.min.x; - fDistanceToY = vPoint.y - aabb.min.y; - fDistanceToZ = vPoint.z - aabb.min.z; - - fNewX = aabb.min.x; - fNewY = aabb.min.y; - fNewZ = aabb.min.z; - - break; - default: - fNewX = fNewY = fNewZ = 0; - break; - } - - if (fDistanceToX < fDistanceToY && fDistanceToX < fDistanceToZ) - { - vClosest.x = fNewX; - } - - if (fDistanceToY < fDistanceToX && fDistanceToY < fDistanceToZ) - { - vClosest.y = fNewY; - } - - if (fDistanceToZ < fDistanceToX && fDistanceToZ < fDistanceToY) - { - vClosest.z = fNewZ; - } - - fDist2 = vClosest.GetSquaredDistance(vPoint); - } - return fDist2; - } - - //---------------------------------------------------------------------------------- - // Distance: Sphere_Triangle - //---------------------------------------------------------------------------------- - // Calculate the closest distance of a sphere to a triangle in 3d-space. - // The function returns the squared distance. If sphere and triangle overlaps, - // the returned distance is 0 - // - // Example: - // float result = Distance::Point_TriangleSq( pos, triangle ); - //---------------------------------------------------------------------------------- - template - ILINE F Sphere_TriangleSq(const ::Sphere& s, const Triangle_tpl& t) - { - F sqdistance = Distance::Point_TriangleSq(s.center, t) - (s.radius * s.radius); - if (sqdistance < 0) - { - sqdistance = 0; - } - return sqdistance; - } - - template - ILINE F Sphere_TriangleSq(const ::Sphere& s, const Triangle_tpl& t, Vec3_tpl& output) - { - F sqdistance = Distance::Point_TriangleSq(s.center, t, output) - (s.radius * s.radius); - if (sqdistance < 0) - { - sqdistance = 0; - } - return sqdistance; - } - - //---------------------------------------------------------------------------------- - /// Calculate squared distance between two line segments, along with the optional - /// parameters of the closest points - //---------------------------------------------------------------------------------- - template - ILINE F Lineseg_LinesegSq(const Lineseg& seg0, const Lineseg seg1, F* t0, F* t1) - { - Vec3 diff = seg0.start - seg1.start; - Vec3 delta0 = seg0.end - seg0.start; - Vec3 delta1 = seg1.end - seg1.start; - F fA00 = delta0.GetLengthSquared(); - F fA01 = -delta0.Dot(delta1); - F fA11 = delta1.GetLengthSquared(); - F fB0 = diff.Dot(delta0); - F fC = diff.GetLengthSquared(); - F fDet = abs(fA00 * fA11 - fA01 * fA01); - F fB1, fS, fT, fSqrDist, fTmp; - - if (fDet > (F) 0.0) - { - // line segments are not parallel - fB1 = -diff.Dot(delta1); - fS = fA01 * fB1 - fA11 * fB0; - fT = fA01 * fB0 - fA00 * fB1; - - if (fS >= (F)0.0) - { - if (fS <= fDet) - { - if (fT >= (F)0.0) - { - if (fT <= fDet) // region 0 (interior) - { - // minimum at two interior points of 3D lines - F fInvDet = ((F)1.0) / fDet; - fS *= fInvDet; - fT *= fInvDet; - fSqrDist = fS * (fA00 * fS + fA01 * fT + ((F)2.0) * fB0) + - fT * (fA01 * fS + fA11 * fT + ((F)2.0) * fB1) + fC; - } - else // region 3 (side) - { - fT = (F)1.0; - fTmp = fA01 + fB0; - if (fTmp >= (F)0.0) - { - fS = (F)0.0; - fSqrDist = fA11 + ((F)2.0) * fB1 + fC; - } - else if (-fTmp >= fA00) - { - fS = (F)1.0; - fSqrDist = fA00 + fA11 + fC + ((F)2.0) * (fB1 + fTmp); - } - else - { - fS = -fTmp / fA00; - fSqrDist = fTmp * fS + fA11 + ((F)2.0) * fB1 + fC; - } - } - } - else // region 7 (side) - { - fT = (F)0.0; - if (fB0 >= (F)0.0) - { - fS = (F)0.0; - fSqrDist = fC; - } - else if (-fB0 >= fA00) - { - fS = (F)1.0; - fSqrDist = fA00 + ((F)2.0) * fB0 + fC; - } - else - { - fS = -fB0 / fA00; - fSqrDist = fB0 * fS + fC; - } - } - } - else - { - if (fT >= (F)0.0) - { - if (fT <= fDet) // region 1 (side) - { - fS = (F)1.0; - fTmp = fA01 + fB1; - if (fTmp >= (F)0.0) - { - fT = (F)0.0; - fSqrDist = fA00 + ((F)2.0) * fB0 + fC; - } - else if (-fTmp >= fA11) - { - fT = (F)1.0; - fSqrDist = fA00 + fA11 + fC + ((F)2.0) * (fB0 + fTmp); - } - else - { - fT = -fTmp / fA11; - fSqrDist = fTmp * fT + fA00 + ((F)2.0) * fB0 + fC; - } - } - else // region 2 (corner) - { - fTmp = fA01 + fB0; - if (-fTmp <= fA00) - { - fT = (F)1.0; - if (fTmp >= (F)0.0) - { - fS = (F)0.0; - fSqrDist = fA11 + ((F)2.0) * fB1 + fC; - } - else - { - fS = -fTmp / fA00; - fSqrDist = fTmp * fS + fA11 + ((F)2.0) * fB1 + fC; - } - } - else - { - fS = (F)1.0; - fTmp = fA01 + fB1; - if (fTmp >= (F)0.0) - { - fT = (F)0.0; - fSqrDist = fA00 + ((F)2.0) * fB0 + fC; - } - else if (-fTmp >= fA11) - { - fT = (F)1.0; - fSqrDist = fA00 + fA11 + fC + - ((F)2.0) * (fB0 + fTmp); - } - else - { - fT = -fTmp / fA11; - fSqrDist = fTmp * fT + fA00 + ((F)2.0) * fB0 + fC; - } - } - } - } - else // region 8 (corner) - { - if (-fB0 < fA00) - { - fT = (F)0.0; - if (fB0 >= (F)0.0) - { - fS = (F)0.0; - fSqrDist = fC; - } - else - { - fS = -fB0 / fA00; - fSqrDist = fB0 * fS + fC; - } - } - else - { - fS = (F)1.0; - fTmp = fA01 + fB1; - if (fTmp >= (F)0.0) - { - fT = (F)0.0; - fSqrDist = fA00 + ((F)2.0) * fB0 + fC; - } - else if (-fTmp >= fA11) - { - fT = (F)1.0; - fSqrDist = fA00 + fA11 + fC + ((F)2.0) * (fB0 + fTmp); - } - else - { - fT = -fTmp / fA11; - fSqrDist = fTmp * fT + fA00 + ((F)2.0) * fB0 + fC; - } - } - } - } - } - else - { - if (fT >= (F)0.0) - { - if (fT <= fDet) // region 5 (side) - { - fS = (F)0.0; - if (fB1 >= (F)0.0) - { - fT = (F)0.0; - fSqrDist = fC; - } - else if (-fB1 >= fA11) - { - fT = (F)1.0; - fSqrDist = fA11 + ((F)2.0) * fB1 + fC; - } - else - { - fT = -fB1 / fA11; - fSqrDist = fB1 * fT + fC; - } - } - else // region 4 (corner) - { - fTmp = fA01 + fB0; - if (fTmp < (F)0.0) - { - fT = (F)1.0; - if (-fTmp >= fA00) - { - fS = (F)1.0; - fSqrDist = fA00 + fA11 + fC + ((F)2.0) * (fB1 + fTmp); - } - else - { - fS = -fTmp / fA00; - fSqrDist = fTmp * fS + fA11 + ((F)2.0) * fB1 + fC; - } - } - else - { - fS = (F)0.0; - if (fB1 >= (F)0.0) - { - fT = (F)0.0; - fSqrDist = fC; - } - else if (-fB1 >= fA11) - { - fT = (F)1.0; - fSqrDist = fA11 + ((F)2.0) * fB1 + fC; - } - else - { - fT = -fB1 / fA11; - fSqrDist = fB1 * fT + fC; - } - } - } - } - else // region 6 (corner) - { - if (fB0 < (F)0.0) - { - fT = (F)0.0; - if (-fB0 >= fA00) - { - fS = (F)1.0; - fSqrDist = fA00 + ((F)2.0) * fB0 + fC; - } - else - { - fS = -fB0 / fA00; - fSqrDist = fB0 * fS + fC; - } - } - else - { - fS = (F)0.0; - if (fB1 >= (F)0.0) - { - fT = (F)0.0; - fSqrDist = fC; - } - else if (-fB1 >= fA11) - { - fT = (F)1.0; - fSqrDist = fA11 + ((F)2.0) * fB1 + fC; - } - else - { - fT = -fB1 / fA11; - fSqrDist = fB1 * fT + fC; - } - } - } - } - } - else - { - // line segments are parallel - if (fA01 > (F)0.0) - { - // direction vectors form an obtuse angle - if (fB0 >= (F)0.0) - { - fS = (F)0.0; - fT = (F)0.0; - fSqrDist = fC; - } - else if (-fB0 <= fA00) - { - fS = -fB0 / fA00; - fT = (F)0.0; - fSqrDist = fB0 * fS + fC; - } - else - { - fB1 = -diff.Dot(delta1); - fS = (F)1.0; - fTmp = fA00 + fB0; - if (-fTmp >= fA01) - { - fT = (F)1.0; - fSqrDist = fA00 + fA11 + fC + ((F)2.0) * (fA01 + fB0 + fB1); - } - else - { - fT = -fTmp / fA01; - fSqrDist = fA00 + ((F)2.0) * fB0 + fC + fT * (fA11 * fT + - ((F)2.0) * (fA01 + fB1)); - } - } - } - else - { - // direction vectors form an acute angle - if (-fB0 >= fA00) - { - fS = (F)1.0; - fT = (F)0.0; - fSqrDist = fA00 + ((F)2.0) * fB0 + fC; - } - else if (fB0 <= (F)0.0) - { - fS = -fB0 / fA00; - fT = (F)0.0; - fSqrDist = fB0 * fS + fC; - } - else - { - fB1 = -diff.Dot(delta1); - fS = (F)0.0; - if (fB0 >= -fA01) - { - fT = (F)1.0; - fSqrDist = fA11 + ((F)2.0) * fB1 + fC; - } - else - { - fT = -fB0 / fA01; - fSqrDist = fC + fT * (((F)2.0) * fB1 + fA11 * fT); - } - } - } - } - - if (t0) - { - *t0 = fS; - } - - if (t1) - { - *t1 = fT; - } - - return abs(fSqrDist); - } - - /// Calculate distance between two line segments, along with the optional - /// parameters of the closest points - template - ILINE F Lineseg_Lineseg(const Lineseg& seg0, const Lineseg seg1, F* s, F* t) - { - return sqrt_tpl(Lineseg_LinesegSq(seg0, seg1, s, t)); - } - - //---------------------------------------------------------------------------------- - /// Squared distance from line segment to triangle. Optionally returns the parameters - /// describing the closest points - //---------------------------------------------------------------------------------- - template - ILINE F Lineseg_TriangleSq(const Lineseg_tpl& seg, const Triangle_tpl& triangle, - F* segT, F* triT0, F* triT1) - { - Vec3_tpl intersection; - if (Intersect::Lineseg_Triangle(seg, triangle.v0, triangle.v1, triangle.v2, intersection, segT)) - { - if (triT0 || triT1) - { - const Vec3_tpl v0v1 = triangle.v1 - triangle.v0; - Lineseg_tpl projPtOnV0V2(intersection, intersection - v0v1); - Lineseg_tpl v0v2(triangle.v0, triangle.v2); - Lineseg_LinesegSq(projPtOnV0V2, v0v2, triT0, triT1); - } - return 0.0f; - } - - // compare segment to all three edges of the triangle - F s, t, u; - F distEdgeSq = Distance::Lineseg_LinesegSq(seg, Lineseg(triangle.v0, triangle.v1), &s, &t); - F distSq = distEdgeSq; - if (segT) - { - *segT = s; - } - if (triT0) - { - *triT0 = t; - } - if (triT1) - { - *triT1 = 0.0f; - } - - distEdgeSq = Distance::Lineseg_LinesegSq(seg, Lineseg(triangle.v0, triangle.v2), &s, &t); - if (distEdgeSq < distSq) - { - distSq = distEdgeSq; - if (segT) - { - *segT = s; - } - if (triT0) - { - *triT0 = 0.0f; - } - if (triT1) - { - *triT1 = t; - } - } - distEdgeSq = Distance::Lineseg_LinesegSq(seg, Lineseg(triangle.v1, triangle.v2), &s, &t); - if (distEdgeSq < distSq) - { - distSq = distEdgeSq; - if (segT) - { - *segT = s; - } - if (triT0) - { - *triT0 = 1.0f - t; - } - if (triT1) - { - *triT1 = t; - } - } - - // compare segment end points to triangle interior - F startTriSq = Distance::Point_TriangleSq(seg.start, triangle, &t, &u); - if (startTriSq < distSq) - { - distSq = startTriSq; - if (segT) - { - *segT = 0.0f; - } - if (triT0) - { - *triT0 = t; - } - if (triT1) - { - *triT1 = u; - } - } - F endTriSq = Distance::Point_TriangleSq(seg.end, triangle, &t, &u); - if (endTriSq < distSq) - { - distSq = endTriSq; - if (segT) - { - *segT = 1.0f; - } - if (triT0) - { - *triT0 = t; - } - if (triT1) - { - *triT1 = u; - } - } - return distSq; - } - - /// Distance from line segment to triangle. Optionally returns the parameters - /// describing the closest points - template - ILINE F Lineseg_Triangle(const Lineseg_tpl& seg, const Triangle_tpl& triangle, - F* segT, F* triT0, F* triT1) - { - return sqrt_tpl(Lineseg_TriangleSq(seg, triangle, segT, triT0, triT1)); - } } //namespace Distance - - -#endif // CRYINCLUDE_CRYCOMMON_CRY_GEODISTANCE_H diff --git a/Code/Legacy/CryCommon/Cry_GeoIntersect.h b/Code/Legacy/CryCommon/Cry_GeoIntersect.h index 7e7c42b216..e9e77bd016 100644 --- a/Code/Legacy/CryCommon/Cry_GeoIntersect.h +++ b/Code/Legacy/CryCommon/Cry_GeoIntersect.h @@ -8,19 +8,14 @@ // Description : Common intersection-tests - - -#ifndef CRYINCLUDE_CRYCOMMON_CRY_GEOINTERSECT_H -#define CRYINCLUDE_CRYCOMMON_CRY_GEOINTERSECT_H #pragma once - #include namespace Intersect { inline bool Ray_Plane(const Ray& ray, const Plane_tpl& plane, Vec3& output, bool bSingleSidePlane = true) { - float cosine = plane.n | ray.direction; + float cosine = plane.n | ray.direction; //REJECTION 1: if "line-direction" is perpendicular to "plane-normal", an intersection is not possible! That means ray is parallel // to the plane @@ -33,9 +28,9 @@ namespace Intersect { return false; } - float numer = plane.DistFromPlane(ray.origin); - float fLength = -numer / cosine; - output = ray.origin + (ray.direction * fLength); + float numer = plane.DistFromPlane(ray.origin); + float fLength = -numer / cosine; + output = ray.origin + (ray.direction * fLength); //skip, if cutting-point is "behind" ray.origin if (fLength < 0.0f) { @@ -45,232 +40,6 @@ namespace Intersect { return true; //intersection occurred } - inline bool Line_Plane(const Line& line, const Plane_tpl& plane, Vec3& output, bool bSingleSidePlane = true) - { - float cosine = plane.n | line.direction; - - //REJECTION 1: if "line-direction" is perpendicular to "plane-normal", an intersection is not possible! That means ray is parallel - // to the plane - //REJECTION 2: if bSingleSidePlane == true we deal with single-sided planes. That means - // if "line-direction" is pointing in the same direction as "the plane-normal", - // an intersection is not possible! - if ((cosine == 0.0f) || // normal is orthogonal to vector, cant intersect - (bSingleSidePlane && (cosine > 0.0f))) // we are trying to find an intersection in the same direction as the plane normal - { - return false; - } - - //an intersection is possible: calculate the exact point! - float perpdist = plane | line.pointonline; - float pd_c = -perpdist / cosine; - output = line.pointonline + (line.direction * pd_c); - - return true; //intersection occurred - } - - // Algorithm description: - // http://softsurfer.com/Archive/algorithm_0104/algorithm_0104B.htm#Line-Plane%20Intersection - template - inline bool Segment_Plane(const Lineseg_tpl& segment, const Plane_tpl& plane, Vec3_tpl& vOutput, bool bSingleSidePlane = true) - { - Vec3_tpl vSegment = segment.end - segment.start; - T planeNormalDotSegment = plane.n | vSegment; - - //REJECTION 1: if "line-direction" is perpendicular to "plane-normal", an intersection is not possible! That means ray is parallel - // to the plane - //REJECTION 2: if bSingleSidePlane == true we deal with single-sided planes. That means - // if "line-direction" is pointing in the same direction as "the plane-normal", - // an intersection is not possible! - if ((planeNormalDotSegment == T(0)) || // normal is orthogonal to vector, cant intersect - (bSingleSidePlane && (planeNormalDotSegment > T(0)))) // we are trying to find an intersection in the same direction as the plane normal - { - return false; - } - - // n Dot (segment.start - closest_point_in_plane) = 1 * DistFromPlane(segment.start) * cos(0) = DistFromPlane(segment.start) - T distanceToStart = plane.DistFromPlane(segment.start); - T scale = -distanceToStart / planeNormalDotSegment; - vOutput = segment.start + (vSegment * scale); - - // skip, if segment start and ends in one side of the plane - if ((scale < T(0)) || (scale > T(1))) - { - return false; - } - - return true; //intersection occurred - } - - /// Intersection between two line segments in 2D (ignoring z coordinate). The two parametric - /// values are set to between 0 and 1 if intersection occurs. If intersection does not occur - /// their values will indicate the parametric values for intersection of the lines extended - /// beyond the segment lengths. Parallel lines will result in a negative result, but the parametric - /// values will both be equal to 0.5 - template - inline bool Lineseg_Lineseg2D(const Lineseg_tpl& lineA, const Lineseg_tpl& lineB, F& outA, F& outB) - { - const F Epsilon = (F)0.0000001; - - Vec3_tpl delta = lineB.start - lineA.start; - - Vec3_tpl dirA = lineA.end - lineA.start; - Vec3_tpl dirB = lineB.end - lineB.start; - - F det = dirA.x * dirB.y - dirA.y * dirB.x; - F detA = delta.x * dirB.y - delta.y * dirB.x; - F detB = delta.x * dirA.y - delta.y * dirA.x; - - F absDet = fabs_tpl(det); - - if (absDet >= Epsilon) - { - F invDet = (F)1.0 / det; - - F a = detA * invDet; - F b = detB * invDet; - outA = a; - outB = b; - - if ((a > (F)1.0) || (a < (F)0.0) || (b > (F)1.0) || (b < (F)0.0)) - { - return false; - } - } - else - { - outA = outB = (F)0.5; - - return false; - } - - return true; - } - - /// Calculates the intersection between a line segment and a polygon, in 2D (i.e. - /// ignoring z coordinate). The VecContainer should be a container of Vec3 such - /// that we can traverse it using iterators. intersectionPoint is set to the intersection - /// point or the end of the segment, if no intersection. - template - inline bool Lineseg_Polygon2D(const Lineseg& lineseg, VecIterator polygonBegin, VecIterator polygonEnd, Vec3& intersectionPoint, Vec3* pNormal = NULL, bool bForceNormalOutwards = false) - { - intersectionPoint = lineseg.end; - bool gotIntersection = false; - - float tmin = 1.0f; - - VecIterator iend = polygonEnd; - VecIterator li, linext; - Lineseg intersectSegment; - for (li = polygonBegin; li != iend; ++li) - { - linext = li; - ++linext; - if (linext == iend) - { - linext = polygonBegin; - } - Lineseg segmentPoly(*li, *linext); - float s, t; - if (Intersect::Lineseg_Lineseg2D(lineseg, segmentPoly, s, t)) - { - if (s < 0.00001f || s > 0.99999f || t < 0.00001f || t > 0.99999f) - { - continue; - } - if (s < tmin) - { - tmin = s; - gotIntersection = true; - intersectSegment = segmentPoly; - } - } - } - - intersectionPoint = lineseg.start + tmin * (lineseg.end - lineseg.start); - - if (pNormal && gotIntersection) - { - Vec3 vPolyseg = intersectSegment.end - intersectSegment.start; - Vec3 vIntSeg = (lineseg.end - lineseg.start); - pNormal->x = vPolyseg.y; - pNormal->y = -vPolyseg.x; - pNormal->z = 0; - pNormal->NormalizeSafe(); - // returns the normal towards the start point of the intersecting segment (if it's not forced to be outwards) - if (!bForceNormalOutwards && vIntSeg.Dot(*pNormal) > 0) - { - pNormal->x = -pNormal->x; - pNormal->y = -pNormal->y; - } - } - return gotIntersection; - } - - template - inline bool Lineseg_Polygon2D(const Lineseg& lineseg, const VecContainer& polygon, Vec3& intersectionPoint, Vec3* pNormal = NULL, bool bForceNormalOutwards = false) - { - return Lineseg_Polygon2D(lineseg, polygon.begin(), polygon.end(), intersectionPoint, pNormal, bForceNormalOutwards); - } - - /* - * calculates intersection between a line and a triangle. - * IMPORTANT: this is a single-sided intersection test. That means its not enough - * that the triangle and line overlap, its also important that the triangle - * is "visible" when you are looking along the line-direction. - * - * If you need a double-sided test, you'll have to call this function twice with - * reversed order of triangle vertices. - * - * return values - * if there is an intertection the functions return "true" and stores the - * 3d-intersection point in "output". if the function returns "false" the value in - * "output" is undefined - * - */ - inline bool Line_Triangle(const Line& line, const Vec3& v0, const Vec3& v1, const Vec3& v2, Vec3& output) - { - const float Epsilon = 0.0000001f; - - Vec3 edgeA = v1 - v0; - Vec3 edgeB = v2 - v0; - - Vec3 dir = line.direction; - - Vec3 p = dir.Cross(edgeA); - Vec3 t = line.pointonline - v0; - Vec3 q = t.Cross(edgeB); - - float dot = edgeB.Dot(p); - - float u = t.Dot(p); - float v = dir.Dot(q); - - float DotGreaterThanEpsilon = dot - Epsilon; - float VGreaterEqualThanZero = v; - float UGreaterEqualThanZero = u; - float UVLessThanDot = dot - (u + v); - float ULessThanDot = dot - u; - - float UVGreaterEqualThanZero = (float)fsel(VGreaterEqualThanZero, UGreaterEqualThanZero, VGreaterEqualThanZero); - float UUVLessThanDot = (float)fsel(UVLessThanDot, ULessThanDot, UVLessThanDot); - float BothGood = (float)fsel(UVGreaterEqualThanZero, UUVLessThanDot, UVGreaterEqualThanZero); - float AllGood = (float)fsel(DotGreaterThanEpsilon, BothGood, DotGreaterThanEpsilon); - - if (AllGood < 0.0f) - { - return false; - } - - float dt = edgeA.Dot(q) / dot; - - Vec3 result = (dir * dt) + line.pointonline; - output = result; - - return true; - } - - - /* * calculates intersection between a ray and a triangle. * IMPORTANT: this is a single-sided intersection test. That means its not sufficient @@ -329,80 +98,6 @@ namespace Intersect { return AfterStart >= 0.0f; } - - - /* - * Description: - * Calculates intersection between a line-segment and a triangle. - * Remarks: - * IMPORTANT: this is a single-sided intersection test. That means its not sufficient - * that the triangle and line-segment overlap, its also important that the triangle - * is "visible" when you are looking along the linesegment from "start" to "end". - * Notes: - * If you need a double-sided test, you'll have to call this function twice with - * reversed order of triangle vertices. - * - * Return value: - * If there is an intertection the the functions return "true" and stores the - * 3d-intersection point in "output". if the function returns "false" the value in - * "output" is undefined. If pT is non-zero then if there is an intersection the "t-value" - * (from 0-1) is also returned (unmodified if there is no intersection). - */ - inline bool Lineseg_Triangle(const Lineseg& lineseg, const Vec3& v0, const Vec3& v1, const Vec3& v2, Vec3& output, - float* outT = 0) - { - const float Epsilon = 0.0000001f; - - Vec3 edgeA = v1 - v0; - Vec3 edgeB = v2 - v0; - - Vec3 dir = lineseg.end - lineseg.start; - - Vec3 p = dir.Cross(edgeA); - Vec3 t = lineseg.start - v0; - Vec3 q = t.Cross(edgeB); - - float dot = edgeB.Dot(p); - - float u = t.Dot(p); - float v = dir.Dot(q); - - float DotGreaterThanEpsilon = dot - Epsilon; - float VGreaterEqualThanZero = v; - float UGreaterEqualThanZero = u; - float UVLessThanDot = dot - (u + v); - float ULessThanDot = dot - u; - - float UVGreaterEqualThanZero = (float)fsel(VGreaterEqualThanZero, UGreaterEqualThanZero, VGreaterEqualThanZero); - float UUVLessThanDot = (float)fsel(UVLessThanDot, ULessThanDot, UVLessThanDot); - float BothGood = (float)fsel(UVGreaterEqualThanZero, UUVLessThanDot, UVGreaterEqualThanZero); - float AllGood = (float)fsel(DotGreaterThanEpsilon, BothGood, DotGreaterThanEpsilon); - - if (AllGood < 0.0f) - { - return false; - } - - float dt = edgeA.Dot(q) / dot; - - Vec3 result = (dir * dt) + lineseg.start; - output = result; - - float AfterStart = (result - lineseg.start).Dot(dir); - float BeforeEnd = -(result - lineseg.end).Dot(dir); - float Within = (float)fsel(AfterStart, BeforeEnd, AfterStart); - - if (outT) - { - *outT = dt; - } - - return Within >= 0.0f; - } - - - - //---------------------------------------------------------------------------------- // Ray_AABB // @@ -466,359 +161,6 @@ namespace Intersect { return 0x00;//no intersection } - - - //---------------------------------------------------------------------------------- - // Ray_OBB - // - // just ONE intersection point is calculated, and thats the entry point - - // Lineseg and OBB are assumed to be in the same space - // - //--- 0x00 = no intersection (output undefined) ---- - //--- 0x01 = intersection (intersection point in output) -------------- - //--- 0x02 = start of Lineseg is inside the OBB (ls.start is output) - //---------------------------------------------------------------------------------- - inline uint8 Ray_OBB(const Ray& ray, const Vec3& pos, const OBB& obb, Vec3& output1) - { - AABB aabb(obb.c - obb.h, obb.c + obb.h); - Ray aray((ray.origin - pos) * obb.m33, ray.direction * obb.m33); - - uint8 cflags; - float cosine; - Vec3 cut; - //-------------------------------------------------------------------------------------- - //---- check if "aray.origin" is inside of AABB --------------------------- - //-------------------------------------------------------------------------------------- - cflags = (aray.origin.x > aabb.min.x) << 0; - cflags |= (aray.origin.x < aabb.max.x) << 1; - cflags |= (aray.origin.y > aabb.min.y) << 2; - cflags |= (aray.origin.y < aabb.max.y) << 3; - cflags |= (aray.origin.z > aabb.min.z) << 4; - cflags |= (aray.origin.z < aabb.max.z) << 5; - if (cflags == 0x3f) - { - output1 = aray.origin; - return 0x02; - } - - //-------------------------------------------------------------------------------------- - //---- check intersection with planes ------------------------------ - //-------------------------------------------------------------------------------------- - for (int i = 0; i < 3; i++) - { - if ((aray.direction[i] > 0) && (aray.origin[i] < aabb.min[i])) - { - cosine = (-aray.origin[i] + aabb.min[i]) / aray.direction[i]; - cut[i] = aabb.min[i]; - cut[incm3(i)] = aray.origin[incm3(i)] + (aray.direction[incm3(i)] * cosine); - cut[decm3(i)] = aray.origin[decm3(i)] + (aray.direction[decm3(i)] * cosine); - if ((cut[incm3(i)] > aabb.min[incm3(i)]) && (cut[incm3(i)] < aabb.max[incm3(i)]) && (cut[decm3(i)] > aabb.min[decm3(i)]) && (cut[decm3(i)] < aabb.max[decm3(i)])) - { - output1 = obb.m33 * cut + pos; - return 0x01; - } - } - if ((aray.direction[i] < 0) && (aray.origin[i] > aabb.max[i])) - { - cosine = (+aray.origin[i] - aabb.max[i]) / aray.direction[i]; - cut[i] = aabb.max[i]; - cut[incm3(i)] = aray.origin[incm3(i)] - (aray.direction[incm3(i)] * cosine); - cut[decm3(i)] = aray.origin[decm3(i)] - (aray.direction[decm3(i)] * cosine); - if ((cut[incm3(i)] > aabb.min[incm3(i)]) && (cut[incm3(i)] < aabb.max[incm3(i)]) && (cut[decm3(i)] > aabb.min[decm3(i)]) && (cut[decm3(i)] < aabb.max[decm3(i)])) - { - output1 = obb.m33 * cut + pos; - return 0x01; - } - } - } - return 0x00;//no intersection - } - - //---------------------------------------------------------------------------------- - // Lineseg_AABB - // - // just ONE intersection point is calculated, and thats the entry point - - // Lineseg and AABB are assumed to be in the same space - // - //--- 0x00 = no intersection (output undefined) -------------------------- - //--- 0x01 = intersection (intersection point in output) -------------- - //--- 0x02 = start of Lineseg is inside the AABB (ls.start is output) - //---------------------------------------------------------------------------------- - inline uint8 Lineseg_AABB(const Lineseg& ls, const AABB& aabb, Vec3& output1) - { - uint8 cflags; - float cosine; - Vec3 cut; - Vec3 lnormal = (ls.start - ls.end).GetNormalized(); - //-------------------------------------------------------------------------------------- - //---- check if "ls.start" is inside of AABB --------------------------- - //-------------------------------------------------------------------------------------- - cflags = (ls.start.x > aabb.min.x) << 0; - cflags |= (ls.start.x < aabb.max.x) << 1; - cflags |= (ls.start.y > aabb.min.y) << 2; - cflags |= (ls.start.y < aabb.max.y) << 3; - cflags |= (ls.start.z > aabb.min.z) << 4; - cflags |= (ls.start.z < aabb.max.z) << 5; - if (cflags == 0x3f) - { - //ls.start is inside of aabb - output1 = ls.start; - return 0x02; - } - - //-------------------------------------------------------------------------------------- - //---- check intersection with x-planes ------------------------------ - //-------------------------------------------------------------------------------------- - if (lnormal.x) - { - if ((ls.start.x < aabb.min.x) && (ls.end.x > aabb.min.x)) - { - cosine = (-ls.start.x + (+aabb.min.x)) / lnormal.x; - cut(aabb.min.x, ls.start.y + (lnormal.y * cosine), ls.start.z + (lnormal.z * cosine)); - //check if cut-point is inside YZ-plane border - if ((cut.y > aabb.min.y) && (cut.y < aabb.max.y) && (cut.z > aabb.min.z) && (cut.z < aabb.max.z)) - { - output1 = cut; - return 0x01; - } - } - if ((ls.start.x > aabb.max.x) && (ls.end.x < aabb.max.x)) - { - cosine = (+ls.start.x + (-aabb.max.x)) / lnormal.x; - cut(aabb.max.x, ls.start.y - (lnormal.y * cosine), ls.start.z - (lnormal.z * cosine)); - //check if cut-point is inside YZ-plane border - if ((cut.y > aabb.min.y) && (cut.y < aabb.max.y) && (cut.z > aabb.min.z) && (cut.z < aabb.max.z)) - { - output1 = cut; - return 0x01; - } - } - } - //-------------------------------------------------------------------------------------- - //---- check intersection with z-planes ------------------------------ - //-------------------------------------------------------------------------------------- - if (lnormal.z) - { - if ((ls.start.z < aabb.min.z) && (ls.end.z > aabb.min.z)) - { - cosine = (-ls.start.z + (+aabb.min.z)) / lnormal.z; - cut(ls.start.x + (lnormal.x * cosine), ls.start.y + (lnormal.y * cosine), aabb.min.z); - //check if cut-point is inside XY-plane border - if ((cut.x > aabb.min.x) && (cut.x < aabb.max.x) && (cut.y > aabb.min.y) && (cut.y < aabb.max.y)) - { - output1 = cut; - return 0x01; - } - } - if ((ls.start.z > aabb.max.z) && (ls.end.z < aabb.max.z)) - { - cosine = (+ls.start.z + (-aabb.max.z)) / lnormal.z; - cut(ls.start.x - (lnormal.x * cosine), ls.start.y - (lnormal.y * cosine), aabb.max.z); - //check if cut-point is inside XY-plane border - if ((cut.x > aabb.min.x) && (cut.x < aabb.max.x) && (cut.y > aabb.min.y) && (cut.y < aabb.max.y)) - { - output1 = cut; - return 0x01; - } - } - } - //-------------------------------------------------------------------------------------- - //---- check intersection with y-planes ------------------------------ - //-------------------------------------------------------------------------------------- - if (lnormal.y) - { - if ((ls.start.y < aabb.min.y) && (ls.end.y > aabb.min.y)) - { - cosine = (-ls.start.y + (+aabb.min.y)) / lnormal.y; - cut(ls.start.x + (lnormal.x * cosine), aabb.min.y, ls.start.z + (lnormal.z * cosine)); - //check if cut-point is inside XZ-plane border - if ((cut.x > aabb.min.x) && (cut.x < aabb.max.x) && (cut.z > aabb.min.z) && (cut.z < aabb.max.z)) - { - output1 = cut; - return 0x01; - } - } - if ((ls.start.y > aabb.max.y) && (ls.end.y < aabb.max.y)) - { - cosine = (+ls.start.y + (-aabb.max.y)) / lnormal.y; - cut(ls.start.x - (lnormal.x * cosine), aabb.max.y, ls.start.z - (lnormal.z * cosine)); - //check if cut-point is inside XZ-plane border - if ((cut.x > aabb.min.x) && (cut.x < aabb.max.x) && (cut.z > aabb.min.z) && (cut.z < aabb.max.z)) - { - output1 = cut; - return 0x01; - } - } - } - //no intersection - return 0x00; - } - - - - //---------------------------------------------------------------------------------- - // Lineseg_OBB - // - // just ONE intersection point is calculated, and thats the entry point - - // Lineseg and OBB are assumed to be in the same space - // - //--- 0x00 = no intersection (output undefined) -------------------------- - //--- 0x01 = intersection (intersection point in output) -------------- - //--- 0x02 = start of Lineseg is inside the OBB (ls.start is output) - //---------------------------------------------------------------------------------- - inline uint8 Lineseg_OBB(const Lineseg& lseg, const Vec3& pos, const OBB& obb, Vec3& output1) - { - AABB aabb(obb.c - obb.h, obb.c + obb.h); - Lineseg ls((lseg.start - pos) * obb.m33, (lseg.end - pos) * obb.m33); - - uint8 cflags; - float cosine; - Vec3 cut; - Vec3 lnormal = (ls.start - ls.end).GetNormalized(); - //-------------------------------------------------------------------------------------- - //---- check if "ls.start" is inside of AABB --------------------------- - //-------------------------------------------------------------------------------------- - cflags = (ls.start.x > aabb.min.x) << 0; - cflags |= (ls.start.x < aabb.max.x) << 1; - cflags |= (ls.start.y > aabb.min.y) << 2; - cflags |= (ls.start.y < aabb.max.y) << 3; - cflags |= (ls.start.z > aabb.min.z) << 4; - cflags |= (ls.start.z < aabb.max.z) << 5; - if (cflags == 0x3f) - { - //ls.start is inside of aabb - output1 = obb.m33 * ls.start + pos; - return 0x02; - } - - //-------------------------------------------------------------------------------------- - //---- check intersection with x-planes ------------------------------ - //-------------------------------------------------------------------------------------- - if (lnormal.x) - { - if ((ls.start.x < aabb.min.x) && (ls.end.x > aabb.min.x)) - { - cosine = (-ls.start.x + (+aabb.min.x)) / lnormal.x; - cut(aabb.min.x, ls.start.y + (lnormal.y * cosine), ls.start.z + (lnormal.z * cosine)); - //check if cut-point is inside YZ-plane border - if ((cut.y > aabb.min.y) && (cut.y < aabb.max.y) && (cut.z > aabb.min.z) && (cut.z < aabb.max.z)) - { - output1 = obb.m33 * cut + pos; - return 0x01; - } - } - if ((ls.start.x > aabb.max.x) && (ls.end.x < aabb.max.x)) - { - cosine = (+ls.start.x + (-aabb.max.x)) / lnormal.x; - cut(aabb.max.x, ls.start.y - (lnormal.y * cosine), ls.start.z - (lnormal.z * cosine)); - //check if cut-point is inside YZ-plane border - if ((cut.y > aabb.min.y) && (cut.y < aabb.max.y) && (cut.z > aabb.min.z) && (cut.z < aabb.max.z)) - { - output1 = obb.m33 * cut + pos; - return 0x01; - } - } - } - //-------------------------------------------------------------------------------------- - //---- check intersection with z-planes ------------------------------ - //-------------------------------------------------------------------------------------- - if (lnormal.z) - { - if ((ls.start.z < aabb.min.z) && (ls.end.z > aabb.min.z)) - { - cosine = (-ls.start.z + (+aabb.min.z)) / lnormal.z; - cut(ls.start.x + (lnormal.x * cosine), ls.start.y + (lnormal.y * cosine), aabb.min.z); - //check if cut-point is inside XY-plane border - if ((cut.x > aabb.min.x) && (cut.x < aabb.max.x) && (cut.y > aabb.min.y) && (cut.y < aabb.max.y)) - { - output1 = obb.m33 * cut + pos; - return 0x01; - } - } - if ((ls.start.z > aabb.max.z) && (ls.end.z < aabb.max.z)) - { - cosine = (+ls.start.z + (-aabb.max.z)) / lnormal.z; - cut(ls.start.x - (lnormal.x * cosine), ls.start.y - (lnormal.y * cosine), aabb.max.z); - //check if cut-point is inside XY-plane border - if ((cut.x > aabb.min.x) && (cut.x < aabb.max.x) && (cut.y > aabb.min.y) && (cut.y < aabb.max.y)) - { - output1 = obb.m33 * cut + pos; - return 0x01; - } - } - } - //-------------------------------------------------------------------------------------- - //---- check intersection with y-planes ------------------------------ - //-------------------------------------------------------------------------------------- - if (lnormal.y) - { - if ((ls.start.y < aabb.min.y) && (ls.end.y > aabb.min.y)) - { - cosine = (-ls.start.y + (+aabb.min.y)) / lnormal.y; - cut(ls.start.x + (lnormal.x * cosine), aabb.min.y, ls.start.z + (lnormal.z * cosine)); - //check if cut-point is inside XZ-plane border - if ((cut.x > aabb.min.x) && (cut.x < aabb.max.x) && (cut.z > aabb.min.z) && (cut.z < aabb.max.z)) - { - output1 = obb.m33 * cut + pos; - return 0x01; - } - } - if ((ls.start.y > aabb.max.y) && (ls.end.y < aabb.max.y)) - { - cosine = (+ls.start.y + (-aabb.max.y)) / lnormal.y; - cut(ls.start.x - (lnormal.x * cosine), aabb.max.y, ls.start.z - (lnormal.z * cosine)); - //check if cut-point is inside XZ-plane border - if ((cut.x > aabb.min.x) && (cut.x < aabb.max.x) && (cut.z > aabb.min.z) && (cut.z < aabb.max.z)) - { - output1 = obb.m33 * cut + pos; - return 0x01; - } - } - } - //no intersection - return 0x00; - } - - - - //---------------------------------------------------------------------------------- - //--- 0x00 = no intersection -------------------------- - //--- 0x01 = not possible -- - //--- 0x02 = not possible -- - //--- 0x03 = two intersection, lineseg has ENTRY and EXIT point -- - //---------------------------------------------------------------------------------- - - inline unsigned char Line_Sphere(const Line& line, const ::Sphere& s, Vec3& i0, Vec3& i1) - { - Vec3 end = line.pointonline + line.direction; - - float a = line.direction | line.direction; - float b = (line.direction | (line.pointonline - s.center)) * 2.0f; - float c = ((line.pointonline - s.center) | (line.pointonline - s.center)) - (s.radius * s.radius); - - float desc = (b * b) - (4 * a * c); - - unsigned char intersection = 0; - if (desc >= 0.0f) - { - float lamba0 = (-b - sqrt_tpl(desc)) / (2.0f * a); - //_stprintf(d3dApp.token,"lamba0: %20.12f",lamba0); - //d3dApp.m_pFont->DrawText( 2, d3dApp.PrintY, D3DCOLOR_ARGB(255,255,255,0), d3dApp.token ); d3dApp.PrintY+=20; - i0 = line.pointonline + ((end - line.pointonline) * lamba0); - intersection = 1; - - float lamba1 = (-b + sqrt_tpl(desc)) / (2.0f * a); - //_stprintf(d3dApp.token,"lamba1: %20.12f",lamba1); - //d3dApp.m_pFont->DrawText( 2, d3dApp.PrintY, D3DCOLOR_ARGB(255,255,255,0), d3dApp.token ); d3dApp.PrintY+=20; - i1 = line.pointonline + ((end - line.pointonline) * lamba1); - intersection |= 2; - } - - return intersection; - } - - - //---------------------------------------------------------------------------------- //--- 0x00 = no intersection -------------------------- //--- 0x01 = not possible -- @@ -873,87 +215,4 @@ namespace Intersect { } return false; } - - - - //---------------------------------------------------------------------------------- - //--- 0x00 = no intersection -------------------------- - //--- 0x01 = one intersection, lineseg has just an ENTRY point but no EXIT point (ls.end is inside the sphere) -- - //--- 0x02 = one intersection, lineseg has just an EXIT point but no ENTRY point (ls.start is inside the sphere) -- - //--- 0x03 = two intersection, lineseg has ENTRY and EXIT point -- - //---------------------------------------------------------------------------------- - inline unsigned char Lineseg_Sphere(const Lineseg& ls, const ::Sphere& s, Vec3& i0, Vec3& i1) - { - Vec3 dir = (ls.end - ls.start); - - float a = dir | dir; - if (a == 0.0f) - { - return 0; - } - - float b = (dir | (ls.start - s.center)) * 2.0f; - float c = ((ls.start - s.center) | (ls.start - s.center)) - (s.radius * s.radius); - float desc = (b * b) - (4 * a * c); - - unsigned char intersection = 0; - if (desc >= 0.0f) - { - float lamba0 = (-b - sqrt_tpl(desc)) / (2.0f * a); - if (lamba0 > 0.0f) - { - i0 = ls.start + ((ls.end - ls.start) * lamba0); - //skip, if 1st cutting-point is "in front" of ls.end - if (((i0 - ls.end) | dir) > 0) - { - return 0; - } - intersection = 0x01; - } - - float lamba1 = (-b + sqrt_tpl(desc)) / (2.0f * a); - if (lamba1 > 0.0f) - { - i1 = ls.start + ((ls.end - ls.start) * lamba1); - //skip, if 2nd cutting-point is "in front" of ls.end (=ls.end is inside sphere) - if (((i1 - ls.end) | dir) > 0) - { - return intersection; - } - intersection |= 0x02; - } - } - return intersection; - } - - - inline bool Lineseg_SphereFirst(const Lineseg& lineseg, const ::Sphere& s, Vec3& intPoint) - { - Vec3 p2; - uint8 res = Lineseg_Sphere(lineseg, s, intPoint, p2); - if (res == 2) - { - intPoint = p2; - } - if (res > 1) - { - return true; - } - return false; - } -}; //CIntersect - - - - - - - - - - - - - - -#endif // CRYINCLUDE_CRYCOMMON_CRY_GEOINTERSECT_H +} //Intersect diff --git a/Code/Legacy/CryCommon/Cry_GeoOverlap.h b/Code/Legacy/CryCommon/Cry_GeoOverlap.h index badb4a1edd..039f292f5b 100644 --- a/Code/Legacy/CryCommon/Cry_GeoOverlap.h +++ b/Code/Legacy/CryCommon/Cry_GeoOverlap.h @@ -657,64 +657,6 @@ namespace Overlap { return AfterStart >= 0.0f; } - /*! - * - * overlap-test between line-segment and a triangle. - * IMPORTANT: this is a single-sided test. That means its not sufficient - * that the triangle and line-segment overlap, its also important that the triangle - * is "visible" when you are looking along the linesegment from "start" to "end". - * - * If you need a double-sided test, you'll have to call this function twice with - * reversed order of triangle vertices. - * - * return values - * return "true" if linesegment and triangle overlap. - */ - inline bool Lineseg_Triangle(const Lineseg& lineseg, const Vec3& v0, const Vec3& v1, const Vec3& v2) - { - const float Epsilon = 0.0000001f; - - Vec3 edgeA = v1 - v0; - Vec3 edgeB = v2 - v0; - - Vec3 dir = lineseg.end - lineseg.start; - - Vec3 p = dir.Cross(edgeA); - Vec3 t = lineseg.start - v0; - Vec3 q = t.Cross(edgeB); - - float dot = edgeB.Dot(p); - - float u = t.Dot(p); - float v = dir.Dot(q); - - float DotGreaterThanEpsilon = dot - Epsilon; - float VGreaterEqualThanZero = v; - float UGreaterEqualThanZero = u; - float UVLessThanDot = dot - (u + v); - float ULessThanDot = dot - u; - - float UVGreaterEqualThanZero = (float)fsel(VGreaterEqualThanZero, UGreaterEqualThanZero, VGreaterEqualThanZero); - float UUVLessThanDot = (float)fsel(UVLessThanDot, ULessThanDot, UVLessThanDot); - float BothGood = (float)fsel(UVGreaterEqualThanZero, UUVLessThanDot, UVGreaterEqualThanZero); - float AllGood = (float)fsel(DotGreaterThanEpsilon, BothGood, DotGreaterThanEpsilon); - - if (AllGood < 0.0f) - { - return false; - } - - float dt = edgeA.Dot(q) / dot; - - Vec3 result = (dir * dt) + lineseg.start; - - float AfterStart = (result - lineseg.start).Dot(dir); - float BeforeEnd = -(result - lineseg.end).Dot(dir); - float Within = (float)fsel(AfterStart, BeforeEnd, AfterStart); - - return Within >= 0.0f; - } - /*---------------------------------------------------------------------------------- * Sphere_AABB * Sphere and AABB are assumed to be in the same space diff --git a/Code/Legacy/CryCommon/Cry_Math.h b/Code/Legacy/CryCommon/Cry_Math.h index 91ceebd51a..885361f4e3 100644 --- a/Code/Legacy/CryCommon/Cry_Math.h +++ b/Code/Legacy/CryCommon/Cry_Math.h @@ -592,14 +592,12 @@ enum type_identity #include "Cry_Vector2.h" #include "Cry_Vector3.h" #include "Cry_Vector4.h" -#include "Cry_MatrixDiag.h" #include "Cry_Matrix33.h" #include "Cry_Matrix34.h" #include "Cry_Matrix44.h" #include "Cry_Quat.h" #include "Cry_HWVector3.h" #include "Cry_HWMatrix.h" -#include "Cry_XOptimise.h" ////////////////////////////////////////////////////////////////////////// diff --git a/Code/Legacy/CryCommon/Cry_Matrix33.h b/Code/Legacy/CryCommon/Cry_Matrix33.h index 075f07a896..02d1586931 100644 --- a/Code/Legacy/CryCommon/Cry_Matrix33.h +++ b/Code/Legacy/CryCommon/Cry_Matrix33.h @@ -177,44 +177,6 @@ struct Matrix33_tpl m22 = F(vz.z); } - - - - - //CONSTRUCTOR for identical float-types. It converts a Diag33 into a Matrix33. - //Matrix33(diag33); - ILINE Matrix33_tpl(const Diag33_tpl&d) - { - assert(d.IsValid()); - m00 = d.x; - m01 = 0; - m02 = 0; - m10 = 0; - m11 = d.y; - m12 = 0; - m20 = 0; - m21 = 0; - m22 = d.z; - } - //CONSTRUCTOR for different float-types. It converts a Diag33 into a Matrix33 and also converts between double/float. - //Matrix33(diag33); - template - ILINE Matrix33_tpl(const Diag33_tpl&d) - { - assert(d.IsValid()); - m00 = F(d.x); - m01 = 0; - m02 = 0; - m10 = 0; - m11 = F(d.y); - m12 = 0; - m20 = 0; - m21 = 0; - m22 = F(d.z); - } - - - //CONSTRUCTOR for identical float-types //Matrix33 m=m33; ILINE Matrix33_tpl(const Matrix33_tpl&m) @@ -1252,40 +1214,6 @@ typedef Matrix33_tpl Matrix33r; //variable float precision. depending on t //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- -template -ILINE Matrix33_tpl operator*(const Matrix33_tpl& l, const Diag33_tpl& r) -{ - assert(l.IsValid()); - assert(r.IsValid()); - Matrix33_tpl res; - res.m00 = l.m00 * r.x; - res.m01 = l.m01 * r.y; - res.m02 = l.m02 * r.z; - res.m10 = l.m10 * r.x; - res.m11 = l.m11 * r.y; - res.m12 = l.m12 * r.z; - res.m20 = l.m20 * r.x; - res.m21 = l.m21 * r.y; - res.m22 = l.m22 * r.z; - return res; -} -template -ILINE Matrix33_tpl& operator *= (Matrix33_tpl& l, const Diag33_tpl& r) -{ - assert(l.IsValid()); - assert(r.IsValid()); - l.m00 *= r.x; - l.m01 *= r.y; - l.m02 *= r.z; - l.m10 *= r.x; - l.m11 *= r.y; - l.m12 *= r.z; - l.m20 *= r.x; - l.m21 *= r.y; - l.m22 *= r.z; - return l; -} - //Matrix33 operations with another Matrix33 template ILINE Matrix33_tpl operator * (const Matrix33_tpl& l, const Matrix33_tpl& r) diff --git a/Code/Legacy/CryCommon/Cry_Matrix34.h b/Code/Legacy/CryCommon/Cry_Matrix34.h index dfc059c11e..d409cfef8b 100644 --- a/Code/Legacy/CryCommon/Cry_Matrix34.h +++ b/Code/Legacy/CryCommon/Cry_Matrix34.h @@ -1281,43 +1281,6 @@ ILINE Vec3_tpl operator * (const Matrix34_tpl& m, const Vec3_tpl& p) return tp; } - -template -ILINE Matrix34_tpl operator*(const Matrix34_tpl& l, const Diag33_tpl& r) -{ - assert(l.IsValid()); - assert(r.IsValid()); - Matrix34_tpl m; - m.m00 = l.m00 * r.x; - m.m01 = l.m01 * r.y; - m.m02 = l.m02 * r.z; - m.m03 = l.m03; - m.m10 = l.m10 * r.x; - m.m11 = l.m11 * r.y; - m.m12 = l.m12 * r.z; - m.m13 = l.m13; - m.m20 = l.m20 * r.x; - m.m21 = l.m21 * r.y; - m.m22 = l.m22 * r.z; - m.m23 = l.m23; - return m; -} -template -ILINE Matrix34_tpl& operator *= (Matrix34_tpl& l, const Diag33_tpl& r) -{ - assert(l.IsValid()); - assert(r.IsValid()); - l.m00 *= r.x; - l.m01 *= r.y; - l.m02 *= r.z; - l.m10 *= r.x; - l.m11 *= r.y; - l.m12 *= r.z; - l.m20 *= r.x; - l.m21 *= r.y; - l.m22 *= r.z; - return l; -} template ILINE Matrix34_tpl operator + (const Matrix34_tpl& l, const Matrix34_tpl& r) { diff --git a/Code/Legacy/CryCommon/Cry_Matrix44.h b/Code/Legacy/CryCommon/Cry_Matrix44.h index 8304f7761e..e97325141c 100644 --- a/Code/Legacy/CryCommon/Cry_Matrix44.h +++ b/Code/Legacy/CryCommon/Cry_Matrix44.h @@ -680,63 +680,6 @@ typedef Matrix44_tpl Matrix44r; //variable float precision. depending on //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- -/*! -* Implements the multiplication operator: Matrix44=Matrix44*Matrix33diag -* -* Matrix44 and Matrix33diag are specified in collumn order. -* AxB = operation B followed by operation A. -* This operation takes 12 mults. -* -* Example: -* Matrix33diag diag(1,2,3); -* Matrix44 m44=CreateRotationZ33(3.14192f); -* Matrix44 result=m44*diag; -*/ -template -ILINE Matrix44_tpl operator * (const Matrix44_tpl& l, const Diag33_tpl& r) -{ - assert(l.IsValid()); - assert(r.IsValid()); - Matrix44_tpl m; - m.m00 = l.m00 * r.x; - m.m01 = l.m01 * r.y; - m.m02 = l.m02 * r.z; - m.m03 = l.m03; - m.m10 = l.m10 * r.x; - m.m11 = l.m11 * r.y; - m.m12 = l.m12 * r.z; - m.m13 = l.m13; - m.m20 = l.m20 * r.x; - m.m21 = l.m21 * r.y; - m.m22 = l.m22 * r.z; - m.m23 = l.m23; - m.m30 = l.m30 * r.x; - m.m31 = l.m31 * r.y; - m.m32 = l.m32 * r.z; - m.m33 = l.m33; - return m; -} -template -ILINE Matrix44_tpl& operator *= (Matrix44_tpl& l, const Diag33_tpl& r) -{ - assert(l.IsValid()); - assert(r.IsValid()); - l.m00 *= r.x; - l.m01 *= r.y; - l.m02 *= r.z; - l.m10 *= r.x; - l.m11 *= r.y; - l.m12 *= r.z; - l.m20 *= r.x; - l.m21 *= r.y; - l.m22 *= r.z; - l.m30 *= r.x; - l.m31 *= r.y; - l.m32 *= r.z; - return l; -} - - /*! * Implements the multiplication operator: Matrix44=Matrix44*Matrix33 * diff --git a/Code/Legacy/CryCommon/Cry_MatrixDiag.h b/Code/Legacy/CryCommon/Cry_MatrixDiag.h deleted file mode 100644 index 897265049e..0000000000 --- a/Code/Legacy/CryCommon/Cry_MatrixDiag.h +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - - -// Description : Common matrix class - - -#ifndef CRYINCLUDE_CRYCOMMON_CRY_MATRIXDIAG_H -#define CRYINCLUDE_CRYCOMMON_CRY_MATRIXDIAG_H -#pragma once - - -/////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// -// struct Diag33_tpl -/////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// - -template -struct Diag33_tpl -{ - F x, y, z; - -#ifdef _DEBUG - ILINE Diag33_tpl() - { - if constexpr (sizeof(F) == 4) - { - uint32* p = alias_cast(&x); - p[0] = F32NAN; - p[1] = F32NAN; - p[2] = F32NAN; - } - if constexpr (sizeof(F) == 8) - { - uint64* p = alias_cast(&x); - p[0] = F64NAN; - p[1] = F64NAN; - p[2] = F64NAN; - } - } -#else - ILINE Diag33_tpl() {}; -#endif - - - Diag33_tpl(F dx, F dy, F dz) { x = dx; y = dy; z = dz; } - Diag33_tpl(const Vec3_tpl& v) { x = v.x; y = v.y; z = v.z; } - template - const Diag33_tpl& operator=(const Vec3_tpl& v) { x = v.x; y = v.y; z = v.z; return *this; } - Diag33_tpl& operator=(const Diag33_tpl& diag) { x = diag.x; y = diag.y; z = diag.z; return *this; } - template - Diag33_tpl& operator=(const Diag33_tpl& diag) { x = diag.x; y = diag.y; z = diag.z; return *this; } - - const void SetIdentity() { x = y = z = 1; } - Diag33_tpl(type_identity) { x = y = z = 1; } - - const Diag33_tpl& zero() { x = y = z = 0; return *this; } - - Diag33_tpl& fabs() { x = fabs_tpl(x); y = fabs_tpl(y); z = fabs_tpl(z); return *this; } - - Diag33_tpl& invert() // in-place inversion - { - F det = determinant(); - if (det == 0) - { - return *this; - } - det = (F)1.0 / det; - F oldata[3]; - oldata[0] = x; - oldata[1] = y; - oldata[2] = z; - x = oldata[1] * oldata[2] * det; - y = oldata[0] * oldata[2] * det; - z = oldata[0] * oldata[1] * det; - return *this; - } - - /*! - * Linear-Interpolation between Diag33(lerp) - * - * Example: - * Diag33 r=Diag33::CreateLerp( p, q, 0.345f ); - */ - ILINE void SetLerp(const Diag33_tpl& p, const Diag33_tpl& q, F t) - { - x = p.x * (1.0f - t) + q.x * t; - y = p.y * (1.0f - t) + q.y * t; - z = p.z * (1.0f - t) + q.z * t; - } - ILINE static Diag33_tpl CreateLerp(const Diag33_tpl& p, const Diag33_tpl& q, F t) - { - Diag33_tpl d; - d.x = p.x * (1.0f - t) + q.x * t; - d.y = p.y * (1.0f - t) + q.y * t; - d.z = p.z * (1.0f - t) + q.z * t; - return d; - } - - F determinant() const { return x * y * z; } - - ILINE bool IsValid() const - { - if (!NumberValid(x)) - { - return false; - } - if (!NumberValid(y)) - { - return false; - } - if (!NumberValid(z)) - { - return false; - } - return true; - } -}; - -/////////////////////////////////////////////////////////////////////////////// -// Typedefs // -/////////////////////////////////////////////////////////////////////////////// - -typedef Diag33_tpl Diag33; //always 32 bit -typedef Diag33_tpl Diag33d;//always 64 bit -typedef Diag33_tpl Diag33r;//variable float precision. depending on the target system it can be between 32, 64 or 80 bit - - -template -Diag33_tpl operator*(const Diag33_tpl& l, const Diag33_tpl& r) -{ - return Diag33_tpl(l.x * r.x, l.y * r.y, l.z * r.z); -} - -template -Matrix33_tpl operator*(const Diag33_tpl& l, const Matrix33_tpl& r) -{ - Matrix33_tpl res; - res.m00 = r.m00 * l.x; - res.m01 = r.m01 * l.x; - res.m02 = r.m02 * l.x; - res.m10 = r.m10 * l.y; - res.m11 = r.m11 * l.y; - res.m12 = r.m12 * l.y; - res.m20 = r.m20 * l.z; - res.m21 = r.m21 * l.z; - res.m22 = r.m22 * l.z; - return res; -} -template -Matrix34_tpl operator*(const Diag33_tpl& l, const Matrix34_tpl& r) -{ - Matrix34_tpl m; - m.m00 = l.x * r.m00; - m.m01 = l.x * r.m01; - m.m02 = l.x * r.m02; - m.m03 = l.x * r.m03; - m.m10 = l.y * r.m10; - m.m11 = l.y * r.m11; - m.m12 = l.y * r.m12; - m.m13 = l.y * r.m13; - m.m20 = l.z * r.m20; - m.m21 = l.z * r.m21; - m.m22 = l.z * r.m22; - m.m23 = l.z * r.m23; - return m; -} - -template -Vec3_tpl operator *(const Diag33_tpl& mtx, const Vec3_tpl& vec) -{ - return Vec3_tpl(mtx.x * vec.x, mtx.y * vec.y, mtx.z * vec.z); -} - -template -Vec3_tpl operator *(const Vec3_tpl& vec, const Diag33_tpl& mtx) -{ - return Vec3_tpl(mtx.x * vec.x, mtx.y * vec.y, mtx.z * vec.z); -} - - - -#endif // CRYINCLUDE_CRYCOMMON_CRY_MATRIXDIAG_H - diff --git a/Code/Legacy/CryCommon/Cry_XOptimise.h b/Code/Legacy/CryCommon/Cry_XOptimise.h deleted file mode 100644 index bc05c16fbc..0000000000 --- a/Code/Legacy/CryCommon/Cry_XOptimise.h +++ /dev/null @@ -1,566 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - - -// Description : Misc mathematical functions - - -#ifndef CRYINCLUDE_CRYCOMMON_CRY_XOPTIMISE_H -#define CRYINCLUDE_CRYCOMMON_CRY_XOPTIMISE_H -#pragma once - -#include - - - - -inline float AngleMod(float a) -{ - a = (float)((360.0 / 65536) * ((int)(a * (65536 / 360.0)) & 65535)); - return a; -} - -inline float AngleModRad(float a) -{ - a = (float)((gf_PI2 / 65536) * ((int)(a * (65536 / gf_PI2)) & 65535)); - return a; -} -inline unsigned short Degr2Word(float f) -{ - return (unsigned short)(AngleMod(f) / 360.0f * 65536.0f); -} -inline float Word2Degr(unsigned short s) -{ - return (float)s / 65536.0f * 360.0f; -} - -#if defined(_CPU_X86) -ILINE float __fastcall Ffabs(float f) -{ - *((unsigned*) &f) &= ~0x80000000; - return (f); -} -#else -inline float Ffabs(float x) { return fabsf(x); } -#endif - - - -#define mathMatrixRotationZ(pOut, angle) (*(Matrix44*)pOut) = GetTransposed44(Matrix44(Matrix34::CreateRotationZ(angle))) -#define mathMatrixRotationY(pOut, angle) (*(Matrix44*)pOut) = GetTransposed44(Matrix44(Matrix34::CreateRotationY(angle))) -#define mathMatrixRotationX(pOut, angle) (*(Matrix44*)pOut) = GetTransposed44(Matrix44(Matrix34::CreateRotationX(angle))) -#define mathMatrixTranslation(pOut, x, y, z) (*(Matrix44*)pOut) = GetTransposed44(Matrix44(Matrix34::CreateTranslationMat(Vec3(x, y, z)))) -#define mathMatrixScaling(pOut, sx, sy, sz) (*(Matrix44*)pOut) = GetTransposed44(Matrix44(Matrix34::CreateScale(Vec3(sx, sy, sz)))) - -template -inline void ExchangeVals(T& X, T& Y) -{ - const T Tmp = X; - X = Y; - Y = Tmp; -} - - -inline void mathMatrixPerspectiveFov(Matrix44A* pMatr, f32 fovY, f32 Aspect, f32 zn, f32 zf) -{ - f32 yScale = 1.0f / tan_tpl(fovY / 2.0f); - f32 xScale = yScale / Aspect; - - f32 m22 = f32(f64(zf) / (f64(zn) - f64(zf))); - f32 m32 = f32(f64(zn) * f64(zf) / (f64(zn) - f64(zf))); - - (*pMatr)(0, 0) = xScale; - (*pMatr)(0, 1) = 0; - (*pMatr)(0, 2) = 0; - (*pMatr)(0, 3) = 0; - (*pMatr)(1, 0) = 0; - (*pMatr)(1, 1) = yScale; - (*pMatr)(1, 2) = 0; - (*pMatr)(1, 3) = 0; - (*pMatr)(2, 0) = 0; - (*pMatr)(2, 1) = 0; - (*pMatr)(2, 2) = m22; - (*pMatr)(2, 3) = -1.0f; - (*pMatr)(3, 0) = 0; - (*pMatr)(3, 1) = 0; - (*pMatr)(3, 2) = m32; - (*pMatr)(3, 3) = 0; -} - - - -inline void mathMatrixOrtho(Matrix44A* pMatr, f32 w, f32 h, f32 zn, f32 zf) -{ - f32 m22 = f32(1.0 / (f64(zn) - f64(zf))); - f32 m32 = f32(f64(zn) / (f64(zn) - f64(zf))); - - (*pMatr)(0, 0) = 2.0f / w; - (*pMatr)(0, 1) = 0; - (*pMatr)(0, 2) = 0; - (*pMatr)(0, 3) = 0; - (*pMatr)(1, 0) = 0; - (*pMatr)(1, 1) = 2.0f / h; - (*pMatr)(1, 2) = 0; - (*pMatr)(1, 3) = 0; - (*pMatr)(2, 0) = 0; - (*pMatr)(2, 1) = 0; - (*pMatr)(2, 2) = m22; - (*pMatr)(2, 3) = 0; - (*pMatr)(3, 0) = 0; - (*pMatr)(3, 1) = 0; - (*pMatr)(3, 2) = m32; - (*pMatr)(3, 3) = 1; -} - -inline void mathMatrixOrthoOffCenter(Matrix44A* pMatr, f32 l, f32 r, f32 b, f32 t, f32 zn, f32 zf) -{ - f32 m22 = f32(1.0 / (f64(zn) - f64(zf))); - f32 m32 = f32(f64(zn) / (f64(zn) - f64(zf))); - - (*pMatr)(0, 0) = 2.0f / (r - l); - (*pMatr)(0, 1) = 0; - (*pMatr)(0, 2) = 0; - (*pMatr)(0, 3) = 0; - (*pMatr)(1, 0) = 0; - (*pMatr)(1, 1) = 2.0f / (t - b); - (*pMatr)(1, 2) = 0; - (*pMatr)(1, 3) = 0; - (*pMatr)(2, 0) = 0; - (*pMatr)(2, 1) = 0; - (*pMatr)(2, 2) = m22; - (*pMatr)(2, 3) = 0; - (*pMatr)(3, 0) = (l + r) / (l - r); - (*pMatr)(3, 1) = (t + b) / (b - t); - (*pMatr)(3, 2) = m32; - (*pMatr)(3, 3) = 1.0f; -} - - -inline void mathMatrixOrthoOffCenterLH(Matrix44A* pMatr, f32 l, f32 r, f32 b, f32 t, f32 zn, f32 zf) -{ - f32 m22 = f32(1.0 / (f64(zf) - f64(zn))); - f32 m32 = f32(f64(zn) / (f64(zn) - f64(zf))); - - (*pMatr)(0, 0) = 2.0f / (r - l); - (*pMatr)(0, 1) = 0; - (*pMatr)(0, 2) = 0; - (*pMatr)(0, 3) = 0; - (*pMatr)(1, 0) = 0; - (*pMatr)(1, 1) = 2.0f / (t - b); - (*pMatr)(1, 2) = 0; - (*pMatr)(1, 3) = 0; - (*pMatr)(2, 0) = 0; - (*pMatr)(2, 1) = 0; - (*pMatr)(2, 2) = m22; - (*pMatr)(2, 3) = 0; - (*pMatr)(3, 0) = (l + r) / (l - r); - (*pMatr)(3, 1) = (t + b) / (b - t); - (*pMatr)(3, 2) = m32; - (*pMatr)(3, 3) = 1.0f; -} - - -inline void mathMatrixPerspectiveOffCenter(Matrix44A* pMatr, f32 l, f32 r, f32 b, f32 t, f32 zn, f32 zf) -{ - f32 m22 = f32(f64(zf) / (f64(zn) - f64(zf))); - f32 m32 = f32(f64(zn) * f64(zf) / (f64(zn) - f64(zf))); - - (*pMatr)(0, 0) = 2 * zn / (r - l); - (*pMatr)(0, 1) = 0; - (*pMatr)(0, 2) = 0; - (*pMatr)(0, 3) = 0; - (*pMatr)(1, 0) = 0; - (*pMatr)(1, 1) = 2 * zn / (t - b); - (*pMatr)(1, 2) = 0; - (*pMatr)(1, 3) = 0; - (*pMatr)(2, 0) = (l + r) / (r - l); - (*pMatr)(2, 1) = (t + b) / (t - b); - (*pMatr)(2, 2) = m22; - (*pMatr)(2, 3) = -1; - (*pMatr)(3, 0) = 0; - (*pMatr)(3, 1) = 0; - (*pMatr)(3, 2) = m32; - (*pMatr)(3, 3) = 0; -} - -inline void mathMatrixPerspectiveOffCenterReverseDepth(Matrix44A* pMatr, f32 l, f32 r, f32 b, f32 t, f32 zn, f32 zf) -{ - f32 m22 = f32(-f64(zn) / (f64(zn) - f64(zf))); - f32 m32 = f32(-f64(zn) * f64(zf) / (f64(zn) - f64(zf))); - - (*pMatr)(0, 0) = 2 * zn / (r - l); - (*pMatr)(0, 1) = 0; - (*pMatr)(0, 2) = 0; - (*pMatr)(0, 3) = 0; - (*pMatr)(1, 0) = 0; - (*pMatr)(1, 1) = 2 * zn / (t - b); - (*pMatr)(1, 2) = 0; - (*pMatr)(1, 3) = 0; - (*pMatr)(2, 0) = (l + r) / (r - l); - (*pMatr)(2, 1) = (t + b) / (t - b); - (*pMatr)(2, 2) = m22; - (*pMatr)(2, 3) = -1; - (*pMatr)(3, 0) = 0; - (*pMatr)(3, 1) = 0; - (*pMatr)(3, 2) = m32; - (*pMatr)(3, 3) = 0; -} - -//RH -inline void mathMatrixLookAt(Matrix44A* pMatr, const Vec3& Eye, const Vec3& At, const Vec3& Up) -{ - Vec3 vLightDir = (Eye - At); - Vec3 zaxis = vLightDir.GetNormalized(); - Vec3 xaxis = (Up.Cross(zaxis)).GetNormalized(); - Vec3 yaxis = zaxis.Cross(xaxis); - - (*pMatr)(0, 0) = xaxis.x; - (*pMatr)(0, 1) = yaxis.x; - (*pMatr)(0, 2) = zaxis.x; - (*pMatr)(0, 3) = 0; - (*pMatr)(1, 0) = xaxis.y; - (*pMatr)(1, 1) = yaxis.y; - (*pMatr)(1, 2) = zaxis.y; - (*pMatr)(1, 3) = 0; - (*pMatr)(2, 0) = xaxis.z; - (*pMatr)(2, 1) = yaxis.z; - (*pMatr)(2, 2) = zaxis.z; - (*pMatr)(2, 3) = 0; - (*pMatr)(3, 0) = -xaxis.Dot(Eye); - (*pMatr)(3, 1) = -yaxis.Dot(Eye); - (*pMatr)(3, 2) = -zaxis.Dot(Eye); - (*pMatr)(3, 3) = 1; -} - -inline bool mathMatrixPerspectiveFovInverse(Matrix44_tpl* pResult, const Matrix44A* pProjFov) -{ - if ((*pProjFov)(0, 1) == 0.0f && (*pProjFov)(0, 2) == 0.0f && (*pProjFov)(0, 3) == 0.0f && - (*pProjFov)(1, 0) == 0.0f && (*pProjFov)(1, 2) == 0.0f && (*pProjFov)(1, 3) == 0.0f && - (*pProjFov)(3, 0) == 0.0f && (*pProjFov)(3, 1) == 0.0f && (*pProjFov)(3, 2) != 0.0f) - { - (*pResult)(0, 0) = 1.0 / (*pProjFov).m00; - (*pResult)(0, 1) = 0; - (*pResult)(0, 2) = 0; - (*pResult)(0, 3) = 0; - (*pResult)(1, 0) = 0; - (*pResult)(1, 1) = 1.0 / (*pProjFov).m11; - (*pResult)(1, 2) = 0; - (*pResult)(1, 3) = 0; - (*pResult)(2, 0) = 0; - (*pResult)(2, 1) = 0; - (*pResult)(2, 2) = 0; - (*pResult)(2, 3) = 1.0 / (*pProjFov).m32; - (*pResult)(3, 0) = (*pProjFov).m20 / (*pProjFov).m00; - (*pResult)(3, 1) = (*pProjFov).m21 / (*pProjFov).m11; - (*pResult)(3, 2) = -1; - (*pResult)(3, 3) = (*pProjFov).m22 / (*pProjFov).m32; - - return true; - } - - return false; -} - -template -inline void mathMatrixLookAtInverse(Matrix44_tpl* pResult, const Matrix44_tpl* pLookAt) -{ - (*pResult)(0, 0) = (*pLookAt).m00; - (*pResult)(0, 1) = (*pLookAt).m10; - (*pResult)(0, 2) = (*pLookAt).m20; - (*pResult)(0, 3) = (*pLookAt).m03; - (*pResult)(1, 0) = (*pLookAt).m01; - (*pResult)(1, 1) = (*pLookAt).m11; - (*pResult)(1, 2) = (*pLookAt).m21; - (*pResult)(1, 3) = (*pLookAt).m13; - (*pResult)(2, 0) = (*pLookAt).m02; - (*pResult)(2, 1) = (*pLookAt).m12; - (*pResult)(2, 2) = (*pLookAt).m22; - (*pResult)(2, 3) = (*pLookAt).m23; - - (*pResult)(3, 0) = T_out(-(f64((*pLookAt).m00) * f64((*pLookAt).m30) + f64((*pLookAt).m01) * f64((*pLookAt).m31) + f64((*pLookAt).m02) * f64((*pLookAt).m32))); - (*pResult)(3, 1) = T_out(-(f64((*pLookAt).m10) * f64((*pLookAt).m30) + f64((*pLookAt).m11) * f64((*pLookAt).m31) + f64((*pLookAt).m12) * f64((*pLookAt).m32))); - (*pResult)(3, 2) = T_out(-(f64((*pLookAt).m20) * f64((*pLookAt).m30) + f64((*pLookAt).m21) * f64((*pLookAt).m31) + f64((*pLookAt).m22) * f64((*pLookAt).m32))); - (*pResult)(3, 3) = (*pLookAt).m33; -}; - -inline void mathVec4Transform(f32 out[4], const f32 m[16], const f32 in[4]) -{ -#define M(row, col) m[col * 4 + row] - out[0] = M(0, 0) * in[0] + M(0, 1) * in[1] + M(0, 2) * in[2] + M(0, 3) * in[3]; - out[1] = M(1, 0) * in[0] + M(1, 1) * in[1] + M(1, 2) * in[2] + M(1, 3) * in[3]; - out[2] = M(2, 0) * in[0] + M(2, 1) * in[1] + M(2, 2) * in[2] + M(2, 3) * in[3]; - out[3] = M(3, 0) * in[0] + M(3, 1) * in[1] + M(3, 2) * in[2] + M(3, 3) * in[3]; -#undef M -} - -//fix: replace by 3x4 Matrix transformation and move to crymath -inline void mathVec3Transform(f32 out[4], const f32 m[16], const f32 in[3]) -{ -#define M(row, col) m[col * 4 + row] - out[0] = M(0, 0) * in[0] + M(0, 1) * in[1] + M(0, 2) * in[2] + M(0, 3) * 1.0f; - out[1] = M(1, 0) * in[0] + M(1, 1) * in[1] + M(1, 2) * in[2] + M(1, 3) * 1.0f; - out[2] = M(2, 0) * in[0] + M(2, 1) * in[1] + M(2, 2) * in[2] + M(2, 3) * 1.0f; - out[3] = M(3, 0) * in[0] + M(3, 1) * in[1] + M(3, 2) * in[2] + M(3, 3) * 1.0f; -#undef M -} - -#define mathVec3TransformF(pOut, pV, pM) mathVec3Transform((f32*)pOut, (const f32*)pM, (f32*)pV) -#define mathVec4TransformF(pOut, pV, pM) mathVec4Transform((f32*)pOut, (const f32*)pM, (f32*)pV) -#define mathVec3NormalizeF(pOut, pV) (*(Vec3*)pOut) = (((Vec3*)pV)->GetNormalizedSafe()) -#define mathVec2NormalizeF(pOut, pV) (*(Vec2*)pOut) = (((Vec2*)pV)->GetNormalizedSafe()) - - -//fix replace viewport by int16 array -//fix for d3d viewport -inline f32 mathVec3Project(Vec3* pvWin, const Vec3* pvObj, const int32 pViewport[4], const Matrix44A* pProjection, const Matrix44A* pView, const Matrix44A* pWorld) -{ - Vec4 in, out; - - in.x = pvObj->x; - in.y = pvObj->y; - in.z = pvObj->z; - in.w = 1.0f; - mathVec4Transform((f32*)&out, (f32*)pWorld, (f32*)&in); - mathVec4Transform((f32*)&in, (f32*)pView, (f32*)&out); - mathVec4Transform((f32*)&out, (f32*)pProjection, (f32*)&in); - - if (out.w == 0.0f) - { - return 0.f; - } - - out.x /= out.w; - out.y /= out.w; - out.z /= out.w; - - //output coords - pvWin->x = pViewport[0] + (1 + out.x) * pViewport[2] / 2; - pvWin->y = pViewport[1] + (1 - out.y) * pViewport[3] / 2; //flip coords for y axis - - //FIX: update fViewportMinZ fViewportMaxZ support for Viewport everywhere - float fViewportMinZ = 0, fViewportMaxZ = 1.0f; - - pvWin->z = fViewportMinZ + out.z * (fViewportMaxZ - fViewportMinZ); - - return out.w; -} - -inline Vec3* mathVec3UnProject(Vec3* pvObj, const Vec3* pvWin, const int32 pViewport[4], const Matrix44A* pProjection, const Matrix44A* pView, const Matrix44A* pWorld, [[maybe_unused]] int32 OptFlags) -{ - Matrix44A m, mA; - Vec4 in, out; - - //FIX: update fViewportMinZ fViewportMaxZ support for Viewport everywhere - float fViewportMinZ = 0, fViewportMaxZ = 1.0f; - - in.x = (pvWin->x - pViewport[0]) * 2 / pViewport[2] - 1.0f; - in.y = 1.0f - ((pvWin->y - pViewport[1]) * 2 / pViewport[3]); //flip coords for y axis - in.z = (pvWin->z - fViewportMinZ) / (fViewportMaxZ - fViewportMinZ); - in.w = 1.0f; - - //prepare inverse projection matrix - mA = ((*pWorld) * (*pView)) * (*pProjection); - m = mA.GetInverted(); - - mathVec4Transform((f32*)&out, m.GetData(), (f32*)&in); - if (out.w == 0.0f) - { - return NULL; - } - - pvObj->x = out.x / out.w; - pvObj->y = out.y / out.w; - pvObj->z = out.z / out.w; - - return pvObj; -} - - -inline Vec3* mathVec3ProjectArray(Vec3* pOut, uint32 OutStride, const Vec3* pV, uint32 VStride, const int32 pViewport[4], const Matrix44A* pProjection, const Matrix44A* pView, const Matrix44A* pWorld, uint32 n, int32) -{ - Matrix44A m; - Vec4 in, out; - - int8* pOutT = (int8*)pOut; - int8* pInT = (int8*)pV; - - Vec3* pvWin; - Vec3* pvObj; - - //FIX: update fViewportMinZ fViewportMaxZ support for Viewport everywhere - float fViewportMinZ = 0, fViewportMaxZ = 1.0f; - - m = ((*pWorld) * (*pView)) * (*pProjection); - - for (uint32 i = 0; i < n; i++) - { - pvObj = (Vec3*)pInT; - pvWin = (Vec3*)pOutT; - - in.x = pvObj->x; - in.y = pvObj->y; - in.z = pvObj->z; - in.w = 1.0f; - - mathVec4Transform((f32*)&out, m.GetData(), (f32*)&in); - - if (out.w == 0.0f) - { - return NULL; - } - - float fInvW = 1.0f / out.w; - out.x *= fInvW; - out.y *= fInvW; - out.z *= fInvW; - - //output coords - pvWin->x = pViewport[0] + (1 + out.x) * pViewport[2] / 2; - pvWin->y = pViewport[1] + (1 - out.y) * pViewport[3] / 2; //flip coords for y axis - - pvWin->z = fViewportMinZ + out.z * (fViewportMaxZ - fViewportMinZ); - - pOutT += OutStride; - pInT += VStride; - } - - return pOut; -} - - -inline Vec3* mathVec3UnprojectArray(Vec3* pOut, uint32 OutStride, const Vec3* pV, uint32 VStride, const int32 pViewport[4], const Matrix44* pProjection, const Matrix44* pView, const Matrix44* pWorld, uint32 n, [[maybe_unused]] int32 OptFlags) -{ - Vec4 in, out; - Matrix44 m, mA; - - int8* pOutT = (int8*)pOut; - int8* pInT = (int8*)pV; - - Vec3* pvWin; - Vec3* pvObj; - - //FIX: update fViewportMinZ fViewportMaxZ support for Viewport everywhere - float fViewportMinZ = 0, fViewportMaxZ = 1.0f; - - mA = ((*pWorld) * (*pView)) * (*pProjection); - m = mA.GetInverted(); - - for (uint32 i = 0; i < n; i++) - { - pvWin = (Vec3*)pInT; - pvObj = (Vec3*)pOutT; - - in.x = (pvWin->x - pViewport[0]) * 2 / pViewport[2] - 1.0f; - in.y = 1.0f - ((pvWin->y - pViewport[1]) * 2 / pViewport[3]); //flip coords for y axis - in.z = (pvWin->z - fViewportMinZ) / (fViewportMaxZ - fViewportMinZ); - in.w = 1.0f; - - mathVec4Transform((f32*)&out, m.GetData(), (f32*)&in); - - assert(out.w != 0.0f); - - if (out.w == 0.0f) - { - return NULL; - } - - pvObj->x = out.x / out.w; - pvObj->y = out.y / out.w; - pvObj->z = out.z / out.w; - - pOutT += OutStride; - pInT += VStride; - } - - return pOut; -} - - - - -/***************************************************** -MISC FUNCTIONS -*****************************************************/ - -////////////////////////////////////////////////////////////////////////// -#if defined(_CPU_X86) -inline int fastftol_positive(float f) -{ - int i; - - f -= 0.5f; -#if defined(_MSC_VER) - __asm fld [f] - __asm fistp [i] -#elif defined(__GNUC__) - __asm__ ("fld %[f]\n fistpl %[i]" : [i] "+m" (i) : [f] "m" (f)); -#else -#error -#endif - return i; -} -#else -inline int fastftol_positive (float f) -{ - assert(f >= 0.f); - return (int)floorf(f); -} -#endif - - - -////////////////////////////////////////////////////////////////////////// -#if defined(_CPU_X86) -inline int fastround_positive(float f) -{ - int i; - assert(f >= 0.f); -#if defined(_MSC_VER) - __asm fld [f] - __asm fistp [i] -#elif defined(__GNUC__) - __asm__ ("fld %[f]\n fistpl %[i]" : [i] "+m" (i) : [f] "m" (f)); -#else -#error -#endif - return i; -} -#else -inline int fastround_positive(float f) -{ - assert(f >= 0.f); - return (int) (f + 0.5f); -} -#endif - - - -////////////////////////////////////////////////////////////////////////// -#if defined(_CPU_X86) -ILINE int __fastcall FtoI(float x) -{ - int t; -#if defined(_MSC_VER) - __asm - { - fld x - fistp t - } -#elif defined(__GNUC__) - __asm__ ("fld %[x]\n fistpl %[t]" : [t] "+m" (t) : [x] "m" (x)); -#else -#error -#endif - return t; -} -#else -inline int FtoI(float x) { return (int)x; } -#endif - -#endif // CRYINCLUDE_CRYCOMMON_CRY_XOPTIMISE_H - diff --git a/Code/Legacy/CryCommon/HeapAllocator.h b/Code/Legacy/CryCommon/HeapAllocator.h deleted file mode 100644 index da5d23e06f..0000000000 --- a/Code/Legacy/CryCommon/HeapAllocator.h +++ /dev/null @@ -1,457 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - - -#ifndef CRYINCLUDE_CRYCOMMON_HEAPALLOCATOR_H -#define CRYINCLUDE_CRYCOMMON_HEAPALLOCATOR_H -#pragma once - - -#include "Synchronization.h" -#include "Options.h" - -#include - -//--------------------------------------------------------------------------- -#define bMEM_ACCESS_CHECK 0 -#define bMEM_HEAP_CHECK 0 - -namespace stl -{ - class HeapSysAllocator - { - public: - static void* SysAlloc(size_t nSize) - { return CryModuleMalloc(nSize); } - static void SysDealloc(void* ptr) - { CryModuleFree(ptr); } - }; - - class GlobalHeapSysAllocator - { - public: - static void* SysAlloc(size_t nSize) - { - return CryModuleMalloc(nSize); - } - static void SysDealloc(void* ptr) - { - CryModuleFree(ptr); - } - }; - - // Round up to next multiple of nAlign. Handles any positive integer. - inline size_t RoundUpTo(size_t nSize, size_t nAlign) - { - assert(nAlign > 0); - nSize += nAlign - 1; - return nSize - nSize % nAlign; - } - - /*--------------------------------------------------------------------------- - HeapAllocator - A memory pool that can allocate arbitrary amounts of memory of arbitrary size - and alignment. The heap may be freed all at once. Individual block deallocation - is not provided. - - Usable as a base class to implement more general-purpose allocators that - track, free, and reuse individual memory blocks. - - The class can optionally support multi-threading, using the second - template parameter. By default it is multithread-safe. - See Synchronization.h. - - Allocation details: Maintains a linked list of pages. - All pages after first are in order of most free memory first. - Allocations are from the smallest free page available. - - ---------------------------------------------------------------------------*/ - - struct SMemoryUsage - { - size_t nAlloc, nUsed; - - SMemoryUsage(size_t _nAlloc = 0, size_t _nUsed = 0) - : nAlloc(_nAlloc) - , nUsed(_nUsed) - { - Validate(); - } - - size_t nFree() const - { - return nAlloc - nUsed; - } - void Validate() const - { - assert(nUsed <= nAlloc); - } - void Clear() - { - nAlloc = nUsed = 0; - } - - void operator += (SMemoryUsage const& op) - { - nAlloc += op.nAlloc; - nUsed += op.nUsed; - } - }; - - ////////////////////////////////////////////////////////////////////////// - struct FHeap - { - OPT_STRUCT(FHeap) - OPT_VAR(size_t, PageSize); // Pages allocated at this size, or multiple thereof if needed. - OPT_VAR(bool, SinglePage) // Only 1 page allowed (fixed alloc) - OPT_VAR(bool, FreeWhenEmpty) // Release all memory when no longer used - }; - - template - class HeapAllocator - : public FHeap - , public L - , private SysAl - { - public: - - typedef AutoLock Lock; - - enum - { - DefaultAlignment = sizeof(void*) - }; - enum - { - DefaultPageSize = 0x1000 - }; - - private: - - struct PageNode - { - PageNode* pNext; - char* pEndAlloc; - char* pEndUsed; - - char* StartUsed() const - { - return (char*)(this + 1); - } - - PageNode(size_t nAlloc) - { - pNext = 0; - pEndAlloc = (char*)this + nAlloc; - pEndUsed = StartUsed(); - } - - void* Allocate(size_t nSize, size_t nAlign) - { - // Align current mem. - char* pNew = Align(pEndUsed, nAlign); - if (pNew + nSize > pEndAlloc) - { - return 0; - } - pEndUsed = pNew + nSize; - return pNew; - } - - bool CanAllocate(size_t nSize, size_t nAlign) - { - return Align(pEndUsed, nAlign) + nSize <= pEndAlloc; - } - - void Reset() - { - pEndUsed = StartUsed(); - } - - size_t GetMemoryAlloc() const - { - return pEndAlloc - (char*)this; - } - size_t GetMemoryUsed() const - { - return pEndUsed - StartUsed(); - } - size_t GetMemoryFree() const - { - return pEndAlloc - pEndUsed; - } - - void Validate() const - { - assert(pEndAlloc >= (char*)this); - assert(pEndUsed >= StartUsed() && pEndUsed <= pEndAlloc); - } - - bool CheckPtr(void* ptr) const - { - return (char*)ptr >= StartUsed() && (char*)ptr < pEndUsed; - } - }; - - public: - - HeapAllocator(FHeap opts = 0) - : FHeap(opts) - , _pPageList(0) - { - PageSize = max(Align(PageSize, DefaultPageSize), DefaultPageSize); - } - - ~HeapAllocator() - { - Clear(); - } - - // - // Raw memory allocation. - // - void* Allocate(const Lock& lock, size_t nSize, size_t nAlign = DefaultAlignment) - { - for (;; ) - { - // Try allocating from head page first. - if (_pPageList) - { - if (void* ptr = _pPageList->Allocate(nSize, nAlign)) - { - _TotalMem.nUsed += nSize; - return ptr; - } - - if (_pPageList->pNext && _pPageList->pNext->GetMemoryFree() > _pPageList->GetMemoryFree()) - { - SortPage(lock, _pPageList); - Validate(lock); - - // Try allocating from new head, which has the most free memory. - // If this fails, we know no further pages will succeed. - if (void* ptr = _pPageList->Allocate(nSize, nAlign)) - { - _TotalMem.nUsed += nSize; - return ptr; - } - } - if (SinglePage) - { - return 0; - } - } - - // Allocate the new page of the required size. - size_t nAllocSize = Align(sizeof(PageNode), nAlign) + nSize; - nAllocSize = RoundUpTo(nAllocSize, PageSize); - - void* pAlloc = this->SysAlloc(nAllocSize); - PageNode* pPageNode = new(pAlloc) PageNode(nAllocSize); - - // Insert at head of list. - pPageNode->pNext = _pPageList; - _pPageList = pPageNode; - - _TotalMem.nAlloc += nAllocSize; - - Validate(lock); - } - } - - void Deallocate([[maybe_unused]] const Lock& lock, [[maybe_unused]] void* ptr, size_t nSize) - { - // Just to maintain counts, can't reuse memory. - assert(CheckPtr(lock, ptr)); - assert(_TotalMem.nUsed >= nSize); - _TotalMem.nUsed -= nSize; - } - - // - // Templated type allocation. - // - template - T* New(size_t nAlign = 0) - { - void* pMemory = Allocate(Lock(*this), sizeof(T), nAlign ? nAlign : alignof(T)); - return pMemory ? new(pMemory) T : 0; - } - - template - T* NewArray(size_t nCount, size_t nAlign = 0) - { - void* pMemory = Allocate(Lock(*this), sizeof(T) * nCount, nAlign ? nAlign : alignof(T)); - return pMemory ? new(pMemory) T[nCount] : 0; - } - - // - // Maintenance. - // - SMemoryUsage GetTotalMemory(const Lock&) - { - return _TotalMem; - } - SMemoryUsage GetTotalMemory() - { - Lock lock(*this); - return _TotalMem; - } - - // Facility to defer freeing of dead pages during memory release calls. - struct FreeMemLock - : Lock - { - struct PageNode* _pPageList; - - FreeMemLock(L& lock) - : Lock(lock) - , _pPageList(0) {} - - ~FreeMemLock() - { - while (_pPageList != 0) - { - // Read the "next" pointer before deleting. - PageNode* pNext = _pPageList->pNext; - - // Delete the current page. - SysAl::SysDealloc(_pPageList); - - // Move to the next page in the list. - _pPageList = pNext; - } - } - }; - - void Clear(FreeMemLock& lock) - { - // Remove the pages from the object. - Validate(lock); - lock._pPageList = _pPageList; - _pPageList = 0; - _TotalMem.Clear(); - } - - void Clear() - { - FreeMemLock lock(*this); - Clear(lock); - } - - void Reset(const Lock& lock) - { - // Reset all pages, allowing memory re-use. - Validate(lock); - size_t nPrevSize = ~0; - for (PageNode** ppPage = &_pPageList; *ppPage; ) - { - (*ppPage)->Reset(); - if ((*ppPage)->GetMemoryAlloc() > nPrevSize) - { - // Move page to sorted location near beginning. - SortPage(lock, *ppPage); - - // ppPage is now next page, so continue loop. - continue; - } - nPrevSize = (*ppPage)->GetMemoryAlloc(); - ppPage = &(*ppPage)->pNext; - } - _TotalMem.nUsed = 0; - Validate(lock); - } - - void Reset() - { - Reset(Lock(*this)); - } - - // - // Validation. - // - bool CheckPtr(const Lock&, void* ptr) const - { - if (!ptr) - { - return true; - } - for (PageNode* pNode = _pPageList; pNode; pNode = pNode->pNext) - { - if (pNode->CheckPtr(ptr)) - { - return true; - } - } - return false; - } - - void Validate(const Lock&) const - { - #ifdef _DEBUG - // Check page validity, and memory counts. - SMemoryUsage MemCheck; - - for (PageNode* pPage = _pPageList; pPage; pPage = pPage->pNext) - { - pPage->Validate(); - if (pPage != _pPageList && pPage->pNext) - { - assert(pPage->GetMemoryFree() >= pPage->pNext->GetMemoryFree()); - } - MemCheck.nAlloc += pPage->GetMemoryAlloc(); - MemCheck.nUsed += pPage->GetMemoryUsed(); - } - assert(MemCheck.nAlloc == _TotalMem.nAlloc); - assert(MemCheck.nUsed >= _TotalMem.nUsed); - #endif - - #if bMEM_HEAP_CHECK - static int nCount = 0, nInterval = 0; - if (nCount++ >= nInterval) - { - nInterval++; - nCount = 0; - } - #endif - } - - void GetMemoryUsage(ICrySizer* pSizer) const - { - Lock lock(non_const(*this)); - for (PageNode* pNode = _pPageList; pNode; pNode = pNode->pNext) - { - pSizer->AddObject(pNode, pNode->GetMemoryAlloc()); - } - } - - private: - - void SortPage(const Lock&, PageNode*& rpPage) - { - // Unlink rpPage. - PageNode* pPage = rpPage; - rpPage = pPage->pNext; - - // Insert into list based on free memory. - PageNode** ppBefore = &_pPageList; - while (*ppBefore && (*ppBefore)->GetMemoryFree() > pPage->GetMemoryFree()) - { - ppBefore = &(*ppBefore)->pNext; - } - - // Link before rpList. - pPage->pNext = *ppBefore; - *ppBefore = pPage; - } - - PageNode* _pPageList; // All allocated pages. - SMemoryUsage _TotalMem; // Track memory allocated and used. - }; -} - -#endif // CRYINCLUDE_CRYCOMMON_HEAPALLOCATOR_H diff --git a/Code/Legacy/CryCommon/IEntityRenderState.h b/Code/Legacy/CryCommon/IEntityRenderState.h index e9f041ba17..c4267b28f2 100644 --- a/Code/Legacy/CryCommon/IEntityRenderState.h +++ b/Code/Legacy/CryCommon/IEntityRenderState.h @@ -6,21 +6,22 @@ * */ - -#ifndef CRYINCLUDE_CRYCOMMON_IENTITYRENDERSTATE_H -#define CRYINCLUDE_CRYCOMMON_IENTITYRENDERSTATE_H #pragma once +#include "IStatObj.h" + #include #include #include + namespace AZ { class Vector2; } struct IMaterial; +struct IRenderNode; struct IVisArea; struct SRenderingPassInfo; struct SRendItemSorter; @@ -576,51 +577,6 @@ struct IVoxelObject // }; -// Summary: -// IFogVolumeRenderNode is an interface to the Fog Volume Render Node object. -struct SFogVolumeProperties -{ - // Common parameters. - // Center position & rotation values are taken from the entity matrix. - - int m_volumeType; - Vec3 m_size; - ColorF m_color; - bool m_useGlobalFogColor; - bool m_ignoresVisAreas; - bool m_affectsThisAreaOnly; - float m_globalDensity; - float m_densityOffset; - float m_softEdges; - float m_fHDRDynamic; // 0 to get the same results in LDR, <0 to get darker, >0 to get brighter. - float m_nearCutoff; - - float m_heightFallOffDirLong; // Height based fog specifics. - float m_heightFallOffDirLati; // Height based fog specifics. - float m_heightFallOffShift; // Height based fog specifics. - float m_heightFallOffScale; // Height based fog specifics. - - float m_rampStart; - float m_rampEnd; - float m_rampInfluence; - float m_windInfluence; - float m_densityNoiseScale; - float m_densityNoiseOffset; - float m_densityNoiseTimeFrequency; - Vec3 m_densityNoiseFrequency; -}; - -struct IFogVolumeRenderNode - : public IRenderNode -{ - // - virtual void SetFogVolumeProperties(const SFogVolumeProperties& properties) = 0; - virtual const Matrix34& GetMatrix() const = 0; - - virtual void FadeGlobalDensity(float fadeTime, float newGlobalDensity) = 0; - // -}; - // LY renderer system spec levels. enum class EngineSpec : AZ::u32 { @@ -630,159 +586,3 @@ enum class EngineSpec : AZ::u32 VeryHigh, Never = UINT_MAX, }; - -struct SDecalProperties -{ - SDecalProperties() - { - m_projectionType = ePlanar; - m_sortPrio = 0; - m_deferred = false; - m_pos = Vec3(0.0f, 0.0f, 0.0f); - m_normal = Vec3(0.0f, 0.0f, 1.0f); - m_explicitRightUpFront = Matrix33::CreateIdentity(); - m_radius = 1.0f; - m_depth = 1.0f; - m_opacity = 1.0f; - m_angleAttenuation = 1.0f; - m_maxViewDist = 8000.0f; - m_minSpec = EngineSpec::Low; - } - - enum EProjectionType : int - { - ePlanar, - eProjectOnTerrain, - eProjectOnTerrainAndStaticObjects - }; - - EProjectionType m_projectionType; - uint8 m_sortPrio; - uint8 m_deferred; - Vec3 m_pos; - Vec3 m_normal; - Matrix33 m_explicitRightUpFront; - float m_radius; - float m_depth; - const char* m_pMaterialName; - float m_opacity; - float m_angleAttenuation; - float m_maxViewDist; - EngineSpec m_minSpec; -}; - -// Description: -// IDecalRenderNode is an interface to the Decal Render Node object. -struct IDecalRenderNode - : public IRenderNode -{ - // - virtual void SetDecalProperties(const SDecalProperties& properties) = 0; - virtual const SDecalProperties* GetDecalProperties() const = 0; - virtual const Matrix34& GetMatrix() = 0; - virtual void CleanUpOldDecals() = 0; - // -}; - -// Description: -// IWaterVolumeRenderNode is an interface to the Water Volume Render Node object. -struct IWaterVolumeRenderNode - : public IRenderNode -{ - enum EWaterVolumeType - { - eWVT_Unknown, - eWVT_Ocean, - eWVT_Area, - eWVT_River - }; - - // - // Description: - // Sets if the render node is attached to a parent entity - // This must be called right after the object construction if it is the case - // Only supported for Areas (not rivers or ocean) - virtual void SetAreaAttachedToEntity() = 0; - - virtual void SetFogDensity(float fogDensity) = 0; - virtual float GetFogDensity() const = 0; - virtual void SetFogColor(const Vec3& fogColor) = 0; - virtual void SetFogColorAffectedBySun(bool enable) = 0; - virtual void SetFogShadowing(float fogShadowing) = 0; - - virtual void SetCapFogAtVolumeDepth(bool capFog) = 0; - virtual void SetVolumeDepth(float volumeDepth) = 0; - virtual void SetStreamSpeed(float streamSpeed) = 0; - - virtual void SetCaustics(bool caustics) = 0; - virtual void SetCausticIntensity(float causticIntensity) = 0; - virtual void SetCausticTiling(float causticTiling) = 0; - virtual void SetCausticHeight(float causticHeight) = 0; - virtual void SetAuxPhysParams(pe_params_area*) = 0; - - virtual void CreateOcean(uint64 volumeID, /* TBD */ bool keepSerializationParams = false) = 0; - virtual void CreateArea(uint64 volumeID, const Vec3* pVertices, unsigned int numVertices, const Vec2& surfUVScale, const Plane_tpl& fogPlane, bool keepSerializationParams = false, int nSID = -1) = 0; - virtual void CreateRiver(uint64 volumeID, const Vec3* pVertices, unsigned int numVertices, float uTexCoordBegin, float uTexCoordEnd, const Vec2& surfUVScale, const Plane_tpl& fogPlane, bool keepSerializationParams = false, int nSID = -1) = 0; - virtual void CreateRiver(uint64 volumeID, const AZStd::vector& verticies, const AZ::Transform& transform, float uTexCoordBegin, float uTexCoordEnd, const AZ::Vector2& surfUVScale, const AZ::Plane& fogPlane, bool keepSerializationParams = false, int nSID = -1) = 0; - - virtual void SetAreaPhysicsArea(const Vec3* pVertices, unsigned int numVertices, bool keepSerializationParams = false) = 0; - virtual void SetRiverPhysicsArea(const Vec3* pVertices, unsigned int numVertices, bool keepSerializationParams = false) = 0; - virtual void SetRiverPhysicsArea(const AZStd::vector& verticies, const AZ::Transform& transform, bool keepSerializationParams = false) = 0; - - // - - // This flag is used to account for legacy entities which used to serialize the node without parent objects. - // Now there are runtime components which spawn the rendering node, however we need to support legacy code as well. - // Remove this flag when legacy entities are removed entirely - bool m_hasToBeSerialised = true; -}; - -// Description: -// IDistanceCloudRenderNode is an interface to the Distance Cloud Render Node object. -struct SDistanceCloudProperties -{ - Vec3 m_pos; - float m_sizeX; - float m_sizeY; - float m_rotationZ; - const char* m_pMaterialName; -}; - -struct IDistanceCloudRenderNode - : public IRenderNode -{ - virtual void SetProperties(const SDistanceCloudProperties& properties) = 0; -}; - -struct SVolumeObjectProperties -{ -}; - -struct SVolumeObjectMovementProperties -{ - bool m_autoMove; - Vec3 m_speed; - Vec3 m_spaceLoopBox; - float m_fadeDistance; -}; - -// Description: -// IVolumeObjectRenderNode is an interface to the Volume Object Render Node object. -struct IVolumeObjectRenderNode - : public IRenderNode -{ - // - virtual void LoadVolumeData(const char* filePath) = 0; - virtual void SetProperties(const SVolumeObjectProperties& properties) = 0; - virtual void SetMovementProperties(const SVolumeObjectMovementProperties& properties) = 0; - // -}; - -#if !defined(EXCLUDE_DOCUMENTATION_PURPOSE) -struct IPrismRenderNode - : public IRenderNode -{ -}; -#endif // EXCLUDE_DOCUMENTATION_PURPOSE - -#endif // CRYINCLUDE_CRYCOMMON_IENTITYRENDERSTATE_H diff --git a/Code/Legacy/CryCommon/IIndexedMesh.h b/Code/Legacy/CryCommon/IIndexedMesh.h index 87c3df98bd..1c91bb82b8 100644 --- a/Code/Legacy/CryCommon/IIndexedMesh.h +++ b/Code/Legacy/CryCommon/IIndexedMesh.h @@ -15,6 +15,7 @@ #include "Cry_Color.h" #include "StlUtils.h" #include "CryEndian.h" + #include #include // for AABB #include @@ -145,14 +146,6 @@ public: a = othera; } - explicit SMeshColor(const Vec4& otherc) - { - r = aznumeric_caster(FtoI(otherc.x)); - g = aznumeric_caster(FtoI(otherc.y)); - b = aznumeric_caster(FtoI(otherc.z)); - a = aznumeric_caster(FtoI(otherc.w)); - } - void TransferRGBTo(SMeshColor& other) const { other.r = r; @@ -200,18 +193,6 @@ public: otherc = Vec4(r, g, b, a); } - void Lerp(const SMeshColor& other, float pos) - { - Vec4 clrA; - Vec4 clrB; - this->GetRGBA(clrA); - other.GetRGBA(clrB); - - clrA.SetLerp(clrA, clrB, pos); - - *this = SMeshColor(clrA); - } - AUTO_STRUCT_INFO }; @@ -1520,7 +1501,6 @@ public: const int oldVertexCount = GetVertexCount(); const int oldFaceCount = GetFaceCount(); - const int nOldCoorCount = GetTexCoordCount(); if (GetTexCoordCount() != 0 && GetTexCoordCount() != oldVertexCount) { diff --git a/Code/Legacy/CryCommon/IMaterial.h b/Code/Legacy/CryCommon/IMaterial.h index 83f9140be7..e1502b0f1a 100644 --- a/Code/Legacy/CryCommon/IMaterial.h +++ b/Code/Legacy/CryCommon/IMaterial.h @@ -8,10 +8,6 @@ // Description : IMaterial interface declaration. - - -#ifndef CRYINCLUDE_CRYCOMMON_IMATERIAL_H -#define CRYINCLUDE_CRYCOMMON_IMATERIAL_H #pragma once struct ISurfaceType; @@ -19,18 +15,13 @@ struct ISurfaceTypeManager; class ICrySizer; enum EEfResTextures : int; // Need to specify a fixed size for the forward declare to work on clang -struct IRenderShaderResources; -struct SEfTexModificator; -struct SInputShaderResources; struct SShaderItem; struct SShaderParam; struct IShader; -struct IShaderPublicParams; struct IMaterial; struct IMaterialManager; struct CMaterialCGF; -struct CRenderChunk; struct IRenderMesh; #include @@ -162,90 +153,6 @@ enum EMaterialCopyFlags MTL_COPY_TEXTURES = BIT(1), }; -struct IMaterialHelpers -{ - virtual ~IMaterialHelpers() {} - - ////////////////////////////////////////////////////////////////////////// - virtual EEfResTextures FindTexSlot(const char* texName) const = 0; - virtual const char* FindTexName(EEfResTextures texSlot) const = 0; - virtual const char* LookupTexName(EEfResTextures texSlot) const = 0; - virtual const char* LookupTexDesc(EEfResTextures texSlot) const = 0; - virtual const char* LookupTexEnum(EEfResTextures texSlot) const = 0; - virtual const char* LookupTexSuffix(EEfResTextures texSlot) const = 0; - virtual bool IsAdjustableTexSlot(EEfResTextures texSlot) const = 0; - - ////////////////////////////////////////////////////////////////////////// - virtual bool SetGetMaterialParamFloat(IRenderShaderResources& pShaderResources, const char* sParamName, float& v, bool bGet) const = 0; - virtual bool SetGetMaterialParamVec3(IRenderShaderResources& pShaderResources, const char* sParamName, Vec3& v, bool bGet) const = 0; - - ////////////////////////////////////////////////////////////////////////// - virtual void SetTexModFromXml(SEfTexModificator& pShaderResources, const XmlNodeRef& node) const = 0; - virtual void SetXmlFromTexMod(const SEfTexModificator& pShaderResources, XmlNodeRef& node) const = 0; - - ////////////////////////////////////////////////////////////////////////// - virtual void SetTexturesFromXml(SInputShaderResources& pShaderResources, const XmlNodeRef& node) const = 0; - virtual void SetXmlFromTextures( SInputShaderResources& pShaderResources, XmlNodeRef& node) const = 0; - - ////////////////////////////////////////////////////////////////////////// - virtual void SetVertexDeformFromXml(SInputShaderResources& pShaderResources, const XmlNodeRef& node) const = 0; - virtual void SetXmlFromVertexDeform(const SInputShaderResources& pShaderResources, XmlNodeRef& node) const = 0; - - ////////////////////////////////////////////////////////////////////////// - virtual void SetLightingFromXml(SInputShaderResources& pShaderResources, const XmlNodeRef& node) const = 0; - virtual void SetXmlFromLighting(const SInputShaderResources& pShaderResources, XmlNodeRef& node) const = 0; - - ////////////////////////////////////////////////////////////////////////// - virtual void SetShaderParamsFromXml(SInputShaderResources& pShaderResources, const XmlNodeRef& node) const = 0; - virtual void SetXmlFromShaderParams(const SInputShaderResources& pShaderResources, XmlNodeRef& node) const = 0; - - ////////////////////////////////////////////////////////////////////////// - virtual void MigrateXmlLegacyData(SInputShaderResources& pShaderResources, const XmlNodeRef& node) const = 0; -}; - -////////////////////////////////////////////////////////////////////////////////////// -// Description: -// IMaterialLayer is group of material layer properties. -// Each layer is composed of shader item, specific layer textures, lod info, etc -struct IMaterialLayer -{ - // - virtual ~IMaterialLayer(){} - // Reference counting - virtual void AddRef() = 0; - virtual void Release() = 0; - - // Description: - // - Enable/disable layer usage - virtual void Enable(bool bEnable = true) = 0; - // Description: - // - Check if layer enabled - virtual bool IsEnabled() const = 0; - // Description: - // - Enable/disable fade out - virtual void FadeOut(bool bFadeOut = true) = 0; - // Description: - // - Check if layer fades out - virtual bool DoesFadeOut() const = 0; - // Description: - // - Set shader item - virtual void SetShaderItem(const _smart_ptr pParentMtl, const SShaderItem& pShaderItem) = 0; - // Description: - // - Return shader item - virtual const SShaderItem& GetShaderItem() const = 0; - virtual SShaderItem& GetShaderItem() = 0; - // Description: - // - Set layer usage flags - virtual void SetFlags(uint8 nFlags) = 0; - // Description: - // - Get layer usage flags - virtual uint8 GetFlags() const = 0; - - // todo: layer specific textures support - // - // -}; - struct IMaterial { // TODO: Remove it! @@ -254,7 +161,7 @@ struct IMaterial float m_fDefautMappingScale; // - virtual ~IMaterial() {}; + virtual ~IMaterial() {} ////////////////////////////////////////////////////////////////////////// // Reference counting. @@ -263,7 +170,6 @@ struct IMaterial virtual void Release() = 0; virtual int GetNumRefs() = 0; - virtual IMaterialHelpers& GetMaterialHelpers() = 0; virtual IMaterialManager* GetMaterialManager() = 0; ////////////////////////////////////////////////////////////////////////// @@ -295,10 +201,6 @@ struct IMaterial virtual ISurfaceType* GetSurfaceType() = 0; // shader item - virtual void ReleaseCurrentShaderItem() = 0; - virtual void SetShaderItem(const SShaderItem& _ShaderItem) = 0; - // [Alexey] EF_LoadShaderItem return value with RefCount = 1, so if you'll use SetShaderItem after EF_LoadShaderItem use Assign function - virtual void AssignShaderItem(const SShaderItem& _ShaderItem) = 0; virtual SShaderItem& GetShaderItem() = 0; virtual const SShaderItem& GetShaderItem() const = 0; @@ -310,41 +212,6 @@ struct IMaterial // Returns true if streamed in virtual bool IsStreamedIn(const int nMinPrecacheRoundIds[MAX_STREAM_PREDICTION_ZONES], IRenderMesh* pRenderMesh) const = 0; - ////////////////////////////////////////////////////////////////////////// - // Sub materials access. - ////////////////////////////////////////////////////////////////////////// - //! Returns number of child sub materials holded by this material. - virtual void SetSubMtlCount(int numSubMtl) = 0; - //! Returns number of child sub materials holded by this material. - virtual int GetSubMtlCount() = 0; - //! Return sub material at specified index. - virtual _smart_ptr GetSubMtl(int nSlot) = 0; - // Assign material to the sub mtl slot. - // Must first allocate slots using SetSubMtlCount. - virtual void SetSubMtl(int nSlot, _smart_ptr pMtl) = 0; - - ////////////////////////////////////////////////////////////////////////// - // Layers access. - ////////////////////////////////////////////////////////////////////////// - //! Returns number of layers in this material. - virtual void SetLayerCount(uint32 nCount) = 0; - //! Returns number of layers in this material. - virtual uint32 GetLayerCount() const = 0; - //! Set layer at slot id (### MUST ALOCATE SLOTS FIRST ### USING SetLayerCount) - virtual void SetLayer(uint32 nSlot, IMaterialLayer* pLayer) = 0; - //! Return active layer - virtual const IMaterialLayer* GetLayer(uint8 nLayersMask, uint8 nLayersUsageMask) const = 0; - //! Return layer at slot id - virtual const IMaterialLayer* GetLayer(uint32 nSlot) const = 0; - //! Create a new layer - virtual IMaterialLayer* CreateLayer() = 0; - - ////////////////////////////////////////////////////////////////////////// - // Always get a valid material. - // If not multi material return this material. - // If Multi material return Default material if wrong id. - virtual _smart_ptr GetSafeSubMtl(int nSlot) = 0; - // Description: // Fill an array of integeres representing surface ids of the sub materials or the material itself. // Arguments: @@ -567,12 +434,5 @@ struct IMaterialManager // Updates material data in the renderer virtual void RefreshMaterialRuntime() = 0; - //// Forcing to create ISurfaceTypeManager - //virtual void CreateSurfaceTypeManager() = 0; - //// Forcing to destroy ISurfaceTypeManager - //virtual void ReleaseSurfaceTypeManager() = 0; - // }; - -#endif // CRYINCLUDE_CRYCOMMON_IMATERIAL_H diff --git a/Code/Legacy/CryCommon/IMovieSystem.h b/Code/Legacy/CryCommon/IMovieSystem.h index 915dc925bf..5d878c45ec 100644 --- a/Code/Legacy/CryCommon/IMovieSystem.h +++ b/Code/Legacy/CryCommon/IMovieSystem.h @@ -20,10 +20,8 @@ #include #include #include -#include -#include +#include #include -#include // forward declaration. struct IAnimTrack; @@ -116,7 +114,7 @@ public: { *this = name; } - + CAnimParamType(AnimParamType type) { *this = type; @@ -378,7 +376,7 @@ struct IAnimTrack virtual int GetSubTrackCount() const = 0; // Retrieve pointer the specfied sub track. virtual IAnimTrack* GetSubTrack(int nIndex) const = 0; - virtual const char* GetSubTrackName(int nIndex) const = 0; + virtual AZStd::string GetSubTrackName(int nIndex) const = 0; virtual void SetSubTrackName(int nIndex, const char* name) = 0; ////////////////////////////////////////////////////////////////////////// @@ -625,7 +623,7 @@ public: , valueType(_valueType) , flags(_flags) {}; - const char* name; // parameter name. + AZStd::string name; // parameter name. CAnimParamType paramType; // parameter id. AnimValueType valueType; // value type, defines type of track to use for animating this parameter. ESupportedParamFlags flags; // combination of flags from ESupportedParamFlags. @@ -738,7 +736,7 @@ public: // Returns name of supported parameter of this animation node or NULL if not available // Arguments: // paramType - parameter id - virtual const char* GetParamName(const CAnimParamType& paramType) const = 0; + virtual AZStd::string GetParamName(const CAnimParamType& paramType) const = 0; // Description: // Returns the params value type @@ -838,7 +836,7 @@ public: // override this method to handle explicit setting of time virtual void TimeChanged([[maybe_unused]] float newTime) {}; - // Compares all of the node's track values at the given time with the associated property value and + // Compares all of the node's track values at the given time with the associated property value and // sets a key at that time if they are different to match the latter // Returns the number of keys set virtual int SetKeysForChangedTrackValues([[maybe_unused]] float time) { return 0; }; @@ -1309,7 +1307,7 @@ struct IMovieSystem // Disable Fixed Step cvars and return to previous settings virtual void DisableFixedStepForCapture() = 0; - + // Signal the capturing start. virtual void StartCapture(const ICaptureKey& key, int frame) = 0; diff --git a/Code/Legacy/CryCommon/INavigationSystem.h b/Code/Legacy/CryCommon/INavigationSystem.h index 6253f815bf..f88fccafff 100644 --- a/Code/Legacy/CryCommon/INavigationSystem.h +++ b/Code/Legacy/CryCommon/INavigationSystem.h @@ -11,10 +11,12 @@ #define CRYINCLUDE_CRYCOMMON_INAVIGATIONSYSTEM_H #pragma once +#include "CryCommon/Cry_Geo.h" + #include #include -#include +#include struct IOffMeshNavigationManager; @@ -47,7 +49,6 @@ typedef TNavigationID NavigationMeshID; typedef TNavigationID NavigationAgentTypeID; typedef TNavigationID NavigationVolumeID; typedef AZStd::function NavigationMeshChangeCallback; -typedef AZStd::function NavigationMeshEntityCallback; struct INavigationSystemUser { @@ -141,7 +142,6 @@ struct INavigationSystem virtual NavigationMeshID CreateMesh(const char* name, NavigationAgentTypeID agentTypeID, const CreateMeshParams& params, NavigationMeshID requestedID) = 0; virtual void DestroyMesh(NavigationMeshID meshID) = 0; - virtual void SetMeshEntityCallback(NavigationAgentTypeID agentTypeID, const NavigationMeshEntityCallback& callback) = 0; virtual void AddMeshChangeCallback(NavigationAgentTypeID agentTypeID, const NavigationMeshChangeCallback& callback) = 0; virtual void RemoveMeshChangeCallback(NavigationAgentTypeID agentTypeID, const NavigationMeshChangeCallback& callback) = 0; diff --git a/Code/Legacy/CryCommon/IPhysics.h b/Code/Legacy/CryCommon/IPhysics.h index f2097ddf36..a1825d3e44 100644 --- a/Code/Legacy/CryCommon/IPhysics.h +++ b/Code/Legacy/CryCommon/IPhysics.h @@ -7,22 +7,11 @@ */ -#ifndef CRYINCLUDE_CRYCOMMON_IPHYSICS_H -#define CRYINCLUDE_CRYCOMMON_IPHYSICS_H #pragma once - - -// -#ifdef PHYSICS_EXPORTS - #define CRYPHYSICS_API DLL_EXPORT -#else - #define CRYPHYSICS_API DLL_IMPORT -#endif - -#define vector_class Vec3_tpl - - #include +#include "Cry_Math.h" +#include "primitives.h" +#include // <> required for Interfuscator ////////////////////////////////////////////////////////////////////////// // IDs that can be used for foreign id. @@ -47,12 +36,3 @@ enum EPhysicsForeignIds PHYS_FOREIGN_ID_USER = 100, // All user defined foreign ids should start from this enum. }; - - -//#include "utils.h" -#include "Cry_Math.h" -#include "primitives.h" -#include // <> required for Interfuscator - - -#endif // CRYINCLUDE_CRYCOMMON_IPHYSICS_H diff --git a/Code/Legacy/CryCommon/IRenderAuxGeom.h b/Code/Legacy/CryCommon/IRenderAuxGeom.h index ab3c1036d5..d487cb483f 100644 --- a/Code/Legacy/CryCommon/IRenderAuxGeom.h +++ b/Code/Legacy/CryCommon/IRenderAuxGeom.h @@ -6,16 +6,12 @@ * */ - -#ifndef CRYINCLUDE_CRYCOMMON_IRENDERAUXGEOM_H -#define CRYINCLUDE_CRYCOMMON_IRENDERAUXGEOM_H #pragma once - -struct SAuxGeomRenderFlags; - +#include "Cry_Color.h" #include "IRenderer.h" +struct SAuxGeomRenderFlags; enum EBoundingBoxDrawStyle { @@ -833,6 +829,3 @@ inline CRenderAuxGeomRenderFlagsRestore::~CRenderAuxGeomRenderFlagsRestore() { m_pRender->SetRenderFlags(m_backuppedRenderFlags); } - - -#endif // CRYINCLUDE_CRYCOMMON_IRENDERAUXGEOM_H diff --git a/Code/Legacy/CryCommon/IRenderMesh.h b/Code/Legacy/CryCommon/IRenderMesh.h index 062c949043..0e225579ad 100644 --- a/Code/Legacy/CryCommon/IRenderMesh.h +++ b/Code/Legacy/CryCommon/IRenderMesh.h @@ -13,18 +13,15 @@ #include "VertexFormats.h" #include -#include #include // PublicRenderPrimitiveType #include #include #include class CMesh; -struct CRenderChunk; class CRenderObject; struct SSkinningData; struct IMaterial; -struct IShader; struct IIndexedMesh; struct SMRendTexVert; struct UCol; @@ -127,7 +124,7 @@ struct IRenderMesh , pNormals(0) , pIndices(0) , nIndexCount(0) - , nPrimetiveType(prtTriangleList) + , nPrimetiveType(PublicRenderPrimitiveType::prtTriangleList) , nRenderChunkCount(0) , nClientTextureBindID(0) , bOnlyVideoBuffer(false) @@ -182,8 +179,6 @@ struct IRenderMesh virtual bool CheckUpdate(uint32 nStreamMask) = 0; virtual int GetStreamStride(int nStream) const = 0; - virtual const uintptr_t GetVBStream(int nStream) const = 0; - virtual const uintptr_t GetIBStream() const = 0; virtual int GetNumVerts() const = 0; virtual int GetNumInds() const = 0; virtual const eRenderPrimitiveType GetPrimitiveType() const = 0; @@ -207,33 +202,24 @@ struct IRenderMesh virtual bool UpdateVertices(const void* pVertBuffer, int nVertCount, int nOffset, int nStream, uint32 copyFlags, bool requiresLock = true) = 0; virtual bool UpdateIndices(const vtx_idx* pNewInds, int nInds, int nOffsInd, uint32 copyFlags, bool requiresLock = true) = 0; virtual void SetCustomTexID(int nCustomTID) = 0; - virtual void SetChunk(int nIndex, CRenderChunk& chunk) = 0; - virtual void SetChunk(_smart_ptr pNewMat, int nFirstVertId, int nVertCount, int nFirstIndexId, int nIndexCount, float texelAreaDensity, const AZ::Vertex::Format& vertexFormat, int nMatID = 0) = 0; - - // Assign array of render chunks. - // Initializes render element for each render chunk. - virtual void SetRenderChunks(CRenderChunk* pChunksArray, int nCount, bool bSubObjectChunks) = 0; virtual void GenerateQTangents() = 0; virtual void CreateChunksSkinned() = 0; virtual void NextDrawSkinned() = 0; virtual IRenderMesh* GetVertexContainer() = 0; virtual void SetVertexContainer(IRenderMesh* pBuf) = 0; - virtual TRenderChunkArray& GetChunks() = 0; - virtual TRenderChunkArray& GetChunksSkinned() = 0; - virtual TRenderChunkArray& GetChunksSubObjects() = 0; virtual void SetBBox(const Vec3& vBoxMin, const Vec3& vBoxMax) = 0; virtual void GetBBox(Vec3& vBoxMin, Vec3& vBoxMax) = 0; virtual void UpdateBBoxFromMesh() = 0; virtual uint32* GetPhysVertexMap() = 0; virtual bool IsEmpty() = 0; - virtual byte* GetPosPtrNoCache(int32& nStride, uint32 nFlags) = 0; - virtual byte* GetPosPtr(int32& nStride, uint32 nFlags) = 0; - virtual byte* GetColorPtr(int32& nStride, uint32 nFlags) = 0; - virtual byte* GetNormPtr(int32& nStride, uint32 nFlags) = 0; + virtual int8* GetPosPtrNoCache(int32& nStride, uint32 nFlags) = 0; + virtual int8* GetPosPtr(int32& nStride, uint32 nFlags) = 0; + virtual int8* GetColorPtr(int32& nStride, uint32 nFlags) = 0; + virtual int8* GetNormPtr(int32& nStride, uint32 nFlags) = 0; //! Returns a pointer to the first uv coordinate in the interleaved vertex stream - virtual byte* GetUVPtrNoCache(int32& nStride, uint32 nFlags, uint32 uvSetIndex = 0) = 0; + virtual int8* GetUVPtrNoCache(int32& nStride, uint32 nFlags, uint32 uvSetIndex = 0) = 0; /*! Get a pointer to the mesh's uv coordinates and the stride from the beginning of one uv coordinate to the next \param[out] nStride The stride in between successive uv coordinates. \param nFlags Stream lock flags (FSL_READ, FSL_WRITE, etc) @@ -242,13 +228,13 @@ struct IRenderMesh Either way, nStride is set such that the caller can use it to iterate over the data in the same way regardless of which pointer was returned Returns nullptr if there is no uv coordinate stream at the given index */ - virtual byte* GetUVPtr(int32& nStride, uint32 nFlags, uint32 uvSetIndex = 0) = 0; + virtual int8* GetUVPtr(int32& nStride, uint32 nFlags, uint32 uvSetIndex = 0) = 0; - virtual byte* GetTangentPtr(int32& nStride, uint32 nFlags) = 0; - virtual byte* GetQTangentPtr(int32& nStride, uint32 nFlags) = 0; + virtual int8* GetTangentPtr(int32& nStride, uint32 nFlags) = 0; + virtual int8* GetQTangentPtr(int32& nStride, uint32 nFlags) = 0; - virtual byte* GetHWSkinPtr(int32& nStride, uint32 nFlags, bool remapped = false) = 0; - virtual byte* GetVelocityPtr(int32& nStride, uint32 nFlags) = 0; + virtual int8* GetHWSkinPtr(int32& nStride, uint32 nFlags, bool remapped = false) = 0; + virtual int8* GetVelocityPtr(int32& nStride, uint32 nFlags) = 0; virtual void UnlockStream(int nStream) = 0; virtual void UnlockIndexStream() = 0; @@ -261,8 +247,6 @@ struct IRenderMesh virtual void Render(const struct SRendParams& rParams, CRenderObject* pObj, _smart_ptr pMaterial, const SRenderingPassInfo& passInfo, bool bSkinned = false) = 0; virtual void Render(CRenderObject* pObj, const SRenderingPassInfo& passInfo, const SRendItemSorter& rendItemSorter) = 0; - virtual void AddRenderElements(_smart_ptr pIMatInfo, CRenderObject* pObj, const SRenderingPassInfo& passInfo, int nSortId = EFSLIST_GENERAL, int nAW = 1) = 0; - virtual void AddRE(_smart_ptr pMaterial, CRenderObject* pObj, IShader* pEf, const SRenderingPassInfo& passInfo, int nList, int nAW, const SRendItemSorter& rendItemSorter) = 0; virtual void SetREUserData(float* pfCustomData, float fFogScale = 0, float fAlpha = 1) = 0; // Debug draw this render mesh. @@ -295,15 +279,4 @@ struct IRenderMesh // }; -struct SBufferStream -{ - void* m_pLocalData; // pointer to buffer data - uintptr_t m_BufferHdl; - SBufferStream() - { - m_pLocalData = NULL; - m_BufferHdl = ~0u; - } -}; - #endif // CRYINCLUDE_CRYCOMMON_IRENDERMESH_H diff --git a/Code/Legacy/CryCommon/IRenderer.h b/Code/Legacy/CryCommon/IRenderer.h index 254f1933de..ab185b3bbc 100644 --- a/Code/Legacy/CryCommon/IRenderer.h +++ b/Code/Legacy/CryCommon/IRenderer.h @@ -9,481 +9,13 @@ #pragma once -#include "Cry_Geo.h" #include "Cry_Camera.h" -#include "ITexture.h" -#include "Cry_Vector2.h" -#include "Cry_Vector3.h" -#include "Cry_Matrix33.h" -#include "Cry_Color.h" -#include "smartptr.h" -#include // <> required for Interfuscator -#include "smartptr.h" +#include "VertexFormats.h" + #include #include -// forward declarations -struct SRenderingPassInfo; -struct SRTStack; -struct SFogVolumeData; -// Callback used for DXTCompress -typedef void (* MIPDXTcallback)(const void* buffer, size_t count, void* userData); - -typedef void (* GpuCallbackFunc)(DWORD context); - -// Callback for shadercache miss -typedef void (* ShaderCacheMissCallback)(const char* acShaderRequest); - -struct ICaptureFrameListener -{ - virtual ~ICaptureFrameListener (){} - virtual bool OnNeedFrameData(unsigned char*& pConvertedTextureBuf) = 0; - virtual void OnFrameCaptured(void) = 0; - virtual int OnGetFrameWidth(void) = 0; - virtual int OnGetFrameHeight(void) = 0; - virtual int OnCaptureFrameBegin(int* pTexHandle) = 0; - - enum ECaptureFrameFlags - { - eCFF_NoCaptureThisFrame = (0 << 1), - eCFF_CaptureThisFrame = (1 << 1), - }; -}; - -// Forward declarations. -////////////////////////////////////////////////////////////////////// -typedef void* WIN_HWND; -typedef void* WIN_HINSTANCE; -typedef void* WIN_HDC; -typedef void* WIN_HGLRC; - -class CREMesh; -class CMesh; -//class CImage; -struct CStatObj; -class CVegetation; -struct ShadowMapFrustum; -struct IStatObj; -class CObjManager; -struct SPrimitiveGroup; -class CRendElementBase; -class CRenderObject; -class CTexMan; -//class ColorF; -class CShadowVolEdge; -class CCamera; -class CDLight; -struct SDeferredLightVolume; -struct ILog; -struct IConsole; -struct ICVar; -struct ITimer; -struct ISystem; -class IGPUParticleEngine; -class ICrySizer; -struct IRenderAuxGeom; -struct SREPointSpriteCreateParams; -struct SPointSpriteVertex; -struct RenderLMData; -struct SShaderParam; -struct SSkyLightRenderParams; -struct SParticleRenderInfo; -struct SParticleAddJobCompare; -struct IColorGradingController; -class IStereoRenderer; -struct IFFont; -struct IFFont_RenderProxy; -struct STextDrawContext; -struct IRenderMesh; -struct ShadowFrustumMGPUCache; -struct IAsyncTextureCompileListener; -struct IClipVolume; -struct SClipVolumeBlendInfo; -class CRenderView; -struct SDynTexture2; -class CTexture; -enum ETexPool : int; - -////////////////////////////////////////////////////////////////////// -typedef unsigned char bvec4[4]; -typedef float vec4_t[4]; -typedef unsigned char byte; -typedef float vec2_t[2]; - -//DOC-IGNORE-BEGIN -#include "Cry_Color.h" -#include "Tarray.h" - -#include -//DOC-IGNORE-END - -#define MAX_NUM_VIEWPORTS 7 - -// Query types for CryInd editor (used in EF_Query() function). -enum ERenderQueryTypes -{ - EFQ_DeleteMemoryArrayPtr = 1, - EFQ_DeleteMemoryPtr, - EFQ_GetShaderCombinations, - EFQ_SetShaderCombinations, - EFQ_CloseShaderCombinations, - - EFQ_MainThreadList, - EFQ_RenderThreadList, - EFQ_RenderMultithreaded, - - EFQ_RecurseLevel, - EFQ_IncrementFrameID, - EFQ_DeviceLost, - EFQ_LightSource, - - EFQ_Alloc_APITextures, - EFQ_Alloc_APIMesh, - - // Memory allocated by meshes in system memory. - EFQ_Alloc_Mesh_SysMem, - EFQ_Mesh_Count, - - EFQ_HDRModeEnabled, - EFQ_ParticlesTessellation, - EFQ_WaterTessellation, - EFQ_MeshTessellation, - EFQ_GetShadowPoolFrustumsNum, - EFQ_GetShadowPoolAllocThisFrameNum, - EFQ_GetShadowMaskChannelsNum, - EFQ_GetTiledShadingSkippedLightsNum, - - // Description: - // Query will return all textures in the renderer, - // pass pointer to an SRendererQueryGetAllTexturesParam instance - EFQ_GetAllTextures, - - // Description: - // Release resources allocated by GetAllTextures query - // pass pointer to an SRendererQueryGetAllTexturesParam instance, populated by EFQ_GetAllTextures - EFQ_GetAllTexturesRelease, - - // Description: - // Query will return all IRenderMesh objects in the renderer, - // Pass an array pointer to be allocated and filled with the IRendermesh pointers. The calling function is responsible for freeing this memory. - // This was originally a two pass process, but proved to be non-thread-safe, leading to buffer overruns and underruns. - EFQ_GetAllMeshes, - - // Summary: - // Multigpu (crossfire/sli) is enabled. - EFQ_MultiGPUEnabled, - EFQ_SetDrawNearFov, - EFQ_GetDrawNearFov, - EFQ_TextureStreamingEnabled, - EFQ_MSAAEnabled, - EFQ_AAMode, - - EFQ_Fullscreen, - EFQ_GetTexStreamingInfo, - EFQ_GetMeshPoolInfo, - - // Description: - // True when shading is done in linear space, de-gamma on texture lookup, gamma on frame buffer writing (sRGB), false otherwise. - EFQ_sLinearSpaceShadingEnabled, - - // The percentages of overscan borders for left/right and top/bottom to adjust the title safe area. - EFQ_OverscanBorders, - - // Get num active post effects - EFQ_NumActivePostEffects, - - // Get size of textures memory pool - EFQ_TexturesPoolSize, - EFQ_RenderTargetPoolSize, - - EFQ_GetShaderCacheInfo, - - EFQ_GetFogCullDistance, - EFQ_GetMaxRenderObjectsNum, - - EFQ_IsRenderLoadingThreadActive, - - EFQ_GetSkinningDataPoolSize, - - EFQ_GetViewportDownscaleFactor, - EFQ_ReverseDepthEnabled, - - EFQ_GetLastD3DDebugMessage -}; - -struct ID3DDebugMessage -{ -public: - virtual void Release() = 0; - virtual const char* GetMessage() const = 0; - -protected: - ID3DDebugMessage() {} - virtual ~ID3DDebugMessage() {} -}; - -enum EScreenAspectRatio -{ - eAspect_Unknown, - eAspect_4_3, - eAspect_16_9, - eAspect_16_10, -}; - -class SBoundingVolume -{ -public: - SBoundingVolume() - : m_vCenter(0, 0, 0) - , m_fRadius(0) {} - ~SBoundingVolume() {} - - void SetCenter(const Vec3& center) { m_vCenter = center; } - void SetRadius(float radius) { m_fRadius = radius; } - const Vec3& GetCenter() const { return m_vCenter; } - float GetRadius() const { return m_fRadius; } - -protected: - Vec3 m_vCenter; - float m_fRadius; -}; - -class SMinMaxBox - : public SBoundingVolume -{ -public: - SMinMaxBox() - { - Clear(); - } - SMinMaxBox(const Vec3& min, const Vec3& max) : - m_min(min), - m_max(max) - { - UpdateSphere(); - } - - // Summary: - // Destructor - virtual ~SMinMaxBox() {} - - void AddPoint(const Vec3& pt) - { - if (pt.x > m_max.x) - { - m_max.x = pt.x; - } - if (pt.x < m_min.x) - { - m_min.x = pt.x; - } - - if (pt.y > m_max.y) - { - m_max.y = pt.y; - } - if (pt.y < m_min.y) - { - m_min.y = pt.y; - } - - if (pt.z > m_max.z) - { - m_max.z = pt.z; - } - if (pt.z < m_min.z) - { - m_min.z = pt.z; - } - - // Summary: - // Updates the center and radius. - UpdateSphere(); - } - void AddPoint(float x, float y, float z) - { - AddPoint(Vec3(x, y, z)); - } - - void Union(const SMinMaxBox& box) { AddPoint(box.GetMin()); AddPoint(box.GetMax()); } - - const Vec3& GetMin() const { return m_min; } - const Vec3& GetMax() const { return m_max; } - - void SetMin(const Vec3& min) { m_min = min; UpdateSphere(); } - void SetMax(const Vec3& max) { m_max = max; UpdateSphere(); } - - float GetWidthInX() const { return m_max.x - m_min.x; } - float GetWidthInY() const { return m_max.y - m_min.y; } - float GetWidthInZ() const { return m_max.z - m_min.z; } - - bool PointInBBox(const Vec3& pt) const; - - bool ViewFrustumCull(const CameraViewParameters& viewParameters, const Matrix44& mat); - - void Transform(const Matrix34& mat) - { - Vec3 verts[8]; - CalcVerts(verts); - Clear(); - for (int i = 0; i < 8; i++) - { - AddPoint(mat.TransformPoint(verts[i])); - } - } - - // Summary: - // Resets the bounding box. - void Clear() - { - m_min = Vec3(999999.0f, 999999.0f, 999999.0f); - m_max = Vec3(-999999.0f, -999999.0f, -999999.0f); - } - -protected: - void UpdateSphere() - { - m_vCenter = m_min; - m_vCenter += m_max; - m_vCenter *= 0.5f; - - Vec3 rad = m_max; - rad -= m_vCenter; - m_fRadius = rad.len(); - } - void CalcVerts(Vec3 pVerts[8]) const - { - pVerts[0].Set(m_max.x, m_max.y, m_max.z); - pVerts[4].Set(m_max.x, m_max.y, m_min.z); - pVerts[1].Set(m_min.x, m_max.y, m_max.z); - pVerts[5].Set(m_min.x, m_max.y, m_min.z); - pVerts[2].Set(m_min.x, m_min.y, m_max.z); - pVerts[6].Set(m_min.x, m_min.y, m_min.z); - pVerts[3].Set(m_max.x, m_min.y, m_max.z); - pVerts[7].Set(m_max.x, m_min.y, m_min.z); - } - -private: - Vec3 m_min; // Original object space BV. - Vec3 m_max; -}; - - - -////////////////////////////////////////////////////////////////////// -// All possible primitive types - -enum PublicRenderPrimitiveType -{ - prtTriangleList, - prtTriangleStrip, - prtLineList, - prtLineStrip -}; - -////////////////////////////////////////////////////////////////////// -#define R_CULL_DISABLE 0 -#define R_CULL_NONE 0 -#define R_CULL_FRONT 1 -#define R_CULL_BACK 2 - -////////////////////////////////////////////////////////////////////// -#define R_DEFAULT_LODBIAS 0 - -////////////////////////////////////////////////////////////////////// -#define R_SOLID_MODE 0 -#define R_WIREFRAME_MODE 1 - -#define R_DX9_RENDERER 2 -#define R_DX11_RENDERER 3 -#define R_NULL_RENDERER 4 -#define R_CUBAGL_RENDERER 5 -#define R_GL_RENDERER 6 -#define R_METAL_RENDERER 7 -#define R_DX12_RENDERER 8 - -////////////////////////////////////////////////////////////////////// -// Render features - -#define RFT_FREE_0x1 0x1 -#define RFT_ALLOW_RECTTEX 0x2 -#define RFT_OCCLUSIONQUERY 0x4 -#define RFT_FREE_0x8 0x8 -#define RFT_HWGAMMA 0x10 -#define RFT_FREE_0x20 0x20 -#define RFT_COMPRESSTEXTURE 0x40 -#define RFT_FREE_0x80 0x80 -#define RFT_ALLOWANISOTROPIC 0x100 // Allows anisotropic texture filtering. -#define RFT_SUPPORTZBIAS 0x200 -#define RFT_FREE_0x400 0x400 -#define RFT_FREE_0x800 0x800 -#define RFT_FREE_0x1000 0x1000 -#define RFT_FREE_0x2000 0x2000 -#define RFT_OCCLUSIONTEST 0x8000 // Support hardware occlusion test. - -#define RFT_HW_ARM_MALI 0x04000 // Unclassified ARM (MALI) hardware. -#define RFT_HW_INTEL 0x10000 // Unclassified intel hardware. -#define RFT_HW_QUALCOMM 0x10000 // Unclassified Qualcomm hardware -#define RFT_HW_ATI 0x20000 // Unclassified ATI hardware. -#define RFT_HW_NVIDIA 0x40000 // Unclassified NVidia hardware. -#define RFT_HW_MASK 0x74000 // Graphics chip mask. - -#define RFT_HW_HDR 0x80000 // Hardware supports high dynamic range rendering. - -#define RFT_HW_SM20 0x100000 // Shader model 2.0 -#define RFT_HW_SM2X 0x200000 // Shader model 2.X -#define RFT_HW_SM30 0x400000 // Shader model 3.0 -#define RFT_HW_SM40 0x800000 // Shader model 4.0 -#define RFT_HW_SM50 0x1000000 // Shader model 5.0 - -#define RFT_FREE_0x2000000 0x2000000 -#define RFT_FREE_0x4000000 0x4000000 -#define RFT_FREE_0x8000000 0x8000000 - -#define RFT_HW_VERTEX_STRUCTUREDBUF 0x10000000 // Supports Structured Buffers in the Vertex Shader. -#define RFT_RGBA 0x20000000 // RGBA order (otherwise BGRA). -#define RFT_COMPUTE_SHADERS 0x40000000 // Compute Shaders support -#define RFT_HW_VERTEXTEXTURES 0x80000000 // Vertex texture fetching supported. - -//==================================================================== -// PrecacheResources flags - -#define FPR_NEEDLIGHT 1 -#define FPR_2D 2 -#define FPR_HIGHPRIORITY 4 -#define FPR_SYNCRONOUS 8 -#define FPR_STARTLOADING 16 -#define FPR_SINGLE_FRAME_PRIORITY_UPDATE 32 - -//===================================================================== -// SetRenderTarget flags -#define SRF_SCREENTARGET 1 -#define SRF_USE_ORIG_DEPTHBUF 2 -#define SRF_USE_ORIG_DEPTHBUF_MSAA 4 - -//==================================================================== -// Draw shaders flags (EF_EndEf3d) - -#define SHDF_ALLOWHDR BIT(0) -#define SHDF_CUBEMAPGEN BIT(1) -#define SHDF_ZPASS BIT(2) -#define SHDF_ZPASS_ONLY BIT(3) -#define SHDF_DO_NOT_CLEAR_Z_BUFFER BIT(4) -#define SHDF_ALLOWPOSTPROCESS BIT(5) -#define SHDF_ALLOW_AO BIT(8) -#define SHDF_ALLOW_WATER BIT(9) -#define SHDF_NOASYNC BIT(10) -#define SHDF_NO_DRAWNEAR BIT(11) -#define SHDF_STREAM_SYNC BIT(13) -#define SHDF_NO_SHADOWGEN BIT(15) - -////////////////////////////////////////////////////////////////////// -// Virtual screen size -const float VIRTUAL_SCREEN_WIDTH = 800.0f; -const float VIRTUAL_SCREEN_HEIGHT = 600.0f; - -////////////////////////////////////////////////////////////////////// -// Object states + // Object states #define OS_ALPHA_BLEND 0x1 #define OS_ADD_BLEND 0x2 #define OS_MULTIPLY_BLEND 0x4 @@ -520,7 +52,6 @@ const float VIRTUAL_SCREEN_HEIGHT = 600.0f; #define GS_BLDST_ONE_A_ZERO 0x90 // separate alpha blend state #define GS_BLDST_ONEMINUSSRC1ALPHA 0xa0 // dual source blending - #define GS_DEPTHWRITE 0x00000100 #define GS_COLMASK_RT1 0x00000200 @@ -555,8 +86,8 @@ const float VIRTUAL_SCREEN_HEIGHT = 600.0f; #define GS_STENCIL 0x00800000 #define GS_BLEND_OP_MASK 0x03000000 -#define GS_BLOP_MAX 0x01000000 -#define GS_BLOP_MIN 0x02000000 +#define GS_BLOP_MAX 0x01000000 +#define GS_BLOP_MIN 0x02000000 // Separate alpha blend mode #define GS_BLALPHA_MASK 0x0c000000 @@ -568,181 +99,28 @@ const float VIRTUAL_SCREEN_HEIGHT = 600.0f; #define GS_ALPHATEST_LESS 0x20000000 #define GS_ALPHATEST_GEQUAL 0x40000000 #define GS_ALPHATEST_LEQUAL 0x80000000 +////////////////////////////////////////////////////////////////////// +#define R_SOLID_MODE 0 +#define R_WIREFRAME_MODE 1 -#define FORMAT_8_BIT 8 -#define FORMAT_24_BIT 24 -#define FORMAT_32_BIT 32 +#define MAX_NUM_VIEWPORTS 7 -//================================================================== -// StencilStates -//Note: If these are altered, g_StencilFuncLookup and g_StencilOpLookup arrays -// need to be updated in turn - -#define FSS_STENCFUNC_ALWAYS 0x0 -#define FSS_STENCFUNC_NEVER 0x1 -#define FSS_STENCFUNC_LESS 0x2 -#define FSS_STENCFUNC_LEQUAL 0x3 -#define FSS_STENCFUNC_GREATER 0x4 -#define FSS_STENCFUNC_GEQUAL 0x5 -#define FSS_STENCFUNC_EQUAL 0x6 -#define FSS_STENCFUNC_NOTEQUAL 0x7 -#define FSS_STENCFUNC_MASK 0x7 - -#define FSS_STENCIL_TWOSIDED 0x8 - -#define FSS_CCW_SHIFT 16 - -#define FSS_STENCOP_KEEP 0x0 -#define FSS_STENCOP_REPLACE 0x1 -#define FSS_STENCOP_INCR 0x2 -#define FSS_STENCOP_DECR 0x3 -#define FSS_STENCOP_ZERO 0x4 -#define FSS_STENCOP_INCR_WRAP 0x5 -#define FSS_STENCOP_DECR_WRAP 0x6 -#define FSS_STENCOP_INVERT 0x7 - -#define FSS_STENCFAIL_SHIFT 4 -#define FSS_STENCFAIL_MASK (0x7 << FSS_STENCFAIL_SHIFT) - -#define FSS_STENCZFAIL_SHIFT 8 -#define FSS_STENCZFAIL_MASK (0x7 << FSS_STENCZFAIL_SHIFT) - -#define FSS_STENCPASS_SHIFT 12 -#define FSS_STENCPASS_MASK (0x7 << FSS_STENCPASS_SHIFT) - -#define STENC_FUNC(op) (op) -#define STENC_CCW_FUNC(op) (op << FSS_CCW_SHIFT) -#define STENCOP_FAIL(op) (op << FSS_STENCFAIL_SHIFT) -#define STENCOP_ZFAIL(op) (op << FSS_STENCZFAIL_SHIFT) -#define STENCOP_PASS(op) (op << FSS_STENCPASS_SHIFT) -#define STENCOP_CCW_FAIL(op) (op << (FSS_STENCFAIL_SHIFT + FSS_CCW_SHIFT)) -#define STENCOP_CCW_ZFAIL(op) (op << (FSS_STENCZFAIL_SHIFT + FSS_CCW_SHIFT)) -#define STENCOP_CCW_PASS(op) (op << (FSS_STENCPASS_SHIFT + FSS_CCW_SHIFT)) - -//Stencil masks -#define BIT_STENCIL_RESERVED 0x80 -#define BIT_STENCIL_INSIDE_CLIPVOLUME 0x40 -#define STENC_VALID_BITS_NUM 7 -#define STENC_MAX_REF ((1 << STENC_VALID_BITS_NUM) - 1) - -// Read FrameBuffer type -enum ERB_Type -{ - eRB_BackBuffer, - eRB_FrontBuffer, - eRB_ShadowBuffer -}; - -enum EVertexCostTypes -{ - EVCT_STATIC = 0, - EVCT_VEGETATION, - EVCT_SKINNED, - EVCT_NUM -}; +constexpr float UIDRAW_TEXTSIZEFACTOR = 12.0f; +constexpr float MIN_RESOLUTION_SCALE = 0.25f; +constexpr float MAX_RESOLUTION_SCALE = 4.0f; ////////////////////////////////////////////////////////////////////// +// All possible primitive types -struct SDispFormat +enum class PublicRenderPrimitiveType { - int m_Width; - int m_Height; - int m_BPP; + prtTriangleList, + prtTriangleStrip, + prtLineList, + prtLineStrip }; -struct SAAFormat -{ - char szDescr[64]; - int nSamples; - int nQuality; -}; - -// Summary: -// Info about Terrain sector texturing. -struct SSectorTextureSet -{ - SSectorTextureSet(unsigned short nT0) - { - nTex0 = nT0; - fTexOffsetX = fTexOffsetY = 0; - fTexScale = 1.f; - } - - unsigned short nTex0; - float fTexOffsetX, fTexOffsetY, fTexScale; -}; - -struct IRenderNode; -struct SShaderItem; - -#ifdef SUPPORT_HW_MOUSE_CURSOR -class IHWMouseCursor -{ -public: - virtual ~IHWMouseCursor() {} - virtual void SetPosition(int x, int y) = 0; - virtual void Show() = 0; - virtual void Hide() = 0; -}; -#endif - -////////////////////////////////////////////////////////////////////// -//DOC-IGNORE-BEGIN -#include // <> required for Interfuscator -//DOC-IGNORE-END -#include - -// Flags passed in function FreeResources. -#define FRR_SHADERS 1 -#define FRR_SHADERTEXTURES 2 -#define FRR_TEXTURES 4 -#define FRR_SYSTEM 8 -#define FRR_RESTORE 0x10 -#define FRR_REINITHW 0x20 -#define FRR_DELETED_MESHES 0x40 -#define FRR_FLUSH_TEXTURESTREAMING 0x80 -#define FRR_OBJECTS 0x100 -#define FRR_RENDERELEMENTS 0x200 -#define FRR_RP_BUFFERS 0x400 -#define FRR_SYSTEM_RESOURCES 0x800 -#define FRR_POST_EFFECTS 0x1000 -#define FRR_ALL -1 - -// Refresh render resources flags. -// Flags passed in function RefreshResources. -#define FRO_SHADERS 1 -#define FRO_SHADERTEXTURES 2 -#define FRO_TEXTURES 4 -#define FRO_GEOMETRY 8 -#define FRO_FORCERELOAD 0x10 - -//============================================================================= -// Shaders render target stuff. - -#define FRT_CLEAR_DEPTH 0x1 -#define FRT_CLEAR_STENCIL 0x2 -#define FRT_CLEAR_COLOR 0x4 -#define FRT_CLEAR (FRT_CLEAR_COLOR | FRT_CLEAR_DEPTH | FRT_CLEAR_STENCIL) -#define FRT_CLEAR_FOGCOLOR 0x8 -#define FRT_CLEAR_IMMEDIATE 0x10 -#define FRT_CLEAR_COLORMASK 0x20 -#define FRT_CLEAR_RESET_VIEWPORT 0x40 - -#define FRT_CAMERA_REFLECTED_WATERPLANE 0x40 -#define FRT_CAMERA_REFLECTED_PLANE 0x80 -#define FRT_CAMERA_CURRENT 0x100 - -#define FRT_USE_FRONTCLIPPLANE 0x200 -#define FRT_USE_BACKCLIPPLANE 0x400 - -#define FRT_GENERATE_MIPS 0x800 - -#define FRT_RENDTYPE_CUROBJECT 0x1000 -#define FRT_RENDTYPE_CURSCENE 0x2000 -#define FRT_RENDTYPE_RECURSIVECURSCENE 0x4000 -#define FRT_RENDTYPE_COPYSCENE 0x8000 - // Summary: // Flags used in DrawText function. // See also: @@ -751,48 +129,26 @@ public: // Text must be fixed pixel size. enum EDrawTextFlags { - eDrawText_Left = 0, // default left alignment if neither Center or Right are specified - eDrawText_Center = BIT(0), // centered alignment, otherwise right or left - eDrawText_Right = BIT(1), // right alignment, otherwise center or left - eDrawText_CenterV = BIT(2), // center vertically, otherwise top - eDrawText_Bottom = BIT(3), // bottom alignment + eDrawText_Left = 0, // default left alignment if neither Center or Right are specified + eDrawText_Center = BIT(0), // centered alignment, otherwise right or left + eDrawText_Right = BIT(1), // right alignment, otherwise center or left + eDrawText_CenterV = BIT(2), // center vertically, otherwise top + eDrawText_Bottom = BIT(3), // bottom alignment - eDrawText_2D = BIT(4), // 3 component vector is used for xy screen position, otherwise it's 3d world space position + eDrawText_2D = BIT(4), // 3 component vector is used for xy screen position, otherwise it's 3d world space position - eDrawText_FixedSize = BIT(5), // font size is defined in the actual pixel resolution, otherwise it's in the virtual 800x600 - eDrawText_800x600 = BIT(6), // position are specified in the virtual 800x600 resolution, otherwise coordinates are in pixels + eDrawText_FixedSize = BIT(5), // font size is defined in the actual pixel resolution, otherwise it's in the virtual 800x600 + eDrawText_800x600 = BIT(6), // position are specified in the virtual 800x600 resolution, otherwise coordinates are in pixels - eDrawText_Monospace = BIT(7), // non proportional font rendering (Font width is same for all characters) + eDrawText_Monospace = BIT(7), // non proportional font rendering (Font width is same for all characters) - eDrawText_Framed = BIT(8), // draw a transparent, rectangular frame behind the text to ease readability independent from the background + eDrawText_Framed = BIT(8), // draw a transparent, rectangular frame behind the text to ease readability independent from the background - eDrawText_DepthTest = BIT(9), // text should be occluded by world geometry using the depth buffer + eDrawText_DepthTest = BIT(9), // text should be occluded by world geometry using the depth buffer eDrawText_IgnoreOverscan = BIT(10), // ignore the overscan borders, text should be drawn at the location specified - eDrawText_UseTransform = BIT(11), // use a transform for the text + eDrawText_UseTransform = BIT(11), // use a transform for the text }; -// Debug stats/views for Partial resolves -// if REFRACTION_PARTIAL_RESOLVE_DEBUG_VIEWS is enabled, make sure REFRACTION_PARTIAL_RESOLVE_STATS is too -#if defined(PERFORMANCE_BUILD) - #define REFRACTION_PARTIAL_RESOLVE_STATS 1 - #define REFRACTION_PARTIAL_RESOLVE_DEBUG_VIEWS 0 -#elif defined(_RELEASE) // note: _RELEASE is defined in PERFORMANCE_BUILD, so this check must come second - #define REFRACTION_PARTIAL_RESOLVE_STATS 0 - #define REFRACTION_PARTIAL_RESOLVE_DEBUG_VIEWS 0 -#else - #define REFRACTION_PARTIAL_RESOLVE_STATS 1 - #define REFRACTION_PARTIAL_RESOLVE_DEBUG_VIEWS 1 -#endif - -#if REFRACTION_PARTIAL_RESOLVE_DEBUG_VIEWS -enum ERefractionPartialResolvesDebugViews -{ - eRPR_DEBUG_VIEW_2D_AREA = 1, - eRPR_DEBUG_VIEW_3D_BOUNDS, - eRPR_DEBUG_VIEW_2D_AREA_OVERLAY -}; -#endif - ////////////////////////////////////////////////////////////////////////// // Description: // This structure used in DrawText method of renderer. @@ -821,25 +177,6 @@ struct SDrawTextInfo } }; -#define UIDRAW_TEXTSIZEFACTOR (12.0f) -#define MIN_RESOLUTION_SCALE (0.25f) -#define MAX_RESOLUTION_SCALE (4.0f) - -#if defined(AZ_RESTRICTED_PLATFORM) - #include AZ_RESTRICTED_FILE(IRenderer_h) -#else -//SLI/CROSSFIRE GPU maximum count - #define MAX_GPU_NUM 4 -#endif - -#define MAX_FRAME_ID_STEP_PER_FRAME 20 -const int MAX_GSM_LODS_NUM = 16; - -const f32 DRAW_NEAREST_MIN = 0.03f; -const f32 DRAW_NEAREST_MAX = 40.0f; - -//=================================================================== - ////////////////////////////////////////////////////////////////////// struct IRenderDebugListener { @@ -848,1609 +185,23 @@ struct IRenderDebugListener virtual void OnDebugDraw() = 0; }; -////////////////////////////////////////////////////////////////////// -struct ILoadtimeCallback +struct DynUiPrimitive : public AZStd::intrusive_slist_node { - virtual void LoadtimeUpdate(float fDeltaTime) = 0; - virtual void LoadtimeRender() = 0; - virtual ~ILoadtimeCallback(){} -}; - -////////////////////////////////////////////////////////////////////// -struct ISyncMainWithRenderListener -{ - virtual void SyncMainWithRender() = 0; - virtual ~ISyncMainWithRenderListener(){} -}; - -////////////////////////////////////////////////////////////////////// -enum ERenderType -{ - eRT_Undefined, - eRT_Null, - eRT_DX11, - eRT_DX12, - eRT_Provo, - eRT_OpenGL, - eRT_Metal, - eRT_Jasper, -}; - -////////////////////////////////////////////////////////////////////// -// Enum for types of deferred lights -enum eDeferredLightType -{ - eDLT_DeferredLight = 0, - - eDLT_NumShadowCastingLights = eDLT_DeferredLight + 1, - // these lights cannot cast shadows - eDLT_DeferredCubemap = eDLT_NumShadowCastingLights, - eDLT_DeferredAmbientLight, - eDLT_NumLightTypes, -}; - -const float RENDERER_LIGHT_UNIT_SCALE = 10000.0f; // Scale factor between photometric and internal light units - -////////////////////////////////////////////////////////////////////// -struct SCustomRenderInitArgs -{ - bool appStartedFromMediaCenter; -}; - -#if defined(ANDROID) -enum -{ - CULL_SIZEX = 128 -}; -enum -{ - CULL_SIZEY = 64 -}; -#else -enum -{ - CULL_SIZEX = 256 -}; -enum -{ - CULL_SIZEY = 128 -}; -#endif - -////////////////////////////////////////////////////////////////////// -// Description: -// Z-buffer as occlusion buffer definitions: used, shared and initialized in engine and renderer. -struct SHWOccZBuffer -{ - uint32* pHardwareZBuffer; - uint32* pZBufferVMem; - uint32 ZBufferSizeX; - uint32 ZBufferSizeY; - uint32 HardwareZBufferRSXOff; - uint32 ZBufferVMemRSXOff; - uint32 pad[2]; // Keep 32 byte aligned - SHWOccZBuffer() - : pHardwareZBuffer(NULL) - , pZBufferVMem(NULL) - , ZBufferSizeX(CULL_SIZEX) - , ZBufferSizeY(CULL_SIZEY) - , ZBufferVMemRSXOff(0) - , HardwareZBufferRSXOff(0){} -}; - -class ITextureStreamListener -{ -public: - virtual void OnCreatedStreamedTexture(void* pHandle, const char* name, int nMips, int nMinMipAvailable) = 0; - virtual void OnDestroyedStreamedTexture(void* pHandle) = 0; - virtual void OnTextureWantsMip(void* pHandle, int nMinMip) = 0; - virtual void OnTextureHasMip(void* pHandle, int nMinMip) = 0; - virtual void OnBegunUsingTextures(void** pHandles, size_t numHandles) = 0; - virtual void OnEndedUsingTextures(void** pHandle, size_t numHandles) = 0; - -protected: - virtual ~ITextureStreamListener() {} -}; - -enum eDolbyVisionMode -{ - eDVM_Disabled, - eDVM_RGBPQ, - eDVM_Vision, -}; - -enum ERenderPipelineProfilerStats -{ - eRPPSTATS_OverallFrame = 0, - eRPPSTATS_Recursion, - - // Scene - eRPPSTATS_SceneOverall, - eRPPSTATS_SceneDecals, - eRPPSTATS_SceneForward, - eRPPSTATS_SceneWater, - - // Shadows - eRPPSTATS_ShadowsOverall, - eRPPSTATS_ShadowsSun, - eRPPSTATS_ShadowsSunCustom, - eRPPSTATS_ShadowsLocal, - - // Lighting - eRPPSTATS_LightingOverall, - eRPPSTATS_LightingGI, - - // VFX - eRPPSTATS_VfxOverall, - eRPPSTATS_VfxTransparent, - eRPPSTATS_VfxFog, - eRPPSTATS_VfxFlares, - - // Individual Total Illumination stats - eRPPSTATS_TI_INJECT_CLEAR, - eRPPSTATS_TI_VOXELIZE, - eRPPSTATS_TI_INJECT_AIR, - eRPPSTATS_TI_INJECT_LIGHT, - eRPPSTATS_TI_INJECT_REFL0, - eRPPSTATS_TI_INJECT_REFL1, - eRPPSTATS_TI_INJECT_DYNL, - eRPPSTATS_TI_NID_DIFF, - eRPPSTATS_TI_GEN_DIFF, - eRPPSTATS_TI_GEN_SPEC, - eRPPSTATS_TI_GEN_AIR, - eRPPSTATS_TI_DEMOSAIC_DIFF, - eRPPSTATS_TI_DEMOSAIC_SPEC, - eRPPSTATS_TI_UPSCALE_DIFF, - eRPPSTATS_TI_UPSCALE_SPEC, - - RPPSTATS_NUM -}; - -struct RPProfilerStats -{ - float gpuTime; - float gpuTimeSmoothed; - float gpuTimeMax; - float cpuTime; - uint32 numDIPs; - uint32 numPolys; - - // Internal - float _gpuTimeMaxNew; -}; - -struct TransformationMatrices -{ - Matrix44A m_viewMatrix; - Matrix44A m_projectMatrix; -}; - -struct ISvoRenderer -{ - virtual bool IsShaderItemUsedForVoxelization([[maybe_unused]] SShaderItem& rShaderItem, [[maybe_unused]] IRenderNode* pRN){ return false; } - virtual void Release(){} -}; - -////////////////////////////////////////////////////////////////////// -struct SRenderPipeline; -struct SRenderThread; -struct SShaderTechnique; -struct SShaderPass; -struct SDepthTexture; -struct SRenderTileInfo; - -class CShaderMan; -class CDeviceBufferManager; -class CShaderResources; -class PerInstanceConstantBufferPool; - -namespace AZ { - class Plane; - namespace Vertex { - class Format; - } -} -enum eRenderPrimitiveType : int8; -enum RenderIndexType : int; - -struct IRenderAPI -{ -}; - -struct IRenderer - : public IRenderAPI -{ - virtual ~IRenderer(){} - - virtual void AddRenderDebugListener(IRenderDebugListener* pRenderDebugListener) = 0; - virtual void RemoveRenderDebugListener(IRenderDebugListener* pRenderDebugListener) = 0; - - virtual ERenderType GetRenderType() const = 0; - - virtual const char* GetRenderDescription() const - { - return "CryRenderer"; - } - - // Summary: - // Initializes the renderer, params are self-explanatory. - virtual WIN_HWND Init(int x, int y, int width, int height, unsigned int cbpp, int zbpp, int sbits, bool fullscreen, bool isEditor, WIN_HINSTANCE hinst, WIN_HWND Glhwnd = 0, bool bReInit = false, const SCustomRenderInitArgs* pCustomArgs = 0, bool bShaderCacheGen = false) = 0; - virtual void PostInit() = 0; - - virtual bool IsPost3DRendererEnabled() const { return false; } - - virtual int GetFeatures() = 0; - virtual const void SetApiVersion(const AZStd::string& apiVersion) = 0; - virtual const void SetAdapterDescription(const AZStd::string& adapterDescription) = 0; - virtual const AZStd::string& GetApiVersion() const = 0; - virtual const AZStd::string& GetAdapterDescription() const = 0; - virtual void GetVideoMemoryUsageStats(size_t& vidMemUsedThisFrame, size_t& vidMemUsedRecently, bool bGetPoolsSizes = false) = 0; - virtual int GetNumGeomInstances() const = 0; - virtual int GetNumGeomInstanceDrawCalls() const = 0; - virtual int GetCurrentNumberOfDrawCalls() const = 0; - virtual void GetCurrentNumberOfDrawCalls(int& nGeneral, int& nShadowGen) const = 0; - //Sums DIP counts for the EFSLIST_* passes that match the submitted mask. - //Compose the mask with bitwise arithmetic, use (1 << EFSLIST_*) per list. - //e.g. to sum general and transparent, pass in ( (1 << EFSLIST_GENERAL) | (1 << EFSLIST_TRANSP) ) - virtual int GetCurrentNumberOfDrawCalls(uint32 EFSListMask) const = 0; - virtual float GetCurrentDrawCallRTTimes(uint32 EFSListMask) const = 0; - - virtual void SetDebugRenderNode(IRenderNode* pRenderNode) = 0; - virtual bool IsDebugRenderNode(IRenderNode* pRenderNode) const = 0; - - ///////////////////////////////////////////////////////////////////////////////// - // Render-context management - ///////////////////////////////////////////////////////////////////////////////// - virtual bool DeleteContext(WIN_HWND hWnd) = 0; - virtual bool CreateContext(WIN_HWND hWnd, bool bAllowMSAA = false, int SSX = 1, int SSY = 1) = 0; - virtual bool SetCurrentContext(WIN_HWND hWnd) = 0; - virtual void MakeMainContextActive() = 0; - virtual WIN_HWND GetCurrentContextHWND() = 0; - virtual bool IsCurrentContextMainVP() = 0; - - // Summary: - // Gets height of the current viewport. - virtual int GetCurrentContextViewportHeight() const = 0; - - // Summary: - // Gets width of the current viewport. - virtual int GetCurrentContextViewportWidth() const = 0; - ///////////////////////////////////////////////////////////////////////////////// - - // Summary: - // Shuts down the renderer. - virtual void ShutDown(bool bReInit = false) = 0; - virtual void ShutDownFast() = 0; - - // Description: - // Creates array of all supported video formats (except low resolution formats). - // Return value: - // Number of formats in memory. - virtual int EnumDisplayFormats(SDispFormat* Formats) = 0; - - // Summary: - // Returns all supported by video card video AA formats. - virtual int EnumAAFormats(SAAFormat* Formats) = 0; - - // Summary: - // Changes resolution of the window/device (doesn't require to reload the level. - virtual bool ChangeResolution(int nNewWidth, int nNewHeight, int nNewColDepth, int nNewRefreshHZ, bool bFullScreen, bool bForceReset) = 0; - - // Note: - // Should be called at the beginning of every frame. - virtual void BeginFrame() = 0; - - // Summary: - // Creates default system shaders and textures. - virtual void InitSystemResources(int nFlags) = 0; - virtual void InitTexturesSemantics() = 0; - - // Summary: - // Frees the allocated resources. - virtual void FreeResources(int nFlags) = 0; - - // Summary: - // Shuts down the renderer. - virtual void Release() = 0; - - // See also: - // r_ShowDynTextures - virtual void RenderDebug(bool bRenderStats = true) = 0; - - // Note: - // Should be called at the end of every frame. - virtual void EndFrame() = 0; - - // Force a swap on the backbuffer - virtual void ForceSwapBuffers() = 0; - - // Summary: - // Try to flush the render thread commands to keep the render thread active during - // level loading, but simpy return if the render thread is still busy - virtual void TryFlush() = 0; - - virtual void GetViewport(int* x, int* y, int* width, int* height) const = 0; - virtual void SetViewport(int x, int y, int width, int height, int id = 0) = 0; - virtual void SetRenderTile(f32 nTilesPosX = 0.f, f32 nTilesPosY = 0.f, f32 nTilesGridSizeX = 1.f, f32 nTilesGridSizeY = 1.f) = 0; - virtual void SetScissor(int x = 0, int y = 0, int width = 0, int height = 0) = 0; - virtual Matrix44A& GetViewProjectionMatrix() = 0; - virtual void SetTranspOrigCameraProjMatrix(Matrix44A& matrix) = 0; - - virtual EScreenAspectRatio GetScreenAspect(int nWidth, int nHeight) = 0; - - virtual Vec2 SetViewportDownscale(float xscale, float yscale) = 0; - virtual void SetViewParameters(const CameraViewParameters& viewParameters) = 0; // Direct setter - virtual void ApplyViewParameters(const CameraViewParameters& viewParameters) = 0; // Uses CameraViewParameters to create matrices. - - // Summary: - // Draws user primitives. - virtual void DrawDynVB(SVF_P3F_C4B_T2F* pBuf, uint16* pInds, int nVerts, int nInds, PublicRenderPrimitiveType nPrimType) = 0; - - struct DynUiPrimitive : public AZStd::intrusive_slist_node - { - SVF_P2F_C4B_T2F_F4B* m_vertices = nullptr; - uint16* m_indices = nullptr; - int m_numVertices = 0; - int m_numIndices = 0; - }; - - using DynUiPrimitiveList = AZStd::intrusive_slist>; - - // Summary: - // Draws a list of UI primitives as one draw call (if using separate render thread) - virtual void DrawDynUiPrimitiveList(DynUiPrimitiveList& primitives, int totalNumVertices, int totalNumIndices) = 0; - - // Summary: - // Sets the renderer camera. - virtual void SetCamera(const CCamera& cam) = 0; - - // Summary: - // Gets the renderer camera. - virtual const CCamera& GetCamera() = 0; - - virtual CRenderView* GetRenderViewForThread(int nThreadID) = 0; - // Summary: - // Gets the renderer previous camera. - //virtual const CCamera& GetCameraPrev() = 0; - - // Summary: - // Sets delta gamma. - virtual bool SetGammaDelta(float fGamma) = 0; - - // Summary: - // Restores gamma - // Note: - // Reset gamma setting if not in fullscreen mode. - virtual void RestoreGamma(void) = 0; - - // Summary: - // Changes display size. - virtual bool ChangeDisplay(unsigned int width, unsigned int height, unsigned int cbpp) = 0; - - // Summary: - // Changes viewport size. - virtual void ChangeViewport(unsigned int x, unsigned int y, unsigned int width, unsigned int height, bool bMainViewport = false, float scaleWidth = 1.0f, float scaleHeight = 1.0f) = 0; - - // Summary: - // Saves source data to a Tga file. - // Note: - // Should not be here. - virtual bool SaveTga(unsigned char* sourcedata, int sourceformat, int w, int h, const char* filename, bool flip) const = 0; - - // Summary: - // Sets the current binded texture. - virtual void SetTexture(int tnum) = 0; - - // Summary: - // Sets the current bound texture for the given texture unit - virtual void SetTexture(int tnum, int nUnit) = 0; - - // Summary: - // Sets the white texture. - virtual void SetWhiteTexture() = 0; - - // Summary: - // Gets the white texture Id. - virtual int GetWhiteTextureId() const = 0; - - // Summary: - // Gets the white texture Id. - virtual int GetBlackTextureId() const = 0; - - // Summary: - // Draws a 2d image on the screen. - // Example: - // Hud etc. - virtual void Draw2dImage(float xpos, float ypos, float w, float h, int texture_id, float s0 = 0, float t0 = 0, float s1 = 1, float t1 = 1, float angle = 0, float r = 1, float g = 1, float b = 1, float a = 1, float z = 1) = 0; - - virtual void Draw2dImageStretchMode(bool stretch) = 0; - - // Summary: - // Adds a 2d image that should be drawn on the screen to an internal render list. The list can be drawn with Draw2dImageList. - // If several images will be drawn, using this function is more efficient than calling Draw2dImage as it allows better batching. - // The function supports placing images in stereo 3d space. - // Arguments: - // stereoDepth - Places image in stereo 3d space. The depth is specified in camera space, the stereo params are the same that - // are used for the scene. A value of 0 is handled as a special case and always places the image on the screen plane. - virtual void Push2dImage(float xpos, float ypos, float w, float h, int texture_id, float s0 = 0, float t0 = 0, float s1 = 1, float t1 = 1, float angle = 0, float r = 1, float g = 1, float b = 1, float a = 1, float z = 1, float stereoDepth = 0) = 0; - - // Summary: - // Draws all images to the screen that were collected with Push2dImage. - virtual void Draw2dImageList() = 0; - - // Summary: - // Draws a image using the current matrix. - virtual void DrawImage(float xpos, float ypos, float w, float h, int texture_id, float s0, float t0, float s1, float t1, float r, float g, float b, float a, bool filtered = true) = 0; - - // Description: - // Draws a image using the current matrix, more flexible than DrawImage - // order for s and t: 0=left_top, 1=right_top, 2=right_bottom, 3=left_bottom. - virtual void DrawImageWithUV(float xpos, float ypos, float z, float width, float height, int texture_id, float* s, float* t, float r = 1, float g = 1, float b = 1, float a = 1, bool filtered = true) = 0; - - // Summary: - // Sets the polygon mode with Push, Pop restores the last used one - // Example: - // Wireframe, solid. - virtual void PushWireframeMode(int mode) = 0; - virtual void PopWireframeMode() = 0; - - // Summary: - // Gets height of the main rendering resolution. - virtual int GetHeight() const = 0; - - // Summary: - // Gets width of the main rendering resolution. - virtual int GetWidth() const = 0; - - // Summary: - // Gets Pixel Aspect Ratio. - virtual float GetPixelAspectRatio() const = 0; - - // Summary: - // Gets the height of the overlay viewport where UI and debug output are rendered. - virtual int GetOverlayHeight() const = 0; - - // Summary: - // Gets the width of the overlay viewport where UI and debug output are rendered. - virtual int GetOverlayWidth() const = 0; - - // Summary: - // Gets the maximum dimension for a square custom render resolution. - virtual int GetMaxSquareRasterDimension() const = 0; - - // Summary: - // Switches subsequent rendering from the internal backbuffer to the native resolution backbuffer if available. - virtual void SwitchToNativeResolutionBackbuffer() = 0; - - // Summary: - // Gets memory status information - virtual void GetMemoryUsage(ICrySizer* Sizer) = 0; - - // Summary: - // Gets textures streaming bandwidth information - virtual void GetBandwidthStats(float* fBandwidthRequested) = 0; - - // Summary: - // Sets an event listener for texture streaming updates - virtual void SetTextureStreamListener(ITextureStreamListener* pListener) = 0; - - // Summary: - // Populates a CPU-side occlusion buffer with the contents from the previous frame's downsampled depth buffer. - // This will be called from a job thread within the occlusion system. - virtual int GetOcclusionBuffer(uint16* pOutOcclBuffer, Matrix44* pmCamBuffer) = 0; - - // Summary: - // Gets a screenshot and save to a file - // Returns: - // true=success - virtual bool ScreenShot(const char* filename = NULL, int width = 0) = 0; - - // Summary: - // Gets current bpp. - virtual int GetColorBpp() = 0; - - // Summary: - // Gets current z-buffer depth. - virtual int GetDepthBpp() = 0; - - // Summary: - // Gets current stencil bits. - virtual int GetStencilBpp() = 0; - - // Summary: - // Returns true if stereo rendering is enabled. - virtual bool IsStereoEnabled() const = 0; - - // Summary: - // Returns values of nearest rendering z-range max - virtual float GetNearestRangeMax() const = 0; - - // Summary: - // Returns the PerInstanceConstantBufferPool - virtual PerInstanceConstantBufferPool* GetPerInstanceConstantBufferPoolPointer() = 0; - - // Summary: - // Projects to screen. - // Returns true if successful. - virtual bool ProjectToScreen( - float ptx, float pty, float ptz, - float* sx, float* sy, float* sz) = 0; - - // Summary: - // Unprojects to screen. - virtual int UnProject( - float sx, float sy, float sz, - float* px, float* py, float* pz, - const float modelMatrix[16], - const float projMatrix[16], - const int viewport[4]) = 0; - - // Summary: - // Unprojects from screen. - virtual int UnProjectFromScreen( - float sx, float sy, float sz, - float* px, float* py, float* pz) = 0; - - // Remarks: - // For editor. - virtual void GetModelViewMatrix(float* mat) = 0; - - // Remarks: - // For editor. - virtual void GetProjectionMatrix(float* mat) = 0; - - virtual bool WriteDDS(const byte* dat, int wdt, int hgt, int Size, const char* name, ETEX_Format eF, int NumMips) = 0; - virtual bool WriteTGA(const byte* dat, int wdt, int hgt, const char* name, int src_bits_per_pixel, int dest_bits_per_pixel) = 0; - virtual bool WriteJPG(const byte* dat, int wdt, int hgt, char* name, int src_bits_per_pixel, int nQuality = 100) = 0; - - ///////////////////////////////////////////////////////////////////////////////// - //Replacement functions for Font - - static const bool FontCreateTextureGenMipsDefaultValue = false; - virtual int FontCreateTexture(int Width, int Height, byte* pData, ETEX_Format eTF = eTF_R8G8B8A8, bool genMips = FontCreateTextureGenMipsDefaultValue, const char* textureName = nullptr) = 0; - virtual bool FontUpdateTexture(int nTexId, int X, int Y, int USize, int VSize, byte* pData) = 0; - virtual void FontSetTexture(int nTexId, int nFilterMode) = 0; - virtual void FontSetRenderingState(bool overrideViewProjMatrices, TransformationMatrices& backupMatrices) = 0; - virtual void FontSetBlending(int src, int dst, int baseState) = 0; - virtual void FontRestoreRenderingState(bool overrideViewProjMatrices, const TransformationMatrices& restoringMatrices) = 0; - - virtual bool FlushRTCommands(bool bWait, bool bImmediatelly, bool bForce) = 0; - virtual void DrawStringU(IFFont_RenderProxy* pFont, float x, float y, float z, const char* pStr, bool asciiMultiLine, const STextDrawContext& ctx) const = 0; - - virtual int RT_CurThreadList() = 0; - - ///////////////////////////////////////////////////////////////////////////////// - // External interface for shaders - ///////////////////////////////////////////////////////////////////////////////// - virtual bool EF_PrecacheResource(SShaderItem* pSI, float fMipFactor, float fTimeToReady, int Flags, int nUpdateId, int nCounter = 1) = 0; - virtual bool EF_PrecacheResource(IShader* pSH, float fMipFactor, float fTimeToReady, int Flags) = 0; - virtual bool EF_PrecacheResource(ITexture* pTP, float fMipFactor, float fTimeToReady, int Flags, int nUpdateId, int nCounter = 1) = 0; - virtual bool EF_PrecacheResource(IRenderMesh* pPB, _smart_ptr pMaterial, float fMipFactor, float fTimeToReady, int Flags, int nUpdateId) = 0; - virtual bool EF_PrecacheResource(CDLight* pLS, float fMipFactor, float fTimeToReady, int Flags, int nUpdateId) = 0; - - virtual ITexture* EF_CreateCompositeTexture(int type, const char* szName, int nWidth, int nHeight, int nDepth, int nMips, int nFlags, ETEX_Format eTF, const STexComposition* pCompositions, size_t nCompositions, int8 nPriority = -1) = 0; - - virtual void PostLevelLoading() = 0; - virtual void PostLevelUnload() = 0; - - virtual CRenderObject* EF_AddPolygonToScene(SShaderItem& si, int numPts, const SVF_P3F_C4B_T2F* verts, const SPipTangents* tangs, CRenderObject* obj, const SRenderingPassInfo& passInfo, uint16* inds, int ninds, int nAW, const SRendItemSorter& rendItemSorter) = 0; - virtual CRenderObject* EF_AddPolygonToScene(SShaderItem& si, CRenderObject* obj, const SRenderingPassInfo& passInfo, int numPts, int ninds, SVF_P3F_C4B_T2F*& verts, SPipTangents*& tangs, uint16*& inds, int nAW, const SRendItemSorter& rendItemSorter) = 0; - - // This is a workaround for when an editor viewport needs to do immediate rendering - // in the editor. Specifically, global constants are updated in a deferred fashion, so - // if a viewport (like the lens flare view) starts doing main-thread rendering, those - // parameters are not bound. - virtual void ForceUpdateGlobalShaderParameters() {} - - ///////////////////////////////////////////////////////////////////////////////// - // Shaders/Shaders management ///////////////////////////////////////////////////////////////////////////////// - - virtual const char* EF_GetShaderMissLogPath() = 0; - - ///////////////////////////////////////////////////////////////////////////////// - virtual AZStd::string* EF_GetShaderNames(int& nNumShaders) = 0; - // Summary: - // Reloads file - virtual bool EF_ReloadFile (const char* szFileName) = 0; - // Summary: - // Reloads file at any time the renderer feels to do so (no guarantees, but likely on next frame update) - // Is threadsafe - virtual bool EF_ReloadFile_Request (const char* szFileName) = 0; - - // Summary: - // Remaps shader gen mask to common global mask. - virtual uint64 EF_GetRemapedShaderMaskGen(const char* name, uint64 nMaskGen = 0, bool bFixup = 0) = 0; - - virtual uint64 EF_GetShaderGlobalMaskGenFromString(const char* szShaderName, const char* szShaderGen, uint64 nMaskGen = 0) = 0; - virtual AZStd::string EF_GetStringFromShaderGlobalMaskGen(const char* szShaderName, uint64 nMaskGen = 0) = 0; - - virtual const SShaderProfile& GetShaderProfile(EShaderType eST) const = 0; - virtual void EF_SetShaderQuality(EShaderType eST, EShaderQuality eSQ) = 0; - - // Summary: - // Gets renderer quality. - virtual ERenderQuality EF_GetRenderQuality() const = 0; - // Summary: - // Gets shader type quality. - virtual EShaderQuality EF_GetShaderQuality(EShaderType eST) = 0; - // Summary: - // Loads shader item for name (name). - virtual SShaderItem EF_LoadShaderItem (const char* szName, bool bShare, int flags = 0, SInputShaderResources* Res = NULL, uint64 nMaskGen = 0) = 0; - // Summary: - // Loads shader for name (name). - virtual IShader* EF_LoadShader (const char* name, int flags = 0, uint64 nMaskGen = 0) = 0; - // Summary: - // Reinitializes all shader files (build hash tables). - virtual void EF_ReloadShaderFiles (int nCategory) = 0; - // Summary: - // Reloads all texture files. - virtual void EF_ReloadTextures () = 0; - // Summary: - // Gets texture object by ID. - virtual ITexture* EF_GetTextureByID(int Id) = 0; - // Summary: - // Gets texture object by Name. - virtual ITexture* EF_GetTextureByName(const char* name, uint32 flags = 0) = 0; - // Summary: - // Loads the texture for name(nameTex). - virtual ITexture* EF_LoadTexture(const char* nameTex, uint32 flags = 0) = 0; - virtual ITexture* EF_LoadCubemapTexture(const char* nameTex, uint32 flags = 0) = 0; - // Summary: - // Loads default texture whose life cycle is managed by Texture Manager, do not try to release them by yourself! - virtual ITexture* EF_LoadDefaultTexture(const char* nameTex) = 0; - - // Summary: - // Loads lightmap for name. - virtual int EF_LoadLightmap (const char* name) = 0; - - // Summary: - // Starts using of the shaders (return first index for allow recursions). - virtual void EF_StartEf (const SRenderingPassInfo& passInfo) = 0; - - virtual SRenderObjData* EF_GetObjData(CRenderObject* pObj, bool bCreate, int nThreadID) = 0; - - // Summary: - // Gets CRenderObject for RE transformation. - //Get temporary RenderObject - virtual CRenderObject* EF_GetObject_Temp (int nThreadID) = 0; - - //Get permanent RenderObject - virtual CRenderObject* EF_DuplicateRO(CRenderObject* pObj, const SRenderingPassInfo& passInfo) = 0; - - // Summary: - // Adds shader to the list. - virtual void EF_AddEf (IRenderElement* pRE, SShaderItem& pSH, CRenderObject* pObj, const SRenderingPassInfo& passInfo, int nList, int nAW, const SRendItemSorter& rendItemSorter) = 0; - - //! Draw all shaded REs in the list - virtual void EF_EndEf3D (int nFlags, int nPrecacheUpdateId, int nNearPrecacheUpdateId, const SRenderingPassInfo& passInfo) = 0; - - virtual void EF_InvokeShadowMapRenderJobs(int nFlags) = 0; - - // Dynamic lights - void EF_ClearLightsList() {}; // For FC Compatibility. - virtual bool EF_IsFakeDLight (const CDLight* Source) = 0; - virtual void EF_ADDDlight(CDLight* Source, const SRenderingPassInfo& passInfo) = 0; - virtual bool EF_UpdateDLight(SRenderLight* pDL) = 0; - virtual bool EF_AddDeferredDecal([[maybe_unused]] const SDeferredDecal& rDecal){return true; } - - // Deferred lights/vis areas - - virtual int EF_AddDeferredLight(const CDLight& pLight, float fMult, const SRenderingPassInfo& passInfo, const SRendItemSorter& rendItemSorter) = 0; - virtual uint32 EF_GetDeferredLightsNum(eDeferredLightType eLightType = eDLT_DeferredLight) = 0; - virtual void EF_ClearDeferredLightsList() = 0; - - virtual uint8 EF_AddDeferredClipVolume(const IClipVolume* pClipVolume) = 0; - virtual bool EF_SetDeferredClipVolumeBlendData(const IClipVolume* pClipVolume, const SClipVolumeBlendInfo& blendInfo) = 0; - virtual void EF_ClearDeferredClipVolumesList() = 0; - - // called in between levels to free up memory - virtual void EF_ReleaseDeferredData() = 0; - - // called in between levels to free up memory - virtual void EF_ReleaseInputShaderResource(SInputShaderResources* pRes) = 0; - - ////////////////////////////////////////////////////////////////////////// - // Post processing effects interfaces - - virtual void EF_SetPostEffectParam(const char* pParam, float fValue, bool bForceValue = false) = 0; - virtual void EF_SetPostEffectParamVec4(const char* pParam, const Vec4& pValue, bool bForceValue = false) = 0; - virtual void EF_SetPostEffectParamString(const char* pParam, const char* pszArg) = 0; - - virtual void EF_GetPostEffectParam(const char* pParam, float& fValue) = 0; - virtual void EF_GetPostEffectParamVec4(const char* pParam, Vec4& pValue) = 0; - virtual void EF_GetPostEffectParamString(const char* pParam, const char*& pszArg) = 0; - - virtual int32 EF_GetPostEffectID(const char* pPostEffectName) = 0; - - virtual void EF_ResetPostEffects(bool bOnSpecChange = false) = 0; - - virtual void SyncPostEffects() = 0; - - virtual void EF_DisableTemporalEffects() = 0; - - ////////////////////////////////////////////////////////////////////////// - - virtual void EF_AddWaterSimHit(const Vec3& vPos, float scale, float strength) = 0; - virtual void EF_DrawWaterSimHits() = 0; - - ///////////////////////////////////////////////////////////////////////////////// - // 2d interface for the shaders - ///////////////////////////////////////////////////////////////////////////////// - virtual void EF_EndEf2D(bool bSort) = 0; - - // Summary: - // Returns various Renderer Settings, see ERenderQueryTypes. - // Arguments: - // Query - e.g. EFQ_GetShaderCombinations. - // rInOut - Input/Output Parameter, depends on the query if written to/read from, or both - void EF_Query(ERenderQueryTypes eQuery) - { - EF_QueryImpl(eQuery, NULL, 0, NULL, 0); - } - template - void EF_Query(ERenderQueryTypes eQuery, T& rInOut) - { - EF_QueryImpl(eQuery, static_cast(&rInOut), sizeof(T), NULL, 0); - } - template - void EF_Query(ERenderQueryTypes eQuery, T0& rInOut0, T1& rInOut1) - { - EF_QueryImpl(eQuery, static_cast(&rInOut0), sizeof(T0), static_cast(&rInOut1), sizeof(T1)); - } - - // Summary: - // Toggles render mesh garbage collection - // Arguments: - // Param - - virtual void ForceGC() = 0; - - // Remarks: - // For stats. - virtual int GetPolyCount() const = 0; - virtual void GetPolyCount(int& nPolygons, int& nShadowVolPolys) const = 0; - - // Note: - // 3d engine set this color to fog color. - virtual void SetClearColor(const Vec3& vColor) = 0; - - virtual void SetClearBackground(bool bClearBackground) = 0; - - // Summary: - // Creates/deletes RenderMesh object. - virtual _smart_ptr CreateRenderMesh( - const char* szType - , const char* szSourceName - , IRenderMesh::SInitParamerers* pInitParams = NULL - , ERenderMeshType eBufType = eRMT_Static - ) = 0; - - virtual _smart_ptr CreateRenderMeshInitialized( - const void* pVertBuffer, int nVertCount, const AZ::Vertex::Format& vertexFormat, - const vtx_idx* pIndices, int nIndices, - const PublicRenderPrimitiveType nPrimetiveType, const char* szType, const char* szSourceName, ERenderMeshType eBufType = eRMT_Static, - int nMatInfoCount = 1, int nClientTextureBindID = 0, - bool (* PrepareBufferCallback)(IRenderMesh*, bool) = NULL, - void* CustomData = NULL, - bool bOnlyVideoBuffer = false, - bool bPrecache = true, - const SPipTangents* pTangents = NULL, bool bLockForThreadAcc = false, Vec3* pNormals = NULL) = 0; - - //Pass false to get a frameID that increments by one each frame. For this case the increment happens in the game thread at the beginning of the frame. - virtual int GetFrameID(bool bIncludeRecursiveCalls = true) = 0; - - virtual void MakeMatrix(const Vec3& pos, const Vec3& angles, const Vec3& scale, Matrix34* mat) = 0; - - // Description: - // Draws text queued. - // Note: - // Position can be in 3d or in 2d depending on the flags. - virtual void DrawTextQueued(Vec3 pos, SDrawTextInfo& ti, const char* format, va_list args) = 0; - - // Description: - // Draws text queued. - // Note: - // Position can be in 3d or in 2d depending on the flags. - virtual void DrawTextQueued(Vec3 pos, SDrawTextInfo& ti, const char* text) = 0; - - ////////////////////////////////////////////////////////////////////// - - virtual float ScaleCoordX(float value) const = 0; - virtual float ScaleCoordY(float value) const = 0; - virtual void ScaleCoord(float& x, float& y) const = 0; - - virtual void SetState(int State, int AlphaRef = -1) = 0; - virtual void SetCullMode (int mode = R_CULL_BACK) = 0; - virtual void SetStencilState(int st, uint32 nStencRef, uint32 nStencMask, uint32 nStencWriteMask, bool bForceFullReadMask = false) = 0; - - virtual void PushProfileMarker(const char* label) = 0; - virtual void PopProfileMarker(const char* label) = 0; - - virtual bool EnableFog(bool enable) = 0; - virtual void SetFogColor(const ColorF& color) = 0; - - virtual void SetColorOp(byte eCo, byte eAo, byte eCa, byte eAa) = 0; - virtual void SetSrgbWrite(bool srgbWrite) = 0; - - // for one frame allows to disable limit of texture streaming requests - virtual void RequestFlushAllPendingTextureStreamingJobs([[maybe_unused]] int nFrames) { } - - // allows to dynamically adjust texture streaming load depending on game conditions - virtual void SetTexturesStreamingGlobalMipFactor([[maybe_unused]] float fFactor) { } - - ////////////////////////////////////////////////////////////////////// - // Summary: - // Interface for auxiliary geometry (for debugging, editor purposes, etc.) - virtual IRenderAuxGeom* GetIRenderAuxGeom(void* jobID = 0) = 0; - ////////////////////////////////////////////////////////////////////// - - // Interface for renderer side SVO - virtual ISvoRenderer* GetISvoRenderer() { return 0; } - - virtual IColorGradingController* GetIColorGradingController() = 0; - virtual IStereoRenderer* GetIStereoRenderer() = 0; - - virtual ITexture* Create2DTexture(const char* name, int width, int height, int numMips, int flags, unsigned char* data, ETEX_Format format) = 0; - virtual void TextToScreen(float x, float y, const char* format, ...) PRINTF_PARAMS(4, 5) = 0; - virtual void TextToScreenColor(int x, int y, float r, float g, float b, float a, const char* format, ...) PRINTF_PARAMS(8, 9) = 0; - virtual void ResetToDefault() = 0; - virtual void SetMaterialColor(float r, float g, float b, float a) = 0; - - // Sets default Blend, DepthStencil and Raster states. - virtual void SetDefaultRenderStates() = 0; - - virtual void Graph(byte* g, int x, int y, int wdt, int hgt, int nC, int type, const char* text, ColorF& color, float fScale) = 0; - virtual void EF_RenderTextMessages() = 0; - - virtual void ClearTargetsImmediately(uint32 nFlags) = 0; - virtual void ClearTargetsImmediately(uint32 nFlags, const ColorF& Colors, float fDepth) = 0; - virtual void ClearTargetsImmediately(uint32 nFlags, const ColorF& Colors) = 0; - virtual void ClearTargetsImmediately(uint32 nFlags, float fDepth) = 0; - - virtual void ClearTargetsLater(uint32 nFlags) = 0; - virtual void ClearTargetsLater(uint32 nFlags, const ColorF& Colors, float fDepth) = 0; - virtual void ClearTargetsLater(uint32 nFlags, const ColorF& Colors) = 0; - virtual void ClearTargetsLater(uint32 nFlags, float fDepth) = 0; - - virtual void ReadFrameBuffer(unsigned char* pRGB, int nImageX, int nSizeX, int nSizeY, ERB_Type eRBType, bool bRGBA, int nScaledX = -1, int nScaledY = -1) = 0; - virtual void ReadFrameBufferFast(uint32* pDstARGBA8, int dstWidth, int dstHeight, bool BGRA = true) = 0; - - // Note: - // The following functions will be removed. - virtual void EnableVSync(bool enable) = 0; - - virtual void CreateResourceAsync(SResourceAsync* Resource) = 0; - virtual void ReleaseResourceAsync(SResourceAsync* Resource) = 0; - virtual void ReleaseResourceAsync(AZStd::unique_ptr pResource) = 0; - virtual unsigned int DownLoadToVideoMemory(const byte* data, int w, int h, ETEX_Format eTFSrc, ETEX_Format eTFDst, int nummipmap, bool repeat = true, int filter = FILTER_BILINEAR, int Id = 0, const char* szCacheName = NULL, int flags = 0, EEndian eEndian = eLittleEndian, RectI* pRegion = NULL, bool bAsynDevTexCreation = false) = 0; - virtual unsigned int DownLoadToVideoMemory3D(const byte* data, int w, int h, int d, ETEX_Format eTFSrc, ETEX_Format eTFDst, int nummipmap, bool repeat = true, int filter = FILTER_BILINEAR, int Id = 0, const char* szCacheName = NULL, int flags = 0, EEndian eEndian = eLittleEndian, RectI* pRegion = NULL, bool bAsynDevTexCreation = false) = 0; - virtual unsigned int DownLoadToVideoMemoryCube(const byte* data, int w, int h, ETEX_Format eTFSrc, ETEX_Format eTFDst, int nummipmap, bool repeat = true, int filter = FILTER_BILINEAR, int Id = 0, const char* szCacheName = NULL, int flags = 0, EEndian eEndian = eLittleEndian, RectI* pRegion = NULL, bool bAsynDevTexCreation = false) = 0; - virtual void UpdateTextureInVideoMemory(uint32 tnum, const byte* newdata, int posx, int posy, int w, int h, ETEX_Format eTFSrc = eTF_B8G8R8, int posz = 0, int sizez = 1) = 0; - - virtual bool DXTCompress(const byte* raw_data, int nWidth, int nHeight, ETEX_Format eTF, bool bUseHW, bool bGenMips, int nSrcBytesPerPix, MIPDXTcallback callback) = 0; - virtual bool DXTDecompress(const byte* srcData, size_t srcFileSize, byte* dstData, int nWidth, int nHeight, int nMips, ETEX_Format eSrcTF, bool bUseHW, int nDstBytesPerPix) = 0; - virtual void RemoveTexture(unsigned int TextureId) = 0; - virtual void DeleteFont(IFFont* font) = 0; - - ///////////////////////////////////////////////////////////////////////////////////////////////////// - // This routines uses 2 destination surfaces. It triggers a backbuffer copy to one of its surfaces, - // and then copies the other surface to system memory. This hopefully will remove any - // CPU stalls due to the rect lock call since the buffer will already be in system - // memory when it is called - // Inputs : - // pDstARGBA8 : Pointer to a buffer that will hold the captured frame (should be at least 4*dstWidth*dstHieght for RGBA surface) - // destinationWidth : Width of the frame to copy - // destinationHeight : Height of the frame to copy - // - // Note : If dstWidth or dstHeight is larger than the current surface dimensions, the dimensions - // of the surface are used for the copy - // - virtual bool CaptureFrameBufferFast(unsigned char* pDstRGBA8, int destinationWidth, int destinationHeight) = 0; - - - ///////////////////////////////////////////////////////////////////////////////////////////////////// - // Copy a captured surface to a buffer - // - // Inputs : - // pDstARGBA8 : Pointer to a buffer that will hold the captured frame (should be at least 4*dstWidth*dstHieght for RGBA surface) - // destinationWidth : Width of the frame to copy - // destinationHeight : Height of the frame to copy - // - // Note : If dstWidth or dstHeight is larger than the current surface dimensions, the dimensions - // of the surface are used for the copy - // - virtual bool CopyFrameBufferFast(unsigned char* pDstRGBA8, int destinationWidth, int destinationHeight) = 0; - - - - ///////////////////////////////////////////////////////////////////////////////////////////////////// - // This routine registers a callback address that is called when a new frame is available - // Inputs : - // pCapture : Address of the ICaptureFrameListener object - // - // Outputs : returns true if successful, otherwise false - // - virtual bool RegisterCaptureFrame(ICaptureFrameListener* pCapture) = 0; - - ///////////////////////////////////////////////////////////////////////////////////////////////////// - // This routine unregisters a callback address that was previously registered - // Inputs : - // pCapture : Address of the ICaptureFrameListener object to unregister - // - // Outputs : returns true if successful, otherwise false - // - virtual bool UnRegisterCaptureFrame(ICaptureFrameListener* pCapture) = 0; - - - ///////////////////////////////////////////////////////////////////////////////////////////////////// - // This routine initializes 2 destination surfaces for use by the CaptureFrameBufferFast routine - // It also, captures the current backbuffer into one of the created surfaces - // - // Inputs : - // bufferWidth : Width of capture buffer, on consoles the scaling is done on the GPU. Pass in 0 (the default) to use backbuffer dimensions - // bufferHeight : Height of capture buffer. - // - // Outputs : returns true if surfaces were created otherwise returns false - // - virtual bool InitCaptureFrameBufferFast(uint32 bufferWidth = 0, uint32 bufferHeight = 0) = 0; - - ///////////////////////////////////////////////////////////////////////////////////////////////////// - // This routine releases the 2 surfaces used for frame capture by the CaptureFrameBufferFast routine - // - // Inputs : None - // - // Returns : None - // - virtual void CloseCaptureFrameBufferFast(void) = 0; - - - ///////////////////////////////////////////////////////////////////////////////////////////////////// - // This routine checks for any frame buffer callbacks that are needed and calls them - // - // Inputs : None - // - // Outputs : None - // - virtual void CaptureFrameBufferCallBack(void) = 0; - - virtual void RegisterSyncWithMainListener(ISyncMainWithRenderListener* pListener) = 0; - virtual void RemoveSyncWithMainListener(const ISyncMainWithRenderListener* pListener) = 0; - - virtual void Set2DMode(uint32 orthoX, uint32 orthoY, TransformationMatrices& backupMatrices, float znear = -1e10f, float zfar = 1e10f) = 0; - virtual void Unset2DMode(const TransformationMatrices& restoringMatrices) = 0; - virtual void Set2DModeNonZeroTopLeft(float orthoLeft, float orthoTop, float orthoWidth, float orthoHeight, TransformationMatrices& backupMatrices, float znear = -1e10f, float zfar = 1e10f) = 0; - - virtual int ScreenToTexture(int nTexID) = 0; - virtual void EnableSwapBuffers(bool bEnable) = 0; - virtual WIN_HWND GetHWND() = 0; - - // Set the window icon to be displayed on the output window. - // The parameter is the path to a DDS texture file to be used as the icon. - // For best results, pass a square power-of-two sized texture, with a mip-chain. - virtual bool SetWindowIcon(const char* path) = 0; - - virtual void OnEntityDeleted(struct IRenderNode* pRenderNode) = 0; - - virtual int CreateRenderTarget(const char* name, int nWidth, int nHeight, const ColorF& clearColor, ETEX_Format eTF) = 0; - virtual bool DestroyRenderTarget (int nHandle) = 0; - virtual bool ResizeRenderTarget(int nHandle, int nWidth, int nHeight) = 0; - virtual bool SetRenderTarget(int nHandle, SDepthTexture* pDepthSurf = nullptr) = 0; - virtual SDepthTexture* CreateDepthSurface(int nWidth, int nHeight, bool shaderResourceView = false) = 0; - virtual void DestroyDepthSurface(SDepthTexture* pDepthSurf) = 0; - - // Note: - // Used for pausing timer related stuff. - // Example: - // For texture animations, and shader 'time' parameter. - virtual void PauseTimer(bool bPause) = 0; - - // Description: - // Creates an Interface to the public params container. - // Return: - // Created IShaderPublicParams interface. - virtual IShaderPublicParams* CreateShaderPublicParams() = 0; - - virtual void GetThreadIDs(threadID& mainThreadID, threadID& renderThreadID) const = 0; - - struct SArtProfileData - { - enum EArtProfileUnit - { - eArtProfileUnit_GPU = 0, - eArtProfileUnit_CPU, - eArtProfile_NumUnits - }; - - enum EArtProfileSections - { - eArtProfile_Shadows = 0, - eArtProfile_ZPass, - eArtProfile_Decals, - eArtProfile_Lighting, - eArtProfile_Opaque, - eArtProfile_Transparent, - eArtProfile_Max, - }; - - float times[eArtProfile_Max]; - float budgets[eArtProfile_Max]; - float total, budgetTotal; - - // detailed values for anything that is grouped together and can be timed - enum EBreakdownDetailValues - { - // Lighting - eArtProfileDetail_LightsAmbient, - eArtProfileDetail_LightsCubemaps, - eArtProfileDetail_LightsDeferred, - eArtProfileDetail_LightsShadowMaps, // just the cost of the shadow maps - - // Transparent - eArtProfileDetail_Reflections, - eArtProfileDetail_Caustics, - eArtProfileDetail_RefractionOverhead, // partial resolves - eArtProfileDetail_Rain, - eArtProfileDetail_LensOptics, - - eArtProfileDetail_Max, - }; - - float breakdowns[eArtProfileDetail_Max]; - - int batches, drawcalls, processedLights; - -#if defined(ENABLE_ART_RT_TIME_ESTIMATE) - int numStandardBatches; - int numStandardDrawCalls; - int numLightDrawCalls; - float actualRenderTimeMinusPost; - float actualRenderTimePost; - float actualMiscRTTime; - float actualTotalRTTime; -#endif - }; - - virtual void EnableGPUTimers2(bool bEnabled) = 0; - virtual void AllowGPUTimers2(bool bAllow) = 0; - virtual const RPProfilerStats* GetRPPStats(ERenderPipelineProfilerStats eStat, bool bCalledFromMainThread = true) const = 0; - virtual const RPProfilerStats* GetRPPStatsArray(bool bCalledFromMainThread = true) const = 0; - - virtual int GetPolygonCountByType(uint32 EFSList, EVertexCostTypes vct, uint32 z, bool bCalledFromMainThread = true) = 0; - - virtual void SetCloudShadowsParams(int nTexID, const Vec3& speed, float tiling, bool invert, float brightness) = 0; - virtual uint16 PushFogVolumeContribution(const SFogVolumeData& fogVolData, const SRenderingPassInfo& passInfo) = 0; - virtual void PushFogVolume(class CREFogVolume* pFogVolume, const SRenderingPassInfo& passInfo) = 0; - - virtual int GetMaxTextureSize() = 0; - - virtual const char* GetTextureFormatName(ETEX_Format eTF) = 0; - virtual int GetTextureFormatDataSize(int nWidth, int nHeight, int nDepth, int nMips, ETEX_Format eTF) = 0; - - virtual void SetDefaultMaterials(_smart_ptr pDefMat, _smart_ptr pTerrainDefMat) = 0; - - virtual IGPUParticleEngine* GetGPUParticleEngine() const { return 0; } - - virtual uint32 GetActiveGPUCount() const = 0; - virtual ShadowFrustumMGPUCache* GetShadowFrustumMGPUCache() = 0; - virtual const StaticArray& GetCachedShadowsResolution() const = 0; - virtual void SetCachedShadowsResolution(const StaticArray& arrResolutions) = 0; - virtual void UpdateCachedShadowsLodCount(int nGsmLods) const = 0; - - virtual void SetTexturePrecaching(bool stat) = 0; - - //platform specific - virtual void RT_InsertGpuCallback(uint32 context, GpuCallbackFunc callback) = 0; - virtual void EnablePipelineProfiler(bool bEnable) = 0; - - struct SRenderTimes - { - float fWaitForMain; - float fWaitForRender; - float fWaitForGPU; - float fTimeProcessedRT; - float fTimeProcessedRTScene; //The part of the render thread between the "SCENE" profiler labels - float fTimeProcessedGPU; - float fTimeGPUIdlePercent; - }; - virtual void GetRenderTimes(SRenderTimes& outTimes) = 0; - virtual float GetGPUFrameTime() = 0; - - // Enable the batch mode if the meshpools are used to enable quick and dirty flushes. - virtual void EnableBatchMode(bool enable) = 0; - // Flag level unloading in progress to disable f.i. rendermesh creation requests - virtual void EnableLevelUnloading(bool enable) = 0; - // Function to handle cleanup required if a level load fails - virtual void OnLevelLoadFailed() = 0; - - struct SDrawCallCountInfo - { - static const uint32 MESH_NAME_LENGTH = 32; - static const uint32 TYPE_NAME_LENGTH = 16; - - SDrawCallCountInfo() - : pPos(0, 0, 0) - , nZpass(0) - , nShadows(0) - , nGeneral(0) - , nTransparent(0) - , nMisc(0) - { - meshName[0] = '\0'; - typeName[0] = '\0'; - } - - void Update(CRenderObject* pObj, IRenderMesh* pRM); - - Vec3 pPos; - uint8 nZpass, nShadows, nGeneral, nTransparent, nMisc; - char meshName[MESH_NAME_LENGTH]; - char typeName[TYPE_NAME_LENGTH]; - }; - - //Debug draw call info (per node) - typedef AZStd::unordered_map< IRenderNode*, IRenderer::SDrawCallCountInfo, AZStd::hash, AZStd::equal_to, AZ::StdLegacyAllocator > RNDrawcallsMapNode; - typedef RNDrawcallsMapNode::iterator RNDrawcallsMapNodeItor; - - //Debug draw call info (per mesh) - typedef AZStd::unordered_map< IRenderMesh*, IRenderer::SDrawCallCountInfo, AZStd::hash, AZStd::equal_to, AZ::StdLegacyAllocator > RNDrawcallsMapMesh; - typedef RNDrawcallsMapMesh::iterator RNDrawcallsMapMeshItor; - -#if !defined(_RELEASE) - //Get draw call info for frame - virtual RNDrawcallsMapMesh& GetDrawCallsInfoPerMesh(bool mainThread = true) = 0; - virtual RNDrawcallsMapMesh& GetDrawCallsInfoPerMeshPreviousFrame(bool mainThread = true) = 0; - virtual RNDrawcallsMapNode& GetDrawCallsInfoPerNodePreviousFrame(bool mainThread = true) = 0; - virtual int GetDrawCallsPerNode(IRenderNode* pRenderNode) = 0; - virtual void ForceRemoveNodeFromDrawCallsMap(IRenderNode* pNode) = 0; -#endif - - virtual void CollectDrawCallsInfo(bool status) = 0; - virtual void CollectDrawCallsInfoPerNode(bool status) = 0; - - ////////////////////////////////////////////////////////////////////////// - // Summary: - // Helper functions to draw text. - ////////////////////////////////////////////////////////////////////////// - void DrawLabel(Vec3 pos, float font_size, const char* label_text, ...) PRINTF_PARAMS(4, 5) - { - va_list args; - va_start(args, label_text); - SDrawTextInfo ti; - ti.xscale = ti.yscale = font_size; - ti.flags = eDrawText_FixedSize | eDrawText_800x600; - DrawTextQueued(pos, ti, label_text, args); - va_end(args); - } - - void DrawLabelEx(Vec3 pos, float font_size, const float* pfColor, bool bFixedSize, bool bCenter, const char* label_text, ...) PRINTF_PARAMS(7, 8) - { - va_list args; - va_start(args, label_text); - SDrawTextInfo ti; - ti.xscale = ti.yscale = font_size; - ti.flags = ((bFixedSize) ? eDrawText_FixedSize : 0) | ((bCenter) ? eDrawText_Center : 0) | eDrawText_800x600; - if (pfColor) - { - ti.color[0] = pfColor[0]; - ti.color[1] = pfColor[1]; - ti.color[2] = pfColor[2]; - ti.color[3] = pfColor[3]; - } - DrawTextQueued(pos, ti, label_text, args); - va_end(args); - } - - void Draw2dLabelEx(float x, float y, float font_size, const ColorF& fColor, EDrawTextFlags flags, const char* label_text, ...) PRINTF_PARAMS(7, 8) - { - va_list args; - va_start(args, label_text); - SDrawTextInfo ti; - ti.xscale = ti.yscale = font_size; - ti.flags = flags; - { - ti.color[0] = fColor[0]; - ti.color[1] = fColor[1]; - ti.color[2] = fColor[2]; - ti.color[3] = fColor[3]; - } - DrawTextQueued(Vec3(x, y, 0.5f), ti, label_text, args); - va_end(args); - } - - void Draw2dLabel(float x, float y, float font_size, const float* pfColor, bool bCenter, const char* label_text, ...) PRINTF_PARAMS(7, 8) - { - va_list args; - va_start(args, label_text); - SDrawTextInfo ti; - ti.xscale = ti.yscale = font_size; - ti.flags = eDrawText_2D | eDrawText_800x600 | eDrawText_FixedSize | ((bCenter) ? eDrawText_Center : 0); - if (pfColor) - { - ti.color[0] = pfColor[0]; - ti.color[1] = pfColor[1]; - ti.color[2] = pfColor[2]; - ti.color[3] = pfColor[3]; - } - DrawTextQueued(Vec3(x, y, 0.5f), ti, label_text, args); - va_end(args); - } - - void Draw2dLabel(float x, float y, float font_size, const ColorF& fColor, bool bCenter, const char* label_text, ...) PRINTF_PARAMS(7, 8) - { - va_list args; - va_start(args, label_text); - SDrawTextInfo ti; - ti.xscale = ti.yscale = font_size; - ti.flags = eDrawText_2D | eDrawText_800x600 | eDrawText_FixedSize | ((bCenter) ? eDrawText_Center : 0); - { - ti.color[0] = fColor[0]; - ti.color[1] = fColor[1]; - ti.color[2] = fColor[2]; - ti.color[3] = fColor[3]; - } - DrawTextQueued(Vec3(x, y, 0.5f), ti, label_text, args); - va_end(args); - } - - // BLM - Added override that takes flags manually, so we can draw monospaced, etc. - void Draw2dLabelWithFlags(float x, float y, float font_size, const ColorF& fColor, uint32 flags, const char* label_text, ...) PRINTF_PARAMS(7, 8) - { - va_list args; - va_start(args, label_text); - SDrawTextInfo ti; - ti.xscale = ti.yscale = font_size; - ti.flags = flags; - { - ti.color[0] = fColor[0]; - ti.color[1] = fColor[1]; - ti.color[2] = fColor[2]; - ti.color[3] = fColor[3]; - } - DrawTextQueued(Vec3(x, y, 0.5f), ti, label_text, args); - va_end(args); - } - - /** - * Used to determine if the renderer has loaded default system - * textures yet. - * - * Some textures like s_ptexWhite aren't available until this is true. - * - * @return True if the renderer has loaded default resources - */ - virtual bool HasLoadedDefaultResources() { return false; } - - // Summary: - virtual SSkinningData* EF_CreateSkinningData(uint32 nNumBones, bool bNeedJobSyncVar, bool bUseMatrixSkinning = false) = 0; - virtual SSkinningData* EF_CreateRemappedSkinningData(uint32 nNumBones, SSkinningData* pSourceSkinningData, uint32 nCustomDataSize, uint32 pairGuid) = 0; - virtual void EF_ClearSkinningDataPool() = 0; - virtual int EF_GetSkinningPoolID() = 0; - - virtual void ClearShaderItem(SShaderItem* pShaderItem) = 0; - virtual void UpdateShaderItem(SShaderItem* pShaderItem, _smart_ptr pMaterial) = 0; - virtual void ForceUpdateShaderItem(SShaderItem* pShaderItem, _smart_ptr pMaterial) = 0; - virtual void RefreshShaderResourceConstants(SShaderItem* pShaderItem, IMaterial* pMaterial) = 0; - - // Summary: - // Determine if a switch to stereo mode will occur at the start of the next frame - virtual bool IsStereoModeChangePending() = 0; - - // Summary: - // Lock/Unlock the video memory buffer used by particles when using the jobsystem - virtual void LockParticleVideoMemory(uint32 nId) = 0; - virtual void UnLockParticleVideoMemory(uint32 nId) = 0; - - // Summary: - // tell the renderer that we will begin/stop spawning jobs which generate SRendItems - virtual void BeginSpawningGeneratingRendItemJobs(int nThreadID) = 0; - virtual void BeginSpawningShadowGeneratingRendItemJobs(int nThreadID) = 0; - virtual void EndSpawningGeneratingRendItemJobs() = 0; - - virtual void StartLoadtimePlayback(ILoadtimeCallback* pCallback) = 0; - virtual void StopLoadtimePlayback() = 0; - - // Summary: - // get the shared job state for SRendItem Generating jobs - virtual AZ::LegacyJobExecutor* GetGenerateRendItemJobExecutor() = 0; - virtual AZ::LegacyJobExecutor* GetGenerateShadowRendItemJobExecutor() = 0; - virtual AZ::LegacyJobExecutor* GetGenerateRendItemJobExecutorPreProcess() = 0; - virtual AZ::LegacyJobExecutor* GetFinalizeRendItemJobExecutor(int nThreadID) = 0; - virtual AZ::LegacyJobExecutor* GetFinalizeShadowRendItemJobExecutor(int nThreadID) = 0; - - virtual void FlushPendingTextureTasks() = 0; - - virtual void SetShadowJittering(float fShadowJittering) = 0; - virtual float GetShadowJittering() const = 0; - - virtual bool LoadShaderStartupCache() = 0; - virtual void UnloadShaderStartupCache() = 0; - - virtual bool LoadShaderLevelCache() = 0; - virtual void UnloadShaderLevelCache() = 0; - - virtual void StartScreenShot([[maybe_unused]] int e_ScreenShot) {}; - virtual void EndScreenShot([[maybe_unused]] int e_ScreenShot) {}; - - // Sets a renderer tracked cvar - virtual void SetRendererCVar(ICVar* pCVar, const char* pArgText, bool bSilentMode = false) = 0; - - // Get the render piepline - virtual SRenderPipeline* GetRenderPipeline() = 0; - - // Get the sahder manager - virtual CShaderMan* GetShaderManager() = 0; - - // Get render thread - virtual SRenderThread* GetRenderThread() = 0; - - // Get premade white texture - virtual ITexture* GetWhiteTexture() = 0; - - // Get the texture for the name and format given - virtual ITexture* GetTextureForName(const char* name, uint32 nFlags, ETEX_Format eFormat) = 0; - - // Get the camera view parameters - virtual const CameraViewParameters& GetViewParameters() = 0; - - // Get frame reset number - virtual uint32 GetFrameReset() = 0; - - // Get original depth buffer - virtual SDepthTexture* GetDepthBufferOrig() = 0; - - // Get width of backbuffer - virtual uint32 GetBackBufferWidth() = 0; - - // Get height of backbuffer - virtual uint32 GetBackBufferHeight() = 0; - - // Get the device buffer manager - virtual CDeviceBufferManager* GetDeviceBufferManager() = 0; - - // Get render tile info - virtual const SRenderTileInfo* GetRenderTileInfo() const = 0; - - // Returns precomputed identity matrix - virtual Matrix44A GetIdentityMatrix() = 0; - - // Get current GPU group Id. Used for tracking which GPU is being used - virtual int32 RT_GetCurrGpuID() const = 0; - - // Generate the next texture id - virtual int GenerateTextureId() = 0; - - // Set culling mode - virtual void SetCull(ECull eCull, bool bSkipMirrorCull = false) = 0; - - // Draw a 2D quad - virtual void DrawQuad(float x0, float y0, float x1, float y1, const ColorF& color, float z = 1.0f, float s0 = 0.0f, float t0 = 0.0f, float s1 = 1.0f, float t1 = 1.0f) = 0; - - // Draw a quad - virtual void DrawQuad3D(const Vec3& v0, const Vec3& v1, const Vec3& v2, const Vec3& v3, const ColorF& color, float ftx0, float fty0, float ftx1, float fty1) = 0; - - // Resets render pipeline state - virtual void FX_ResetPipe() = 0; - - // Gets an (existing) depth surface of the dimensions given - virtual SDepthTexture* FX_GetDepthSurface(int nWidth, int nHeight, bool bAA, bool shaderResourceView = false) = 0; - - // Check to see if buffers are full and if so flush - virtual void FX_CheckOverflow(int nVerts, int nInds, IRenderElement* re, int* nNewVerts = nullptr, int* nNewInds = nullptr) = 0; - - // Perform pre render work - virtual void FX_PreRender(int Stage) = 0; - - // Perform post render work - virtual void FX_PostRender() = 0; - - // Set render states - virtual void FX_SetState(int st, int AlphaRef = -1, int RestoreState = 0) = 0; - - // Commit render states - virtual void FX_CommitStates(const SShaderTechnique* pTech, const SShaderPass* pPass, bool bUseMaterialState) = 0; - - // Commit changes made thus dar - virtual void FX_Commit(bool bAllowDIP = false) = 0; - - // Sets vertex declaration - virtual long FX_SetVertexDeclaration(int StreamMask, const AZ::Vertex::Format& vertexFormat) = 0; - - // Draw indexed prim - virtual void FX_DrawIndexedPrimitive(eRenderPrimitiveType eType, int nVBOffset, int nMinVertexIndex, int nVerticesCount, int nStartIndex, int nNumIndices, bool bInstanced = false) = 0; - - // Set Index stream - virtual long FX_SetIStream(const void* pB, uint32 nOffs, RenderIndexType idxType) = 0; - - // Set vertex stream - virtual long FX_SetVStream(int nID, const void* pB, uint32 nOffs, uint32 nStride, uint32 nFreq = 1) = 0; - - // Draw primitives - virtual void FX_DrawPrimitive(eRenderPrimitiveType eType, int nStartVertex, int nVerticesCount, int nInstanceVertices = 0) = 0; - - // Clear texture - virtual void FX_ClearTarget(ITexture* pTex) = 0; - - // Clear depth - virtual void FX_ClearTarget(SDepthTexture* pTex) = 0; - - // Set render target - virtual bool FX_SetRenderTarget(int nTarget, void* pTargetSurf, SDepthTexture* pDepthTarget, uint32 nTileCount = 1) = 0; - - // Pushes render target - virtual bool FX_PushRenderTarget(int nTarget, void* pTargetSurf, SDepthTexture* pDepthTarget, uint32 nTileCount = 1) = 0; - - // Sets up the render target - virtual bool FX_SetRenderTarget(int nTarget, CTexture* pTarget, SDepthTexture* pDepthTarget, bool bPush = false, int nCMSide = -1, bool bScreenVP = false, uint32 nTileCount = 1) = 0; - - // Push render target - virtual bool FX_PushRenderTarget(int nTarget, CTexture* pTarget, SDepthTexture* pDepthTarget, int nCMSide = -1, bool bScreenVP = false, uint32 nTileCount = 1) = 0; - - // Restore render target - virtual bool FX_RestoreRenderTarget(int nTarget) = 0; - - // Pop render target - virtual bool FX_PopRenderTarget(int nTarget) = 0; - - // Set active render targets - virtual void FX_SetActiveRenderTargets(bool bAllowDIP = false) = 0; - - // Start an effect / shader / etc.. - virtual void FX_Start(CShader* ef, int nTech, CShaderResources* Res, IRenderElement* re) = 0; - - // Pop render target on render thread - virtual void RT_PopRenderTarget(int nTarget) = 0; - - // Sets viewport dimensions on render thread - virtual void RT_SetViewport(int x, int y, int width, int height, int id = -1) = 0; - - // Push render target on render thread - virtual void RT_PushRenderTarget(int nTarget, CTexture* pTex, SDepthTexture* pDS, int nS) = 0; - - // Setup scissors rect - virtual void EF_Scissor(bool bEnable, int sX, int sY, int sWdt, int sHgt) = 0; - -#ifdef SUPPORT_HW_MOUSE_CURSOR - virtual IHWMouseCursor* GetIHWMouseCursor() = 0; -#endif - - virtual int GetRecursionLevel() = 0; - - virtual int GetIntegerConfigurationValue(const char* varName, int defaultValue) = 0; - virtual float GetFloatConfigurationValue(const char* varName, float defaultValue) = 0; - virtual bool GetBooleanConfigurationValue(const char* varName, bool defaultValue) = 0; - - // Methods exposed to external libraries - virtual void ApplyDepthTextureState(int unit, int nFilter, bool clamp) = 0; - virtual ITexture* GetZTargetTexture() = 0; - virtual int GetTextureState(const STexState& TS) = 0; - virtual uint32 TextureDataSize(uint32 nWidth, uint32 nHeight, uint32 nDepth, uint32 nMips, uint32 nSlices, ETEX_Format eTF, ETEX_TileMode eTM = eTM_None) = 0; - virtual void ApplyForID(int nID, int nTUnit, int nTState, int nTexMaterialSlot, int nSUnit, bool useWhiteDefault) = 0; - virtual ITexture* Create3DTexture(const char* szName, int nWidth, int nHeight, int nDepth, int nMips, int nFlags, const byte* pData, ETEX_Format eTFSrc, ETEX_Format eTFDst) = 0; - virtual bool IsTextureExist(const ITexture* pTex) = 0; - virtual const char* NameForTextureFormat(ETEX_Format eTF) = 0; - virtual const char* NameForTextureType(ETEX_Type eTT) = 0; - virtual bool IsVideoThreadModeEnabled() = 0; - virtual IDynTexture* CreateDynTexture2(uint32 nWidth, uint32 nHeight, uint32 nTexFlags, const char* szSource, ETexPool eTexPool) = 0; - virtual uint32 GetCurrentTextureAtlasSize() = 0; - - virtual void BeginProfilerSection(const char* name, uint32 eProfileLabelFlags = 0) = 0; - virtual void EndProfilerSection(const char* name) = 0; - virtual void AddProfilerLabel(const char* name) = 0; - -private: - // use private for EF_Query to prevent client code to submit arbitrary combinations of output data/size - virtual void EF_QueryImpl(ERenderQueryTypes eQuery, void* pInOut0, uint32 nInOutSize0, void* pInOut1, uint32 nInOutSize1) = 0; -}; - -struct SShaderCacheStatistics -{ - size_t m_nTotalLevelShaderCacheMisses; - size_t m_nGlobalShaderCacheMisses; - size_t m_nNumShaderAsyncCompiles; - bool m_bShaderCompileActive; - - SShaderCacheStatistics() - : m_nTotalLevelShaderCacheMisses(0) - , m_nGlobalShaderCacheMisses(0) - , m_nNumShaderAsyncCompiles(0) - , m_bShaderCompileActive(false) - {} -}; - -// The statistics about the pool for render mesh data -// Note: -struct SMeshPoolStatistics -{ - // The size of the mesh data size in bytes - size_t nPoolSize; - - // The amount of memory currently in use in the pool - size_t nPoolInUse; - - // The highest amount of memory allocated within the mesh data pool - size_t nPoolInUsePeak; - - // The size of the mesh data size in bytes - size_t nInstancePoolSize; - - // The amount of memory currently in use in the pool - size_t nInstancePoolInUse; - - // The highest amount of memory allocated within the mesh data pool - size_t nInstancePoolInUsePeak; - - size_t nFallbacks; - size_t nInstanceFallbacks; - size_t nFlushes; - - SMeshPoolStatistics() - : nPoolSize() - , nPoolInUse() - , nInstancePoolSize() - , nInstancePoolInUse() - , nInstancePoolInUsePeak() - , nFallbacks() - , nInstanceFallbacks() - , nFlushes() - {} -}; - -struct SRendererQueryGetAllTexturesParam -{ - SRendererQueryGetAllTexturesParam() - : pTextures(NULL) - , numTextures(0) - { - } - - _smart_ptr* pTextures; - uint32 numTextures; -}; - - -////////////////////////////////////////////////////////////////////// - -#define STRIPTYPE_NONE 0 -#define STRIPTYPE_ONLYLISTS 1 -#define STRIPTYPE_SINGLESTRIP 2 -#define STRIPTYPE_MULTIPLESTRIPS 3 -#define STRIPTYPE_DEFAULT 4 - -///////////////////////////////////////////////////////////////////// - -struct IRenderMesh; - -//DOC-IGNORE-BEGIN -#include "VertexFormats.h" -//DOC-IGNORE-END - -struct SRestLightingInfo -{ - SRestLightingInfo() - { - averDir.zero(); - averCol = Col_Black; - refPoint.zero(); - } - Vec3 averDir; - ColorF averCol; - Vec3 refPoint; + SVF_P2F_C4B_T2F_F4B* m_vertices = nullptr; + uint16* m_indices = nullptr; + int m_numVertices = 0; + int m_numIndices = 0; }; +using DynUiPrimitiveList = AZStd::intrusive_slist>; class CLodValue { public: - CLodValue() - { - m_nLodA = -1; - m_nLodB = -1; - m_nDissolveRef = 0; - } + CLodValue() = default; CLodValue(int nLodA) { m_nLodA = aznumeric_caster(nLodA); - m_nLodB = -1; - m_nDissolveRef = 0; } CLodValue(int nLodA, uint8 nDissolveRef, int nLodB) @@ -2467,140 +218,7 @@ public: uint8 DissolveRefB() const { return 255 - m_nDissolveRef; } private: - int16 m_nLodA; - int16 m_nLodB; - uint8 m_nDissolveRef; -}; - -// Description: -// Structure used to pass render parameters to Render() functions of IStatObj and ICharInstance. -struct SRendParams -{ - SRendParams() - { - memset(this, 0, sizeof(SRendParams)); - fAlpha = 1.f; - fRenderQuality = 1.f; - nRenderList = EFSLIST_GENERAL; - nAfterWater = 1; - mRenderFirstContainer = false; - NoDecalReceiver = false; - } - - // Summary: - // object transformations. - Matrix34* pMatrix; - struct SInstancingInfo* pInstInfo; - // Summary: - // object previous transformations - motion blur specific. - Matrix34* pPrevMatrix; - // Summary: - // VisArea that contains this object, used for RAM-ambient cube query - IVisArea* m_pVisArea; - // Summary: - // Override material. - _smart_ptr pMaterial; - // Summary: - // Weights stream for deform morphs. - IRenderMesh* pWeights; - // Summary: - // Object Id for objects identification in renderer. - struct IRenderNode* pRenderNode; - // Summary: - // Unique object Id for objects identification in renderer. - void* pInstance; - // Summary: - // TerrainTexInfo for grass. - struct SSectorTextureSet* pTerrainTexInfo; - // Summary: - // storage for LOD transition states. - struct CRNTmpData** ppRNTmpData; - // Summary: - // dynamic render data object which can be set by the game - AZStd::vector* pShaderParams; - // Summary: - // Ambient color for the object. - ColorF AmbientColor; - // Summary: - // Custom sorting offset. - float fCustomSortOffset; - // Summary: - // Object alpha. - float fAlpha; - // Summary: - // Distance from camera. - float fDistance; - // Summary: - // Quality of shaders rendering. - float fRenderQuality; - // Summary: - // Light mask to specify which light to use on the object. - uint32 nDLightMask; - // Summary: - // Approximate information about the lights not included into nDLightMask. - // SRestLightingInfo restLightInfo; - // Summary: - // CRenderObject flags. - int32 dwFObjFlags; - // Summary: - // Material layers blending amount - uint32 nMaterialLayersBlend; - // Summary: - // Vision modes params - uint32 nVisionParams; - // Summary: - // Vision modes params - uint32 nHUDSilhouettesParams; - // Summary: - // Defines what pieces of pre-broken geometry has to be rendered - uint64 nSubObjHideMask; - - // Defines per object float custom data - float fCustomData[4]; - - // Custom TextureID - int16 nTextureID; - - // Defines per object custom flags - uint16 nCustomFlags; - - // The LOD value compute for rendering - CLodValue lodValue; - - // Defines per object custom data - uint8 nCustomData; - - // Summary: - // Defines per object DissolveRef value if used by shader. - uint8 nDissolveRef; - // Summary: - // per-instance vis area stencil ref id - uint8 nClipVolumeStencilRef; - // Summary: - // Custom offset for sorting by distance. - uint8 nAfterWater; - - // Summary: - // Material layers bitmask -> which material layers are active. - uint8 nMaterialLayers; - - // Summary: - // Force a sort value for render elements. - uint8 nRenderList; - // Summary: - // Special sorter to ensure correct ordering even if parts of the 3DEngine are run in parallel - uint32 rendItemSorter; - // Summary: - // Render the first particle container only, instead of all the containers - bool mRenderFirstContainer; - - // Summary: - // Check if the preview would Show Wireframe - Vera,Confetti - bool bIsShowWireframe; - - //Summary: - // Force drawing static instead of deformable meshes - bool bForceDrawStatic; - - bool NoDecalReceiver; + int16 m_nLodA = -1; + int16 m_nLodB = -1; + uint8 m_nDissolveRef = 0; }; diff --git a/Code/Legacy/CryCommon/IShader.h b/Code/Legacy/CryCommon/IShader.h index 5f00eb56d3..93f8534dfc 100644 --- a/Code/Legacy/CryCommon/IShader.h +++ b/Code/Legacy/CryCommon/IShader.h @@ -9,9 +9,6 @@ // Description : Shaders common interface. - -#ifndef CRYINCLUDE_CRYCOMMON_ISHADER_H -#define CRYINCLUDE_CRYCOMMON_ISHADER_H #pragma once @@ -20,19 +17,17 @@ #endif #include "smartptr.h" -#include "Cry_Vector2.h" + #include "Cry_Vector3.h" -#include "Cry_Matrix33.h" + #include "Cry_Color.h" #include "smartptr.h" -#include // <> required for Interfuscator -#include "smartptr.h" + #include "VertexFormats.h" #include -#include -#include -#include "Cry_XOptimise.h" + + #include #include @@ -43,9 +38,12 @@ class CREMesh; struct IRenderMesh; struct IShader; struct IVisArea; -class CShader; + class CRendElement; class CRendElementBase; +class CTexture; +class CTexAnim; +class CShader; class ITexAnim; struct SShaderPass; struct SShaderItem; @@ -192,7 +190,7 @@ enum ESamplerType union UParamVal { - byte m_Byte; + int8 m_Byte; bool m_Bool; short m_Short; int m_Int; @@ -215,7 +213,7 @@ struct SShaderParam uint8 m_eSemantic; uint8 m_Pad[3] = { 0 }; - inline void Construct() + void Construct() { memset(&m_Value, 0, sizeof(m_Value)); m_Type = eType_UNKNOWN; @@ -223,7 +221,8 @@ struct SShaderParam m_Name.clear(); m_Script.clear(); } - inline SShaderParam() + + SShaderParam() { Construct(); } @@ -246,18 +245,20 @@ struct SShaderParam } } - inline void Destroy() + void Destroy() { if (m_Type == eType_STRING) { delete [] m_Value.m_String; } } - inline ~SShaderParam() + + ~SShaderParam() { Destroy(); } - inline SShaderParam (const SShaderParam& src) + + SShaderParam (const SShaderParam& src) { m_Name = src.m_Name; m_Script = src.m_Script; @@ -274,7 +275,8 @@ struct SShaderParam m_Value = src.m_Value; } } - inline SShaderParam& operator = (const SShaderParam& src) + + SShaderParam& operator = (const SShaderParam& src) { this->~SShaderParam(); new(this)SShaderParam(src); @@ -348,7 +350,7 @@ struct SShaderParam static bool GetValue(uint8 eSemantic, AZStd::vector* Params, float* v, int nID); - inline void CopyValue(const SShaderParam& src) + void CopyValue(const SShaderParam& src) { if (m_Type == eType_STRING && this != &src) { @@ -366,131 +368,20 @@ struct SShaderParam m_Value = src.m_Value; } - inline void CopyValueNoString(const SShaderParam& src) + void CopyValueNoString(const SShaderParam& src) { assert(m_Type != eType_STRING && src.m_Type != eType_STRING); m_Value = src.m_Value; } - inline void CopyType(const SShaderParam& src) + void CopyType(const SShaderParam& src) { m_Type = src.m_Type; } }; -// Description: -// IShaderPublicParams can be used to hold a collection of the shader public params. -// Manipulate this collection, and use them during rendering by submit to the SRendParams. -struct IShaderPublicParams -{ - // - virtual ~IShaderPublicParams(){} - virtual void AddRef() = 0; - virtual void Release() = 0; - - // Description: - // Changes number of parameters in collection. - virtual void SetParamCount(int nParam) = 0; - - // Description: - // Retrieves number of parameters in collection. - virtual int GetParamCount() const = 0; - - // Description: - // Retrieves shader public parameter at specified index of the collection. - virtual SShaderParam& GetParam(int nIndex) = 0; - virtual const SShaderParam& GetParam(int nIndex) const = 0; - - // Description: - // Retrieves shader public parameter at specified index of the collection. - virtual SShaderParam* GetParamByName(const char* pszName) = 0; - virtual const SShaderParam* GetParamByName(const char* pszName) const = 0; - - virtual SShaderParam* GetParamBySemantic(uint8 eParamSemantic) = 0; - virtual const SShaderParam* GetParamBySemantic(uint8 eParamSemantic) const = 0; - - // Description: - // Sets a shader parameter (and if doesn't exists, add it to the parameters list). - virtual void SetParam(const char* pszName, UParamVal& pParam, EParamType nType = eType_FLOAT, uint8 eSemantic = 0) = 0; - - // Description: - // Assigns shader public parameter at specified index of the collection. - virtual void SetParam(int nIndex, const SShaderParam& param) = 0; - - // Description: - // Assigns existing shader parameters list. - virtual void SetShaderParams(const AZStd::vector& pParams) = 0; - - // Description: - // Adds a new shader public parameter at the end of the collection. - virtual void AddParam(const SShaderParam& param) = 0; - - // Description: - // Removes a shader public parameter - virtual void RemoveParamByName(const char* pszName) = 0; - virtual void RemoveParamBySemantic(uint8 eParamSemantic) = 0; - - // Description: - // Assigns collection of shader public parameters to the specified render params structure. - virtual void AssignToRenderParams(struct SRendParams& rParams) = 0; - - virtual uint8 GetSemanticByName(const char* pszName) = 0; - - // Description: - // Gets shader parameters. - virtual AZStd::vector* GetShaderParams() = 0; - virtual const AZStd::vector* GetShaderParams() const = 0; - // -}; - -//================================================================================= - -class CInputLightMaterial -{ -public: - CInputLightMaterial() - : m_Diffuse(0, 0, 0, 0) - , m_Specular(0, 0, 0, 0) - , m_Emittance(1, 1, 1, 0) - , m_Opacity(0) - , m_Smoothness(0) - { - // memset() - for (int i = 0; i < EFTT_MAX; i++) - { - m_Channels[i][0] = 0.0f, - m_Channels[i][1] = 1.0f; - } - } - - // scale & bias - ColorF m_Channels[EFTT_MAX][2]; - - // TODO: these will go away - ColorF m_Diffuse; - ColorF m_Specular; - ColorF m_Emittance; // RGB: Color, Alpha: Intensity (kcd/m2 or kilonits) - float m_Opacity; - float m_Smoothness; - - inline friend bool operator == (const CInputLightMaterial& m1, const CInputLightMaterial& m2) - { - return !memcmp(&m1, &m2, CInputLightMaterial::Size()); - } - - inline static int Size() - { - int nSize = sizeof(CInputLightMaterial); - return nSize; - } -}; - -class CTexture; -class CTexAnim; -#include - // Summary: // Vertex modificators definitions (must be 16 bit flag). @@ -505,170 +396,6 @@ class CTexAnim; // Note this is different than the technique flag FHF_POSITION_INVARIANT as that does custom behavior for terrain #define MDV_POSITION_INVARIANT 0x4000 -// Summary: -// Deformations/Morphing types. -enum EDeformType -{ - eDT_Unknown = 0, - eDT_SinWave = 1, - eDT_SinWaveUsingVtxColor = 2, - eDT_Bulge = 3, - eDT_Squeeze = 4, - eDT_Perlin2D = 5, - eDT_Perlin3D = 6, - eDT_FromCenter = 7, - eDT_Bending = 8, - eDT_ProcFlare = 9, - eDT_AutoSprite = 10, - eDT_Beam = 11, - eDT_FixedOffset = 12, -}; - -// Summary: -// Wave form evaluator flags. -enum EWaveForm -{ - eWF_None, - eWF_Sin, - eWF_HalfSin, - eWF_InvHalfSin, - eWF_Square, - eWF_Triangle, - eWF_SawTooth, - eWF_InvSawTooth, - eWF_Hill, - eWF_InvHill, -}; - -#define WFF_CLAMP 1 -#define WFF_LERP 2 - -// Summary: -// Wave form definition. -struct SWaveForm -{ - EWaveForm m_eWFType; - byte m_Flags; - - float m_Level; - float m_Level1; - float m_Amp; - float m_Amp1; - float m_Phase; - float m_Phase1; - float m_Freq; - float m_Freq1; - - SWaveForm(EWaveForm eWFType, float fLevel, float fAmp, float fPhase, float fFreq) - { - m_eWFType = eWFType; - m_Level = m_Level1 = fLevel; - m_Amp = m_Amp1 = fAmp; - m_Phase = m_Phase1 = fPhase; - m_Freq = m_Freq1 = fFreq; - } - - int Size() - { - int nSize = sizeof(SWaveForm); - return nSize; - } - SWaveForm() - { - memset(this, 0, sizeof(SWaveForm)); - } - bool operator == (const SWaveForm& wf) const - { - if (m_eWFType == wf.m_eWFType && m_Level == wf.m_Level && m_Amp == wf.m_Amp && m_Phase == wf.m_Phase && m_Freq == wf.m_Freq && m_Level1 == wf.m_Level1 && m_Amp1 == wf.m_Amp1 && m_Phase1 == wf.m_Phase1 && m_Freq1 == wf.m_Freq1 && m_Flags == wf.m_Flags) - { - return true; - } - return false; - } - - SWaveForm& operator += (const SWaveForm& wf) - { - m_Level += wf.m_Level; - m_Level1 += wf.m_Level1; - m_Amp += wf.m_Amp; - m_Amp1 += wf.m_Amp1; - m_Phase += wf.m_Phase; - m_Phase1 += wf.m_Phase1; - m_Freq += wf.m_Freq; - m_Freq1 += wf.m_Freq1; - return *this; - } -}; - -struct SWaveForm2 -{ - EWaveForm m_eWFType; - - float m_Level; - float m_Amp; - float m_Phase; - float m_Freq; - - SWaveForm2() - { - memset(this, 0, sizeof(SWaveForm2)); - } - bool operator == (const SWaveForm2& wf) const - { - if (m_eWFType == wf.m_eWFType && m_Level == wf.m_Level && m_Amp == wf.m_Amp && m_Phase == wf.m_Phase && m_Freq == wf.m_Freq) - { - return true; - } - return false; - } - - SWaveForm2& operator += (const SWaveForm2& wf) - { - m_Level += wf.m_Level; - m_Amp += wf.m_Amp; - m_Phase += wf.m_Phase; - m_Freq += wf.m_Freq; - return *this; - } -}; - -struct SDeformInfo -{ - EDeformType m_eType; - SWaveForm2 m_WaveX; - float m_fDividerX; - Vec3 m_vNoiseScale; - - SDeformInfo() - { - m_eType = eDT_Unknown; - m_fDividerX = 0.01f; - m_vNoiseScale = Vec3(1, 1, 1); - } - - inline bool operator == (const SDeformInfo& m) - { - if (m_eType == m.m_eType && - m_WaveX == m.m_WaveX && - m_vNoiseScale == m.m_vNoiseScale && - m_fDividerX == m.m_fDividerX) - { - return true; - } - - return false; - } - - int Size() - { - return sizeof(SDeformInfo); - } - - void GetMemoryUsage(ICrySizer* pSizer) const - { - pSizer->Add(*this); - } -}; //============================================================================== // CRenderObject @@ -734,21 +461,6 @@ struct SSkyInfo } }; -struct SBending -{ - Vec2 m_vBending; - float m_fMainBendingScale; - SWaveForm2 m_Waves[2]; - - SBending() - { - m_vBending.zero(); - m_fMainBendingScale = 1.f; - } - - Vec4 GetShaderConstants(float realTime) const; - void GetShaderConstantsStatic(float realTime, Vec4* vBendInfo) const; -}; // Description: // Interface for the skinnable objects (renderer calls its functions to get the skinning data). @@ -786,12 +498,6 @@ struct alignas(16) SRenderObjData uint64 m_nSubObjHideMask; - union - { - SBending* m_pBending; - }; - - SBending* m_BendingPrev; uint16 m_FogVolumeContribIdx[2]; @@ -819,8 +525,7 @@ struct alignas(16) SRenderObjData m_nCustomData = 0; m_nCustomFlags = 0; m_nHUDSilhouetteParams = 0; - m_pBending = nullptr; - m_BendingPrev = nullptr; + m_pShaderParams = nullptr; m_FogVolumeContribIdx[0] = m_FogVolumeContribIdx[1] = static_cast(-1); @@ -882,7 +587,7 @@ public: , m_IndirectId{0xFF} {} - inline bool IsValid() const + bool IsValid() const { return m_Id != 0xFFFF; } @@ -924,9 +629,9 @@ public: uint32 m_nMaterialLayers; //!< Which mtl layers active and how much to blend them - IRenderNode* m_pRenderNode; //!< Will define instance id. + _smart_ptr m_pCurrMaterial; //!< Parent material used for render object. - IRenderElement* m_pRE; //!< RenderElement used by this CRenderObject + PerInstanceConstantBufferKey m_PerInstanceConstantBufferKey; @@ -949,15 +654,15 @@ public: { Init(); } - ~CRenderObject() {}; + ~CRenderObject() {} //========================================================================================================= - inline Vec3 GetTranslation() const { return m_II.m_Matrix.GetTranslation(); } - inline float GetScaleX() const { return sqrt_tpl(m_II.m_Matrix(0, 0) * m_II.m_Matrix(0, 0) + m_II.m_Matrix(0, 1) * m_II.m_Matrix(0, 1) + m_II.m_Matrix(0, 2) * m_II.m_Matrix(0, 2)); } - inline float GetScaleZ() const { return sqrt_tpl(m_II.m_Matrix(2, 0) * m_II.m_Matrix(2, 0) + m_II.m_Matrix(2, 1) * m_II.m_Matrix(2, 1) + m_II.m_Matrix(2, 2) * m_II.m_Matrix(2, 2)); } + Vec3 GetTranslation() const { return m_II.m_Matrix.GetTranslation(); } + float GetScaleX() const { return sqrt_tpl(m_II.m_Matrix(0, 0) * m_II.m_Matrix(0, 0) + m_II.m_Matrix(0, 1) * m_II.m_Matrix(0, 1) + m_II.m_Matrix(0, 2) * m_II.m_Matrix(0, 2)); } + float GetScaleZ() const { return sqrt_tpl(m_II.m_Matrix(2, 0) * m_II.m_Matrix(2, 0) + m_II.m_Matrix(2, 1) * m_II.m_Matrix(2, 1) + m_II.m_Matrix(2, 2) * m_II.m_Matrix(2, 2)); } - inline void Init() + void Init() { m_ObjFlags = 0; m_nRenderQuality = 65535; @@ -976,11 +681,11 @@ public: m_fAlpha = 1.0f; m_nTextureID = -1; m_pCurrMaterial = nullptr; - m_pRE = nullptr; + m_PerInstanceConstantBufferKey = {}; m_nRTMask = 0; - m_pRenderNode = NULL; + m_NoDecalReceiver = false; m_data.Init(); @@ -989,13 +694,6 @@ public: ILINE Matrix34A& GetMatrix() { return m_II.m_Matrix; } - ILINE SRenderObjData* GetObjData() - { - return &m_data; - } - - IRenderElement* GetRE() { return m_pRE; } - void SetRE(IRenderElement* re) { m_pRE = re; } protected: @@ -1023,7 +721,7 @@ struct SResourceAsync { AZ_CLASS_ALLOCATOR(SResourceAsync, AZ::SystemAllocator, 0); int nReady; // 0: Not ready; 1: Ready; -1: Error - byte* pData; + int8* pData; EResClassName eClassName; // Resource class name char* Name; // Resource name union @@ -1131,164 +829,8 @@ enum ETexGenType ETG_Max }; -#define CASE_TEXMOD(var_name) \ - if (!_stricmp(#var_name, szParamName)) \ - { \ - var_name = fValue; \ - return true; \ - } \ -#define CASE_TEXMODANGLE(var_name) \ - if (!_stricmp(#var_name, szParamName)) \ - { \ - var_name = Degr2Word(fValue); \ - return true; \ - } \ -#define CASE_TEXMODBYTE(var_name) \ - if (!_stricmp(#var_name, szParamName)) \ - { \ - var_name = (byte)fValue; \ - return true; \ - } \ - -#define CASE_TEXMODBOOL(var_name) \ - if (!_stricmp(#var_name, szParamName)) \ - { \ - var_name = (fValue == 1.f); \ - return true; \ - } \ - -struct SEfTexModificator -{ - AZ_CLASS_ALLOCATOR(SEfTexModificator, AZ::SystemAllocator, 0); - bool SetMember(const char* szParamName, float fValue) - { - CASE_TEXMODBYTE(m_eTGType); - CASE_TEXMODBYTE(m_eRotType); - CASE_TEXMODBYTE(m_eMoveType[0]); - CASE_TEXMODBYTE(m_eMoveType[1]); - CASE_TEXMODBOOL(m_bTexGenProjected); - - CASE_TEXMOD(m_Tiling[0]); - CASE_TEXMOD(m_Tiling[1]); - CASE_TEXMOD(m_Tiling[2]); - CASE_TEXMOD(m_Offs[0]); - CASE_TEXMOD(m_Offs[1]); - CASE_TEXMOD(m_Offs[2]); - - CASE_TEXMODANGLE(m_Rot[0]); - CASE_TEXMODANGLE(m_Rot[1]); - CASE_TEXMODANGLE(m_Rot[2]); - CASE_TEXMODANGLE(m_RotOscRate[0]); - CASE_TEXMODANGLE(m_RotOscRate[1]); - CASE_TEXMODANGLE(m_RotOscRate[2]); - CASE_TEXMODANGLE(m_RotOscAmplitude[0]); - CASE_TEXMODANGLE(m_RotOscAmplitude[1]); - CASE_TEXMODANGLE(m_RotOscAmplitude[2]); - CASE_TEXMODANGLE(m_RotOscPhase[0]); - CASE_TEXMODANGLE(m_RotOscPhase[1]); - CASE_TEXMODANGLE(m_RotOscPhase[2]); - CASE_TEXMOD(m_RotOscCenter[0]); - CASE_TEXMOD(m_RotOscCenter[1]); - CASE_TEXMOD(m_RotOscCenter[2]); - - CASE_TEXMOD(m_OscRate[0]); - CASE_TEXMOD(m_OscRate[1]); - CASE_TEXMOD(m_OscAmplitude[0]); - CASE_TEXMOD(m_OscAmplitude[1]); - CASE_TEXMOD(m_OscPhase[0]); - CASE_TEXMOD(m_OscPhase[1]); - - return false; - } - - alignas(16) Matrix44 m_TexGenMatrix; - alignas(16) Matrix44 m_TexMatrix; - - float m_Tiling[3]; - float m_Offs[3]; - - float m_RotOscCenter[3]; - - float m_OscRate[2]; - float m_OscAmplitude[2]; - float m_OscPhase[2]; - - // This members are used only during updating of the matrices - float m_LastTime[2]; - float m_CurrentJitter[2]; - - uint16 m_RotOscPhase[3]; - uint16 m_Rot[3]; - uint16 m_RotOscRate[3]; - uint16 m_RotOscAmplitude[3]; - - uint8 m_eTGType; - uint8 m_eRotType; - uint8 m_eMoveType[2]; - bool m_bTexGenProjected; - - void Reset() - { - memset(this, 0, sizeof(*this)); - m_Tiling[0] = m_Tiling[1] = 1.0f; - } - inline SEfTexModificator() - { - Reset(); - } - inline SEfTexModificator(const SEfTexModificator& m) - { - if (&m != this) - { - memcpy(this, &m, sizeof(*this)); - } - } - SEfTexModificator& operator = (const SEfTexModificator& src) - { - if (&src != this) - { - this->~SEfTexModificator(); - new(this)SEfTexModificator(src); - } - return *this; - } - int Size() - { - return sizeof(*this); - } - - inline bool operator != (const SEfTexModificator& m) - { - return memcmp(this, &m, sizeof(*this)) != 0; - } - - inline bool isModified() - { - return ( m_eMoveType[0] != ETMM_NoChange || - m_eMoveType[1] != ETMM_NoChange || - m_eRotType != ETMR_NoChange || - m_Offs[0] != 0.0f || - m_Offs[1] != 0.0f || - m_Tiling[0] != 1.0f || - m_Tiling[1] != 1.0f || - m_Rot[0] != 0.0f || - m_Rot[1] != 0.0f || - m_Rot[2] != 0.0f ); - } -}; - -inline bool IsTextureModifierSupportedForTextureMap(EEfResTextures texture) -{ - // Custom uv modifiers are currently only supported for diffuse, detail, decal, 2nd diffuse, and emittance texture maps - if (texture == EFTT_DIFFUSE || texture == EFTT_DETAIL_OVERLAY || texture == EFTT_DECAL_OVERLAY || texture == EFTT_CUSTOM || texture == EFTT_EMITTANCE) - { - return true; - } - - return false; -} ////////////////////////////////////////////////////////////////////// #define FILTER_NONE -1 @@ -1307,81 +849,6 @@ inline bool IsTextureModifierSupportedForTextureMap(EEfResTextures texture) #define TADDR_MIRROR 2 #define TADDR_BORDER 3 -//============================================================================== -//------------------------------------------------------------------------------ -struct STexState -{ - struct - { - signed char m_nMinFilter : 8; - signed char m_nMagFilter : 8; - signed char m_nMipFilter : 8; - signed char m_nAddressU : 8; - signed char m_nAddressV : 8; - signed char m_nAddressW : 8; - signed char m_nAnisotropy : 8; - signed char padding : 8; - }; - DWORD m_dwBorderColor; - float m_MipBias; - void* m_pDeviceState; - bool m_bActive; - bool m_bComparison; - bool m_bSRGBLookup; - byte m_bPAD; - // NOTE: There are 4 more pad bytes that exist here because m_pDeviceState is a 64-bit pointer. - uint32 m_PadBytes; - - STexState () - { - // Make sure we clear everything, including "invisible" pad bytes. - memset(this, 0, sizeof(*this)); - } - STexState(int nFilter, bool bClamp) - { - memset(this, 0, sizeof(*this)); - int nAddress = bClamp ? TADDR_CLAMP : TADDR_WRAP; - SetFilterMode(nFilter); - SetClampMode(nAddress, nAddress, nAddress); - SetBorderColor(0); - } - STexState(int nFilter, int nAddressU, int nAddressV, int nAddressW, unsigned int borderColor) - { - memset(this, 0, sizeof(*this)); - SetFilterMode(nFilter); - SetClampMode(nAddressU, nAddressV, nAddressW); - SetBorderColor(borderColor); - } - - void Destroy(); - void Init(const STexState& src); - - ~STexState() { Destroy(); } - STexState(const STexState& src) { Init(src); } - STexState& operator = (const STexState& src) - { - this->~STexState(); - new(this)STexState(src); - return *this; - } - _inline friend bool operator == (const STexState& m1, const STexState& m2) - { - return (*(uint64*)&m1 == *(uint64*)&m2 && m1.m_dwBorderColor == m2.m_dwBorderColor && - m1.m_bActive == m2.m_bActive && m1.m_bComparison == m2.m_bComparison && m1.m_bSRGBLookup == m2.m_bSRGBLookup && - m1.m_MipBias == m2.m_MipBias); - } - void Release() - { - delete this; - } - - bool SetFilterMode(int nFilter); - bool SetClampMode(int nAddressU, int nAddressV, int nAddressW); - void SetBorderColor(DWORD dwColor); - void SetComparisonFilter(bool bEnable); - void PostCreate(); -}; - struct IRenderTarget { @@ -1390,569 +857,6 @@ struct IRenderTarget virtual void AddRef() = 0; }; -//============================================================================== -// FX shader texture sampler (description) -//------------------------------------------------------------------------------ -struct STexSamplerFX -{ -#if SHADER_REFLECT_TEXTURE_SLOTS - AZStd::string m_szUIName; - AZStd::string m_szUIDescription; -#endif - - AZStd::string m_szName; - AZStd::string m_szTexture; - - union - { - struct SHRenderTarget* m_pTarget; - IRenderTarget* m_pITarget; - }; - - int16 m_nTexState; - byte m_eTexType; // ETEX_Type e.g. eTT_2D or eTT_Cube - byte m_nSlotId; // EFTT_ index if it references one of the material texture slots, EFTT_MAX otherwise - uint32 m_nTexFlags; - - STexSamplerFX() - { - m_nTexState = -1; - m_eTexType = eTT_2D; - m_nSlotId = EFTT_MAX; - m_nTexFlags = 0; - m_pTarget = NULL; - } - - ~STexSamplerFX() - { - SAFE_RELEASE(m_pITarget); - } - - size_t Size() - { - size_t nSize = sizeof(*this); - nSize += m_szName.capacity(); - nSize += m_szTexture.capacity(); -#if SHADER_REFLECT_TEXTURE_SLOTS - nSize += m_szUIName.capacity(); - nSize += m_szUIDescription.capacity(); -#endif - return nSize; - } - - void GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer) const - { - } - - uint32 GetTexFlags() { return m_nTexFlags; } - void Update(); - void PostLoad(); - NO_INLINE STexSamplerFX (const STexSamplerFX& src) - { - m_pITarget = src.m_pITarget; - if (m_pITarget) - { - m_pITarget->AddRef(); - } - m_szName = src.m_szName; - m_szTexture = src.m_szTexture; - m_nSlotId = src.m_nSlotId; - m_eTexType = src.m_eTexType; - m_nTexFlags = src.m_nTexFlags; - m_nTexState = src.m_nTexState; - -#if SHADER_REFLECT_TEXTURE_SLOTS - m_szUIName = src.m_szUIName; - m_szUIDescription = src.m_szUIDescription; -#endif - } - NO_INLINE STexSamplerFX& operator = (const STexSamplerFX& src) - { - this->~STexSamplerFX(); - new(this)STexSamplerFX(src); - return *this; - } - _inline friend bool operator != (const STexSamplerFX& m1, const STexSamplerFX& m2) - { - if (m1.m_szTexture != m2.m_szTexture || m1.m_eTexType != m2.m_eTexType || m1.m_nTexFlags != m2.m_nTexFlags) - { - return true; - } - return false; - } - _inline bool operator == (const STexSamplerFX& m1) - { - return !(*this != m1); - } - - bool Export(SShaderSerializeContext& SC); - bool Import(SShaderSerializeContext& SC, SSTexSamplerFX* pTS); -}; - - -//============================================================================== -// Resource texture sampler (runtime) -//------------------------------------------------------------------------------ -struct STexSamplerRT -{ - union - { - CTexture* m_pTex; - ITexture* m_pITex; - }; - - union - { - struct SHRenderTarget* m_pTarget; - IRenderTarget* m_pITarget; - }; - - union - { - CTexAnim* m_pAnimInfo; - ITexAnim* m_pIAnimInfo; - }; - - uint32 m_nTexFlags; - int16 m_nTexState; - - uint8 m_eTexType; // ETEX_Type e.g. eTT_2D or eTT_Cube - int8 m_nSamplerSlot; - int8 m_nTextureSlot; - - bool m_bGlobal; - - STexSamplerRT() - { - m_nTexState = -1; - m_pTex = NULL; - m_eTexType = eTT_2D; - m_nTexFlags = 0; - m_pTarget = NULL; - m_pAnimInfo = NULL; - m_nSamplerSlot = -1; - m_nTextureSlot = -1; - m_bGlobal = false; - } - ~STexSamplerRT() - { - Cleanup(); - } - - void Cleanup() - { - SAFE_RELEASE(m_pITex); - // TODO: ref counted deleting of m_pAnimInfo & m_pTarget! - CW - SAFE_RELEASE(m_pITarget); - SAFE_RELEASE(m_pIAnimInfo); - } - int Size() const - { - int nSize = sizeof(*this); - return nSize; - } - - void GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer) const - { - } - - uint32 GetTexFlags() const { return m_nTexFlags; } - void Update(); - void PostLoad(); - - NO_INLINE STexSamplerRT (const STexSamplerRT& src) - { - m_pITex = src.m_pITex; - if (m_pITex) - { - m_pITex->AddRef(); - } - m_pITarget = src.m_pITarget; - if (m_pITarget) - { - m_pITarget->AddRef(); - } - m_pIAnimInfo = src.m_pIAnimInfo; - if (m_pIAnimInfo) - { - m_pIAnimInfo->AddRef(); - } - m_eTexType = src.m_eTexType; - m_nTexFlags = src.m_nTexFlags; - m_nTexState = src.m_nTexState; - m_nSamplerSlot = src.m_nSamplerSlot; - m_nTextureSlot = src.m_nTextureSlot; - m_bGlobal = src.m_bGlobal; - } - NO_INLINE STexSamplerRT& operator = (const STexSamplerRT& src) - { - this->~STexSamplerRT(); - new(this)STexSamplerRT(src); - return *this; - } - STexSamplerRT (const STexSamplerFX& src) - { - m_pITex = NULL; - m_pAnimInfo = NULL; - m_pITarget = src.m_pITarget; - if (m_pITarget) - { - m_pITarget->AddRef(); - } - m_eTexType = src.m_eTexType; - m_nTexFlags = src.m_nTexFlags; - m_nTexState = src.m_nTexState; - m_nSamplerSlot = -1; - m_nTextureSlot = -1; - m_bGlobal = (src.m_nTexFlags & FT_FROMIMAGE) != 0; - } - inline bool operator != (const STexSamplerRT& m) const - { - if (m_pTex != m.m_pTex || m_eTexType != m.m_eTexType || m_nTexFlags != m.m_nTexFlags || m_nTexState != m.m_nTexState) - { - return true; - } - return false; - } -}; - -//============================================================================== -//------------------------------------------------------------------------------ -struct SEfResTextureExt -{ - int32 m_nFrameUpdated; - int32 m_nUpdateFlags; - int32 m_nLastRecursionLevel; - SEfTexModificator* m_pTexModifier; - - SEfResTextureExt () - { - m_nFrameUpdated = -1; - m_nUpdateFlags = 0; - m_nLastRecursionLevel = 0; - m_pTexModifier = nullptr; - } - ~SEfResTextureExt () - { - Cleanup(); - } - void Cleanup() - { - SAFE_DELETE(m_pTexModifier); - } - inline bool operator != (const SEfResTextureExt& m) const - { - if (m_pTexModifier && m.m_pTexModifier) - { - return *m_pTexModifier != *m.m_pTexModifier; - } - if (!m_pTexModifier && !m.m_pTexModifier) - { - return false; - } - return true; - } - SEfResTextureExt(const SEfResTextureExt& src) - { - if (&src != this) - { - Cleanup(); - if (src.m_pTexModifier) - { - m_pTexModifier = new SEfTexModificator; - * m_pTexModifier = *src.m_pTexModifier; - } - m_nFrameUpdated = -1; - m_nUpdateFlags = src.m_nUpdateFlags; - m_nLastRecursionLevel = -1; - } - } - SEfResTextureExt& operator = (const SEfResTextureExt& src) - { - if (&src != this) - { - Cleanup(); - new(this)SEfResTextureExt(src); - } - return *this; - } - - void CopyTo(SEfResTextureExt* pTo) const - { - if (pTo && pTo != this) - { - pTo->Cleanup(); - pTo->m_nFrameUpdated = -1; - pTo->m_nUpdateFlags = m_nUpdateFlags; - pTo->m_nLastRecursionLevel = -1; - pTo->m_pTexModifier = nullptr; - if (m_pTexModifier) - { - pTo->m_pTexModifier = new SEfTexModificator; - *(pTo->m_pTexModifier) = *m_pTexModifier; - } - } - } - inline int Size() const - { - int nSize = sizeof(SEfResTextureExt); - if (m_pTexModifier) - { - nSize += m_pTexModifier->Size(); - } - return nSize; - } -}; - -//============================================================================== -// SEfResTexture - holds the actual data representing a texture and its associated -// sampler and modulator properties. -//------------------------------------------------------------------------------ -struct SEfResTexture -{ - AZStd::string m_Name; - bool m_bUTile; - bool m_bVTile; - signed char m_Filter; - - STexSamplerRT m_Sampler; - SEfResTextureExt m_Ext; - - void UpdateForCreate(int nTSlot); - void Update(int nTSlot); - void UpdateWithModifier(int nTSlot); - - inline bool operator != (const SEfResTexture& m) const - { - if (_stricmp(m_Name.c_str(), m.m_Name.c_str()) != 0 || - m_bUTile != m.m_bUTile || - m_bVTile != m.m_bVTile || - m_Filter != m.m_Filter || - m_Ext != m.m_Ext || - m_Sampler != m.m_Sampler) - { - return true; - } - return false; - } - - inline bool IsHasModificators() const - { - return (m_Ext.m_pTexModifier != NULL); - } - - //! Find out if the texture has modulator and if it requires per frame computation change - bool IsNeedTexTransform() const - { - if (!m_Ext.m_pTexModifier) - { - return false; - } - if (m_Ext.m_pTexModifier->m_eRotType != ETMR_NoChange || m_Ext.m_pTexModifier->m_eMoveType[0] != ETMM_NoChange || m_Ext.m_pTexModifier->m_eMoveType[1] != ETMM_NoChange) - { - return true; - } - return false; - } - - bool IsNeedTexGen() const - { - if (!m_Ext.m_pTexModifier) - { - return false; - } - if (m_Ext.m_pTexModifier->m_eTGType != ETG_Stream) - { - return true; - } - return false; - } - - inline float GetTiling(int n) const - { - if (!m_Ext.m_pTexModifier) - { - return 1.0f; - } - return m_Ext.m_pTexModifier->m_Tiling[n]; - } - - inline float GetOffset(int n) const - { - if (!m_Ext.m_pTexModifier) - { - return 0; - } - return m_Ext.m_pTexModifier->m_Offs[n]; - } - - inline SEfTexModificator* AddModificator() - { - if (!m_Ext.m_pTexModifier) - { - m_Ext.m_pTexModifier = new SEfTexModificator; - } - return m_Ext.m_pTexModifier; - } - - inline SEfTexModificator* GetModificator() const - { - if (!m_Ext.m_pTexModifier) - { - static SEfTexModificator dummy; - dummy.Reset(); - return &dummy; - } - - return m_Ext.m_pTexModifier; - } - - size_t Size() const - { - size_t nSize = sizeof(SEfResTexture) - sizeof(STexSamplerRT) - sizeof(SEfResTextureExt); - nSize += m_Name.size(); - nSize += m_Sampler.Size(); - nSize += m_Ext.Size(); - - return nSize; - } - - void GetMemoryUsage(ICrySizer* pSizer) const - { - pSizer->Add(*this); - pSizer->AddObject(m_Name); - pSizer->AddObject(m_Sampler); - } - - void Cleanup() - { - m_Sampler.Cleanup(); - m_Ext.Cleanup(); - } - - ~SEfResTexture() - { - Cleanup(); - } - - void Reset() - { - m_bUTile = true; - m_bVTile = true; - m_Filter = FILTER_NONE; - SAFE_DELETE(m_Ext.m_pTexModifier); - m_Ext.m_nFrameUpdated = -1; - } - - SEfResTexture (const SEfResTexture& src) - { - if (&src != this) - { - Cleanup(); - m_Sampler = src.m_Sampler; - m_Ext = src.m_Ext; - m_Name = src.m_Name; - m_bUTile = src.m_bUTile; - m_bVTile = src.m_bVTile; - m_Filter = src.m_Filter; - } - } - - SEfResTexture& operator = (const SEfResTexture& src) - { - if (&src != this) - { - Cleanup(); - new(this)SEfResTexture(src); - } - return *this; - } - void CopyTo(SEfResTexture* pTo) const - { - if (pTo && (pTo != this)) - { - pTo->Cleanup(); - pTo->m_Sampler = m_Sampler; - m_Ext.CopyTo(&pTo->m_Ext); - pTo->m_Name = m_Name; - pTo->m_bUTile = m_bUTile; - pTo->m_bVTile = m_bVTile; - pTo->m_Filter = m_Filter; - } - } - - SEfResTexture() - { - Reset(); - } -}; - -//============================================================================== -//------------------------------------------------------------------------------ -struct SBaseShaderResources -{ - AZStd::vector m_ShaderParams; - AZStd::string m_TexturePath; - const char* m_szMaterialName; - - float m_AlphaRef; - uint32 m_ResFlags; - - uint16 m_SortPrio; - - uint8 m_VoxelCoverage; - - size_t Size() const - { - size_t nSize = sizeof(SBaseShaderResources) + m_ShaderParams.size() * sizeof(SShaderParam); - return nSize; - } - - void GetMemoryUsage(ICrySizer* pSizer) const - { - pSizer->AddObject(m_ShaderParams); - } - - SBaseShaderResources& operator=(const SBaseShaderResources& src) - { - if (&src != this) - { - ReleaseParams(); - m_szMaterialName = src.m_szMaterialName; - m_ResFlags = src.m_ResFlags; - m_AlphaRef = src.m_AlphaRef; - m_VoxelCoverage = src.m_VoxelCoverage; - m_SortPrio = src.m_SortPrio; - m_ShaderParams = src.m_ShaderParams; - } - return *this; - } - - SBaseShaderResources() - { - m_ResFlags = 0; - m_AlphaRef = 0; - m_VoxelCoverage = 255; - m_SortPrio = 0; - m_szMaterialName = NULL; - } - - void ReleaseParams() - { - m_ShaderParams.clear(); - } - - virtual ~SBaseShaderResources() - { - ReleaseParams(); - } -}; - -//------------------------------------------------------------------------------ -typedef uint16 ResourceSlotIndex; -typedef AZStd::unordered_map TexturesResourcesMap; -typedef AZStd::unordered_map TexturesSlotsUsageMap; -//------------------------------------------------------------------------------ struct IRenderShaderResources { @@ -1963,8 +867,6 @@ struct IRenderShaderResources virtual bool HasLMConstants() const = 0; // properties - virtual void ToInputLM(CInputLightMaterial& lm) = 0; - virtual void SetInputLM(const CInputLightMaterial& lm) = 0; virtual ColorF GetColorValue(EEfResTextures slot) const = 0; virtual void SetColorValue(EEfResTextures slot, const ColorF& color) = 0; @@ -1982,9 +884,7 @@ struct IRenderShaderResources virtual SSkyInfo* GetSkyInfo() = 0; virtual void SetMaterialName(const char* szName) = 0; - virtual bool TextureSlotExists(ResourceSlotIndex slotId) const = 0; - virtual SEfResTexture* GetTextureResource(ResourceSlotIndex slotId) = 0; - virtual TexturesResourcesMap* GetTexturesResourceMap() = 0; + virtual AZStd::vector& GetParameters() = 0; virtual ColorF GetFinalEmittance() = 0; @@ -2001,23 +901,26 @@ struct IRenderShaderResources virtual void GetMemoryUsage(ICrySizer* pSizer) const = 0; // - inline bool IsEmissive() const + bool IsEmissive() const { // worst: *reinterpret_cast(&) > 0x00000000 // causes value to pass from FPU to CPU registers return GetStrengthValue(EFTT_EMITTANCE) > 0.0f; } - inline bool IsTransparent() const + + bool IsTransparent() const { // worst: *reinterpret_cast(&) < 0x3f800000 // causes value to pass from FPU to CPU registers return GetStrengthValue(EFTT_OPACITY) < 1.0f; } - inline bool IsAlphaTested() const + + bool IsAlphaTested() const { return GetAlphaRef() > 0.0f; } - inline bool IsInvisible() const + + bool IsInvisible() const { const float o = GetStrengthValue(EFTT_OPACITY); const float a = GetAlphaRef(); @@ -2027,75 +930,6 @@ struct IRenderShaderResources }; -struct SInputShaderResources - : public SBaseShaderResources -{ - CInputLightMaterial m_LMaterial; - TexturesResourcesMap m_TexturesResourcesMap; // a map of all textures resources used by the shader by name - SDeformInfo m_DeformInfo; - - size_t Size() const - { - size_t nSize = SBaseShaderResources::Size();// -sizeof(SEfResTexture) * m_TexturesResourcesMap.size(); - nSize += m_TexturePath.size(); - nSize += sizeof(SDeformInfo); - - for (auto& iter : m_TexturesResourcesMap) - { - nSize += iter.second.Size(); - } - return nSize; - } - - SInputShaderResources& operator=(const SInputShaderResources& src) - { - if (&src != this) - { - Cleanup(); // this will also remove all texture slots - SBaseShaderResources::operator = (src); - m_TexturePath = src.m_TexturePath; - m_DeformInfo = src.m_DeformInfo; - m_TexturesResourcesMap = src.m_TexturesResourcesMap; - m_LMaterial = src.m_LMaterial; - } - return *this; - } - - SInputShaderResources() {} - SInputShaderResources(struct IRenderShaderResources* pSrc) - { - pSrc->ConvertToInputResource(this); - m_ShaderParams = pSrc->GetParameters(); - } - - void Cleanup() - { - m_TexturesResourcesMap.clear(); - } - - virtual ~SInputShaderResources() - { - Cleanup(); - } - - bool IsEmpty(ResourceSlotIndex nTSlot) const - { - auto iter = m_TexturesResourcesMap.find(nTSlot); - return (iter != m_TexturesResourcesMap.end()) ? iter->second.m_Name.empty() : true; - } - - SEfResTexture* GetTextureResource(ResourceSlotIndex slotId) - { - auto iter = m_TexturesResourcesMap.find(slotId); - return (iter != m_TexturesResourcesMap.end()) ? &iter->second : nullptr; - } - - inline TexturesResourcesMap* GetTexturesResourceMap() - { - return &m_TexturesResourcesMap; - } -}; - //=================================================================================== // Shader gen structure (used for automatic shader script generating). @@ -2138,106 +972,6 @@ struct SInputShaderResources SHGD_TEX_OCC | SHGD_TEX_SPECULAR_2 | SHGD_TEX_EMITTANCE) -//------------------------------------------------------------------------------ -// Texture slot descriptor for shader -//------------------------------------------------------------------------------ -struct SShaderTextureSlot -{ - SShaderTextureSlot() - { - m_TexType = eTT_MaxTexType; - } - - AZStd::string m_Name; - AZStd::string m_Description; - byte m_TexType; // 2D, 3D, Cube etc.. - - void GetMemoryUsage(ICrySizer* pSizer) const - { - pSizer->AddObject(m_Name); - pSizer->AddObject(m_Description); - pSizer->AddObject(m_TexType); - } -}; - -//------------------------------------------------------------------------------ -// Shader's used texture slots -//------------------------------------------------------------------------------ -/* [Shader System] - To Do: bring that back to life after testing -struct SShaderTexSlots -{ - uint32 m_nRefCount; - TexturesSlotsUsageMap m_UsedTextureSlots; - - SShaderTexSlots() - { - m_nRefCount = 1; - } - - ~SShaderTexSlots() - { - for (auto& iter : m_UsedTextureSlots ) - { - SAFE_DELETE( iter.second ); - } - m_UsedTextureSlots.clear(); - } - void Release() - { - m_nRefCount--; - if (!m_nRefCount) - { - delete this; - } - } - - void GetMemoryUsage(ICrySizer* pSizer) const - { - pSizer->AddObject(m_UsedTextureSlots); - } - - SShaderTextureSlot* GetUsedTextureSlot(uint16 slotId) - { - auto iter = m_UsedTextureSlots.find(slotId); - return (iter != m_UsedTextureSlots.end()) ? iter->second : nullptr; - } -}; -*/ - -// [Shader System] - To Do: replace this with the code above after testing -struct SShaderTexSlots -{ - uint32 m_nRefCount; - SShaderTextureSlot* m_UsedTextureSlots[EFTT_MAX]; - SShaderTexSlots() - { - m_nRefCount = 1; - memset(m_UsedTextureSlots, 0, sizeof(m_UsedTextureSlots)); - } - ~SShaderTexSlots() - { - uint32 i; - for (i = 0; i < EFTT_MAX; i++) - { - SShaderTextureSlot* pSlot = m_UsedTextureSlots[i]; - SAFE_DELETE(pSlot); - } - } - void Release() - { - m_nRefCount--; - if (!m_nRefCount) - { - delete this; - } - } - - void GetMemoryUsage(ICrySizer* pSizer) const - { - pSizer->AddObject(m_UsedTextureSlots); - } -}; - //=================================================================================== enum EShaderType @@ -2291,33 +1025,6 @@ enum ERenderQuality eRQ_Max = 4 }; -// Summary: -// Shader profile flags . -#define SPF_LOADNORMALALPHA 0x1 - -struct SShaderProfile -{ - SShaderProfile() - : m_iShaderProfileQuality(eSQ_High) - , m_nShaderProfileFlags(SPF_LOADNORMALALPHA) - { - } - - EShaderQuality GetShaderQuality() const - { - return (EShaderQuality)CLAMP(m_iShaderProfileQuality, 0, eSQ_VeryHigh); - } - - void SetShaderQuality(const EShaderQuality& rValue) - { - m_iShaderProfileQuality = (int)rValue; - } - - // ---------------------------------------------------------------- - - int m_iShaderProfileQuality; // EShaderQuality e.g. eSQ_Medium, use Get/Set functions if possible - uint32 m_nShaderProfileFlags; // SPF_... -}; //==================================================================================== // Phys. material flags @@ -2350,39 +1057,6 @@ enum EShaderTechniqueID TTYPE_MAX }; -//==================================================================================== - -// EFSLIST_ lists -// Note - declaration order/index value has no explicit meaning. - -enum ERenderListID -{ - EFSLIST_INVALID = 0, // Don't use, internally used. - EFSLIST_PREPROCESS, // Pre-process items. - EFSLIST_GENERAL, // Opaque ambient_light+shadow passes. - EFSLIST_SHADOW_GEN, // Shadow map generation. - EFSLIST_DECAL, // Opaque or transparent decals. - EFSLIST_WATER_VOLUMES, // After decals. - EFSLIST_TRANSP, // Sorted by distance under-water render items. - EFSLIST_WATER, // Water-ocean render items. - EFSLIST_HDRPOSTPROCESS, // Hdr post-processing screen effects. - EFSLIST_AFTER_HDRPOSTPROCESS, // After hdr post-processing screen effects. - EFSLIST_POSTPROCESS, // Post-processing screen effects. - EFSLIST_AFTER_POSTPROCESS, // After post-processing screen effects. - EFSLIST_SHADOW_PASS, // Shadow mask generation (usually from from shadow maps). - EFSLIST_DEFERRED_PREPROCESS, // Pre-process before deferred passes. - EFSLIST_SKIN, // Skin rendering pre-process - EFSLIST_HALFRES_PARTICLES, // Half resolution particles - EFSLIST_PARTICLES_THICKNESS, // Particles thickness passes - EFSLIST_LENSOPTICS, // Lens-optics processing - EFSLIST_VOXELIZE, // Mesh voxelization - EFSLIST_EYE_OVERLAY, // Eye overlay layer requires special processing - EFSLIST_FOG_VOLUME, // Fog density injection passes. - EFSLIST_GPU_PARTICLE_CUBEMAP_COLLISION, // Cubemaps for GPU particle cubemap depth collision - EFSLIST_REFRACTIVE_SURFACE, // After decals, used for instance for the water surface that comes with water volumes. - - EFSLIST_NUM -}; //================================================================ // Different preprocess flags for shaders that require preprocessing (like recursive render to texture, screen effects, visibility check, ...) @@ -2502,35 +1176,15 @@ public: virtual void SetFlags2(int Flags) = 0; virtual void ClearFlags2(int Flags) = 0; virtual bool Reload(int nFlags, const char* szShaderName) = 0; - virtual AZStd::vector& GetPublicParams() = 0; + virtual int GetTexId () = 0; - virtual ITexture* GetBaseTexture(int* nPass, int* nTU) = 0; - virtual unsigned int GetUsedTextureTypes(void) = 0; - virtual SShaderTexSlots* GetUsedTextureSlots(int nTechnique) = 0; + virtual ECull GetCull(void) = 0; virtual int Size(int Flags) = 0; - virtual uint64 GetGenerationMask() = 0; - virtual size_t GetNumberOfUVSets() = 0; + virtual int GetTechniqueID(int nTechnique, int nRegisteredTechnique) = 0; virtual AZ::Vertex::Format GetVertexFormat(void) = 0; - // D3D Effects interface - virtual bool FXSetTechnique(const CCryNameTSCRC& Name) = 0; - virtual bool FXSetPSFloat(const CCryNameR& NameParam, const Vec4 fParams[], int nParams) = 0; - virtual bool FXSetCSFloat(const CCryNameR& NameParam, const Vec4 fParams[], int nParams) = 0; - virtual bool FXSetVSFloat(const CCryNameR& NameParam, const Vec4 fParams[], int nParams) = 0; - virtual bool FXSetGSFloat(const CCryNameR& NameParam, const Vec4 fParams[], int nParams) = 0; - - virtual bool FXSetPSFloat(const char* NameParam, const Vec4 fParams[], int nParams) = 0; - virtual bool FXSetCSFloat(const char* NameParam, const Vec4 fParams[], int nParams) = 0; - virtual bool FXSetVSFloat(const char* NameParam, const Vec4 fParams[], int nParams) = 0; - virtual bool FXSetGSFloat(const char* NameParam, const Vec4 fParams[], int nParams) = 0; - - virtual bool FXBegin(uint32* uiPassCount, uint32 nFlags) = 0; - virtual bool FXBeginPass(uint32 uiPass) = 0; - virtual bool FXCommit(const uint32 nFlags) = 0; - virtual bool FXEndPass() = 0; - virtual bool FXEnd() = 0; virtual EShaderType GetShaderType() = 0; virtual EShaderDrawType GetShaderDrawType() const = 0; @@ -2585,7 +1239,7 @@ struct SShaderItem // If you change this function please check bTransparent variable in CRenderMesh::Render(). // See also: // CRenderMesh::Render() - inline bool IsZWrite() const + bool IsZWrite() const { IShader* pSH = m_pShader; if (pSH->GetFlags() & (EF_NODRAW | EF_DECAL)) @@ -2613,103 +1267,6 @@ struct SShaderItem }; -////////////////////////////////////////////////////////////////////// -// define before including - -struct CRenderChunk -{ - bool m_bUsesBones; - CREMesh* pRE; // Pointer to the mesh. - - float m_texelAreaDensity; - - uint32 nFirstIndexId; - uint32 nNumIndices; - - uint32 nFirstVertId; - uint32 nNumVerts; - - uint16 m_nMatFlags; // Material flags from originally assigned material @see EMaterialFlags. - uint16 m_nMatID; // Material Sub-object id. - - // Index of sub-object that this chunk originates from, used by sub-object hide mask. - // @see IStatObj::GetSubObject - uint32 nSubObjectIndex; - - AZ::Vertex::Format m_vertexFormat; - - ////////////////////////////////////////////////////////////////////////// - CRenderChunk() - : m_bUsesBones(false) - , pRE(0) - , m_texelAreaDensity(1.0f) - , nFirstIndexId(0) - , nNumIndices(0) - , nFirstVertId(0) - , nNumVerts(0) - , m_nMatFlags(0) - , m_nMatID(0) - , nSubObjectIndex(0) - , m_vertexFormat(eVF_P3F_C4B_T2F) - { - } - - int Size() const; - - void GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer) const - { - } -}; - -typedef DynArray TRenderChunkArray; - -////////////////////////////////////////////////////////////////////// -// DLights - -enum eDynamicLightFlags -{ - DLF_AREA_SPEC_TEX = BIT(0), - DLF_DIRECTIONAL = BIT(1), - DLF_BOX_PROJECTED_CM = BIT(2), - // BIT(3) DEPRECATED, Available for use - DLF_POST_3D_RENDERER = BIT(4), - DLF_CASTSHADOW_MAPS = BIT(5), - DLF_POINT = BIT(6), - DLF_PROJECT = BIT(7), - DLF_LIGHT_BEAM = BIT(8), - DLF_IGNORES_VISAREAS = BIT(10), - DLF_DEFERRED_CUBEMAPS = BIT(11), - DLF_HAS_CLIP_VOLUME = BIT(12), - DLF_DISABLED = BIT(13), - DLF_AREA_LIGHT = BIT(14), - DLF_USE_FOR_SVOGI = BIT(15), - // UNUSED = BIT(16), - DLF_FAKE = BIT(17), // No lighting, used for Flares, beams and such. - DLF_SUN = BIT(18), - DLF_LM = BIT(19), - DLF_THIS_AREA_ONLY = BIT(20), // Affects only current area/sector. - DLF_AMBIENT = BIT(21), // Ambient light (has name indicates, used for replacing ambient) - DLF_INDOOR_ONLY = BIT(22), // Do not affect height map. - DLF_VOLUMETRIC_FOG = BIT(23), // Affects volumetric fog. - DLF_ATTACH_TO_SUN = BIT(24), // Add only to Light Propagation Volume if it's possible. - DLF_TRACKVIEW_TIMESCRUBBING = BIT(25), // Add only to Light Propagation Volume if it's possible. - DLF_VOLUMETRIC_FOG_ONLY = BIT(26), // Affects only volumetric fog. - DLF_DEFERRED_LIGHT = BIT(27), // DEPRECATED. Remove once deferred shading by default - DLF_SPECULAROCCLUSION = BIT(28), // DEPRECATED. Remove all dependencies editor side, etc - DLF_DIFFUSEOCCLUSION = BIT(29), - DLF_CAST_TERRAIN_SHADOWS = BIT(30), // Include terrain in shadow casters - - DLF_LIGHTTYPE_MASK = (DLF_DIRECTIONAL | DLF_POINT | DLF_PROJECT | DLF_AREA_LIGHT) -}; - - -//Area light types -#define DLAT_SPHERE 0x1 -#define DLAT_RECTANGLE 0x2 -#define DLAT_POINT 0x4 - -#define DL_SHADOW_UPDATE_SHIFT 8 - #include // <> required for Interfuscator struct IAnimNode; @@ -2732,445 +1289,13 @@ protected: IAnimNode* m_pNode; }; -struct SOpticsInstanceParameters -{ - SOpticsInstanceParameters(float brightness = 0.0f, float size = 0.0f, const ColorF& color = ColorF(), bool valid = false) : - m_brightness(brightness), - m_size(size), m_color(color), - m_isValid(valid) {} - - float m_brightness; - float m_size; - ColorF m_color; - bool m_isValid; -}; #define MAX_RECURSION_LEVELS 2 -struct SRenderLight -{ - SRenderLight() - { - memset(this, 0, sizeof(SRenderLight)); - m_fLightFrustumAngle = 45.0f; - m_fRadius = 4.0f; - m_fBaseRadius = 4.0f; - m_SpecMult = m_BaseSpecMult = 1.0f; - m_ProjMatrix.SetIdentity(); - m_ObjMatrix.SetIdentity(); - m_BaseObjMatrix.SetIdentity(); - m_sName = ""; - m_pLightAnim = NULL; - m_fAreaWidth = 1; - m_fAreaHeight = 1; - m_fBoxWidth = 1.0f; - m_fBoxHeight = 1.0f; - m_fBoxLength = 1.0f; - m_fTimeScrubbed = 0.0f; - - m_fShadowBias = 1.0f; - m_fShadowSlopeBias = 1.0f; - m_fShadowResolutionScale = 1.0f; - m_nShadowMinResolution = 0; - m_fShadowUpdateMinRadius = m_fRadius; - m_nShadowUpdateRatio = 1 << DL_SHADOW_UPDATE_SHIFT; - m_nEntityId = (uint32) - 1; - m_LensOpticsFrustumAngle = 255; - m_nAttenFalloffMax = 255; - m_fAttenuationBulbSize = 0.1f; - m_fProbeAttenuation = 1.0f; - m_lightId = -1; - } - - const Vec3& GetPosition() const - { - return m_Origin; - } - void SetPosition(const Vec3& vPos) - { - m_BaseOrigin = vPos; - m_Origin = vPos; - } - - // Summary: - // Use this instead of m_Color. - void SetLightColor(const ColorF& cColor) - { - m_Color = cColor; - m_BaseColor = cColor; - } - - ITexture* GetDiffuseCubemap() const - { - return m_pDiffuseCubemap; - } - - ITexture* GetSpecularCubemap() const - { - return m_pSpecularCubemap; - } - - ITexture* GetLightTexture() const - { - return m_pLightImage ? m_pLightImage : NULL; - } - - void SetOpticsParams(const SOpticsInstanceParameters& params) - { - m_opticsParams = params; - } - - const SOpticsInstanceParameters& GetOpticsParams() const - { - return m_opticsParams; - } - - void GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer) const { /*LATER*/} - - void AcquireResources() - { - if (m_Shader.m_pShader) - { - m_Shader.m_pShader->AddRef(); - } - if (m_pLightImage) - { - m_pLightImage->AddRef(); - } - if (m_pDiffuseCubemap) - { - m_pDiffuseCubemap->AddRef(); - } - if (m_pSpecularCubemap) - { - m_pSpecularCubemap->AddRef(); - } - if (m_pLightAnim) - { - m_pLightAnim->AddRef(); - } - if (m_pLightAttenMap) - { - m_pLightAttenMap->AddRef(); - } - } - - void DropResources() - { - SAFE_RELEASE(m_Shader.m_pShader); - SAFE_RELEASE(m_pLightImage); - SAFE_RELEASE(m_pDiffuseCubemap); - SAFE_RELEASE(m_pSpecularCubemap); - SAFE_RELEASE(m_pLightAnim); - SAFE_RELEASE(m_pLightAttenMap); - } - - void SetAnimSpeed(float fAnimSpeed) - { - m_nAnimSpeed = aznumeric_caster(int_round(min(fAnimSpeed * 255.0f / 4.0f, 255.0f))); // Assuming speed multiplier in range [0, 4] - } - - float GetAnimSpeed() const - { - return ((float) m_nAnimSpeed) * (4.0f / 255.0f); - } - - void SetFalloffMax(float fMax) - { - m_nAttenFalloffMax = aznumeric_caster(int_round(fMax * 255.0f)); - } - - float GetFalloffMax() const - { - return ((float) m_nAttenFalloffMax) / 255.0f; - } - - // Calculate the scissor rectangle in screenspace that encompasses this light. These values are used to set - // the hardware scissor rect in order to clip the min/max 2d extents for the light. - // These values must be calculated and read on the render thread due to the VR tracking updates performed on the render thread. - void CalculateScissorRect(); - - //========================================================================================================================= - - // Commonly used on most code paths (64 bytes) - int16 m_Id; // Shader id - uint8 m_nStencilRef[2]; - uint32 m_n3DEngineUpdateFrameID; - uint32 m_nEntityId; // Unique entity id - uint32 m_Flags; // light flags (DLF_etc). - Vec3 m_Origin; // World space position - float m_fRadius; // xyz= Origin, w=Radius. (Do not change order) - ColorF m_Color; // w component unused - todo pack spec mul into alpha (post c3 - touches quite some code) - float m_SpecMult; // Specular multiplier - float m_fHDRDynamic; // 0 to get the same results in HDR, <0 to get darker, >0 to get brighter. - int16 m_sX; // Scissor parameters (2d extent). - int16 m_sY; - int16 m_sWidth; - int16 m_sHeight; - int m_lightId; - - // Env. probes - ITexture* m_pDiffuseCubemap; // Very small cubemap texture to make a lookup for diffuse. - ITexture* m_pSpecularCubemap; // Cubemap texture to make a lookup for local specular. - Vec3 m_ProbeExtents; - float m_fBoxWidth; - float m_fBoxHeight; - float m_fBoxLength; - float m_fProbeAttenuation; // Can be used fade out distant probes, or to manually blend between multiple co-located probes - uint8 m_nAttenFalloffMax; - uint8 m_nSortPriority; - - // Shadow map fields - struct ILightSource* m_pOwner; - ShadowMapFrustum** m_pShadowMapFrustums; - float m_fShadowBias; - float m_fShadowSlopeBias; - float m_fShadowResolutionScale; - float m_fShadowUpdateMinRadius; - uint16 m_nShadowMinResolution; - uint16 m_nShadowUpdateRatio; - uint8 m_ShadowChanMask : 4; - uint8 m_ShadowMaskIndex : 4; - - // Projector - ITexture* m_pLightAttenMap; // User can specify custom light attenuation gradient - ITexture* m_pLightImage; - Matrix44 m_ProjMatrix; - Matrix34 m_ObjMatrix; - float m_fLightFrustumAngle; - float m_fProjectorNearPlane; - - // Misc fields. todo: put in cold data struct (post c3 - touches quite some code) - const char* m_sName; // Optional name of the light source. - SShaderItem m_Shader; // Shader item - CRenderObject* m_pObject[MAX_RECURSION_LEVELS]; // Object for light coronas and light flares. - ILightAnimWrapper* m_pLightAnim; - - Matrix34 m_BaseObjMatrix; - float m_fTimeScrubbed; - Vec3 m_BaseOrigin; // World space position. - float m_fBaseRadius; // Base radius - ColorF m_BaseColor; // w component unused.. - float m_BaseSpecMult; - - float m_fAttenuationBulbSize; - - float m_fAreaWidth; - float m_fAreaHeight; - - float m_fFogRadialLobe; // The blend ratio of two radial lobe for volumetric fog. - - AZ::u8 m_nAnimSpeed; - AZ::u8 m_nLightStyle; - AZ::u8 m_nLightPhase; - AZ::u8 m_LensOpticsFrustumAngle; // from 0 to 255, The range will be adjusted from 0 to 360 when used. - - IClipVolume* m_pClipVolumes[2]; - - SOpticsInstanceParameters m_opticsParams; // Per instance optics parameters -}; - -////////////////////////////////////////////////////////////////////// -class CDLight - : public SRenderLight -{ -public: - CDLight() - : SRenderLight() - { - } - - ~CDLight() - { - DropResources(); - } - - // Summary: - // Good for debugging. - bool IsOk() const - { - for (int i = 0; i < 3; ++i) - { - if (m_Color[i] < 0 || m_Color[i] > 100.0f || _isnan(m_Color[i])) - { - return false; - } - if (m_BaseColor[i] < 0 || m_BaseColor[i] > 100.0f || _isnan(m_BaseColor[i])) - { - return false; - } - } - return true; - } - - CDLight(const CDLight& other) - { - operator=(other); - } - - CDLight& operator=(const CDLight& dl) - { - if (this == &dl) - { - return *this; - } - - DropResources(); - - m_pOwner = dl.m_pOwner; - memcpy(m_pObject, dl.m_pObject, sizeof(m_pObject)); - m_Shader = dl.m_Shader; - m_pShadowMapFrustums = dl.m_pShadowMapFrustums; - m_pDiffuseCubemap = dl.m_pDiffuseCubemap; - m_pSpecularCubemap = dl.m_pSpecularCubemap; - m_pLightImage = dl.m_pLightImage; - m_pLightAttenMap = dl.m_pLightAttenMap; - m_sName = dl.m_sName; - m_ProjMatrix = dl.m_ProjMatrix; - m_ObjMatrix = dl.m_ObjMatrix; - m_BaseObjMatrix = dl.m_BaseObjMatrix; - m_Color = dl.m_Color; - m_BaseColor = dl.m_BaseColor; - m_Origin = dl.m_Origin; - m_BaseOrigin = dl.m_BaseOrigin; - m_fRadius = dl.m_fRadius; - m_fBaseRadius = dl.m_fBaseRadius; - m_ProbeExtents = dl.m_ProbeExtents; - m_SpecMult = dl.m_SpecMult; - m_BaseSpecMult = dl.m_BaseSpecMult; - m_fShadowBias = dl.m_fShadowBias; - m_fShadowSlopeBias = dl.m_fShadowSlopeBias; - m_fShadowResolutionScale = dl.m_fShadowResolutionScale; - m_fHDRDynamic = dl.m_fHDRDynamic; - m_LensOpticsFrustumAngle = dl.m_LensOpticsFrustumAngle; - m_fLightFrustumAngle = dl.m_fLightFrustumAngle; - m_fProjectorNearPlane = dl.m_fProjectorNearPlane; - m_Flags = dl.m_Flags; - m_Id = dl.m_Id; - m_n3DEngineUpdateFrameID = dl.m_n3DEngineUpdateFrameID; - m_sX = dl.m_sX; - m_sY = dl.m_sY; - m_sWidth = dl.m_sWidth; - m_sHeight = dl.m_sHeight; - m_nLightStyle = dl.m_nLightStyle; - m_nLightPhase = dl.m_nLightPhase; - m_ShadowChanMask = dl.m_ShadowChanMask; - m_pLightAnim = dl.m_pLightAnim; - m_fAreaWidth = dl.m_fAreaWidth; - m_fAreaHeight = dl.m_fAreaHeight; - m_fBoxWidth = dl.m_fBoxWidth; - m_fBoxHeight = dl.m_fBoxHeight; - m_fBoxLength = dl.m_fBoxLength; - m_fTimeScrubbed = dl.m_fTimeScrubbed; - m_nShadowMinResolution = dl.m_nShadowMinResolution; - m_fShadowUpdateMinRadius = dl.m_fShadowUpdateMinRadius; - m_nShadowUpdateRatio = dl.m_nShadowUpdateRatio; - m_nAnimSpeed = dl.m_nAnimSpeed; - m_nSortPriority = dl.m_nSortPriority; - m_nAttenFalloffMax = dl.m_nAttenFalloffMax; - m_fProbeAttenuation = dl.m_fProbeAttenuation; - m_fAttenuationBulbSize = dl.m_fAttenuationBulbSize; - m_fFogRadialLobe = dl.m_fFogRadialLobe; - m_nEntityId = dl.m_nEntityId; - memcpy(m_nStencilRef, dl.m_nStencilRef, sizeof(m_nStencilRef)); - memcpy(m_pClipVolumes, dl.m_pClipVolumes, sizeof(m_pClipVolumes)); - m_opticsParams = dl.m_opticsParams; - AcquireResources(); - - return *this; - } - - // Summary: - // Use this instead of m_Color. - const ColorF& GetFinalColor([[maybe_unused]] const ColorF& cColor) const - { - return m_Color; - } - - // Summary: - // Use this instead of m_Color. - void SetSpecularMult(float fSpecMult) - { - m_SpecMult = fSpecMult; - m_BaseSpecMult = fSpecMult; - } - - void SetShadowBiasParams(float fShadowBias, float fShadowSlopeBias) - { - m_fShadowBias = fShadowBias; - m_fShadowSlopeBias = fShadowSlopeBias; - } - - // Summary: - // Use this instead of m_Color. - const float& GetSpecularMult() const - { - return m_SpecMult; - } - void SetMatrix(const Matrix34& Matrix, bool reset = true) - { - // Scale the cubemap to adjust the default 45 degree 1/2 angle fustrum to - // the desired angle (0 to 90 degrees). - float scaleFactor = tan_tpl((90.0f - m_fLightFrustumAngle) * gf_PI / 180.0f); - m_ProjMatrix = Matrix33(Matrix) * Matrix33::CreateScale(Vec3(1, scaleFactor, scaleFactor)); - Matrix44 transMat; - transMat.SetIdentity(); - transMat(3, 0) = -Matrix(0, 3); - transMat(3, 1) = -Matrix(1, 3); - transMat(3, 2) = -Matrix(2, 3); - m_ProjMatrix = transMat * m_ProjMatrix; - m_ObjMatrix = Matrix; - - // Remove any scale - m_ObjMatrix.GetColumn0().NormalizeSafe(Vec3_OneX); - m_ObjMatrix.GetColumn1().NormalizeSafe(Vec3_OneY); - m_ObjMatrix.GetColumn2().NormalizeSafe(Vec3_OneZ); - - if (reset) - { - m_BaseObjMatrix = m_ObjMatrix; - } - } - - void SetSpecularCubemap(ITexture* texture) - { - m_pSpecularCubemap = texture; - } - - void SetDiffuseCubemap(ITexture* texture) - { - m_pDiffuseCubemap = texture; - } - - void ReleaseCubemaps() - { - SAFE_RELEASE(m_pSpecularCubemap); - SAFE_RELEASE(m_pDiffuseCubemap); - } -}; - #define DECAL_HAS_NORMAL_MAP (1 << 0) #define DECAL_STATIC (1 << 1) #define DECAL_HAS_SPECULAR_MAP (1 << 2) -struct SDeferredDecal -{ - SDeferredDecal() - { - ZeroStruct(*this); - rectTexture.w = rectTexture.h = 1.f; - angleAttenuation = 1.0f; - } - - Matrix34 projMatrix; // defines where projection should be applied in the world - _smart_ptr pMaterial; // decal material - float fAlpha; // transparency of decal, used mostly for distance fading - float fGrowAlphaRef; - float angleAttenuation; - RectF rectTexture; // subset of texture to render - uint32 nFlags; - uint8 nSortOrder; // user defined sort order -}; // Summary: // Runtime shader flags for HW skinning. @@ -3189,124 +1314,5 @@ enum EBoneTypes eBoneType_Count, }; -// Summary: -// Shader graph support. -enum EGrBlockType -{ - eGrBlock_Unknown, - eGrBlock_VertexInput, - eGrBlock_VertexOutput, - eGrBlock_PixelInput, - eGrBlock_PixelOutput, - eGrBlock_Texture, - eGrBlock_Sampler, - eGrBlock_Function, - eGrBlock_Constant, -}; - -enum EGrBlockSamplerType -{ - eGrBlockSampler_Unknown, - eGrBlockSampler_2D, - eGrBlockSampler_3D, - eGrBlockSampler_Cube, - eGrBlockSampler_Bias2D, - eGrBlockSampler_BiasCube, -}; - -enum EGrNodeType -{ - eGrNode_Unknown, - eGrNode_Input, - eGrNode_Output, -}; - -enum EGrNodeFormat -{ - eGrNodeFormat_Unknown, - eGrNodeFormat_Float, - eGrNodeFormat_Vector, - eGrNodeFormat_Matrix, - eGrNodeFormat_Int, - eGrNodeFormat_Bool, - eGrNodeFormat_Texture2D, - eGrNodeFormat_Texture3D, - eGrNodeFormat_TextureCUBE, -}; - -enum EGrNodeIOSemantic -{ - eGrNodeIOSemantic_Unknown, - eGrNodeIOSemantic_Custom, - eGrNodeIOSemantic_VPos, - eGrNodeIOSemantic_Color0, - eGrNodeIOSemantic_Color1, - eGrNodeIOSemantic_Color2, - eGrNodeIOSemantic_Color3, - eGrNodeIOSemantic_Normal, - eGrNodeIOSemantic_TexCoord0, - eGrNodeIOSemantic_TexCoord1, - eGrNodeIOSemantic_TexCoord2, - eGrNodeIOSemantic_TexCoord3, - eGrNodeIOSemantic_TexCoord4, - eGrNodeIOSemantic_TexCoord5, - eGrNodeIOSemantic_TexCoord6, - eGrNodeIOSemantic_TexCoord7, - eGrNodeIOSemantic_Tangent, - eGrNodeIOSemantic_Binormal, -}; - -struct SShaderGraphFunction -{ - AZStd::string m_Data; - AZStd::string m_Name; - std::vector inParams; - std::vector outParams; - std::vector szInTypes; - std::vector szOutTypes; -}; - -struct SShaderGraphNode -{ - EGrNodeType m_eType; - EGrNodeFormat m_eFormat; - EGrNodeIOSemantic m_eSemantic; - AZStd::string m_CustomSemantics; - AZStd::string m_Name; - bool m_bEditable; - bool m_bWasAdded; - SShaderGraphFunction* m_pFunction; - AZStd::vector m_Properties; - - SShaderGraphNode() - { - m_eType = eGrNode_Unknown; - m_eFormat = eGrNodeFormat_Unknown; - m_eSemantic = eGrNodeIOSemantic_Unknown; - m_bEditable = false; - m_bWasAdded = false; - m_pFunction = NULL; - } - ~SShaderGraphNode(); -}; - - -typedef std::vector FXShaderGraphNodes; -typedef FXShaderGraphNodes::iterator FXShaderGraphNodeItor; - -struct SShaderGraphBlock -{ - EGrBlockType m_eType; - EGrBlockSamplerType m_eSamplerType; - AZStd::string m_ClassName; - FXShaderGraphNodes m_Nodes; - - ~SShaderGraphBlock(); -}; - -typedef std::vector FXShaderGraphBlocks; -typedef FXShaderGraphBlocks::iterator FXShaderGraphBlocksItor; #include - -#endif // CRYINCLUDE_CRYCOMMON_ISHADER_H diff --git a/Code/Legacy/CryCommon/ISplines.h b/Code/Legacy/CryCommon/ISplines.h index 2353489163..ff67ae0d56 100644 --- a/Code/Legacy/CryCommon/ISplines.h +++ b/Code/Legacy/CryCommon/ISplines.h @@ -11,7 +11,6 @@ #define CRYINCLUDE_CRYCOMMON_ISPLINES_H #pragma once -#include #include ////////////////////////////////////////////////////////////////////////// @@ -638,7 +637,7 @@ namespace spline ////////////////////////////////////////////////////////////////////////// static void Reflect(AZ::SerializeContext* serializeContext) {} - + inline void add_ref() { ++m_refCount; diff --git a/Code/Legacy/CryCommon/IStatObj.h b/Code/Legacy/CryCommon/IStatObj.h index 4921ab3a25..a268f40406 100644 --- a/Code/Legacy/CryCommon/IStatObj.h +++ b/Code/Legacy/CryCommon/IStatObj.h @@ -11,20 +11,20 @@ #include "smartptr.h" // TYPEDEF_AUTOPTR #include "IMaterial.h" +#include "ISerialize.h" // forward declarations ////////////////////////////////////////////////////////////////////// struct ShadowMapFrustum; struct SRenderingPassInfo; struct SRendItemSorter; -struct IShader; +struct ITetrLattice; struct SPhysGeomArray; struct CStatObj; class CRenderObject; class CDLight; class IReadStream; -class CRenderObject; class CLodValue; @@ -39,9 +39,11 @@ class CRenderObject; struct SMeshLodInfo; #include "CryHeaders.h" +#include "Cry_Color.h" #include "Cry_Math.h" #include "Cry_Geo.h" -#include "IPhysics.h" +#include "CrySizer.h" +#include "stridedptr.h" #define MAX_STATOBJ_LODS_NUM 6 @@ -399,10 +401,6 @@ struct IStatObj // Set the physic representation virtual void SetPhysGeom(phys_geometry* pPhysGeom, int nType = 0) = 0; - // Description: - // Returns a tetrahedral lattice, if any (used for breakable objects) - virtual ITetrLattice* GetTetrLattice() = 0; - virtual float GetAIVegetationRadius() const = 0; virtual void SetAIVegetationRadius(float radius) = 0; @@ -635,15 +633,6 @@ struct IStatObj // adds a new sub object virtual IStatObj::SSubObject& AddSubObject(IStatObj* pStatObj) = 0; - // Summary: - // Adds subobjects to pent, meshes as parts, joint helpers as breakable joints - virtual int PhysicalizeSubobjects(IPhysicalEntity* pent, const Matrix34* pMtx, float mass, float density = 0.0f, int id0 = 0, strided_pointer pJointsIdMap = 0, const char* szPropsOverride = 0) = 0; - // Summary: - // Adds all phys geometries to pent, assigns ids starting from id; takes mass and density from the StatObj properties if not set in pgp - // for compound objects calls PhysicalizeSubobjects - // returns the physical id of the last physicalized part - virtual int Physicalize(IPhysicalEntity* pent, pe_geomparams* pgp, int id = 0, const char* szPropsOverride = 0) = 0; - virtual bool IsDeformable() = 0; ////////////////////////////////////////////////////////////////////////// @@ -768,12 +757,6 @@ struct IStatObj virtual bool UpdateStreamableComponents(float fImportance, const Matrix34A& objMatrix, bool bFullUpdate, int nNewLod) = 0; - virtual void RenderInternal(CRenderObject* pRenderObject, uint64 nSubObjectHideMask, const CLodValue& lodValue, const SRenderingPassInfo& passInfo, const SRendItemSorter& rendItemSorter, bool forceStaticDraw) = 0; - virtual void RenderObjectInternal(CRenderObject* pRenderObject, int nLod, uint8 uLodDissolveRef, bool dissolveOut, const SRenderingPassInfo& passInfo, const SRendItemSorter& rendItemSorter, bool forceStaticDraw) = 0; - virtual void RenderSubObject(CRenderObject* pRenderObject, int nLod, int nSubObjId, const Matrix34A& renderTM, const SRenderingPassInfo& passInfo, const SRendItemSorter& rendItemSorter, bool forceStaticDraw) = 0; - virtual void RenderSubObjectInternal(CRenderObject* pRenderObject, int nLod, const SRenderingPassInfo& passInfo, const SRendItemSorter& rendItemSorter, bool forceStaticDraw) = 0; - virtual void RenderRenderMesh(CRenderObject* pObj, struct SInstancingInfo* pInstInfo, const SRenderingPassInfo& passInfo, const SRendItemSorter& rendItemSorter) = 0; - virtual SPhysGeomArray& GetArrPhysGeomInfo() = 0; virtual bool IsLodsAreLoadedFromSeparateFile() = 0; diff --git a/Code/Legacy/CryCommon/ISystem.h b/Code/Legacy/CryCommon/ISystem.h index 3c13ac04d8..6008c4ae32 100644 --- a/Code/Legacy/CryCommon/ISystem.h +++ b/Code/Legacy/CryCommon/ISystem.h @@ -624,8 +624,6 @@ struct SSystemGlobalEnvironment ISystem* pSystem = nullptr; ILog* pLog; IMovieSystem* pMovieSystem; - INameTable* pNameTable; - IRenderer* pRenderer; ILyShine* pLyShine; SharedEnvironmentInstance* pSharedEnvironment; @@ -852,7 +850,6 @@ struct ISystem // virtual IViewSystem* GetIViewSystem() = 0; virtual ILevelSystem* GetILevelSystem() = 0; - virtual INameTable* GetINameTable() = 0; virtual ICmdLine* GetICmdLine() = 0; virtual ILog* GetILog() = 0; virtual AZ::IO::IArchive* GetIPak() = 0; @@ -1149,11 +1146,6 @@ struct DiskOperationInfo #endif -#define LOADING_TIME_PROFILE_SECTION -#define LOADING_TIME_PROFILE_SECTION_ARGS(...) -#define LOADING_TIME_PROFILE_SECTION_NAMED(sectionName) -#define LOADING_TIME_PROFILE_SECTION_NAMED_ARGS(sectionName, ...) - ////////////////////////////////////////////////////////////////////////// // CrySystem DLL Exports. ////////////////////////////////////////////////////////////////////////// diff --git a/Code/Legacy/CryCommon/LyShine/Animation/IUiAnimation.h b/Code/Legacy/CryCommon/LyShine/Animation/IUiAnimation.h index e04fb6ada7..8d988d0df5 100644 --- a/Code/Legacy/CryCommon/LyShine/Animation/IUiAnimation.h +++ b/Code/Legacy/CryCommon/LyShine/Animation/IUiAnimation.h @@ -10,9 +10,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -191,7 +189,7 @@ public: private: EUiAnimParamType m_type; - CCryName m_name; + AZStd::string m_name; }; // The data required to identify a specific parameter/property on an AZ component on an AZ entity @@ -442,7 +440,7 @@ struct IUiAnimTrack virtual int GetSubTrackCount() const = 0; // Retrieve pointer the specfied sub track. virtual IUiAnimTrack* GetSubTrack(int nIndex) const = 0; - virtual const char* GetSubTrackName(int nIndex) const = 0; + virtual AZStd::string GetSubTrackName(int nIndex) const = 0; virtual void SetSubTrackName(int nIndex, const char* name) = 0; ////////////////////////////////////////////////////////////////////////// @@ -634,7 +632,7 @@ public: virtual void SetName(const char* name) = 0; //! Get node name. - virtual const char* GetName() = 0; + virtual AZStd::string GetName() = 0; // Get Type of this node. virtual EUiAnimNodeType GetType() const = 0; @@ -710,13 +708,13 @@ public: // Returns name of supported parameter of this animation node or NULL if not available // Arguments: // paramType - parameter id - virtual const char* GetParamName(const CUiAnimParamType& paramType) const = 0; + virtual AZStd::string GetParamName(const CUiAnimParamType& paramType) const = 0; // Description: // Returns name of supported parameter of this animation node or NULL if not available // Arguments: // paramType - parameter id - virtual const char* GetParamNameForTrack(const CUiAnimParamType& paramType, [[maybe_unused]] const IUiAnimTrack* track) const { return GetParamName(paramType); } + virtual AZStd::string GetParamNameForTrack(const CUiAnimParamType& paramType, [[maybe_unused]] const IUiAnimTrack* track) const { return GetParamName(paramType); } // Description: // Returns the params value type diff --git a/Code/Legacy/CryCommon/LyShine/IRenderGraph.h b/Code/Legacy/CryCommon/LyShine/IRenderGraph.h index 561e07243b..716e0f7417 100644 --- a/Code/Legacy/CryCommon/LyShine/IRenderGraph.h +++ b/Code/Legacy/CryCommon/LyShine/IRenderGraph.h @@ -8,6 +8,7 @@ #pragma once #include +#include #include namespace AZ @@ -48,20 +49,11 @@ namespace LyShine //! End rendering to a texture virtual void EndRenderToTexture() = 0; - //! Add an indexed triangle list primitive to the render graph with given render state - virtual void AddPrimitive(IRenderer::DynUiPrimitive* primitive, ITexture* texture, - bool isClampTextureMode, bool isTextureSRGB, bool isTexturePremultipliedAlpha, BlendMode blendMode) = 0; - - //! Add an indexed triangle list primitive to the render graph which will use maskTexture as an alpha (gradient) mask - virtual void AddAlphaMaskPrimitive(IRenderer::DynUiPrimitive* primitive, - ITexture* texture, ITexture* maskTexture, - bool isClampTextureMode, bool isTextureSRGB, bool isTexturePremultipliedAlpha, BlendMode blendMode) = 0; - //! Get a dynamic quad primitive that can be added as an image primitive to the render graph //! The graph handles the allocation of this DynUiPrimitive and deletes it when the graph is reset //! This can be used if the UI component doesn't want to own the storage of the primitive. Used infrequently, //! e.g. for the selection rect on a text component. - virtual IRenderer::DynUiPrimitive* GetDynamicQuadPrimitive(const AZ::Vector2* positions, uint32 packedColor) = 0; + virtual DynUiPrimitive* GetDynamicQuadPrimitive(const AZ::Vector2* positions, uint32 packedColor) = 0; //---- Functions for supporting masking (used during creation of the graph, not rendering ) ---- diff --git a/Code/Legacy/CryCommon/Mocks/IRendererMock.h b/Code/Legacy/CryCommon/Mocks/IRendererMock.h deleted file mode 100644 index be9c1eec8b..0000000000 --- a/Code/Legacy/CryCommon/Mocks/IRendererMock.h +++ /dev/null @@ -1,854 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#pragma once - -#include -#include - -struct SRendItemSorter {}; -struct SRenderingPassInfo {}; -struct SClipVolumeBlendInfo {}; -struct SFogVolumeData {}; - -// the following was generated using google's python script to autogenerate mocks. -// however, it needed some hand-editing to make it work, so if you add functions to IRenderer, -// it will probably be better to just manually add them here than try to run the script again -// hand-edits are marked with 'hand-edit'. Everything else was autogenerated. - -class IRendererMock - : public IRenderer -{ -public: - MOCK_METHOD1(AddRenderDebugListener, - void(IRenderDebugListener * pRenderDebugListener)); - MOCK_METHOD1(RemoveRenderDebugListener, - void(IRenderDebugListener * pRenderDebugListener)); - MOCK_CONST_METHOD0(GetRenderType, - ERenderType()); - - // Hand-edit: Googlemock cannot handle 14 param functions. - WIN_HWND Init(int, int, int, int, unsigned int, int, int, bool, bool, WIN_HINSTANCE, WIN_HWND = 0, - bool = false, const SCustomRenderInitArgs* = 0, bool = false) override { return nullptr; } - - MOCK_METHOD0(PostInit, - void()); - MOCK_CONST_METHOD0(IsPost3DRendererEnabled, - bool()); - MOCK_METHOD0(GetFeatures, - int()); - - // Hand-edit: Googlemock doesn't like 'const void' as a return type: - const void SetApiVersion(const AZStd::string&) override {} - const void SetAdapterDescription(const AZStd::string&) override {} - - MOCK_CONST_METHOD0(GetApiVersion, - const AZStd::string& ()); - MOCK_CONST_METHOD0(GetAdapterDescription, - const AZStd::string& ()); - MOCK_METHOD3(GetVideoMemoryUsageStats, - void(size_t&, size_t&, bool)); - MOCK_CONST_METHOD0(GetNumGeomInstances, - int()); - MOCK_CONST_METHOD0(GetNumGeomInstanceDrawCalls, - int()); - MOCK_CONST_METHOD0(GetCurrentNumberOfDrawCalls, - int()); - MOCK_CONST_METHOD2(GetCurrentNumberOfDrawCalls, - void(int& nGeneral, int& nShadowGen)); - MOCK_CONST_METHOD1(GetCurrentNumberOfDrawCalls, - int(uint32 EFSListMask)); - MOCK_CONST_METHOD1(GetCurrentDrawCallRTTimes, - float(uint32 EFSListMask)); - MOCK_METHOD1(SetDebugRenderNode, - void(IRenderNode * pRenderNode)); - MOCK_CONST_METHOD1(IsDebugRenderNode, - bool(IRenderNode * pRenderNode)); - MOCK_METHOD1(DeleteContext, - bool(WIN_HWND hWnd)); - MOCK_METHOD4(CreateContext, - bool(WIN_HWND, bool, int, int)); - MOCK_METHOD1(SetCurrentContext, - bool(WIN_HWND hWnd)); - MOCK_METHOD0(MakeMainContextActive, - void()); - MOCK_METHOD0(GetCurrentContextHWND, - WIN_HWND()); - MOCK_METHOD0(IsCurrentContextMainVP, - bool()); - MOCK_CONST_METHOD0(GetCurrentContextViewportHeight, - int()); - MOCK_CONST_METHOD0(GetCurrentContextViewportWidth, - int()); - MOCK_METHOD1(ShutDown, - void(bool)); - MOCK_METHOD0(ShutDownFast, - void()); - MOCK_METHOD1(EnumDisplayFormats, - int(SDispFormat * Formats)); - MOCK_METHOD1(EnumAAFormats, - int(SAAFormat * Formats)); - MOCK_METHOD6(ChangeResolution, - bool(int nNewWidth, int nNewHeight, int nNewColDepth, int nNewRefreshHZ, bool bFullScreen, bool bForceReset)); - MOCK_METHOD0(BeginFrame, - void()); - MOCK_METHOD1(InitSystemResources, - void(int nFlags)); - MOCK_METHOD0(InitTexturesSemantics, - void()); - MOCK_METHOD1(FreeResources, - void(int nFlags)); - MOCK_METHOD0(Release, - void()); - MOCK_METHOD1(RenderDebug, - void(bool)); - MOCK_METHOD0(EndFrame, - void()); - MOCK_METHOD0(ForceSwapBuffers, - void()); - MOCK_METHOD0(TryFlush, - void()); - MOCK_CONST_METHOD4(GetViewport, - void(int* x, int* y, int* width, int* height)); - MOCK_METHOD5(SetViewport, - void(int, int, int, int, int)); - MOCK_METHOD4(SetRenderTile, - void(f32, f32, f32, f32)); - MOCK_METHOD4(SetScissor, - void(int, int, int, int)); - MOCK_METHOD0(GetViewProjectionMatrix, - Matrix44A & ()); - MOCK_METHOD1(SetTranspOrigCameraProjMatrix, - void(Matrix44A & matrix)); - MOCK_METHOD2(GetScreenAspect, - EScreenAspectRatio(int nWidth, int nHeight)); - MOCK_METHOD2(SetViewportDownscale, - Vec2(float xscale, float yscale)); - MOCK_METHOD1(SetViewParameters, - void(const CameraViewParameters& viewParameters)); - MOCK_METHOD1(ApplyViewParameters, - void(const CameraViewParameters& viewParameters)); - MOCK_METHOD5(DrawDynVB, - void(SVF_P3F_C4B_T2F * pBuf, uint16 * pInds, int nVerts, int nInds, PublicRenderPrimitiveType nPrimType)); - - // Hand-edit: google mock has issues with DynUiPrimitiveList - void DrawDynUiPrimitiveList([[maybe_unused]] DynUiPrimitiveList& primitives, [[maybe_unused]] int totalNumVertices, [[maybe_unused]] int totalNumIndices) override { return; } - - MOCK_METHOD1(SetCamera, - void(const CCamera& cam)); - MOCK_METHOD0(GetCamera, - const CCamera& ()); - MOCK_METHOD1(GetRenderViewForThread, - CRenderView * (int nThreadID)); - MOCK_METHOD1(SetGammaDelta, - bool(float fGamma)); - MOCK_METHOD0(RestoreGamma, - void(void)); - MOCK_METHOD3(ChangeDisplay, - bool(unsigned int width, unsigned int height, unsigned int cbpp)); - MOCK_METHOD7(ChangeViewport, - void(unsigned int, unsigned int, unsigned int, unsigned int, bool, float, float)); - MOCK_CONST_METHOD6(SaveTga, - bool(unsigned char* sourcedata, int sourceformat, int w, int h, const char* filename, bool flip)); - MOCK_METHOD1(SetTexture, - void(int tnum)); - MOCK_METHOD2(SetTexture, - void(int tnum, int nUnit)); - MOCK_METHOD0(SetWhiteTexture, - void()); - MOCK_CONST_METHOD0(GetWhiteTextureId, - int()); - MOCK_CONST_METHOD0(GetBlackTextureId, - int()); - - // Hand-edit: google mock can only do up to 10 parameters - void Draw2dImage(float, float, float, float, int, float, float, float, float, float, float, float, float, float, float) override {}; - MOCK_METHOD1(Draw2dImageStretchMode, - void(bool stretch)); - - // Hand-edit: google mock can only do up to 10 parameters - void Push2dImage(float, float, float, float, int, float, float, float, float, float, float, float, float, float, float, float) override {}; - - MOCK_METHOD0(Draw2dImageList, - void()); - - // Hand-edit: Hand-edit: google mock can only do up to 10 parameters - void DrawImage(float, float, float, float, int, float, float, float, float, float, float, float, float, bool) override {} - - // Hand-edit: google mock can only do up to 10 parameters - void DrawImageWithUV(float, float, float, float, float, int, float*, float*, float, float, float, float, bool) override {} - - MOCK_METHOD1(PushWireframeMode, - void(int mode)); - MOCK_METHOD0(PopWireframeMode, - void()); - MOCK_CONST_METHOD0(GetHeight, - int()); - MOCK_CONST_METHOD0(GetWidth, - int()); - MOCK_CONST_METHOD0(GetPixelAspectRatio, - float()); - MOCK_CONST_METHOD0(GetOverlayHeight, - int()); - MOCK_CONST_METHOD0(GetOverlayWidth, - int()); - MOCK_CONST_METHOD0(GetMaxSquareRasterDimension, - int()); - MOCK_METHOD0(SwitchToNativeResolutionBackbuffer, - void()); - MOCK_METHOD1(GetMemoryUsage, - void(ICrySizer * Sizer)); - MOCK_METHOD1(GetBandwidthStats, - void(float* fBandwidthRequested)); - MOCK_METHOD1(SetTextureStreamListener, - void(ITextureStreamListener * pListener)); - MOCK_METHOD2(GetOcclusionBuffer, - int(uint16 * pOutOcclBuffer, Matrix44 * pmCamBuffer)); - MOCK_METHOD2(ScreenShot, - bool(const char*, int)); - MOCK_METHOD0(GetColorBpp, - int()); - MOCK_METHOD0(GetDepthBpp, - int()); - MOCK_METHOD0(GetStencilBpp, - int()); - MOCK_CONST_METHOD0(IsStereoEnabled, - bool()); - MOCK_CONST_METHOD0(GetNearestRangeMax, - float()); - MOCK_METHOD0(GetPerInstanceConstantBufferPoolPointer, - PerInstanceConstantBufferPool * ()); - MOCK_METHOD6(ProjectToScreen, - bool(float ptx, float pty, float ptz, float* sx, float* sy, float* sz)); - MOCK_METHOD9(UnProject, - int(float sx, float sy, float sz, float* px, float* py, float* pz, const float modelMatrix[16], const float projMatrix[16], const int viewport[4])); - MOCK_METHOD6(UnProjectFromScreen, - int(float sx, float sy, float sz, float* px, float* py, float* pz)); - MOCK_METHOD1(GetModelViewMatrix, - void(float* mat)); - MOCK_METHOD1(GetProjectionMatrix, - void(float* mat)); - MOCK_METHOD7(WriteDDS, - bool(const byte * dat, int wdt, int hgt, int Size, const char* name, ETEX_Format eF, int NumMips)); - MOCK_METHOD6(WriteTGA, - bool(const byte * dat, int wdt, int hgt, const char* name, int src_bits_per_pixel, int dest_bits_per_pixel)); - MOCK_METHOD6(WriteJPG, - bool(const byte*, int, int, char*, int, int)); - MOCK_METHOD6(FontCreateTexture, - int(int, int, byte*, ETEX_Format, bool, const char*)); - MOCK_METHOD6(FontUpdateTexture, - bool(int nTexId, int X, int Y, int USize, int VSize, byte * pData)); - MOCK_METHOD2(FontSetTexture, - void(int nTexId, int nFilterMode)); - MOCK_METHOD2(FontSetRenderingState, - void(bool overrideViewProjMatrices, TransformationMatrices & backupMatrices)); - MOCK_METHOD3(FontSetBlending, - void(int src, int dst, int baseState)); - MOCK_METHOD2(FontRestoreRenderingState, - void(bool overrideViewProjMatrices, const TransformationMatrices& restoringMatrices)); - MOCK_METHOD3(FlushRTCommands, - bool(bool bWait, bool bImmediatelly, bool bForce)); - MOCK_CONST_METHOD7(DrawStringU, - void(IFFont_RenderProxy * pFont, float x, float y, float z, const char* pStr, bool asciiMultiLine, const STextDrawContext& ctx)); - MOCK_METHOD0(RT_CurThreadList, - int()); - MOCK_METHOD6(EF_PrecacheResource, - bool(SShaderItem*, float, float, int, int, int)); - MOCK_METHOD4(EF_PrecacheResource, - bool(IShader * pSH, float fMipFactor, float fTimeToReady, int Flags)); - MOCK_METHOD6(EF_PrecacheResource, - bool(ITexture*, float, float, int, int, int)); - MOCK_METHOD6(EF_PrecacheResource, - bool(IRenderMesh * pPB, _smart_ptr pMaterial, float fMipFactor, float fTimeToReady, int Flags, int nUpdateId)); - MOCK_METHOD5(EF_PrecacheResource, - bool(CDLight * pLS, float fMipFactor, float fTimeToReady, int Flags, int nUpdateId)); - - // Hand-edit: google mock can only do up to 10 parameters - ITexture* EF_CreateCompositeTexture([[maybe_unused]] int type, [[maybe_unused]] const char* szName, [[maybe_unused]] int nWidth, [[maybe_unused]] int nHeight, [[maybe_unused]] int nDepth, [[maybe_unused]] int nMips, [[maybe_unused]] int nFlags, [[maybe_unused]] ETEX_Format eTF, [[maybe_unused]] const STexComposition* pCompositions, [[maybe_unused]] size_t nCompositions, [[maybe_unused]] int8 nPriority = -1) override { return nullptr; } - - MOCK_METHOD0(PostLevelLoading, - void()); - MOCK_METHOD0(PostLevelUnload, - void()); - MOCK_METHOD10(EF_AddPolygonToScene, - CRenderObject * (SShaderItem & si, int numPts, const SVF_P3F_C4B_T2F * verts, const SPipTangents * tangs, CRenderObject * obj, const SRenderingPassInfo& passInfo, uint16 * inds, int ninds, int nAW, const SRendItemSorter& rendItemSorter)); - MOCK_METHOD10(EF_AddPolygonToScene, - CRenderObject * (SShaderItem & si, CRenderObject * obj, const SRenderingPassInfo& passInfo, int numPts, int ninds, SVF_P3F_C4B_T2F * &verts, SPipTangents * &tangs, uint16 * &inds, int nAW, const SRendItemSorter& rendItemSorter)); - MOCK_METHOD0(ForceUpdateGlobalShaderParameters, - void()); - MOCK_METHOD0(EF_GetShaderMissLogPath, - const char*()); - MOCK_METHOD1(EF_GetShaderNames, - AZStd::string * (int& nNumShaders)); - MOCK_METHOD1(EF_ReloadFile, - bool(const char* szFileName)); - MOCK_METHOD1(EF_ReloadFile_Request, - bool(const char* szFileName)); - MOCK_METHOD3(EF_GetRemapedShaderMaskGen, - uint64(const char*, uint64, bool)); - MOCK_METHOD3(EF_GetShaderGlobalMaskGenFromString, - uint64(const char*, const char*, uint64)); - MOCK_METHOD2(EF_GetStringFromShaderGlobalMaskGen, - AZStd::string(const char*, uint64)); - MOCK_CONST_METHOD1(GetShaderProfile, - const SShaderProfile& (EShaderType eST)); - MOCK_METHOD2(EF_SetShaderQuality, - void(EShaderType eST, EShaderQuality eSQ)); - MOCK_CONST_METHOD0(EF_GetRenderQuality, - ERenderQuality()); - MOCK_METHOD1(EF_GetShaderQuality, - EShaderQuality(EShaderType eST)); - MOCK_METHOD5(EF_LoadShaderItem, - SShaderItem(const char*, bool, int, SInputShaderResources*, uint64)); - MOCK_METHOD3(EF_LoadShader, - IShader * (const char*, int, uint64)); - MOCK_METHOD1(EF_ReloadShaderFiles, - void(int nCategory)); - MOCK_METHOD0(EF_ReloadTextures, - void()); - MOCK_METHOD1(EF_GetTextureByID, - ITexture * (int Id)); - MOCK_METHOD2(EF_GetTextureByName, - ITexture * (const char*, uint32)); - MOCK_METHOD2(EF_LoadTexture, - ITexture * (const char*, uint32)); - MOCK_METHOD2(EF_LoadCubemapTexture, - ITexture * (const char*, uint32)); - MOCK_METHOD1(EF_LoadDefaultTexture, - ITexture * (const char* nameTex)); - MOCK_METHOD1(EF_LoadLightmap, - int(const char* name)); - MOCK_METHOD1(EF_StartEf, - void(const SRenderingPassInfo& passInfo)); - MOCK_METHOD3(EF_GetObjData, - SRenderObjData * (CRenderObject * pObj, bool bCreate, int nThreadID)); - MOCK_METHOD1(EF_GetObject_Temp, - CRenderObject * (int nThreadID)); - MOCK_METHOD2(EF_DuplicateRO, - CRenderObject * (CRenderObject * pObj, const SRenderingPassInfo& passInfo)); - MOCK_METHOD7(EF_AddEf, - void(IRenderElement * pRE, SShaderItem & pSH, CRenderObject * pObj, const SRenderingPassInfo& passInfo, int nList, int nAW, const SRendItemSorter& rendItemSorter)); - MOCK_METHOD4(EF_EndEf3D, - void(int nFlags, int nPrecacheUpdateId, int nNearPrecacheUpdateId, const SRenderingPassInfo& passInfo)); - MOCK_METHOD1(EF_InvokeShadowMapRenderJobs, - void(int nFlags)); - MOCK_METHOD1(EF_IsFakeDLight, - bool(const CDLight * Source)); - MOCK_METHOD2(EF_ADDDlight, - void(CDLight * Source, const SRenderingPassInfo& passInfo)); - MOCK_METHOD1(EF_UpdateDLight, - bool(SRenderLight * pDL)); - MOCK_METHOD1(EF_AddDeferredDecal, - bool(const SDeferredDecal& rDecal)); - MOCK_METHOD4(EF_AddDeferredLight, - int(const CDLight& pLight, float fMult, const SRenderingPassInfo& passInfo, const SRendItemSorter& rendItemSorter)); - MOCK_METHOD1(EF_GetDeferredLightsNum, - uint32(eDeferredLightType)); - MOCK_METHOD0(EF_ClearDeferredLightsList, - void()); - MOCK_METHOD1(EF_AddDeferredClipVolume, - uint8(const IClipVolume * pClipVolume)); - MOCK_METHOD2(EF_SetDeferredClipVolumeBlendData, - bool(const IClipVolume * pClipVolume, const SClipVolumeBlendInfo& blendInfo)); - MOCK_METHOD0(EF_ClearDeferredClipVolumesList, - void()); - MOCK_METHOD0(EF_ReleaseDeferredData, - void()); - MOCK_METHOD1(EF_ReleaseInputShaderResource, - void(SInputShaderResources * pRes)); - MOCK_METHOD3(EF_SetPostEffectParam, - void(const char*, float, bool)); - MOCK_METHOD3(EF_SetPostEffectParamVec4, - void(const char*, const Vec4&, bool)); - MOCK_METHOD2(EF_SetPostEffectParamString, - void(const char* pParam, const char* pszArg)); - MOCK_METHOD2(EF_GetPostEffectParam, - void(const char* pParam, float& fValue)); - MOCK_METHOD2(EF_GetPostEffectParamVec4, - void(const char* pParam, Vec4 & pValue)); - MOCK_METHOD2(EF_GetPostEffectParamString, - void(const char* pParam, const char* & pszArg)); - MOCK_METHOD1(EF_GetPostEffectID, - int32(const char* pPostEffectName)); - MOCK_METHOD1(EF_ResetPostEffects, - void(bool)); - MOCK_METHOD0(SyncPostEffects, - void()); - MOCK_METHOD0(EF_DisableTemporalEffects, - void()); - MOCK_METHOD3(EF_AddWaterSimHit, - void(const Vec3& vPos, float scale, float strength)); - MOCK_METHOD0(EF_DrawWaterSimHits, - void()); - MOCK_METHOD1(EF_EndEf2D, - void(bool bSort)); - MOCK_METHOD0(ForceGC, - void()); - MOCK_CONST_METHOD0(GetPolyCount, - int()); - MOCK_CONST_METHOD2(GetPolyCount, - void(int& nPolygons, int& nShadowVolPolys)); - MOCK_METHOD1(SetClearColor, - void(const Vec3& vColor)); - MOCK_METHOD1(SetClearBackground, - void(bool bClearBackground)); - MOCK_METHOD4(CreateRenderMesh, - _smart_ptr(const char*, const char*, IRenderMesh::SInitParamerers*, ERenderMeshType)); - - // Hand-edit: google mock can only do up to 10 parameters - virtual _smart_ptr CreateRenderMeshInitialized( - const void*, int, const AZ::Vertex::Format&, const vtx_idx*, int, const PublicRenderPrimitiveType, - const char*, const char*, ERenderMeshType = eRMT_Static, int = 1, int = 0, - [[maybe_unused]] bool (*PrepareBufferCallback)(IRenderMesh*, bool) = nullptr, void* = nullptr, bool = false, bool = true, - const SPipTangents* = nullptr, bool = false, Vec3* = nullptr) - { - return _smart_ptr(); - } - - MOCK_METHOD1(GetFrameID, - int(bool)); - MOCK_CONST_METHOD0(GetCameraFrameID, - int()); - MOCK_CONST_METHOD0(IsRenderToTextureActive, - bool()); - MOCK_METHOD4(MakeMatrix, - void(const Vec3& pos, const Vec3& angles, const Vec3& scale, Matrix34 * mat)); - MOCK_METHOD4(DrawTextQueued, - void(Vec3 pos, SDrawTextInfo & ti, const char* format, va_list args)); - MOCK_METHOD3(DrawTextQueued, - void(Vec3 pos, SDrawTextInfo & ti, const char* text)); - MOCK_CONST_METHOD1(ScaleCoordX, - float(float value)); - MOCK_CONST_METHOD1(ScaleCoordY, - float(float value)); - MOCK_CONST_METHOD2(ScaleCoord, - void(float& x, float& y)); - MOCK_METHOD2(SetState, - void(int, int)); - MOCK_METHOD1(SetCullMode, - void(int)); - MOCK_METHOD5(SetStencilState, - void(int, uint32, uint32, uint32, bool)); - MOCK_METHOD1(PushProfileMarker, - void(const char* label)); - MOCK_METHOD1(PopProfileMarker, - void(const char* label)); - MOCK_METHOD1(EnableFog, - bool(bool enable)); - MOCK_METHOD1(SetFogColor, - void(const ColorF& color)); - MOCK_METHOD4(SetColorOp, - void(byte eCo, byte eAo, byte eCa, byte eAa)); - MOCK_METHOD1(SetSrgbWrite, - void(bool srgbWrite)); - MOCK_METHOD1(RequestFlushAllPendingTextureStreamingJobs, - void(int nFrames)); - MOCK_METHOD1(SetTexturesStreamingGlobalMipFactor, - void(float fFactor)); - MOCK_METHOD1(GetIRenderAuxGeom, - IRenderAuxGeom * (void*)); - MOCK_METHOD0(GetISvoRenderer, - ISvoRenderer * ()); - MOCK_METHOD0(GetIColorGradingController, - IColorGradingController * ()); - MOCK_METHOD0(GetIStereoRenderer, - IStereoRenderer * ()); - MOCK_METHOD7(Create2DTexture, - ITexture * (const char* name, int width, int height, int numMips, int flags, unsigned char* data, ETEX_Format format)); - - void TextToScreen([[maybe_unused]] float x, [[maybe_unused]] float y, [[maybe_unused]] const char* format, ...) override {} - void TextToScreenColor([[maybe_unused]] int x, [[maybe_unused]] int y, [[maybe_unused]] float r, [[maybe_unused]] float g, [[maybe_unused]] float b, [[maybe_unused]] float a, [[maybe_unused]] const char* format, ...) override {} - - MOCK_METHOD0(ResetToDefault, - void()); - MOCK_METHOD4(SetMaterialColor, - void(float r, float g, float b, float a)); - MOCK_METHOD0(SetDefaultRenderStates, - void()); - MOCK_METHOD10(Graph, - void(byte * g, int x, int y, int wdt, int hgt, int nC, int type, const char* text, ColorF & color, float fScale)); - MOCK_METHOD0(EF_RenderTextMessages, - void()); - MOCK_METHOD1(ClearTargetsImmediately, - void(uint32 nFlags)); - MOCK_METHOD3(ClearTargetsImmediately, - void(uint32 nFlags, const ColorF& Colors, float fDepth)); - MOCK_METHOD2(ClearTargetsImmediately, - void(uint32 nFlags, const ColorF& Colors)); - MOCK_METHOD2(ClearTargetsImmediately, - void(uint32 nFlags, float fDepth)); - MOCK_METHOD1(ClearTargetsLater, - void(uint32 nFlags)); - MOCK_METHOD3(ClearTargetsLater, - void(uint32 nFlags, const ColorF& Colors, float fDepth)); - MOCK_METHOD2(ClearTargetsLater, - void(uint32 nFlags, const ColorF& Colors)); - MOCK_METHOD2(ClearTargetsLater, - void(uint32 nFlags, float fDepth)); - MOCK_METHOD8(ReadFrameBuffer, - void(unsigned char*, int, int, int, ERB_Type, bool, int, int)); - MOCK_METHOD4(ReadFrameBufferFast, - void(uint32*, int, int, bool)); - MOCK_METHOD1(EnableVSync, - void(bool enable)); - MOCK_METHOD1(CreateResourceAsync, - void(SResourceAsync * Resource)); - MOCK_METHOD1(ReleaseResourceAsync, - void(SResourceAsync * Resource)); - MOCK_METHOD1(ReleaseResourceAsync, - void(AZStd::unique_ptr Resource)); - - // Hand-edit: google mock can only do up to 10 parameters - unsigned int DownLoadToVideoMemory(const byte*, int, int, ETEX_Format, ETEX_Format, int, bool = true, - int = FILTER_BILINEAR, int = 0, const char* = nullptr, int = 0, EEndian = eLittleEndian, - RectI* = nullptr, bool = false) override { return 0; } - - unsigned int DownLoadToVideoMemory3D(const byte*, int, int, [[maybe_unused]] int d, ETEX_Format, ETEX_Format, int, bool = true, - int = FILTER_BILINEAR, int = 0, const char* = nullptr, int = 0, EEndian = eLittleEndian, - RectI* = nullptr, bool = false) override { return 0; } - - unsigned int DownLoadToVideoMemoryCube(const byte*, int, int, ETEX_Format, ETEX_Format, int, bool = true, - int = FILTER_BILINEAR, int = 0, const char* = nullptr, int = 0, EEndian = eLittleEndian, - RectI* = nullptr, bool = false) override { return 0; } - - MOCK_METHOD9(UpdateTextureInVideoMemory, - void(uint32, const byte*, int, int, int, int, ETEX_Format, int, int)); - MOCK_METHOD8(DXTCompress, - bool(const byte * raw_data, int nWidth, int nHeight, ETEX_Format eTF, bool bUseHW, bool bGenMips, int nSrcBytesPerPix, MIPDXTcallback callback)); - MOCK_METHOD9(DXTDecompress, - bool(const byte * srcData, size_t srcFileSize, byte * dstData, int nWidth, int nHeight, int nMips, ETEX_Format eSrcTF, bool bUseHW, int nDstBytesPerPix)); - MOCK_METHOD1(RemoveTexture, - void(unsigned int TextureId)); - MOCK_METHOD1(DeleteFont, - void(IFFont * font)); - MOCK_METHOD3(CaptureFrameBufferFast, - bool(unsigned char* pDstRGBA8, int destinationWidth, int destinationHeight)); - MOCK_METHOD3(CopyFrameBufferFast, - bool(unsigned char* pDstRGBA8, int destinationWidth, int destinationHeight)); - MOCK_METHOD1(RegisterCaptureFrame, - bool(ICaptureFrameListener * pCapture)); - MOCK_METHOD1(UnRegisterCaptureFrame, - bool(ICaptureFrameListener * pCapture)); - MOCK_METHOD2(InitCaptureFrameBufferFast, - bool(uint32, uint32)); - MOCK_METHOD0(CloseCaptureFrameBufferFast, - void(void)); - MOCK_METHOD0(CaptureFrameBufferCallBack, - void(void)); - MOCK_METHOD1(RegisterSyncWithMainListener, - void(ISyncMainWithRenderListener * pListener)); - MOCK_METHOD1(RemoveSyncWithMainListener, - void(const ISyncMainWithRenderListener * pListener)); - MOCK_METHOD5(Set2DMode, - void(uint32, uint32, TransformationMatrices&, float, float)); - MOCK_METHOD1(Unset2DMode, - void(const TransformationMatrices& restoringMatrices)); - MOCK_METHOD7(Set2DModeNonZeroTopLeft, - void(float, float, float, float, TransformationMatrices&, float, float)); - MOCK_METHOD1(ScreenToTexture, - int(int nTexID)); - MOCK_METHOD1(EnableSwapBuffers, - void(bool bEnable)); - MOCK_METHOD0(GetHWND, - WIN_HWND()); - MOCK_METHOD1(SetWindowIcon, - bool(const char* path)); - MOCK_METHOD1(OnEntityDeleted, - void(struct IRenderNode* pRenderNode)); - MOCK_METHOD5(CreateRenderTarget, - int(const char* name, int nWidth, int nHeight, const ColorF& clearColor, ETEX_Format eTF)); - MOCK_METHOD1(DestroyRenderTarget, - bool(int nHandle)); - MOCK_METHOD3(ResizeRenderTarget, - bool(int nHandle, int nWidth, int nHeight)); - MOCK_METHOD2(SetRenderTarget, - bool(int, SDepthTexture*)); - MOCK_METHOD3(CreateDepthSurface, - SDepthTexture * (int, int, bool)); - MOCK_METHOD1(DestroyDepthSurface, - void(SDepthTexture * pDepthSurf)); - MOCK_METHOD1(PauseTimer, - void(bool bPause)); - MOCK_METHOD0(CreateShaderPublicParams, - IShaderPublicParams * ()); - MOCK_CONST_METHOD2(GetThreadIDs, - void(threadID & mainThreadID, threadID & renderThreadID)); - MOCK_METHOD1(EnableGPUTimers2, - void(bool bEnabled)); - MOCK_METHOD1(AllowGPUTimers2, - void(bool bAllow)); - MOCK_CONST_METHOD2(GetRPPStats, - const RPProfilerStats * (ERenderPipelineProfilerStats, bool)); - MOCK_CONST_METHOD1(GetRPPStatsArray, - const RPProfilerStats * (bool)); - MOCK_METHOD4(GetPolygonCountByType, - int(uint32, EVertexCostTypes, uint32, bool)); - MOCK_METHOD5(SetCloudShadowsParams, - void(int nTexID, const Vec3& speed, float tiling, bool invert, float brightness)); - MOCK_METHOD2(PushFogVolumeContribution, - uint16(const SFogVolumeData& fogVolData, const SRenderingPassInfo& passInfo)); - MOCK_METHOD2(PushFogVolume, - void(class CREFogVolume * pFogVolume, const SRenderingPassInfo& passInfo)); - MOCK_METHOD0(GetMaxTextureSize, - int()); - MOCK_METHOD1(GetTextureFormatName, - const char*(ETEX_Format eTF)); - MOCK_METHOD5(GetTextureFormatDataSize, - int(int nWidth, int nHeight, int nDepth, int nMips, ETEX_Format eTF)); - MOCK_METHOD2(SetDefaultMaterials, - void(_smart_ptr pDefMat, _smart_ptr pTerrainDefMat)); - MOCK_CONST_METHOD0(GetGPUParticleEngine, - IGPUParticleEngine * ()); - MOCK_CONST_METHOD0(GetActiveGPUCount, - uint32()); - MOCK_METHOD0(GetShadowFrustumMGPUCache, - ShadowFrustumMGPUCache * ()); - - MOCK_CONST_METHOD0(GetCachedShadowsResolution, - const StaticArray&()); - - MOCK_METHOD1(SetCachedShadowsResolution, - void(const StaticArray&arrResolutions)); - MOCK_CONST_METHOD1(UpdateCachedShadowsLodCount, - void(int nGsmLods)); - MOCK_METHOD1(SetTexturePrecaching, - void(bool stat)); - MOCK_METHOD2(RT_InsertGpuCallback, - void(uint32 context, GpuCallbackFunc callback)); - MOCK_METHOD1(EnablePipelineProfiler, - void(bool bEnable)); - MOCK_METHOD1(GetRenderTimes, - void(SRenderTimes & outTimes)); - MOCK_METHOD0(GetGPUFrameTime, - float()); - MOCK_METHOD1(EnableBatchMode, - void(bool enable)); - MOCK_METHOD1(EnableLevelUnloading, - void(bool enable)); - MOCK_METHOD0(OnLevelLoadFailed, - void()); -#if !defined(_RELEASE) - MOCK_METHOD1(GetDrawCallsInfoPerMesh, - RNDrawcallsMapMesh & (bool)); - MOCK_METHOD1(GetDrawCallsInfoPerMeshPreviousFrame, - RNDrawcallsMapMesh & (bool)); - MOCK_METHOD1(GetDrawCallsInfoPerNodePreviousFrame, - RNDrawcallsMapNode & (bool)); - MOCK_METHOD1(GetDrawCallsPerNode, - int(IRenderNode * pRenderNode)); - MOCK_METHOD1(ForceRemoveNodeFromDrawCallsMap, - void(IRenderNode * pNode)); -#endif - MOCK_METHOD1(CollectDrawCallsInfo, - void(bool status)); - MOCK_METHOD1(CollectDrawCallsInfoPerNode, - void(bool status)); - MOCK_METHOD0(HasLoadedDefaultResources, - bool()); - MOCK_METHOD3(EF_CreateSkinningData, - SSkinningData * (uint32, bool, bool)); - MOCK_METHOD4(EF_CreateRemappedSkinningData, - SSkinningData * (uint32 nNumBones, SSkinningData * pSourceSkinningData, uint32 nCustomDataSize, uint32 pairGuid)); - MOCK_METHOD0(EF_ClearSkinningDataPool, - void()); - MOCK_METHOD0(EF_GetSkinningPoolID, - int()); - MOCK_METHOD1(ClearShaderItem, - void(SShaderItem * pShaderItem)); - MOCK_METHOD2(UpdateShaderItem, - void(SShaderItem * pShaderItem, _smart_ptr pMaterial)); - MOCK_METHOD2(ForceUpdateShaderItem, - void(SShaderItem * pShaderItem, _smart_ptr pMaterial)); - MOCK_METHOD2(RefreshShaderResourceConstants, - void(SShaderItem * pShaderItem, IMaterial * pMaterial)); - MOCK_METHOD0(IsStereoModeChangePending, - bool()); - MOCK_METHOD1(LockParticleVideoMemory, - void(uint32 nId)); - MOCK_METHOD1(UnLockParticleVideoMemory, - void(uint32 nId)); - MOCK_METHOD1(BeginSpawningGeneratingRendItemJobs, - void(int nThreadID)); - MOCK_METHOD1(BeginSpawningShadowGeneratingRendItemJobs, - void(int nThreadID)); - MOCK_METHOD0(EndSpawningGeneratingRendItemJobs, - void()); - MOCK_METHOD1(StartLoadtimePlayback, - void(ILoadtimeCallback* pCallback)); - MOCK_METHOD0(StopLoadtimePlayback, - void()); - - MOCK_METHOD0(GetGenerateRendItemJobExecutor, - AZ::LegacyJobExecutor*()); - MOCK_METHOD0(GetGenerateShadowRendItemJobExecutor, - AZ::LegacyJobExecutor*()); - MOCK_METHOD0(GetGenerateRendItemJobExecutorPreProcess, - AZ::LegacyJobExecutor*()); - MOCK_METHOD1(GetFinalizeRendItemJobExecutor, - AZ::LegacyJobExecutor*(int nThreadID)); - MOCK_METHOD1(GetFinalizeShadowRendItemJobExecutor, - AZ::LegacyJobExecutor*(int nThreadID)); - MOCK_METHOD0(FlushPendingTextureTasks, - void()); - MOCK_METHOD1(SetShadowJittering, - void(float fShadowJittering)); - MOCK_CONST_METHOD0(GetShadowJittering, - float()); - MOCK_METHOD0(LoadShaderStartupCache, - bool()); - MOCK_METHOD0(UnloadShaderStartupCache, - void()); - MOCK_METHOD0(LoadShaderLevelCache, - bool()); - MOCK_METHOD0(UnloadShaderLevelCache, - void()); - MOCK_METHOD1(StartScreenShot, - void(int e_ScreenShot)); - MOCK_METHOD1(EndScreenShot, - void(int e_ScreenShot)); - MOCK_METHOD3(SetRendererCVar, - void(ICVar*, const char*, bool)); - MOCK_METHOD0(GetRenderPipeline, - SRenderPipeline * ()); - MOCK_METHOD0(GetShaderManager, - CShaderMan * ()); - MOCK_METHOD0(GetRenderThread, - SRenderThread * ()); - MOCK_METHOD0(GetWhiteTexture, - ITexture * ()); - MOCK_METHOD3(GetTextureForName, - ITexture * (const char* name, uint32 nFlags, ETEX_Format eFormat)); - MOCK_METHOD0(GetViewParameters, - const CameraViewParameters& ()); - MOCK_METHOD0(GetFrameReset, - uint32()); - MOCK_METHOD0(GetDepthBufferOrig, - SDepthTexture * ()); - MOCK_METHOD0(GetBackBufferWidth, - uint32()); - MOCK_METHOD0(GetBackBufferHeight, - uint32()); - MOCK_METHOD0(GetDeviceBufferManager, - CDeviceBufferManager * ()); - MOCK_CONST_METHOD0(GetRenderTileInfo, - const SRenderTileInfo * ()); - MOCK_METHOD0(GetIdentityMatrix, - Matrix44A()); - MOCK_CONST_METHOD0(RT_GetCurrGpuID, - int32()); - MOCK_METHOD0(GenerateTextureId, - int()); - MOCK_METHOD2(SetCull, - void(ECull, bool)); - MOCK_METHOD10(DrawQuad, - void(float x0, float y0, float x1, float y1, const ColorF& color, float z, float s0, float t0, float s1, float t1)); - MOCK_METHOD9(DrawQuad3D, - void(const Vec3& v0, const Vec3& v1, const Vec3& v2, const Vec3& v3, const ColorF& color, float ftx0, float fty0, float ftx1, float fty1)); - MOCK_METHOD0(FX_ResetPipe, - void()); - MOCK_METHOD4(FX_GetDepthSurface, - SDepthTexture * (int, int, bool, bool)); - MOCK_METHOD5(FX_CheckOverflow, - void(int, int, IRenderElement*, int*, int*)); - MOCK_METHOD1(FX_PreRender, - void(int Stage)); - MOCK_METHOD0(FX_PostRender, - void()); - MOCK_METHOD3(FX_SetState, - void(int, int, int)); - MOCK_METHOD3(FX_CommitStates, - void(const SShaderTechnique * pTech, const SShaderPass * pPass, bool bUseMaterialState)); - MOCK_METHOD1(FX_Commit, - void(bool)); - MOCK_METHOD2(FX_SetVertexDeclaration, - long(int StreamMask, const AZ::Vertex::Format& vertexFormat)); - MOCK_METHOD7(FX_DrawIndexedPrimitive, - void(eRenderPrimitiveType, int, int, int, int, int, bool)); - MOCK_METHOD3(FX_SetIStream, - long(const void* pB, uint32 nOffs, RenderIndexType idxType)); - MOCK_METHOD5(FX_SetVStream, - long(int, const void*, uint32, uint32, uint32)); - MOCK_METHOD4(FX_DrawPrimitive, - void(eRenderPrimitiveType, int, int, int)); - MOCK_METHOD1(FX_ClearTarget, - void(ITexture * pTex)); - MOCK_METHOD1(FX_ClearTarget, - void(SDepthTexture * pTex)); - MOCK_METHOD4(FX_SetRenderTarget, - bool(int, void*, SDepthTexture*, uint32)); - MOCK_METHOD4(FX_PushRenderTarget, - bool(int, void*, SDepthTexture*, uint32)); - MOCK_METHOD7(FX_SetRenderTarget, - bool(int, CTexture*, SDepthTexture*, bool, int, bool, uint32)); - MOCK_METHOD6(FX_PushRenderTarget, - bool(int, CTexture*, SDepthTexture*, int, bool, uint32)); - MOCK_METHOD1(FX_RestoreRenderTarget, - bool(int nTarget)); - MOCK_METHOD1(FX_PopRenderTarget, - bool(int nTarget)); - MOCK_METHOD1(FX_SetActiveRenderTargets, - void(bool bAllowDIP)); - MOCK_METHOD4(FX_Start, - void(CShader * ef, int nTech, CShaderResources * Res, IRenderElement * re)); - MOCK_METHOD1(RT_PopRenderTarget, - void(int nTarget)); - MOCK_METHOD5(RT_SetViewport, - void(int, int, int, int, int)); - MOCK_METHOD4(RT_PushRenderTarget, - void(int nTarget, CTexture * pTex, SDepthTexture * pDS, int nS)); - MOCK_METHOD5(EF_Scissor, - void(bool bEnable, int sX, int sY, int sWdt, int sHgt)); - -#ifdef SUPPORT_HW_MOUSE_CURSOR - MOCK_METHOD0(GetIHWMouseCursor, - IHWMouseCursor * ()); -#endif - - MOCK_METHOD0(GetRecursionLevel, - int()); - MOCK_METHOD2(GetIntegerConfigurationValue, - int(const char* varName, int defaultValue)); - MOCK_METHOD2(GetFloatConfigurationValue, - float(const char* varName, float defaultValue)); - MOCK_METHOD2(GetBooleanConfigurationValue, - bool(const char* varName, bool defaultValue)); - MOCK_METHOD3(ApplyDepthTextureState, - void(int unit, int nFilter, bool clamp)); - MOCK_METHOD0(GetZTargetTexture, - ITexture * ()); - MOCK_METHOD1(GetTextureState, - int(const STexState& TS)); - MOCK_METHOD7(TextureDataSize, - uint32(uint32, uint32, uint32, uint32, uint32, ETEX_Format, ETEX_TileMode)); - MOCK_METHOD6(ApplyForID, - void(int nID, int nTUnit, int nTState, int nTexMaterialSlot, int nSUnit, bool useWhiteDefault)); - MOCK_METHOD9(Create3DTexture, - ITexture * (const char* szName, int nWidth, int nHeight, int nDepth, int nMips, int nFlags, const byte * pData, ETEX_Format eTFSrc, ETEX_Format eTFDst)); - MOCK_METHOD1(IsTextureExist, - bool(const ITexture * pTex)); - MOCK_METHOD1(NameForTextureFormat, - const char*(ETEX_Format eTF)); - MOCK_METHOD1(NameForTextureType, - const char*(ETEX_Type eTT)); - MOCK_METHOD0(IsVideoThreadModeEnabled, - bool()); - MOCK_METHOD5(CreateDynTexture2, - IDynTexture * (uint32 nWidth, uint32 nHeight, uint32 nTexFlags, const char* szSource, ETexPool eTexPool)); - MOCK_METHOD0(GetCurrentTextureAtlasSize, - uint32()); - MOCK_METHOD2(BeginProfilerSection, - void(const char*, uint32)); - MOCK_METHOD1(EndProfilerSection, - void(const char*)); - MOCK_METHOD1(AddProfilerLabel, - void(const char*)); - - MOCK_METHOD5(EF_QueryImpl, - void(ERenderQueryTypes eQuery, void* pInOut0, uint32 nInOutSize0, void* pInOut1, uint32 nInOutSize1)); -}; - - diff --git a/Code/Legacy/CryCommon/Mocks/ISystemMock.h b/Code/Legacy/CryCommon/Mocks/ISystemMock.h index c4566537b1..9d41b9e77d 100644 --- a/Code/Legacy/CryCommon/Mocks/ISystemMock.h +++ b/Code/Legacy/CryCommon/Mocks/ISystemMock.h @@ -60,8 +60,6 @@ public: IViewSystem * ()); MOCK_METHOD0(GetILevelSystem, ILevelSystem * ()); - MOCK_METHOD0(GetINameTable, - INameTable * ()); MOCK_METHOD0(GetICmdLine, ICmdLine * ()); MOCK_METHOD0(GetILog, diff --git a/Code/Legacy/CryCommon/Platform/Android/crycommon_android.cmake b/Code/Legacy/CryCommon/Platform/Android/crycommon_android.cmake new file mode 100644 index 0000000000..7a325ca97e --- /dev/null +++ b/Code/Legacy/CryCommon/Platform/Android/crycommon_android.cmake @@ -0,0 +1,7 @@ +# +# 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/Code/Legacy/CryCommon/Platform/Android/crycommon_android_files.cmake b/Code/Legacy/CryCommon/Platform/Android/crycommon_android_files.cmake new file mode 100644 index 0000000000..7a325ca97e --- /dev/null +++ b/Code/Legacy/CryCommon/Platform/Android/crycommon_android_files.cmake @@ -0,0 +1,7 @@ +# +# 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/Code/Legacy/CryCommon/Platform/Linux/crycommon_linux.cmake b/Code/Legacy/CryCommon/Platform/Linux/crycommon_linux.cmake new file mode 100644 index 0000000000..7a325ca97e --- /dev/null +++ b/Code/Legacy/CryCommon/Platform/Linux/crycommon_linux.cmake @@ -0,0 +1,7 @@ +# +# 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/Code/Legacy/CryCommon/Platform/Linux/crycommon_linux_files.cmake b/Code/Legacy/CryCommon/Platform/Linux/crycommon_linux_files.cmake new file mode 100644 index 0000000000..7a325ca97e --- /dev/null +++ b/Code/Legacy/CryCommon/Platform/Linux/crycommon_linux_files.cmake @@ -0,0 +1,7 @@ +# +# 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/Code/Legacy/CryCommon/Platform/Mac/crycommon_mac.cmake b/Code/Legacy/CryCommon/Platform/Mac/crycommon_mac.cmake new file mode 100644 index 0000000000..7a325ca97e --- /dev/null +++ b/Code/Legacy/CryCommon/Platform/Mac/crycommon_mac.cmake @@ -0,0 +1,7 @@ +# +# 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/Code/Legacy/CryCommon/Platform/Mac/crycommon_mac_files.cmake b/Code/Legacy/CryCommon/Platform/Mac/crycommon_mac_files.cmake new file mode 100644 index 0000000000..7a325ca97e --- /dev/null +++ b/Code/Legacy/CryCommon/Platform/Mac/crycommon_mac_files.cmake @@ -0,0 +1,7 @@ +# +# 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/Code/Legacy/CryCommon/Platform/Windows/crycommon_windows.cmake b/Code/Legacy/CryCommon/Platform/Windows/crycommon_windows.cmake new file mode 100644 index 0000000000..7a325ca97e --- /dev/null +++ b/Code/Legacy/CryCommon/Platform/Windows/crycommon_windows.cmake @@ -0,0 +1,7 @@ +# +# 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/Code/Legacy/CryCommon/Platform/Windows/crycommon_windows_files.cmake b/Code/Legacy/CryCommon/Platform/Windows/crycommon_windows_files.cmake new file mode 100644 index 0000000000..7a325ca97e --- /dev/null +++ b/Code/Legacy/CryCommon/Platform/Windows/crycommon_windows_files.cmake @@ -0,0 +1,7 @@ +# +# 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/Code/Legacy/CryCommon/Platform/iOS/crycommon_ios.cmake b/Code/Legacy/CryCommon/Platform/iOS/crycommon_ios.cmake new file mode 100644 index 0000000000..7a325ca97e --- /dev/null +++ b/Code/Legacy/CryCommon/Platform/iOS/crycommon_ios.cmake @@ -0,0 +1,7 @@ +# +# 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/Code/Legacy/CryCommon/Platform/iOS/crycommon_ios_files.cmake b/Code/Legacy/CryCommon/Platform/iOS/crycommon_ios_files.cmake new file mode 100644 index 0000000000..7a325ca97e --- /dev/null +++ b/Code/Legacy/CryCommon/Platform/iOS/crycommon_ios_files.cmake @@ -0,0 +1,7 @@ +# +# 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/Code/Legacy/CryCommon/PoolAllocator.h b/Code/Legacy/CryCommon/PoolAllocator.h deleted file mode 100644 index 9125c87c51..0000000000 --- a/Code/Legacy/CryCommon/PoolAllocator.h +++ /dev/null @@ -1,507 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - - -#ifndef CRYINCLUDE_CRYCOMMON_POOLALLOCATOR_H -#define CRYINCLUDE_CRYCOMMON_POOLALLOCATOR_H -#pragma once - - -//--------------------------------------------------------------------------- -// Memory allocation class. Allocates, frees, and reuses fixed-size blocks of -// memory, a scheme sometimes known as Simple Segregated Memory. -// -// Allocation is amortized constant time. The normal case is very fast - -// basically just a couple of dereferences. If many blocks are allocated, -// the system may occasionally need to allocate a further bucket of blocks -// for itself. Deallocation is strictly fast constant time. -// -// Each PoolAllocator allocates blocks of a single size and alignment, specified -// by template arguments. There is no per-block space overhead, except for -// alignment. The free list mechanism uses the memory of the block itself -// when it is deallocated. -// -// In this implementation memory claimed by the system is never deallocated, -// until the entire allocator is deallocated. This is to ensure fast -// allocation/deallocation - reference counting the bucket quickly would -// require a pointer to the bucket be stored, whereas now no memory is used -// while the block is allocated. -// -// The class can optionally support multi-threading, using the second -// template parameter. By default it is multithread-safe. -// See Synchronization.h. -// -// The class is implemented using a HeapAllocator. -//--------------------------------------------------------------------------- - -#include "HeapAllocator.h" - -namespace stl -{ - ////////////////////////////////////////////////////////////////////////// - // Fixed-size pool allocator, using a shared heap. - template - class SharedSizePoolAllocator - { - template - friend struct PoolCommonAllocator; - protected: - - using_type(THeap, Lock); - - struct ObjectNode - { - ObjectNode* pNext; - }; - - static size_t AllocSize(size_t nSize) - { - return max(nSize, sizeof(ObjectNode)); - } - static size_t AllocAlign(size_t nSize, size_t nAlign) - { - return nAlign > 0 ? nAlign : min(nSize, alignof(void*)); - } - - public: - - SharedSizePoolAllocator(THeap& heap, size_t nSize, size_t nAlign = 0) - : _pHeap(&heap) - , _nAllocSize(AllocSize(nSize)) - , _nAllocAlign(AllocAlign(nSize, nAlign)) - , _pFreeList(0) - { - } - - ~SharedSizePoolAllocator() - { - // All allocated objects should be freed by now. - Lock lock(*_pHeap); - Validate(lock); - for (ObjectNode* pFree = _pFreeList; pFree; ) - { - ObjectNode* pNext = pFree->pNext; - _pHeap->Deallocate(lock, pFree, _nAllocSize); - pFree = pNext; - } - } - - // Raw allocation. - void* Allocate() - { - Lock lock(*_pHeap); - if (_pFreeList) - { - ObjectNode* pFree = _pFreeList; - _pFreeList = _pFreeList->pNext; - Validate(lock); - _Counts.nUsed++; - return pFree; - } - - // No free pointer, allocate a new one. - void* pNewMemory = _pHeap->Allocate(lock, _nAllocSize, _nAllocAlign); - if (pNewMemory) - { - _Counts.nUsed++; - _Counts.nAlloc++; - Validate(lock); - } - return pNewMemory; - } - - void Deallocate(void* pObject) - { - Deallocate(Lock(*_pHeap), pObject); - } - - SMemoryUsage GetCounts() const - { - Lock lock(*_pHeap); - return _Counts; - } - SMemoryUsage GetTotalMemory(const Lock&) const - { - return SMemoryUsage(_Counts.nAlloc * _nAllocSize, _Counts.nUsed * _nAllocSize); - } - - protected: - - void Deallocate(const Lock& lock, void* pObject) - { - if (pObject) - { - assert(_pHeap->CheckPtr(lock, pObject)); - - ObjectNode* pNode = static_cast(pObject); - - // Add the object to the front of the free list. - pNode->pNext = _pFreeList; - _pFreeList = pNode; - _Counts.nUsed--; - Validate(lock); - } - } - - void Validate(const Lock& lock) const - { - _pHeap->Validate(lock); - _Counts.Validate(); - assert(_Counts.nAlloc * _nAllocSize <= _pHeap->GetTotalMemory(lock).nUsed); - } - - void Reset(const Lock&, [[maybe_unused]] bool bForce = false) - { - assert(bForce || _Counts.nUsed == 0); - _Counts.Clear(); - _pFreeList = 0; - } - - protected: - const size_t _nAllocSize, _nAllocAlign; - SMemoryUsage _Counts; - - THeap* _pHeap; - ObjectNode* _pFreeList; - }; - - ////////////////////////////////////////////////////////////////////////// - struct SPoolMemoryUsage - : SMemoryUsage - { - size_t nPool; - - SPoolMemoryUsage(size_t _nAlloc = 0, size_t _nPool = 0, size_t _nUsed = 0) - : SMemoryUsage(_nAlloc, _nUsed) - , nPool(_nPool) - { - // These values are pulled from 3 atomic variables and not guaranteed to be a perfect "snapshot" - // Of the current state of the pool memory usage (e.g. Used may be > max, etc) - // Patch the values so that they make sense (it won't be wrong, just mildly out of date) - // This is done to prevent sticking expensive mutexes or potentially forever blocking semaphores in the pool - if (nUsed > nPool) - { - nPool = nUsed; - } - - assert(nPool <= nAlloc); - } - - size_t nPoolFree() const - { - return nPool - nUsed; - } - size_t nNonPoolFree() const - { - return nAlloc - nPool; - } - - void Clear() - { - nAlloc = nUsed = nPool = 0; - } - - void operator += (SPoolMemoryUsage const& op) - { - nAlloc += op.nAlloc; - nPool += op.nPool; - nUsed += op.nUsed; - } - }; - - ////////////////////////////////////////////////////////////////////////// - // SizePoolAllocator with owned heap - template - class SizePoolAllocator - : protected THeap - , public SharedSizePoolAllocator - { - typedef SharedSizePoolAllocator TPool; - - using_type(THeap, Lock); - using_type(THeap, FreeMemLock); - using TPool::AllocSize; - using TPool::_Counts; - using TPool::_nAllocSize; - - public: - - SizePoolAllocator(size_t nSize, size_t nAlign = 0, FHeap opts = 0) - : THeap(opts.PageSize(opts.PageSize * AllocSize(nSize))) - , TPool(*this, nSize, nAlign) - { - } - - using TPool::Allocate; - using THeap::GetMemoryUsage; - - void Deallocate(void* pObject) - { - FreeMemLock lock(*this); - TPool::Deallocate(lock, pObject); - if (THeap::FreeWhenEmpty && _Counts.nUsed == 0) - { - TPool::Reset(lock); - THeap::Clear(lock); - } - } - - void FreeMemoryIfEmpty() - { - FreeMemLock lock(*this); - if (_Counts.nUsed == 0) - { - TPool::Reset(lock); - THeap::Clear(lock); - } - } - - void ResetMemory() - { - FreeMemLock lock(*this); - TPool::Reset(lock); - THeap::Reset(lock); - } - - void FreeMemory() - { - FreeMemLock lock(*this); - TPool::Reset(lock); - THeap::Clear(lock); - } - - - void FreeMemoryForce() - { - FreeMemLock lock(*this); - TPool::Reset(lock, true); - THeap::Clear(lock); - } - - SPoolMemoryUsage GetTotalMemory() - { - Lock lock(*this); - return SPoolMemoryUsage(THeap::GetTotalMemory(lock).nAlloc, _Counts.nAlloc * _nAllocSize, _Counts.nUsed * _nAllocSize); - } - }; - - ////////////////////////////////////////////////////////////////////////// - // Templated size version of SizePoolAllocator - template - class PoolAllocator - : public SizePoolAllocator< HeapAllocator > - { - public: - PoolAllocator(FHeap opts = 0) - : SizePoolAllocator< HeapAllocator >(S, A, opts) - { - } - }; - - ////////////////////////////////////////////////////////////////////////// - template - class PoolAllocatorNoMT - : public SizePoolAllocator< HeapAllocator > - { - public: - PoolAllocatorNoMT(FHeap opts = 0) - : SizePoolAllocator< HeapAllocator >(S, A, opts) - { - } - }; - - ////////////////////////////////////////////////////////////////////////// - template - class TPoolAllocator - : public SizePoolAllocator< HeapAllocator > - { - typedef SizePoolAllocator< HeapAllocator > TSizePool; - - public: - - using TSizePool::Allocate; - using TSizePool::Deallocate; - - TPoolAllocator(FHeap opts = 0) - : TSizePool(sizeof(T), max(alignof(T), A), opts) - {} - - T* New() - { - return new(Allocate())T(); - } - - template - T* New(const I& init) - { - return new(Allocate())T(init); - } - - void Delete(T* ptr) - { - if (ptr) - { - ptr->~T(); - Deallocate(ptr); - } - } - }; - - // Legacy verbose typedefs. - typedef PSyncNone PoolAllocatorSynchronizationSinglethreaded; - typedef PSyncMultiThread PoolAllocatorSynchronizationMultithreaded; - - ////////////////////////////////////////////////////////////////////////// - // Allocator maintaining multiple type-specific pools, sharing a common heap source. - template - struct PoolCommonAllocator - : protected THeap - { - typedef SharedSizePoolAllocator TPool; - - using_type(THeap, Lock); - using_type(THeap, FreeMemLock); - - struct TPoolNode - : SharedSizePoolAllocator - { - TPoolNode* pNext; - - TPoolNode(THeap& heap, TPoolNode*& pList, size_t nSize, size_t nAlign) - : SharedSizePoolAllocator(heap, nSize, nAlign) - { - pNext = pList; - pList = this; - } - }; - - public: - - PoolCommonAllocator() - : _pPoolList(0) - { - } - ~PoolCommonAllocator() - { - TPoolNode* pPool = _pPoolList; - while (pPool) - { - TPoolNode* pNextPool = pPool->pNext; - delete pPool; - pPool = pNextPool; - } - } - - TPool* CreatePool(size_t nSize, size_t nAlign = 0) - { - return new TPoolNode(*this, _pPoolList, nSize, nAlign); - } - - SPoolMemoryUsage GetTotalMemory() - { - Lock lock(*this); - SMemoryUsage mem; - for (TPoolNode* pPool = _pPoolList; pPool; pPool = pPool->pNext) - { - mem += pPool->GetTotalMemory(lock); - } - return SPoolMemoryUsage(THeap::GetTotalMemory(lock).nAlloc, mem.nAlloc, mem.nUsed); - } - - bool FreeMemory(bool bDeallocate = true) - { - FreeMemLock lock(*this); - for (TPoolNode* pPool = _pPoolList; pPool; pPool = pPool->pNext) - { - if (pPool->GetTotalMemory(lock).nUsed) - { - return false; - } - } - - for (TPoolNode* pPool = _pPoolList; pPool; pPool = pPool->pNext) - { - pPool->Reset(lock); - } - - if (bDeallocate) - { - THeap::Clear(lock); - } - else - { - THeap::Reset(lock); - } - return true; - } - - protected: - TPoolNode* _pPoolList; - }; - - ////////////////////////////////////////////////////////////////////////// - // The additional TInstancer type provides a way of instantiating multiple instances - // of this class, without static variables. - template - struct StaticPoolCommonAllocator - { - ILINE static PoolCommonAllocator& StaticAllocator() - { - static PoolCommonAllocator s_Allocator; - return s_Allocator; - } - - typedef SharedSizePoolAllocator TPool; - - template - ILINE static TPool& TypeAllocator() - { - static TPool* sp_Pool = CreatePoolOnGlobalHeap(sizeof(T), alignof(T)); - return *sp_Pool; - } - - template - ILINE static void* Allocate(T*& p) - { return p = (T*)TypeAllocator().Allocate(); } - - template - ILINE static void Deallocate(T* p) - { return TypeAllocator().Deallocate(p); } - - template - static T* New() - { return new(TypeAllocator().Allocate())T(); } - - template - static T* New(const I& init) - { return new(TypeAllocator().Allocate())T(init); } - - template - static void Delete(T* ptr) - { - if (ptr) - { - ptr->~T(); - TypeAllocator().Deallocate(ptr); - } - } - - static SPoolMemoryUsage GetTotalMemory() - { return StaticAllocator().GetTotalMemory(); } - - private: - - ILINE static TPool* CreatePoolOnGlobalHeap(size_t nSize, size_t nAlign = 0) - { - return StaticAllocator().CreatePool(nSize, nAlign); - } - }; -}; - - -#endif // CRYINCLUDE_CRYCOMMON_POOLALLOCATOR_H diff --git a/Code/Legacy/CryCommon/StaticInstance.h b/Code/Legacy/CryCommon/StaticInstance.h index 70739a0a3c..8e14606abf 100644 --- a/Code/Legacy/CryCommon/StaticInstance.h +++ b/Code/Legacy/CryCommon/StaticInstance.h @@ -7,13 +7,24 @@ */ #pragma once +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include template class StaticInstanceSpecialization { }; -// Specializations for std::vector and std::map which allows us to modify the +// Specializations for std::vector and std::map which allows us to modify the // least amount of legacy code by mirroring the std APIs that are in use // These are not intended to be complete, just enough to shim existing legacy code template @@ -30,7 +41,7 @@ public: using size_type = typename Container::size_type; template - AZ_FORCE_INLINE + AZ_FORCE_INLINE typename AZStd::enable_if::value, reference>::type operator[](Integral index) { @@ -322,7 +333,7 @@ public: using size_type = typename Container::size_type; using pair_iter_bool = std::pair; - + AZ_FORCE_INLINE iterator begin() { @@ -360,7 +371,7 @@ public: } template - AZ_FORCE_INLINE + AZ_FORCE_INLINE typename AZStd::enable_if::value, mapped_type&>::type operator[](const K2& keylike) { diff --git a/Code/Legacy/CryCommon/VectorMap.h b/Code/Legacy/CryCommon/VectorMap.h index 75b1562c4d..6fce90b4ec 100644 --- a/Code/Legacy/CryCommon/VectorMap.h +++ b/Code/Legacy/CryCommon/VectorMap.h @@ -411,7 +411,6 @@ typename VectorMap::iterator VectorMap::lower_bound(cons { int count = static_cast(m_entries.size()); iterator first = m_entries.begin(); - iterator last = m_entries.end(); for (; 0 < count; ) { // divide and conquer, find half that contains answer int count2 = count / 2; @@ -434,7 +433,6 @@ typename VectorMap::const_iterator VectorMap::lower_boun { int count = static_cast(m_entries.size()); const_iterator first = m_entries.begin(); - const_iterator last = m_entries.end(); for (; 0 < count; ) { // divide and conquer, find half that contains answer int count2 = count / 2; diff --git a/Code/Legacy/CryCommon/WinBase.cpp b/Code/Legacy/CryCommon/WinBase.cpp index ae646e9e1c..8473417d4a 100644 --- a/Code/Legacy/CryCommon/WinBase.cpp +++ b/Code/Legacy/CryCommon/WinBase.cpp @@ -86,10 +86,6 @@ typedef struct stat FS_STAT_TYPE; #else typedef struct stat64 FS_STAT_TYPE; #endif -static const int FS_O_RDWR = O_RDWR; -static const int FS_O_RDONLY = O_RDONLY; -static const int FS_O_WRONLY = O_WRONLY; -static const FS_ERRNO_TYPE FS_EISDIR = EISDIR; #include @@ -829,7 +825,7 @@ const int comparePathNames(const char* cpFirst, const char* cpSecond, unsigned i return memicmp(first.c_str(), second.c_str(), length); } -#if defined(LINUX) || defined(APPLE) || defined(DEFINE_FIX_ONE_PATH_ELEMENT) +#if FIX_FILENAME_CASE static bool FixOnePathElement(char* path) { if (*path == '\0') @@ -1193,9 +1189,7 @@ DLL_EXPORT void OutputDebugString(const char* outputString) typedef DIR* FS_DIR_TYPE; typedef dirent FS_DIRENT_TYPE; static const FS_ERRNO_TYPE FS_ENOENT = ENOENT; -static const FS_ERRNO_TYPE FS_EINVAL = EINVAL; static const FS_DIR_TYPE FS_DIR_NULL = NULL; -static const unsigned char FS_TYPE_DIRECTORY = DT_DIR; typedef int FS_ERRNO_TYPE; @@ -1305,13 +1299,8 @@ const bool GetFilenameNoCase char* slash; const char* dirname; char* name; - FS_ERRNO_TYPE fsErr = 0; - FS_DIRENT_TYPE dirent; - uint64_t direntSize = 0; - FS_DIR_TYPE fd = FS_DIR_NULL; - if ( - (pAdjustedFilename) == (char*)-1) + if ((pAdjustedFilename) == (char*)-1) { return false; } @@ -1343,9 +1332,6 @@ const bool GetFilenameNoCase #endif // Scan for the file. - bool found = false; - bool skipScan = false; - if (slash) { *slash = '/'; diff --git a/Code/Legacy/CryCommon/crycommon_files.cmake b/Code/Legacy/CryCommon/crycommon_files.cmake index 8b8df7856e..7131eb7207 100644 --- a/Code/Legacy/CryCommon/crycommon_files.cmake +++ b/Code/Legacy/CryCommon/crycommon_files.cmake @@ -80,14 +80,12 @@ set(FILES CryHeaders_info.cpp CryListenerSet.h CryLegacyAllocator.h - CryName.h CryPath.h CryPodArray.h CrySizer.h CrySystemBus.h CryTypeInfo.h CryVersion.h - HeapAllocator.h LegacyAllocator.cpp LegacyAllocator.h MetaUtils.h @@ -95,7 +93,6 @@ set(FILES MultiThread_Containers.h NullAudioSystem.h PNoise3.h - PoolAllocator.h primitives.h ProjectDefines.h Range.h @@ -120,7 +117,6 @@ set(FILES Cry_Matrix33.h Cry_Matrix34.h Cry_Matrix44.h - Cry_MatrixDiag.h Cry_Vector4.h Cry_Camera.h Cry_Color.h @@ -133,7 +129,6 @@ set(FILES Cry_ValidNumber.h Cry_Vector2.h Cry_Vector3.h - Cry_XOptimise.h CryHalf_info.h CryHalf.inl MathConversion.h diff --git a/Code/Legacy/CryCommon/crycommon_testing_files.cmake b/Code/Legacy/CryCommon/crycommon_testing_files.cmake index b3769c4f63..9c3427d529 100644 --- a/Code/Legacy/CryCommon/crycommon_testing_files.cmake +++ b/Code/Legacy/CryCommon/crycommon_testing_files.cmake @@ -14,7 +14,6 @@ set(FILES Mocks/ISystemMock.h Mocks/ITimerMock.h Mocks/ICVarMock.h - Mocks/IRendererMock.h Mocks/ITextureMock.h Mocks/IRemoteConsoleMock.h ) diff --git a/Code/Legacy/CryCommon/physinterface.h b/Code/Legacy/CryCommon/physinterface.h index b1aaa5aef4..06d07af82b 100644 --- a/Code/Legacy/CryCommon/physinterface.h +++ b/Code/Legacy/CryCommon/physinterface.h @@ -8,10 +8,6 @@ // Description : declarations of all physics interfaces and structures - - -#ifndef CRYINCLUDE_CRYCOMMON_PHYSINTERFACE_H -#define CRYINCLUDE_CRYCOMMON_PHYSINTERFACE_H #pragma once @@ -25,3655 +21,4 @@ #endif #include - #include - -////////////////////////////////////////////////////////////////////////// -// Physics defines. -////////////////////////////////////////////////////////////////////////// - -enum EPE_Params -{ - ePE_params_pos = 0, - ePE_player_dimensions = 1, - ePE_params_car = 2, - ePE_params_particle = 3, - ePE_player_dynamics = 4, - ePE_params_joint = 5, - ePE_params_part = 6, - ePE_params_sensors = 7, - ePE_params_articulated_body = 8, - ePE_params_outer_entity = 9, - ePE_simulation_params = 10, - ePE_params_foreign_data = 11, - ePE_params_buoyancy = 12, - ePE_params_rope = 13, - ePE_params_bbox = 14, - ePE_params_flags = 15, - ePE_params_wheel = 16, - ePE_params_softbody = 17, - ePE_params_area = 18, - ePE_tetrlattice_params = 19, - ePE_params_ground_plane = 20, - ePE_params_structural_joint = 21, - ePE_params_waterman = 22, - ePE_params_timeout = 23, - ePE_params_skeleton = 24, - ePE_params_structural_initial_velocity = 25, - ePE_params_collision_class = 26, - - ePE_Params_Count -}; - -enum EPE_Action -{ - ePE_action_move = 1, - ePE_action_impulse = 2, - ePE_action_drive = 3, - ePE_action_reset = 4, - ePE_action_add_constraint = 5, - ePE_action_update_constraint = 6, - ePE_action_register_coll_event = 7, - ePE_action_awake = 8, - ePE_action_remove_all_parts = 9, - ePE_action_set_velocity = 10, - ePE_action_attach_points = 11, - ePE_action_target_vtx = 12, - ePE_action_reset_part_mtx = 13, - ePE_action_notify = 14, - ePE_action_auto_part_detachment = 15, - ePE_action_move_parts = 16, - ePE_action_batch_parts_update = 17, - ePE_action_slice = 18, - pPE_action_syncliving = 19, - - ePE_Action_Count -}; - -enum EPE_GeomParams -{ - ePE_geomparams = 0, - ePE_cargeomparams = 1, - ePE_articgeomparams = 2, - - ePE_GeomParams_Count -}; - -enum EPE_Status -{ - ePE_status_pos = 1, - ePE_status_living = 2, - ePE_status_vehicle = 4, - ePE_status_wheel = 5, - ePE_status_joint = 6, - ePE_status_awake = 7, - ePE_status_dynamics = 8, - ePE_status_collisions = 9, - ePE_status_id = 10, - ePE_status_timeslices = 11, - ePE_status_nparts = 12, - ePE_status_contains_point = 13, - ePE_status_rope = 14, - ePE_status_vehicle_abilities = 15, - ePE_status_placeholder = 16, - ePE_status_softvtx = 17, - ePE_status_sensors = 18, - ePE_status_sample_contact_area = 19, - ePE_status_caps = 20, - ePE_status_check_stance = 21, - ePE_status_waterman = 22, - ePE_status_area = 23, - ePE_status_extent = 24, - ePE_status_random = 25, - ePE_status_constraint = 26, - ePE_status_netpos = 27, - - ePE_Status_Count -}; - -enum pe_type -{ - PE_NONE = 0, PE_STATIC = 1, PE_RIGID = 2, PE_WHEELEDVEHICLE = 3, PE_LIVING = 4, PE_PARTICLE = 5, PE_ARTICULATED = 6, PE_ROPE = 7, PE_SOFT = 8, PE_AREA = 9 -}; -enum sim_class -{ - SC_STATIC = 0, SC_SLEEPING_RIGID = 1, SC_ACTIVE_RIGID = 2, SC_LIVING = 3, SC_INDEPENDENT = 4, SC_TRIGGER = 6, SC_DELETED = 7 -}; -struct IGeometry; -struct IPhysicalEntity; -struct IGeomManager; -struct IPhysRenderer; -class ICrySizer; -struct IDeferredPhysicsEvent; -struct ILog; -IPhysicalEntity* const WORLD_ENTITY = (IPhysicalEntity*)-10; - -#ifndef USE_IMPROVED_RIGID_ENTITY_SYNCHRONISATION -# define USE_IMPROVED_RIGID_ENTITY_SYNCHRONISATION 1 -#endif - -/** - * 64-bit wrapper for foreign data on physical entities. - * Int and pointer values are regularly stored in foreign data, but we now also support - * 64-bit unsigned integers (AZ::EntityId). - * - Supports implicit two-way conversion as integer, pointer, int, or 64-bit unsigned integer. - * - Supports casting to typed pointers for compatibility with original void* foreign data. - */ -class PhysicsForeignData final -{ -public: - - PhysicsForeignData() - : m_data(0) {} - - /// Explicit or implicit creation from pointer, int, or unsigned int types. - PhysicsForeignData(void* data) - : m_data(reinterpret_cast(data)) {} - PhysicsForeignData(int data) - : m_data(static_cast(data)) {} - PhysicsForeignData(uint64 data) - : m_data(static_cast(data)) {} - - /// Comparison operators. - bool operator==(const PhysicsForeignData& rhs) const - { - return m_data == rhs.m_data; - } - - bool operator!=(const PhysicsForeignData& rhs) const - { - return m_data != rhs.m_data; - } - - template - bool operator==(T* data) const - { - return reinterpret_cast(m_data) == data; - } - - template - bool operator==(const T* data) const - { - return reinterpret_cast(m_data) == data; - } - - bool operator==(int data) const - { - return static_cast(m_data) == data; - } - - bool operator==(uint64 data) const - { - return m_data == data; - } - - /// Using CryPhysics' existing pattern for marking fields as unused. - void MarkUnused() - { - m_data = uint64(1 << 31); - } - - bool IsUnused() const - { - return m_data == uint64(1 << 31); - } - - /// Bool operator for: if (foreignData) - operator bool() const - { - return m_data != 0; - } - - /// Void* cast conversion - operator void*() const - { - return reinterpret_cast(m_data); - } - - /// int cast conversion - operator int() const - { - return static_cast(m_data); - } - - /// 64-bit unsigned int cast conversion - operator uint64() const - { - return m_data; - } - - /// Cast conversion to pointers or arbitrary types. - template - operator T*() const - { - return reinterpret_cast(m_data); - } - -private: - - uint64 m_data; ///< Underlying 64-bit storage. -}; - -///////////////////////////////////////////////////////////////////////////////////// -//////////////////////////// IPhysicsStreamer Interface ///////////////////////////// -///////////////////////////////////////////////////////////////////////////////////// - -// this is a callback interface for on-demand physicalization, physics gets a pointer to an implementation -struct IPhysicsStreamer -{ - // - virtual ~IPhysicsStreamer(){} - // called whenever a placeholder (created through CreatePhysicalPlaceholder) requests a full entity - virtual int CreatePhysicalEntity(PhysicsForeignData foreignData, int iForeignData, int iForeignFlags) = 0; - // called whenever a placeholder-owned entity expires - virtual int DestroyPhysicalEntity(IPhysicalEntity* pent) = 0; - // called when on-demand entities in a box need to be physicalized - // (the grid is activated once RegisterBBoxInPODGrid is called) - virtual int CreatePhysicalEntitiesInBox(const Vec3& boxMin, const Vec3& boxMax) = 0; - // called when on-demand physicalized box expires. - // the streamer is expected to delete those that have a 0 refcounter, and keep the rest - virtual int DestroyPhysicalEntitiesInBox(const Vec3& boxMin, const Vec3& boxMax) = 0; - // -}; - -///////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////// IPhysRenderer Interface ///////////////////////////// -///////////////////////////////////////////////////////////////////////////////////// - -// this is a callback interface for debug rendering, physics gets a pointer to an implementation -struct IPhysRenderer -{ - // - virtual ~IPhysRenderer(){} - // draws helpers for the specified geometry (idxColor is in 0..7 range) - virtual void DrawGeometry(IGeometry* pGeom, struct geom_world_data* pgwd, int idxColor = 0, int bSlowFadein = 0, const Vec3& sweepDir = Vec3(0)) = 0; - // draws a line for wireframe helpers - virtual void DrawLine(const Vec3& pt0, const Vec3& pt1, int idxColor = 0, int bSlowFadein = 0) = 0; - // gets a descriptive name of the phys entity's owner (used solely for debug output) - virtual const char* GetForeignName(PhysicsForeignData foreignData, int iForeignData, int iForeignFlags) = 0; - // draws a text line (stauration is 0..1 and is currently used to represent stress level on a breakable joint) - virtual void DrawText(const Vec3& pt, const char* txt, int idxColor, float saturation = 0) = 0; - // sets an offset that is to be added to all subsequent draw requests - virtual Vec3 SetOffset(const Vec3& offs = Vec3(ZERO)) = 0; - // draw a frame or a partial frame using a scale for the axes. - // pnt is the world space position - // axes are the 3 axes normalized - // scale is a scale applied on the axes - // limits are the x, y, z radians for the Y, Z, X plane. If the pointer is not null, limits will be drawn in form of arcs. - // bitfield for what axes are locked - virtual void DrawFrame(const Vec3& pnt, const Vec3* axes, const float scale, const Vec3* limits, const int axes_locked) = 0; - // -}; - -class CMemStream -{ // For "fastload" serialization -public: - - ILINE CMemStream(bool swap) - { - Prealloc(); - m_iPos = 0; - bDeleteBuf = true; - bSwapEndian = swap; - bMeasureOnly = 0; - } - - ILINE CMemStream(void* pbuf, int sz, bool swap) - { - m_pBuf = (char*)pbuf; - m_nSize = sz; - m_iPos = 0; - bDeleteBuf = false; - bSwapEndian = swap; - bMeasureOnly = 0; - } - ILINE CMemStream() - { - m_pBuf = (char*)m_dummyBuf; - m_iPos = 0; - m_nSize = 0; - bDeleteBuf = false; - bSwapEndian = false; - bMeasureOnly = -1; - } - - virtual ~CMemStream() - { - if (bDeleteBuf) - { - CryModuleFree(m_pBuf); - } - } - virtual void Prealloc() - { - m_pBuf = (char*)CryModuleMalloc(m_nSize = 0x1000); - } - - ILINE void* GetBuf() { return m_pBuf; } - ILINE int GetUsedSize() { return m_iPos; } - ILINE int GetAllocatedSize() { return m_nSize; } - - template - ILINE void Write(const ftype& op) { Write(&op, sizeof(op)); } - ILINE void Write(const void* pbuf, int sz) - { -#if defined(MEMSTREAM_DEBUG) - if (bMeasureOnly <= 0 && m_nSize && m_iPos + sz > m_nSize) - { - printf("overflow: %d + %d >= %d\n", m_iPos, sz, m_nSize); - } -#endif - if (!bMeasureOnly) - { - if (m_iPos + sz > m_nSize) - { - GrowBuf(sz); - } - memcpy(m_pBuf + m_iPos, pbuf, (unsigned int)sz); - } - m_iPos += sz; - } - - virtual void GrowBuf(int sz) - { - int prevsz = m_nSize; - char* prevbuf = m_pBuf; - m_pBuf = (char*)CryModuleMalloc(m_nSize = (m_iPos + sz - 1 & ~0xFFF) + 0x1000); - memcpy(m_pBuf, prevbuf, (unsigned int)prevsz); - CryModuleFree(prevbuf); - } - - template - ILINE void Read(ftype& op) - { - ReadRaw(&op, sizeof(op)); -#if defined (NEED_ENDIAN_SWAP) - if (bSwapEndian) - { - SwapEndian(op); - } -#endif - } - - template - ILINE ftype Read() - { - ftype val; - Read(val); - return val; - } - template - ILINE void ReadType(ftype* op, int count = 1) - { - ReadRaw(op, sizeof(*op) * count); -#if defined (NEED_ENDIAN_SWAP) - if (bSwapEndian) - { - while (count-- > 0) - { - SwapEndian(*op++); - } - } -#endif - } - ILINE void ReadRaw(void* pbuf, int sz) - { -#if defined(MEMSTREAM_DEBUG) - if (bMeasureOnly <= 0 && m_nSize && m_iPos + sz > m_nSize) - { - printf("overflow: %d + %d >= %d\n", m_iPos, sz, m_nSize); - } -#endif - memcpy(pbuf, (m_pBuf + m_iPos), (unsigned int)sz); - m_iPos += sz; - } - - char* m_pBuf, m_dummyBuf[4]; - int m_iPos, m_nSize; - bool bDeleteBuf; - bool bSwapEndian; - int bMeasureOnly; -}; - - -// Workaround for bug in GCC 4.8. The kind of access patterns here leads to an internal -// compiler error in GCC 4.8 when optimizing with debug symbols. Two possible solutions -// are available, compile in Profile mode without debug symbols or remove optimizations -// in the code where the bug occurs -// see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59776 -#if defined(_PROFILE) && !defined(__clang__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) -// Cannot use #pragma GCC optimize("O0") because it causes a system crash when using -// the gcc compiler for another platform -#define CRY_GCC48_AVOID_OPTIMIZE __attribute__((optimize("-O0"))) -#else -#define CRY_GCC48_AVOID_OPTIMIZE -#endif -// unused_marker deliberately fills a variable with invalid data, -// so that later is_unused() can check whether it was initialized -// (this is used in all physics params/status/action structures) -class unused_marker -{ -public: - union f2i - { - float f; - uint32 i; - }; - union d2i - { - double d; - uint32 i[2]; - }; - unused_marker() {} - unused_marker& operator,(float& x) CRY_GCC48_AVOID_OPTIMIZE; - unused_marker& operator,(double& x) CRY_GCC48_AVOID_OPTIMIZE; - unused_marker& operator,(int& x) CRY_GCC48_AVOID_OPTIMIZE; - unused_marker& operator,(unsigned int& x) CRY_GCC48_AVOID_OPTIMIZE; - unused_marker& operator,(PhysicsForeignData& x) CRY_GCC48_AVOID_OPTIMIZE; - template - unused_marker& operator,(ref*& x) { x = (ref*)-1; return *this; } - template - unused_marker& operator,(Vec3_tpl& x) { return *this, x.x; } - template - unused_marker& operator,(Quat_tpl& x) { return *this, x.w; } - template - unused_marker& operator,(strided_pointer& x) { return *this, x.data; } -}; -inline unused_marker& unused_marker::operator,(float& x) { *alias_cast(&x) = 0xFFBFFFFF; return *this; } -inline unused_marker& unused_marker::operator,(double& x) { (alias_cast(&x))[false ? 1 : 0] = 0xFFF7FFFF; return *this; } -inline unused_marker& unused_marker::operator,(int& x) { x = 1 << 31; return *this; } -inline unused_marker& unused_marker::operator,(unsigned int& x) { x = 1u << 31; return *this; } -inline unused_marker& unused_marker::operator,(PhysicsForeignData& x) { x.MarkUnused(); return *this; } - -#undef CRY_GCC48_AVOID_OPTIMIZE - -inline bool is_unused(const float& x) { unused_marker::f2i u; u.f = x; return (u.i & 0xFFA00000) == 0xFFA00000; } - -inline bool is_unused(int x) { return x == 1 << 31; } -inline bool is_unused(unsigned int x) { return x == 1u << 31; } -inline bool is_unused(const PhysicsForeignData& x) { return x.IsUnused(); } -template -bool is_unused(ref* x) { return x == (ref*)-1; } -template -bool is_unused(strided_pointer x) { return is_unused(x.data); } -template -bool is_unused(const Ang3_tpl& x) { return is_unused(x.x); } -template -bool is_unused(const Vec3_tpl& x) { return is_unused(x.x); } -template -bool is_unused(const Quat_tpl& x) { return is_unused(x.w); } -inline bool is_unused(const double& x) { unused_marker::d2i u; u.d = x; return (u.i[eLittleEndian ? 1 : 0] & 0xFFF40000) == 0xFFF40000; } -#define MARK_UNUSED unused_marker(), - - -// validators do nothing in the interface, but inside the physics they are redefined -// so that they check the input for consistency and report errors -#if !defined(VALIDATOR_LOG) -#define VALIDATOR_LOG(pLog, str) -#define VALIDATORS_START -#define VALIDATOR(member) -#define VALIDATOR_NORM(member) -#define VALIDATOR_NORM_MSG(member, msg, member1) -#define VALIDATOR_RANGE(member, minval, maxval) -#define VALIDATOR_RANGE2(member, minval, maxval) -#define VALIDATORS_END -#endif - - - -////////// physics entity collision filtering class enums ///////////////// - -enum pe_collision_class -{ - /// reserved basic collision classes - collision_class_terrain = 1 << 0, - collision_class_wheeled = 1 << 1, - collision_class_living = 1 << 2, - collision_class_articulated = 1 << 3, - collision_class_soft = 1 << 4, - collision_class_rope = 1 << 5, - collision_class_particle = 1 << 6, - // begin game specific ones from this enum - collision_class_game = 1 << 10, -}; - -struct SCollisionClass -{ - uint32 type; // collision_class flags to identify the enity - uint32 ignore; // another entity will be ignored if *any* of these bits are set in its type - - SCollisionClass() {} - - SCollisionClass(uint32 t, uint32 i) - { - type = t; - ignore = i; - } -}; - -ILINE int IgnoreCollision(const SCollisionClass& a, const SCollisionClass& b) -{ - return (a.type & b.ignore) | (b.type & a.ignore); -} - - - -// in physics interface [almost] all parameters are passed via structures -// this allows having stable interface methods and flexible default arguments system - -////////////////////////// Params structures ///////////////////// - -////////// common params -struct pe_params -{ - int type; -}; - -struct pe_params_pos - : pe_params // Sets position and orientation of entity -{ - enum entype - { - type_id = ePE_params_pos - }; - pe_params_pos() - { - type = type_id; - MARK_UNUSED pos, scale, q, iSimClass; - pMtx3x4 = 0; - pMtx3x3 = 0; - bRecalcBounds = 1; - bEntGridUseOBB = 0; - } - - Vec3 pos; - quaternionf q; - float scale; // note that since there's no per-entity scale, it gets 'baked' into individual parts' scales - Matrix34* pMtx3x4; // optional position+orientation - Matrix33* pMtx3x3; // optional orientation via 3x3 matrix - int iSimClass; // see the sim_class enum - int bRecalcBounds; // tells to recompute the bounding boxes - bool bEntGridUseOBB; // whether or not to use part OBBs rather than object AABB when registering in the entity grid - - VALIDATORS_START - VALIDATOR(pos) - VALIDATOR_NORM_MSG(q, "(perhaps non-uniform scaling was used?)", pos) - VALIDATOR(scale) - VALIDATORS_END -}; - -struct pe_params_bbox - : pe_params -{ - enum entype - { - type_id = ePE_params_bbox - }; - pe_params_bbox() { type = type_id; MARK_UNUSED BBox[0], BBox[1]; } - Vec3 BBox[2]; // force this bounding box (note that if the entity recomputes it later, it'll override this) - - VALIDATORS_START - VALIDATOR(BBox[0]) - VALIDATOR(BBox[1]) - VALIDATORS_END -}; - -struct pe_params_outer_entity - : pe_params -{ - enum entype - { - type_id = ePE_params_outer_entity - }; - pe_params_outer_entity() { type = type_id; pOuterEntity = 0; pBoundingGeometry = 0; } - - IPhysicalEntity* pOuterEntity; // outer entity is used to group together SC_INDEPENDENT entities (example: ropes on a tree trunk) - IGeometry* pBoundingGeometry; // optional geometry to test containment (used in pe_status_contains_point) -}; - -struct ITetrLattice; - -struct pe_params_part - : pe_params // Sets geometrical parameters of entity part -{ - enum entype - { - type_id = ePE_params_part - }; - pe_params_part() - { - type = type_id; - MARK_UNUSED pos, q, scale, partid, ipart, mass, density, pPhysGeom, pPhysGeomProxy, idmatBreakable, pLattice, pMatMapping, minContactDist, flagsCond, idSkeleton, invTimeStep, idParent; - pMtx3x4 = 0; - pMtx3x3 = 0; - bRecalcBBox = 1; - bAddrefGeoms = 0; - flagsOR = flagsColliderOR = 0; - flagsAND = flagsColliderAND = (unsigned)-1; - } - - int partid; // partid identifier of part - int ipart; // optionally, internal part slot number - int bRecalcBBox; // whether entity's bounding box should be recalculated - Vec3 pos; - quaternionf q; - float scale; - Matrix34* pMtx3x4; // optional position+orientation - Matrix33* pMtx3x3; // optional orientation via 3x3 matrix - unsigned int flagsCond; // if partid and ipart are not specified, check for parts with flagsCond set - unsigned int flagsOR, flagsAND; // new flags = (flags & flagsAND) | flagsOR - unsigned int flagsColliderOR, flagsColliderAND; - float mass; // either mass of density should be set; mass = density*volume - float density; - float minContactDist; // threshold for contact points generation - struct phys_geometry* pPhysGeom, * pPhysGeomProxy; // if present and different from pPhysGeomProxy, pPhysGeom is used for raytracing - int idmatBreakable; // if >=0, the part is procedurally breakable with this mat_id (see AddExplosionShape) - ITetrLattice* pLattice; // lattice is used for soft bodies and procedural structural breaking - int idSkeleton; // part with this id becomes this part's deformation skeleton - int* pMatMapping; // material mapping table for this part - int nMats; // number of pMatMapping entries - float invTimeStep; // 1.0f/time_step, ragdolls will compute joint's velocity if this and position is set - int bAddrefGeoms; // AddRef returned geometries if used in GetParams - int idParent; // parent for hierarchical breaking; it hides all children until at least one of them breaks off - - VALIDATORS_START - VALIDATOR(pos) - VALIDATOR_NORM_MSG(q, "(perhaps non-uniform scaling was used in the asset?)", pt) - VALIDATOR(scale) - VALIDATORS_END -}; - -struct pe_params_sensors - : pe_params // Attaches optional ray sensors to an entity; only living entities support it -{ - enum entype - { - type_id = ePE_params_sensors - }; - pe_params_sensors() { type = type_id; nSensors = 0; pOrigins = 0; pDirections = 0; } - - int nSensors; // nSensors number of sensors - const Vec3* pOrigins; // pOrigins sensors origins in entity CS - const Vec3* pDirections; // pDirections sensors directions (dir*ray length) in entity CS -}; - -struct pe_simulation_params - : pe_params -{ - enum entype - { - type_id = ePE_simulation_params - }; - pe_simulation_params() - { - type = type_id; - MARK_UNUSED maxTimeStep, gravity, minEnergy, damping, iSimClass, - dampingFreefall, gravityFreefall, mass, density, maxLoggedCollisions, maxRotVel, disablePreCG, maxFriction, collTypes; - } - - int iSimClass; - float maxTimeStep; // maximum time step that entity can accept (larger steps will be split) - float minEnergy; // minimun of kinetic energy below which entity falls asleep (divided by mass) - float damping; // damped velocity = oridinal velocity * (1 - damping*time interval) - Vec3 gravity; // per-entity gravity (note that if there are any phys areas with gravity, they will override it unless pef_ignore_areas is set - float dampingFreefall; // damping and gravity used when there are no collisions, - Vec3 gravityFreefall; // NOTE: if left unused, gravity value will be substituted (if provided) - float maxRotVel; // rotational velocity is clamped to this value - float mass; // either mass of density should be set; mass = density*volume - float density; - int maxLoggedCollisions; // maximum EventPhysCollisions reported per frame (only supported by rigid bodies/ragdolls/vehicles) - int disablePreCG; // disables Pre-CG solver for the group this body is in (recommended for balls) - float maxFriction; // sets upper friction limit for this object and all objects it's currently in contact with - int collTypes; // collision types (a combination of ent_xxx flags) -}; - -struct pe_params_foreign_data - : pe_params -{ - enum entype - { - type_id = ePE_params_foreign_data - }; - pe_params_foreign_data() { type = type_id; MARK_UNUSED pForeignData, iForeignData, iForeignFlags; iForeignFlagsAND = -1; iForeignFlagsOR = 0; } - - PhysicsForeignData pForeignData; // foreign data is an arbitrary pointer used to associate physical entity with its owner object - int iForeignData; // foreign data types (defined in IPhysics.h) - int iForeignFlags; // any flags the owner wants to store - int iForeignFlagsAND, iForeignFlagsOR; // when setting, flagsNew = flags & flagsAND | flagsOR -}; - -struct pe_params_buoyancy - : pe_params -{ - enum entype - { - type_id = ePE_params_buoyancy - }; - pe_params_buoyancy() - { - type = type_id; - iMedium = 0; - MARK_UNUSED waterDensity, kwaterDensity, waterDamping, - waterPlane.n, waterPlane.origin, waterEmin, waterResistance, kwaterResistance, waterFlow, flowVariance; - }; - - float waterDensity; // overrides water density from the current water volume for an entity; sets for water areas - float kwaterDensity; // scales water density from the current water volume (used for entities only) - // NOTE: for entities , waterDensity override is stored as kwaterDensity relative to the global area's density - float waterDamping; // uniform damping while submerged, will be scaled with submerged fraction - float waterResistance, kwaterResistance; // water's medium resistance; same comments on water and kwater.. apply - Vec3 waterFlow; // flow's movement vector; can only be set for a water area - float flowVariance; // not yet supported - primitives::plane waterPlane; // positive normal = above the water surface - float waterEmin; // sleep energy while floating with no contacts (see minEnergy in pe_simulation_params) - int iMedium; // 0 for water, 1 for air -}; - -enum phentity_flags -{ - // PE_PARTICLE-specific flags - particle_single_contact = 0x01, // full stop after first contact - particle_constant_orientation = 0x02, // forces constant orientation - particle_no_roll = 0x04, // 'sliding' mode; entity's 'normal' vector axis will be alinged with the ground normal - particle_no_path_alignment = 0x08, // unless set, entity's y axis will be aligned along the movement trajectory - particle_no_spin = 0x10, // disables spinning while flying - particle_no_self_collisions = 0x100, // disables collisions with other particles - particle_no_impulse = 0x200, // particle will not add hit impulse (expecting that some other system will) - - // PE_LIVING-specific flags - lef_push_objects = 0x01, lef_push_players = 0x02, // push objects and players during contacts - lef_snap_velocities = 0x04, // quantizes velocities after each step (was ised in MP for precise deterministic sync) - lef_loosen_stuck_checks = 0x08, // don't do additional intersection checks after each step (recommended for NPCs to improve performance) - lef_report_sliding_contacts = 0x10, // unless set, 'grazing' contacts are not reported - - // PE_ROPE-specific flags - rope_findiff_attached_vel = 0x01, // approximate velocity of the parent object as v = (pos1-pos0)/time_interval - rope_no_solver = 0x02, // no velocity solver; will rely on stiffness (if set) and positional length enforcement - rope_ignore_attachments = 0x4, // no collisions with objects the rope is attached to - rope_target_vtx_rel0 = 0x08, rope_target_vtx_rel1 = 0x10, // whether target vertices are set in the parent entity's frame - rope_subdivide_segs = 0x100, // turns on 'dynamic subdivision' mode (only in this mode contacts in a strained state are handled correctly) - rope_no_tears = 0x200, // rope will not tear when it reaches its force limit, but stretch - rope_collides = 0x200000, // rope will collide with objects other than the terrain - rope_collides_with_terrain = 0x400000, // rope will collide with the terrain - rope_collides_with_attachment = 0x80, // rope will collide with the objects it's attached to even if the other collision flags are not set - rope_no_stiffness_when_colliding = 0x10000000, // rope will use stiffness 0 if it has contacts - - // PE_SOFT-specific flags - se_skip_longest_edges = 0x01, // the longest edge in each triangle with not participate in the solver - se_rigid_core = 0x02, // soft body will have an additional rigid body core - - // PE_RIGID-specific flags (note that PE_ARTICULATED and PE_WHEELEDVEHICLE are derived from it) - ref_use_simple_solver = 0x01, // use penalty-based solver (obsolete) - ref_no_splashes = 0x04, // will not generate EventPhysCollisions when contacting water - ref_checksum_received = 0x04, ref_checksum_outofsync = 0x08, // obsolete - ref_small_and_fast = 0x100, // entity will trace rays against alive characters; set internally unless overriden - - // PE_ARTICULATED-specific flags - aef_recorded_physics = 0x02, // specifies a an entity that contains pre-baked physics simulation - - // PE_WHEELEDVEHICLE-specific flags - wwef_fake_inner_wheels = 0x08, // exclude wheels between the first and the last one from the solver - // (only wheels with non-0 suspension are considered) - - // general flags - pef_parts_traceable = 0x10, // each entity part will be registered separately in the entity grid - pef_disabled = 0x20, // entity will not be simulated - pef_never_break = 0x40, // entity will not break or deform other objects - pef_deforming = 0x80, // entity undergoes a dynamic breaking/deforming - pef_pushable_by_players = 0x200, // entity can be pushed by playerd - pef_traceable = 0x400, particle_traceable = 0x400, rope_traceable = 0x400, // entity is registered in the entity grid - pef_update = 0x800, // only entities with this flag are updated if ent_flagged_only is used in TimeStep() - pef_monitor_state_changes = 0x1000, // generate immediate events for simulation class changed (typically rigid bodies falling asleep) - pef_monitor_collisions = 0x2000, // generate immediate events for collisions - pef_monitor_env_changes = 0x4000, // generate immediate events when something breaks nearby - pef_never_affect_triggers = 0x8000, // don't generate events when moving through triggers - pef_invisible = 0x10000, // will apply certain optimizations for invisible entities - pef_ignore_ocean = 0x20000, // entity will ignore global water area - pef_fixed_damping = 0x40000, // entity will force its damping onto the entire group - pef_monitor_poststep = 0x80000, // entity will generate immediate post step events - pef_always_notify_on_deletion = 0x100000, // when deleted, entity will awake objects around it even if it's not referenced (has refcount 0) - pef_override_impulse_scale = 0x200000, // entity will ignore breakImpulseScale in PhysVars - pef_players_can_break = 0x400000, // playes can break the entiy by bumping into it - pef_cannot_squash_players = 0x10000000, // entity will never trigger 'squashed' state when colliding with players - pef_ignore_areas = 0x800000, // entity will ignore phys areas (gravity and water) - pef_log_state_changes = 0x1000000, // entity will log simulation class change events - pef_log_collisions = 0x2000000, // entity will log collision events - pef_log_env_changes = 0x4000000, // entity will log EventPhysEnvChange when something breaks nearby - pef_log_poststep = 0x8000000, // entity will log EventPhysPostStep events -}; - -struct pe_params_flags - : pe_params -{ - enum entype - { - type_id = ePE_params_flags - }; - pe_params_flags() { type = type_id; MARK_UNUSED flags, flagsOR, flagsAND; } - unsigned int flags; - unsigned int flagsOR; // when setting, flagsNew = (flags set ? flags:flagsOld) & flagsAND | flagsOR - unsigned int flagsAND; // when getting, only flags is filled -}; - - -struct pe_params_collision_class - : pe_params -{ - enum entype - { - type_id = ePE_params_collision_class - }; - pe_params_collision_class() { type = type_id; collisionClassOR.type = collisionClassOR.ignore = 0; collisionClassAND.type = collisionClassAND.ignore = (unsigned)-1; } - SCollisionClass collisionClassOR; // When getting both collisionClassOR and collisionClassAND are filled out - SCollisionClass collisionClassAND; // When setting first collisionClassAND is applied to mask bits, then collisionClassOR is applied to turn on collision bits -}; - -struct pe_params_ground_plane - : pe_params -{ - // used for breakable objects; pieces that are below ground (at least partially) stay in the entity - enum entype - { - type_id = ePE_params_ground_plane - }; - pe_params_ground_plane() { type = type_id; iPlane = 0; MARK_UNUSED ground.origin, ground.n; } - int iPlane; // index of the plane to be set (-1 removes existing planes) - primitives::plane ground; -}; - -enum special_joint_ids -{ - joint_impulse = 1000000 -}; -struct pe_params_structural_joint - : pe_params -{ - enum entype - { - type_id = ePE_params_structural_joint - }; - pe_params_structural_joint() - { - type = type_id; - id = 0; - bReplaceExisting = 0; - MARK_UNUSED idx, partid[0], partid[1], pt, n, maxForcePush, maxForcePull, maxForceShift, maxTorqueBend, maxTorqueTwist, damageAccum, damageAccumThresh, - bBreakable, szSensor, bBroken, partidEpicenter, axisx, limitConstraint, bConstraintWillIgnoreCollisions, dampingConstraint; - } - - int id; // joint's 'foreign' identifier - int idx; // joint's internal index - int bReplaceExisting; // if not set, SetParams will add a new joint even if id is already used - int partid[2]; // ids of the parts this joint connects (-1 for ground) - Vec3 pt; // point in entity space - Vec3 n; // push/pull direction in entity space - Vec3 axisx; // x axis in entity frame; only used for joints that can become dynamic constraints - float maxForcePush, maxForcePull, maxForceShift; // linear force limits - float maxTorqueBend, maxTorqueTwist; // angular force (torque) limits - float damageAccum, damageAccumThresh; // fraction of tension that gets accumulated, can be used to emulate an health system - Vec3 limitConstraint; // x=min angle, y=max angle, z=force limit - int bBreakable; // joint is at all breakable - int bConstraintWillIgnoreCollisions; // dynamic constraints will have constraint_ignore_buddy flag - int bDirectBreaksOnly; // joint can only be broken by direct impulses to one of the parts it connects - float dampingConstraint; // dynamic constraint's damping - float szSensor; // sensor geometry size; used to re-attach the joint when parts break off - int bBroken; // joint is broken - int partidEpicenter; // tension recomputation will start from this part (used for network playback, for instance) -}; - -struct pe_params_structural_initial_velocity - : pe_params -{ - // Setting of initial velocities of parts before breaking joints on clients through pe_params_structural_joint - enum entype - { - type_id = ePE_params_structural_initial_velocity - }; - pe_params_structural_initial_velocity() { type = type_id; } - - int partid; // id of the part to prepare for breakage - Vec3 v; // Initial velocity - Vec3 w; // Initial ang velocity -}; - - -struct pe_params_timeout - : pe_params -{ - // entities can be forced to go to sleep after some time without external impulses - enum entype - { - type_id = ePE_params_timeout - }; - pe_params_timeout() { type = type_id; MARK_UNUSED timeIdle, maxTimeIdle; } - float timeIdle; // current 'idle' time (time without any 'prods' from outside) - float maxTimeIdle; // sleep when timeIdle>maxTimeIdle; 0 turns this feature off -}; - -struct pe_params_skeleton - : pe_params -{ - // skeleton is a hidden mesh that uses cloth simulation to skin the main physics geometry - enum entype - { - type_id = ePE_params_skeleton - }; - pe_params_skeleton() { type = type_id; MARK_UNUSED partid, ipart, stiffness, thickness, maxStretch, maxImpulse, timeStep, nSteps, hardness, explosionScale, bReset; } - - int partid; // id of the skinned part - int ipart; // ..or its internal index - float stiffness; // skeleton's hardness against bending and shearing - float thickness; // skeleton's thickness for collisions - float maxStretch; // skeleton's maximal stretching - float maxImpulse; // skeleton impulse cap - float timeStep; // time step, used to simulate the skeleton (typically small) - int nSteps; // number of skeleton sub-steps per each structure update - float hardness; // skeleton's hardness against stretching - float explosionScale; // skeleton's explosion impulse scale - int bReset; // resets the skeleton to its original pose -}; - - -////////// articulated entity params -enum joint_flags -{ - angle0_locked = 1, all_angles_locked = 7, angle0_limit_reached = 010, angle0_auto_kd = 0100, joint_no_gravity = 01000, - joint_isolated_accelerations = 02000, joint_expand_hinge = 04000, angle0_gimbal_locked = 010000, - joint_dashpot_reached = 0100000, joint_ignore_impulses = 0200000 -}; - -struct pe_params_joint - : pe_params -{ - enum entype - { - type_id = ePE_params_joint - }; - pe_params_joint() - { - type = type_id; - for (int i = 0; i < 3; i++) - { - MARK_UNUSED limits[0][i], limits[1][i], qdashpot[i], kdashpot[i], bounciness[i], q[i], qext[i], ks[i], kd[i], qtarget[i]; - } - bNoUpdate = 0; - pMtx0 = 0; - flagsPivot = 3; - MARK_UNUSED flags, q0, pivot, ranimationTimeStep, nSelfCollidingParts, animationTimeStep, op[0]; - } - - unsigned int flags; // should be a combination of angle0,1,2_locked, angle0,1,2_auto_kd, joint_no_gravity - int flagsPivot; // if bit 0 is set, update pivot point in parent frame, if bit 1 - in child - Vec3 pivot; // joint pivot in entity CS - quaternionf q0; // orientation of child in parent coordinates that corresponds to angles (0,0,0) - Matrix33* pMtx0; // same as q0 - Vec3 limits[2]; // limits for each angle - Vec3 bounciness; // bounciness for each angle (applied when limit is reached) - Vec3 ks, kd; // stiffness and damping koefficients for each angle angular spring - Vec3 qdashpot; // limit vicinity where joints starts resisting movement - Vec3 kdashpot; // when dashpot is activated, this is roughly the angular speed, stopped in 2 sec - Ang3 q; // angles values - Ang3 qext; // additional angles values (angle[i] = q[i]+qext[i]; only q[i] is taken into account - // while calculating spring torque - Ang3 qtarget; - int op[2]; // body identifiers of parent (optional) and child respectively - int nSelfCollidingParts, * pSelfCollidingParts; // part ids of only parts that should be checked for self-collision - int bNoUpdate; // omit recalculation of body parameters after changing this joint - float animationTimeStep; // used to calculate joint velocities of animation - float ranimationTimeStep; // 1/animation time step, can be not specified (specifying just saves extra division operation) - - VALIDATORS_START - VALIDATOR(pivot) - VALIDATOR_NORM(q0) - VALIDATOR(q) - VALIDATOR(qext) - VALIDATORS_END -}; - -struct pe_params_articulated_body - : pe_params -{ - enum entype - { - type_id = ePE_params_articulated_body - }; - pe_params_articulated_body() - { - type = type_id; - MARK_UNUSED bGrounded, bInheritVel, bCheckCollisions, bCollisionResp, nJointsAlloc; - MARK_UNUSED bGrounded, bInheritVel, bCheckCollisions, bCollisionResp, a, wa, w, v, pivot, scaleBounceResponse, posHostPivot, qHostPivot; - MARK_UNUSED bAwake, pHost, nCollLyingMode, gravityLyingMode, dampingLyingMode, minEnergyLyingMode, iSimType, iSimTypeLyingMode, nRoots; - bApply_dqext = 0; - bRecalcJoints = 1; - } - - int bGrounded; // whether body's pivot is firmly attached to something or free - int bCheckCollisions; // only works with bCollisionResp set - int bCollisionResp; // when on, uses 'ragdoll' simulation mode, when off - 'skeleton' (for hit simulation on alive actors) - Vec3 pivot; // attachment position for grounded entities - Vec3 a; // acceleration of the ground for grounded entities - Vec3 wa; // angular acceleration of the ground for grounded entities - Vec3 w; // angular velocity of the ground for grounded entities - Vec3 v; // linear velocity of the ground for grounded entities - float scaleBounceResponse; // scales impulsive torque that is applied at a joint that has just reached its limit - int bApply_dqext; // adds current dqext to joints velocities. dqext is the speed of external animation and is calculated each time - // qext is set for joint (as difference between new value and current value, multiplied by inverse of animation timestep) - int bAwake; // current state - - IPhysicalEntity* pHost; // 'ground' entity - Vec3 posHostPivot; // attachment position inside pHost - quaternionf qHostPivot; - int bInheritVel; // take pHost velocity into account during the simulation - - int nCollLyingMode; // number of contacts that triggers 'lying mode' - Vec3 gravityLyingMode; // gravity override in lying mode - float dampingLyingMode; // damping override - float minEnergyLyingMode; // sleep speed override - int iSimType; // simulation type: 0-'joint-based', 1-'body-based'; fast motion forces joint-based mode automatically - int iSimTypeLyingMode; // simulation type override - int nRoots; // only used in GetParams - int nJointsAlloc; // pre-allocates this amount of joints and parts - - int bRecalcJoints; // re-build geometry positions from joint agnles -}; - -////////// living entity params - -struct pe_player_dimensions - : pe_params -{ - enum entype - { - type_id = ePE_player_dimensions - }; - pe_player_dimensions() - : dirUnproj(0, 0, 1) - , maxUnproj(0) - { - type = type_id; - MARK_UNUSED sizeCollider, heightPivot, heightCollider, heightEye, heightHead, headRadius, bUseCapsule, groundContactEps; - } - - float heightPivot; // offset from central ground position that is considered entity center - float heightEye; // vertical offset of camera - Vec3 sizeCollider; // collision cylinder dimensions - float heightCollider; // vertical offset of collision geometry center - float headRadius; // radius of the 'head' geometry (used for camera offset) - float heightHead; // center.z of the head geometry - Vec3 dirUnproj; // unprojection direction to test in case the new position overlaps with the environment (can be 0 for 'auto') - float maxUnproj; // maximum allowed unprojection - int bUseCapsule; // switches between capsule and cylinder collider geometry - float groundContactEps; // the amount that the living needs to move upwards before ground contact is lost. defaults to which ever is greater 0.004, or 0.01*geometryHeight - - VALIDATORS_START - VALIDATOR(heightPivot) - VALIDATOR(heightEye) - VALIDATOR_RANGE2(sizeCollider, 0, 100) - VALIDATORS_END -}; - -struct pe_player_dynamics - : pe_params -{ - enum entype - { - type_id = ePE_player_dynamics - }; - pe_player_dynamics() - { - type = type_id; - MARK_UNUSED kInertia, kInertiaAccel, kAirControl, gravity, gravity.z, nodSpeed, mass, bSwimming, surface_idx, bActive, collTypes, pLivingEntToIgnore; - MARK_UNUSED minSlideAngle, maxClimbAngle, maxJumpAngle, minFallAngle, kAirResistance, maxVelGround, timeImpulseRecover, bReleaseGroundColliderWhenNotActive; - } - - float kInertia; // inertia koefficient, the more it is, the less inertia is; 0 means no inertia - float kInertiaAccel; // inertia on acceleration - float kAirControl; // air control coefficient 0..1, 1 - special value (total control of movement) - float kAirResistance; // standard air resistance - Vec3 gravity; // gravity vector - float nodSpeed; // vertical camera shake speed after landings - int bSwimming; // whether entity is swimming (is not bound to ground plane) - float mass; // mass (in kg) - int surface_idx; // surface identifier for collisions - float minSlideAngle; // if surface slope is more than this angle, player starts sliding (angle is in degrees) - float maxClimbAngle; // player cannot climb surface which slope is steeper than this angle (angle is in degrees) - float maxJumpAngle; // player is not allowed to jump towards ground if this angle is exceeded (angle is in degrees) - float minFallAngle; // player starts falling when slope is steeper than this (angle is in degrees) - float maxVelGround; // player cannot stand on surfaces that are moving faster than this - float timeImpulseRecover; // forcefully turns on inertia for that duration after receiving an impulse - int collTypes; // entity types to check collisions against - IPhysicalEntity* pLivingEntToIgnore; // ignore collisions with this *living entity* (doesn't work with other entity types) - int bActive; // 0 disables all simulation for the character, apart from moving along the requested velocity - int bReleaseGroundColliderWhenNotActive; // when not 0, if the living entity is not active, the ground collider, if any, will be explicitly released during the simulation step. -}; - -////////// particle entity params - -struct pe_params_particle - : pe_params -{ - enum entype - { - type_id = ePE_params_particle - }; - pe_params_particle() - { - type = type_id; - MARK_UNUSED mass, size, thickness, wspin, accThrust, kAirResistance, kWaterResistance, velocity, heading, accLift, accThrust, gravity, waterGravity; - MARK_UNUSED surface_idx, normal, q0, minBounceVel, rollAxis, flags, pColliderToIgnore, iPierceability, areaCheckPeriod, minVel, collTypes, dontPlayHitEffect; - } - - unsigned int flags; // see entity flags - float mass; - float size; // pseudo-radius - float thickness; // thickness when lying on a surface (if left unused, size will be used) - Vec3 heading; // direction of movement - float velocity; // velocity along "heading" - float kAirResistance; // air resistance koefficient, F = kv - float kWaterResistance; // same for water - float accThrust; // acceleration along direction of movement - float accLift; // acceleration that lifts particle with the current speed - int surface_idx; - Vec3 wspin; // angular velocity - Vec3 gravity; // stores this gravity and uses it if the current area's gravity is equal to the global gravity - Vec3 waterGravity; // gravity when underwater - Vec3 normal; // aligns this direction with the surface normal when sliding - Vec3 rollAxis; // aligns this directon with the roll axis when rolling (0,0,0 to disable alignment) - quaternionf q0; // initial orientation (zero means x along direction of movement, z up) - float minBounceVel; // velocity threshold for bouncing->sliding switch - float minVel; // sleep speed threshold - IPhysicalEntity* pColliderToIgnore; // physical entity to ignore during collisions - int iPierceability; // pierceability for ray tests; pierceble hits slow the particle down, but don't stop it - int collTypes; // 'objtype' passed to RayWorldntersection - int areaCheckPeriod; // how often (in frames) world area checks are made - int dontPlayHitEffect; // prevent playing of material FX from now on - - VALIDATORS_START - VALIDATOR(mass) - VALIDATOR(size) - VALIDATOR(thickness) - VALIDATOR_NORM(heading) - VALIDATOR_NORM(q0) - VALIDATORS_END -}; - -////////// vehicle entity params - -struct pe_params_car - : pe_params -{ - enum entype - { - type_id = ePE_params_car - }; - pe_params_car() - { - type = type_id; - MARK_UNUSED engineMaxRPM, iIntegrationType, axleFriction, enginePower, maxSteer, maxTimeStep, minEnergy, damping, brakeTorque; - MARK_UNUSED engineMinRPM, engineShiftUpRPM, engineShiftDownRPM, engineIdleRPM, engineStartRPM, clutchSpeed, nGears, gearRatios, kStabilizer; - MARK_UNUSED slipThreshold, gearDirSwitchRPM, kDynFriction, minBrakingFriction, maxBrakingFriction, steerTrackNeutralTurn, maxGear, minGear, pullTilt; - MARK_UNUSED maxTilt, bKeepTractionWhenTilted; - } - - float axleFriction; // friction torque at axes divided by mass of vehicle - float enginePower; // power of engine (about 10,000 - 100,000) - float maxSteer; // maximum steering angle - float engineMaxRPM; // engine torque decreases to 0 after reaching this rotation speed - float brakeTorque; // torque applied when breaking using the engine - int iIntegrationType; // for suspensions; 0-explicit Euler, 1-implicit Euler - float maxTimeStep; // maximum time step when vehicle has only wheel contacts - float minEnergy; // minimum awake energy when vehicle has only wheel contacts - float damping; // damping when vehicle has only wheel contacts - float minBrakingFriction; // limits the the tire friction when handbraked - float maxBrakingFriction; // limits the the tire friction when handbraked - float kStabilizer; // stabilizer force, as a multiplier for kStiffness of respective suspensions - int nWheels; // the number of wheels - float engineMinRPM; // disengages the clutch when falling behind this limit, if braking with the engine - float engineShiftUpRPM; // RPM threshold for for automatic gear switching - float engineShiftDownRPM; - float engineIdleRPM; // RPM for idle state - float engineStartRPM; // sets this RPM when activating the engine - float clutchSpeed; // clutch engagement/disengagement speed - int nGears; - float* gearRatios; // assumes 0-backward gear, 1-neutral, 2 and above - forward - int maxGear, minGear; // additional gear index clamping - float slipThreshold; // lateral speed threshold for switchig a wheel to a 'slipping' mode - float gearDirSwitchRPM; // RPM threshold for switching back and forward gears - float kDynFriction; // friction modifier for sliping wheels - float steerTrackNeutralTurn; // for tracked vehicles, steering angle that causes equal but opposite forces on tracks - float pullTilt; // for tracked vehicles, tilt angle of pulling force towards ground - float maxTilt; // maximum wheel contact normal tilt (left or right) after which it acts as a locked part of the hull; it's a cosine of the angle - int bKeepTractionWhenTilted; // keeps wheel traction in tilted mode -}; - -struct pe_params_wheel - : pe_params -{ - enum entype - { - type_id = ePE_params_wheel - }; - pe_params_wheel() - { - type = type_id; - iWheel = 0; - MARK_UNUSED bDriving, iAxle, suspLenMax, suspLenInitial, minFriction, maxFriction, surface_idx, bCanBrake, bBlocked, - bRayCast, kStiffness, kDamping, kLatFriction, Tscale, w, bCanSteer, kStiffnessWeight; - } - - int iWheel; - int bDriving; - int iAxle; // wheels on the same axle align their coordinates (if only slightly misaligned) - // and apply stabilizer force (if set); axle<0 means the wheel does not affect the physics - int bCanBrake; // handbrake applies - int bBlocked; // locks the wheel (acts like a forced handbrake) - int bCanSteer; // can this wheel steer, 0 or 1 - float suspLenMax; // full suspension length (relaxed) - float suspLenInitial; // length in the initial state (used for automatic computations) - float minFriction; // surface friction is cropped to this min-max range - float maxFriction; - int surface_idx; - int bRayCast; // uses raycasts instead of cylinders - float kStiffness; // if 0, will be computed based on mass distribution, lenMax, and lenInitial - float kStiffnessWeight; // When autocalculating stiffness use this weight for this wheel. Note weights for wheels in front of the centre of mass do not influence the weights of wheels behind the centre of mass - // By default all weights are 1.0 and the sum doesn't have to add up to 1.0! - // Also a <=0 weight will leave the wheel out of the autocalculation. It will be get a stiffness of weight*mass*gravity/defaultLength/numWheels. weight=-1 is a good starting point for these wheels - float kDamping; // absolute value if >=0, otherwise -(fraction of 0-oscillation damping) - float kLatFriction; // lateral friction scale (doesn't apply when on handbrake) - float Tscale; // optional driving torque scale - float w; // rotational velocity; it's computed automatically, but can be overriden if needed -}; - -////////// rope entity params - -struct pe_params_rope - : pe_params -{ - enum entype - { - type_id = ePE_params_rope - }; - pe_params_rope() - { - type = type_id; - //START: Per bone UDP for stiffness, damping and thickness for touch bending vegetation - MARK_UNUSED length, mass, collDist, surface_idx, friction, nSegments, pPoints.data, pVelocities.data, pDamping, pStiffness, pThickness; - //END: Per bone UDP for stiffness, damping and thickness for touch bending vegetation - MARK_UNUSED pEntTiedTo[0], ptTiedTo[0], idPartTiedTo[0], pEntTiedTo[1], ptTiedTo[1], idPartTiedTo[1], stiffnessAnim, maxForce, - flagsCollider, nMaxSubVtx, stiffnessDecayAnim, dampingAnim, bTargetPoseActive, wind, windVariance, airResistance, waterResistance, density, collTypes, - jointLimit, jointLimitDecay, sensorRadius, frictionPull, stiffness, collisionBBox[0], penaltyScale, maxIters, attachmentZone, minSegLen, unprojLimit, noCollDist, hingeAxis; - bLocalPtTied = 0; - } - - float length; // 'target' length; 0 is allowed for ropes with dynamic subdivision - float mass; - float collDist; // thickness for collisions - int surface_idx; // for collision reports; friction is overriden - float friction; // friction for free state and lateral friction in strained state - float frictionPull; // friction in pull direction in strained state - float stiffness; // stiffness against stretching (used in the solver; it's *not* a spring, though) - float stiffnessAnim; // shape-preservation stiffness - float stiffnessDecayAnim; // the final shape stiffness will be interpolated from full to full*(1-decay) at the end - float dampingAnim; // damping for shape preservation forces - int bTargetPoseActive; // 0-no target pose (no shape-preservation stiffness), - // 1-simplified target pose (vertices are pulled directly to targets) - // 2-physically correct target pose (the rope applies penalty torques at joints) - Vec3 wind; // local wind in addition to one from phys areas - float windVariance; // wariance (applied to local only) - float airResistance; // needs to be >0 in order to be affetcted by the wind - float waterResistance; // medium resistance when underwater - float density; // used only to compute buoyancy - float jointLimit; // joint rotation limit (doesn't work when both ends are tied) - float jointLimitDecay; // joint limit change (0..1) towards the unattached rope end; can be positive or negative - float sensorRadius; // size of the sensor used to re-attach the rope if the host entity breaks - float maxForce; // force limit; when breached, the rope will detach itself unless rope_no_tears is set - float penaltyScale; // for the solver in strained state with subdivision on - float attachmentZone; // don't register solver contacts within this distance around attachment points (subdivision mode) - float minSegLen; // delete segments below this length in subdivision mode - float unprojLimit; // rotational unprojection limit per frame (no-subdivision mode) - float noCollDist; // fraction of the segment near the attachment point that doesn't collide (no-subdivision mode) - int maxIters; // tweak for the internal vertex solver - int nSegments; // segment count, changin will reset vertex positions - int flagsCollider; // only collide with entity parts flagged this way - int collTypes; // a selection of ent_xxx flags to collide against - int nMaxSubVtx; // maximum internal vertices per segment in subdivision mode - Vec3 collisionBBox[2]; // bbox for entity proximity query in host's space - // (used make all ropes belonging to one host share the same box, to automatically reuse the query results) - Vec3 hingeAxis; // only allow rotation around this axis (in parent's frame if rope_target_vtx_rel is set) - strided_pointer pPoints; - strided_pointer pVelocities; - - IPhysicalEntity* pEntTiedTo[2]; - int bLocalPtTied; // ptTiedTo is in tied part's local coordinates - Vec3 ptTiedTo[2]; - int idPartTiedTo[2]; - //START: Per bone UDP for stiffness, damping and thickness for touch bending vegetation - float* pDamping; - float* pStiffness; - float* pThickness; - //END: Per bone UDP for stiffness, damping and thickness for touch bending vegetation -}; - -////////// soft entity params - -struct pe_params_softbody - : pe_params -{ - enum entype - { - type_id = ePE_params_softbody - }; - pe_params_softbody() - { - type = type_id; - MARK_UNUSED thickness, maxSafeStep, ks, kdRatio, airResistance, wind, windVariance, nMaxIters, - accuracy, friction, impulseScale, explosionScale, collisionImpulseScale, maxCollisionImpulse, collTypes, waterResistance, massDecay, - shapeStiffnessNorm, shapeStiffnessTang, stiffnessAnim, stiffnessDecayAnim, dampingAnim, maxDistAnim, hostSpaceSim; - } - - float thickness; // thickness for collisions - float maxSafeStep; // time step cap - float ks; // stiffness against stretching (for soft bodies, <0 means fraction of maximum stable) - float kdRatio; // damping in stretch direction, in fractions of 0-oscillation damping - float friction; // overrides material friction - float waterResistance; - float airResistance; - Vec3 wind; // wind in addition to phys area wind - float windVariance; // wind variance, in fractions of 1 (currently changes 4 times/sec) - int nMaxIters; // tweak for the solver (complexity = O(nMaxIters*numVertices)) - float accuracy; // accuracy for the solver (velocity) - float impulseScale; // scale general incoming impulses - float explosionScale; // scale impulses from explosions - float collisionImpulseScale; // not used - float maxCollisionImpulse; // not used - int collTypes; // combination of ent_... flags - float massDecay; // decreases mass from attached points to free ends; mass_free = mass_attached/(1+decay) (can impove stability) - float shapeStiffnessNorm; // resistance to bending - float shapeStiffnessTang; // resistance to shearing - float stiffnessAnim; // strength of linear target pose pull - float stiffnessDecayAnim; // decay of stiffnessAnim - float dampingAnim; // damping for target pose pull - float maxDistAnim; // max deviation from the target pose at the rim; uses stiffnessDecalAnim to scale down closer to attached vtx - float hostSpaceSim; // 0 - world-space simulation, 1 - fully host-space simulation -}; - -/////////// area params - -struct params_wavesim -{ - params_wavesim() { MARK_UNUSED timeStep, waveSpeed, dampingCenter, dampingRim, minhSpread, minVel, simDepth, heightLimit, resistance; } - float timeStep; // fixed timestep used for the simulation - float waveSpeed; // wave propagation speed - float simDepth; // assumed height of moving water layer (relative to cell size) - float heightLimit; // hard limit on height changes (relative to cell size) - float resistance; // rate of velocity transfer from floating objects - float dampingCenter; // damping in the central tile - float dampingRim; // damping in the outer tiles - float minhSpread; // minimum height perturbation that activates a neighbouring tile - float minVel; // sleep speed threshold -}; - -struct pe_params_area - : pe_params -{ - enum entype - { - type_id = ePE_params_area - }; - pe_params_area() { type = type_id; MARK_UNUSED gravity, bUniform, damping, falloff0, bUseCallback, pGeom, volume, borderPad, bConvexBorder, objectVolumeThreshold, cellSize, growthReserve, volumeAccuracy; } - // water/air area params are set through pe_params_buoyancy - - Vec3 gravity; // see also bUniform - float falloff0; // parametric distance (0..1) where falloff starts - int bUniform; // gravity has same direction in every point or always points to the center - int bUseCallback; // will generate immediate EventPhysArea when needs to apply params to an entity - float damping; // uniform damping - IGeometry* pGeom; // phys geometry used in the area - float volume; // the area will try to maintain this volume by adjusting water level - float volumeAccuracy; // accuracy of level computation based on volume (in fractions of the volume) - float borderPad; // after adjusting level, expand the border by this distance - int bConvexBorder; // forces convex border after water level adjustments - float objectVolumeThreshold; // only consider entities larger than this for level adjustment (set in fractions of area volume) - float cellSize; // cell size for wave simulation - params_wavesim waveSim; - float growthReserve; // assume this area increase during level adjustment (only used for wave simulation) -}; - - -////////// water manager params - -struct pe_params_waterman - : pe_params - , params_wavesim -{ - enum entype - { - type_id = ePE_params_waterman - }; - pe_params_waterman() - { - type = type_id; - MARK_UNUSED posViewer, nExtraTiles, nCells, tileSize, timeStep, waveSpeed, - dampingCenter, dampingRim, minhSpread, minVel, simDepth, heightLimit, resistance; - } - - Vec3 posViewer; // water will only be simulated around this point - int nExtraTiles; // number of additional tiles in each direction around the one below posViewer (so total = (nExtarTiles*2+1)^2) - int nCells; // number of cells in each tile - float tileSize; -}; - - -////////////////////////// Action structures ///////////////////// - -////////// common actions -struct pe_action -{ - int type; -}; - -struct pe_action_impulse - : pe_action -{ - enum entype - { - type_id = ePE_action_impulse - }; - pe_action_impulse() { type = type_id; impulse.Set(0, 0, 0); MARK_UNUSED point, angImpulse, partid, ipart; iApplyTime = 2; iSource = 0; } - - Vec3 impulse; - Vec3 angImpulse; // optional - Vec3 point; // point of application, in world CS, optional - int partid; // receiver part identifier - int ipart; // alternatively, part index can be used - int iApplyTime; // 0-apply immediately, 1-apply before the next time step, 2-apply after the next time step - int iSource; // reserved for internal use - - VALIDATORS_START - VALIDATOR_RANGE2(impulse, 0, 1E12f) - VALIDATOR_RANGE2(angImpulse, 0, 1E8f) - VALIDATOR_RANGE2(point, 0, 1E6f) - VALIDATOR_RANGE(ipart, 0, 10000) - VALIDATORS_END -}; - -struct pe_action_reset - : pe_action // Resets dynamic state of an entity -{ - enum entype - { - type_id = ePE_action_reset - }; - pe_action_reset() { type = type_id; bClearContacts = 1; } - int bClearContacts; -}; - -enum constrflags // see pe_action_add_constraint -{ - local_frames = 1, // pt and qframe are in respective entities' coordinate frames - world_frames = 2, // pt and qframe are in the world frame - local_frames_part = 4, // pt and qframe are if respective entity parts' coordinate frames - constraint_inactive = 0x100, // constraint does nothing, except applying _ignore_buddy if set - constraint_ignore_buddy = 0x200, // disables collisions between the constrained entities - constraint_line = 0x400, // position if constrained to a line - constraint_plane = 0x800, // position is constrained to a plane - constraint_free_position = 0x1000, // position is unconstrained - constraint_no_rotation = 0x2000, // relative rotation is fully constrained - constraint_no_enforcement = 0x4000, // disables positional enforcement during fast movement (currently disabled unconditionally) - constraint_no_tears = 0x8000 // constraint is not deleted when force limit is reached -}; - -struct pe_action_add_constraint - : pe_action -{ - enum entype - { - type_id = ePE_action_add_constraint - }; - pe_action_add_constraint() - { - type = type_id; - pBuddy = 0; - flags = world_frames; - MARK_UNUSED id, pt[0], pt[1], partid[0], partid[1], qframe[0], qframe[1], xlimits[0], yzlimits[0], - pConstraintEntity, damping, sensorRadius, maxPullForce, maxBendTorque; - } - int id; // if not set, will be auto-assigned; return value of Action() - IPhysicalEntity* pBuddy; // the second constrained entity; can be WORLD_ENTITY for static attachments - Vec3 pt[2]; // pt[0] must be set; if pt[1] is not set, assumed to be equal to pt[1] - int partid[2]; // if not set, the first part is assumed - quaternionf qframe[2]; // constraint frames for constraint angles computation; if not set, identity in the specified frame is assumed - float xlimits[2]; // rotation limits around x axis ("twist"); if xlimits[0]>=[1], x axis is locked - float yzlimits[2]; // combined yz-rotation - "bending" of x axis; yzlimits[0] is ignored and assumed to be 0 during simulation - unsigned int flags; // see enum constrflags - float damping; // internal constraint damping - float sensorRadius; // used for sampling environment and re-attaching the constraint when something breaks - float maxPullForce, maxBendTorque; // positional and rotational force limits - IPhysicalEntity* pConstraintEntity; // used internally for creating dynamic rope constraints -}; - -struct pe_action_update_constraint - : pe_action -{ - enum entype - { - type_id = ePE_action_update_constraint - }; - pe_action_update_constraint() - { - type = type_id; - MARK_UNUSED idConstraint, pt[0], pt[1], qframe[0], qframe[1], maxPullForce, maxBendTorque, damping; - flagsOR = 0; - flagsAND = (unsigned int)-1; - bRemove = 0; - flags = world_frames; - } - int idConstraint; // doesn't have to be unique - can update several constraints with one id; if not set, updates all constraints - unsigned int flagsOR; - unsigned int flagsAND; - int bRemove; // permanently delete the constraint - Vec3 pt[2]; // local_frames_part is not supported currently - quaternionf qframe[2]; // update to constraint frames - float maxPullForce, maxBendTorque; - float damping; - int flags; // generally it's better to use flagsOR and/or flagsAND -}; - -struct pe_action_register_coll_event - : pe_action -{ - // this can be used to ask an entity to post a fake collision event to the log - enum entype - { - type_id = ePE_action_register_coll_event - }; - pe_action_register_coll_event() { type = type_id; MARK_UNUSED vSelf; } - - Vec3 pt; // collision point - Vec3 n; // collision normal - Vec3 v; // collider's velocity at pt - Vec3 vSelf; // optional override for the current entity's velocity at pt - float collMass; // collider's mass - IPhysicalEntity* pCollider; // collider entity - int partid[2]; - int idmat[2]; - short iPrim[2]; -}; - -struct pe_action_awake - : pe_action -{ - enum entype - { - type_id = ePE_action_awake - }; - pe_action_awake() { type = type_id; bAwake = 1; MARK_UNUSED minAwakeTime; } - int bAwake; - float minAwakeTime; // minimum time to stay awake after executing the action; supported only by some entity types -}; - -struct pe_action_remove_all_parts - : pe_action -{ - enum entype - { - type_id = ePE_action_remove_all_parts - }; - pe_action_remove_all_parts() { type = type_id; } -}; - -struct pe_action_reset_part_mtx - : pe_action -{ - // this will bake the part's matrix into the entity's matrix and clear the former - enum entype - { - type_id = ePE_action_reset_part_mtx - }; - pe_action_reset_part_mtx() { type = type_id; MARK_UNUSED ipart, partid; } - int ipart; - int partid; -}; - -struct pe_action_set_velocity - : pe_action -{ - enum entype - { - type_id = ePE_action_set_velocity - }; - pe_action_set_velocity() { type = type_id; MARK_UNUSED ipart, partid, v, w; bRotationAroundPivot = 0; } - int ipart; // if part is not set, vel is applied to the whole entity; the distinction makes sense only for ragdolls - int partid; - Vec3 v, w; - int bRotationAroundPivot; // if set, w is rotation around the entity's pivot, otherwise around its center of mass - - VALIDATORS_START - VALIDATOR_RANGE2(v, 0, 1E5f) - VALIDATOR_RANGE2(w, 0, 1E5f) - VALIDATORS_END -}; - -struct pe_action_notify - : pe_action -{ - enum entype - { - type_id = ePE_action_notify - }; - enum encodes - { - ParentChange = 0 - }; // the entity this one is attached to moved; only ropes handle it ATM, by immediately enforcing length - pe_action_notify() { type = type_id; iCode = ParentChange; } - int iCode; -}; - -struct pe_action_auto_part_detachment - : pe_action -{ - // this is used to PE_ARTICULATED entities with pre-baked physics simulation - enum entype - { - type_id = ePE_action_auto_part_detachment - }; - pe_action_auto_part_detachment() { type = type_id; MARK_UNUSED threshold, autoDetachmentDist; } - float threshold; // each part will receive a breakable joint with this force limit (which is assumed to be set in fractions of gravity) - float autoDetachmentDist; // additionally, a part will auto-detach itself once it's farther than that from the entity's pivot -}; - -struct pe_action_move_parts - : pe_action -{ - // this will move parts from one entity to another - enum entype - { - type_id = ePE_action_move_parts - }; - int idStart, idEnd; - int idOffset; // added once parts are in the new entity - IPhysicalEntity* pTarget; - Matrix34 mtxRel; // mtxInNewEntity = mtxRel*mtxCurrent - pe_action_move_parts() { type = type_id; idStart = 0; idEnd = 1 << 30; idOffset = 0; mtxRel.SetIdentity(); pTarget = 0; } -}; - -struct pe_action_batch_parts_update - : pe_action -{ - // updates positions of all parts from arrays - enum entype - { - type_id = ePE_action_batch_parts_update - }; - pe_action_batch_parts_update() { type = type_id; qOffs.SetIdentity(); posOffs.zero(); numParts = 0; pnumParts = 0; pIds = 0; pValidator = 0; } - int* pIds; - strided_pointer qParts; - strided_pointer posParts; - int numParts; - int* pnumParts; - quaternionf qOffs; // extra rotation - Vec3 posOffs; // extra offset - struct Validator - { - virtual ~Validator() {} - virtual bool Lock() = 0; - virtual void Unlock() = 0; - }* pValidator; -}; - -struct pe_action_slice - : pe_action -{ - // slices entity's geometry with a shape - enum entype - { - type_id = ePE_action_slice - }; - pe_action_slice() { type = type_id; MARK_UNUSED ipart, partid; npt = 3; } - int ipart; - int partid; - Vec3* pt; - int npt; // only 3 is supported currently -}; - -////////// living entity actions - -struct pe_action_move - : pe_action // movement request for living entities -{ - enum entype - { - type_id = ePE_action_move - }; - pe_action_move() { type = type_id; iJump = 0; dt = 0; MARK_UNUSED dir; } - - Vec3 dir; // requested velocity vector - int iJump; // jump mode - 1-instant velocity change, 2-just adds to current velocity - float dt; // time interval for this action (doesn't need to be set normally) - - VALIDATORS_START - VALIDATOR_RANGE2(dir, 0, 1000) - VALIDATOR_RANGE(dt, 0, 2) - VALIDATORS_END -}; - -struct pe_action_syncliving - : pe_action // syncing living entity physics -{ - enum entype - { - type_id = pPE_action_syncliving - }; - pe_action_syncliving() { type = type_id; pos.zero(); vel.zero(); velRequested.zero(); } - Vec3 pos; - Vec3 vel; - Vec3 velRequested; -}; - -////////// vehicle entity actions - -struct pe_action_drive - : pe_action -{ - enum entype - { - type_id = ePE_action_drive - }; - pe_action_drive() { type = type_id; MARK_UNUSED pedal, dpedal, steer, dsteer, bHandBrake, clutch, iGear; ackermanOffset = 0.f; } - - float pedal; // engine pedal absolute value; active pedal always awakes the entity - float dpedal; // engine pedal delta - float steer; // steering angle absolute value - float ackermanOffset; // apply ackerman steering, 0.0 -> normal driving front wheels steer, back fixed. 1.0 -> front fixed, back steer. 0.5 -> both front and back steer - float dsteer; // steering angle delta - float clutch; // forces clutch; 0..1 - int bHandBrake; // removing handbrake will automatically awaken the vehicle if it's sleeping - int iGear; // 0-back; 1-neutral; 2+-forward -}; - -////////// rope entity actions - -struct pe_action_target_vtx - : pe_action -{ - enum entype - { - type_id = ePE_action_target_vtx - }; - pe_action_target_vtx() { type = type_id; MARK_UNUSED points, nPoints; posHost.zero(); qHost.SetIdentity(); } - - int nPoints; - Vec3* points; // coordinate frame is world, unless the rope has one of rope_target_vtx_rel flags - Vec3 posHost; // world position of the host the vertices are attached to - Quat qHost; -}; - -////////// soft entity actions - -struct pe_action_attach_points - : pe_action -{ - enum entype - { - type_id = ePE_action_attach_points - }; - pe_action_attach_points() { type = type_id; MARK_UNUSED partid, points; nPoints = 1; pEntity = WORLD_ENTITY; bLocal = 0; } - - IPhysicalEntity* pEntity; - int partid; - int* piVtx; // vertex indices to be attached to pEntity.partid - Vec3* points; // can set the desired attachment points; if not set, current positions are fixed in the target's frame - int nPoints; - int bLocal; // if true, points are in the attached part's CS -}; - -////////////////////////// Status structures ///////////////////// - -////////// common statuses -struct pe_status -{ - int type; -}; - -enum status_pos_flags -{ - status_local = 1, status_thread_safe = 2, status_addref_geoms = 4 -}; - -struct pe_status_pos - : pe_status -{ - enum entype - { - type_id = ePE_status_pos - }; - pe_status_pos() { type = type_id; ipart = partid = -1; flags = 0; pMtx3x4 = 0; pMtx3x3 = 0; iSimClass = 0; timeBack = 0; } - - int partid; // part identifier, -1 for entire entity - int ipart; // optionally, part slot index - unsigned int flags; // status_local if part coordinates should be returned in entity CS rather than world CS - unsigned int flagsOR; // boolean OR for all parts flags of the object (or just flags for the selected part) - unsigned int flagsAND; // boolean AND for all parts flags of the object (or just flags for the selected part) - Vec3 pos; // position of center - Vec3 BBox[2]; // bounding box relative to pos (bbox[0]-min, bbox[1]-max) - quaternionf q; - float scale; - int iSimClass; - Matrix34* pMtx3x4; // optional 3x4 transformation matrix - Matrix33* pMtx3x3; // optional 3x3 rotation+scale matrix - IGeometry* pGeom, * pGeomProxy; - float timeBack; // can retrieve previous position; only supported by rigid entities; pos and q; one step back -}; - -// Only works when USE_IMPROVED_RIGID_ENTITY_SYNCHRONISATION is 1 -struct pe_status_netpos - : pe_status -{ - enum entype - { - type_id = ePE_status_netpos - }; - pe_status_netpos() { type = type_id; } - - Vec3 pos; - quaternionf rot; - Vec3 vel; - Vec3 angvel; - float timeOffset; -}; - -struct pe_status_extent - : pe_status // Caches eForm extent of entity in pGeo -{ - enum entype - { - type_id = ePE_status_extent - }; - pe_status_extent() { type = type_id; eForm = EGeomForm(-1); extent = 0; } - - EGeomForm eForm; - float extent; -}; - -struct pe_status_random - : pe_status_extent // Generates random pos on entity, also caches extent -{ - enum entype - { - type_id = ePE_status_random - }; - pe_status_random() { type = type_id; ran.vPos.zero(); ran.vNorm.zero(); } - PosNorm ran; -}; - -struct pe_status_sensors - : pe_status // Requests status of attached to the entity sensors -{ - enum entype - { - type_id = ePE_status_sensors - }; - pe_status_sensors() { type = type_id; } - - Vec3* pPoints; // pointer to array of points where sensors touch environment (assigned by physical entity) - Vec3* pNormals; // pointer to array of surface normals at points where sensors touch environment - unsigned int flags; // bitmask of flags, bit==1 - sensor touched environment -}; - -struct pe_status_dynamics - : pe_status -{ - enum entype - { - type_id = ePE_status_dynamics - }; - pe_status_dynamics() - : v(ZERO) - , w(ZERO) - , a(ZERO) - , wa(ZERO) - , centerOfMass(ZERO) - { - MARK_UNUSED partid, ipart; - type = type_id; - mass = energy = 0; - nContacts = 0; - time_interval = 0; - submergedFraction = 0; - } - - int partid; - int ipart; - Vec3 v; // velocity - Vec3 w; // angular velocity - Vec3 a; // linear acceleration - Vec3 wa; // angular acceleration - Vec3 centerOfMass; - float submergedFraction; // percentage of the entity that is underwater; 0..1. not supported for individual parts - float mass; // entity's or part's mass - float energy; // kinetic energy; only supported by PE_ARTICULATED currently - int nContacts; - float time_interval; // not used -}; - -struct coll_history_item -{ - Vec3 pt; // collision area center - Vec3 n; // collision normal in entity CS - Vec3 v[2]; // velocities of contacting bodies at the point of impact - float mass[2]; // masses of contacting bodies - float age; // age of collision event - int idCollider; // id of collider (not a pointer, since collider can be destroyed before history item is queried) - int partid[2]; - int idmat[2]; // 0-this body material, 1-collider material -}; - -struct pe_status_collisions - : pe_status -{ - // obsolete, replaced with EventPhysCollision events - enum entype - { - type_id = ePE_status_collisions - }; - pe_status_collisions() { type = type_id; age = 0; len = 1; pHistory = 0; bClearHistory = 0; } - - coll_history_item* pHistory; // pointer to a user-provided array of history items - int len; // length of this array - float age; // maximum age of collision events (older events are ignored) - int bClearHistory; -}; - -struct pe_status_id - : pe_status -{ - // retrives surface id from geometry - enum entype - { - type_id = ePE_status_id - }; - pe_status_id() { type = type_id; ipart = partid = -1; bUseProxy = 1; } - - int ipart; - int partid; - int iPrim; // primitive index (only makes sense for meshes) - int iFeature; // feature id inside the primitive; doesn't affect the result currently - int bUseProxy; // use pPhysGeomProxy or pPhysGeom - int id; // surface id -}; - -struct pe_status_timeslices - : pe_status -{ - // only implemented for PE_LIVING and is obsolete, although still supported - enum entype - { - type_id = ePE_status_timeslices - }; - pe_status_timeslices() { type = type_id; pTimeSlices = 0; sz = 1; precision = 0.0001f; MARK_UNUSED time_interval; } - - float* pTimeSlices; - int sz; - float precision; // time surplus below this threshhold will be discarded - float time_interval; // if unused, time elapsed since the last action will be used -}; - -struct pe_status_nparts - : pe_status // GetStuts will return the number of parts -{ - enum entype - { - type_id = ePE_status_nparts - }; - pe_status_nparts() { type = type_id; } -}; - -struct pe_status_awake - : pe_status -{ - enum entype - { - type_id = ePE_status_awake - }; - pe_status_awake() { type = type_id; lag = 0; } - int lag; // GetStatus returns 1 ("awake") if the entity fell asleep later than this amount of frames before -}; - -struct pe_status_contains_point - : pe_status -{ - enum entype - { - type_id = ePE_status_contains_point - }; - pe_status_contains_point() { type = type_id; } - Vec3 pt; -}; - -struct pe_status_placeholder - : pe_status -{ - enum entype - { - type_id = ePE_status_placeholder - }; - pe_status_placeholder() { type = type_id; } - IPhysicalEntity* pFullEntity; // if called on a placeholder, returns the corresponding full entity -}; - -struct pe_status_sample_contact_area - : pe_status -{ - enum entype - { - type_id = ePE_status_sample_contact_area - }; - pe_status_sample_contact_area() { type = type_id; } - Vec3 ptTest; // checks if ptTest, projected along dirTest falls inside the convex hull of this entity's contacts - Vec3 dirTest; -}; - -struct pe_status_caps - : pe_status -{ - enum entype - { - type_id = ePE_status_caps - }; - pe_status_caps() { type = type_id; } - unsigned int bCanAlterOrientation; // the entity can change orientation that is explicitly set from outside (by baking it into parts/geometries) -}; - -struct pe_status_constraint - : pe_status -{ - enum entype - { - type_id = ePE_status_constraint - }; - pe_status_constraint() { type = type_id; idx = -1; } - int id; - int idx; - int flags; - Vec3 pt[2]; - Vec3 n; - IPhysicalEntity* pBuddyEntity; - IPhysicalEntity* pConstraintEntity; -}; - -////////// area status - -struct pe_status_area - : pe_status -{ - enum entype - { - type_id = ePE_status_area - }; - pe_status_area() { type = type_id; bUniformOnly = false; ctr.zero(); size.zero(); vel.zero(); MARK_UNUSED gravity; pLockUpdate = 0; pSurface = 0; } - - // inputs. - Vec3 ctr, size; // query bounds - Vec3 vel; - bool bUniformOnly; - - // outputs. - Vec3 gravity; - pe_params_buoyancy pb; - volatile int* pLockUpdate; - IGeometry* pSurface; -}; - -////////// living entity statuses - -struct pe_status_living - : pe_status -{ - enum entype - { - type_id = ePE_status_living - }; - pe_status_living() { type = type_id; } - - int bFlying; // whether entity has no contact with ground - float timeFlying; // for how long the entity was flying - Vec3 camOffset; // camera offset - Vec3 vel; // actual velocity (as rate of position change) - Vec3 velUnconstrained; // 'physical' movement velocity - Vec3 velRequested; // velocity requested in the last action - Vec3 velGround; // velocity of the object entity is standing on - float groundHeight; // position where the last contact with the ground occured - Vec3 groundSlope; - int groundSurfaceIdx; - int groundSurfaceIdxAux; // contact with the ground that also has default collision flags - IPhysicalEntity* pGroundCollider; // only returns an actual entity if the ground collider is not static - int iGroundColliderPart; - float timeSinceStanceChange; - //int bOnStairs; // tries to detect repeated abrupt ground height changes - int bStuck; // tries to detect cases when the entity cannot move as before because of collisions - volatile int* pLockStep; // internal timestepping lock - int iCurTime; // quantised time - int bSquashed; // entity is being pushed by heavy objects from opposite directions -}; - -struct pe_status_check_stance - : pe_status -{ - // checks whether new dimensions cause collisions; params have the same meaning as in pe_player_dimensions - enum entype - { - type_id = ePE_status_check_stance - }; - pe_status_check_stance() - : dirUnproj(0, 0, 1) - , unproj(0) { type = type_id; MARK_UNUSED pos, q, sizeCollider, heightCollider, bUseCapsule; } - - Vec3 pos; - quaternionf q; - Vec3 sizeCollider; - float heightCollider; - Vec3 dirUnproj; - float unproj; - int bUseCapsule; -}; - -////////// vehicle entity statuses - -struct pe_status_vehicle - : pe_status -{ - enum entype - { - type_id = ePE_status_vehicle - }; - pe_status_vehicle() { type = type_id; } - - float steer; // current steering angle - float pedal; // current engine pedal - int bHandBrake; // nonzero if handbrake is on - float footbrake; // nonzero if footbrake is pressed (range 0..1) - Vec3 vel; - int bWheelContact; // nonzero if at least one wheel touches ground - int iCurGear; - float engineRPM; - float clutch; - float drivingTorque; - int nActiveColliders; // number of non-static contacting entities -}; - -struct pe_status_wheel - : pe_status -{ - enum entype - { - type_id = ePE_status_wheel - }; - pe_status_wheel() { type = type_id; iWheel = 0; MARK_UNUSED partid; } - int iWheel; - int partid; - - int bContact; // nonzero if wheel touches ground - Vec3 ptContact; // point where wheel touches ground - Vec3 normContact; // contact normal - float w; // rotation speed - int bSlip; - Vec3 velSlip; // slip velocity - int contactSurfaceIdx; - float friction; // current friction applied - float suspLen; // current suspension spring length - float suspLenFull; // relaxed suspension spring length - float suspLen0; // initial suspension spring length - float r; // wheel radius - float torque; // driving torque - float steer; // current streeing angle - IPhysicalEntity* pCollider; -}; - -struct pe_status_vehicle_abilities - : pe_status -{ - enum entype - { - type_id = ePE_status_vehicle_abilities - }; - pe_status_vehicle_abilities() { type = type_id; MARK_UNUSED steer; } - - float steer; // should be set to requested steering angle - Vec3 rotPivot; // returns turning circle center - float maxVelocity; // calculates maximum velocity of forward movement along a plane (steer is ignored) -}; - -////////// articulated entity statuses - -struct pe_status_joint - : pe_status -{ - enum entype - { - type_id = ePE_status_joint - }; - pe_status_joint() { type = type_id; MARK_UNUSED partid, idChildBody; } - - int idChildBody; // requested joint is identified by child body id - int partid; // ..or, alternatively, by any of parts that belong to it - unsigned int flags; // joint flags - Ang3 q; // current joint angles (controlled by physics) - Ang3 qext; // external angles (from animation) - Ang3 dq; // current joint angular velocities - quaternionf quat0; // orientation of child inside parent that corresponds to 0 angles -}; - -////////// rope entity statuses - -struct pe_status_rope - : pe_status -{ - enum entype - { - type_id = ePE_status_rope - }; - pe_status_rope() - : pContactEnts(0) - { - type = type_id; - pPoints = pVelocities = pVtx = pContactNorms = 0; - nCollStat = nCollDyn = bTargetPoseActive = bStrained = 0; - stiffnessAnim = timeLastActive = 0; - nVtx = 0; - lock = 0; - } - - int nSegments; - Vec3* pPoints; // expects the caller to provide an array of nSegments+1, if 0, no points are returned - Vec3* pVelocities; // expects the caller to provide an array of nSegments+1, if 0, no velocities are returned - int nCollStat, nCollDyn; // number of rope contacts with static and dynamic objects - int bTargetPoseActive; // current traget pose mode (0, 1, or 2) - float stiffnessAnim; // current target pose stiffness - int bStrained; // whether the rope is strained, either along a line or wrapped around objects - strided_pointer pContactEnts; // returns a pointer to internal data, the caller doesn't need to provide it - int nVtx; // current number of vertices, used for ropes with dynamic subdivision - Vec3* pVtx; // expects the caller to provide the array - Vec3* pContactNorms; // normals for points (not vertices), expects a pointer from the caller - float timeLastActive; // physics time when the rope was last active (not asleep) - Vec3 posHost; // host (the entity part it's attached to) position that corresponds to the returned state - quaternionf qHost; // host's orientation - int lock; // for subdivided ropes: +1 to leave read-locked, -1 to release from a previously read-locked state; 0 - local locking only -}; - -////////// soft entity statuses - -enum ESSVFlags -{ - eSSV_LockPos = 1, // locks vertices (soft entity won't be able to update them until released) - eSSV_UnlockPos = 2 // release the vertices -}; - -struct pe_status_softvtx - : pe_status -{ - enum entype - { - type_id = ePE_status_softvtx - }; - pe_status_softvtx() - : pVtx(0) - , pNormals(0) { type = type_id; pVtxMap = 0; flags = 0; } - - int nVtx; - strided_pointer pVtx; // a pointer to an internal data; doesn't need to be filled - strided_pointer pNormals; // a pointer to an internal data; doesn't need to be filled - int* pVtxMap; // mapping table mesh vertex->simulated vertex (can be 0) - IGeometry* pMesh; // phys mesh that reflects the simulated data - int flags; // see ESSVFlags - quaternionf qHost; // host's orientation - Vec3 posHost; // host (the entity part it's attached to) position that corresponds to the returned state - Vec3 pos; // entity position that corresponds to the returned state - quaternionf q; // entity's orientation -}; - -////////// waterman statuses - -struct SWaterTileBase -{ - int bActive; - float* ph; // heights - Vec3* pvel; // velocities -}; - -struct pe_status_waterman - : pe_status -{ - enum entype - { - type_id = ePE_status_waterman - }; - pe_status_waterman() { type = type_id; } - - int bActive; - Matrix33 R; - Vec3 origin; - int nTiles, nCells; // number of tiles and cells in one dimension - SWaterTileBase** pTiles; // nTiles^2 entries -}; - -////////////////////////// Geometry structures ///////////////////// - -////////// common geometries -enum geom_flags -{ - // collisions between parts are checked if (part0->flagsCollider & part1->flags) !=0 - geom_colltype0 = 0x0001, geom_colltype1 = 0x0002, geom_colltype2 = 0x0004, geom_colltype3 = 0x0008, geom_colltype4 = 0x0010, - geom_colltype5 = 0x0020, geom_colltype6 = 0x0040, geom_colltype7 = 0x0080, geom_colltype8 = 0x0100, geom_colltype9 = 0x0200, - geom_colltype10 = 0x0400, geom_colltype11 = 0x0800, geom_colltype12 = 0x1000, geom_colltype13 = 0x2000, geom_colltype14 = 0x4000, - geom_colltype_ray = 0x8000, // special colltype used by raytracing by default - geom_floats = 0x10000, // colltype required to apply buoyancy - geom_proxy = 0x20000, // only used in AddGeometry to specify that this geometry should go to pPhysGeomProxy - geom_structure_changes = 0x40000, // part is breaking/deforming - geom_can_modify = 0x80000, // geometry is cloned and is used in this entity only - geom_squashy = 0x100000, // part has 'soft' collisions (used for tree foliage proxy) - geom_log_interactions = 0x200000, // part will post EventPhysBBoxOverlap whenever something happens inside its bbox - geom_monitor_contacts = 0x400000, // part needs collision callback from the solver (used internally) - geom_manually_breakable = 0x800000, // part is breakable outside the physics - geom_no_coll_response = 0x1000000, // collisions are detected and reported, but not processed - geom_mat_substitutor = 0x2000000, // geometry is used to change other collision's material id if the collision point is inside it - geom_break_approximation = 0x4000000, // applies capsule approximation after breaking (used for tree trunks) - geom_no_particle_impulse = 0x8000000, // phys particles don't apply impulses to this part; should be used in flagsCollider - geom_destroyed_on_break = 0x2000000, // should be used in flagsCollider - // mnemonic group names - geom_colltype_player = geom_colltype1, geom_colltype_explosion = geom_colltype2, - geom_colltype_vehicle = geom_colltype3, geom_colltype_foliage = geom_colltype4, geom_colltype_debris = geom_colltype5, - geom_colltype_foliage_proxy = geom_colltype13, geom_colltype_obstruct = geom_colltype14, - geom_colltype_solid = 0x0FFF & ~geom_colltype_explosion, geom_collides = 0xFFFF -}; - - - -struct pe_geomparams -{ - enum entype - { - type_id = ePE_geomparams - }; - pe_geomparams() - { - type = type_id; - density = mass = 0; - pos.Set(0, 0, 0); - q.SetIdentity(); - bRecalcBBox = 1; - flags = geom_colltype_solid | geom_colltype_ray | geom_floats | geom_colltype_explosion; - flagsCollider = geom_colltype0; - pMtx3x4 = 0; - pMtx3x3 = 0; - scale = 1.0f; - pLattice = 0; - pMatMapping = 0; - nMats = 0; - MARK_UNUSED surface_idx, minContactDist, idmatBreakable; - } - - int type; - float density; // 0 if mass is used - float mass; // 0 if density is used - Vec3 pos; // offset from object's geometrical pivot - quaternionf q; // orientation relative to object - float scale; - Matrix34* pMtx3x4; // optional full transform matrix - Matrix33* pMtx3x3; // optional 3x3 orintation+scale matrix - int surface_idx; // surface identifier (used if corresponding CGeometry does not contain materials) - unsigned int flags, flagsCollider; - float minContactDist; // contacts closer then this threshold are merged - int idmatBreakable; // index for procedural (boolean) breakability - ITetrLattice* pLattice; // optional tetrahedral lattice (for lattice breaking and soft bodies) - int* pMatMapping; // mapping of mat ids from geometry to final mat ids - int nMats; - int bRecalcBBox; // recalculate all bbox info after the part is added - - VALIDATORS_START - VALIDATOR_RANGE(density, -1E8, 1E8) - VALIDATOR_RANGE(mass, -1E8, 1E8) - VALIDATOR(pos) - VALIDATOR_NORM_MSG(q, "(perhaps non-uniform scaling was used in the asset?)", pt) - VALIDATORS_END -}; - -////////// articulated entity geometries - -struct pe_articgeomparams - : pe_geomparams -{ - enum entype - { - type_id = ePE_articgeomparams - }; - pe_articgeomparams() { type = type_id; idbody = 0; } - pe_articgeomparams(pe_geomparams& src) - { - type = type_id; - density = src.density; - mass = src.mass; - pos = src.pos; - q = src.q; - scale = src.scale; - surface_idx = src.surface_idx; - pLattice = src.pLattice; - pMatMapping = src.pMatMapping; - nMats = src.nMats; - pMtx3x4 = src.pMtx3x4; - pMtx3x3 = src.pMtx3x3; - flags = src.flags; - flagsCollider = src.flagsCollider; - idbody = 0; - idmatBreakable = src.idmatBreakable; - bRecalcBBox = src.bRecalcBBox; - if (!is_unused(src.minContactDist)) - { - minContactDist = src.minContactDist; - } - else - { - MARK_UNUSED minContactDist; - } - } - int idbody; // id of the subbody this geometry is attached to, the 1st add geometry specifies frame CS of this subbody -}; - -////////// vehicle entity geometries - -const int NMAXWHEELS = 30; -struct pe_cargeomparams - : pe_geomparams -{ - enum entype - { - type_id = ePE_cargeomparams - }; - pe_cargeomparams() - : pe_geomparams() { type = type_id; MARK_UNUSED bDriving, minFriction, maxFriction, bRayCast, kLatFriction; bCanBrake = 1; bCanSteer = 1; kStiffnessWeight = 1.f; } - pe_cargeomparams(pe_geomparams& src) - { - type = type_id; - density = src.density; - mass = src.mass; - pos = src.pos; - q = src.q; - surface_idx = src.surface_idx; - idmatBreakable = src.idmatBreakable; - pLattice = src.pLattice; - pMatMapping = src.pMatMapping; - nMats = src.nMats; - pMtx3x4 = src.pMtx3x4; - pMtx3x3 = src.pMtx3x3; - flags = src.flags; - flagsCollider = src.flagsCollider; - MARK_UNUSED bDriving, minFriction, maxFriction, bRayCast; - bCanBrake = 1, bCanSteer = 1; - kStiffnessWeight = 1.f; - } - int bDriving; // whether wheel is driving, -1 - geometry os not a wheel - int iAxle; // wheel axle, currently not used - int bCanBrake; // whether the wheel is locked during handbrakes - int bRayCast; // whether the wheel use simple raycasting instead of geometry sweep check - int bCanSteer; // wheel the wheel can steer - Vec3 pivot; // upper suspension point in vehicle CS - float lenMax; // relaxed suspension length - float lenInitial; // current suspension length (assumed to be length in rest state) - float kStiffness; // suspension stiffness, if 0 - calculate from lenMax, lenInitial, and vehicle mass and geometry - float kStiffnessWeight; // When autocalculating stiffness use this weight for this wheel. Note weights for wheels in front of the centre of mass do not influence the weights of wheels behind the centre of mass - float kDamping; // suspension damping, if <0 - calculate as -kdamping*(approximate zero oscillations damping) - float minFriction, maxFriction; // additional friction limits for tire friction - float kLatFriction; // coefficient for lateral friction -}; - -///////////////// tetrahedra lattice params //////////////////////// - -struct pe_tetrlattice_params - : pe_params -{ - enum entype - { - type_id = ePE_tetrlattice_params - }; - pe_tetrlattice_params() - { - type = type_id; - MARK_UNUSED nMaxCracks, maxForcePush, maxForcePull, maxForceShift, maxTorqueTwist, maxTorqueBend, crackWeaken, density; - } - - int nMaxCracks; // maximum cracks per update - float maxForcePush, maxForcePull, maxForceShift; // linear force limits - float maxTorqueTwist, maxTorqueBend; // angular force limits - float crackWeaken; // weakens faces neighbouring a newly generated crack (0..1) - float density; // also affects all force limits -}; - -///////////////////////////////////////////////////////////////////////////////////// -//////////////////////////// IGeometry Interface //////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////// - -struct geom_world_data // geometry orientation for Intersect() requests -{ - geom_world_data() - { - v.Set(0, 0, 0); - w.Set(0, 0, 0); - offset.Set(0, 0, 0); - R.SetIdentity(); - centerOfMass.Set(0, 0, 0); - scale = 1.0f; - iStartNode = 0; - } - Vec3 offset; - Matrix33 R; - float scale; - Vec3 v, w; // used to give hints about unprojection direction - Vec3 centerOfMass; // w is rotation around this point - int iStartNode; // for warm-starting (checks collisions in this node first) -}; - -struct intersection_params -{ - intersection_params() - { - iUnprojectionMode = 0; - vrel_min = 1E-6f; - time_interval = 100.0f; - maxSurfaceGapAngle = 1.0f * float(g_PI / 180); - pGlobalContacts = 0; - minAxisDist = 0; - bSweepTest = false; - centerOfRotation.Set(0, 0, 0); - axisContactNormal.Set(0, 0, 1); - unprojectionPlaneNormal.Set(0, 0, 0); - axisOfRotation.Set(0, 0, 0); - bKeepPrevContacts = false; - bStopAtFirstTri = false; - ptOutsidePivot[0].Set(1E11f, 1E11f, 1E11f); - ptOutsidePivot[1].Set(1E11f, 1E11f, 1E11f); - maxUnproj = 1E10f; - bNoAreaContacts = false; - bNoBorder = false; - bNoIntersection = 0; - bExactBorder = 0; - bThreadSafe = bThreadSafeMesh = 0; - } - int iUnprojectionMode; // 0-angular, 1-rotational - Vec3 centerOfRotation; // for mode 1 only - Vec3 axisOfRotation; // if left 0, will be set based on collision area normal - float time_interval; // used to set unprojection limits - float vrel_min; // if local relative velocity in contact area is above this, unprojects along its derection; otherwise along area normal - float maxSurfaceGapAngle; // theshold for generating area contacts - float minAxisDist; // disables rotational unprojection if contact point is closer than this to the axis - Vec3 unprojectionPlaneNormal; // restrict linear unprojection to this plane - Vec3 axisContactNormal; // a mild hint about possible contact normal - float maxUnproj; // unprojections longer than this are discarded - Vec3 ptOutsidePivot[2]; // discard contacts that are not facing outward wrt this point - bool bSweepTest; // requests a linear sweep test along v*time_interval (v from geom_world_data) - bool bKeepPrevContacts; // append results to existing contact buffer - bool bStopAtFirstTri; // stop after the first collision is detected - bool bNoAreaContacts; // don't try to detect contact areas - bool bNoBorder; // don't trace contact border - int bExactBorder; // always tries to return a consequtive border (useful for boolean ops) - int bNoIntersection; // don't find all intersection points (only applies to primitive-primitive collisions) - int bBothConvex; // (output) both operands were convex - int bThreadSafe; // set if it's known that no other thread will contend for the internal intersection data (only used in PrimitiveWorldIntersection now) - int bThreadSafeMesh; // set if it's known that no other thread will try to modify the colliding geometry - geom_contact* pGlobalContacts; // pointer to thread's global contact buffer -}; - -struct phys_geometry -{ - IGeometry* pGeom; - Vec3 Ibody; // tensor of inertia in body frame - quaternionf q; // body frame - Vec3 origin; - float V; // volume - int nRefCount; - int surface_idx; // used for primitives and meshes without per-face ids - int* pMatMapping; // mat mapping; can later be overridden inside entity part - int nMats; - PhysicsForeignData pForeignData; // any external pointer to be associated with phys geometry -}; - -struct bop_newvtx -{ - int idx; // vertex index in the resulting A phys mesh - int iBvtx; // -1 if intersection vertex, >=0 if B vertex - int idxTri[2]; // intersecting triangles' foreign indices -}; - -struct bop_newtri -{ - int idxNew; // a newly generated foreign index (can be remapped later) - int iop; // triangle source 0=A, 1=B - int idxOrg; // original (triangulated) triangle's foreign index - int iVtx[3]; // for each vertex, existing vertex index if >=0, -(new vertex index+1) if <0 - float areaOrg; // original triangle's area - Vec3 area[3]; // areas of compementary triangles for each vertex (divide by original tri area to get barycentric coords) -}; - -struct bop_vtxweld -{ - void set(int _ivtxDst, int _ivtxWelded) { ivtxDst = _ivtxDst; ivtxWelded = _ivtxWelded; } - int ivtxDst : 16; // ivtxWelded is getting replaced with ivtxDst - int ivtxWelded : 16; -}; - -struct bop_TJfix -{ - void set(int _iACJ, int _iAC, int _iABC, int _iCA, int _iTJvtx) { iACJ = _iACJ; iAC = _iAC; iABC = _iABC; iCA = _iCA; iTJvtx = _iTJvtx; } - // A _____J____ C (ACJ is a thin triangle on top of ABC; J is 'the junction vertex') - // \ . / in ABC: set A->Jnew - // \ . / in ACJ: set J->Jnew, A -> A from original ABC, C -> B from original ABC - // \/ - // B - int iABC; // big triangle's foreign idx - int iACJ; // small triangle's foreign idx - int iCA; // CA edge number in ABC - int iAC; // AC edge number in ACJ - int iTJvtx; // J vertex index -}; - -struct bop_meshupdate_thunk -{ - bop_meshupdate_thunk() { prevRef = nextRef = this; } - virtual ~bop_meshupdate_thunk() { prevRef->nextRef = nextRef; nextRef->prevRef = prevRef; prevRef = nextRef = this; } - bop_meshupdate_thunk* prevRef, * nextRef; -}; - -struct bop_meshupdate - : bop_meshupdate_thunk -{ - bop_meshupdate() { Reset(); } - virtual ~bop_meshupdate(); - - void Reset() - { - pRemovedVtx = 0; - pRemovedTri = 0; - pNewVtx = 0; - pNewTri = 0; - pWeldedVtx = 0; - pTJFixes = 0; - pMovedBoxes = 0; - nRemovedVtx = nRemovedTri = nNewVtx = nNewTri = nWeldedVtx = nTJFixes = nMovedBoxes = 0; - next = 0; - pMesh[0] = pMesh[1] = 0; - relScale = 1.0f; - } - - IGeometry* pMesh[2]; // 0-dst (A), 1-src (B) - int* pRemovedVtx; - int nRemovedVtx; - int* pRemovedTri; - int nRemovedTri; - bop_newvtx* pNewVtx; - int nNewVtx; - bop_newtri* pNewTri; - int nNewTri; - bop_vtxweld* pWeldedVtx; - int nWeldedVtx; - bop_TJfix* pTJFixes; - int nTJFixes; - bop_meshupdate* next; - primitives::box* pMovedBoxes; - int nMovedBoxes; - float relScale; -}; - -struct trinfo -{ - trinfo& operator=(trinfo& src) { ibuddy[0] = src.ibuddy[0]; ibuddy[1] = src.ibuddy[1]; ibuddy[2] = src.ibuddy[2]; return *this; } - index_t ibuddy[3]; -}; - -struct mesh_island // mesh island is a connected group of trinagles -{ - int itri; // first triangle - int nTris; // trinagle count - int iParent; // outer island is V<0 - int iChild; // first islands inside it with V<0 - int iNext; // maintains a linked list of iChild's inside iParent - float V; // can be negative (means it represents an inner surface) - Vec3 center; // geometrical center - int bProcessed; // for internal use -}; - -struct tri2isle // maintains a linked triangle list inside an island -{ - unsigned int inext : 16; - unsigned int isle : 15; - unsigned int bFree : 1; -}; - -struct mesh_data - : primitives::primitive -{ - index_t* pIndices; - char* pMats; - int* pForeignIdx; // an int associated with each face - strided_pointer pVertices; - Vec3* pNormals; - int* pVtxMap; // original vertex index->merged vertex index - trinfo* pTopology; // neighbours for each triangle's edge - int nTris, nVertices; - mesh_island* pIslands; - int nIslands; - tri2isle* pTri2Island; - int flags; -}; - -const int BOP_NEWIDX0 = 0x8000000; - -enum geomtypes -{ - GEOM_TRIMESH = primitives::triangle::type, GEOM_HEIGHTFIELD = primitives::heightfield::type, GEOM_CYLINDER = primitives::cylinder::type, - GEOM_CAPSULE = primitives::capsule::type, GEOM_RAY = primitives::ray::type, GEOM_SPHERE = primitives::sphere::type, - GEOM_BOX = primitives::box::type, GEOM_VOXELGRID = primitives::voxelgrid::type -}; -enum foreigntypes -{ - DATA_OWNED_OBJECT = 1, DATA_MESHUPDATE = -1, DATA_UNUSED = -2 -}; - -enum meshflags -{ - // mesh_shared_... flags mean that the mesh will not attempt to free the corresponding array upon deletion - mesh_shared_vtx = 1, mesh_shared_idx = 2, mesh_shared_mats = 4, mesh_shared_foreign_idx = 8, mesh_shared_normals = 0x10, - // bounding volume flags (if several are specified in CreateMesh(), the best fitting one will be used) - mesh_OBB = 0x20, mesh_AABB = 0x40, mesh_SingleBB = 0x80, mesh_AABB_rotated = 0x40000, mesh_VoxelGrid = 0x80000, - // mesh_multicontact is a hint on how many contacts per node to expect; 0-one contact, 2-no limit, 1-balanced - mesh_multicontact0 = 0x100, mesh_multicontact1 = 0x200, mesh_multicontact2 = 0x400, - // mesh_approx flags are used in CreateMesh to specify which primitive approximations to try - mesh_approx_cylinder = 0x800, mesh_approx_box = 0x1000, mesh_approx_sphere = 0x2000, mesh_approx_capsule = 0x200000, - mesh_keep_vtxmap = 0x8000, // keeps vertex map after adjacent vertices were merged - mesh_keep_vtxmap_for_saving = 0x10000, // deletes vertex map after loading - mesh_no_vtx_merge = 0x20000, // does not attempt to merge adjacent vertices - mesh_always_static = 0x100000, // simplifies phys mass properties calculation if by just setting them to 0 - mesh_full_serialization = 0x400000, // mesh will save all data to stream unconditionally - mesh_transient = 0x800000, // all mesh allocations will go to a flushable pool - mesh_no_booleans = 0x1000000, // disables boolean operations on the mesh - mesh_AABB_plane_optimise = 0x4000, // aabb generation is faster since it assumes the tri's are in a plane and distributed uniformly - mesh_no_filter = 0x2000000 // doesn't attempt to filter away degenerate triangles -}; -enum meshAuxData -{ - mesh_data_materials = 1, mesh_data_foreign_idx = 2, mesh_data_vtxmap = 4 -}; // used in DestroyAuxiliaryMeshData - -struct IOwnedObject -{ - // - virtual ~IOwnedObject(){} - virtual int Release() = 0; - // -}; - -struct SOcclusionCubeMap; - -struct IGeometry -{ - struct SBoxificationParams - { - SBoxificationParams() { minFaceArea = sqr(0.4f); distFilter = 0.2f; voxResolution = 100; maxFaceTiltAngle = DEG2RAD(10); minLayerFilling = 0.5f; maxLayerReusage = 0.8f; maxVoxIslandConnections = 0.5f; } - float minFaceArea; // ignore patches smaller than this in the box growing process - float distFilter; // smooth away details smaller than this (in terms of linear size) - int voxResolution; // resolution of the grid in the longest direction - float maxFaceTiltAngle; // tolerance for patch alignment with box faces - float minLayerFilling; // stop growing boxes once layer fill percentage falls below this - float maxLayerReusage; // stop growing a box if it goes through already used cells (> than this percentage) - float maxVoxIslandConnections; // ignore isolated voxel islands that have more than this amount of connections to the used ones - }; - // - virtual ~IGeometry(){} - virtual int GetType() = 0; // see enum geomtypes - virtual int AddRef() = 0; - virtual void Release() = 0; - virtual void Lock(int bWrite = 1) = 0; // locks the geometry for reading or writing - virtual void Unlock(int bWrite = 1) = 0; // bWrite should match the preceding Lock - virtual void GetBBox(primitives::box* pbox) = 0; // possibly oriented bbox (depends on BV tree type) - virtual int CalcPhysicalProperties(phys_geometry* pgeom) = 0; // O(num_triangles) for meshes, unless mesh_always_static is set - virtual int PointInsideStatus(const Vec3& pt) = 0; // for meshes, will create an auxiliary hashgrid for acceleration - // IntersectLocked - the main function for geomtries. pdata1,pdata2,pparams can be 0 - defaults will be assumed. - // returns a pointer to an internal thread-specific contact buffer, locked with the lock argument - virtual int IntersectLocked(IGeometry* pCollider, geom_world_data* pdata1, geom_world_data* pdata2, intersection_params* pparams, geom_contact*& pcontacts, AZStd::spin_mutex& lock) = 0; - virtual int IntersectLocked(IGeometry* pCollider, geom_world_data* pdata1, geom_world_data* pdata2, intersection_params* pparams, geom_contact*& pcontacts, AZStd::spin_mutex& lock, int iCaller) = 0; - // Intersect - same as Intersect, but doesn't lock pcontacts - virtual int Intersect(IGeometry* pCollider, geom_world_data* pdata1, geom_world_data* pdata2, intersection_params* pparams, geom_contact*& pcontacts) = 0; - // FindClosestPoint - for non-convex meshes only does local search, doesn't guarantee global minimum - // iFeature's format: (feature type: 2-face, 1-edge, 0-vertex)<<9 | feature index - // if ptdst0 and ptdst1 are different, searches for a closest point on a line segment - // ptres[0] is the closest point on the geometry, ptres[1] - on the test line segment - virtual int FindClosestPoint(geom_world_data* pgwd, int& iPrim, int& iFeature, const Vec3& ptdst0, const Vec3& ptdst1, Vec3* ptres, int nMaxIters = 10) = 0; - // CalcVolumetricPressure: a fairly correct computation of volumetric pressure with inverse-quadratic falloff (ex: explosions) - // for a surface fragment dS, impulse is: k*dS*cos(surface_normal,direction to epicenter) / max(rmin, distance to epicenter)^2 - // returns integral impulse and angular impulse - virtual void CalcVolumetricPressure(geom_world_data* gwd, const Vec3& epicenter, float k, float rmin, const Vec3& centerOfMass, Vec3& P, Vec3& L) = 0; - // CalculateBuoyancy: computes the submerged volume (return value) and the mass center of the submerged part - virtual float CalculateBuoyancy(const primitives::plane* pplane, const geom_world_data* pgwd, Vec3& submergedMassCenter) = 0; - // CalculateMediumResistance: computes medium resistance integral of the surface; self flow of the medium should be baked into pgwd - // for a surface fragment dS with normal n and velocity v impulse is: -n*max(0,n*v) (can be scaled by the medium resistance coeff. later) - virtual void CalculateMediumResistance(const primitives::plane* pplane, const geom_world_data* pgwd, Vec3& dPres, Vec3& dLres) = 0; - // DrawWireframe: draws physics helpers; iLevel>0 will draaw a level in the bounding volume tree - virtual void DrawWireframe(IPhysRenderer* pRenderer, geom_world_data* gwd, int iLevel, int idxColor) = 0; - virtual int GetPrimitiveId(int iPrim, int iFeature) = 0; // get material id for a primitive (iFeature is ignored currently) - // GetPrimitive: expects a valid pprim pointer, type depends on GetType; meshes return primitives::triangle - virtual int GetPrimitive(int iPrim, primitives::primitive* pprim) = 0; - virtual int GetForeignIdx(int iPrim) = 0; // only works for meshes - virtual Vec3 GetNormal(int iPrim, const Vec3& pt) = 0; // only implemented for meshes currently; pt is ignored - virtual int GetFeature(int iPrim, int iFeature, Vec3* pt) = 0; // returns vertices of face, edge, or vertex; only for boxes and meshes currently - virtual int IsConvex(float tolerance) = 0; - // PrepareForRayTest: creates an auxiliary hash structure for short rays test acceleration - virtual void PrepareForRayTest(float raylen) = 0; // raylen - 'expected' ray length to optimize the hash for - // BuildOcclusionCubemap: cubemap projection-based occlusion (used for explosions); pGrids are 6 [nRes^2] arrays - // iMode: 0 - update cubemap in pGrid0; 1 - build cubemap in pGrid1, grow edges by nGrow cells, and compare with pGrid0 - // all geometry closer than rmin is ignored (to avoid large projection scale); same if farther than rmax - virtual float BuildOcclusionCubemap(geom_world_data* pgwd, int iMode, SOcclusionCubeMap* cubemap0, SOcclusionCubeMap* cubemap1, int nGrow) = 0; - virtual void GetMemoryStatistics(ICrySizer* pSizer) = 0; - virtual void Save(CMemStream& stm) = 0; - virtual void Load(CMemStream& stm) = 0; - // Load: meshes can avoid storing vertex, index, and mat id data, in this case same arrays should be provided during loading - virtual void Load(CMemStream& stm, strided_pointer pVertices, strided_pointer pIndices, char* pIds) = 0; - virtual int GetPrimitiveCount() = 0; - virtual const primitives::primitive* GetData() = 0; // returns an pointer to an internal structure; for meshes returns mesh_data - virtual void SetData(const primitives::primitive*) = 0; // not supported by meshes - virtual float GetVolume() = 0; - virtual Vec3 GetCenter() = 0; - // Subtract: performs boolean subtraction; if bLogUpdates==1, will create bop_meshupdate inside the mesh - virtual int Subtract(IGeometry* pGeom, geom_world_data* pdata1, geom_world_data* pdata2, int bLogUpdates = 1) = 0; - virtual int GetSubtractionsCount() = 0; // number of Subtract()s the mesh has survived so far - // GetForeignData: returns a pointer associated with the geometry - // special: GetForeignData(DATA_MESHUPDATE) returns the internal bop_meshupdate list (does not interfere with the main foreign pointer) - virtual PhysicsForeignData GetForeignData(int iForeignData = 0) = 0; - virtual int GetiForeignData() = 0; // foreign data type - virtual void SetForeignData(PhysicsForeignData pForeignData, int iForeignData) = 0; - virtual int GetErrorCount() = 0; // for meshes, the number of edges that don't belong to exactly 2 triangles - virtual void DestroyAuxilaryMeshData(int idata) = 0; // see meshAuxData enum - virtual void RemapForeignIdx(int* pCurForeignIdx, int* pNewForeignIdx, int nTris) = 0; // used in rendermesh-physics sync after boolean ops - virtual void AppendVertices(Vec3* pVtx, int* pVtxMap, int nVtx) = 0; // used in rendermesh-physics sync after boolean ops - virtual float GetExtent(EGeomForm eForm) const = 0; - virtual void GetRandomPos(PosNorm& ran, EGeomForm eForm) const = 0; - virtual void CompactMemory() = 0; // used only by non-breakable meshes to compact non-shared vertices into same contingous block of memory - // Boxify: attempts to build a set of boxes covering the geometry's volume (only supported by trimeshes) - virtual int Boxify(primitives::box* pboxes, int nMaxBoxes, const SBoxificationParams& params) = 0; - // Sanity check the geometry. i.e. its tree doesn't have an excessive depth. returns 0 if fails - virtual int SanityCheck() = 0; - // -}; - - -///////////////////////////////////////////////////////////////////////////////////// -//////////////////////////// IGeometryManager Interface ///////////////////////////// -///////////////////////////////////////////////////////////////////////////////////// - -struct SMeshBVParams {}; - -struct SBVTreeParams - : SMeshBVParams -{ - int nMinTrisPerNode; // if a split creates a node with - virtual ~ITetrLattice(){} - virtual int SetParams(const pe_params*) = 0; // only accepts pe_tetrlattice_params - virtual int GetParams(pe_params*) = 0; - virtual void DrawWireframe(IPhysRenderer* pRenderer, geom_world_data* gwd, int idxColor) = 0; - virtual IGeometry* CreateSkinMesh(int nMaxTrisPerBVNode = 8) = 0; // builds triangle mesh for exterior faces - virtual int CheckPoint(const Vec3& pt, int* idx, float* w) = 0; // check if a point is inside any tetrahedron, fills barycentric weights[4] - virtual void Release() = 0; - // -}; - -struct IBreakableGrid2d -{ - // - virtual ~IBreakableGrid2d(){} - // BreakIntoChunks: emulates fracure in the grid around pt with dimensions r x ry - // ptout receives a pointer to a vertex array - // return value is an allocated array of indices, 3 per triangle, -1 marks contour end, -2 array end - // maxPatchTris tells to unite broken trianges into patches of up to this size; 0 means broken triangles are discarded - // jointhresh (0..1) affects the way triangles unite into patches - // seed bootsraps the RNG if >=0 - // hole edges are filtered to removes corners sharper than filterAng (except those that are formed by several joined triangles) - virtual int* BreakIntoChunks(const vector2df& pt, float r, vector2df*& ptout, int maxPatchTris, float jointhresh, int seed = -1, float filterAng = 0.0f, float ry = 0.0f) = 0; - virtual primitives::grid* GetGridData() = 0; - virtual bool IsEmpty() = 0; - virtual void Release() = 0; - virtual float GetFracture() = 0; // destroyed percentage so far - virtual void GetMemoryStatistics(ICrySizer* pSizer) const = 0; - // -}; - - -struct IGeomManager -{ - // - virtual ~IGeomManager(){} - virtual void InitGeoman() = 0; - virtual void ShutDownGeoman() = 0; - - // CreateMesh - depending on flags (see enum meshflags) can create either a mesh or a primitive that approximates - // approx_tolerance is the approximation tolerance in relative units - // pMats are per-face material ids (which can later be mapped via pMatMapping) - // pForeignIdx store any user data per face (internally indices might be sorted when building BV structure, pForegnIdx will reflect that) - virtual IGeometry* CreateMesh(strided_pointer pVertices, strided_pointer pIndices, char* pMats, int* pForeignIdx, int nTris, int flags, float approx_tolerance = 0.05f, int nMinTrisPerNode = 2, int nMaxTrisPerNode = 4, float favorAABB = 1.0f) = 0; - virtual IGeometry* CreateMesh(strided_pointer pVertices, strided_pointer pIndices, char* pMats, int* pForeignIdx, int nTris, int flags, float approx_tolerance, SMeshBVParams* pParams) = 0; // this version can take SVoxGridParams in pParams, if mesh_VoxelGrid is set - virtual IGeometry* CreatePrimitive(int type, const primitives::primitive* pprim) = 0; // used to create primitives explicitly - virtual void DestroyGeometry(IGeometry* pGeom) = 0; // just calls Release() on pGeom - - // RegisterGeometry: creates a phys_geometry structure for IGeometry, computes mass properties - // phys_geometries are managed in pools internally; the new structure has nRefCount 1 - // defSurfaceIdx will be used (until overwritten in entity part) if the geometry doesn't have per-face materials - virtual phys_geometry* RegisterGeometry(IGeometry* pGeom, int defSurfaceIdx = 0, int* pMatMapping = 0, int nMats = 0) = 0; - virtual int AddRefGeometry(phys_geometry* pgeom) = 0; - virtual int UnregisterGeometry(phys_geometry* pgeom) = 0; // decreases nRefCount, frees the pool slot if <=0 - virtual void SetGeomMatMapping(phys_geometry* pgeom, int* pMatMapping, int nMats) = 0; - - virtual void SaveGeometry(CMemStream& stm, IGeometry* pGeom) = 0; - virtual IGeometry* LoadGeometry(CMemStream& stm, strided_pointer pVertices, strided_pointer pIndices, char* pMats) = 0; - virtual void SavePhysGeometry(CMemStream& stm, phys_geometry* pgeom) = 0; - virtual phys_geometry* LoadPhysGeometry(CMemStream& stm, strided_pointer pVertices, strided_pointer pIndices, char* pIds) = 0; - virtual IGeometry* CloneGeometry(IGeometry* pGeom) = 0; - - virtual ITetrLattice* CreateTetrLattice(const Vec3* pt, int npt, const int* pTets, int nTets) = 0; - // RegisterCrack: cracks are used for ITertLattice-induced breaking to subtract a shape whenever a tetrahedral face breaks - // pVtx specify 3 control vertices; when applying, they are affinely stretched to match the broken face's corners - // idmat is breakability index - virtual int RegisterCrack(IGeometry* pGeom, Vec3* pVtx, int idmat) = 0; - virtual void UnregisterCrack(int id) = 0; - virtual void UnregisterAllCracks(void (* OnRemoveGeom)(IGeometry* pGeom) = 0) = 0; - // GetCrackGeom - creates a stretched crack based on the three corner vertices (pt[3]) - // pgwd receives it world transformation - virtual IGeometry* GetCrackGeom(const Vec3* pt, int idmat, geom_world_data* pgwd) = 0; - - // GenerateBreakebleGrid - creates a perturbed regular grid of points - // ptsrc's bbox is split into a nCells grid (with an additional border) - // vertices are randomly perturbed up to 0.4 cell size (seed can bootstrap the randomizer) - // ptsrc is "painted" into the grid, snapping the closest grid vertices to ptsrc (but no new ones are created at this stage) - // bStatic is ignored currently - virtual IBreakableGrid2d* GenerateBreakableGrid(vector2df* ptsrc, int npt, const vector2di& nCells, int bStatic = 1, int seed = -1) = 0; - - virtual void ReleaseGeomsImmediately(bool bReleaseImmediately) = 0; - // -}; - - -///////////////////////////////////////////////////////////////////////////////////// -////////////////////////////// IPhysUtils Interface ///////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////// - -typedef void* (* qhullmalloc)(size_t); - -struct IPhysUtils -{ - // - virtual ~IPhysUtils(){} - // CoverPolygonWithCircles - attempts to fits circles to roughly cover a polygon (can used to generate round spalshes over an area) - // bConsecutive is false, uses convex hull of the points - // center is a pre-calculated geometrical center of pt's - // outputs data into centers and radii arrays, which use global buffers; returns the number of circles - virtual int CoverPolygonWithCircles(strided_pointer pt, int npt, bool bConsecutive, const vector2df& center, vector2df*& centers, float*& radii, float minCircleRadius) = 0; - virtual int qhull(strided_pointer pts, int npts, index_t*& pTris, qhullmalloc qmalloc = 0) = 0; - virtual void DeletePointer(void* pdata) = 0; // should be used to free data allocated in physics - virtual int TriangulatePoly(vector2df* pVtx, int nVtx, int* pTris, int szTriBuf) = 0; - // -}; - -///////////////////////////////////////////////////////////////////////////////////// -//////////////////////////// IPhysicalEntity Interface ////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////// - -enum snapshot_flags -{ - ssf_compensate_time_diff = 1, ssf_checksum_only = 2, ssf_no_update = 4 -}; - -struct IPhysicalEntity -{ - // - virtual ~IPhysicalEntity(){} - virtual pe_type GetType() const = 0; // returns pe_type - - virtual int AddRef() = 0; - virtual int Release() = 0; - - // SetParams - changes parameters; can be queued and executed later if the physics is busy (unless bThreadSafe is flagged) - // returns !0 if successful - virtual int SetParams(const pe_params* params, int bThreadSafe = 0) = 0; - virtual int GetParams(pe_params* params) const = 0; // uses the same structures as SetParams; returns !0 if successful - virtual int GetStatus(pe_status* status) const = 0; // generally returns >0 if successful, but some pe_status'es have special meaning - virtual int Action(const pe_action*, int bThreadSafe = 0) = 0; // like SetParams, can get queued - - // AddGeometry - add a new entity part, containing pgeom; request can get queued - // params can be specialized depending on the entity type - // id is a requested geometry id (expected to be unique), if -1 - assign automatically - // returns geometry id (0..some number), -1 means error - virtual int AddGeometry(phys_geometry* pgeom, pe_geomparams* params, int id = -1, int bThreadSafe = 0) = 0; - virtual void RemoveGeometry(int id, int bThreadSafe = 0) = 0; // returns !0 if successful; can get queued - - virtual PhysicsForeignData GetForeignData(int itype = 0) const = 0; // returns entity's pForeignData if itype matches iForeignData, 0 otherwise - virtual int GetiForeignData() const = 0; // returns entity's iForegnData - - virtual int GetStateSnapshot(class CStream& stm, float time_back = 0, int flags = 0) = 0; // obsolete, was used in Far Cry - virtual int GetStateSnapshot(TSerialize ser, float time_back = 0, int flags = 0) = 0; - virtual int SetStateFromSnapshot(class CStream& stm, int flags = 0) = 0; // obsolete - virtual int PostSetStateFromSnapshot() = 0; // obsolete - virtual unsigned int GetStateChecksum() = 0; // obsolete - virtual void SetNetworkAuthority(int authoritive = -1, int paused = -1) = 0; // -1 dont change, 0 - set to false, 1 - set to true - - virtual int SetStateFromSnapshot(TSerialize ser, int flags = 0) = 0; - virtual int SetStateFromTypedSnapshot(TSerialize ser, int type, int flags = 0) = 0; - virtual int GetStateSnapshotTxt(char* txtbuf, int szbuf, float time_back = 0) = 0; // packs state into ASCII text - virtual void SetStateFromSnapshotTxt(const char* txtbuf, int szbuf) = 0; - - // DoStep: evolves entity in time. Normally this is called from PhysicalWorld::TimeStep - virtual int DoStep(float time_interval) = 0; - virtual int DoStep(float time_interval, int iCaller) = 0; - virtual void StartStep(float time_interval) = 0; // must be called before DoStep - virtual void StepBack(float time_interval) = 0; - - virtual void GetMemoryStatistics(ICrySizer* pSizer) const = 0; - // -}; - - -///////////////////////////////////////////////////////////////////////////////////// -//////////////////////////// IPhysicsEventClient Interface ////////////////////////// -///////////////////////////////////////////////////////////////////////////////////// - -struct IPhysicsEventClient // obsolete, replaced with event system (EventPhys...) -{ // - virtual ~IPhysicsEventClient(){} - virtual void OnBBoxOverlap(IPhysicalEntity* pEntity, PhysicsForeignData pForeignData, int iForeignData, IPhysicalEntity* pCollider, void* pColliderForeignData, int iColliderForeignData) = 0; - virtual void OnStateChange(IPhysicalEntity* pEntity, PhysicsForeignData pForeignData, int iForeignData, int iOldSimClass, int iNewSimClass) = 0; - virtual void OnCollision(IPhysicalEntity* pEntity, PhysicsForeignData pForeignData, int iForeignData, coll_history_item* pCollision) = 0; - virtual int OnImpulse(IPhysicalEntity* pEntity, PhysicsForeignData pForeignData, int iForeignData, pe_action_impulse* impulse) = 0; - virtual void OnPostStep(IPhysicalEntity* pEntity, PhysicsForeignData pForeignData, int iForeignData, float dt) = 0; - // -}; - -///////////////////////////////////////////////////////////////////////////////////// -///////////////////////////// IPhysicalWorld Interface ////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////// - -enum draw_helper_flags -{ - pe_helper_collisions = 1, pe_helper_geometry = 2, pe_helper_bbox = 4, pe_helper_lattice = 8 -}; -enum surface_flags -{ - sf_pierceable_mask = 0x0F, sf_max_pierceable = 0x0F, sf_important = 0x200, sf_manually_breakable = 0x400, sf_matbreakable_bit = 16 -}; -#define sf_pierceability(i) (i) -#define sf_matbreakable(i) (((i) + 1) << sf_matbreakable_bit) -enum rwi_flags // see RayWorldIntersection -{ - rwi_ignore_terrain_holes = 0x20, rwi_ignore_noncolliding = 0x40, rwi_ignore_back_faces = 0x80, rwi_ignore_solid_back_faces = 0x100, - rwi_pierceability_mask = 0x0F, rwi_pierceability0 = 0, rwi_stop_at_pierceable = 0x0F, - rwi_separate_important_hits = sf_important, // among pierceble hits, materials with sf_important will have priority - rwi_colltype_bit = 16, // used to manually specify collision geometry types (default is geom_colltype_ray) - rwi_colltype_any = 0x400, // if several colltype flag are specified, switches between requiring all or any of them in a geometry - rwi_queue = 0x800, // queues the RWI request, when done it'll generate EventPhysRWIResult - rwi_force_pierceable_noncoll = 0x1000, // non-colliding geometries will be treated as pierceable regardless of the actual material - rwi_update_last_hit = 0x4000, // update phitLast with the current hit results (should be set if the last hit should be reused for a "warm" start) - rwi_any_hit = 0x8000 // returns the first found hit for meshes, not necessarily the closets -}; -#define rwi_pierceability(pty) (pty) -#define rwi_colltype_all(colltypes) ((colltypes) << rwi_colltype_bit) -#define rwi_colltype_any(colltypes) ((colltypes) << rwi_colltype_bit | rwi_colltype_any) -enum entity_query_flags // see GetEntitiesInBox and RayWorldIntersection -{ - ent_static = 1, ent_sleeping_rigid = 2, ent_rigid = 4, ent_living = 8, ent_independent = 16, ent_deleted = 128, ent_terrain = 0x100, - ent_all = ent_static | ent_sleeping_rigid | ent_rigid | ent_living | ent_independent | ent_terrain, - ent_flagged_only = pef_update, ent_skip_flagged = pef_update * 2, // "flagged" meas has pef_update set - ent_areas = 32, ent_triggers = 64, - ent_ignore_noncolliding = 0x10000, - ent_sort_by_mass = 0x20000, // sort by mass in ascending order - ent_allocate_list = 0x40000, // if not set, the function will return an internal pointer - ent_addref_results = 0x100000, // will call AddRef on each entity in the list (expecting the caller call Release) - ent_water = 0x200, // can only be used in RayWorldIntersection - ent_no_ondemand_activation = 0x80000, // can only be used in RayWorldIntersection - ent_delayed_deformations = 0x80000 // queues procedural breakage requests; can only be used in SimulateExplosion -}; -enum phys_locks -{ - PLOCK_WORLD_STEP = 1, PLOCK_CALLER0, PLOCK_CALLER1, PLOCK_QUEUE, PLOCK_AREAS -}; - -struct phys_profile_info -{ - IPhysicalEntity* pEntity; - int nTicks, nCalls; - int nTicksLast, nCallsLast; - int nTicksAvg; - float nCallsAvg; - int nTicksPeak, nCallsPeak, peakAge; - int nTicksStep; - int id; - const char* pName; -}; - -struct phys_job_info -{ - int jobType; - int nInvocations; - int nFallbacks; - int64 nTicks, nLatency, nLatencyAbs; - int64 nTicksPeak, nLatencyPeak, nLatencyAbsPeak, peakAge; - const char* pName; -}; - -struct SolverSettings -{ - int nMaxStackSizeMC; // def 8 - float maxMassRatioMC; // def 50 - int nMaxMCiters; // def 1400 - int nMinMCiters; // def 4 - int nMaxMCitersHopeless; // def 400 - float accuracyMC; // def 0.005 - float accuracyLCPCG; // def 0.005 - int nMaxContacts; // def 150 - int nMaxPlaneContacts; // def 7 - int nMaxPlaneContactsDistress; // def 4 - int nMaxLCPCGsubiters; // def 120 - int nMaxLCPCGsubitersFinal; // def 250 - int nMaxLCPCGmicroiters; - int nMaxLCPCGmicroitersFinal; - int nMaxLCPCGiters; // def 5 - float minLCPCGimprovement; // def 0.1 - int nMaxLCPCGFruitlessIters; // def 4 - float accuracyLCPCGnoimprovement; // def 0.05 - float minSeparationSpeed; // def 0.02 - float maxvCG; - float maxwCG; - float maxvUnproj; - int bCGUnprojVel; - float maxMCMassRatio; - float maxMCVel; - int maxLCPCGContacts; -}; - -enum entity_out_of_bounds_flags -{ - raycast_out_of_bounds = 1, // Affects ray casts. NB, ray casting out of bounds entities can cause performance issues - get_entities_out_of_bounds = 2, // Affects GetEntitiesAround. -}; - -struct PhysicsVars - : SolverSettings -{ - int bFlyMode; - int iCollisionMode; - int bSingleStepMode; - int bDoStep; - float fixedTimestep; - float timeGranularity; - float maxWorldStep; - int iDrawHelpers; - int iOutOfBounds; - float maxContactGap; - float maxContactGapPlayer; - float minBounceSpeed; - int bProhibitUnprojection; - int bUseDistanceContacts; - float unprojVelScale; - float maxUnprojVel; - float maxUnprojVelRope; - int bEnforceContacts; - int nMaxSubsteps; - int nMaxSurfaces; - Vec3 gravity; - int nGroupDamping; - float groupDamping; - int nMaxSubstepsLargeGroup; - int nBodiesLargeGroup; - int bBreakOnValidation; - int bLogActiveObjects; - int bProfileEntities; - int bProfileFunx; - int bProfileGroups; - int nGEBMaxCells; - int nMaxEntityCells; - int nMaxAreaCells; - float maxVel; - float maxVelPlayers; - float maxVelBones; - float maxContactGapSimple; - float penaltyScale; - int bSkipRedundantColldet; - int bLimitSimpleSolverEnergy; - int nMaxEntityContacts; - int bLogLatticeTension; - int nMaxLatticeIters; - int bLogStructureChanges; - float tickBreakable; - float approxCapsLen; - int nMaxApproxCaps; - int bPlayersCanBreak; - float lastTimeStep; - int bMultithreaded; - float breakImpulseScale; - float rtimeGranularity; - float massLimitDebris; - int flagsColliderDebris; - int flagsANDDebris; - int maxRopeColliderSize; - int maxSplashesPerObj; - float splashDist0, minSplashForce0, minSplashVel0; - float splashDist1, minSplashForce1, minSplashVel1; - int bDebugExplosions; - float jointGravityStep; - float jointDmgAccum; - float jointDmgAccumThresh; - float timeScalePlayers; - float threadLag; - int numThreads; - int physCPU; - int physWorkerCPU; - Vec3 helperOffset; - int64 ticksPerSecond; - // net-synchronization related -#if USE_IMPROVED_RIGID_ENTITY_SYNCHRONISATION - float netInterpTime; - float netExtrapMaxTime; - int netSequenceFrequency; - int netDebugDraw; -#else - float netMinSnapDist; - float netVelSnapMul; - float netMinSnapDot; - float netAngSnapMul; - float netSmoothTime; -#endif - - int bEntGridUseOBB; - int nStartupOverloadChecks; - float breakageMinAxisInertia; // For procedural breaking, each axis must have a minium inertia compared to the axis with the largest inertia (0.01-1.00) - - int bForceSyncPhysics; -}; - -struct ray_hit -{ - float dist; - IPhysicalEntity* pCollider; - int ipart; - int partid; - short surface_idx; - short idmatOrg; // original material index, not mapped with material mapping - int foreignIdx; - int iNode; // BV tree node that had the intersection; can be used for "warm start" next time - Vec3 pt; - Vec3 n; // surface normal - int bTerrain; // global terrain hit - int iPrim; // hit triangle index - ray_hit* next; // reserved for internal use, do not change -}; - -struct ray_hit_cached // used in conjunction with rwi_reuse_last_hit -{ - ray_hit_cached() { pCollider = 0; ipart = 0; } - ray_hit_cached(const ray_hit& hit) { pCollider = hit.pCollider; ipart = hit.ipart; iNode = hit.iNode; } - ray_hit_cached& operator=(const ray_hit& hit) { pCollider = hit.pCollider; ipart = hit.ipart; iNode = hit.iNode; return *this; } - - IPhysicalEntity* pCollider; - int ipart; - int iNode; -}; - -#ifndef PWI_NAME_TAG -#define PWI_NAME_TAG "PrimitiveWorldIntersection" -#endif -#ifndef RWI_NAME_TAG -#define RWI_NAME_TAG "RayWorldIntersection" -#endif - -struct pe_explosion // see SimulateExplosion -{ - pe_explosion() { nOccRes = 0; nGrow = 0; rminOcc = 0.1f; holeSize = 0; explDir.Set(0, 0, 1); iholeType = 0; forceDeformEntities = false; } - Vec3 epicenter; // epicenter for the occlusion computation - Vec3 epicenterImp; // epicenter for impulse computation - // the impulse a surface fragment with area dS and normal n gets is: dS*k*n*max(0,n*dir_to_epicenter)/max(rmin, dist_to_epicenter)^2 - // k is selected in such way that at impulsivePressureAtR = k/r^2 - float rmin, rmax, r; - float impulsivePressureAtR; - int nOccRes; // resolution of the occlusion map (0 disables) - int nGrow; // grow occlusion projections by this amount of cells to allow explosion to reach around corners a bit - float rminOcc; // ignores geometry closer than this for occlusion computations - float holeSize; // explosion shape for iholeType will be scaled by this holeSize / shape's declared size - Vec3 explDir; // hit direction, for aligning the explosion boolean shape - int iholeType; // breakability index for the explosion (<0 disables) - bool forceDeformEntities; // force deformation even if breakImpulseScale is zero - // filled as results - IPhysicalEntity** pAffectedEnts; - float* pAffectedEntsExposure; // 0..1 exposure, computed from the occlusion map - int nAffectedEnts; -}; - -// Physics events can be logged or immediate. The former are posted to the event queue and the client handler is called -// during PumpLoggedEvents function. The latter are call client handlers immediately when they happen, which is likely -// to be inside the physics thread, so the handler must be thread-safe. -// In most cases, in order to generate events the entity must have the corresponding flag set -// Important Note: Please keep event ids contigous in respect to being stereo or mono events -struct EventPhys -{ - EventPhys* next; - int idval; -}; - -struct EventPhysStereo - : EventPhys // base for two-entity events, ids 0-2 -{ - IPhysicalEntity* pEntity[2]; - PhysicsForeignData pForeignData[2]; - int iForeignData[2]; -}; - -struct EventPhysMono - : EventPhys // base for one-entity events, ids 3-16 -{ - IPhysicalEntity* pEntity; - PhysicsForeignData pForeignData; - int iForeignData; -}; - -struct EventPhysBBoxOverlap - : EventPhysStereo // generated by triggers and parts with geom_log_interactions -{ - enum entype - { - id = 0, flagsCall = 0, flagsLog = 0 - }; - EventPhysBBoxOverlap() { idval = id; } -}; - -enum EventPhysCollisionState -{ - EPC_DEFERRED_INITIAL, EPC_DEFERRED_REQUEUE, EPC_DEFERRED_FINISHED -}; - -struct EventPhysCollision - : EventPhysStereo -{ - enum entype - { - id = 2, flagsCall = pef_monitor_collisions, flagsLog = pef_log_collisions - }; - EventPhysCollision() { idval = id; pEntContact = 0; iPrim[0] = iPrim[1] = -1; deferredState = EPC_DEFERRED_INITIAL; fDecalPlacementTestMaxSize = 1000.f; } - int idCollider; // in addition to pEntity[1] - Vec3 pt; // contact point in world coordinates - Vec3 n; // contact normal - Vec3 vloc[2]; // velocities at the contact point - float mass[2]; - int partid[2]; - short idmat[2]; - short iPrim[2]; - float penetration; // contact's penetration depth - float normImpulse; // impulse applied by the solver to resolve the collision - float radius; // some characteristic size of the contact area - void* pEntContact; // reserved for internal use - char deferredState; // EventPhysCollisionState - char deferredResult; // stores the result returned by the deferred event - float fDecalPlacementTestMaxSize; // maximum allowed size of decals caused by this collision -}; - -struct EventPhysStateChange - : EventPhysMono // triggered by simclass changes, even those caused by SetParams -{ - enum entype - { - id = 8, flagsCall = pef_monitor_state_changes, flagsLog = pef_log_state_changes - }; - EventPhysStateChange() { idval = id; } - int iSimClass[2]; - float timeIdle; // how long the entity stayed without external activation (such as impulses) - Vec3 BBoxOld[2]; - Vec3 BBoxNew[2]; -}; - -struct EventPhysEnvChange - : EventPhysMono // called when something around the entityy breaks -{ - enum entype - { - id = 3, flagsCall = pef_monitor_env_changes, flagsLog = pef_log_env_changes - }; - enum encode - { - EntStructureChange = 0 - }; - EventPhysEnvChange() { idval = id; } - int iCode; - IPhysicalEntity* pentSrc; // entity that broke - IPhysicalEntity* pentNew; // new entity that broke off the original one -}; - -struct EventPhysPostStep - : EventPhysMono // entity has just completed its step -{ - enum entype - { - id = 4, flagsCall = pef_monitor_poststep, flagsLog = pef_log_poststep - }; - EventPhysPostStep() { idval = id; } - float dt; - Vec3 pos; - quaternionf q; - int idStep; // world's internal step count -}; - -struct EventPhysUpdateMesh - : EventPhysMono // physics mesh changed -{ - enum entype - { - id = 5, flagsCall = 1, flagsLog = 2 - }; - enum reason - { - ReasonExplosion, ReasonFracture, ReasonRequest, ReasonDeform - }; - EventPhysUpdateMesh() { idval = id; idx = -1; pMesh = 0; } - int partid; - int bInvalid; - int iReason; // see enum reason - IGeometry* pMesh; // ->GetForeignData(DATA_MESHUPDATE) returns a list of bop_meshupdates - bop_meshupdate* pLastUpdate; // the last mesh update for at moment when the event was generated - Matrix34 mtxSkelToMesh; // skeleton's frame -> mesh's frame transform - IGeometry* pMeshSkel; // for deformable bodies - int idx; // used for event deferring by listeners -}; - -struct EventPhysCreateEntityPart - : EventPhysMono // a part broke off an existing entity -{ - enum entype - { - id = 6, flagsCall = 1, flagsLog = 2 - }; - enum reason - { - ReasonMeshSplit, ReasonJointsBroken - }; - EventPhysCreateEntityPart() { idval = id; idx = -1; } - IPhysicalEntity* pEntNew; // new physical entity (has type PE_RIGID) - int partidSrc; // original part id - int partidNew; // part id assigned to it in the new entity - int nTotParts; // total number of parts that broke off during this update (each will have its own event) - int bInvalid; // generated mesh was invalid (degenerate or flipped) - int iReason; - Vec3 breakImpulse; // impulse that initiated the breaking - Vec3 breakAngImpulse; - Vec3 v; // initial vel of ejected product - Vec3 w; // initial ang vel of ejected product - float breakSize; // if caused by an explosion, the explosion's rmin - float cutRadius; // if updated mesh was successfully approximated with capsules, this is their cross section at the point of breakage - Vec3 cutPtLoc[2]; // the cut's center in both entities' frames - Vec3 cutDirLoc[2]; // the cut area's normal - IGeometry* pMeshNew; // new mesh if was caused by boolean breaking, 0 if by joint breaking (i.e. no new mesh was created) - bop_meshupdate* pLastUpdate; // last meshupdate for the moment the event was reported - int idx; // used for event deferring by listeners -}; - -struct EventPhysRemoveEntityParts - : EventPhysMono -{ - enum entype - { - id = 7, flagsCall = 1, flagsLog = 2 - }; - EventPhysRemoveEntityParts() { idval = id; idOffs = 0; } - unsigned int partIds[4]; // remove parts with ids corresponding to the set bits in partIds[], +idOffs - int idOffs; - float massOrg; // entity's mass before the parts were removed -}; - -struct EventPhysRevealEntityPart - : EventPhysMono -{ - enum entype - { - id = 13, flagsCall = 1, flagsLog = 2 - }; - EventPhysRevealEntityPart() { idval = id; } - int partId; // id of a part that was hidden due to hierarchical breakability, but should be revealed now -}; - -struct EventPhysJointBroken - : EventPhysStereo -{ - enum entype - { - id = 1, flagsCall = 1, flagsLog = 2 - }; - EventPhysJointBroken() { idval = id; } - int idJoint; - int bJoint; // structural joint if 1, dynamics constraint if 0 - int partidEpicenter; // the "seed" part during the update - Vec3 pt; // joint's position in the entity frame - Vec3 n; // joint's z axis - int partid[2]; - int partmat[2]; // material id from the parts' first primitive - IPhysicalEntity* pNewEntity[2]; // only set for broken constraints -}; - -struct EventPhysRWIResult - : EventPhysMono -{ - enum entype - { - id = 9, flagsCall = 0, flagsLog = 0 - }; - EventPhysRWIResult() { idval = id; } - int (* OnEvent)(const EventPhysRWIResult*); - ray_hit* pHits; - int nHits, nMaxHits; - int bHitsFromPool; // 1 if hits reside in the internal physics hits pool -}; - -struct EventPhysPWIResult - : EventPhysMono -{ - enum entype - { - id = 10, flagsCall = 0, flagsLog = 0 - }; - EventPhysPWIResult() { idval = id; } - int (* OnEvent)(const EventPhysPWIResult*); - float dist; - Vec3 pt; - Vec3 n; - int idxMat; - int partId; -}; - -struct EventPhysArea - : EventPhysMono // for callback phys areas -{ - enum entype - { - id = 11, flagsCall = 0, flagsLog = 0 - }; - EventPhysArea() { idval = id; } - - Vec3 pt; // entity's center - Vec3 ptref; // for splines - closest point on spline to pt; for normal areas - area's world position - Vec3 dirref; // for splines, calculated force direction - pe_params_buoyancy pb; // can be filled by the caller - Vec3 gravity; // can be filled by the caller - IPhysicalEntity* pent; // the entity that entered the area and caused this event -}; - -struct EventPhysAreaChange - : EventPhysMono -{ - enum entype - { - id = 12, flagsCall = 0, flagsLog = 0 - }; - EventPhysAreaChange() { idval = id; pContainer = 0; } - - Vec3 boxAffected[2]; - quaternion q; - Vec3 pos; - float depth; - IPhysicalEntity* pContainer; - quaternion qContainer; - Vec3 posContainer; -}; - -struct EventPhysEntityDeleted - : EventPhysMono -{ - enum entype - { - id = 14, flagsCall = 0, flagsLog = 0 - }; - EventPhysEntityDeleted() { idval = id; } - int mode; -}; - -struct EventPhysPostPump - : EventPhys -{ - enum entype - { - id = 15, flagsCall = 0, flagsLog = 0 - }; - EventPhysPostPump() { idval = id; } -}; - -const int EVENT_TYPES_NUM = 16; - -// Physical entity iterator interface. This interface is used to traverse trough all the physical entities in an physical world. In a way, -// this iterator works a lot like a stl iterator. -struct IPhysicalEntityIt -{ - // - virtual ~IPhysicalEntityIt(){} - virtual void AddRef() = 0; - virtual void Release() = 0; // Deletes this iterator and frees any memory it might have allocated. - - virtual bool IsEnd() = 0; // Check whether current iterator position is the end position. - virtual IPhysicalEntity* Next() = 0; // returns the entity that the iterator points to before it goes to the next - virtual IPhysicalEntity* This() = 0; // returns the entity that the iterator points to - virtual void MoveFirst() = 0; // positions the iterator at the begining of the entity list - // -}; - - - -#endif // CRYINCLUDE_CRYCOMMON_PHYSINTERFACE_H diff --git a/Code/Legacy/CryCommon/platform_impl.cpp b/Code/Legacy/CryCommon/platform_impl.cpp index 168b5fd253..d61bfe6ee4 100644 --- a/Code/Legacy/CryCommon/platform_impl.cpp +++ b/Code/Legacy/CryCommon/platform_impl.cpp @@ -18,6 +18,7 @@ #include #include + // Section dictionary #if defined(AZ_RESTRICTED_PLATFORM) #define PLATFORM_IMPL_H_SECTION_TRAITS 1 diff --git a/Code/Legacy/CrySystem/AZCoreLogSink.h b/Code/Legacy/CrySystem/AZCoreLogSink.h index d9e815841c..e824c4c172 100644 --- a/Code/Legacy/CrySystem/AZCoreLogSink.h +++ b/Code/Legacy/CrySystem/AZCoreLogSink.h @@ -51,10 +51,10 @@ public: static bool IsCryLogReady() { - static bool hasSetCVar = false; bool ready = gEnv && gEnv->pSystem && gEnv->pLog; #ifdef _RELEASE + static bool hasSetCVar = false; if(!hasSetCVar && ready) { // AZ logging only has a concept of 3 levels (error, warning, info) but cry logging has 4 levels (..., messaging). If info level is set, we'll turn on messaging as well diff --git a/Code/Legacy/CrySystem/CMakeLists.txt b/Code/Legacy/CrySystem/CMakeLists.txt index 57e33c4cc0..9e1cf92267 100644 --- a/Code/Legacy/CrySystem/CMakeLists.txt +++ b/Code/Legacy/CrySystem/CMakeLists.txt @@ -6,6 +6,8 @@ # # +ly_get_list_relative_pal_filename(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME}) + add_subdirectory(XML) ly_add_target( @@ -13,9 +15,13 @@ ly_add_target( NAMESPACE Legacy FILES_CMAKE crysystem_files.cmake + ${pal_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake # Required for restricted platforms + PLATFORM_INCLUDE_FILES + ${pal_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}.cmake # Required for restricted platforms INCLUDE_DIRECTORIES PUBLIC . + ${pal_dir} # Required for restricted platforms BUILD_DEPENDENCIES PRIVATE 3rdParty::expat diff --git a/Code/Legacy/CrySystem/CrySystem_precompiled.h b/Code/Legacy/CrySystem/CrySystem_precompiled.h index daf1c335e4..79fbbd92be 100644 --- a/Code/Legacy/CrySystem/CrySystem_precompiled.h +++ b/Code/Legacy/CrySystem/CrySystem_precompiled.h @@ -99,7 +99,6 @@ inline int RoundToClosestMB(size_t memSize) #include #include #include -#include #include #include #include diff --git a/Code/Legacy/CrySystem/DebugCallStack.cpp b/Code/Legacy/CrySystem/DebugCallStack.cpp index cdfc5de21e..bea6c8c035 100644 --- a/Code/Legacy/CrySystem/DebugCallStack.cpp +++ b/Code/Legacy/CrySystem/DebugCallStack.cpp @@ -284,7 +284,7 @@ int DebugCallStack::handleException(EXCEPTION_POINTERS* exception_pointer) char excAddr[80]; WriteLineToLog(""); sprintf_s(excAddr, "0x%04X:0x%p", exception_pointer->ContextRecord->SegCs, exception_pointer->ExceptionRecord->ExceptionAddress); - sprintf_s(excCode, "0x%08X", exception_pointer->ExceptionRecord->ExceptionCode); + sprintf_s(excCode, "0x%08lX", exception_pointer->ExceptionRecord->ExceptionCode); WriteLineToLog("Exception: %s, at Address: %s", excCode, excAddr); } @@ -445,7 +445,7 @@ void DebugCallStack::LogExceptionInfo(EXCEPTION_POINTERS* pex) else { sprintf_s(excAddr, "0x%04X:0x%p", pex->ContextRecord->SegCs, pex->ExceptionRecord->ExceptionAddress); - sprintf_s(excCode, "0x%08X", pex->ExceptionRecord->ExceptionCode); + sprintf_s(excCode, "0x%08lX", pex->ExceptionRecord->ExceptionCode); excName = TranslateExceptionCode(pex->ExceptionRecord->ExceptionCode); azstrcpy(desc, AZ_ARRAY_SIZE(desc), ""); sprintf_s(excDesc, "%s\r\n%s", excName, desc); diff --git a/Code/Legacy/CrySystem/LevelSystem/LevelSystem.cpp b/Code/Legacy/CrySystem/LevelSystem/LevelSystem.cpp index bb2f36e69c..fe87c3f784 100644 --- a/Code/Legacy/CrySystem/LevelSystem/LevelSystem.cpp +++ b/Code/Legacy/CrySystem/LevelSystem/LevelSystem.cpp @@ -16,6 +16,7 @@ #include "CryPath.h" #include +#include #include #include @@ -45,8 +46,6 @@ void CLevelInfo::GetMemoryUsage(ICrySizer* pSizer) const ////////////////////////////////////////////////////////////////////////// bool CLevelInfo::OpenLevelPak() { - LOADING_TIME_PROFILE_SECTION; - bool usePrefabSystemForLevels = false; AzFramework::ApplicationRequests::Bus::BroadcastResult( usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemForLevelsEnabled); @@ -69,8 +68,6 @@ bool CLevelInfo::OpenLevelPak() ////////////////////////////////////////////////////////////////////////// void CLevelInfo::CloseLevelPak() { - LOADING_TIME_PROFILE_SECTION; - bool usePrefabSystemForLevels = false; AzFramework::ApplicationRequests::Bus::BroadcastResult( usePrefabSystemForLevels, &AzFramework::ApplicationRequests::IsPrefabSystemForLevelsEnabled); @@ -190,7 +187,6 @@ CLevelSystem::CLevelSystem(ISystem* pSystem, const char* levelsFolder) , m_pCurrentLevel(0) , m_pLoadingLevelInfo(0) { - LOADING_TIME_PROFILE_SECTION; CRY_ASSERT(pSystem); //if (!gEnv->IsEditor()) @@ -297,8 +293,6 @@ void CLevelSystem::ScanFolder(const char* subfolder, bool modFolder) AZStd::unordered_set pakList; - const bool allowFileSystem = true; - const uint32_t skipPakFiles = 1; AZ::IO::ArchiveFileIterator handle = pPak->FindFirst(search.c_str(), AZ::IO::IArchive::eFileSearchType_AllowOnDiskOnly); if (handle) @@ -566,8 +560,6 @@ ILevel* CLevelSystem::LoadLevelInternal(const char* _levelName) // Not remove a scope!!! { - LOADING_TIME_PROFILE_SECTION; - //m_levelLoadStartTime = gEnv->pTimer->GetAsyncTime(); CLevelInfo* pLevelInfo = GetLevelInfoInternal(levelName); @@ -582,7 +574,6 @@ ILevel* CLevelSystem::LoadLevelInternal(const char* _levelName) m_bLevelLoaded = false; - const bool bLoadingSameLevel = azstricmp(m_lastLevelName.c_str(), levelName) == 0; m_lastLevelName = levelName; delete m_pCurrentLevel; @@ -746,8 +737,6 @@ void CLevelSystem::OnLoadingStart(const char* levelName) GetISystem()->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_LEVEL_LOAD_START, 0, 0); - LOADING_TIME_PROFILE_SECTION(gEnv->pSystem); - for (AZStd::vector::const_iterator it = m_listeners.begin(); it != m_listeners.end(); ++it) { (*it)->OnLoadingStart(levelName); diff --git a/Code/Legacy/CrySystem/LevelSystem/SpawnableLevelSystem.cpp b/Code/Legacy/CrySystem/LevelSystem/SpawnableLevelSystem.cpp index b37b257f5b..72d74ea1c1 100644 --- a/Code/Legacy/CrySystem/LevelSystem/SpawnableLevelSystem.cpp +++ b/Code/Legacy/CrySystem/LevelSystem/SpawnableLevelSystem.cpp @@ -55,10 +55,8 @@ namespace LegacyLevelSystem AZ_CONSOLEFREEFUNC(UnloadLevel, AZ::ConsoleFunctorFlags::Null, "Unloads the current level"); //------------------------------------------------------------------------ - SpawnableLevelSystem::SpawnableLevelSystem(ISystem* pSystem) - : m_pSystem(pSystem) + SpawnableLevelSystem::SpawnableLevelSystem([[maybe_unused]] ISystem* pSystem) { - LOADING_TIME_PROFILE_SECTION; CRY_ASSERT(pSystem); m_fLastLevelLoadTime = 0; @@ -248,8 +246,6 @@ namespace LegacyLevelSystem // This scope is specifically used for marking a loading time profile section { - LOADING_TIME_PROFILE_SECTION; - m_bLevelLoaded = false; m_lastLevelName = levelName; gEnv->pConsole->SetScrollMax(600); @@ -388,8 +384,6 @@ namespace LegacyLevelSystem GetISystem()->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_LEVEL_LOAD_START, 0, 0); - LOADING_TIME_PROFILE_SECTION(gEnv->pSystem); - for (auto& listener : m_listeners) { listener->OnLoadingStart(levelName); diff --git a/Code/Legacy/CrySystem/LevelSystem/SpawnableLevelSystem.h b/Code/Legacy/CrySystem/LevelSystem/SpawnableLevelSystem.h index 858a0b24f0..0a7b821262 100644 --- a/Code/Legacy/CrySystem/LevelSystem/SpawnableLevelSystem.h +++ b/Code/Legacy/CrySystem/LevelSystem/SpawnableLevelSystem.h @@ -66,8 +66,6 @@ class SpawnableLevelSystem void LogLoadingTime(); - ISystem* m_pSystem{nullptr}; - AZStd::string m_lastLevelName; float m_fLastLevelLoadTime{0.0f}; float m_fLastTime{0.0f}; diff --git a/Code/Legacy/CrySystem/LocalizedStringManager.cpp b/Code/Legacy/CrySystem/LocalizedStringManager.cpp index 8b09667f13..78ece6f74c 100644 --- a/Code/Legacy/CrySystem/LocalizedStringManager.cpp +++ b/Code/Legacy/CrySystem/LocalizedStringManager.cpp @@ -20,12 +20,14 @@ #include "System.h" // to access InitLocalization() #include #include +#include #include #include #include #include #include +#include #define MAX_CELL_COUNT 32 @@ -209,7 +211,7 @@ CLocalizedStringsManager::CLocalizedStringsManager(ISystem* pSystem) AZStd::string sPath; const AZStd::string sLocalizationFolder(PathUtil::GetLocalizationFolder()); ILocalizationManager::TLocalizationBitfield availableLanguages = 0; - + AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance(); // test language name against supported languages for (int i = 0; i < ILocalizationManager::ePILID_MAX_OR_INVALID; i++) @@ -872,7 +874,6 @@ inline YesNoType ToYesNoType(const char* szString) // Loads a string-table from a Excel XML Spreadsheet file. bool CLocalizedStringsManager::DoLoadExcelXmlSpreadsheet(const char* sFileName, uint8 nTagID, bool bReload) { - LOADING_TIME_PROFILE_SECTION_ARGS(sFileName) if (!m_pLanguage) { return false; @@ -1319,7 +1320,7 @@ bool CLocalizedStringsManager::DoLoadExcelXmlSpreadsheet(const char* sFileName, } //Compute the CRC32 of the key - keyCRC = CCrc32::Compute(szLowerCaseKey); + keyCRC = AZ::Crc32(szLowerCaseKey); if (m_cvarLocalizationDebug >= 3) { CryLogAlways(" CRC32: 0x%8X, Key: %s", keyCRC, szLowerCaseKey); @@ -1507,7 +1508,7 @@ bool CLocalizedStringsManager::DoLoadExcelXmlSpreadsheet(const char* sFileName, if (m_cvarLocalizationEncode == 1) { pEncoder->Finalize(); - + { uint8 compressionBuffer[COMPRESSION_FIXED_BUFFER_LENGTH]; //uint8 decompressionBuffer[COMPRESSION_FIXED_BUFFER_LENGTH]; @@ -1647,7 +1648,7 @@ bool CLocalizedStringsManager::DoLoadAGSXmlDocument(const char* sFileName, uint8 } lowerKey = keyString; AZStd::to_lower(lowerKey.begin(), lowerKey.end()); - keyCRC = CCrc32::Compute(lowerKey.c_str()); + keyCRC = AZ::Crc32(lowerKey); if (m_cvarLocalizationDebug >= 3) { CryLogAlways(" CRC32: 0%8X, Key: %s", keyCRC, lowerKey.c_str()); @@ -1755,7 +1756,7 @@ void CLocalizedStringsManager::AddLocalizedString(SLanguage* pLanguage, SLocaliz pLanguage->m_vLocalizedStrings.push_back(pEntry); int nId = (int)pLanguage->m_vLocalizedStrings.size() - 1; pLanguage->m_keysMap[keyCRC32] = pEntry; - + if (m_cvarLocalizationDebug >= 2) { CryLog(" Add new string <%u> with ID %d to <%s>", keyCRC32, nId, pLanguage->sLanguage.c_str()); @@ -1861,7 +1862,7 @@ void CLocalizedStringsManager::LocalizeAndSubstituteInternal(AZStd::string& locS startIndex += substituteOut.length(); } startIndex = locString.find_first_of('{', startIndex); - endIndex = locString.find_first_of('}', startIndex); + endIndex = locString.find_first_of('}', startIndex); } } #if defined(LOG_DECOMP_TIMES) @@ -1925,11 +1926,9 @@ AZStd::string CLocalizedStringsManager::SLocalizedStringEntry::GetTranslatedText #endif //LOG_DECOMP_TIMES #if !defined(NDEBUG) - size_t len = -#endif - strnlen((const char*)decompressionBuffer, COMPRESSION_FIXED_BUFFER_LENGTH); + size_t len = strnlen((const char*)decompressionBuffer, COMPRESSION_FIXED_BUFFER_LENGTH); assert(len < COMPRESSION_FIXED_BUFFER_LENGTH && "Buffer not null-terminated"); - +#endif #if defined(LOG_DECOMP_TIMES) nAllocTicks = CryGetTicks(); @@ -2002,7 +2001,7 @@ bool CLocalizedStringsManager::LocalizeLabel(const char* sLabel, AZStd::string& // Label sign. if (sLabel[0] == '@') { - uint32 labelCRC32 = CCrc32::ComputeLowercase(sLabel + 1); // skip @ character. + uint32 labelCRC32 = AZ::Crc32(sLabel + 1); // skip @ character. { AutoLock lock(m_cs); //Lock here, to prevent strings etc being modified underneath this lookup SLocalizedStringEntry* entry = stl::find_in_map(m_pLanguage->m_keysMap, labelCRC32, NULL); @@ -2051,10 +2050,10 @@ bool CLocalizedStringsManager::GetEnglishString(const char* sKey, AZStd::string& // Label sign. if (sKey[0] == '@') { - uint32 keyCRC32 = CCrc32::ComputeLowercase(sKey + 1); + uint32 keyCRC32 = AZ::Crc32(sKey + 1); { - AutoLock lock(m_cs); //Lock here, to prevent strings etc being modified underneath this lookup - SLocalizedStringEntry* entry = stl::find_in_map(m_pLanguage->m_keysMap, keyCRC32, NULL); // skip @ character. + AutoLock lock(m_cs); // Lock here, to prevent strings etc being modified underneath this lookup + SLocalizedStringEntry* entry = stl::find_in_map(m_pLanguage->m_keysMap, keyCRC32, NULL); // skip @ character. if (entry != NULL && entry->pEditorExtension != NULL) { sLocalizedString = entry->pEditorExtension->sOriginalText; @@ -2062,7 +2061,7 @@ bool CLocalizedStringsManager::GetEnglishString(const char* sKey, AZStd::string& } else { - keyCRC32 = CCrc32::ComputeLowercase(sKey); + keyCRC32 = AZ::Crc32(sKey); entry = stl::find_in_map(m_pLanguage->m_keysMap, keyCRC32, NULL); if (entry != NULL && entry->pEditorExtension != NULL) { @@ -2080,7 +2079,8 @@ bool CLocalizedStringsManager::GetEnglishString(const char* sKey, AZStd::string& } else { - // CryWarning( VALIDATOR_MODULE_SYSTEM,VALIDATOR_WARNING,"Not a valid localized string Label <%s>, must start with @ symbol", sKey ); + // CryWarning( VALIDATOR_MODULE_SYSTEM,VALIDATOR_WARNING,"Not a valid localized string Label <%s>, must start with @ symbol", sKey + // ); } sLocalizedString = sKey; @@ -2093,7 +2093,7 @@ bool CLocalizedStringsManager::IsLocalizedInfoFound(const char* sKey) { return false; } - uint32 keyCRC32 = CCrc32::ComputeLowercase(sKey); + uint32 keyCRC32 = AZ::Crc32(sKey); { AutoLock lock(m_cs); //Lock here, to prevent strings etc being modified underneath this lookup const SLocalizedStringEntry* entry = stl::find_in_map(m_pLanguage->m_keysMap, keyCRC32, NULL); @@ -2109,7 +2109,7 @@ bool CLocalizedStringsManager::GetLocalizedInfoByKey(const char* sKey, SLocalize return false; } - uint32 keyCRC32 = CCrc32::ComputeLowercase(sKey); + uint32 keyCRC32 = AZ::Crc32(sKey); { AutoLock lock(m_cs); //Lock here, to prevent strings etc being modified underneath this lookup const SLocalizedStringEntry* entry = stl::find_in_map(m_pLanguage->m_keysMap, keyCRC32, NULL); @@ -2140,7 +2140,7 @@ bool CLocalizedStringsManager::GetLocalizedInfoByKey(const char* sKey, SLocalize bool bResult = false; - uint32 keyCRC32 = CCrc32::ComputeLowercase(sKey); + uint32 keyCRC32 = AZ::Crc32(sKey); { AutoLock lock(m_cs); //Lock here, to prevent strings etc being modified underneath this lookup const SLocalizedStringEntry* pEntry = stl::find_in_map(m_pLanguage->m_keysMap, keyCRC32, NULL); @@ -2293,7 +2293,7 @@ bool CLocalizedStringsManager::GetSubtitle(const char* sKeyOrLabel, AZStd::strin ++sKeyOrLabel; } - uint32 keyCRC32 = CCrc32::ComputeLowercase(sKeyOrLabel); + uint32 keyCRC32 = AZ::Crc32(sKeyOrLabel); { AutoLock lock(m_cs); //Lock here, to prevent strings etc being modified underneath this lookup const SLocalizedStringEntry* pEntry = stl::find_in_map(m_pLanguage->m_keysMap, keyCRC32, NULL); @@ -2457,7 +2457,7 @@ namespace { "nl-NL", 0x0413 }, // Dutch (The Netherlands) { "fi-FI", 0x040b }, // Finnish { "sv-SE", 0x041d }, // Swedish - { "cs-CZ", 0x0405 }, // Czech + { "cs-CZ", 0x0405 }, // Czech { "no-NO", 0x0414 }, // Norwegian (Norway) { "ar-SA", 0x0401 }, // Arabic (Saudi Arabia) { "da-DK", 0x0406 }, // Danish (Denmark) diff --git a/Code/Legacy/CrySystem/Log.cpp b/Code/Legacy/CrySystem/Log.cpp index b671748920..a157501f0a 100644 --- a/Code/Legacy/CrySystem/Log.cpp +++ b/Code/Legacy/CrySystem/Log.cpp @@ -44,7 +44,7 @@ namespace LogCVars int max_backup_directory_size_mb = 200; //200MB default }; -#ifndef _RELEASE +#if defined(SUPPORT_LOG_IDENTER) static CLog::LogStringType indentString (" "); #endif @@ -396,7 +396,6 @@ void CLog::LogV(const ELogType type, [[maybe_unused]]int flags, const char* szFo } } - LOADING_TIME_PROFILE_SECTION(GetISystem()); bool bfile = false, bconsole = false; const char* szCommand = szFormat; @@ -443,8 +442,6 @@ void CLog::LogV(const ELogType type, [[maybe_unused]]int flags, const char* szFo return; } - LogStringType tempString; - char szBuffer[MAX_WARNING_LENGTH + 32]; char* szString = szBuffer; char* szAfterColour = szString; @@ -574,8 +571,6 @@ void CLog::LogPlus(const char* szFormat, ...) return; } - LOADING_TIME_PROFILE_SECTION(GetISystem()); - if (!szFormat) { return; @@ -1188,7 +1183,6 @@ void CLog::LogToFile(const char* szFormat, ...) ////////////////////////////////////////////////////////////////////// void CLog::CreateBackupFile() const { - LOADING_TIME_PROFILE_SECTION; if (!m_backupLogs) { return; @@ -1296,7 +1290,7 @@ void CLog::CheckAndPruneBackupLogs() const AZStd::list fileInfoList; // Now that we've copied the new log over, lets check the size of the backup folder and trim it as necessary to keep it within appropriate limits - AZ::IO::Result res = fileSystem->FindFiles(LOG_BACKUP_PATH, "*", + fileSystem->FindFiles(LOG_BACKUP_PATH, "*", [&totalBackupDirectorySize, &fileSystem, &fileInfoList](const char* fileName) { AZ::u64 size; diff --git a/Code/Legacy/CrySystem/Platform/Android/platform_android.cmake b/Code/Legacy/CrySystem/Platform/Android/platform_android.cmake new file mode 100644 index 0000000000..7a325ca97e --- /dev/null +++ b/Code/Legacy/CrySystem/Platform/Android/platform_android.cmake @@ -0,0 +1,7 @@ +# +# 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/Code/Legacy/CrySystem/Platform/Android/platform_android_files.cmake b/Code/Legacy/CrySystem/Platform/Android/platform_android_files.cmake new file mode 100644 index 0000000000..7a325ca97e --- /dev/null +++ b/Code/Legacy/CrySystem/Platform/Android/platform_android_files.cmake @@ -0,0 +1,7 @@ +# +# 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/Code/Legacy/CrySystem/Platform/Linux/platform_linux.cmake b/Code/Legacy/CrySystem/Platform/Linux/platform_linux.cmake new file mode 100644 index 0000000000..7a325ca97e --- /dev/null +++ b/Code/Legacy/CrySystem/Platform/Linux/platform_linux.cmake @@ -0,0 +1,7 @@ +# +# 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/Code/Legacy/CrySystem/Platform/Linux/platform_linux_files.cmake b/Code/Legacy/CrySystem/Platform/Linux/platform_linux_files.cmake new file mode 100644 index 0000000000..7a325ca97e --- /dev/null +++ b/Code/Legacy/CrySystem/Platform/Linux/platform_linux_files.cmake @@ -0,0 +1,7 @@ +# +# 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/Code/Legacy/CrySystem/Platform/Mac/platform_mac.cmake b/Code/Legacy/CrySystem/Platform/Mac/platform_mac.cmake new file mode 100644 index 0000000000..7a325ca97e --- /dev/null +++ b/Code/Legacy/CrySystem/Platform/Mac/platform_mac.cmake @@ -0,0 +1,7 @@ +# +# 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/Code/Legacy/CrySystem/Platform/Mac/platform_mac_files.cmake b/Code/Legacy/CrySystem/Platform/Mac/platform_mac_files.cmake new file mode 100644 index 0000000000..7a325ca97e --- /dev/null +++ b/Code/Legacy/CrySystem/Platform/Mac/platform_mac_files.cmake @@ -0,0 +1,7 @@ +# +# 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/Code/Legacy/CrySystem/Platform/Windows/platform_windows.cmake b/Code/Legacy/CrySystem/Platform/Windows/platform_windows.cmake new file mode 100644 index 0000000000..7a325ca97e --- /dev/null +++ b/Code/Legacy/CrySystem/Platform/Windows/platform_windows.cmake @@ -0,0 +1,7 @@ +# +# 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/Code/Legacy/CrySystem/Platform/Windows/platform_windows_files.cmake b/Code/Legacy/CrySystem/Platform/Windows/platform_windows_files.cmake new file mode 100644 index 0000000000..7a325ca97e --- /dev/null +++ b/Code/Legacy/CrySystem/Platform/Windows/platform_windows_files.cmake @@ -0,0 +1,7 @@ +# +# 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/Code/Legacy/CrySystem/Platform/iOS/platform_ios.cmake b/Code/Legacy/CrySystem/Platform/iOS/platform_ios.cmake new file mode 100644 index 0000000000..7a325ca97e --- /dev/null +++ b/Code/Legacy/CrySystem/Platform/iOS/platform_ios.cmake @@ -0,0 +1,7 @@ +# +# 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/Code/Legacy/CrySystem/Platform/iOS/platform_ios_files.cmake b/Code/Legacy/CrySystem/Platform/iOS/platform_ios_files.cmake new file mode 100644 index 0000000000..7a325ca97e --- /dev/null +++ b/Code/Legacy/CrySystem/Platform/iOS/platform_ios_files.cmake @@ -0,0 +1,7 @@ +# +# 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/Code/Legacy/CrySystem/RemoteConsole/RemoteConsole.h b/Code/Legacy/CrySystem/RemoteConsole/RemoteConsole.h index f6c59a384a..23edafa736 100644 --- a/Code/Legacy/CrySystem/RemoteConsole/RemoteConsole.h +++ b/Code/Legacy/CrySystem/RemoteConsole/RemoteConsole.h @@ -11,8 +11,9 @@ #define CRYINCLUDE_CRYSYSTEM_REMOTECONSOLE_REMOTECONSOLE_H #pragma once -#include -#include +#include +#include +#include #if !defined(RELEASE) || defined(RELEASE_LOGGING) || defined(ENABLE_PROFILING_CODE) #define USE_REMOTE_CONSOLE diff --git a/Code/Legacy/CrySystem/System.cpp b/Code/Legacy/CrySystem/System.cpp index 8c950e900c..2d756d1352 100644 --- a/Code/Legacy/CrySystem/System.cpp +++ b/Code/Legacy/CrySystem/System.cpp @@ -19,6 +19,7 @@ #include "CryLibrary.h" #include #include +#include #include #include #include @@ -166,60 +167,6 @@ SSystemCVars g_cvars; #include #include "AZCoreLogSink.h" -#if defined(ANDROID) -namespace -{ - struct Callstack - { - Callstack() - : addrs(NULL) - , ignore(0) - , count(0) - { - } - Callstack(void** addrs, size_t ignore, size_t count) - { - this->addrs = addrs; - this->ignore = ignore; - this->count = count; - } - void** addrs; - size_t ignore; - size_t count; - }; - - static _Unwind_Reason_Code trace_func(struct _Unwind_Context* context, void* arg) - { - Callstack* cs = static_cast(arg); - if (cs->count) - { - void* ip = (void*) _Unwind_GetIP(context); - if (ip) - { - if (cs->ignore) - { - cs->ignore--; - } - else - { - cs->addrs[0] = ip; - cs->addrs++; - cs->count--; - } - } - } - return _URC_NO_REASON; - } - - static int Backtrace(void** addrs, size_t ignore, size_t size) - { - Callstack cs(addrs, ignore, size); - _Unwind_Backtrace(trace_func, (void*) &cs); - return size - cs.count; - } -} -#endif - ///////////////////////////////////////////////////////////////////////////////// // System Implementation. ////////////////////////////////////////////////////////////////////////// @@ -257,7 +204,6 @@ CSystem::CSystem(SharedEnvironmentInstance* pSharedEnvironment) // Initialize global environment interface pointers. m_env.pSystem = this; m_env.pTimer = &m_Time; - m_env.pNameTable = &m_nameTable; m_env.bIgnoreAllAsserts = false; m_env.bNoAssertDialog = false; @@ -1032,15 +978,12 @@ IXmlUtils* CSystem::GetXmlUtils() ////////////////////////////////////////////////////////////////////////// XmlNodeRef CSystem::LoadXmlFromFile(const char* sFilename, bool bReuseStrings) { - LOADING_TIME_PROFILE_SECTION_ARGS(sFilename); - return m_pXMLUtils->LoadXmlFromFile(sFilename, bReuseStrings); } ////////////////////////////////////////////////////////////////////////// XmlNodeRef CSystem::LoadXmlFromBuffer(const char* buffer, size_t size, bool bReuseStrings, bool bSuppressWarnings) { - LOADING_TIME_PROFILE_SECTION return m_pXMLUtils->LoadXmlFromBuffer(buffer, size, bReuseStrings, bSuppressWarnings); } @@ -1250,9 +1193,6 @@ ILocalizationManager* CSystem::GetLocalizationManager() ////////////////////////////////////////////////////////////////////////// void CSystem::debug_GetCallStackRaw(void** callstack, uint32& callstackLength) { - uint32 callstackCapacity = callstackLength; - uint32 nNumStackFramesToSkip = 1; - memset(callstack, 0, sizeof(void*) * callstackLength); #if !defined(ANDROID) @@ -1260,6 +1200,8 @@ void CSystem::debug_GetCallStackRaw(void** callstack, uint32& callstackLength) #endif #if AZ_LEGACY_CRYSYSTEM_TRAIT_CAPTURESTACK + uint32 nNumStackFramesToSkip = 1; + uint32 callstackCapacity = callstackLength; if (callstackCapacity > 0x40) { callstackCapacity = 0x40; @@ -1708,10 +1650,10 @@ bool CSystem::HandleMessage([[maybe_unused]] HWND hWnd, UINT uMsg, WPARAM wParam AZStd::array rawInputBytesArray; LPBYTE rawInputBytes = rawInputBytesArray.data(); - const UINT bytesCopied = GetRawInputData((HRAWINPUT)lParam, RID_INPUT, rawInputBytes, &rawInputSize, rawInputHeaderSize); + [[maybe_unused]] const UINT bytesCopied = GetRawInputData((HRAWINPUT)lParam, RID_INPUT, rawInputBytes, &rawInputSize, rawInputHeaderSize); CRY_ASSERT(bytesCopied == rawInputSize); - RAWINPUT* rawInput = (RAWINPUT*)rawInputBytes; + [[maybe_unused]] RAWINPUT* rawInput = (RAWINPUT*)rawInputBytes; CRY_ASSERT(rawInput); AzFramework::RawInputNotificationBusWindows::Broadcast(&AzFramework::RawInputNotificationsWindows::OnRawInputEvent, *rawInput); diff --git a/Code/Legacy/CrySystem/System.h b/Code/Legacy/CrySystem/System.h index 952de817e7..738ffd4bfb 100644 --- a/Code/Legacy/CrySystem/System.h +++ b/Code/Legacy/CrySystem/System.h @@ -11,13 +11,11 @@ #include #include -#include #include #include "Timer.h" #include #include "CmdLine.h" -#include "CryName.h" #include #include "RenderBus.h" @@ -25,6 +23,7 @@ #include #include +#include namespace AzFramework { @@ -330,7 +329,6 @@ public: ICryFont* GetICryFont(){ return m_env.pCryFont; } ILog* GetILog(){ return m_env.pLog; } ICmdLine* GetICmdLine(){ return m_pCmdLine; } - INameTable* GetINameTable() { return m_env.pNameTable; }; IViewSystem* GetIViewSystem(); ILevelSystem* GetILevelSystem(); ISystemEventDispatcher* GetISystemEventDispatcher() { return m_pSystemEventDispatcher; } @@ -490,27 +488,27 @@ private: // ------------------------------------------------------ // System environment. SSystemGlobalEnvironment m_env; - CTimer m_Time; //!< - bool m_bInitializedSuccessfully; //!< true if the system completed all initialization steps - bool m_bRelaunch; //!< relaunching the app or not (true beforerelaunch) - int m_iLoadingMode; //!< Game is loading w/o changing context (0 not, 1 quickloading, 2 full loading) - bool m_bTestMode; //!< If running in testing mode. - bool m_bEditor; //!< If running in Editor. - bool m_bNoCrashDialog; - bool m_bNoErrorReportWindow; + CTimer m_Time; //!< + bool m_bInitializedSuccessfully; //!< true if the system completed all initialization steps + bool m_bRelaunch; //!< relaunching the app or not (true beforerelaunch) + int m_iLoadingMode; //!< Game is loading w/o changing context (0 not, 1 quickloading, 2 full loading) + bool m_bTestMode; //!< If running in testing mode. + bool m_bEditor; //!< If running in Editor. + bool m_bNoCrashDialog; + bool m_bNoErrorReportWindow; bool m_bPreviewMode; //!< If running in Preview mode. - bool m_bDedicatedServer; //!< If running as Dedicated server. - bool m_bIgnoreUpdates; //!< When set to true will ignore Update and Render calls, - bool m_bForceNonDevMode; //!< true when running on a cheat protected server or a client that is connected to it (not used in singlplayer) - bool m_bWasInDevMode; //!< Set to true if was in dev mode. - bool m_bInDevMode; //!< Set to true if was in dev mode. + bool m_bDedicatedServer; //!< If running as Dedicated server. + bool m_bIgnoreUpdates; //!< When set to true will ignore Update and Render calls, + bool m_bForceNonDevMode; //!< true when running on a cheat protected server or a client that is connected to it (not used in singlplayer) + bool m_bWasInDevMode; //!< Set to true if was in dev mode. + bool m_bInDevMode; //!< Set to true if was in dev mode. bool m_bGameFolderWritable;//!< True when verified that current game folder have write access. - int m_ttMemStatSS; //!< Time to memstat screenshot - bool m_bDrawConsole; //!< Set to true if OK to draw the console. - bool m_bDrawUI; //!< Set to true if OK to draw UI. + int m_ttMemStatSS; //!< Time to memstat screenshot + bool m_bDrawConsole; //!< Set to true if OK to draw the console. + bool m_bDrawUI; //!< Set to true if OK to draw UI. - std::map > m_moduleDLLHandles; + std::map > m_moduleDLLHandles; //! current active process IProcess* m_pProcess; @@ -632,9 +630,6 @@ private: // ------------------------------------------------------ class CLocalizedStringsManager* m_pLocalizationManager; - // Name table. - CNameTable m_nameTable; - ESystemConfigSpec m_nServerConfigSpec; ESystemConfigSpec m_nMaxConfigSpec; ESystemConfigPlatform m_ConfigPlatform; diff --git a/Code/Legacy/CrySystem/SystemInit.cpp b/Code/Legacy/CrySystem/SystemInit.cpp index ebd3d91a3d..a0769d1a2c 100644 --- a/Code/Legacy/CrySystem/SystemInit.cpp +++ b/Code/Legacy/CrySystem/SystemInit.cpp @@ -431,8 +431,6 @@ AZStd::unique_ptr CSystem::LoadDynamiclibrary(const cha ////////////////////////////////////////////////////////////////////////// AZStd::unique_ptr CSystem::LoadDLL(const char* dllName) { - LOADING_TIME_PROFILE_SECTION(GetISystem()); - AZ_TracePrintf(AZ_TRACE_SYSTEM_WINDOW, "Loading DLL: %s", dllName); AZStd::unique_ptr handle = LoadDynamiclibrary(dllName); @@ -475,7 +473,7 @@ bool CSystem::UnloadDLL(const char* dllName) { bool isSuccess = false; - CCryNameCRC key(dllName); + AZ::Crc32 key(dllName); AZStd::unique_ptr empty; AZStd::unique_ptr& hModule = stl::find_in_map_ref(m_moduleDLLHandles, key, empty); if ((hModule) && (hModule->IsLoaded())) @@ -611,8 +609,6 @@ AZStd::wstring GetErrorStringUnsupportedGPU(const char* gpuName, unsigned int gp ///////////////////////////////////////////////////////////////////////////////// bool CSystem::InitConsole() { - LOADING_TIME_PROFILE_SECTION(GetISystem()); - if (m_env.pConsole) { m_env.pConsole->Init(this); @@ -661,7 +657,6 @@ ICVar* CSystem::attachVariable (const char* szVarName, int* pContainer, const ch ///////////////////////////////////////////////////////////////////////////////// bool CSystem::InitFileSystem() { - LOADING_TIME_PROFILE_SECTION; using namespace AzFramework::AssetSystem; if (m_pUserCallback) @@ -747,11 +742,8 @@ void CSystem::ShutdownFileSystem() ///////////////////////////////////////////////////////////////////////////////// bool CSystem::InitFileSystem_LoadEngineFolders(const SSystemInitParams&) { - LOADING_TIME_PROFILE_SECTION; - { - LoadConfiguration(m_systemConfigName.c_str()); - AZ_Printf(AZ_TRACE_SYSTEM_WINDOW, "Loading system configuration from %s...", m_systemConfigName.c_str()); - } + LoadConfiguration(m_systemConfigName.c_str()); + AZ_Printf(AZ_TRACE_SYSTEM_WINDOW, "Loading system configuration from %s...", m_systemConfigName.c_str()); #if defined(AZ_PLATFORM_ANDROID) AZ::Android::Utils::SetLoadFilesToMemory(m_sys_load_files_to_memory->GetString()); @@ -782,8 +774,6 @@ bool CSystem::InitFileSystem_LoadEngineFolders(const SSystemInitParams&) ////////////////////////////////////////////////////////////////////////// bool CSystem::InitAudioSystem(const SSystemInitParams& initParams) { - LOADING_TIME_PROFILE_SECTION(GetISystem()); - if (!Audio::Gem::AudioSystemGemRequestBus::HasHandlers()) { // AudioSystem Gem has not been enabled for this project. @@ -825,8 +815,6 @@ bool CSystem::InitAudioSystem(const SSystemInitParams& initParams) ////////////////////////////////////////////////////////////////////////// bool CSystem::InitVTuneProfiler() { - LOADING_TIME_PROFILE_SECTION(GetISystem()); - #ifdef PROFILE_WITH_VTUNE WIN_HMODULE hModule = LoadDLL("VTuneApi.dll"); @@ -854,7 +842,6 @@ bool CSystem::InitVTuneProfiler() ////////////////////////////////////////////////////////////////////////// void CSystem::InitLocalization() { - LOADING_TIME_PROFILE_SECTION(GetISystem()); // Set the localization folder ICVar* pCVar = m_env.pConsole != 0 ? m_env.pConsole->GetCVar("sys_localization_folder") : 0; if (pCVar) @@ -916,8 +903,6 @@ void CSystem::OpenBasicPaks() } bBasicPaksLoaded = true; - LOADING_TIME_PROFILE_SECTION; - // open pak files constexpr AZStd::string_view paksFolder = "@assets@/*.pak"; // (@assets@ assumed) m_env.pCryPak->OpenPacks(paksFolder); @@ -1152,8 +1137,6 @@ bool CSystem::Init(const SSystemInitParams& startupParams) gEnv = &m_env; } - LOADING_TIME_PROFILE_SECTION; - SetSystemGlobalState(ESYSTEM_GLOBAL_STATE_INIT); gEnv->mMainThreadId = GetCurrentThreadId(); //Set this ASAP on startup @@ -1184,7 +1167,7 @@ bool CSystem::Init(const SSystemInitParams& startupParams) { azConsole->LinkDeferredFunctors(AZ::ConsoleFunctorBase::GetDeferredHead()); } - + if (auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry) { AZ::SettingsRegistryInterface::FixedValueString assetPlatform; @@ -1837,19 +1820,6 @@ void CSystem::CreateSystemVars() "Usage: e_EntitySuppressionLevel [0-infinity]\n" "Default is 0 (off)"); -#if defined(WIN32) || defined(WIN64) - const uint32 nJobSystemDefaultCoreNumber = 8; -#define AZ_RESTRICTED_SECTION_IMPLEMENTED -#elif defined(AZ_RESTRICTED_PLATFORM) -#define AZ_RESTRICTED_SECTION SYSTEMINIT_CPP_SECTION_11 -#include AZ_RESTRICTED_FILE(SystemInit_cpp) -#endif -#if defined(AZ_RESTRICTED_SECTION_IMPLEMENTED) -#undef AZ_RESTRICTED_SECTION_IMPLEMENTED -#else - const uint32 nJobSystemDefaultCoreNumber = 4; -#endif - m_sys_firstlaunch = REGISTER_INT("sys_firstlaunch", 0, 0, "Indicates that the game was run for the first time."); diff --git a/Code/Legacy/CrySystem/XConsole.cpp b/Code/Legacy/CrySystem/XConsole.cpp index 46eea1528c..88a7fc262e 100644 --- a/Code/Legacy/CrySystem/XConsole.cpp +++ b/Code/Legacy/CrySystem/XConsole.cpp @@ -20,8 +20,8 @@ #include #include #include -#include -#include +#include +#include #include "ConsoleHelpGen.h" // CConsoleHelpGen #include diff --git a/Code/Legacy/CrySystem/XML/XmlUtils.cpp b/Code/Legacy/CrySystem/XML/XmlUtils.cpp index ecc10508f1..56944eb344 100644 --- a/Code/Legacy/CrySystem/XML/XmlUtils.cpp +++ b/Code/Legacy/CrySystem/XML/XmlUtils.cpp @@ -24,7 +24,6 @@ #include ////////////////////////////////////////////////////////////////////////// -CXmlNode_PoolAlloc* g_pCXmlNode_PoolAlloc = 0; #ifdef CRY_COLLECT_XML_NODE_STATS SXmlNodeStats* g_pCXmlNode_Stats = 0; #endif @@ -35,11 +34,9 @@ extern bool g_bEnableBinaryXmlLoading; CXmlUtils::CXmlUtils(ISystem* pSystem) { m_pSystem = pSystem; - m_pSystem->GetISystemEventDispatcher()->RegisterListener(this); // create IReadWriteXMLSink object m_pReadWriteXMLSink = new CReadWriteXMLSink(); - g_pCXmlNode_PoolAlloc = new CXmlNode_PoolAlloc; #ifdef CRY_COLLECT_XML_NODE_STATS g_pCXmlNode_Stats = new SXmlNodeStats(); #endif @@ -53,8 +50,6 @@ CXmlUtils::CXmlUtils(ISystem* pSystem) ////////////////////////////////////////////////////////////////////////// CXmlUtils::~CXmlUtils() { - m_pSystem->GetISystemEventDispatcher()->RemoveListener(this); - delete g_pCXmlNode_PoolAlloc; #ifdef CRY_COLLECT_XML_NODE_STATS delete g_pCXmlNode_Stats; #endif @@ -200,13 +195,8 @@ IXmlSerializer* CXmlUtils::CreateXmlSerializer() } ////////////////////////////////////////////////////////////////////////// -void CXmlUtils::GetMemoryUsage(ICrySizer* pSizer) +void CXmlUtils::GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer) { - { - SIZER_COMPONENT_NAME(pSizer, "Nodes"); - g_pCXmlNode_PoolAlloc->GetMemoryUsage(pSizer); - } - #ifdef CRY_COLLECT_XML_NODE_STATS // yes, slow std::vector rootNodes; @@ -260,18 +250,6 @@ void CXmlUtils::GetMemoryUsage(ICrySizer* pSizer) #endif } -////////////////////////////////////////////////////////////////////////// -void CXmlUtils::OnSystemEvent(ESystemEvent event, [[maybe_unused]] UINT_PTR wparam, [[maybe_unused]] UINT_PTR lparam) -{ - switch (event) - { - case ESYSTEM_EVENT_LEVEL_POST_UNLOAD: - case ESYSTEM_EVENT_LEVEL_LOAD_END: - g_pCXmlNode_PoolAlloc->FreeMemoryIfEmpty(); - break; - } -} - ////////////////////////////////////////////////////////////////////////// class CXmlBinaryDataWriterFile : public XMLBinary::IDataWriter diff --git a/Code/Legacy/CrySystem/XML/XmlUtils.h b/Code/Legacy/CrySystem/XML/XmlUtils.h index 8e44b86e41..d81dc4b642 100644 --- a/Code/Legacy/CrySystem/XML/XmlUtils.h +++ b/Code/Legacy/CrySystem/XML/XmlUtils.h @@ -27,7 +27,6 @@ class CXMLPatcher; ////////////////////////////////////////////////////////////////////////// class CXmlUtils : public IXmlUtils - , public ISystemEventListener { public: CXmlUtils(ISystem* pSystem); @@ -62,12 +61,6 @@ public: virtual IXmlTableReader* CreateXmlTableReader(); ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - // ISystemEventListener - ////////////////////////////////////////////////////////////////////////// - virtual void OnSystemEvent(ESystemEvent event, UINT_PTR wparam, UINT_PTR lparam); - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// virtual void GetMemoryUsage(ICrySizer* pSizer); diff --git a/Code/Legacy/CrySystem/XML/xml.cpp b/Code/Legacy/CrySystem/XML/xml.cpp index adbfcc5f3e..cc3ea7f820 100644 --- a/Code/Legacy/CrySystem/XML/xml.cpp +++ b/Code/Legacy/CrySystem/XML/xml.cpp @@ -1293,7 +1293,6 @@ XmlString CXmlNode::getXMLUnsafe(int level, char* tmpBuffer, uint32 sizeOfTmpBuf // TODO: those 2 saving functions are a bit messy. should probably make a separate one for the use of PlatformAPI bool CXmlNode::saveToFile(const char* fileName) { - const size_t chunkSizeBytes = (15 * 1024); if (!fileName) { return false; @@ -1310,6 +1309,7 @@ bool CXmlNode::saveToFile(const char* fileName) gEnv->pCryPak->FClose(fileHandle); return true; #else + constexpr size_t chunkSizeBytes = (15 * 1024); bool ret = saveToFile(fileName, chunkSizeBytes, fileHandle); gEnv->pCryPak->FClose(fileHandle); return ret; @@ -1675,8 +1675,6 @@ XmlNodeRef XmlParserImp::ParseBuffer(const char* buffer, size_t bufLen, XmlStrin ////////////////////////////////////////////////////////////////////////// XmlNodeRef XmlParserImp::ParseFile(const char* filename, XmlString& errorString, bool bCleanPools) { - LOADING_TIME_PROFILE_SECTION(GetISystem()); - if (!filename) { return 0; @@ -1739,8 +1737,6 @@ XmlNodeRef XmlParserImp::ParseFile(const char* filename, XmlString& errorString, if (g_bEnableBinaryXmlLoading) { - LOADING_TIME_PROFILE_SECTION_NAMED("XMLBinaryReader::Parse"); - XMLBinary::XMLBinaryReader reader; XMLBinary::XMLBinaryReader::EResult result; root = reader.LoadFromBuffer(XMLBinary::XMLBinaryReader::eBufferMemoryHandling_TakeOwnership, pFileContents, fileSize, result); @@ -1760,21 +1756,9 @@ XmlNodeRef XmlParserImp::ParseFile(const char* filename, XmlString& errorString, { // not binary XML - refuse to load if in scripts dir and not in bin xml to help reduce hacking // wish we could compile the text xml parser out, but too much work to get everything moved over - static const char SCRIPTS_DIR[] = "Scripts/"; - AZStd::fixed_string<32> strScripts("S"); - strScripts += "c"; - strScripts += "r"; - strScripts += "i"; - strScripts += "p"; - strScripts += "t"; - strScripts += "s"; - strScripts += "/"; + constexpr AZStd::fixed_string<32> strScripts{"Scripts/"}; // exclude files and PAKs from Mods folder - AZStd::fixed_string<8> modsStr("M"); - modsStr += "o"; - modsStr += "d"; - modsStr += "s"; - modsStr += "/"; + constexpr AZStd::fixed_string<8> modsStr{"Mods/"}; if (_strnicmp(filename, strScripts.c_str(), strScripts.length()) == 0 && _strnicmp(adjustedFilename.c_str(), modsStr.c_str(), modsStr.length()) != 0 && _strnicmp(pakPath.c_str(), modsStr.c_str(), modsStr.length()) != 0) diff --git a/Code/Legacy/CrySystem/XML/xml.h b/Code/Legacy/CrySystem/XML/xml.h index cb20c351f4..912767eae7 100644 --- a/Code/Legacy/CrySystem/XML/xml.h +++ b/Code/Legacy/CrySystem/XML/xml.h @@ -6,14 +6,10 @@ * */ - -#ifndef CRYINCLUDE_CRYSYSTEM_XML_XML_H -#define CRYINCLUDE_CRYSYSTEM_XML_XML_H #pragma once #include -#include #include #include "IXml.h" @@ -344,9 +340,6 @@ private: friend class XmlParserImp; }; -typedef stl::PoolAllocatorNoMT CXmlNode_PoolAlloc; -extern CXmlNode_PoolAlloc* g_pCXmlNode_PoolAlloc; - #ifdef CRY_COLLECT_XML_NODE_STATS typedef std::set TXmlNodeSet; // yes, slow, but really only for one-shot debugging struct SXmlNodeStats @@ -361,35 +354,6 @@ struct SXmlNodeStats extern SXmlNodeStats* g_pCXmlNode_Stats; #endif -/* -////////////////////////////////////////////////////////////////////////// -inline void* CXmlNode::operator new( size_t nSize ) -{ - void *ptr = g_pCXmlNode_PoolAlloc->Allocate(); - if (ptr) - { - memset( ptr,0,nSize ); // Clear objects memory. -#ifdef CRY_COLLECT_XML_NODE_STATS - g_pCXmlNode_Stats->nodeSet.insert(reinterpret_cast (ptr)); - ++g_pCXmlNode_Stats->nAllocs; -#endif - } - return ptr; -} - -////////////////////////////////////////////////////////////////////////// -inline void CXmlNode::operator delete( void *ptr ) -{ - if (ptr) - { - g_pCXmlNode_PoolAlloc->Deallocate(ptr); -#ifdef CRY_COLLECT_XML_NODE_STATS - g_pCXmlNode_Stats->nodeSet.erase(reinterpret_cast (ptr)); - ++g_pCXmlNode_Stats->nFrees; -#endif - } -} -*/ ////////////////////////////////////////////////////////////////////////// // @@ -434,6 +398,3 @@ private: unsigned int m_nAllocated; std::stack m_pNodePool; }; - - -#endif // CRYINCLUDE_CRYSYSTEM_XML_XML_H diff --git a/Code/Tools/AssetBundler/source/ui/AddSeedDialog.h b/Code/Tools/AssetBundler/source/ui/AddSeedDialog.h index 436db64693..c24e724994 100644 --- a/Code/Tools/AssetBundler/source/ui/AddSeedDialog.h +++ b/Code/Tools/AssetBundler/source/ui/AddSeedDialog.h @@ -47,7 +47,6 @@ namespace AssetBundler QSharedPointer m_ui; QString m_platformSpecificCachePath; - bool m_isAddSeedDialog = false; AZStd::string m_fileName; diff --git a/Code/Tools/AssetBundler/source/utils/utils.cpp b/Code/Tools/AssetBundler/source/utils/utils.cpp index 12830166b7..6daf3c571b 100644 --- a/Code/Tools/AssetBundler/source/utils/utils.cpp +++ b/Code/Tools/AssetBundler/source/utils/utils.cpp @@ -110,7 +110,6 @@ namespace AssetBundler const char RestrictedDirectoryName[] = "restricted"; const char PlatformsDirectoryName[] = "Platforms"; const char GemsDirectoryName[] = "Gems"; - const char GemsAssetsDirectoryName[] = "Assets"; const char GemsSeedFileName[] = "seedList"; const char EngineSeedFileName[] = "SeedAssetList"; diff --git a/Code/Tools/AssetProcessor/AssetBuilderSDK/AssetBuilderSDK/SerializationDependencies.cpp b/Code/Tools/AssetProcessor/AssetBuilderSDK/AssetBuilderSDK/SerializationDependencies.cpp index 06d076dcfe..9e826faabb 100644 --- a/Code/Tools/AssetProcessor/AssetBuilderSDK/AssetBuilderSDK/SerializationDependencies.cpp +++ b/Code/Tools/AssetProcessor/AssetBuilderSDK/AssetBuilderSDK/SerializationDependencies.cpp @@ -101,7 +101,6 @@ namespace AssetBuilderSDK for (const auto& thisEntry : productDependencySet) { - constexpr int flags = 0; productDependencies.emplace_back(thisEntry.first, thisEntry.second); } } diff --git a/Code/Tools/AssetProcessor/Platform/Linux/native/FileWatcher/FileWatcher_linux.cpp b/Code/Tools/AssetProcessor/Platform/Linux/native/FileWatcher/FileWatcher_linux.cpp index 96f3dfb5e6..ea458ba826 100644 --- a/Code/Tools/AssetProcessor/Platform/Linux/native/FileWatcher/FileWatcher_linux.cpp +++ b/Code/Tools/AssetProcessor/Platform/Linux/native/FileWatcher/FileWatcher_linux.cpp @@ -192,7 +192,6 @@ void FolderRootWatch::WatchFolderLoop() for (size_t index=0; indexname; if (event->mask & (IN_CREATE | IN_DELETE | IN_MODIFY | IN_MOVE )) { diff --git a/Code/Tools/AssetProcessor/Platform/Mac/main_dummy.cpp b/Code/Tools/AssetProcessor/Platform/Mac/main_dummy.cpp index 12832cc488..e624b40787 100644 --- a/Code/Tools/AssetProcessor/Platform/Mac/main_dummy.cpp +++ b/Code/Tools/AssetProcessor/Platform/Mac/main_dummy.cpp @@ -66,8 +66,8 @@ int main(int argc, char* argv[]) processLaunchInfo.m_environmentVariables = &envVars; processLaunchInfo.m_showWindow = true; - AzFramework::ProcessWatcher* processWatcher = AzFramework::ProcessWatcher::LaunchProcess(processLaunchInfo, AzFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_NONE); - + AZStd::unique_ptr processWatcher(AzFramework::ProcessWatcher::LaunchProcess(processLaunchInfo, AzFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_NONE)); + application.Destroy(); return 0; diff --git a/Code/Tools/AssetProcessor/native/AssetDatabase/AssetDatabase.cpp b/Code/Tools/AssetProcessor/native/AssetDatabase/AssetDatabase.cpp index 8c334c4468..4d2053c6d1 100644 --- a/Code/Tools/AssetProcessor/native/AssetDatabase/AssetDatabase.cpp +++ b/Code/Tools/AssetProcessor/native/AssetDatabase/AssetDatabase.cpp @@ -174,12 +174,6 @@ namespace AssetProcessor static const char* CREATEINDEX_TYPEOFDEPENDENCY_SOURCEDEPENDENCY = "AssetProcessor::CreateIndexTypeOfDependency_SourceDependency"; static const char* CREATEINDEX_TYPEOFDEPENDENCY_SOURCEDEPENDENCY_STATEMENT = "CREATE INDEX IF NOT EXISTS TypeOfDependency_SourceDependency ON SourceDependency (TypeOfDependency);"; - - static const char* CREATEINDEX_SCANFOLDERS_SOURCES = "AssetProcesser::CreateIndexScanFoldersSources"; - static const char* CREATEINDEX_SCANFOLDERS_SOURCES_STATEMENT = - "CREATE INDEX IF NOT EXISTS ScanFolders_Sources ON Sources (ScanFolderPK);"; - static const char* DROPINDEX_SCANFOLDERS_SOURCES_STATEMENT = - "DROP INDEX IF EXISTS ScanFolders_Sources_idx;"; static const char* CREATEINDEX_SCANFOLDERS_SOURCES_SCANFOLDER = "AssetProcesser::CreateIndexScanFoldersSourcesScanFolder"; static const char* CREATEINDEX_SCANFOLDERS_SOURCES_SCANFOLDER_STATEMENT = @@ -188,20 +182,14 @@ namespace AssetProcessor static const char* CREATEINDEX_SOURCES_JOBS = "AssetProcesser::CreateIndexSourcesJobs"; static const char* CREATEINDEX_SOURCES_JOBS_STATEMENT = "CREATE INDEX IF NOT EXISTS Sources_Jobs ON Jobs (SourcePK);"; - static const char* DROPINDEX_SOURCES_JOBS_STATEMENT = - "DROP INDEX IF EXISTS Sources_Jobs_idx;"; static const char* CREATEINDEX_JOBS_PRODUCTS = "AssetProcesser::CreateIndexJobsProducts"; static const char* CREATEINDEX_JOBS_PRODUCTS_STATEMENT = "CREATE INDEX IF NOT EXISTS Jobs_Products ON Products (JobPK);"; - static const char* DROPINDEX_JOBS_PRODUCTS_STATEMENT = - "DROP INDEX IF EXISTS Jobs_Products_idx;"; static const char* CREATEINDEX_SOURCE_NAME = "AssetProcessor::CreateIndexSourceName"; static const char* CREATEINDEX_SOURCE_NAME_STATEMENT = "CREATE INDEX IF NOT EXISTS Sources_SourceName ON Sources (SourceName);"; - static const char* DROPINDEX_SOURCE_NAME_STATEMENT = - "DROP INDEX IF EXISTS Sources_SourceName_idx;"; static const char* CREATEINDEX_SOURCE_GUID = "AssetProcessor::CreateIndexSourceGuid"; static const char* CREATEINDEX_SOURCE_GUID_STATEMENT = @@ -210,8 +198,6 @@ namespace AssetProcessor static const char* CREATEINDEX_PRODUCT_NAME = "AssetProcessor::CreateIndexProductName"; static const char* CREATEINDEX_PRODUCT_NAME_STATEMENT = "CREATE INDEX IF NOT EXISTS Products_ProductName ON Products (ProductName);"; - static const char* DROPINDEX_PRODUCT_NAME_STATEMENT = - "DROP INDEX IF EXISTS Products_ProductName_idx;"; static const char* CREATEINDEX_PRODUCT_SUBID = "AssetProcessor::CreateIndexProductSubID"; static const char* CREATEINDEX_PRODUCT_SUBID_STATEMENT = diff --git a/Code/Tools/AssetProcessor/native/AssetManager/AssetRequestHandler.h b/Code/Tools/AssetProcessor/native/AssetManager/AssetRequestHandler.h index 5ebd507685..5fcb2ca730 100644 --- a/Code/Tools/AssetProcessor/native/AssetManager/AssetRequestHandler.h +++ b/Code/Tools/AssetProcessor/native/AssetManager/AssetRequestHandler.h @@ -115,7 +115,7 @@ namespace AssetProcessor { static constexpr unsigned int MessageType = TRequest::MessageType; - m_messageHandlers[MessageType] = [this, handler = AZStd::move(handler)](MessageData messageData) + m_messageHandlers[MessageType] = [handler = AZStd::move(handler)](MessageData messageData) { MessageData downcastData = messageData; diff --git a/Code/Tools/AssetProcessor/native/InternalBuilders/SettingsRegistryBuilder.cpp b/Code/Tools/AssetProcessor/native/InternalBuilders/SettingsRegistryBuilder.cpp index 9781c200fd..7c88c4324c 100644 --- a/Code/Tools/AssetProcessor/native/InternalBuilders/SettingsRegistryBuilder.cpp +++ b/Code/Tools/AssetProcessor/native/InternalBuilders/SettingsRegistryBuilder.cpp @@ -337,7 +337,7 @@ namespace AssetProcessor // Merge the Project User and User home settings registry only in non-release builds constexpr bool executeRegDumpCommands = false; AZ::CommandLine* commandLine{}; - AZ::ComponentApplicationBus::Broadcast([®istry, &commandLine](AZ::ComponentApplicationRequests* appRequests) + AZ::ComponentApplicationBus::Broadcast([&commandLine](AZ::ComponentApplicationRequests* appRequests) { commandLine = appRequests->GetAzCommandLine(); }); diff --git a/Code/Tools/AssetProcessor/native/resourcecompiler/rcjob.cpp b/Code/Tools/AssetProcessor/native/resourcecompiler/rcjob.cpp index eacff14180..aaf6496f7b 100644 --- a/Code/Tools/AssetProcessor/native/resourcecompiler/rcjob.cpp +++ b/Code/Tools/AssetProcessor/native/resourcecompiler/rcjob.cpp @@ -22,7 +22,6 @@ namespace { - unsigned long s_jobSerial = 1; bool s_typesRegistered = false; // You have up to 60 minutes to finish processing an asset. // This was increased from 10 to account for PVRTC compression diff --git a/Code/Tools/AssetProcessor/native/tests/assetmanager/AssetProcessorManagerTest.cpp b/Code/Tools/AssetProcessor/native/tests/assetmanager/AssetProcessorManagerTest.cpp index 10ecc411ab..48a86dc5f6 100644 --- a/Code/Tools/AssetProcessor/native/tests/assetmanager/AssetProcessorManagerTest.cpp +++ b/Code/Tools/AssetProcessor/native/tests/assetmanager/AssetProcessorManagerTest.cpp @@ -3500,7 +3500,6 @@ TEST_F(AssetProcessorManagerTest, JobDependencyOrderOnce_MultipleJobs_EmitOK) using namespace AssetProcessor; using namespace AssetBuilderSDK; - AZ::Uuid dummyBuilderUUID = AZ::Uuid::CreateRandom(); QDir tempPath(m_tempDir.path()); QString watchFolderPath = tempPath.absoluteFilePath("subfolder1"); const ScanFolderInfo* scanFolder = m_config->GetScanFolderByPath(watchFolderPath); diff --git a/Code/Tools/AssetProcessor/native/tests/resourcecompiler/RCBuilderTest.cpp b/Code/Tools/AssetProcessor/native/tests/resourcecompiler/RCBuilderTest.cpp index 2465be2b33..9b2a12ecad 100644 --- a/Code/Tools/AssetProcessor/native/tests/resourcecompiler/RCBuilderTest.cpp +++ b/Code/Tools/AssetProcessor/native/tests/resourcecompiler/RCBuilderTest.cpp @@ -447,7 +447,6 @@ TEST_F(RCBuilderTest, ProcessLegacyRCJob_ProcessStandardSingleJob_Valid) TEST_F(RCBuilderTest, ProcessLegacyRCJob_ProcessCopySingleJob_Valid) { AZStd::string name = "test"; - AZ::Uuid builderUuid = AZ::Uuid::CreateRandom(); AZ::Uuid assetTypeUUid = AZ::Uuid::CreateRandom(); MockRCCompiler* mockRC = new MockRCCompiler(); TestInternalRecognizerBasedBuilder test(mockRC); @@ -506,7 +505,6 @@ TEST_F(RCBuilderTest, MatchTempFileToSkip_SkipRCFiles_false) TEST_F(RCBuilderTest, ProcessJob_ProcessStandardRCSingleJob_Valid) { - AZ::Uuid assetTypeUUid = AZ::Uuid::CreateRandom(); MockRCCompiler* mockRC = new MockRCCompiler(); TestInternalRecognizerBasedBuilder test(mockRC); MockRecognizerConfiguration configuration; @@ -536,7 +534,6 @@ TEST_F(RCBuilderTest, ProcessJob_ProcessStandardRCSingleJob_Valid) TEST_F(RCBuilderTest, ProcessJob_ProcessStandardRCSingleJob_Failed) { - AZ::Uuid assetTypeUUid = AZ::Uuid::CreateRandom(); MockRCCompiler* mockRC = new MockRCCompiler(); TestInternalRecognizerBasedBuilder test(mockRC); MockRecognizerConfiguration configuration; @@ -564,7 +561,6 @@ TEST_F(RCBuilderTest, ProcessJob_ProcessStandardRCSingleJob_Failed) TEST_F(RCBuilderTest, ProcessJob_ProcessStandardCopySingleJob_Valid) { - AZ::Uuid assetTypeUUid = AZ::Uuid::CreateRandom(); MockRCCompiler* mockRC = new MockRCCompiler(); TestInternalRecognizerBasedBuilder test(mockRC); MockRecognizerConfiguration configuration; @@ -590,7 +586,6 @@ TEST_F(RCBuilderTest, ProcessJob_ProcessStandardCopySingleJob_Valid) TEST_F(RCBuilderTest, ProcessJob_ProcessStandardSkippedSingleJob_Invalid) { - AZ::Uuid assetTypeUUid = AZ::Uuid::CreateRandom(); MockRCCompiler* mockRC = new MockRCCompiler(); TestInternalRecognizerBasedBuilder test(mockRC); MockRecognizerConfiguration configuration; diff --git a/Code/Tools/AssetProcessor/native/ui/SourceAssetTreeModel.cpp b/Code/Tools/AssetProcessor/native/ui/SourceAssetTreeModel.cpp index 1fcdd62cf7..88fbe5a204 100644 --- a/Code/Tools/AssetProcessor/native/ui/SourceAssetTreeModel.cpp +++ b/Code/Tools/AssetProcessor/native/ui/SourceAssetTreeModel.cpp @@ -87,8 +87,6 @@ namespace AssetProcessor return; } - QModelIndex newIndicesStart; - AssetTreeItem* parentItem = m_root.get(); // Use posix path separator for each child item AZ::IO::Path currentFullFolderPath(AZ::IO::PosixPathSeparator); diff --git a/Code/Tools/AssetProcessor/native/unittests/RCcontrollerUnitTests.cpp b/Code/Tools/AssetProcessor/native/unittests/RCcontrollerUnitTests.cpp index 0f5fea5eb9..5b15a6a552 100644 --- a/Code/Tools/AssetProcessor/native/unittests/RCcontrollerUnitTests.cpp +++ b/Code/Tools/AssetProcessor/native/unittests/RCcontrollerUnitTests.cpp @@ -604,14 +604,14 @@ void RCcontrollerUnitTests::RunRCControllerTests() m_rcController.m_RCJobListModel.addNewJob(jobA); bool beginWorkA = false; - QObject::connect(jobA, &RCJob::BeginWork, this, [this, &beginWorkA]() + QObject::connect(jobA, &RCJob::BeginWork, this, [&beginWorkA]() { beginWorkA = true; } ); bool jobFinishedA = false; - QObject::connect(jobA, &RCJob::JobFinished, this, [this, &jobFinishedA](AssetBuilderSDK::ProcessJobResponse /*result*/) + QObject::connect(jobA, &RCJob::JobFinished, this, [&jobFinishedA](AssetBuilderSDK::ProcessJobResponse /*result*/) { jobFinishedA = true; } @@ -655,7 +655,7 @@ void RCcontrollerUnitTests::RunRCControllerTests() ); bool jobFinishedB = false; - QObject::connect(jobB, &RCJob::JobFinished, this, [this, &jobFinishedB](AssetBuilderSDK::ProcessJobResponse /*result*/) + QObject::connect(jobB, &RCJob::JobFinished, this, [&jobFinishedB](AssetBuilderSDK::ProcessJobResponse /*result*/) { jobFinishedB = true; } diff --git a/Code/Tools/AssetProcessor/native/unittests/UtilitiesUnitTests.cpp b/Code/Tools/AssetProcessor/native/unittests/UtilitiesUnitTests.cpp index ed6fa4b8b4..bbeafda342 100644 --- a/Code/Tools/AssetProcessor/native/unittests/UtilitiesUnitTests.cpp +++ b/Code/Tools/AssetProcessor/native/unittests/UtilitiesUnitTests.cpp @@ -30,15 +30,6 @@ using namespace AssetProcessor; namespace AssetProcessor { - const char* const TEST_BOOTSTRAP_DATA = - "project_path = TestProject \r\n\ - assets = pc \r\n\ - -- ip and port of the asset processor.Only if you need to change defaults \r\n\ - -- remote_ip = 127.0.0.1 \r\n\ - windows_remote_ip = 127.0.0.7 \r\n\ - remote_port = 45645 \r\n\ - assetProcessor_branch_token = 0xDD814240"; - // simple utility class to make sure threads join and don't cause asserts // if the unit test exits early. class AutoThreadJoiner final @@ -319,13 +310,6 @@ void UtilitiesUnitTests::StartTest() // --------------- TEST FilePatternMatcher { - const char* wildcardMatch[] = { - "*.cfg", - "*.txt", - "abf*.llm" - "sdf.c*", - "a.bcd" - }; { AssetBuilderSDK::FilePatternMatcher extensionWildcardTest(AssetBuilderSDK::AssetBuilderPattern("*.cfg", AssetBuilderSDK::AssetBuilderPattern::Wildcard)); UNIT_TEST_EXPECT_TRUE(extensionWildcardTest.MatchesPath(AZStd::string("foo.cfg"))); diff --git a/Code/Tools/AssetProcessor/native/utilities/ApplicationManagerBase.cpp b/Code/Tools/AssetProcessor/native/utilities/ApplicationManagerBase.cpp index b90364e1c5..4e0bc7e434 100644 --- a/Code/Tools/AssetProcessor/native/utilities/ApplicationManagerBase.cpp +++ b/Code/Tools/AssetProcessor/native/utilities/ApplicationManagerBase.cpp @@ -1209,7 +1209,7 @@ void ApplicationManagerBase::InitFileProcessor() AssetProcessor::ThreadController* fileProcessorHelper = new AssetProcessor::ThreadController(); addRunningThread(fileProcessorHelper); - m_fileProcessor.reset(fileProcessorHelper->initialize([this, &fileProcessorHelper]() + m_fileProcessor.reset(fileProcessorHelper->initialize([this]() { return new AssetProcessor::FileProcessor(m_platformConfiguration); })); diff --git a/Code/Tools/AssetProcessor/native/utilities/PlatformConfiguration.cpp b/Code/Tools/AssetProcessor/native/utilities/PlatformConfiguration.cpp index 07106614cf..a1bc508899 100644 --- a/Code/Tools/AssetProcessor/native/utilities/PlatformConfiguration.cpp +++ b/Code/Tools/AssetProcessor/native/utilities/PlatformConfiguration.cpp @@ -681,7 +681,6 @@ namespace AssetProcessor const char AssetConfigPlatformDir[] = "AssetProcessorConfig/"; const char AssetProcessorPlatformConfigFileName[] = "AssetProcessorPlatformConfig.ini"; - const char RestrictedPlatformDir[] = "restricted"; PlatformConfiguration::PlatformConfiguration(QObject* pParent) : QObject(pParent) diff --git a/Code/Tools/AssetProcessor/native/utilities/assetUtils.cpp b/Code/Tools/AssetProcessor/native/utilities/assetUtils.cpp index 72a036bdaa..7292990a72 100644 --- a/Code/Tools/AssetProcessor/native/utilities/assetUtils.cpp +++ b/Code/Tools/AssetProcessor/native/utilities/assetUtils.cpp @@ -1399,7 +1399,6 @@ namespace AssetUtilities QString inputName; QString platformName; QString jobDescription; - AZ::Uuid guid = AZ::Uuid::CreateNull(); using namespace AzToolsFramework::AssetDatabase; diff --git a/Code/Tools/GridHub/GridHub/main.cpp b/Code/Tools/GridHub/GridHub/main.cpp index bfb82efd0d..3b853910be 100644 --- a/Code/Tools/GridHub/GridHub/main.cpp +++ b/Code/Tools/GridHub/GridHub/main.cpp @@ -361,7 +361,7 @@ public: else { // remove from start up folder - DeleteFile(fullLinkName); + DeleteFileW(fullLinkName); } #endif #if AZ_TRAIT_OS_PLATFORM_APPLE diff --git a/Code/Tools/ProjectManager/Source/ProjectsScreen.cpp b/Code/Tools/ProjectManager/Source/ProjectsScreen.cpp index 27e39926e4..aa231afef2 100644 --- a/Code/Tools/ProjectManager/Source/ProjectsScreen.cpp +++ b/Code/Tools/ProjectManager/Source/ProjectsScreen.cpp @@ -402,7 +402,7 @@ namespace O3DE::ProjectManager constexpr int waitTimeInMs = 3000; QTimer::singleShot( waitTimeInMs, this, - [this, button] + [button] { if (button) { diff --git a/Code/Tools/SceneAPI/SceneBuilder/Importers/AssImpAnimationImporter.cpp b/Code/Tools/SceneAPI/SceneBuilder/Importers/AssImpAnimationImporter.cpp index 16f8d85509..a5b286bbc6 100644 --- a/Code/Tools/SceneAPI/SceneBuilder/Importers/AssImpAnimationImporter.cpp +++ b/Code/Tools/SceneAPI/SceneBuilder/Importers/AssImpAnimationImporter.cpp @@ -652,7 +652,6 @@ namespace AZ aiAnimMesh* aiAnimMesh = mesh->mAnimMeshes[meshIdx]; AZStd::string_view nodeName(aiAnimMesh->mName.C_Str()); - const AZ::u32 maxKeys = static_cast(keys.size()); AZ::u32 keyIdx = 0; for (AZ::u32 frame = 0; frame < numKeyFrames; ++frame) { diff --git a/Code/Tools/SceneAPI/SceneBuilder/SceneSystem.cpp b/Code/Tools/SceneAPI/SceneBuilder/SceneSystem.cpp index e9117b780a..ebe907706d 100644 --- a/Code/Tools/SceneAPI/SceneBuilder/SceneSystem.cpp +++ b/Code/Tools/SceneAPI/SceneBuilder/SceneSystem.cpp @@ -105,7 +105,6 @@ namespace AZ } break; } - AZ::Matrix4x4 inverse = currentCoordMatrix.GetInverseTransform(); AZ::Matrix4x4 adjustmatrix = targetCoordMatrix * currentCoordMatrix.GetInverseTransform(); m_adjustTransform.reset(new DataTypes::MatrixType(AssImpSDKWrapper::AssImpTypeConverter::ToTransform(adjustmatrix))); m_adjustTransformInverse.reset(new DataTypes::MatrixType(m_adjustTransform->GetInverseFull())); diff --git a/Code/Tools/SceneAPI/SceneCore/Containers/Scene.h b/Code/Tools/SceneAPI/SceneCore/Containers/Scene.h index c96ebd25e1..49320c4592 100644 --- a/Code/Tools/SceneAPI/SceneCore/Containers/Scene.h +++ b/Code/Tools/SceneAPI/SceneCore/Containers/Scene.h @@ -63,7 +63,7 @@ namespace AZ SceneGraph m_graph; SceneManifest m_manifest; SceneOrientation m_originalOrientation = SceneOrientation::YUp; - AZ_POP_DISABLE_OVERRIDE_WARNING + AZ_POP_DISABLE_WARNING }; } // Containers } // SceneAPI diff --git a/Code/Tools/SceneAPI/SceneCore/Containers/SceneManifest.h b/Code/Tools/SceneAPI/SceneCore/Containers/SceneManifest.h index 00df1bca21..4386d4fd8c 100644 --- a/Code/Tools/SceneAPI/SceneCore/Containers/SceneManifest.h +++ b/Code/Tools/SceneAPI/SceneCore/Containers/SceneManifest.h @@ -106,7 +106,7 @@ namespace AZ AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") StorageLookup m_storageLookup; ValueStorage m_values; - AZ_POP_DISABLE_OVERRIDE_WARNING + AZ_POP_DISABLE_WARNING }; } // Containers } // SceneAPI diff --git a/Code/Tools/SceneAPI/SceneCore/Tests/Containers/SceneGraphTests.cpp b/Code/Tools/SceneAPI/SceneCore/Tests/Containers/SceneGraphTests.cpp index b57f284003..87e2cbdbde 100644 --- a/Code/Tools/SceneAPI/SceneCore/Tests/Containers/SceneGraphTests.cpp +++ b/Code/Tools/SceneAPI/SceneCore/Tests/Containers/SceneGraphTests.cpp @@ -332,7 +332,7 @@ namespace AZ { SceneGraph testSceneGraph; AZStd::shared_ptr testDataObject = AZStd::make_shared(); - SceneGraph::NodeIndex firstChildNodeIndex = testSceneGraph.AddChild(testSceneGraph.GetRoot(), "FirstChild", AZStd::move(testDataObject)); + testSceneGraph.AddChild(testSceneGraph.GetRoot(), "FirstChild", AZStd::move(testDataObject)); testDataObject = AZStd::make_shared(); SceneGraph::NodeIndex testNodeIndex = testSceneGraph.AddChild(testSceneGraph.GetRoot(), "SecondChild", AZStd::move(testDataObject)); @@ -350,7 +350,7 @@ namespace AZ SceneGraph::NodeIndex testRootNodeIndex = testSceneGraph.AddChild(testSceneGraph.GetRoot(), "testRoot", AZStd::move(testDataObject)); testDataObject = AZStd::make_shared(); - SceneGraph::NodeIndex firstChildNodeIndex = testSceneGraph.AddChild(testRootNodeIndex, "FirstChild", AZStd::move(testDataObject)); + testSceneGraph.AddChild(testRootNodeIndex, "FirstChild", AZStd::move(testDataObject)); testDataObject = AZStd::make_shared(); SceneGraph::NodeIndex testNodeIndex = testSceneGraph.AddChild(testRootNodeIndex, "SecondChild", AZStd::move(testDataObject)); @@ -371,10 +371,10 @@ namespace AZ SceneGraph::NodeIndex testRootNodeSiblingIndex = testSceneGraph.AddChild(testSceneGraph.GetRoot(), "testRootSibling", AZStd::move(testDataObject)); testDataObject = AZStd::make_shared(); - SceneGraph::NodeIndex firstChildNodeIndex = testSceneGraph.AddChild(testRootNodeIndex, "FirstChild", AZStd::move(testDataObject)); + testSceneGraph.AddChild(testRootNodeIndex, "FirstChild", AZStd::move(testDataObject)); testDataObject = AZStd::make_shared(); - SceneGraph::NodeIndex testNodeIndex = testSceneGraph.AddChild(testRootNodeIndex, "SecondChild", AZStd::move(testDataObject)); + testSceneGraph.AddChild(testRootNodeIndex, "SecondChild", AZStd::move(testDataObject)); SceneGraph::NodeIndex foundIndex = testSceneGraph.Find(testRootNodeSiblingIndex, "SecondChild"); EXPECT_FALSE(foundIndex.IsValid()); @@ -475,7 +475,7 @@ namespace AZ AZStd::string expectedNodeName("TestNode"); - SceneGraph::NodeIndex testNodeIndex = testSceneGraph.AddChild(testSceneGraph.GetRoot(), expectedNodeName.c_str()); + testSceneGraph.AddChild(testSceneGraph.GetRoot(), expectedNodeName.c_str()); SceneGraph::NodeIndex foundIndex = testSceneGraph.Find(expectedNodeName); ASSERT_TRUE(foundIndex.IsValid()); const SceneGraph::Name& nodeName = testSceneGraph.GetNodeName(foundIndex); diff --git a/Code/Tools/SceneAPI/SceneCore/Tests/Containers/Views/SceneGraphDownwardsIteratorTests.cpp b/Code/Tools/SceneAPI/SceneCore/Tests/Containers/Views/SceneGraphDownwardsIteratorTests.cpp index fbecbe635c..84892373bf 100644 --- a/Code/Tools/SceneAPI/SceneCore/Tests/Containers/Views/SceneGraphDownwardsIteratorTests.cpp +++ b/Code/Tools/SceneAPI/SceneCore/Tests/Containers/Views/SceneGraphDownwardsIteratorTests.cpp @@ -303,7 +303,6 @@ namespace AZ TYPED_TEST_P(SceneGraphDownwardsIteratorContext, Algorithms_FindIf_FindsValue3InNodeAdotC) { using Traversal = typename SceneGraphDownwardsIteratorContext::Traversal; - SceneGraph::NodeIndex index = this->m_graph.Find("A.C"); auto sceneView = MakeSceneGraphDownwardsView(this->m_graph, this->m_graph.GetContentStorage().begin()); auto result = AZStd::find_if(sceneView.begin(), sceneView.end(), [](const AZStd::shared_ptr& object) -> bool diff --git a/Code/Tools/SceneAPI/SceneCore/Utilities/CoordinateSystemConverter.h b/Code/Tools/SceneAPI/SceneCore/Utilities/CoordinateSystemConverter.h index 24f7243b32..11ba8cd391 100644 --- a/Code/Tools/SceneAPI/SceneCore/Utilities/CoordinateSystemConverter.h +++ b/Code/Tools/SceneAPI/SceneCore/Utilities/CoordinateSystemConverter.h @@ -55,7 +55,7 @@ namespace AZ::SceneAPI AZ::Transform m_targetTransform; AZ::Transform m_conversionTransform; AZ::Transform m_conversionTransformInversed; - AZ_POP_DISABLE_OVERRIDE_WARNING + AZ_POP_DISABLE_WARNING AZ::u32 m_targetBasisIndices[3]; bool m_needsConversion; bool m_sourceRightHanded; diff --git a/Code/Tools/SceneAPI/SceneUI/RowWidgets/TransformRowWidget.cpp b/Code/Tools/SceneAPI/SceneUI/RowWidgets/TransformRowWidget.cpp index e9d83002e9..2672555850 100644 --- a/Code/Tools/SceneAPI/SceneUI/RowWidgets/TransformRowWidget.cpp +++ b/Code/Tools/SceneAPI/SceneUI/RowWidgets/TransformRowWidget.cpp @@ -149,7 +149,7 @@ namespace AZ hider->setLayout(layout2); layoutOriginal->addWidget(hider); - connect(toolButton, &QToolButton::clicked, this, [this, hider, parentWidget, toolButton] + connect(toolButton, &QToolButton::clicked, this, [this, hider, toolButton] { m_expanded = !m_expanded; if (m_expanded) diff --git a/Code/Tools/SerializeContextTools/Converter.cpp b/Code/Tools/SerializeContextTools/Converter.cpp index 38e114855a..eff5f140d5 100644 --- a/Code/Tools/SerializeContextTools/Converter.cpp +++ b/Code/Tools/SerializeContextTools/Converter.cpp @@ -82,7 +82,7 @@ namespace AZ AZ_Printf("Convert", "Converting '%s'\n", filePath.c_str()); PathDocumentContainer documents; - auto callback = [&result, &documents, &extension, &convertSettings, &verifySettings, skipVerify] + auto callback = [&result, &documents, &convertSettings, &verifySettings, skipVerify] (void* classPtr, const Uuid& classId, SerializeContext* /*context*/) { rapidjson::Document document; @@ -346,7 +346,7 @@ namespace AZ // Convert the supplied file list to an absolute path AZStd::optional absFilePath = AZ::Utils::ConvertToAbsolutePath(configFileView); AZ::IO::FixedMaxPath configFilePath = absFilePath ? *absFilePath : configFileView; - auto callback = [&documents, &outputExtension, &configFilePath](AZ::IO::PathView configFileView, bool isFile) -> bool + auto callback = [&documents, &configFilePath](AZ::IO::PathView configFileView, bool isFile) -> bool { if (configFileView == "." || configFileView == "..") { diff --git a/Code/Tools/Standalone/Source/LUA/CodeCompletion/LUACompletionModel.cpp b/Code/Tools/Standalone/Source/LUA/CodeCompletion/LUACompletionModel.cpp index 8fadc230cd..977b7a4d29 100644 --- a/Code/Tools/Standalone/Source/LUA/CodeCompletion/LUACompletionModel.cpp +++ b/Code/Tools/Standalone/Source/LUA/CodeCompletion/LUACompletionModel.cpp @@ -130,12 +130,8 @@ namespace LUAEditor return Qt::ItemIsEnabled | Qt::ItemIsSelectable; } - QVariant CompletionModel::headerData(int section, Qt::Orientation orientation, int role) const + QVariant CompletionModel::headerData([[maybe_unused]] int section, [[maybe_unused]] Qt::Orientation orientation, [[maybe_unused]] int role) const { - section; - orientation; - role; - return QVariant(); } diff --git a/Code/Tools/Standalone/Source/LUA/LUAEditorBreakpointWidget.cpp b/Code/Tools/Standalone/Source/LUA/LUAEditorBreakpointWidget.cpp index 8cce681a74..5b47ee136a 100644 --- a/Code/Tools/Standalone/Source/LUA/LUAEditorBreakpointWidget.cpp +++ b/Code/Tools/Standalone/Source/LUA/LUAEditorBreakpointWidget.cpp @@ -67,10 +67,8 @@ namespace LUAEditor OnBreakpointLineDeleted.clear(); } - void LUAEditorBreakpointWidget::paintEvent(QPaintEvent* paintEvent) + void LUAEditorBreakpointWidget::paintEvent([[maybe_unused]] QPaintEvent* paintEvent) { - paintEvent; - QPainter p(this); auto colors = AZ::UserSettings::CreateFind(AZ_CRC("LUA Editor Text Settings", 0xb6e15565), AZ::UserSettings::CT_GLOBAL); diff --git a/Code/Tools/Standalone/Source/LUA/LUAEditorContext.cpp b/Code/Tools/Standalone/Source/LUA/LUAEditorContext.cpp index 0c9b3a1d77..1fa127dd7d 100644 --- a/Code/Tools/Standalone/Source/LUA/LUAEditorContext.cpp +++ b/Code/Tools/Standalone/Source/LUA/LUAEditorContext.cpp @@ -950,7 +950,6 @@ namespace LUAEditor newAssetName += ".lua"; } - AZ::Data::AssetType assetType = AZ::AzTypeInfo::Uuid(); AZ::Data::AssetId catalogAssetId; EBUS_EVENT_RESULT(catalogAssetId, AZ::Data::AssetCatalogRequestBus, GetAssetIdByPath, newAssetName.c_str(), AZ::AzTypeInfo::Uuid(), false); @@ -2419,7 +2418,7 @@ namespace LUAEditor std::regex errorRegex(".+\\.lua:(\\d+):(.*)"); AzToolsFramework::Logging::LogLine::ParseLog(logResult.GetValue().c_str(), logResult.GetValue().size(), - [this, &msg, ¤tAsset, &errorRegex](AzToolsFramework::Logging::LogLine& logLine) + [this, ¤tAsset, &errorRegex](AzToolsFramework::Logging::LogLine& logLine) { if ((logLine.GetLogType() == AzToolsFramework::Logging::LogLine::TYPE_WARNING) || (logLine.GetLogType() == AzToolsFramework::Logging::LogLine::TYPE_ERROR)) { diff --git a/Code/Tools/Standalone/Source/LUA/LUAEditorFindDialog.cpp b/Code/Tools/Standalone/Source/LUA/LUAEditorFindDialog.cpp index 69108a1ad2..c775ddc0ba 100644 --- a/Code/Tools/Standalone/Source/LUA/LUAEditorFindDialog.cpp +++ b/Code/Tools/Standalone/Source/LUA/LUAEditorFindDialog.cpp @@ -80,7 +80,7 @@ namespace LUAEditor auto pState = AZ::UserSettings::CreateFind(AZ_CRC("FindInCurrent", 0xba0962af), AZ::UserSettings::CT_LOCAL); m_gui->wrapCheckBox->setChecked((pState ? pState->m_findWrap : true)); - connect(m_gui->wrapCheckBox, &QCheckBox::stateChanged, this, [this](int newState) + connect(m_gui->wrapCheckBox, &QCheckBox::stateChanged, this, [](int newState) { auto pState = AZ::UserSettings::CreateFind(AZ_CRC("FindInCurrent", 0xba0962af), AZ::UserSettings::CT_LOCAL); pState->m_findWrap = (newState == Qt::Checked); @@ -350,7 +350,6 @@ namespace LUAEditor void LUAEditorFindDialog::FindInView(LUAViewWidget* pLUAViewWidget, QListWidget* pCurrentFindListView) { - pCurrentFindListView; if (!pLUAViewWidget) { return; @@ -373,8 +372,6 @@ namespace LUAEditor void LUAEditorFindDialog::FindNextInView(LUAViewWidget::FindOperation* operation, LUAViewWidget* pLUAViewWidget, QListWidget* pCurrentFindListView) { - pLUAViewWidget; - pCurrentFindListView; int line = 0; int index = 0; pLUAViewWidget->GetCursorPosition(line, index); diff --git a/Code/Tools/Standalone/Source/LUA/LUAEditorFoldingWidget.cpp b/Code/Tools/Standalone/Source/LUA/LUAEditorFoldingWidget.cpp index 98bf18e7ca..43257f66f2 100644 --- a/Code/Tools/Standalone/Source/LUA/LUAEditorFoldingWidget.cpp +++ b/Code/Tools/Standalone/Source/LUA/LUAEditorFoldingWidget.cpp @@ -31,10 +31,8 @@ namespace LUAEditor { } - void FoldingWidget::paintEvent(QPaintEvent* paintEvent) + void FoldingWidget::paintEvent([[maybe_unused]] QPaintEvent* paintEvent) { - paintEvent; - auto colors = AZ::UserSettings::CreateFind(AZ_CRC("LUA Editor Text Settings", 0xb6e15565), AZ::UserSettings::CT_GLOBAL); auto cursor = m_textEdit->textCursor(); diff --git a/Code/Tools/Standalone/Source/LUA/LUAEditorMainWindow.cpp b/Code/Tools/Standalone/Source/LUA/LUAEditorMainWindow.cpp index 45484f2815..ffbc5a445c 100644 --- a/Code/Tools/Standalone/Source/LUA/LUAEditorMainWindow.cpp +++ b/Code/Tools/Standalone/Source/LUA/LUAEditorMainWindow.cpp @@ -213,7 +213,7 @@ namespace LUAEditor auto newState = AZ::UserSettings::CreateFind(AZ_CRC("LUA EDITOR MAIN WINDOW STATE", 0xa181bc4a), AZ::UserSettings::CT_LOCAL); m_gui->actionAutoReloadUnmodifiedFiles->setChecked(newState->m_bAutoReloadUnmodifiedFiles); - connect(m_gui->actionAutoReloadUnmodifiedFiles, &QAction::triggered, this, [this](bool newValue) + connect(m_gui->actionAutoReloadUnmodifiedFiles, &QAction::triggered, this, [](bool newValue) { auto newState = AZ::UserSettings::CreateFind(AZ_CRC("LUA EDITOR MAIN WINDOW STATE", 0xa181bc4a), AZ::UserSettings::CT_LOCAL); newState->m_bAutoReloadUnmodifiedFiles = newValue; @@ -2394,7 +2394,6 @@ namespace LUAEditor // if we have any elements, the last element is top right aligned: QLayoutItem* pItem = children[children.size() - 1]; QSize lastItemSize = pItem->minimumSize(); - QPoint topRight = effectiveRect.topRight(); const int magicalRightEdgeOffset = pItem->widget()->style()->pixelMetric(QStyle::PM_ScrollBarExtent); QRect topRightCorner(effectiveRect.topRight() - QPoint(lastItemSize.width() + magicalRightEdgeOffset, 0) + QPoint(-2, 2), lastItemSize); diff --git a/Code/Tools/Standalone/Source/LUA/LUAEditorSyntaxHighlighter.cpp b/Code/Tools/Standalone/Source/LUA/LUAEditorSyntaxHighlighter.cpp index a0c4d175a7..29229d36d0 100644 --- a/Code/Tools/Standalone/Source/LUA/LUAEditorSyntaxHighlighter.cpp +++ b/Code/Tools/Standalone/Source/LUA/LUAEditorSyntaxHighlighter.cpp @@ -16,9 +16,8 @@ namespace LUAEditor namespace { template - void CreateTypes(Container& container) + void CreateTypes([[maybe_unused]] Container& container) { - container; } template @@ -44,11 +43,11 @@ namespace LUAEditor { public: virtual ~BaseParserState() {} - virtual bool IsMultilineState(LUASyntaxHighlighter::StateMachine& machine) const { (void*)&machine; return false; } - virtual void StartState(LUASyntaxHighlighter::StateMachine& machine) { (void*)&machine; } + virtual bool IsMultilineState([[maybe_unused]] LUASyntaxHighlighter::StateMachine& machine) const { return false; } + virtual void StartState([[maybe_unused]] LUASyntaxHighlighter::StateMachine& machine) {} //note you only get 13 bits of usable space here. see QTBlockState m_syntaxHighlighterStateExtra virtual AZ::u16 GetSaveState() const { return 0; } - virtual void SetSaveState(AZ::u16 state) { state; } + virtual void SetSaveState([[maybe_unused]] AZ::u16 state) {} virtual void Parse(LUASyntaxHighlighter::StateMachine& machine, const QChar& nextChar) = 0; }; @@ -87,7 +86,7 @@ namespace LUAEditor class LongCommentParserState : public BaseParserState { - bool IsMultilineState(LUASyntaxHighlighter::StateMachine& machine) const override { (void*)&machine; return true; } + bool IsMultilineState([[maybe_unused]] LUASyntaxHighlighter::StateMachine& machine) const override { return true; } void StartState(LUASyntaxHighlighter::StateMachine& machine) override; AZ::u16 GetSaveState() const override { return m_bracketLevel; } void SetSaveState(AZ::u16 state) override; @@ -341,9 +340,8 @@ namespace LUAEditor } } - void ShortCommentParserState::StartState(LUASyntaxHighlighter::StateMachine& machine) + void ShortCommentParserState::StartState([[maybe_unused]] LUASyntaxHighlighter::StateMachine& machine) { - machine; m_mightBeLong = true; } @@ -365,10 +363,8 @@ namespace LUAEditor m_endNextChar = false; } - void LongCommentParserState::Parse(LUASyntaxHighlighter::StateMachine& machine, const QChar& nextChar) + void LongCommentParserState::Parse(LUASyntaxHighlighter::StateMachine& machine, [[maybe_unused]] const QChar& nextChar) { - nextChar; - if (m_endNextChar) { machine.SetState(ParserStates::Null); diff --git a/Code/Tools/Standalone/Source/LUA/LUAEditorView.cpp b/Code/Tools/Standalone/Source/LUA/LUAEditorView.cpp index 092d3f4b8c..18d12f292c 100644 --- a/Code/Tools/Standalone/Source/LUA/LUAEditorView.cpp +++ b/Code/Tools/Standalone/Source/LUA/LUAEditorView.cpp @@ -1200,8 +1200,6 @@ namespace LUAEditor void LUAViewWidget::focusInEvent(QFocusEvent* pEvent) { - pEvent; - QWidget::focusInEvent(pEvent); m_gui->m_luaTextEdit->setFocus(); } diff --git a/Code/Tools/TestImpactFramework/Runtime/Code/Source/Artifact/Factory/TestImpactTestRunSuiteFactory.cpp b/Code/Tools/TestImpactFramework/Runtime/Code/Source/Artifact/Factory/TestImpactTestRunSuiteFactory.cpp index f5d7d3a8a2..b7a44d43ea 100644 --- a/Code/Tools/TestImpactFramework/Runtime/Code/Source/Artifact/Factory/TestImpactTestRunSuiteFactory.cpp +++ b/Code/Tools/TestImpactFramework/Runtime/Code/Source/Artifact/Factory/TestImpactTestRunSuiteFactory.cpp @@ -64,8 +64,9 @@ namespace TestImpact return !name.starts_with("DISABLED_") && name.find("/DISABLED_") == AZStd::string::npos; }; - const auto getDuration = [&Keys](const AZ::rapidxml::xml_node<>* node) + const auto getDuration = [Keys](const AZ::rapidxml::xml_node<>* node) { + AZ_UNUSED(Keys); const AZStd::string duration = node->first_attribute(Keys[DurationKey])->value(); return AZStd::chrono::milliseconds(static_cast(AZStd::stof(duration) * 1000.f)); }; @@ -78,8 +79,9 @@ namespace TestImpact for (auto testcase_node = testsuite_node->first_node(Keys[TestCaseKey]); testcase_node; testcase_node = testcase_node->next_sibling()) { - const auto getStatus = [&Keys](const AZ::rapidxml::xml_node<>* node) + const auto getStatus = [Keys](const AZ::rapidxml::xml_node<>* node) { + AZ_UNUSED(Keys); const AZStd::string status = node->first_attribute(Keys[StatusKey])->value(); if (status == Keys[RunKey]) { diff --git a/Code/Tools/TestImpactFramework/Runtime/Code/Source/Dependency/TestImpactTestSelectorAndPrioritizer.cpp b/Code/Tools/TestImpactFramework/Runtime/Code/Source/Dependency/TestImpactTestSelectorAndPrioritizer.cpp index 74d8f354bd..7aae55a20a 100644 --- a/Code/Tools/TestImpactFramework/Runtime/Code/Source/Dependency/TestImpactTestSelectorAndPrioritizer.cpp +++ b/Code/Tools/TestImpactFramework/Runtime/Code/Source/Dependency/TestImpactTestSelectorAndPrioritizer.cpp @@ -87,7 +87,7 @@ namespace TestImpact { for (const auto& parentTarget : sourceDependency.GetParentTargets()) { - AZStd::visit([&selectedTestTargetMap, &sourceDependency, this](auto&& target) + AZStd::visit([&selectedTestTargetMap, &sourceDependency](auto&& target) { if constexpr (IsProductionTarget) { @@ -129,7 +129,7 @@ namespace TestImpact { for (const auto& parentTarget : sourceDependency.GetParentTargets()) { - AZStd::visit([&selectedTestTargetMap, &sourceDependency, this](auto&& target) + AZStd::visit([&selectedTestTargetMap](auto&& target) { if constexpr (IsTestTarget) { diff --git a/Code/Tools/TestImpactFramework/Runtime/Code/Source/Process/JobRunner/TestImpactProcessJobRunner.h b/Code/Tools/TestImpactFramework/Runtime/Code/Source/Process/JobRunner/TestImpactProcessJobRunner.h index 6a898931a0..8144615aeb 100644 --- a/Code/Tools/TestImpactFramework/Runtime/Code/Source/Process/JobRunner/TestImpactProcessJobRunner.h +++ b/Code/Tools/TestImpactFramework/Runtime/Code/Source/Process/JobRunner/TestImpactProcessJobRunner.h @@ -107,7 +107,7 @@ namespace TestImpact } // Wrapper around low-level process launch callback to gather job meta-data and present a simplified callback interface to the client - const ProcessLaunchCallback processLaunchCallback = [&jobCallback, &jobInfos, &metas]( + const ProcessLaunchCallback processLaunchCallback = [&jobCallback, &metas]( TestImpact::ProcessId pid, TestImpact::LaunchResult launchResult, AZStd::chrono::high_resolution_clock::time_point createTime) @@ -126,7 +126,7 @@ namespace TestImpact }; // Wrapper around low-level process exit callback to gather job meta-data and present a simplified callback interface to the client - const ProcessExitCallback processExitCallback = [&jobCallback, &jobInfos, &metas]( + const ProcessExitCallback processExitCallback = [&jobCallback, &metas]( TestImpact::ProcessId pid, TestImpact::ExitCondition exitCondition, TestImpact::ReturnCode returnCode, diff --git a/Code/Tools/TestImpactFramework/Runtime/Code/Source/Process/Scheduler/TestImpactProcessScheduler.cpp b/Code/Tools/TestImpactFramework/Runtime/Code/Source/Process/Scheduler/TestImpactProcessScheduler.cpp index 94df662a1d..683e2bfb23 100644 --- a/Code/Tools/TestImpactFramework/Runtime/Code/Source/Process/Scheduler/TestImpactProcessScheduler.cpp +++ b/Code/Tools/TestImpactFramework/Runtime/Code/Source/Process/Scheduler/TestImpactProcessScheduler.cpp @@ -270,7 +270,6 @@ namespace TestImpact { processInFlight.m_process->Terminate(ProcessTerminateErrorCode); AccumulateProcessStdContent(processInFlight); - const ProcessId processId = processInFlight.m_process->GetProcessInfo().GetId(); if (isCallingBackToClient) { diff --git a/Code/Tools/TestImpactFramework/Runtime/Code/Source/TestEngine/Enumeration/TestImpactTestEnumerator.cpp b/Code/Tools/TestImpactFramework/Runtime/Code/Source/TestEngine/Enumeration/TestImpactTestEnumerator.cpp index 756b1c75d6..dba1053ee1 100644 --- a/Code/Tools/TestImpactFramework/Runtime/Code/Source/TestEngine/Enumeration/TestImpactTestEnumerator.cpp +++ b/Code/Tools/TestImpactFramework/Runtime/Code/Source/TestEngine/Enumeration/TestImpactTestEnumerator.cpp @@ -151,7 +151,7 @@ namespace TestImpact } */ - const auto payloadGenerator = [this](const JobDataMap& jobDataMap) + const auto payloadGenerator = [](const JobDataMap& jobDataMap) { PayloadMap enumerations; for (const auto& [jobId, jobData] : jobDataMap) diff --git a/Code/Tools/TestImpactFramework/Runtime/Code/Source/TestEngine/Run/TestImpactInstrumentedTestRunner.cpp b/Code/Tools/TestImpactFramework/Runtime/Code/Source/TestEngine/Run/TestImpactInstrumentedTestRunner.cpp index bf7e4d2c34..51a3445a53 100644 --- a/Code/Tools/TestImpactFramework/Runtime/Code/Source/TestEngine/Run/TestImpactInstrumentedTestRunner.cpp +++ b/Code/Tools/TestImpactFramework/Runtime/Code/Source/TestEngine/Run/TestImpactInstrumentedTestRunner.cpp @@ -40,7 +40,7 @@ namespace TestImpact AZStd::optional runnerTimeout, AZStd::optional clientCallback) { - const auto payloadGenerator = [this](const JobDataMap& jobDataMap) + const auto payloadGenerator = [](const JobDataMap& jobDataMap) { PayloadMap runs; for (const auto& [jobId, jobData] : jobDataMap) diff --git a/Code/Tools/TestImpactFramework/Runtime/Code/Source/TestEngine/Run/TestImpactTestRunSerializer.cpp b/Code/Tools/TestImpactFramework/Runtime/Code/Source/TestEngine/Run/TestImpactTestRunSerializer.cpp index c0ca2caeae..5e385c9c12 100644 --- a/Code/Tools/TestImpactFramework/Runtime/Code/Source/TestEngine/Run/TestImpactTestRunSerializer.cpp +++ b/Code/Tools/TestImpactFramework/Runtime/Code/Source/TestEngine/Run/TestImpactTestRunSerializer.cpp @@ -154,8 +154,6 @@ namespace TestImpact const AZStd::chrono::milliseconds suiteDuration = AZStd::chrono::milliseconds{suite[TestRunFields::Keys[TestRunFields::DurationKey]].GetUint()}; // Suite enabled - const bool enabled = suite[TestRunFields::Keys[TestRunFields::EnabledKey]].GetBool(); - testSuites.emplace_back(TestRunSuite{ suite[TestRunFields::Keys[TestRunFields::NameKey]].GetString(), suite[TestRunFields::Keys[TestRunFields::EnabledKey]].GetBool(), diff --git a/Code/Tools/TestImpactFramework/Runtime/Code/Source/TestEngine/Run/TestImpactTestRunner.cpp b/Code/Tools/TestImpactFramework/Runtime/Code/Source/TestEngine/Run/TestImpactTestRunner.cpp index a480f4aa4a..28c38d05d4 100644 --- a/Code/Tools/TestImpactFramework/Runtime/Code/Source/TestEngine/Run/TestImpactTestRunner.cpp +++ b/Code/Tools/TestImpactFramework/Runtime/Code/Source/TestEngine/Run/TestImpactTestRunner.cpp @@ -28,7 +28,7 @@ namespace TestImpact AZStd::optional runnerTimeout, AZStd::optional clientCallback) { - const auto payloadGenerator = [this](const JobDataMap& jobDataMap) + const auto payloadGenerator = [](const JobDataMap& jobDataMap) { PayloadMap runs; for (const auto& [jobId, jobData] : jobDataMap) diff --git a/Code/Tools/TestImpactFramework/Runtime/Code/Source/TestImpactRuntime.cpp b/Code/Tools/TestImpactFramework/Runtime/Code/Source/TestImpactRuntime.cpp index 515118dd7a..770a1458b8 100644 --- a/Code/Tools/TestImpactFramework/Runtime/Code/Source/TestImpactRuntime.cpp +++ b/Code/Tools/TestImpactFramework/Runtime/Code/Source/TestImpactRuntime.cpp @@ -323,7 +323,7 @@ namespace TestImpact void Runtime::EnumerateMutatedTestTargets(const ChangeDependencyList& changeDependencyList) { AZStd::vector testTargets; - const auto addMutatedTestTargetsToEnumerationList = [this, &testTargets](const AZStd::vector& sourceDependencies) + const auto addMutatedTestTargetsToEnumerationList = [&testTargets](const AZStd::vector& sourceDependencies) { for (const auto& sourceDependency : sourceDependencies) { diff --git a/Gems/AWSClientAuth/Code/Source/UserManagement/AWSCognitoUserManagementController.cpp b/Gems/AWSClientAuth/Code/Source/UserManagement/AWSCognitoUserManagementController.cpp index 19827f7013..42ee0065ad 100644 --- a/Gems/AWSClientAuth/Code/Source/UserManagement/AWSCognitoUserManagementController.cpp +++ b/Gems/AWSClientAuth/Code/Source/UserManagement/AWSCognitoUserManagementController.cpp @@ -229,7 +229,7 @@ namespace AWSClientAuth AZ::JobContext* jobContext = nullptr; AWSCore::AWSCoreRequestBus::BroadcastResult(jobContext, &AWSCore::AWSCoreRequests::GetDefaultJobContext); - AZ::Job* enableMFAJob = AZ::CreateJobFunction([this, cognitoIdentityProviderClient, accessToken]() + AZ::Job* enableMFAJob = AZ::CreateJobFunction([cognitoIdentityProviderClient, accessToken]() { Aws::CognitoIdentityProvider::Model::SetUserMFAPreferenceRequest confirmForgotPasswordRequest; Aws::CognitoIdentityProvider::Model::SMSMfaSettingsType settings; diff --git a/Gems/AWSCore/Code/Include/Public/Framework/JsonObjectHandler.h b/Gems/AWSCore/Code/Include/Public/Framework/JsonObjectHandler.h index 85461ff644..57eabe3593 100644 --- a/Gems/AWSCore/Code/Include/Public/Framework/JsonObjectHandler.h +++ b/Gems/AWSCore/Code/Include/Public/Framework/JsonObjectHandler.h @@ -67,7 +67,6 @@ namespace AWSCore AZStd::string GetContent() { - std::istream::pos_type pos = m_is.tellg(); m_is.seekg(0); std::istreambuf_iterator eos; AZStd::string content{ std::istreambuf_iterator(m_is),eos }; diff --git a/Gems/AWSCore/Code/Source/Editor/Attribution/AWSCoreAttributionManager.cpp b/Gems/AWSCore/Code/Source/Editor/Attribution/AWSCoreAttributionManager.cpp index 85dd1469cb..712c083e7a 100644 --- a/Gems/AWSCore/Code/Source/Editor/Attribution/AWSCoreAttributionManager.cpp +++ b/Gems/AWSCore/Code/Source/Editor/Attribution/AWSCoreAttributionManager.cpp @@ -298,7 +298,7 @@ namespace AWSCore { AZ::ModuleManagerRequestBus::Broadcast( &AZ::ModuleManagerRequestBus::Events::EnumerateModules, - [this, &gems](const AZ::ModuleData& moduleData) + [&gems](const AZ::ModuleData& moduleData) { AZ::Entity* moduleEntity = moduleData.GetEntity(); auto moduleEntityName = moduleEntity->GetName(); @@ -338,7 +338,7 @@ namespace AWSCore AZ_Printf("AWSAttributionManager", "AWSAttribution metric submit success"); }, - [this]([[maybe_unused]] ServiceAPI::AWSAttributionRequestJob* failJob) + []([[maybe_unused]] ServiceAPI::AWSAttributionRequestJob* failJob) { AZ_Error("AWSAttributionManager", false, "Metrics send error: %s", failJob->error.message.c_str()); }, diff --git a/Gems/AWSCore/Code/Source/Framework/HttpRequestJob.cpp b/Gems/AWSCore/Code/Source/Framework/HttpRequestJob.cpp index ee9459b9af..7c9ec045e9 100644 --- a/Gems/AWSCore/Code/Source/Framework/HttpRequestJob.cpp +++ b/Gems/AWSCore/Code/Source/Framework/HttpRequestJob.cpp @@ -42,7 +42,7 @@ namespace AWSCore // This will run the code fed to the macro, and then assign 0 to a static int (note the ,0 at the end) #define AWS_CORE_ONCE_PASTE(x) (x) -#define AWS_CORE_ONCE(x) static int AZ_JOIN(init, __LINE__)((AWS_CORE_ONCE_PASTE(x), 0)) +#define AWS_CORE_ONCE(x) [[maybe_unused]] static int AZ_JOIN(init, __LINE__)((AWS_CORE_ONCE_PASTE(x), 0)) #define AWS_CORE_HTTP_METHOD_ENTRY(x) { HttpRequestJob::HttpMethod::HTTP_##x, HttpMethodInfo{ Aws::Http::HttpMethod::HTTP_##x, #x } } diff --git a/Gems/AWSCore/Code/Tests/Editor/Attribution/AWSCoreAttributionManagerTest.cpp b/Gems/AWSCore/Code/Tests/Editor/Attribution/AWSCoreAttributionManagerTest.cpp index b8f7688ac6..37a8c0f6d4 100644 --- a/Gems/AWSCore/Code/Tests/Editor/Attribution/AWSCoreAttributionManagerTest.cpp +++ b/Gems/AWSCore/Code/Tests/Editor/Attribution/AWSCoreAttributionManagerTest.cpp @@ -211,7 +211,6 @@ namespace AWSAttributionUnitTest m_localFileIO->ResolvePath("@user@/Registry/", m_resolvedSettingsPath.data(), m_resolvedSettingsPath.size()); AZ::IO::SystemFile::DeleteDir(m_resolvedSettingsPath.data()); - delete AZ::IO::FileIOBase::GetInstance(); AZ::IO::FileIOBase::SetInstance(nullptr); AWSCoreFixture::TearDown(); diff --git a/Gems/AWSCore/Code/Tests/ResourceMapping/AWSResourceMappingManagerTest.cpp b/Gems/AWSCore/Code/Tests/ResourceMapping/AWSResourceMappingManagerTest.cpp index 557fbc820c..91d85c2f99 100644 --- a/Gems/AWSCore/Code/Tests/ResourceMapping/AWSResourceMappingManagerTest.cpp +++ b/Gems/AWSCore/Code/Tests/ResourceMapping/AWSResourceMappingManagerTest.cpp @@ -30,8 +30,6 @@ static constexpr const char TEST_EXPECTED_BUCKET_TYPE[] = "AWS::S3::Bucket"; static constexpr const char TEST_EXPECTED_BUCKET_NAMEID[] = "MyTestS3Bucket"; static constexpr const char TEST_EXPECTED_SERVICE_KEYNAME[] = "TestService"; -static constexpr const char TEST_EXPECTED_RESTAPI_ID_KEYNAME[] = "TestService.RESTApiId"; -static constexpr const char TEST_EXPECTED_RESTAPI_STAGE_KEYNAME[] = "TestService.RESTApiStage"; static constexpr const char TEST_VALID_RESOURCE_MAPPING_CONFIG_FILE[] = R"({ diff --git a/Gems/AWSCore/Code/Tests/TestFramework/AWSCoreFixture.h b/Gems/AWSCore/Code/Tests/TestFramework/AWSCoreFixture.h index 0595353b6e..9d33d96215 100644 --- a/Gems/AWSCore/Code/Tests/TestFramework/AWSCoreFixture.h +++ b/Gems/AWSCore/Code/Tests/TestFramework/AWSCoreFixture.h @@ -130,10 +130,11 @@ public: m_settingsRegistry.reset(); AZ::IO::FileIOBase::SetInstance(nullptr); - + + delete m_localFileIO; + if (m_otherFileIO) { - delete m_localFileIO; AZ::IO::FileIOBase::SetInstance(m_otherFileIO); } diff --git a/Gems/AWSGameLift/Code/AWSGameLiftServer/Tests/AWSGameLiftServerManagerTest.cpp b/Gems/AWSGameLift/Code/AWSGameLiftServer/Tests/AWSGameLiftServerManagerTest.cpp index a0b8f2e495..e0a7caba24 100644 --- a/Gems/AWSGameLift/Code/AWSGameLiftServer/Tests/AWSGameLiftServerManagerTest.cpp +++ b/Gems/AWSGameLift/Code/AWSGameLiftServer/Tests/AWSGameLiftServerManagerTest.cpp @@ -398,7 +398,6 @@ namespace UnitTest .WillOnce(Return(successOutcome)); AZStd::vector testThreadPool; - AZStd::atomic trueCount = 0; AZ_TEST_START_TRACE_SUPPRESSION; for (int index = 0; index < testThreadNumber; index++) { diff --git a/Gems/AWSMetrics/Code/Tests/MetricsManagerTest.cpp b/Gems/AWSMetrics/Code/Tests/MetricsManagerTest.cpp index 2d9990ad1e..3f87a1079d 100644 --- a/Gems/AWSMetrics/Code/Tests/MetricsManagerTest.cpp +++ b/Gems/AWSMetrics/Code/Tests/MetricsManagerTest.cpp @@ -290,7 +290,7 @@ namespace AWSMetrics for (int index = 0; index < MaxNumMetricsEvents; ++index) { - producers.emplace_back(AZStd::thread([this, index]() + producers.emplace_back(AZStd::thread([index]() { AZStd::vector metricsAttributes; metricsAttributes.emplace_back(AZStd::move(MetricsAttribute(AwsMetricsAttributeKeyEventName, AttrValue))); diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Compressors/ETC2.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Compressors/ETC2.cpp index 9c002952be..0c3d6dca3d 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Compressors/ETC2.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Compressors/ETC2.cpp @@ -115,8 +115,6 @@ namespace ImageProcessingAtom IImageObjectPtr ETC2Compressor::CompressImage(IImageObjectPtr srcImage, EPixelFormat fmtDst, const CompressOption* compressOption) const { - const size_t srcPixelSize = 4; - //validate input EPixelFormat fmtSrc = srcImage->GetPixelFormat(); diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Converters/ColorChart.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Converters/ColorChart.cpp index 0b06e00a9f..b6e9cf4c8c 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Converters/ColorChart.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Converters/ColorChart.cpp @@ -133,7 +133,6 @@ namespace ImageProcessingAtom IImageObjectPtr C3dLutColorChart::GenerateChartImage() { - const AZ::u32 mipCount = 1; IImageObjectPtr image(IImageObject::CreateImage(ePS_Red* ePS_Blue, ePS_Green, 1, ePixelFormat_R8G8B8A8)); { diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Converters/FIR-Filter.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Converters/FIR-Filter.cpp index 0bfdf6d672..0387ec5c7b 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Converters/FIR-Filter.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Converters/FIR-Filter.cpp @@ -209,18 +209,18 @@ namespace ImageProcessingAtom /* addition of c-pointers already takes care of datatype-sizes */ \ const signed long int dy = /*parm->mirror ? -1 :*/ 1; \ const unsigned int stridei = parm->incols * 1 * 1; \ - const unsigned int stridet = parm->subcols * 1 * 1; \ - const unsigned int strideo = parm->outcols * 1 * 1; \ + [[maybe_unused]] const unsigned int stridet = parm->subcols * 1 * 1; \ + [[maybe_unused]] const unsigned int strideo = parm->outcols * 1 * 1; \ /* offset and shift calculations still require the unmodified values */ \ const unsigned int strideiraw = parm->incols; \ - const unsigned int stridetraw = parm->subcols; \ + [[maybe_unused]] const unsigned int stridetraw = parm->subcols; \ const unsigned int strideoraw = parm->outcols; \ \ class Plane2D tmp(tmpcols, tmprows, 4); \ dtyp*** t = (dtyp***)tmp; \ int srcPos, dstPos; \ - bool plusminush = false; const bool of = true; \ - bool plusminusv = false; const bool nc = false; \ + bool plusminush = false; [[maybe_unused]] const bool of = true; \ + bool plusminusv = false; [[maybe_unused]] const bool nc = false; \ FilterWeights* fwh = calculateFilterWeights(parm->resample.colrem, parm->caged ? 0 : 0 - parm->region.subtop, parm->caged ? srccols : parm->subrows - parm->region.subtop, \ parm->resample.colquo, 0, dstcols, reps, parm->resample.colblur, parm->resample.wf, parm->resample.operation != eWindowEvaluation_Sum, plusminush); \ FilterWeights* fwv = calculateFilterWeights(parm->resample.rowrem, parm->caged ? 0 : 0 - parm->region.intop, parm->caged ? srcrows : parm->inrows - parm->region.intop, \ @@ -833,7 +833,7 @@ namespace ImageProcessingAtom #define filterRowFetch(srcOffs, srcSize, srcSkip, dstOffs, dstSize, dstSkip) \ /* vertical stride, horizontal fetch */ \ - getCxNFromStreamSwapped(srcSkip, i); \ + /* getCxNFromStreamSwapped(srcSkip, i); Expands to nothing */ \ getCxNFromStream(srcSkip, i); \ getCxNFromPlane(1); \ \ @@ -935,7 +935,7 @@ namespace ImageProcessingAtom comcpyCHistogram(); \ \ /* horizontal stride, vertical store */ \ - putCxNToStreamSwapped(dstSkip, o); \ + /* putCxNToStreamSwapped(dstSkip, o); Expands to nothing */ \ putCxNToStream(dstSkip, o); \ putCxNToPlane(1); \ \ diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Converters/HighPass.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Converters/HighPass.cpp index eefd5332be..e2071fb586 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Converters/HighPass.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Converters/HighPass.cpp @@ -58,9 +58,6 @@ namespace ImageProcessingAtom // linear interpolation FilterImage(MipGenType::triangle, MipGenEvalType::sum, 0.0f, 0.0f, m_img, dwMipDown, newImage, dstMip, NULL, NULL); - const AZ::u32 pixelCountIn = m_img->GetWidth(dstMip) * m_img->GetHeight(dstMip); - const AZ::u32 pixelCountOut = newImage->GetWidth(dstMip) * newImage->GetHeight(dstMip); - //substraction AZ::u8* srcPixelBuf; AZ::u32 srcPitch; diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Editor/EditorCommon.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Editor/EditorCommon.cpp index 8ce8b2d487..c6f1398703 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Editor/EditorCommon.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Editor/EditorCommon.cpp @@ -103,6 +103,10 @@ namespace ImageProcessingAtomEditor { readableString = "PC"; } + else if (platformStrLowerCase == "linux") + { + readableString = "Linux"; + } else if (platformStrLowerCase == "android") { readableString = "Android"; diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/ImageLoader/DdsLoader.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/ImageLoader/DdsLoader.cpp index b9054a9911..20367227bd 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/ImageLoader/DdsLoader.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/ImageLoader/DdsLoader.cpp @@ -87,7 +87,7 @@ namespace ImageProcessingAtom if (dxgiFormat != DXGI_FORMAT_UNKNOWN) { int i = 0; - for (i; i < ePixelFormat_Count; i++) + for (; i < ePixelFormat_Count; i++) { const PixelFormatInfo* info = CPixelFormats::GetInstance().GetPixelFormatInfo((EPixelFormat)i); if (static_cast(info->d3d10Format) == dxgiFormat) @@ -506,7 +506,7 @@ namespace ImageProcessingAtom if (dxgiFormat != DXGI_FORMAT_UNKNOWN) { uint32_t i = 0; - for (i; i < ePixelFormat_Count; i++) + for (; i < ePixelFormat_Count; i++) { const PixelFormatInfo* info = CPixelFormats::GetInstance().GetPixelFormatInfo((EPixelFormat)i); if (static_cast(info->d3d10Format) == dxgiFormat) diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Platform/Linux/ImageProcessing_Traits_Linux.h b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Platform/Linux/ImageProcessing_Traits_Linux.h index b4efe031fd..19b7621f8a 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Platform/Linux/ImageProcessing_Traits_Linux.h +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Platform/Linux/ImageProcessing_Traits_Linux.h @@ -8,7 +8,7 @@ #pragma once #define AZ_TRAIT_IMAGEPROCESSING_BESSEL_FUNCTION_FIRST_ORDER j1 -#define AZ_TRAIT_IMAGEPROCESSING_DEFAULT_PLATFORM "pc" +#define AZ_TRAIT_IMAGEPROCESSING_DEFAULT_PLATFORM "linux" #define AZ_TRAIT_IMAGEPROCESSING_DEFINE_DIRECT3D_CONSTANTS 0 #define AZ_TRAIT_IMAGEPROCESSING_PVRTEXLIB_USE_WINDLL_IMPORT 0 #define AZ_TRAIT_IMAGEPROCESSING_SQUISH_DO_NOT_USE_FASTCALL 1 diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageConvert.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageConvert.cpp index 9abb6de300..3f28e89334 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageConvert.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageConvert.cpp @@ -603,8 +603,6 @@ namespace ImageProcessingAtom const bool isCompressing = isSourceFormatUncompressed ? true : false; const EPixelFormat outputFormat = isCompressing ? destinationFormat : sourceFormat; - const uint32_t imageWidth = m_image->Get()->GetWidth(0); - const uint32_t imageHeight = m_image->Get()->GetHeight(0); ICompressorPtr compressor = ICompressor::FindCompressor(outputFormat, m_input->m_presetSetting.m_destColorSpace, isCompressing); // find out if the compressor has a preference to any specific colorspace diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageObjectImpl.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageObjectImpl.cpp index fd3923d7bf..8504f5e074 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageObjectImpl.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Processing/ImageObjectImpl.cpp @@ -241,8 +241,6 @@ namespace ImageProcessingAtom // clone this image-object's contents IImageObject* CImageObject::Clone(uint32_t maxMipCount) const { - const EPixelFormat srcPixelformat = GetPixelFormat(); - IImageObject* outImage = AllocateImage(maxMipCount); AZ::u32 mips = outImage->GetMipCount(); diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Thumbnail/ImageThumbnailSystemComponent.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Thumbnail/ImageThumbnailSystemComponent.cpp index 7e4d29e23c..5a41411d86 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Thumbnail/ImageThumbnailSystemComponent.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Thumbnail/ImageThumbnailSystemComponent.cpp @@ -180,7 +180,7 @@ namespace ImageProcessingAtom // Dispatch event on main thread AZ::SystemTickBus::QueueFunction( [ - thumbnailKey, thumbnailSize, + thumbnailKey, pixmap = QPixmap::fromImage(image.scaled(QSize(thumbnailSize, thumbnailSize), Qt::KeepAspectRatio, Qt::SmoothTransformation)) ]() mutable { diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Tests/ImageProcessing_Test.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Tests/ImageProcessing_Test.cpp index 6395913f7a..20aa1e927d 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Tests/ImageProcessing_Test.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Tests/ImageProcessing_Test.cpp @@ -928,7 +928,7 @@ namespace UnitTest PlatformNameList platforms = BuilderSettingManager::Instance()->GetPlatformList(); #ifndef AZ_TOOLS_EXPAND_FOR_RESTRICTED_PLATFORMS - ASSERT_TRUE(platforms.size() == 4); + EXPECT_THAT(platforms, testing::UnorderedPointwise(testing::Eq(), {"pc", "linux", "mac", "ios", "android"})); #endif //AZ_TOOLS_EXPAND_FOR_RESTRICTED_PLATFORMS } diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Config/ImageBuilder.settings b/Gems/Atom/Asset/ImageProcessingAtom/Config/ImageBuilder.settings index 82a57dd614..c513e05a97 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Config/ImageBuilder.settings +++ b/Gems/Atom/Asset/ImageProcessingAtom/Config/ImageBuilder.settings @@ -29,6 +29,12 @@ "Streaming": false, "Enable": true }, + "linux": { + "GlossScale": 16.0, + "GlossBias": 0.0, + "Streaming": false, + "Enable": true + }, "provo": { "GlossScale": 16.0, "GlossBias": 0.0, diff --git a/Gems/Atom/Asset/Shader/Code/Source/Editor/AzslShaderBuilderSystemComponent.cpp b/Gems/Atom/Asset/Shader/Code/Source/Editor/AzslShaderBuilderSystemComponent.cpp index 16cebef6ac..cacb310918 100644 --- a/Gems/Atom/Asset/Shader/Code/Source/Editor/AzslShaderBuilderSystemComponent.cpp +++ b/Gems/Atom/Asset/Shader/Code/Source/Editor/AzslShaderBuilderSystemComponent.cpp @@ -81,7 +81,7 @@ namespace AZ // Register Shader Asset Builder AssetBuilderSDK::AssetBuilderDesc shaderAssetBuilderDescriptor; shaderAssetBuilderDescriptor.m_name = "Shader Asset Builder"; - shaderAssetBuilderDescriptor.m_version = 103; // ATOM-15058 + shaderAssetBuilderDescriptor.m_version = 104; // ATOM-15871 // .shader file changes trigger rebuilds shaderAssetBuilderDescriptor.m_patterns.push_back(AssetBuilderSDK::AssetBuilderPattern( AZStd::string::format("*.%s", RPI::ShaderSourceData::Extension), AssetBuilderSDK::AssetBuilderPattern::PatternType::Wildcard)); shaderAssetBuilderDescriptor.m_busId = azrtti_typeid(); @@ -96,7 +96,7 @@ namespace AZ shaderVariantAssetBuilderDescriptor.m_name = "Shader Variant Asset Builder"; // Both "Shader Variant Asset Builder" and "Shader Asset Builder" produce ShaderVariantAsset products. If you update // ShaderVariantAsset you will need to update BOTH version numbers, not just "Shader Variant Asset Builder". - shaderVariantAssetBuilderDescriptor.m_version = 24; // ATOM-15978 + shaderVariantAssetBuilderDescriptor.m_version = 25; // ATOM-15871 shaderVariantAssetBuilderDescriptor.m_patterns.push_back(AssetBuilderSDK::AssetBuilderPattern(AZStd::string::format("*.%s", RPI::ShaderVariantListSourceData::Extension), AssetBuilderSDK::AssetBuilderPattern::PatternType::Wildcard)); shaderVariantAssetBuilderDescriptor.m_busId = azrtti_typeid(); shaderVariantAssetBuilderDescriptor.m_createJobFunction = AZStd::bind(&ShaderVariantAssetBuilder::CreateJobs, &m_shaderVariantAssetBuilder, AZStd::placeholders::_1, AZStd::placeholders::_2); diff --git a/Gems/Atom/Asset/Shader/Code/Source/Editor/CommonFiles/Preprocessor.cpp b/Gems/Atom/Asset/Shader/Code/Source/Editor/CommonFiles/Preprocessor.cpp index 1f96ee2a48..fe1fd99f4e 100644 --- a/Gems/Atom/Asset/Shader/Code/Source/Editor/CommonFiles/Preprocessor.cpp +++ b/Gems/Atom/Asset/Shader/Code/Source/Editor/CommonFiles/Preprocessor.cpp @@ -154,7 +154,8 @@ namespace AZ // Remark: for MacOS & Linux it is important to call va_start again before // each call to azvsnprintf. Not required for Windows. va_start(args, format); - count = azvscprintf(format, args) + 1; // vscprintf returns a size that doesn't include the null character. + count = azvscprintf(format, args); + count += 1; // vscprintf returns a size that doesn't include the null character. va_end(args); biggerData.reset(new char[count]); diff --git a/Gems/Atom/Asset/Shader/Code/Source/Editor/ShaderAssetBuilder.cpp b/Gems/Atom/Asset/Shader/Code/Source/Editor/ShaderAssetBuilder.cpp index 87eb6dc97d..8ec7733d07 100644 --- a/Gems/Atom/Asset/Shader/Code/Source/Editor/ShaderAssetBuilder.cpp +++ b/Gems/Atom/Asset/Shader/Code/Source/Editor/ShaderAssetBuilder.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include "AzslCompiler.h" #include "ShaderVariantAssetBuilder.h" @@ -236,7 +237,9 @@ namespace AZ void ShaderAssetBuilder::ProcessJob(const AssetBuilderSDK::ProcessJobRequest& request, AssetBuilderSDK::ProcessJobResponse& response) const { - const AZStd::sys_time_t startTime = AZStd::GetTimeNowTicks(); + AZ::Debug::Timer timer; + timer.Stamp(); + AZStd::string shaderFullPath; AzFramework::StringFunc::Path::ConstructFull(request.m_watchFolder.c_str(), request.m_sourceFile.c_str(), shaderFullPath, true); // Save .shader file name (no extension and no parent directory path) @@ -579,7 +582,7 @@ namespace AZ request.m_platformInfo, buildOptions.m_compilerArguments, request.m_tempDirPath, - startTime, + shaderAssetBuildTimestamp, shaderSourceData, *shaderOptionGroupLayout.get(), shaderEntryPoints, @@ -660,12 +663,8 @@ namespace AZ } response.m_resultCode = AssetBuilderSDK::ProcessJobResult_Success; - - const AZStd::sys_time_t endTime = AZStd::GetTimeNowTicks(); - const AZStd::sys_time_t deltaTime = endTime - startTime; - const float elapsedTimeSeconds = (float)(deltaTime) / (float)AZStd::GetTimeTicksPerSecond(); - - AZ_TracePrintf(ShaderAssetBuilderName, "Finished processing %s in %.2f seconds\n", request.m_sourceFile.c_str(), elapsedTimeSeconds); + + AZ_TracePrintf(ShaderAssetBuilderName, "Finished processing %s in %.3f seconds\n", request.m_sourceFile.c_str(), timer.GetDeltaTimeInSeconds()); ShaderBuilderUtility::LogProfilingData(ShaderAssetBuilderName, shaderFileName); } diff --git a/Gems/Atom/Asset/Shader/Code/Source/Editor/ShaderBuilderUtility.cpp b/Gems/Atom/Asset/Shader/Code/Source/Editor/ShaderBuilderUtility.cpp index 5a30cc344d..88abf92e54 100644 --- a/Gems/Atom/Asset/Shader/Code/Source/Editor/ShaderBuilderUtility.cpp +++ b/Gems/Atom/Asset/Shader/Code/Source/Editor/ShaderBuilderUtility.cpp @@ -521,7 +521,7 @@ namespace AZ { // Search the function name into the list of valid entry points into the shader. auto findId = - AZStd::find_if(shaderEntryPoints.begin(), shaderEntryPoints.end(), [&functionName, &mask](const auto& item) { + AZStd::find_if(shaderEntryPoints.begin(), shaderEntryPoints.end(), [&functionName](const auto& item) { return item.first == functionName; }); diff --git a/Gems/Atom/Asset/Shader/Code/Source/Editor/ShaderVariantAssetBuilder.cpp b/Gems/Atom/Asset/Shader/Code/Source/Editor/ShaderVariantAssetBuilder.cpp index 0e995992b9..5dc1267dbb 100644 --- a/Gems/Atom/Asset/Shader/Code/Source/Editor/ShaderVariantAssetBuilder.cpp +++ b/Gems/Atom/Asset/Shader/Code/Source/Editor/ShaderVariantAssetBuilder.cpp @@ -743,7 +743,6 @@ namespace AZ void ShaderVariantAssetBuilder::ProcessShaderVariantJob(const AssetBuilderSDK::ProcessJobRequest& request, AssetBuilderSDK::ProcessJobResponse& response) const { - const AZStd::sys_time_t startTime = AZStd::GetTimeNowTicks(); AssetBuilderSDK::JobCancelListener jobCancelListener(request.m_jobId); AZStd::string fullPath; @@ -777,6 +776,8 @@ namespace AZ response.m_resultCode = AssetBuilderSDK::ProcessJobResult_Success; return; } + + const AZStd::sys_time_t shaderVariantAssetBuildTimestamp = AZStd::GetTimeNowMicroSecond(); auto supervariantList = ShaderBuilderUtility::GetSupervariantListFromShaderSourceData(shaderSourceDescriptor); @@ -911,7 +912,7 @@ namespace AZ ShaderVariantCreationContext shaderVariantCreationContext = { *shaderPlatformInterface, request.m_platformInfo, buildOptions.m_compilerArguments, request.m_tempDirPath, - startTime, + shaderVariantAssetBuildTimestamp, shaderSourceDescriptor, *shaderOptionGroupLayout.get(), shaderEntryPoints, diff --git a/Gems/Atom/Asset/Shader/Code/Source/Editor/SrgLayoutUtility.cpp b/Gems/Atom/Asset/Shader/Code/Source/Editor/SrgLayoutUtility.cpp index dba95741ad..cb3318128e 100644 --- a/Gems/Atom/Asset/Shader/Code/Source/Editor/SrgLayoutUtility.cpp +++ b/Gems/Atom/Asset/Shader/Code/Source/Editor/SrgLayoutUtility.cpp @@ -15,8 +15,6 @@ namespace AZ { namespace SrgLayoutUtility { - static constexpr char SrgLayoutUtilityName[] = "SrgLayoutUtility"; - RHI::ShaderInputImageType ToShaderInputImageType(TextureType textureType) { switch (textureType) diff --git a/Gems/Atom/Component/DebugCamera/Code/Source/CameraComponent.cpp b/Gems/Atom/Component/DebugCamera/Code/Source/CameraComponent.cpp index 217cf0f061..ca62918aa3 100644 --- a/Gems/Atom/Component/DebugCamera/Code/Source/CameraComponent.cpp +++ b/Gems/Atom/Component/DebugCamera/Code/Source/CameraComponent.cpp @@ -257,8 +257,8 @@ namespace AZ void CameraComponent::OnViewportResized(uint32_t width, uint32_t height) { - AZ_UNUSED(width) - AZ_UNUSED(height) + AZ_UNUSED(width); + AZ_UNUSED(height); UpdateAspectRatio(); UpdateViewToClipMatrix(); } diff --git a/Gems/Atom/Component/DebugCamera/Code/Source/NoClipControllerComponent.cpp b/Gems/Atom/Component/DebugCamera/Code/Source/NoClipControllerComponent.cpp index b2d2a4bb15..d9979c455b 100644 --- a/Gems/Atom/Component/DebugCamera/Code/Source/NoClipControllerComponent.cpp +++ b/Gems/Atom/Component/DebugCamera/Code/Source/NoClipControllerComponent.cpp @@ -388,9 +388,9 @@ namespace AZ m_properties = properties; } - void NoClipControllerComponent::SetTouchSensitivity([[maybe_unused]] float touchSensitivity) + void NoClipControllerComponent::SetTouchSensitivity(float touchSensitivity) { - m_properties.m_touchSensitivity; + m_properties.m_touchSensitivity = touchSensitivity; } void NoClipControllerComponent::SetPosition(AZ::Vector3 position) diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridBlendDistance.precompiledshader b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridBlendDistance.precompiledshader index 0322f750a4..be1d87ff3e 100644 --- a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridBlendDistance.precompiledshader +++ b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridBlendDistance.precompiledshader @@ -7,7 +7,7 @@ "ShaderAssetFileName": "diffuseprobegridblenddistance.azshader", "PlatformIdentifiers": [ - "pc" + "pc", "linux" ], "RootShaderVariantAssets": [ diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridBlendIrradiance.precompiledshader b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridBlendIrradiance.precompiledshader index f6b19e6f5b..92fb12d5cc 100644 --- a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridBlendIrradiance.precompiledshader +++ b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridBlendIrradiance.precompiledshader @@ -7,7 +7,7 @@ "ShaderAssetFileName": "diffuseprobegridblendirradiance.azshader", "PlatformIdentifiers": [ - "pc" + "pc", "linux" ], "RootShaderVariantAssets": [ diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridBorderUpdateColumn.precompiledshader b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridBorderUpdateColumn.precompiledshader index e9ab96b088..8de77320f0 100644 --- a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridBorderUpdateColumn.precompiledshader +++ b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridBorderUpdateColumn.precompiledshader @@ -7,7 +7,7 @@ "ShaderAssetFileName": "diffuseprobegridborderupdatecolumn.azshader", "PlatformIdentifiers": [ - "pc" + "pc", "linux" ], "RootShaderVariantAssets": [ diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridBorderUpdateRow.precompiledshader b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridBorderUpdateRow.precompiledshader index bbfd19ce48..274dae91af 100644 --- a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridBorderUpdateRow.precompiledshader +++ b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridBorderUpdateRow.precompiledshader @@ -7,7 +7,7 @@ "ShaderAssetFileName": "diffuseprobegridborderupdaterow.azshader", "PlatformIdentifiers": [ - "pc" + "pc", "linux" ], "RootShaderVariantAssets": [ diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridClassification.precompiledshader b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridClassification.precompiledshader index 75fbd1d7a3..85f75e6364 100644 --- a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridClassification.precompiledshader +++ b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridClassification.precompiledshader @@ -7,7 +7,7 @@ "ShaderAssetFileName": "diffuseprobegridclassification.azshader", "PlatformIdentifiers": [ - "pc" + "pc", "linux" ], "RootShaderVariantAssets": [ diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridRayTracing.precompiledshader b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridRayTracing.precompiledshader index a9f75bff7d..88aa115b63 100644 --- a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridRayTracing.precompiledshader +++ b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridRayTracing.precompiledshader @@ -7,7 +7,7 @@ "ShaderAssetFileName": "diffuseprobegridraytracing.azshader", "PlatformIdentifiers": [ - "pc" + "pc", "linux" ], "RootShaderVariantAssets": [ diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridRayTracingClosestHit.precompiledshader b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridRayTracingClosestHit.precompiledshader index 15fb9ecf52..948fc793ab 100644 --- a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridRayTracingClosestHit.precompiledshader +++ b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridRayTracingClosestHit.precompiledshader @@ -7,7 +7,7 @@ "ShaderAssetFileName": "diffuseprobegridraytracingclosesthit.azshader", "PlatformIdentifiers": [ - "pc" + "pc", "linux" ], "RootShaderVariantAssets": [ diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridRayTracingMiss.precompiledshader b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridRayTracingMiss.precompiledshader index 38bb7e3de0..dec0e244b1 100644 --- a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridRayTracingMiss.precompiledshader +++ b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridRayTracingMiss.precompiledshader @@ -7,7 +7,7 @@ "ShaderAssetFileName": "diffuseprobegridraytracingmiss.azshader", "PlatformIdentifiers": [ - "pc" + "pc", "linux" ], "RootShaderVariantAssets": [ diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridRelocation.precompiledshader b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridRelocation.precompiledshader index 3517cd7955..e09a29a7e8 100644 --- a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridRelocation.precompiledshader +++ b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridRelocation.precompiledshader @@ -7,7 +7,7 @@ "ShaderAssetFileName": "diffuseprobegridrelocation.azshader", "PlatformIdentifiers": [ - "pc" + "pc", "linux" ], "RootShaderVariantAssets": [ diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridRender.precompiledshader b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridRender.precompiledshader index 29f9476ceb..279deaaa29 100644 --- a/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridRender.precompiledshader +++ b/Gems/Atom/Feature/Common/Assets/Shaders/DiffuseGlobalIllumination/DiffuseProbeGridRender.precompiledshader @@ -7,7 +7,7 @@ "ShaderAssetFileName": "diffuseprobegridrender.azshader", "PlatformIdentifiers": [ - "pc" + "pc", "linux" ], "RootShaderVariantAssets": [ diff --git a/Gems/Atom/Feature/Common/Assets/Textures/PostProcessing/AreaTex.dds.assetinfo b/Gems/Atom/Feature/Common/Assets/Textures/PostProcessing/AreaTex.dds.assetinfo index 72a7948174..4462730464 100644 --- a/Gems/Atom/Feature/Common/Assets/Textures/PostProcessing/AreaTex.dds.assetinfo +++ b/Gems/Atom/Feature/Common/Assets/Textures/PostProcessing/AreaTex.dds.assetinfo @@ -62,6 +62,14 @@ + + + + + + + + diff --git a/Gems/Atom/Feature/Common/Assets/Textures/PostProcessing/SearchTex.dds.assetinfo b/Gems/Atom/Feature/Common/Assets/Textures/PostProcessing/SearchTex.dds.assetinfo index 86d698d24e..0f6348f410 100644 --- a/Gems/Atom/Feature/Common/Assets/Textures/PostProcessing/SearchTex.dds.assetinfo +++ b/Gems/Atom/Feature/Common/Assets/Textures/PostProcessing/SearchTex.dds.assetinfo @@ -62,6 +62,14 @@ + + + + + + + + diff --git a/Gems/Atom/Feature/Common/Code/Source/AuxGeom/DynamicPrimitiveProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/AuxGeom/DynamicPrimitiveProcessor.cpp index 10d1bdc2c6..f35809f148 100644 --- a/Gems/Atom/Feature/Common/Code/Source/AuxGeom/DynamicPrimitiveProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/AuxGeom/DynamicPrimitiveProcessor.cpp @@ -27,9 +27,6 @@ namespace AZ { namespace { - // the max size of a vertex buffer - static const size_t MaxUploadBufferSize = MaxDynamicVertexCount * sizeof(AuxGeomDynamicVertex); - static const RHI::PrimitiveTopology PrimitiveTypeToTopology[PrimitiveType_Count] = { RHI::PrimitiveTopology::PointList, diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/DirectionalLightFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/CoreLights/DirectionalLightFeatureProcessor.cpp index 6a418117fc..0d089a26bf 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/DirectionalLightFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/DirectionalLightFeatureProcessor.cpp @@ -471,7 +471,7 @@ namespace AZ const RPI::RenderPipelineId& renderPipelineId) { ShadowProperty& property = m_shadowProperties.GetData(handle.GetIndex()); - auto update = [this, handle, &property, &baseCameraConfiguration](const RPI::View* view) + auto update = [&property, &baseCameraConfiguration](const RPI::View* view) { CascadeShadowCameraConfiguration& cameraConfig = property.m_cameraConfigurations[view]; if (!cameraConfig.HasSameConfiguration(baseCameraConfiguration)) diff --git a/Gems/Atom/Feature/Common/Code/Source/Decals/AsyncLoadTracker.h b/Gems/Atom/Feature/Common/Code/Source/Decals/AsyncLoadTracker.h index dd035afec6..8e03cc51fe 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Decals/AsyncLoadTracker.h +++ b/Gems/Atom/Feature/Common/Code/Source/Decals/AsyncLoadTracker.h @@ -97,7 +97,6 @@ namespace AZ { const auto iter = AZStd::find(vec.begin(), vec.end(), elementToErase); AZ_Assert(iter != vec.end(), "EraseFromVector failed to find the given object"); - const auto indexToRemove = AZStd::distance(vec.begin(), iter); AZStd::swap(*iter, vec.back()); vec.pop_back(); } diff --git a/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGrid.cpp b/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGrid.cpp index a4d24b7cb1..4d58948b98 100644 --- a/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGrid.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/DiffuseGlobalIllumination/DiffuseProbeGrid.cpp @@ -731,7 +731,6 @@ namespace AZ } const RHI::ShaderResourceGroupLayout* srgLayout = m_classificationSrg->GetLayout(); - RHI::ShaderInputConstantIndex constantIndex; RHI::ShaderInputImageIndex imageIndex; imageIndex = srgLayout->FindShaderInputImageIndex(AZ::Name("m_probeRayTrace")); diff --git a/Gems/Atom/Feature/Common/Code/Source/FrameCaptureSystemComponent.cpp b/Gems/Atom/Feature/Common/Code/Source/FrameCaptureSystemComponent.cpp index 6fbdf5b3f0..7374fdaf71 100644 --- a/Gems/Atom/Feature/Common/Code/Source/FrameCaptureSystemComponent.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/FrameCaptureSystemComponent.cpp @@ -33,7 +33,11 @@ #include #if defined(OPEN_IMAGE_IO_ENABLED) +// OpenImageIO/fmath.h(2271,5): error C4777: 'fprintf' : format string '%zd' requires an argument of type 'unsigned __int64', but variadic +// argument 5 has type 'OpenImageIO_v2_1::span_strided::index_type' +AZ_PUSH_DISABLE_WARNING(4777, "-Wunknown-warning-option") #include +AZ_POP_DISABLE_WARNING #endif namespace AZ diff --git a/Gems/Atom/Feature/Common/Code/Source/OcclusionCullingPlane/OcclusionCullingPlane.cpp b/Gems/Atom/Feature/Common/Code/Source/OcclusionCullingPlane/OcclusionCullingPlane.cpp index 5ea5a496d6..0e644b9555 100644 --- a/Gems/Atom/Feature/Common/Code/Source/OcclusionCullingPlane/OcclusionCullingPlane.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/OcclusionCullingPlane/OcclusionCullingPlane.cpp @@ -16,8 +16,6 @@ namespace AZ { namespace Render { - static const char* OcclusionCullingPlaneDrawListTag("occlusioncullingplanevisualization"); - OcclusionCullingPlane::~OcclusionCullingPlane() { Data::AssetBus::MultiHandler::BusDisconnect(); diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomBlurPass.cpp b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomBlurPass.cpp index 3fcff54eaa..b91990f6c9 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomBlurPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomBlurPass.cpp @@ -271,8 +271,6 @@ namespace AZ void BloomBlurPass::BuildKernelData() { - RHI::Size sourceImageSize; - m_weightData.clear(); m_offsetData.clear(); m_kernelRadiusData.clear(); diff --git a/Gems/Atom/Feature/Common/Code/Source/ProfilingCaptureSystemComponent.cpp b/Gems/Atom/Feature/Common/Code/Source/ProfilingCaptureSystemComponent.cpp index b2b82bbcb1..920326e081 100644 --- a/Gems/Atom/Feature/Common/Code/Source/ProfilingCaptureSystemComponent.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/ProfilingCaptureSystemComponent.cpp @@ -453,7 +453,7 @@ namespace AZ RHI::CpuProfiler::Get()->SetProfilerEnabled(true); } - const bool captureStarted = m_cpuFrameTimeStatisticsCapture.StartCapture([this, outputFilePath, wasEnabled]() + const bool captureStarted = m_cpuFrameTimeStatisticsCapture.StartCapture([outputFilePath, wasEnabled]() { JsonSerializerSettings serializationSettings; serializationSettings.m_keepDefaults = true; @@ -603,7 +603,7 @@ namespace AZ RHI::CpuProfiler::Get()->SetProfilerEnabled(true); } - const bool captureStarted = m_cpuProfilingStatisticsCapture.StartCapture([this, outputFilePath, wasEnabled]() + const bool captureStarted = m_cpuProfilingStatisticsCapture.StartCapture([outputFilePath, wasEnabled]() { // Blocking call for a single frame of data, avoid thread overhead AZStd::ring_buffer singleFrameData(1); @@ -669,7 +669,7 @@ namespace AZ bool ProfilingCaptureSystemComponent::CaptureBenchmarkMetadata(const AZStd::string& benchmarkName, const AZStd::string& outputFilePath) { - const bool captureStarted = m_benchmarkMetadataCapture.StartCapture([this, benchmarkName, outputFilePath]() + const bool captureStarted = m_benchmarkMetadataCapture.StartCapture([benchmarkName, outputFilePath]() { JsonSerializerSettings serializationSettings; serializationSettings.m_keepDefaults = true; diff --git a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp index 31899b9bb6..ea89f64b73 100644 --- a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingFeatureProcessor.cpp @@ -458,9 +458,7 @@ namespace AZ void RayTracingFeatureProcessor::UpdateRayTracingMaterialSrg() { const RHI::ShaderResourceGroupLayout* srgLayout = m_rayTracingMaterialSrg->GetLayout(); - RHI::ShaderInputImageIndex imageIndex; RHI::ShaderInputBufferIndex bufferIndex; - RHI::ShaderInputConstantIndex constantIndex; bufferIndex = srgLayout->FindShaderInputBufferIndex(AZ::Name("m_materialInfo")); m_rayTracingMaterialSrg->SetBufferView(bufferIndex, m_materialInfoBuffer->GetBufferView()); diff --git a/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.cpp b/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.cpp index 276ea7683f..66c326e6e7 100644 --- a/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/ReflectionProbe/ReflectionProbe.cpp @@ -22,8 +22,6 @@ namespace AZ { namespace Render { - static const char* ReflectionProbeDrawListTag("reflectionprobevisualization"); - ReflectionProbe::~ReflectionProbe() { Data::AssetBus::MultiHandler::BusDisconnect(); diff --git a/Gems/Atom/Feature/Common/Code/Source/Shadows/ProjectedShadowFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/Shadows/ProjectedShadowFeatureProcessor.cpp index 0e42c5520e..68dac8f773 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Shadows/ProjectedShadowFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Shadows/ProjectedShadowFeatureProcessor.cpp @@ -418,7 +418,6 @@ namespace AZ::Render } const FilterParameter& filter = m_shadowData.GetElement(shadowProperty.m_shadowId.GetIndex()); const float boundaryWidthAngle = shadow.m_boundaryScale * 2.0f; - constexpr float SmallAngle = 0.01f; const float fieldOfView = GetMax(shadowProperty.m_desc.m_fieldOfViewYRadians, MinimumFieldOfView); const float ratioToEntireWidth = boundaryWidthAngle / fieldOfView; const float widthInPixels = ratioToEntireWidth * filter.m_shadowmapSize; diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI/ConstantsData.h b/Gems/Atom/RHI/Code/Include/Atom/RHI/ConstantsData.h index ff1158e455..82b0b7146b 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI/ConstantsData.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI/ConstantsData.h @@ -248,7 +248,6 @@ namespace AZ AZStd::array_view constantBytes = GetConstantRaw(inputIndex); const size_t elementSize = sizeof(T); const size_t elementOffset = arrayIndex * elementSize; - const size_t elementCount = DivideByMultiple(constantBytes.size(), elementSize); if (ValidateConstantAccess(inputIndex, ValidateConstantAccessExpect::ArrayElement, elementOffset, elementSize)) { return *reinterpret_cast(&constantBytes[elementOffset]); diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI/IndexBufferView.h b/Gems/Atom/RHI/Code/Include/Atom/RHI/IndexBufferView.h index 5e2b244627..8e19ad1bff 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI/IndexBufferView.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI/IndexBufferView.h @@ -24,7 +24,7 @@ namespace AZ uint32_t GetIndexFormatSize(IndexFormat indexFormat); - class IndexBufferView + class alignas(8) IndexBufferView { public: IndexBufferView() = default; @@ -56,8 +56,6 @@ namespace AZ uint32_t m_byteOffset = 0; uint32_t m_byteCount = 0; IndexFormat m_format = IndexFormat::Uint32; - // Padding the size so it's 8 bytes aligned - uint32_t m_pad = 0; }; } } diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI/IndirectBufferView.h b/Gems/Atom/RHI/Code/Include/Atom/RHI/IndirectBufferView.h index aabb329434..b97ea81dd8 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI/IndirectBufferView.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI/IndirectBufferView.h @@ -19,7 +19,7 @@ namespace AZ //! Provides a view into a buffer, to be used as an indirect buffer. The content of the view is a contiguous //! list of commands sequences. It is provided to the RHI back-end at draw time. - class IndirectBufferView + class alignas(8) IndirectBufferView { public: IndirectBufferView() = default; @@ -57,8 +57,6 @@ namespace AZ uint32_t m_byteOffset = 0; uint32_t m_byteCount = 0; uint32_t m_byteStride = 0; - // Padding the size so it's 8 bytes aligned - uint32_t m_pad = 0; }; } } diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI/StreamBufferView.h b/Gems/Atom/RHI/Code/Include/Atom/RHI/StreamBufferView.h index df62cb84f8..4efc7da002 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI/StreamBufferView.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI/StreamBufferView.h @@ -29,7 +29,7 @@ namespace AZ * or interleaved in a single StreamBufferView (one view having multiple StreamChannelDescriptors). * - The view will correspond to a single StreamBufferDescriptor. */ - class StreamBufferView + class alignas(8) StreamBufferView { public: StreamBufferView() = default; @@ -62,8 +62,6 @@ namespace AZ uint32_t m_byteOffset = 0; uint32_t m_byteCount = 0; uint32_t m_byteStride = 0; - // Padding the size so it's 8 bytes aligned - uint32_t m_pad = 0; }; /// Utility function for checking that the set of StreamBufferViews aligns with the InputStreamLayout diff --git a/Gems/Atom/RHI/Code/Source/RHI/DrawPacketBuilder.cpp b/Gems/Atom/RHI/Code/Source/RHI/DrawPacketBuilder.cpp index 7bfaed0a31..ebda9732df 100644 --- a/Gems/Atom/RHI/Code/Source/RHI/DrawPacketBuilder.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI/DrawPacketBuilder.cpp @@ -119,7 +119,7 @@ namespace AZ LinearAllocator linearAllocator; linearAllocator.Init(linearAllocatorDesc); - const VirtualAddress drawPacketOffset = linearAllocator.Allocate( + [[maybe_unused]] const VirtualAddress drawPacketOffset = linearAllocator.Allocate( sizeof(DrawPacket), AZStd::alignment_of::value); diff --git a/Gems/Atom/RHI/Code/Source/RHI/PipelineStateCache.cpp b/Gems/Atom/RHI/Code/Source/RHI/PipelineStateCache.cpp index c9609edcf5..52093f7b4c 100644 --- a/Gems/Atom/RHI/Code/Source/RHI/PipelineStateCache.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI/PipelineStateCache.cpp @@ -177,7 +177,7 @@ namespace AZ */ AZStd::vector threadLibraries; - m_threadLibrarySet.ForEach([this, handle, &threadLibraries](const ThreadLibrarySet& threadLibrarySet) + m_threadLibrarySet.ForEach([handle, &threadLibraries](const ThreadLibrarySet& threadLibrarySet) { const ThreadLibraryEntry& threadLibraryEntry = threadLibrarySet[handle.GetIndex()]; diff --git a/Gems/Atom/RHI/Code/Tests/AllocatorTests.cpp b/Gems/Atom/RHI/Code/Tests/AllocatorTests.cpp index fa4c14089f..e43510adb5 100644 --- a/Gems/Atom/RHI/Code/Tests/AllocatorTests.cpp +++ b/Gems/Atom/RHI/Code/Tests/AllocatorTests.cpp @@ -67,7 +67,6 @@ namespace UnitTest AZStd::vector retiredAllocationsCurrent; AZStd::vector retiredAllocationsPrevious; - const size_t AllocationCount = 100; const size_t AllocationSizeRange = descriptor.m_allocationSizeMax - descriptor.m_allocationSizeMin; AZStd::string outputString; diff --git a/Gems/Atom/RHI/Code/Tests/ShaderResourceGroupTests.cpp b/Gems/Atom/RHI/Code/Tests/ShaderResourceGroupTests.cpp index 32d89cd596..83b3b68b25 100644 --- a/Gems/Atom/RHI/Code/Tests/ShaderResourceGroupTests.cpp +++ b/Gems/Atom/RHI/Code/Tests/ShaderResourceGroupTests.cpp @@ -56,8 +56,7 @@ namespace UnitTest const uint32_t BufferConstantCount = 2; const uint32_t BufferReadCount = 2; const uint32_t BufferReadWriteCount = 2; - const uint32_t BindingIndex = 1; - + AZStd::unique_ptr m_factory; AZStd::unique_ptr m_serializeContext; diff --git a/Gems/Atom/RHI/DX12/Code/Source/RHI/AliasedHeap.cpp b/Gems/Atom/RHI/DX12/Code/Source/RHI/AliasedHeap.cpp index 8c1ce4b3b2..d45c58e24c 100644 --- a/Gems/Atom/RHI/DX12/Code/Source/RHI/AliasedHeap.cpp +++ b/Gems/Atom/RHI/DX12/Code/Source/RHI/AliasedHeap.cpp @@ -104,8 +104,6 @@ namespace AZ { const RHI::BufferDescriptor& descriptor = request.m_descriptor; Buffer* buffer = static_cast(request.m_buffer); - const size_t alignmentInBytes = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT; - const size_t sizeInBytes = RHI::AlignUp(descriptor.m_byteCount, alignmentInBytes); MemoryView memoryView = GetDX12RHIDevice().CreateBufferPlaced( diff --git a/Gems/Atom/RHI/DX12/Code/Source/RHI/AsyncUploadQueue.cpp b/Gems/Atom/RHI/DX12/Code/Source/RHI/AsyncUploadQueue.cpp index e9beb55314..29b210e17e 100644 --- a/Gems/Atom/RHI/DX12/Code/Source/RHI/AsyncUploadQueue.cpp +++ b/Gems/Atom/RHI/DX12/Code/Source/RHI/AsyncUploadQueue.cpp @@ -378,7 +378,6 @@ namespace AZ } const uint32_t endRow = AZStd::GetMin(startRow + rowsPerSplit, subresourceLayout.m_rowCount); - const uint32_t numRowsToCopy = endRow - startRow; // Calculate the blocksize for BC formatted images; the copy command works in texels. uint32_t heightToCopy = (endRow - startRow) * compressedTexelBlockSizeHeight; diff --git a/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandListPool.cpp b/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandListPool.cpp index 3d3ec472a7..c31fe8ada8 100644 --- a/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandListPool.cpp +++ b/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandListPool.cpp @@ -138,7 +138,7 @@ namespace AZ commandAllocatorPoolDescriptor.m_collectLatency = descriptor.m_frameCountMax; commandAllocatorPool.Init(commandAllocatorPoolDescriptor); - m_commandListSubAllocators[queueIdx].SetInitFunction([this, &commandListPool, &commandAllocatorPool] + m_commandListSubAllocators[queueIdx].SetInitFunction([&commandListPool, &commandAllocatorPool] (Internal::CommandListSubAllocator& subAllocator) { subAllocator.Init(commandAllocatorPool, commandListPool); diff --git a/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandQueue.cpp b/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandQueue.cpp index afd0eb8074..9d58217f01 100644 --- a/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandQueue.cpp +++ b/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandQueue.cpp @@ -108,7 +108,7 @@ namespace AZ void CommandQueue::QueueGpuSignal(Fence& fence) { - QueueCommand([this, &fence](void* commandQueue) + QueueCommand([&fence](void* commandQueue) { AZ_PROFILE_SCOPE(RHI, "SignalFence"); ID3D12CommandQueue* dx12CommandQueue = static_cast(commandQueue); diff --git a/Gems/Atom/RHI/DX12/Code/Source/RHI/FrameGraphCompiler.cpp b/Gems/Atom/RHI/DX12/Code/Source/RHI/FrameGraphCompiler.cpp index ba4aa76a60..7eaafc3705 100644 --- a/Gems/Atom/RHI/DX12/Code/Source/RHI/FrameGraphCompiler.cpp +++ b/Gems/Atom/RHI/DX12/Code/Source/RHI/FrameGraphCompiler.cpp @@ -530,7 +530,6 @@ namespace AZ transition.StateAfter = GetResourceState(*scopeAttachment); logger.SetStateAfter(transition.StateAfter); - const bool isCopyQueueAfter = scopeAfter.GetHardwareQueueClass() == RHI::HardwareQueueClass::Copy; RHI::ImageSubresourceRange viewRange = RHI::ImageSubresourceRange(scopeAttachment->GetImageView()->GetDescriptor()); for (const auto& subresourceState : image.GetAttachmentStateByIndex(&viewRange)) { diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI.Builders/ShaderPlatformInterface.cpp b/Gems/Atom/RHI/Metal/Code/Source/RHI.Builders/ShaderPlatformInterface.cpp index b65db2a993..903b25e16f 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI.Builders/ShaderPlatformInterface.cpp +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI.Builders/ShaderPlatformInterface.cpp @@ -252,9 +252,7 @@ namespace AZ // Output file AZStd::string shaderMSLOutputFile = RHI::BuildFileNameWithExtension(shaderSourceFile, tempFolder, "metal"); - - bool outputFileWriteResult = false; - + // Stage profile name parameter const AZStd::string shaderModelVersion = "6_2"; diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI/AsyncUploadQueue.cpp b/Gems/Atom/RHI/Metal/Code/Source/RHI/AsyncUploadQueue.cpp index 2c9eb95ad4..bd163f1419 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI/AsyncUploadQueue.cpp +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI/AsyncUploadQueue.cpp @@ -105,7 +105,6 @@ namespace AZ } Fence* fenceToSignal = nullptr; - uint64_t fenceToSignalValue = 0; size_t byteCount = uploadRequest.m_byteCount; size_t byteOffset = destMemoryView.GetOffset() + uploadRequest.m_byteOffset; uint64_t queueValue = m_uploadFence.Increment(); @@ -183,8 +182,6 @@ namespace AZ { CommandQueue* commandQueue = static_cast(queue); FramePacket* framePacket = BeginFramePacket(commandQueue); - const uint16_t arraySize = image->GetDescriptor().m_arraySize; - const uint16_t imageMipLevels = image->GetDescriptor().m_mipLevels; //[GFX TODO][ATOM-5605] - Cache alignments for all formats at Init const static uint32_t bufferOffsetAlign = [mtlDevice minimumTextureBufferAlignmentForPixelFormat: ConvertPixelFormat(image->GetDescriptor().m_format)]; @@ -212,7 +209,6 @@ namespace AZ if (subresourceLayout.m_size.m_height < subresourceLayout.m_rowCount) { AZ_Error("Metal", false, "AsyncUploadQueue::QueueUpload expects ImageHeight '%d' to be bigger than or equal to the image's RowCount '%d'.", subresourceLayout.m_size.m_height, subresourceLayout.m_rowCount); - RHI::AsyncWorkHandle::Null; } // The final staging size for each CopyTextureRegion command @@ -281,8 +277,6 @@ namespace AZ { const uint8_t* subresourceDataStart = reinterpret_cast(subresourceData.m_data) + depth * subresourceSlicePitch; - MTLTextureDescriptor* mtlTextureDesc = ConvertImageDescriptor(image->GetDescriptor()); - uint32_t startRow = 0; uint32_t destHeight = 0; while (startRow < subresourceLayout.m_rowCount) @@ -468,7 +462,6 @@ namespace AZ MTLBlitOption mtlBlitOption = GetBlitOption(destImage->GetDescriptor().m_format); - id tempTex = destImage->GetMemoryView().GetGpuAddress>(); [blitEncoder copyFromBuffer:framePacket->m_stagingResource sourceOffset:framePacket->m_dataOffset sourceBytesPerRow:stagingRowPitch diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI/BufferPool.cpp b/Gems/Atom/RHI/Metal/Code/Source/RHI/BufferPool.cpp index a1bd9533bc..13f216e098 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI/BufferPool.cpp +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI/BufferPool.cpp @@ -102,8 +102,7 @@ namespace AZ void BufferPool::ShutdownResourceInternal(RHI::Resource& resourceBase) { Buffer& buffer = static_cast(resourceBase); - auto& device = static_cast(GetDevice()); - + if (auto* resolver = GetResolver()) { resolver->OnResourceShutdown(resourceBase); diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI/CommandListPool.cpp b/Gems/Atom/RHI/Metal/Code/Source/RHI/CommandListPool.cpp index 62091b794a..7753968122 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI/CommandListPool.cpp +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI/CommandListPool.cpp @@ -72,7 +72,7 @@ namespace AZ commandListPoolDescriptor.m_collectLatency = descriptor.m_frameCountMax; commandListPool.Init(commandListPoolDescriptor); - m_commandListSubAllocators[queueIdx].SetInitFunction([this, &commandListPool] + m_commandListSubAllocators[queueIdx].SetInitFunction([&commandListPool] (CommandListSubAllocator& subAllocator) { subAllocator.Init(commandListPool); diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI/CommandListPool.h b/Gems/Atom/RHI/Metal/Code/Source/RHI/CommandListPool.h index ca40f3c7aa..0ec5952525 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI/CommandListPool.h +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI/CommandListPool.h @@ -90,7 +90,7 @@ namespace AZ void Collect(); private: - CommandListPool* m_commandListPool = nullptr; + [[maybe_unused]] CommandListPool* m_commandListPool = nullptr; AZStd::vector m_activeLists; AZStd::array m_commandListPools; diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI/ImagePoolResolver.cpp b/Gems/Atom/RHI/Metal/Code/Source/RHI/ImagePoolResolver.cpp index 94dacb2488..d8a0c2e788 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI/ImagePoolResolver.cpp +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI/ImagePoolResolver.cpp @@ -25,11 +25,9 @@ namespace AZ RHI::ResultCode ImagePoolResolver::UpdateImage(const RHI::ImageUpdateRequest& request, size_t& bytesTransferred) { Image* image = static_cast(request.m_image); - auto& device = static_cast(GetDevice()); - + const RHI::ImageSubresourceLayout& sourceSubresourceLayout = request.m_sourceSubresourceLayout; - const RHI::Origin& imageSubresourcePixelOffset = request.m_imageSubresourcePixelOffset; - + const uint32_t stagingRowPitch = sourceSubresourceLayout.m_bytesPerRow; const uint32_t stagingSlicePitch = sourceSubresourceLayout.m_bytesPerImage; const uint32_t stagingSize = stagingSlicePitch * sourceSubresourceLayout.m_size.m_depth; diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI/NullDescriptorManager.cpp b/Gems/Atom/RHI/Metal/Code/Source/RHI/NullDescriptorManager.cpp index e86ba3c2c3..749e47f6b5 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI/NullDescriptorManager.cpp +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI/NullDescriptorManager.cpp @@ -42,8 +42,6 @@ namespace AZ void NullDescriptorManager::Shutdown() { - const Device& device = static_cast(GetDevice()); - m_nullImages.clear(); m_nullBuffer.m_memoryView = {}; m_nullMtlSamplerState = nil; @@ -94,7 +92,6 @@ namespace AZ textureSizeAndAlign.size = memoryRequirements.m_sizeInBytes; const size_t alignedHeapSize = RHI::AlignUp(heapSize, textureSizeAndAlign.align); - const uint32_t bytesPerPixel = RHI::GetFormatSize(m_nullImages[imageIndex].m_imageDescriptor.m_format); if(imageIndex == static_cast(NullDescriptorManager::ImageTypes::TextureBuffer)) { m_nullImages[imageIndex].m_memoryView = device.CreateImagePlaced(m_nullImages[imageIndex].m_imageDescriptor, m_nullDescriptorHeap, alignedHeapSize, textureSizeAndAlign, MTLTextureTypeTextureBuffer); diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI/QueryPool.cpp b/Gems/Atom/RHI/Metal/Code/Source/RHI/QueryPool.cpp index c8f2b89346..629aeb24f1 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI/QueryPool.cpp +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI/QueryPool.cpp @@ -26,10 +26,9 @@ namespace AZ RHI::ResultCode QueryPool::InitInternal(RHI::Device& baseDevice, const RHI::QueryPoolDescriptor& descriptor) { auto& device = static_cast(baseDevice); - id mtlDevice = device.GetMtlDevice(); - NSError* error = nil; - + #if AZ_TRAIT_ATOM_METAL_COUNTER_SAMPLING + id mtlDevice = device.GetMtlDevice(); NSArray> * counterSets = [mtlDevice counterSets]; CacheCounterIndices(counterSets); #endif @@ -77,6 +76,7 @@ namespace AZ } case RHI::QueryType::PipelineStatistics: { + NSError* error = nil; NSUInteger statisticCounterIndex = [counterSets indexOfObjectPassingTest:^BOOL(id mtlCounterSet, NSUInteger idx, BOOL *stop) { if ([mtlCounterSet.name isEqualToString:MTLCommonCounterSetStatistic]) @@ -127,9 +127,6 @@ namespace AZ RHI::ResultCode QueryPool::GetResultsInternal(uint32_t startIndex, uint32_t queryCount, uint64_t* results, uint32_t resultsCount, RHI::QueryResultFlagBits flags) { - auto& device = static_cast(GetDevice()); - MTLCommandBufferStatus commandBufferStatus = MTLCommandBufferStatusError; - switch(GetDescriptor().m_type) { case RHI::QueryType::Occlusion: diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI/Scope.cpp b/Gems/Atom/RHI/Metal/Code/Source/RHI/Scope.cpp index d70a4d4e60..7e4d510dfa 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI/Scope.cpp +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI/Scope.cpp @@ -115,12 +115,10 @@ namespace AZ const RHI::ImageScopeAttachmentDescriptor& bindingDescriptor = scopeAttachment->GetDescriptor(); id imageViewMtlTexture = imageView->GetMemoryView().GetGpuAddress>(); - const bool isFullView = imageView->IsFullView(); const bool isClearAction = bindingDescriptor.m_loadStoreAction.m_loadAction == RHI::AttachmentLoadAction::Clear; const bool isClearActionStencil = bindingDescriptor.m_loadStoreAction.m_loadActionStencil == RHI::AttachmentLoadAction::Clear; const bool isLoadAction = bindingDescriptor.m_loadStoreAction.m_loadAction == RHI::AttachmentLoadAction::Load; - const bool isLoadActionStencil = bindingDescriptor.m_loadStoreAction.m_loadActionStencil == RHI::AttachmentLoadAction::Load; const bool isStoreAction = bindingDescriptor.m_loadStoreAction.m_storeAction == RHI::AttachmentStoreAction::Store; const bool isStoreActionStencil = bindingDescriptor.m_loadStoreAction.m_storeActionStencil == RHI::AttachmentStoreAction::Store; @@ -158,7 +156,6 @@ namespace AZ { mtlStoreActionStencil = MTLStoreActionStore; } - const RHI::ImageViewDescriptor& imgViewDescriptor = imageView->GetDescriptor(); const AZStd::vector& usagesAndAccesses = scopeAttachment->GetUsageAndAccess(); for (const RHI::ScopeAttachmentUsageAndAccess& usageAndAccess : usagesAndAccesses) { diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI/ShaderResourceGroupPool.cpp b/Gems/Atom/RHI/Metal/Code/Source/RHI/ShaderResourceGroupPool.cpp index 3862885395..6be5ec7259 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI/ShaderResourceGroupPool.cpp +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI/ShaderResourceGroupPool.cpp @@ -26,7 +26,6 @@ namespace AZ { Device& device = static_cast(deviceBase); m_device = &device; - const RHI::ShaderResourceGroupLayout& layout = *descriptor.m_layout; m_srgLayout = descriptor.m_layout; return RHI::ResultCode::Success; } diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI/StreamingImagePool.cpp b/Gems/Atom/RHI/Metal/Code/Source/RHI/StreamingImagePool.cpp index 03d898bc60..3d90b595e4 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI/StreamingImagePool.cpp +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI/StreamingImagePool.cpp @@ -50,7 +50,6 @@ namespace AZ RHI::ResultCode StreamingImagePool::InitImageInternal(const RHI::StreamingImageInitRequest& request) { Image& image = static_cast(*request.m_image); - auto& device = static_cast(GetDevice()); MemoryView memoryView = GetDevice().CreateImageCommitted(image.GetDescriptor()); if (!memoryView.IsValid()) diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI/SwapChain.cpp b/Gems/Atom/RHI/Metal/Code/Source/RHI/SwapChain.cpp index 0065ea724e..90ba04c3db 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI/SwapChain.cpp +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI/SwapChain.cpp @@ -123,9 +123,6 @@ namespace AZ RHI::ResultCode SwapChain::InitImageInternal(const InitImageRequest& request) { - const RHI::SwapChainDescriptor& descriptor = GetDescriptor(); - Device& device = GetDevice(); - Name name(AZStd::string::format("SwapChainImage_%d", request.m_imageIndex)); Image& image = static_cast(*request.m_image); diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/AsyncUploadQueue.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/AsyncUploadQueue.cpp index 69c3d3cc20..47cde358ba 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/AsyncUploadQueue.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/AsyncUploadQueue.cpp @@ -63,7 +63,6 @@ namespace AZ const uint8_t* sourceData = reinterpret_cast(request.m_sourceData); const size_t byteCount = request.m_byteCount; - const size_t byteOffset = request.m_byteOffset; auto* buffer = static_cast(request.m_buffer); RHI::BufferPool* bufferPool = static_cast(buffer->GetPool()); @@ -189,8 +188,6 @@ namespace AZ // Set pipeline barriers before copy. EmmitPrologueMemoryBarrier(request, residentMip); - const uint16_t arraySize = image->GetDescriptor().m_arraySize; - const uint16_t imageMipLevels = image->GetDescriptor().m_mipLevels; const static uint32_t bufferOffsetAlign = 4; // refer VkBufferImageCopy in the spec. // Variables for split subresource slice. @@ -213,11 +210,7 @@ namespace AZ // ImageHeight must be bigger than or equal to the Image's row count. Images with a RowCount that is less than the ImageHeight indicates a block compression. // Images with a RowCount which is higher than the ImageHeight indicates a planar image, which is not supported for streaming images. - if (subresourceLayout.m_size.m_height < subresourceLayout.m_rowCount) - { - AZ_Error("StreamingImage", false, "AsyncUploadQueue::QueueUpload expects ImageHeight '%d' to be bigger than or equal to the image's RowCount '%d'.", subresourceLayout.m_size.m_height, subresourceLayout.m_rowCount); - RHI::AsyncWorkHandle::Null; - } + AZ_Error("StreamingImage", subresourceLayout.m_size.m_height < subresourceLayout.m_rowCount, "AsyncUploadQueue::QueueUpload expects ImageHeight '%d' to be bigger than or equal to the image's RowCount '%d'.", subresourceLayout.m_size.m_height, subresourceLayout.m_rowCount); // The final staging size for each CopyTextureRegion command uint32_t stagingSize = stagingSlicePitch; @@ -596,7 +589,6 @@ namespace AZ uint32_t residentMip) { const auto& image = static_cast(*request.m_image); - const RHI::ImageBindFlags bindFlags = image.GetDescriptor().m_bindFlags; const VkImageLayout layout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; const uint32_t beforeMip = residentMip; const uint32_t afterMip = beforeMip - static_cast(request.m_mipSlices.size()); diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/BufferPoolResolver.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/BufferPoolResolver.cpp index ba67f11c32..a94e610b49 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/BufferPoolResolver.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/BufferPoolResolver.cpp @@ -94,7 +94,6 @@ namespace AZ void BufferPoolResolver::Resolve(CommandList& commandList) { auto& device = static_cast(commandList.GetDevice()); - VkBufferCopy bufCopy{}; for (const BufferUploadPacket& packet : m_uploadPackets) { Buffer* stagingBuffer = packet.m_stagingBuffer.get(); diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/CommandListAllocator.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/CommandListAllocator.cpp index 09179c7110..bac7a69c9a 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/CommandListAllocator.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/CommandListAllocator.cpp @@ -100,7 +100,7 @@ namespace AZ commandPoolAllocatorDescriptor.m_collectLatency = descriptor.m_frameCountMax; commadPoolAllocator.Init(commandPoolAllocatorDescriptor); - m_commandListSubAllocators[queueFamilyIndex].SetInitFunction([this, &commadPoolAllocator] + m_commandListSubAllocators[queueFamilyIndex].SetInitFunction([&commadPoolAllocator] (Internal::CommandListSubAllocator& subAllocator) { subAllocator.Init(commadPoolAllocator); diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/CommandQueue.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/CommandQueue.cpp index bfce4dfb33..dc52e530e0 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/CommandQueue.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/CommandQueue.cpp @@ -109,7 +109,7 @@ namespace AZ { // The queue doesn't have an explicit way to signal a fence, so // we submit an empty work batch with only a fence to signal. - QueueCommand([this, &fence](void* queue) + QueueCommand([&fence](void* queue) { Queue* vulkanQueue = static_cast(queue); vulkanQueue->SubmitCommandBuffers( diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/Device.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/Device.cpp index 15a532f832..4f800f114b 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/Device.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/Device.cpp @@ -190,7 +190,6 @@ namespace AZ if (majorVersion >= 1 && minorVersion >= 2) { vulkan12Features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES; - VkPhysicalDeviceVulkan12Features physicalDeviceVulkan12Features = physicalDevice.GetPhysicalDeviceVulkan12Features(); vulkan12Features.drawIndirectCount = physicalDevice.GetPhysicalDeviceVulkan12Features().drawIndirectCount; vulkan12Features.shaderFloat16 = physicalDevice.GetPhysicalDeviceVulkan12Features().shaderFloat16; vulkan12Features.shaderInt8 = physicalDevice.GetPhysicalDeviceVulkan12Features().shaderInt8; diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/NullDescriptorManager.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/NullDescriptorManager.cpp index 316144f323..6d16cdc284 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/NullDescriptorManager.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/NullDescriptorManager.cpp @@ -73,7 +73,6 @@ namespace AZ Device& device = static_cast(GetDevice()); const uint32_t imageDimension = 8; - const uint32_t pixelSize = 4; // fill out the different options for the types of image null descriptors m_imageNullDescriptor.m_images.resize(static_cast(ImageTypes::Count)); diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PhysicalDevice.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PhysicalDevice.cpp index c00c1804b9..cdb9bbc7bd 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PhysicalDevice.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/PhysicalDevice.cpp @@ -17,8 +17,6 @@ namespace AZ { namespace Vulkan { - static constexpr size_t MinGPUMemSize = AZ_TRAIT_ATOM_VULKAN_MIN_GPU_MEM; - RHI::PhysicalDeviceList PhysicalDevice::Enumerate() { RHI::PhysicalDeviceList physicalDeviceList; diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/StreamingImagePool.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/StreamingImagePool.cpp index 586470da0a..d00e597ae6 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/StreamingImagePool.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/StreamingImagePool.cpp @@ -153,7 +153,6 @@ namespace AZ } const VkMemoryRequirements memoryRequirements = GetMemoryRequirements(image.GetDescriptor(), targetMipLevel); - const uint16_t residentMipLevelBefore = static_cast(image.GetResidentMipLevel()); RHI::HeapMemoryUsage& memoryUsage = m_memoryUsage.GetHeapMemoryUsage(RHI::HeapMemoryLevel::Device); const size_t imageSizeBefore = image.GetResidentSizeInBytes(); diff --git a/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/MaterialAssetBuilderComponent.cpp b/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/MaterialAssetBuilderComponent.cpp index 4a4c2156ce..ccbdc47f7e 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/MaterialAssetBuilderComponent.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/MaterialAssetBuilderComponent.cpp @@ -253,7 +253,6 @@ namespace AZ } const auto& scene = context.m_scene; - const Uuid sourceSceneUuid = scene.GetSourceGuid(); const auto& sceneGraph = scene.GetGraph(); auto names = sceneGraph.GetNameStorage(); diff --git a/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/ModelAssetBuilderComponent.cpp b/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/ModelAssetBuilderComponent.cpp index 13e5714b52..9fc99e3ea4 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/ModelAssetBuilderComponent.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/ModelAssetBuilderComponent.cpp @@ -60,7 +60,6 @@ namespace { - const uint32_t IndicesPerFace = 3; const AZ::RHI::Format IndicesFormat = AZ::RHI::Format::R32_UINT; const uint32_t PositionFloatsPerVert = 3; @@ -84,11 +83,6 @@ namespace // Morph targets const char* ShaderSemanticName_MorphTargetDeltas = "MORPHTARGET_VERTEXDELTAS"; - const AZ::RHI::Format MorphTargetVertexIndexFormat = AZ::RHI::Format::R32_UINT; // Single-component, 32-bit integer as vertex index - const char* ShaderSemanticName_MorphTargetPositionDeltas = "MORPHTARGET_POSITIONDELTAS"; - const AZ::RHI::Format MorphTargetPositionDeltaFormat = AZ::RHI::Format::R16_UINT; // 16-bit integer per compressed position delta component - const char* ShaderSemanticName_MorphTargetNormalDeltas = "MORPHTARGET_NORMALDELTAS"; - const AZ::RHI::Format MorphTargetNormalDeltaFormat = AZ::RHI::Format::R8_UINT; // 8-bit integer per compressed normal delta component // Cloth data const char* const ShaderSemanticName_ClothData = "CLOTH_DATA"; @@ -959,7 +953,6 @@ namespace AZ size_t numInfluencesAdded = 0; for (const auto& skinData : sourceMesh.m_skinData) { - const size_t numJoints = skinData->GetBoneCount(); const AZ::u32 controlPointIndex = sourceMeshData->GetControlPointIndex(static_cast(vertexIndex)); const size_t numSkinInfluences = skinData->GetLinkCount(controlPointIndex); diff --git a/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/MorphTargetExporter.cpp b/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/MorphTargetExporter.cpp index fa437c002f..44141f3ae3 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/MorphTargetExporter.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Builders/Model/MorphTargetExporter.cpp @@ -149,8 +149,6 @@ namespace AZ::RPI const float tolerance = CalcPositionDeltaTolerance(sourceMesh); AZ::Aabb deltaPositionAabb = AZ::Aabb::CreateNull(); - const uint32_t numFaces = blendShapeData->GetFaceCount(); - AZStd::vector& packedCompressedMorphTargetVertexData = productMesh.m_morphTargetVertexData; MorphTargetMetaAsset::MorphTarget metaData; diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Culling.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Culling.cpp index 98b3ab6f5f..bedf4fe989 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Culling.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Culling.cpp @@ -596,7 +596,7 @@ namespace AZ jobData->m_maskedOcclusionCulling = maskedOcclusionCulling; #endif - auto nodeVisitorLambda = [this, jobData, &parentJob, &frustum, &worklist](const AzFramework::IVisibilityScene::NodeData& nodeData) -> void + auto nodeVisitorLambda = [jobData, &parentJob, &worklist](const AzFramework::IVisibilityScene::NodeData& nodeData) -> void { AZ_PROFILE_SCOPE(RPI, "nodeVisitorLambda()"); AZ_Assert(nodeData.m_entries.size() > 0, "should not get called with 0 entries"); diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/DynamicDraw/DynamicDrawContext.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/DynamicDraw/DynamicDrawContext.cpp index 29f57d6e0f..4da85823b3 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/DynamicDraw/DynamicDrawContext.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/DynamicDraw/DynamicDrawContext.cpp @@ -25,8 +25,7 @@ namespace AZ namespace { constexpr const char* PerContextSrgName = "PerContextSrg"; - constexpr const char* PerDrawSrgName = "PerDrawSrg"; - }; + } void DynamicDrawContext::MultiStates::UpdateHash(const DrawStateOptions& drawStateOptions) { diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/MeshDrawPacket.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/MeshDrawPacket.cpp index 2d876fd6ad..0e4c8ec15a 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/MeshDrawPacket.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/MeshDrawPacket.cpp @@ -88,7 +88,7 @@ namespace AZ } else { - itEntry->second == value; + itEntry->second = value; } } } diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassLibrary.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassLibrary.cpp index ca49843efb..8eedf3aa1f 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassLibrary.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassLibrary.cpp @@ -247,8 +247,6 @@ namespace AZ void PassLibrary::OnAssetReloaded(Data::Asset asset) { - Data::AssetId assetId = asset->GetId(); - // Handle pass asset reload Data::Asset passAsset = { asset.GetAs(), AZ::Data::AssetLoadBehavior::PreLoad }; if (passAsset && passAsset->GetPassTemplate()) diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Shader/Shader.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Shader/Shader.cpp index 3b546d192a..4440b96f79 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Shader/Shader.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Shader/Shader.cpp @@ -175,6 +175,8 @@ namespace AZ /// ShaderVariantFinderNotificationBus overrides void Shader::OnShaderVariantAssetReady(Data::Asset shaderVariantAsset, bool isError) { + ShaderReloadDebugTracker::ScopedSection reloadSection("{%p}->Shader::OnShaderVariantAssetReady %s", this, shaderVariantAsset.GetHint().c_str()); + AZ_Assert(shaderVariantAsset, "Reloaded ShaderVariantAsset is null"); const ShaderVariantStableId stableId = shaderVariantAsset->GetStableId(); diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Shader/ShaderSystem.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Shader/ShaderSystem.cpp index c1ae1f0be9..ec6aeb3771 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Shader/ShaderSystem.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Shader/ShaderSystem.cpp @@ -25,8 +25,6 @@ namespace AZ { namespace RPI { - static constexpr char ShaderSystemLog[] = "ShaderSystem"; - void ShaderSystem::Reflect(ReflectContext* context) { ShaderOptionDescriptor::Reflect(context); diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/View.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/View.cpp index 436aa0d538..b07728938f 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/View.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/View.cpp @@ -30,8 +30,10 @@ namespace AZ namespace RPI { // fixed-size software occlusion culling buffer +#if AZ_TRAIT_MASKED_OCCLUSION_CULLING_SUPPORTED const uint32_t MaskedSoftwareOcclusionCullingWidth = 1920; const uint32_t MaskedSoftwareOcclusionCullingHeight = 1080; +#endif ViewPtr View::CreateView(const AZ::Name& name, UsageFlags usage) { 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 25fe2a566e..bd49a72f40 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Shader/ShaderAsset.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Shader/ShaderAsset.cpp @@ -587,6 +587,8 @@ namespace AZ { Data::Asset shaderVariantAsset = { asset.GetAs(), AZ::Data::AssetLoadBehavior::PreLoad }; AZ_Assert(shaderVariantAsset->GetStableId() == RootShaderVariantStableId, "Was expecting to update the root variant"); + SupervariantIndex supervariantIndex = GetSupervariantIndexFromAssetId(asset.GetId()); + GetCurrentShaderApiData().m_supervariants[supervariantIndex.GetIndex()].m_rootShaderVariantAsset = asset; ShaderReloadNotificationBus::Event(GetId(), &ShaderReloadNotificationBus::Events::OnShaderAssetReinitialized, Data::Asset{ this, AZ::Data::AssetLoadBehavior::PreLoad } ); } @@ -607,17 +609,7 @@ namespace AZ // so it continues using the old ShaderVariantAsset instead of the new one. // The OnAssetReady bus function is called automatically whenever a connection to AssetBus is made, so listening to this gives // us the opportunity to assign the appropriate ShaderVariantAsset. - - ShaderReloadNotificationBus::Event(GetId(), &ShaderReloadNotificationBus::Events::OnShaderAssetReinitialized, Data::Asset{ this, AZ::Data::AssetLoadBehavior::PreLoad } ); - - Data::Asset shaderVariantAsset = { asset.GetAs(), AZ::Data::AssetLoadBehavior::PreLoad }; - AZ_Assert(shaderVariantAsset->GetStableId() == RootShaderVariantStableId, - "Was expecting to update the root variant"); - SupervariantIndex supervariantIndex = GetSupervariantIndexFromAssetId(asset.GetId()); - GetCurrentShaderApiData().m_supervariants[supervariantIndex.GetIndex()].m_rootShaderVariantAsset = asset; - - ShaderReloadNotificationBus::Event(GetId(), &ShaderReloadNotificationBus::Events::OnShaderAssetReinitialized, Data::Asset{ this, AZ::Data::AssetLoadBehavior::PreLoad } ); - + ShaderReloadDebugTracker::ScopedSection reloadSection("{%p}->ShaderAsset::OnAssetReady %s", this, asset.GetHint().c_str()); ReinitializeRootShaderVariant(asset); } diff --git a/Gems/Atom/RPI/Code/Tests/Buffer/BufferTests.cpp b/Gems/Atom/RPI/Code/Tests/Buffer/BufferTests.cpp index f648de6997..a2f478901c 100644 --- a/Gems/Atom/RPI/Code/Tests/Buffer/BufferTests.cpp +++ b/Gems/Atom/RPI/Code/Tests/Buffer/BufferTests.cpp @@ -616,7 +616,6 @@ namespace UnitTest Data::Asset asset; creator.End(asset); - bufferInfo.m_bufferDescriptor.m_byteCount; Data::Instance bufferInst = RPI::Buffer::FindOrCreate(asset); ASSERT_NE(bufferInst.get(), nullptr); diff --git a/Gems/Atom/RPI/Code/Tests/Common/ErrorMessageFinder.cpp b/Gems/Atom/RPI/Code/Tests/Common/ErrorMessageFinder.cpp index 7ffdffbb14..fa88f145a6 100644 --- a/Gems/Atom/RPI/Code/Tests/Common/ErrorMessageFinder.cpp +++ b/Gems/Atom/RPI/Code/Tests/Common/ErrorMessageFinder.cpp @@ -105,7 +105,7 @@ namespace UnitTest { EXPECT_FALSE(m_disabled); - AZStd::for_each(m_expectedErrors.begin(), m_expectedErrors.end(), [this](ExpectedError& expectedError) { expectedError.m_gotCount = 0; }); + AZStd::for_each(m_expectedErrors.begin(), m_expectedErrors.end(), [](ExpectedError& expectedError) { expectedError.m_gotCount = 0; }); m_checked = false; } diff --git a/Gems/Atom/RPI/Code/Tests/Image/StreamingImageTests.cpp b/Gems/Atom/RPI/Code/Tests/Image/StreamingImageTests.cpp index 3836f5c8f5..345637bfe5 100644 --- a/Gems/Atom/RPI/Code/Tests/Image/StreamingImageTests.cpp +++ b/Gems/Atom/RPI/Code/Tests/Image/StreamingImageTests.cpp @@ -490,7 +490,6 @@ namespace UnitTest const uint16_t mipLevels = 1; const uint16_t arraySize = 1; - const uint16_t pixelSize = 4; Data::Asset mipChain; diff --git a/Gems/Atom/RPI/Code/Tests/Material/MaterialAssetTests.cpp b/Gems/Atom/RPI/Code/Tests/Material/MaterialAssetTests.cpp index 0b30b723d6..ce223ceb35 100644 --- a/Gems/Atom/RPI/Code/Tests/Material/MaterialAssetTests.cpp +++ b/Gems/Atom/RPI/Code/Tests/Material/MaterialAssetTests.cpp @@ -267,47 +267,47 @@ namespace UnitTest creator.SetPropertyValue(Name{ "MyBool" }, m_testImageAsset); }); - expectCreatorError([this](MaterialAssetCreator& creator) + expectCreatorError([](MaterialAssetCreator& creator) { creator.SetPropertyValue(Name{ "MyInt" }, 0.0f); }); - expectCreatorError([this](MaterialAssetCreator& creator) + expectCreatorError([](MaterialAssetCreator& creator) { creator.SetPropertyValue(Name{ "MyUInt" }, -1); }); - expectCreatorError([this](MaterialAssetCreator& creator) + expectCreatorError([](MaterialAssetCreator& creator) { creator.SetPropertyValue(Name{ "MyFloat" }, 10u); }); - expectCreatorError([this](MaterialAssetCreator& creator) + expectCreatorError([](MaterialAssetCreator& creator) { creator.SetPropertyValue(Name{ "MyFloat2" }, 1.0f); }); - expectCreatorError([this](MaterialAssetCreator& creator) + expectCreatorError([](MaterialAssetCreator& creator) { creator.SetPropertyValue(Name{ "MyFloat3" }, AZ::Vector4{}); }); - expectCreatorError([this](MaterialAssetCreator& creator) + expectCreatorError([](MaterialAssetCreator& creator) { creator.SetPropertyValue(Name{ "MyFloat4" }, AZ::Vector3{}); }); - expectCreatorError([this](MaterialAssetCreator& creator) + expectCreatorError([](MaterialAssetCreator& creator) { creator.SetPropertyValue(Name{ "MyColor" }, MaterialPropertyValue(false)); }); - expectCreatorError([this](MaterialAssetCreator& creator) + expectCreatorError([](MaterialAssetCreator& creator) { creator.SetPropertyValue(Name{ "MyImage" }, true); }); - expectCreatorError([this](MaterialAssetCreator& creator) + expectCreatorError([](MaterialAssetCreator& creator) { creator.SetPropertyValue(Name{ "MyEnum" }, -1); }); diff --git a/Gems/Atom/RPI/Code/Tests/Material/MaterialSourceDataTests.cpp b/Gems/Atom/RPI/Code/Tests/Material/MaterialSourceDataTests.cpp index a20d16b0d6..553c3243e1 100644 --- a/Gems/Atom/RPI/Code/Tests/Material/MaterialSourceDataTests.cpp +++ b/Gems/Atom/RPI/Code/Tests/Material/MaterialSourceDataTests.cpp @@ -566,7 +566,7 @@ namespace UnitTest // We use local functions to easily start a new MaterialAssetCreator for each test case because // the AssetCreator would just skip subsequent operations after the first failure is detected. - auto expectError = [this](AZStd::function setOneBadInput, [[maybe_unused]] uint32_t expectedAsserts = 2) + auto expectError = [](AZStd::function setOneBadInput, [[maybe_unused]] uint32_t expectedAsserts = 2) { MaterialSourceData sourceData; @@ -583,7 +583,7 @@ namespace UnitTest EXPECT_FALSE(materialAssetOutcome.IsSuccess()); }; - auto expectWarning = [this](AZStd::function setOneBadInput, [[maybe_unused]] uint32_t expectedAsserts = 1) + auto expectWarning = [](AZStd::function setOneBadInput, [[maybe_unused]] uint32_t expectedAsserts = 1) { MaterialSourceData sourceData; diff --git a/Gems/Atom/RPI/Code/Tests/Material/MaterialTypeAssetTests.cpp b/Gems/Atom/RPI/Code/Tests/Material/MaterialTypeAssetTests.cpp index 6b788addc7..e11a049af2 100644 --- a/Gems/Atom/RPI/Code/Tests/Material/MaterialTypeAssetTests.cpp +++ b/Gems/Atom/RPI/Code/Tests/Material/MaterialTypeAssetTests.cpp @@ -413,7 +413,7 @@ namespace UnitTest EXPECT_EQ(1, creator.GetErrorCount()); }; - auto expectCreatorWarning = [this](AZStd::function passBadInput) + auto expectCreatorWarning = [](AZStd::function passBadInput) { MaterialTypeAssetCreator creator; creator.Begin(Uuid::CreateRandom()); @@ -442,47 +442,47 @@ namespace UnitTest creator.SetPropertyValue(Name{ "MyBool" }, m_testImageAsset); }); - expectCreatorError([this](MaterialTypeAssetCreator& creator) + expectCreatorError([](MaterialTypeAssetCreator& creator) { creator.SetPropertyValue(Name{ "MyInt" }, 0.0f); }); - expectCreatorError([this](MaterialTypeAssetCreator& creator) + expectCreatorError([](MaterialTypeAssetCreator& creator) { creator.SetPropertyValue(Name{ "MyUInt" }, -1); }); - expectCreatorError([this](MaterialTypeAssetCreator& creator) + expectCreatorError([](MaterialTypeAssetCreator& creator) { creator.SetPropertyValue(Name{ "MyFloat" }, 10u); }); - expectCreatorError([this](MaterialTypeAssetCreator& creator) + expectCreatorError([](MaterialTypeAssetCreator& creator) { creator.SetPropertyValue(Name{ "MyFloat2" }, 1.0f); }); - expectCreatorError([this](MaterialTypeAssetCreator& creator) + expectCreatorError([](MaterialTypeAssetCreator& creator) { creator.SetPropertyValue(Name{ "MyFloat3" }, AZ::Vector4{}); }); - expectCreatorError([this](MaterialTypeAssetCreator& creator) + expectCreatorError([](MaterialTypeAssetCreator& creator) { creator.SetPropertyValue(Name{ "MyFloat4" }, AZ::Vector3{}); }); - expectCreatorError([this](MaterialTypeAssetCreator& creator) + expectCreatorError([](MaterialTypeAssetCreator& creator) { creator.SetPropertyValue(Name{ "MyColor" }, MaterialPropertyValue(false)); }); - expectCreatorError([this](MaterialTypeAssetCreator& creator) + expectCreatorError([](MaterialTypeAssetCreator& creator) { creator.SetPropertyValue(Name{ "MyImage" }, true); }); - expectCreatorError([this](MaterialTypeAssetCreator& creator) + expectCreatorError([](MaterialTypeAssetCreator& creator) { creator.SetPropertyValue(Name{ "MyEnum" }, -1); }); diff --git a/Gems/Atom/RPI/Code/Tests/Model/ModelTests.cpp b/Gems/Atom/RPI/Code/Tests/Model/ModelTests.cpp index ff998ad4d3..7b07e14de0 100644 --- a/Gems/Atom/RPI/Code/Tests/Model/ModelTests.cpp +++ b/Gems/Atom/RPI/Code/Tests/Model/ModelTests.cpp @@ -783,7 +783,6 @@ namespace UnitTest const uint32_t vertexCount = 36; const uint32_t vertexSize = sizeof(float) * 3; - const uint32_t vertexBufferSize = vertexCount * vertexSize; RHI::BufferViewDescriptor validStreamBufferViewDescriptor = RHI::BufferViewDescriptor::CreateStructured(0, vertexCount, vertexSize); diff --git a/Gems/Atom/TestData/TestData/Textures/Foliage_Leaves_0_BaseColor.dds.assetinfo b/Gems/Atom/TestData/TestData/Textures/Foliage_Leaves_0_BaseColor.dds.assetinfo index 1aa896a8d7..8a189b3b98 100644 --- a/Gems/Atom/TestData/TestData/Textures/Foliage_Leaves_0_BaseColor.dds.assetinfo +++ b/Gems/Atom/TestData/TestData/Textures/Foliage_Leaves_0_BaseColor.dds.assetinfo @@ -62,6 +62,14 @@ + + + + + + + + diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/RenderViewportWidget.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/RenderViewportWidget.h index b6db6b78ae..62e2f834c8 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/RenderViewportWidget.h +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/RenderViewportWidget.h @@ -159,8 +159,6 @@ namespace AtomToolsFramework QElapsedTimer m_renderTimer; // The time of the last recorded tick event from the system tick bus. AZ::ScriptTimePoint m_time; - // Whether the Viewport is currently hiding and capturing the cursor position. - bool m_capturingCursor = false; // The viewport settings (e.g. grid snapping, grid size) for this viewport. const AzToolsFramework::ViewportInteraction::ViewportSettings* m_viewportSettings = nullptr; // Maps our internal Qt events into AzFramework InputChannels for our ViewportControllerList. diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentMainWindow.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentMainWindow.cpp index c39bfc8327..0d62adc9ee 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentMainWindow.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentMainWindow.cpp @@ -121,7 +121,7 @@ namespace AtomToolsFramework }, QKeySequence::Close); m_menuFile->insertAction(insertPostion, m_actionClose); - m_actionCloseAll = CreateAction("Close All", [this]() { + m_actionCloseAll = CreateAction("Close All", []() { AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsDocumentSystemRequestBus::Events::CloseAllDocuments); }); m_menuFile->insertAction(insertPostion, m_actionCloseAll); diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorBrowserInteractions.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorBrowserInteractions.cpp index 3440d9c316..e6ffd2842f 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorBrowserInteractions.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorBrowserInteractions.cpp @@ -125,7 +125,7 @@ namespace MaterialEditor QDesktopServices::openUrl(QUrl::fromLocalFile(entry->GetFullPath().c_str())); }); - menu->addAction("Duplicate...", [entry, caller]() + menu->addAction("Duplicate...", [entry]() { const QFileInfo duplicateFileInfo(AtomToolsFramework::GetDuplicationFileInfo(entry->GetFullPath().c_str())); if (!duplicateFileInfo.absoluteFilePath().isEmpty()) @@ -156,7 +156,7 @@ namespace MaterialEditor AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::OpenDocument, entry->GetFullPath()); }); - menu->addAction("Duplicate...", [entry, caller]() + menu->addAction("Duplicate...", [entry]() { const QFileInfo duplicateFileInfo(AtomToolsFramework::GetDuplicationFileInfo(entry->GetFullPath().c_str())); if (!duplicateFileInfo.absoluteFilePath().isEmpty()) @@ -285,7 +285,7 @@ namespace MaterialEditor }); // add get latest action - m_getLatestAction = sourceControlMenu->addAction("Get Latest", [path, this]() + m_getLatestAction = sourceControlMenu->addAction("Get Latest", [path]() { SourceControlCommandBus::Broadcast(&SourceControlCommandBus::Events::RequestLatest, path.c_str(), [](bool, const SourceControlFileInfo&) {}); diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleBrowserInteractions.cpp b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleBrowserInteractions.cpp index b82d348df3..ca836b1b8d 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleBrowserInteractions.cpp +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleBrowserInteractions.cpp @@ -84,7 +84,7 @@ namespace ShaderManagementConsole } }); - menu->addAction("Duplicate...", [entry, caller]() + menu->addAction("Duplicate...", [entry]() { const QFileInfo duplicateFileInfo(AtomToolsFramework::GetDuplicationFileInfo(entry->GetFullPath().c_str())); if (!duplicateFileInfo.absoluteFilePath().isEmpty()) @@ -189,7 +189,7 @@ namespace ShaderManagementConsole }); // add get latest action - m_getLatestAction = sourceControlMenu->addAction("Get Latest", [path, this]() + m_getLatestAction = sourceControlMenu->addAction("Get Latest", [path]() { SourceControlCommandBus::Broadcast(&SourceControlCommandBus::Events::RequestLatest, path.c_str(), [](bool, const SourceControlFileInfo&) {}); diff --git a/Gems/Atom/Utils/Code/Include/Atom/Utils/ImGuiCpuProfiler.inl b/Gems/Atom/Utils/Code/Include/Atom/Utils/ImGuiCpuProfiler.inl index 638927d601..cd9e4fc2b5 100644 --- a/Gems/Atom/Utils/Code/Include/Atom/Utils/ImGuiCpuProfiler.inl +++ b/Gems/Atom/Utils/Code/Include/Atom/Utils/ImGuiCpuProfiler.inl @@ -356,14 +356,12 @@ namespace AZ const AZ::RHI::CpuTimingStatistics& cpuTimingStatistics = m_cpuTimingStatisticsWhenPause; - const AZStd::sys_time_t ticksPerSecond = AZStd::GetTimeTicksPerSecond(); - - const auto ShowTimeInMs = [ticksPerSecond](AZStd::sys_time_t duration) + const auto ShowTimeInMs = [](AZStd::sys_time_t duration) { ImGui::Text("%.2f ms", CpuProfilerImGuiHelper::TicksToMs(duration)); }; - const auto ShowRow = [ticksPerSecond, &ShowTimeInMs](const char* regionLabel, AZStd::sys_time_t duration) + const auto ShowRow = [&ShowTimeInMs](const char* regionLabel, AZStd::sys_time_t duration) { ImGui::Text(regionLabel); ImGui::NextColumn(); @@ -632,7 +630,6 @@ namespace AZ else if (io.MouseWheel != 0 && io.KeyCtrl) // Zooming { // We want zooming to be relative to the mouse's current position - const float mouseVel = io.MouseWheel; const float mouseX = ImGui::GetMousePos().x; // Find the normalized position of the cursor relative to the window diff --git a/Gems/Atom/Utils/Code/Include/Atom/Utils/ImGuiGpuProfiler.inl b/Gems/Atom/Utils/Code/Include/Atom/Utils/ImGuiGpuProfiler.inl index 9ebd0f7a26..49b6430221 100644 --- a/Gems/Atom/Utils/Code/Include/Atom/Utils/ImGuiGpuProfiler.inl +++ b/Gems/Atom/Utils/Code/Include/Atom/Utils/ImGuiGpuProfiler.inl @@ -1336,7 +1336,7 @@ namespace AZ inline PassEntry* ImGuiGpuProfiler::CreatePassEntries(RHI::Ptr rootPass) { AZStd::unordered_map passEntryDatabase; - const auto addPassEntry = [&passEntryDatabase, this](const RPI::Pass* pass, PassEntry* parent) -> PassEntry* + const auto addPassEntry = [&passEntryDatabase](const RPI::Pass* pass, PassEntry* parent) -> PassEntry* { // If parent a nullptr, it's assumed to be the rootpass. if (parent == nullptr) diff --git a/Gems/Atom/Utils/Code/Include/Atom/Utils/StableDynamicArray.inl b/Gems/Atom/Utils/Code/Include/Atom/Utils/StableDynamicArray.inl index 25f3f528ab..870ed04b33 100644 --- a/Gems/Atom/Utils/Code/Include/Atom/Utils/StableDynamicArray.inl +++ b/Gems/Atom/Utils/Code/Include/Atom/Utils/StableDynamicArray.inl @@ -305,7 +305,7 @@ namespace AZ template size_t StableDynamicArray::Page::Reserve() { - for (m_bitStartIndex; m_bitStartIndex < NumUint64_t; ++m_bitStartIndex) + for (; m_bitStartIndex < NumUint64_t; ++m_bitStartIndex) { if (m_bits[m_bitStartIndex] != FullBits) { @@ -462,7 +462,7 @@ namespace AZ } // skip the empty bitfields in the page - for (m_bitGroupIndex; m_bitGroupIndex < Page::NumUint64_t && m_page->m_bits.at(m_bitGroupIndex) == 0; ++m_bitGroupIndex) + for (; m_bitGroupIndex < Page::NumUint64_t && m_page->m_bits.at(m_bitGroupIndex) == 0; ++m_bitGroupIndex) { } diff --git a/Gems/AtomLyIntegration/AtomBridge/Code/Source/PerViewportDynamicDrawManager.cpp b/Gems/AtomLyIntegration/AtomBridge/Code/Source/PerViewportDynamicDrawManager.cpp index 414dd7cdf0..c0627d38da 100644 --- a/Gems/AtomLyIntegration/AtomBridge/Code/Source/PerViewportDynamicDrawManager.cpp +++ b/Gems/AtomLyIntegration/AtomBridge/Code/Source/PerViewportDynamicDrawManager.cpp @@ -86,7 +86,7 @@ namespace AZ::AtomBridge context.second->SetOutputScope(pipeline.get()); } }); - viewportData.m_viewportDestroyedHandler = AZ::Event::Handler([this, viewportId](AzFramework::ViewportId id) + viewportData.m_viewportDestroyedHandler = AZ::Event::Handler([this](AzFramework::ViewportId id) { AZStd::lock_guard lock(m_mutexDrawContexts); m_viewportData.erase(id); diff --git a/Gems/AtomLyIntegration/AtomFont/Code/Include/AtomLyIntegration/AtomFont/AtomFont.h b/Gems/AtomLyIntegration/AtomFont/Code/Include/AtomLyIntegration/AtomFont/AtomFont.h index f5883232eb..6d361c01ae 100644 --- a/Gems/AtomLyIntegration/AtomFont/Code/Include/AtomLyIntegration/AtomFont/AtomFont.h +++ b/Gems/AtomLyIntegration/AtomFont/Code/Include/AtomLyIntegration/AtomFont/AtomFont.h @@ -136,7 +136,6 @@ namespace AZ FontMap m_fonts; FontFamilyMap m_fontFamilies; //!< Map font family names to weak ptrs so we can construct shared_ptrs but not keep a ref ourselves. FontFamilyReverseLookupMap m_fontFamilyReverseLookup; //GetViewportSize(); AzFramework::CameraState cameraState; AzFramework::SetCameraClippingVolumeFromPerspectiveFovMatrixRH(cameraState, currentView->GetViewToClipMatrix()); const AZ::Transform transform = currentView->GetCameraTransform(); diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/EditorMaterialComponentInspector.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/EditorMaterialComponentInspector.cpp index f4c255d774..b9a4adc068 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/EditorMaterialComponentInspector.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/Material/EditorMaterialComponentInspector.cpp @@ -214,7 +214,7 @@ namespace AZ groupNameId.c_str())); auto propertyGroupWidget = new AtomToolsFramework::InspectorPropertyGroupWidget( &group, &group, group.TYPEINFO_Uuid(), this, this, saveStateKey, - [this](const AzToolsFramework::InstanceDataNode* source, const AzToolsFramework::InstanceDataNode* target) { + [](const AzToolsFramework::InstanceDataNode* source, const AzToolsFramework::InstanceDataNode* target) { AZ_UNUSED(source); const AtomToolsFramework::DynamicProperty* property = AtomToolsFramework::FindDynamicPropertyForInstanceDataNode(target); return property && AtomToolsFramework::ArePropertyValuesEqual(property->GetValue(), property->GetConfig().m_parentValue); @@ -267,7 +267,7 @@ namespace AZ groupNameId.c_str())); auto propertyGroupWidget = new AtomToolsFramework::InspectorPropertyGroupWidget( &group, &group, group.TYPEINFO_Uuid(), this, this, saveStateKey, - [this](const AzToolsFramework::InstanceDataNode* source, const AzToolsFramework::InstanceDataNode* target) { + [](const AzToolsFramework::InstanceDataNode* source, const AzToolsFramework::InstanceDataNode* target) { AZ_UNUSED(source); const AtomToolsFramework::DynamicProperty* property = AtomToolsFramework::FindDynamicPropertyForInstanceDataNode(target); return property && AtomToolsFramework::ArePropertyValuesEqual(property->GetValue(), property->GetConfig().m_parentValue); diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/ActorAsset.cpp b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/ActorAsset.cpp index 8d247eaf45..284e1ed35d 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/ActorAsset.cpp +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Source/ActorAsset.cpp @@ -39,25 +39,6 @@ // Copied from ModelAssetBuilderComponent.cpp namespace { - const AZ::u32 IndicesPerFace = 3; - const AZ::RHI::Format IndicesFormat = AZ::RHI::Format::R32_UINT; - - const AZ::u32 PositionFloatsPerVert = 3; - const AZ::u32 NormalFloatsPerVert = 3; - const AZ::u32 UVFloatsPerVert = 2; - const AZ::u32 ColorFloatsPerVert = 4; - const AZ::u32 TangentFloatsPerVert = 4; - const AZ::u32 BitangentFloatsPerVert = 3; - - const AZ::RHI::Format PositionFormat = AZ::RHI::Format::R32G32B32_FLOAT; - const AZ::RHI::Format NormalFormat = AZ::RHI::Format::R32G32B32_FLOAT; - const AZ::RHI::Format UVFormat = AZ::RHI::Format::R32G32_FLOAT; - const AZ::RHI::Format ColorFormat = AZ::RHI::Format::R32G32B32A32_FLOAT; - const AZ::RHI::Format TangentFormat = AZ::RHI::Format::R32G32B32A32_FLOAT; - const AZ::RHI::Format BitangentFormat = AZ::RHI::Format::R32G32B32_FLOAT; - const AZ::RHI::Format BoneIndexFormat = AZ::RHI::Format::R32G32B32A32_UINT; - const AZ::RHI::Format BoneWeightFormat = AZ::RHI::Format::R32G32B32A32_FLOAT; - const uint32_t LinearSkinningFloatsPerBone = 12; const uint32_t DualQuaternionSkinningFloatsPerBone = 8; const uint32_t MaxSupportedSkinInfluences = 4; diff --git a/Gems/AudioSystem/Code/Source/Editor/AudioControlsLoader.cpp b/Gems/AudioSystem/Code/Source/Editor/AudioControlsLoader.cpp index 30889e33f0..45f044be32 100644 --- a/Gems/AudioSystem/Code/Source/Editor/AudioControlsLoader.cpp +++ b/Gems/AudioSystem/Code/Source/Editor/AudioControlsLoader.cpp @@ -31,7 +31,6 @@ namespace AudioControls namespace LoaderStrings { static constexpr const char* LevelsSubFolder = "levels"; - static constexpr const char* PathAttribute = "path"; } // namespace LoaderStrings diff --git a/Gems/AudioSystem/Code/Source/Engine/ATL.cpp b/Gems/AudioSystem/Code/Source/Engine/ATL.cpp index 3122ddcbd3..8fbb8fffc0 100644 --- a/Gems/AudioSystem/Code/Source/Engine/ATL.cpp +++ b/Gems/AudioSystem/Code/Source/Engine/ATL.cpp @@ -22,7 +22,8 @@ #include #include -#include +#include +#include #include namespace Audio @@ -1156,7 +1157,6 @@ namespace Audio EAudioRequestStatus eResult = eARS_FAILURE; const TAudioObjectID nATLObjectID = pAudioObject->GetID(); - const TAudioControlID nATLTriggerID = pTrigger->GetID(); const TObjectTriggerImplStates& rTriggerImplStates = pAudioObject->GetTriggerImpls(); for (auto const triggerImpl : pTrigger->m_cImplPtrs) @@ -1358,7 +1358,6 @@ namespace Audio { EAudioRequestStatus eResult = eARS_FAILURE; - const TAudioObjectID nATLObjectID = pAudioObject->GetID(); const TAudioControlID nATLTriggerID = pTrigger->GetID(); TObjectEventSet rEvents = pAudioObject->GetActiveEvents(); diff --git a/Gems/AudioSystem/Code/Source/Engine/ATLAudioObject.cpp b/Gems/AudioSystem/Code/Source/Engine/ATLAudioObject.cpp index 980757ffca..c8548efa04 100644 --- a/Gems/AudioSystem/Code/Source/Engine/ATLAudioObject.cpp +++ b/Gems/AudioSystem/Code/Source/Engine/ATLAudioObject.cpp @@ -1042,7 +1042,8 @@ namespace Audio auxGeom.SetRenderFlags(newRenderFlags); const bool drawRays = CVars::s_debugDrawOptions.AreAllFlagsActive(DebugDraw::Options::DrawRays); - const bool drawLabels = CVars::s_debugDrawOptions.AreAllFlagsActive(DebugDraw::Options::RayLabels); + // ToDo: Update to work with Atom? LYN-3677 + //const bool drawLabels = CVars::s_debugDrawOptions.AreAllFlagsActive(DebugDraw::Options::RayLabels); size_t numRays = m_obstOccType == eAOOCT_SINGLE_RAY ? 1 : s_maxRaysPerObject; for (size_t rayIndex = 0; rayIndex < numRays; ++rayIndex) diff --git a/Gems/AudioSystem/Code/Source/Engine/ATLComponents.cpp b/Gems/AudioSystem/Code/Source/Engine/ATLComponents.cpp index 91340ca9bb..996a2a80b6 100644 --- a/Gems/AudioSystem/Code/Source/Engine/ATLComponents.cpp +++ b/Gems/AudioSystem/Code/Source/Engine/ATLComponents.cpp @@ -284,10 +284,9 @@ namespace Audio /////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// - CAudioObjectManager::CAudioObjectManager(CAudioEventManager& refAudioEventManager) + CAudioObjectManager::CAudioObjectManager([[maybe_unused]] CAudioEventManager& refAudioEventManager) : m_cObjectPool(Audio::CVars::s_AudioObjectPoolSize, AudioObjectIDFactory::s_minValidAudioObjectID) , m_fTimeSinceLastVelocityUpdateMS(0.0f) - , m_refAudioEventManager(refAudioEventManager) #if !defined(AUDIO_RELEASE) , m_pDebugNameStore(nullptr) #endif // !AUDIO_RELEASE @@ -1777,7 +1776,6 @@ namespace Audio static float const fItemPlayingColor[4] = { 0.3f, 0.6f, 0.3f, 0.9f }; static float const fItemLoadingColor[4] = { 0.9f, 0.2f, 0.2f, 0.9f }; static float const fItemOtherColor[4] = { 0.8f, 0.8f, 0.8f, 0.9f }; - static float const fNoImplColor[4] = { 1.0f, 0.6f, 0.6f, 0.9f }; rAuxGeom.Draw2dLabel(fPosX, fPosY, 1.6f, fHeaderColor, false, "Audio Events [%zu]", m_cActiveAudioEvents.size()); fPosX += 20.0f; diff --git a/Gems/AudioSystem/Code/Source/Engine/ATLComponents.h b/Gems/AudioSystem/Code/Source/Engine/ATLComponents.h index 17a1b65afe..efdee4fd2f 100644 --- a/Gems/AudioSystem/Code/Source/Engine/ATLComponents.h +++ b/Gems/AudioSystem/Code/Source/Engine/ATLComponents.h @@ -160,8 +160,6 @@ namespace Audio CInstanceManager m_cObjectPool; float m_fTimeSinceLastVelocityUpdateMS; - CAudioEventManager& m_refAudioEventManager; - AudioRaycastManager m_raycastManager; }; diff --git a/Gems/AudioSystem/Code/Source/Engine/AudioSystem.cpp b/Gems/AudioSystem/Code/Source/Engine/AudioSystem.cpp index dfe34fb6eb..5f3603c956 100644 --- a/Gems/AudioSystem/Code/Source/Engine/AudioSystem.cpp +++ b/Gems/AudioSystem/Code/Source/Engine/AudioSystem.cpp @@ -292,7 +292,7 @@ namespace Audio PushRequestBlocking(request); m_audioSystemThread.Deactivate(); - const bool bSuccess = m_oATL.ShutDown(); + m_oATL.ShutDown(); m_bSystemInitialized = false; } diff --git a/Gems/AudioSystem/Code/Source/Engine/FileCacheManager.cpp b/Gems/AudioSystem/Code/Source/Engine/FileCacheManager.cpp index 791c86eba8..b106c4f9d2 100644 --- a/Gems/AudioSystem/Code/Source/Engine/FileCacheManager.cpp +++ b/Gems/AudioSystem/Code/Source/Engine/FileCacheManager.cpp @@ -841,7 +841,7 @@ namespace Audio streamer->SetRequestCompleteCallback( audioFileEntry->m_asyncStreamRequest, - [this](AZ::IO::FileRequestHandle request) + [](AZ::IO::FileRequestHandle request) { AZ_PROFILE_FUNCTION(Audio); AudioFileCacheManagerNotficationBus::QueueBroadcast( diff --git a/Gems/Blast/Code/Source/Actor/BlastActorFactory.cpp b/Gems/Blast/Code/Source/Actor/BlastActorFactory.cpp index 704661c716..989ea1221a 100644 --- a/Gems/Blast/Code/Source/Actor/BlastActorFactory.cpp +++ b/Gems/Blast/Code/Source/Actor/BlastActorFactory.cpp @@ -43,8 +43,6 @@ namespace Blast const Nv::Blast::ExtPxChunk* pxChunks = blastFamily.GetPxAsset().getChunks(); const NvBlastChunk* chunks = tkAsset->getChunks(); const uint32_t pxChunkCount = blastFamily.GetPxAsset().getChunkCount(); - const uint32_t chunkCount = tkAsset->getChunkCount(); - const uint32_t nodeCount = tkActor.getGraphNodeCount(); AZ_Assert(pxChunks, "ExtPxAsset asset has a null chunk array."); AZ_Assert(chunks, "TkActor's asset has a null chunk array."); @@ -183,8 +181,6 @@ namespace Blast bool BlastActorFactoryImpl::VisibleChunksHasStaticActor( const BlastFamily& blastFamily, const AZStd::vector& chunkIndices) const { - const uint32_t chunkCount = blastFamily.GetPxAsset().getChunkCount(); - const Nv::Blast::ExtPxChunk* pxChunks = blastFamily.GetPxAsset().getChunks(); if (!pxChunks) { diff --git a/Gems/Blast/Code/Source/Asset/BlastAsset.cpp b/Gems/Blast/Code/Source/Asset/BlastAsset.cpp index bfd27448c0..9046ae62d5 100644 --- a/Gems/Blast/Code/Source/Asset/BlastAsset.cpp +++ b/Gems/Blast/Code/Source/Asset/BlastAsset.cpp @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -27,6 +28,17 @@ namespace Blast { } + void BlastAsset::Reflect(AZ::ReflectContext* context) + { + if (auto* serializeContext = azrtti_cast(context)) + { + serializeContext->Class() + ->Version(0) + ; + } + } + + bool BlastAsset::LoadFromBuffer(void* buffer, size_t bytesSize) { Nv::Blast::ExtSerialization* serialization = nullptr; diff --git a/Gems/Blast/Code/Source/Asset/BlastAsset.h b/Gems/Blast/Code/Source/Asset/BlastAsset.h index 8c7fd1db4b..22754aa535 100644 --- a/Gems/Blast/Code/Source/Asset/BlastAsset.h +++ b/Gems/Blast/Code/Source/Asset/BlastAsset.h @@ -25,6 +25,8 @@ namespace Blast BlastAsset(Nv::Blast::ExtPxAsset* pxAsset = nullptr, NvBlastExtDamageAccelerator* damageAccelerator = nullptr); + static void Reflect(AZ::ReflectContext* context); + bool LoadFromBuffer(void* buffer, size_t bytesSize); const Nv::Blast::ExtPxAsset* GetPxAsset() const diff --git a/Gems/Blast/Code/Source/Components/BlastFamilyComponent.cpp b/Gems/Blast/Code/Source/Components/BlastFamilyComponent.cpp index 9b61ee0dbe..c2fb81e86a 100644 --- a/Gems/Blast/Code/Source/Components/BlastFamilyComponent.cpp +++ b/Gems/Blast/Code/Source/Components/BlastFamilyComponent.cpp @@ -48,6 +48,7 @@ namespace Blast BlastFamilyComponentNotificationBusHandler::Reflect(context); BlastActorConfiguration::Reflect(context); BlastActorData::Reflect(context); + BlastAsset::Reflect(context); if (AZ::SerializeContext* serialize = azrtti_cast(context)) { diff --git a/Gems/Camera/Code/Source/ViewportCameraSelectorWindow_Internals.h b/Gems/Camera/Code/Source/ViewportCameraSelectorWindow_Internals.h index 2c3d114908..b07ae7789f 100644 --- a/Gems/Camera/Code/Source/ViewportCameraSelectorWindow_Internals.h +++ b/Gems/Camera/Code/Source/ViewportCameraSelectorWindow_Internals.h @@ -58,7 +58,6 @@ namespace Camera private: AZStd::vector m_cameraItems; AZ::EntityId m_sequenceCameraEntityId; - bool m_sequenceCameraSelected; }; struct ViewportCameraSelectorWindow diff --git a/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/ActorCommands.cpp b/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/ActorCommands.cpp index da5366f6cf..85bb726822 100644 --- a/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/ActorCommands.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/CommandSystem/Source/ActorCommands.cpp @@ -145,7 +145,6 @@ namespace CommandSystem AZStd::vector nodeNames; AzFramework::StringFunc::Tokenize(attachmentNodes.c_str(), nodeNames, ";", false, true); - const size_t numNodeNames = nodeNames.size(); // Remove the given nodes from the attachment node list by unsetting the flag. if (AzFramework::StringFunc::Equal(nodeAction.c_str(), "remove")) @@ -224,7 +223,6 @@ namespace CommandSystem AZStd::vector nodeNames; AzFramework::StringFunc::Tokenize(nodesExcludedFromBounds.c_str(), nodeNames, ";", false, true); - const size_t numNodeNames = nodeNames.size(); // Remove the selected nodes from the bounding volume calculations. if (AzFramework::StringFunc::Equal(nodeAction.c_str(), "remove")) diff --git a/Gems/EMotionFX/Code/EMotionFX/Pipeline/RCExt/Actor/ActorGroupExporter.cpp b/Gems/EMotionFX/Code/EMotionFX/Pipeline/RCExt/Actor/ActorGroupExporter.cpp index efd3d84aa0..4cba50138a 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Pipeline/RCExt/Actor/ActorGroupExporter.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Pipeline/RCExt/Actor/ActorGroupExporter.cpp @@ -163,7 +163,6 @@ namespace EMotionFX } // Default to the first mesh group until we get a way to choose it via the scene settings (ATOM-13590). - AZStd::optional meshAssetId = AZStd::nullopt; AZ_Error("EMotionFX", atomModelAssets.size() <= 1, "Ambigious mesh for actor asset. More than one mesh group found. Defaulting to the first one."); if (!atomModelAssets.empty()) { diff --git a/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/RenderUtil.cpp b/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/RenderUtil.cpp index 183d56a07f..6fd28ee72f 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/RenderUtil.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Rendering/Common/RenderUtil.cpp @@ -519,7 +519,6 @@ namespace MCommon EMotionFX::SubMesh* subMesh = mesh->GetSubMesh(subMeshIndex); const uint32 numVertices = subMesh->GetNumVertices(); const uint32 startVertex = subMesh->GetStartVertex(); - const uint32 startIndex = subMesh->GetStartIndex(); for (uint32 j = 0; j < numVertices; ++j) { @@ -1332,7 +1331,6 @@ namespace MCommon // render mesh based axis void RenderUtil::RenderAxis(float size, const AZ::Vector3& position, const AZ::Vector3& right, const AZ::Vector3& up, const AZ::Vector3& forward) { - const float zeroSphereRadius = size * 0.075f; static const MCore::RGBAColor xAxisColor(1.0f, 0.0f, 0.0f); static const MCore::RGBAColor yAxisColor(0.0f, 1.0f, 0.0f); static const MCore::RGBAColor zAxisColor(0.0f, 0.0f, 1.0f); diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/Attachment.h b/Gems/EMotionFX/Code/EMotionFX/Source/Attachment.h index 67a62ac7f6..d2cd9cdc6f 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/Attachment.h +++ b/Gems/EMotionFX/Code/EMotionFX/Source/Attachment.h @@ -63,7 +63,7 @@ namespace EMotionFX * This can be implemented for say skin attachments, which copy over joint transforms from the actor instance they are attached to. * @param outPose The pose that will be modified. */ - virtual void UpdateJointTransforms(Pose& outPose) { AZ_UNUSED(outPose) }; + virtual void UpdateJointTransforms(Pose& outPose) { AZ_UNUSED(outPose); }; /** * Get the actor instance object of the attachment. diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/BlendSpace2DNode.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/BlendSpace2DNode.cpp index b34a860b71..03a7552410 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/BlendSpace2DNode.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/BlendSpace2DNode.cpp @@ -24,19 +24,6 @@ namespace { - // Dimensions of the 2D grid into which we place the triangles for quick lookup - const uint32_t kGridCellCountX = 10; - const uint32_t kGridCellCountY = 10; - - AZ_FORCE_INLINE void GetBoundsOfTriangle(const AZ::Vector2 triVerts[3], - float& minX, float& minY, float& maxX, float& maxY) - { - minX = AZStd::min(triVerts[0].GetX(), AZStd::min(triVerts[1].GetX(), triVerts[2].GetX())); - minY = AZStd::min(triVerts[0].GetY(), AZStd::min(triVerts[1].GetY(), triVerts[2].GetY())); - maxX = AZStd::max(triVerts[0].GetX(), AZStd::max(triVerts[1].GetX(), triVerts[2].GetX())); - maxY = AZStd::max(triVerts[0].GetY(), AZStd::max(triVerts[1].GetY(), triVerts[2].GetY())); - } - AZ_FORCE_INLINE bool IsDegenerateTriangle(const AZ::Vector2& p0, const AZ::Vector2& p1, const AZ::Vector2& p2) { const AZ::Vector2 v01(p1 - p0); diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/Importer/ChunkProcessors.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/Importer/ChunkProcessors.cpp index 7d800f8928..fad160407b 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/Importer/ChunkProcessors.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/Importer/ChunkProcessors.cpp @@ -1585,9 +1585,6 @@ namespace EMotionFX // get the expression name const char* morphTargetName = SharedHelperData::ReadString(file, importParams.m_sharedData, endianType); - // get the level of detail of the expression part - const uint32 morphTargetLOD = morphTargetChunk.m_lod; - if (GetLogging()) { MCore::LogDetailedInfo(" + Morph Target:"); @@ -1732,9 +1729,6 @@ namespace EMotionFX // get the expression name const char* morphTargetName = SharedHelperData::ReadString(file, importParams.m_sharedData, endianType); - // get the level of detail of the expression part - const uint32 morphTargetLOD = morphTargetChunk.m_lod; - if (GetLogging()) { MCore::LogDetailedInfo(" + Morph Target:"); diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/RagdollInstance.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/RagdollInstance.cpp index c7da3430b1..426f6da473 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/RagdollInstance.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/RagdollInstance.cpp @@ -433,7 +433,6 @@ namespace EMotionFX } const EMotionFX::TransformData* transformData = m_actorInstance->GetTransformData(); - const size_t transformCount = transformData->GetNumTransforms(); const EMotionFX::Skeleton* skeleton = m_actorInstance->GetActor()->GetSkeleton(); const size_t jointCount = skeleton->GetNumNodes(); @@ -498,9 +497,7 @@ namespace EMotionFX const AZ::Vector3 currentPos = currentNodeState.m_position; const AZ::Vector3 currentParentPos = currentParentJointPose.m_position; - const Physics::RagdollNodeState& targetJointPose = ragdollTargetPose[ragdollJointIndex.GetValue()]; const Physics::RagdollNodeState& targetParentJointPose = ragdollTargetPose[ragdollParentJointIndex.GetValue()]; - const float strength = targetJointPose.m_strength; if (targetParentJointPose.m_simulationType == Physics::SimulationType::Dynamic) { diff --git a/Gems/EMotionFX/Code/EMotionFX/Source/SpringSolver.cpp b/Gems/EMotionFX/Code/EMotionFX/Source/SpringSolver.cpp index 83cbc41a36..adf0a0cc2b 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Source/SpringSolver.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Source/SpringSolver.cpp @@ -310,7 +310,6 @@ namespace EMotionFX SetParentParticle(parentParticleIndex); // Register the joint, which creates a particle internally. - const bool isPinned = (parentParticleIndex != InvalidIndex) ? joint->IsPinned() : true; SpringSolver::Particle* particle = AddJoint(joint); if (!particle) { diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/FileManager.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/FileManager.h index 98d7de188d..9e2b4001b5 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/FileManager.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/FileManager.h @@ -112,8 +112,6 @@ namespace EMStudio QString m_lastWorkspaceFolder; QString m_lastNodeMapFolder; - bool m_skipFileChangedCheck; - void UpdateLastUsedFolder(const char* filename, QString& outLastFolder) const; QString GetLastUsedFolder(const QString& lastUsedFolder) const; }; diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/MainWindow.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/MainWindow.h index 734dd7840d..318838b2b1 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/MainWindow.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/MainWindow.h @@ -203,9 +203,6 @@ namespace EMStudio QAction* m_saveAllAction; QAction* m_mergeActorAction; QAction* m_saveSelectedActorsAction; -#ifdef EMFX_DEVELOPMENT_BUILD - QAction* m_saveSelectedActorAsAttachmentsAction; -#endif // application mode QComboBox* m_applicationMode; diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/MainWindowEventFilter.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/MainWindowEventFilter.h index c7e82b13e9..144fac4eed 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/MainWindowEventFilter.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/MainWindowEventFilter.h @@ -27,6 +27,6 @@ namespace EMStudio virtual bool nativeEventFilter(const QByteArray& /*eventType*/, void* message, long* /*result*/) Q_DECL_OVERRIDE; private: - MainWindow* m_mainWindow; + [[maybe_unused]] MainWindow* m_mainWindow; }; } diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/AnimGraphModel.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/AnimGraphModel.h index 7ff61123cb..46ab632ce2 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/AnimGraphModel.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/AnimGraphModel.h @@ -313,7 +313,7 @@ namespace EMStudio bool Execute(MCore::Command * command, const MCore::CommandLine& commandLine) override; \ bool Undo(MCore::Command* command, const MCore::CommandLine& commandLine) override; \ private: \ - AnimGraphModel& m_animGraphModel; \ + [[maybe_unused]] AnimGraphModel& m_animGraphModel; \ }; \ friend class CLASSNAME; diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/BlendSpace1DNodeWidget.cpp b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/BlendSpace1DNodeWidget.cpp index bd8b94f361..e4990d658b 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/BlendSpace1DNodeWidget.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/BlendSpace1DNodeWidget.cpp @@ -364,8 +364,6 @@ namespace EMStudio const int rectLeft = m_drawRect.left(); const int rectRight = m_drawRect.right(); - const int rectBottom = m_drawRect.bottom(); - const int xValueTop = rectBottom + 4; const int xAxisLabelTop = m_drawCenterY + 15; const char numFormat = 'g'; const int numPrecision = 4; diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/ParameterWindow.cpp b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/ParameterWindow.cpp index c93d358c07..3f3c7c1c7d 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/ParameterWindow.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/ParameterWindow.cpp @@ -651,7 +651,6 @@ namespace EMStudio // enable/disable recording/playback mode void ParameterWindow::OnRecorderStateChanged() { - const bool readOnly = (EMotionFX::GetRecorder().GetIsInPlayMode()); // disable when in playback mode, enable otherwise if (m_animGraph) { // update parameter values diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/ParameterWindow.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/ParameterWindow.h index 66cb62f0a5..f3b1702751 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/ParameterWindow.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/AnimGraph/ParameterWindow.h @@ -205,7 +205,6 @@ namespace EMStudio ParameterWindowTreeWidget* m_treeWidget; AzQtComponents::FilteredSearchWidget* m_searchWidget; QVBoxLayout* m_verticalLayout; - QScrollArea* m_scrollArea; AZStd::string m_nameString; struct ParameterWidget { diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/Attachments/AttachmentsPlugin.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/Attachments/AttachmentsPlugin.h index d59d0d1b93..edab3a9580 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/Attachments/AttachmentsPlugin.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/Attachments/AttachmentsPlugin.h @@ -85,7 +85,6 @@ namespace EMStudio CommandAdjustActorCallback* m_adjustActorCallback; CommandRemoveActorInstanceCallback* m_removeActorInstanceCallback; - QWidget* m_noSelectionWidget; MysticQt::DialogStack* m_dialogStack; AttachmentsWindow* m_attachmentsWindow; AttachmentsHierarchyWindow* m_attachmentsHierarchyWindow; diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MorphTargetsWindow/MorphTargetsWindowPlugin.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MorphTargetsWindow/MorphTargetsWindowPlugin.h index d2295fcd9c..26503bfbc6 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MorphTargetsWindow/MorphTargetsWindowPlugin.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MorphTargetsWindow/MorphTargetsWindowPlugin.h @@ -91,6 +91,5 @@ namespace EMStudio QVBoxLayout* m_staticTextLayout; QWidget* m_staticTextWidget; MysticQt::DialogStack* m_dialogStack; - QLabel* m_infoText; }; } // namespace EMStudio diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionEvents/MotionEventsPlugin.cpp b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionEvents/MotionEventsPlugin.cpp index 316b2017cc..8d77bd5e04 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionEvents/MotionEventsPlugin.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionEvents/MotionEventsPlugin.cpp @@ -32,7 +32,6 @@ namespace EMStudio , m_dialogStack(nullptr) , m_motionEventPresetsWidget(nullptr) , m_motionEventWidget(nullptr) - , m_motionTable(nullptr) , m_timeViewPlugin(nullptr) , m_trackHeaderWidget(nullptr) , m_trackDataWidget(nullptr) diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionEvents/MotionEventsPlugin.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionEvents/MotionEventsPlugin.h index 7cd34e4bca..f2c0f43b9b 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionEvents/MotionEventsPlugin.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionEvents/MotionEventsPlugin.h @@ -87,7 +87,6 @@ namespace EMStudio MotionEventPresetsWidget* m_motionEventPresetsWidget; MotionEventWidget* m_motionEventWidget; - QTableWidget* m_motionTable; TimeViewPlugin* m_timeViewPlugin; TrackHeaderWidget* m_trackHeaderWidget; TrackDataWidget* m_trackDataWidget; diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionSetsWindow/MotionSetWindow.cpp b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionSetsWindow/MotionSetWindow.cpp index 6d16ea19b1..393e26790b 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionSetsWindow/MotionSetWindow.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionSetsWindow/MotionSetWindow.cpp @@ -819,7 +819,6 @@ namespace EMStudio } const QList selectedItems = m_tableWidget->selectedItems(); - const size_t numSelectedItems = selectedItems.count(); // Get the row indices from the selected items. AZStd::vector rowIndices; @@ -1079,7 +1078,6 @@ namespace EMStudio // Get the row indices from the selected items. AZStd::vector rowIndices; GetRowIndices(selectedItems, rowIndices); - const size_t numRowIndices = rowIndices.size(); // remove motion from motion window, too? bool removeMotion = false; diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionSetsWindow/MotionSetWindow.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionSetsWindow/MotionSetWindow.h index 8c1fe04662..a1cab4e89f 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionSetsWindow/MotionSetWindow.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionSetsWindow/MotionSetWindow.h @@ -187,7 +187,6 @@ namespace EMStudio size_t CalcNumMotionEntriesUsingMotionExcluding(const AZStd::string& motionFilename, EMotionFX::MotionSet* excludedMotionSet); private: - QVBoxLayout* m_vLayout = nullptr; MotionSetTableWidget* m_tableWidget = nullptr; QAction* m_addAction = nullptr; diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionWindow/MotionExtractionWindow.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionWindow/MotionExtractionWindow.h index 5e314df323..2f0bf63685 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionWindow/MotionExtractionWindow.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionWindow/MotionExtractionWindow.h @@ -68,7 +68,6 @@ namespace EMStudio // general MotionWindowPlugin* m_motionWindowPlugin; - QCheckBox* m_autoMode; // flags widget QWidget* m_flagsWidget; diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionWindow/MotionRetargetingWindow.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionWindow/MotionRetargetingWindow.h index a846982eca..3090a1f8bd 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionWindow/MotionRetargetingWindow.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/MotionWindow/MotionRetargetingWindow.h @@ -49,8 +49,6 @@ namespace EMStudio private: MotionWindowPlugin* m_motionWindowPlugin; QCheckBox* m_motionRetargetingButton; - EMotionFX::ActorInstance* m_selectedActorInstance; - EMotionFX::Actor* m_actor; CommandSystem::SelectionList m_selectionList; }; } // namespace EMStudio diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/NodeGroups/NodeGroupWidget.h b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/NodeGroups/NodeGroupWidget.h index c96b972085..e1530ebd3b 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/NodeGroups/NodeGroupWidget.h +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/NodeGroups/NodeGroupWidget.h @@ -58,7 +58,6 @@ namespace EMStudio NodeSelectionWindow* m_nodeSelectionWindow; CommandSystem::SelectionList m_nodeSelectionList; EMotionFX::NodeGroup* m_nodeGroup; - uint16 m_nodeGroupIndex; CommandSystem::CommandAdjustNodeGroup::NodeAction m_nodeAction; // widgets diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/TimeView/TimeViewToolBar.cpp b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/TimeView/TimeViewToolBar.cpp index d95b606b3f..14a27eec49 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/TimeView/TimeViewToolBar.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/TimeView/TimeViewToolBar.cpp @@ -441,7 +441,7 @@ namespace EMStudio const bool playbackOptionsVisible = m_playbackOptions->UpdateInterface(mode, /*showRightSeparator=*/false); const bool playbackControlsVisible = m_playbackControls->UpdateInterface(mode, /*showRightSeparator=*/playbackOptionsVisible); - const bool recorderGroupVisible = m_recorderGroup->UpdateInterface(mode, /*showRightSeparator=*/playbackControlsVisible); + m_recorderGroup->UpdateInterface(mode, /*showRightSeparator=*/playbackControlsVisible); } void TimeViewToolBar::OnDetailedNodes() diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/TimeView/TrackDataHeaderWidget.cpp b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/TimeView/TrackDataHeaderWidget.cpp index 0d1f55c172..9524d6f57d 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/TimeView/TrackDataHeaderWidget.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/Plugins/StandardPlugins/Source/TimeView/TrackDataHeaderWidget.cpp @@ -284,8 +284,6 @@ namespace EMStudio { m_plugin->SetRedrawFlag(); - const bool ctrlPressed = event->modifiers() & Qt::ControlModifier; - const bool shiftPressed = event->modifiers() & Qt::ShiftModifier; const bool altPressed = event->modifiers() & Qt::AltModifier; // store the last clicked position @@ -370,8 +368,6 @@ namespace EMStudio m_plugin->GetTimeInfoWidget()->SetIsOverwriteMode(false); } - const bool ctrlPressed = event->modifiers() & Qt::ControlModifier; - if (event->button() == Qt::RightButton) { m_mouseRightClicked = false; diff --git a/Gems/EMotionFX/Code/Source/Editor/Plugins/SimulatedObject/SimulatedJointWidget.cpp b/Gems/EMotionFX/Code/Source/Editor/Plugins/SimulatedObject/SimulatedJointWidget.cpp index 4dd8b94303..1e35a084fa 100644 --- a/Gems/EMotionFX/Code/Source/Editor/Plugins/SimulatedObject/SimulatedJointWidget.cpp +++ b/Gems/EMotionFX/Code/Source/Editor/Plugins/SimulatedObject/SimulatedJointWidget.cpp @@ -441,8 +441,8 @@ namespace EMotionFX void SimulatedJointWidget::UpdateDetailsView(const QItemSelection& selected, const QItemSelection& deselected) { - AZ_UNUSED(selected) - AZ_UNUSED(deselected) + AZ_UNUSED(selected); + AZ_UNUSED(deselected); const SimulatedObjectModel* model = m_plugin->GetSimulatedObjectModel(); const QItemSelectionModel* selectionModel = model->GetSelectionModel(); diff --git a/Gems/EMotionFX/Code/Source/Editor/Plugins/SimulatedObject/SimulatedObjectWidget.cpp b/Gems/EMotionFX/Code/Source/Editor/Plugins/SimulatedObject/SimulatedObjectWidget.cpp index a2b23e3268..48104707de 100644 --- a/Gems/EMotionFX/Code/Source/Editor/Plugins/SimulatedObject/SimulatedObjectWidget.cpp +++ b/Gems/EMotionFX/Code/Source/Editor/Plugins/SimulatedObject/SimulatedObjectWidget.cpp @@ -495,7 +495,6 @@ namespace EMotionFX if (renderSimulatedJoints && !selectedJointIndices.empty()) { // Render the joint radius. - const MCore::RGBAColor defaultColor = renderPlugin->GetRenderOptions()->GetSelectedSimulatedObjectColliderColor(); const size_t actorInstanceCount = GetActorManager().GetNumActorInstances(); for (size_t actorInstanceIndex = 0; actorInstanceIndex < actorInstanceCount; ++actorInstanceIndex) { diff --git a/Gems/EMotionFX/Code/Source/Editor/PropertyWidgets/AnimGraphTransitionHandler.cpp b/Gems/EMotionFX/Code/Source/Editor/PropertyWidgets/AnimGraphTransitionHandler.cpp index 4bc4da1030..ce114a498e 100644 --- a/Gems/EMotionFX/Code/Source/Editor/PropertyWidgets/AnimGraphTransitionHandler.cpp +++ b/Gems/EMotionFX/Code/Source/Editor/PropertyWidgets/AnimGraphTransitionHandler.cpp @@ -206,7 +206,7 @@ namespace EMotionFX QPushButton* removeTransitionButton = new QPushButton(); EMStudio::EMStudioManager::MakeTransparentButton(removeTransitionButton, "Images/Icons/Trash.svg", "Remove transition from list"); - connect(removeTransitionButton, &QPushButton::clicked, this, [this, removeTransitionButton, id]() + connect(removeTransitionButton, &QPushButton::clicked, this, [this, id]() { m_transitionIds.erase(AZStd::remove(m_transitionIds.begin(), m_transitionIds.end(), id), m_transitionIds.end()); Reinit(); diff --git a/Gems/EMotionFX/Code/Source/Integration/Editor/Components/EditorActorComponent.cpp b/Gems/EMotionFX/Code/Source/Integration/Editor/Components/EditorActorComponent.cpp index 485b56c077..ed4edda891 100644 --- a/Gems/EMotionFX/Code/Source/Integration/Editor/Components/EditorActorComponent.cpp +++ b/Gems/EMotionFX/Code/Source/Integration/Editor/Components/EditorActorComponent.cpp @@ -683,7 +683,6 @@ namespace EMotionFX const size_t lodLevel = m_actorInstance->GetLODLevel(); Actor* actor = m_actorAsset.Get()->GetActor(); const size_t numNodes = actor->GetNumNodes(); - const size_t numLods = actor->GetNumLODLevels(); for (size_t nodeIndex = 0; nodeIndex < numNodes; ++nodeIndex) { Mesh* mesh = actor->GetMesh(lodLevel, nodeIndex); diff --git a/Gems/EMotionFX/Code/Tests/AnimGraphCopyPasteTests.cpp b/Gems/EMotionFX/Code/Tests/AnimGraphCopyPasteTests.cpp index 4feb8cd86a..dee1bd5ca2 100644 --- a/Gems/EMotionFX/Code/Tests/AnimGraphCopyPasteTests.cpp +++ b/Gems/EMotionFX/Code/Tests/AnimGraphCopyPasteTests.cpp @@ -184,7 +184,6 @@ namespace EMotionFX void VerifyAfterOperation() { const AZStd::vector conditionTypeIds = GetConditionTypeIds(); - const size_t numConditionTypes = conditionTypeIds.size(); const bool cutMode = GetParam(); if (cutMode) { @@ -419,7 +418,6 @@ namespace EMotionFX AZStd::string result; MCore::CommandGroup commandGroup; const bool cutMode = GetParam(); - const AnimGraphConnectionId oldtransitionId = m_transition->GetId(); // Add transition actions to the node. AnimGraphParameterAction* action1 = aznew AnimGraphParameterAction(); diff --git a/Gems/EMotionFX/Code/Tests/AnimGraphEventTests.cpp b/Gems/EMotionFX/Code/Tests/AnimGraphEventTests.cpp index 1b88092917..bd3fa10b24 100644 --- a/Gems/EMotionFX/Code/Tests/AnimGraphEventTests.cpp +++ b/Gems/EMotionFX/Code/Tests/AnimGraphEventTests.cpp @@ -88,7 +88,7 @@ namespace EMotionFX void SimulateTest(float simulationTime, float expectedFps, float fpsVariance) { Simulate(simulationTime, expectedFps, fpsVariance, - /*preCallback*/[this](AnimGraphInstance*) + /*preCallback*/[](AnimGraphInstance*) { }, /*postCallback*/[this](AnimGraphInstance*) @@ -102,8 +102,8 @@ namespace EMotionFX EXPECT_EQ(this->m_eventHandler->m_numTransitionsStarted, numStates); EXPECT_EQ(this->m_eventHandler->m_numTransitionsEnded, numStates); }, - /*preUpdateCallback*/[this](AnimGraphInstance*, float, float, int) {}, - /*postUpdateCallback*/[this](AnimGraphInstance*, float, float, int) {}); + /*preUpdateCallback*/[](AnimGraphInstance*, float, float, int) {}, + /*postUpdateCallback*/[](AnimGraphInstance*, float, float, int) {}); const int numStates = GetParam().m_numStates; if (numStates > 1) diff --git a/Gems/EMotionFX/Code/Tests/AnimGraphRefCountTests.cpp b/Gems/EMotionFX/Code/Tests/AnimGraphRefCountTests.cpp index 8b51f5b814..54f945d95f 100644 --- a/Gems/EMotionFX/Code/Tests/AnimGraphRefCountTests.cpp +++ b/Gems/EMotionFX/Code/Tests/AnimGraphRefCountTests.cpp @@ -32,12 +32,10 @@ namespace EMotionFX this->m_animGraphInstance->SetAutoReleaseRefDatas(false); this->m_animGraphInstance->SetAutoReleasePoses(false); }, - /*postCallback*/[this](AnimGraphInstance*){}, - /*preUpdateCallback*/[this](AnimGraphInstance*, float, float, int){}, + /*postCallback*/[](AnimGraphInstance*){}, + /*preUpdateCallback*/[](AnimGraphInstance*, float, float, int){}, /*postUpdateCallback*/[this](AnimGraphInstance*, float, float, int) { - const uint32 threadIndex = this->m_actorInstance->GetThreadIndex(); - // Check if data and pose ref counts are back to 0 for all nodes. const size_t numNodes = this->m_animGraph->GetNumNodes(); for (size_t i = 0; i < numNodes; ++i) diff --git a/Gems/EMotionFX/Code/Tests/AnimGraphStateMachineInterruptionTests.cpp b/Gems/EMotionFX/Code/Tests/AnimGraphStateMachineInterruptionTests.cpp index 39fc296d9f..b0f070d203 100644 --- a/Gems/EMotionFX/Code/Tests/AnimGraphStateMachineInterruptionTests.cpp +++ b/Gems/EMotionFX/Code/Tests/AnimGraphStateMachineInterruptionTests.cpp @@ -137,9 +137,9 @@ namespace EMotionFX m_eventHandler->m_numStatesEnded -= 1; Simulate(20.0f/*simulationTime*/, 60.0f/*expectedFps*/, 0.0f/*fpsVariance*/, - /*preCallback*/[this]([[maybe_unused]] AnimGraphInstance* animGraphInstance){}, - /*postCallback*/[this]([[maybe_unused]] AnimGraphInstance* animGraphInstance){}, - /*preUpdateCallback*/[this](AnimGraphInstance*, float, float, int) {}, + /*preCallback*/[]([[maybe_unused]] AnimGraphInstance* animGraphInstance){}, + /*postCallback*/[]([[maybe_unused]] AnimGraphInstance* animGraphInstance){}, + /*preUpdateCallback*/[](AnimGraphInstance*, float, float, int) {}, /*postUpdateCallback*/[this](AnimGraphInstance* animGraphInstance, [[maybe_unused]] float time, [[maybe_unused]] float timeDelta, int frame) { const std::vector& activeObjectsAtFrame = GetParam().m_activeObjectsAtFrame; @@ -457,14 +457,11 @@ namespace EMotionFX float prevBlendWeight = 0.0f; Simulate(2.0f /*simulationTime*/, 10.0f /*expectedFps*/, 0.0f /*fpsVariance*/, - /*preCallback*/[this]([[maybe_unused]] AnimGraphInstance* animGraphInstance) {}, - /*postCallback*/[this]([[maybe_unused]] AnimGraphInstance* animGraphInstance) {}, - /*preUpdateCallback*/[this](AnimGraphInstance*, float, float, int) {}, + /*preCallback*/[]([[maybe_unused]] AnimGraphInstance* animGraphInstance) {}, + /*postCallback*/[]([[maybe_unused]] AnimGraphInstance* animGraphInstance) {}, + /*preUpdateCallback*/[](AnimGraphInstance*, float, float, int) {}, /*postUpdateCallback*/[this, &prevGotInterrupted, &prevBlendWeight](AnimGraphInstance* animGraphInstance, [[maybe_unused]] float time, [[maybe_unused]] float timeDelta, [[maybe_unused]] int frame) { - const AnimGraphStateMachine_InterruptionPropertiesTestData param = GetParam(); - - const AnimGraphStateTransition::EInterruptionMode interruptionMode = m_transitionLeft->GetInterruptionMode(); const float maxInterruptionBlendWeight = m_transitionLeft->GetMaxInterruptionBlendWeight(); const bool gotInterrupted = m_transitionLeft->GotInterrupted(animGraphInstance); const bool gotInterruptedThisFrame = gotInterrupted && !prevGotInterrupted; diff --git a/Gems/EMotionFX/Code/Tests/AnimGraphStateMachineSyncTests.cpp b/Gems/EMotionFX/Code/Tests/AnimGraphStateMachineSyncTests.cpp index 37996abbd8..d95140a23b 100644 --- a/Gems/EMotionFX/Code/Tests/AnimGraphStateMachineSyncTests.cpp +++ b/Gems/EMotionFX/Code/Tests/AnimGraphStateMachineSyncTests.cpp @@ -100,13 +100,11 @@ namespace EMotionFX TEST_P(AnimGraphStateMachineSyncFixture, PlayspeedTests) { - const AnimGraphStateMachineSyncParam param = GetParam(); - bool transitioned = false; Simulate(2.0f/*simulationTime*/, 10.0f/*expectedFps*/, 0.0f/*fpsVariance*/, - /*preCallback*/[this]([[maybe_unused]] AnimGraphInstance* animGraphInstance){}, - /*postCallback*/[this]([[maybe_unused]] AnimGraphInstance* animGraphInstance){}, - /*preUpdateCallback*/[this](AnimGraphInstance*, float, float, int){}, + /*preCallback*/[]([[maybe_unused]] AnimGraphInstance* animGraphInstance){}, + /*postCallback*/[]([[maybe_unused]] AnimGraphInstance* animGraphInstance){}, + /*preUpdateCallback*/[](AnimGraphInstance*, float, float, int){}, /*postUpdateCallback*/[this, &transitioned](AnimGraphInstance* animGraphInstance, [[maybe_unused]] float time, [[maybe_unused]] float timeDelta, [[maybe_unused]] int frame) { if (m_rootStateMachine->IsTransitionActive(m_transition, animGraphInstance)) diff --git a/Gems/EMotionFX/Code/Tests/BlendTreeBlendNNodeTests.cpp b/Gems/EMotionFX/Code/Tests/BlendTreeBlendNNodeTests.cpp index 1f5fb9a512..53744aeb6b 100644 --- a/Gems/EMotionFX/Code/Tests/BlendTreeBlendNNodeTests.cpp +++ b/Gems/EMotionFX/Code/Tests/BlendTreeBlendNNodeTests.cpp @@ -332,9 +332,7 @@ namespace EMotionFX EXPECT_NEAR(durationA, durationN, epsilon); // Node B gets synced to the blend N node which got synced to node A. - const float timeRatio = durationA / durationB; const float timeRatio2 = durationB / durationA; - const float factorA = AZ::Lerp(1.0f, timeRatio, blendWeight); const float factorB = AZ::Lerp(timeRatio2, 1.0f, blendWeight); const float primaryMotionPlaySpeed = m_motionNodes[motionIndexA]->GetDefaultPlaySpeed(); const float interpolatedSpeed = AZ::Lerp(playSpeedA, primaryMotionPlaySpeed, blendWeight); diff --git a/Gems/EMotionFX/Code/Tests/BlendTreeRagdollNodeTests.cpp b/Gems/EMotionFX/Code/Tests/BlendTreeRagdollNodeTests.cpp index 85504675db..a01d333e95 100644 --- a/Gems/EMotionFX/Code/Tests/BlendTreeRagdollNodeTests.cpp +++ b/Gems/EMotionFX/Code/Tests/BlendTreeRagdollNodeTests.cpp @@ -115,7 +115,6 @@ namespace EMotionFX { AddRagdollNodeConfig(ragdollNodes, jointName.c_str()); } - const size_t numRagdollNodes = ragdollNodes.size(); // Create the ragdoll instance and check if the ragdoll root node is set correctly. TestRagdoll testRagdoll; diff --git a/Gems/EMotionFX/Code/Tests/BlendTreeTwoLinkIKNodeTests.cpp b/Gems/EMotionFX/Code/Tests/BlendTreeTwoLinkIKNodeTests.cpp index eab445ddfe..5d57c74d10 100644 --- a/Gems/EMotionFX/Code/Tests/BlendTreeTwoLinkIKNodeTests.cpp +++ b/Gems/EMotionFX/Code/Tests/BlendTreeTwoLinkIKNodeTests.cpp @@ -165,8 +165,6 @@ namespace EMotionFX if (weight) { const AZ::Vector3 expectedPosition(goalX, goalY, goalZ); - const AZ::Vector3 dist = (expectedPosition - testJointNewPos).GetAbs(); - const float length = dist.GetLength(); EXPECT_TRUE(PosePositionCompareClose(testJointNewPos, expectedPosition, 0.0001f)) << "Joint position should be similar to expected position."; } diff --git a/Gems/EMotionFX/Code/Tests/Integration/ActorComponentRagdollTests.cpp b/Gems/EMotionFX/Code/Tests/Integration/ActorComponentRagdollTests.cpp index 809dd67573..4c9eb2c32c 100644 --- a/Gems/EMotionFX/Code/Tests/Integration/ActorComponentRagdollTests.cpp +++ b/Gems/EMotionFX/Code/Tests/Integration/ActorComponentRagdollTests.cpp @@ -61,7 +61,6 @@ namespace EMotionFX TEST_F(EntityComponentFixture, ActorComponent_ActivateRagdoll) { AZ::EntityId entityId(740216387); - AZ::Crc32 worldId(174592); AzPhysics::SceneEvents::OnSceneSimulationFinishEvent sceneFinishSimEvent; diff --git a/Gems/EMotionFX/Code/Tests/MotionExtractionBusTests.cpp b/Gems/EMotionFX/Code/Tests/MotionExtractionBusTests.cpp index d8b8a2a430..170f4d2d75 100644 --- a/Gems/EMotionFX/Code/Tests/MotionExtractionBusTests.cpp +++ b/Gems/EMotionFX/Code/Tests/MotionExtractionBusTests.cpp @@ -132,8 +132,6 @@ namespace EMotionFX EXPECT_TRUE(hasCustomMotionExtractionController) << "MotionExtractionBus is not found."; - const float deltaTimeInv = (timeDelta > 0.0f) ? (1.0f / timeDelta) : 0.0f; - AZ::Transform currentTransform = AZ::Transform::CreateIdentity(); AZ::TransformBus::EventResult(currentTransform, m_entityId, &AZ::TransformBus::Events::GetWorldTM); diff --git a/Gems/EMotionFX/Code/Tests/Prefabs/LeftArmSkeleton.h b/Gems/EMotionFX/Code/Tests/Prefabs/LeftArmSkeleton.h index 2af9da3306..b9ddac817b 100644 --- a/Gems/EMotionFX/Code/Tests/Prefabs/LeftArmSkeleton.h +++ b/Gems/EMotionFX/Code/Tests/Prefabs/LeftArmSkeleton.h @@ -80,7 +80,7 @@ namespace EMotionFX .WillRepeatedly(Return(nodeName)); AZ::u32 i = 0; - std::initializer_list {(([&]() { + [[maybe_unused]] std::initializer_list dummy = {(([&]() { EXPECT_CALL(*node, GetChildIndex(i)) .WillRepeatedly(Return(children)); ++i; diff --git a/Gems/EMotionFX/Code/Tests/ProvidesUI/AnimGraph/Transitions/RemoveTransition.cpp b/Gems/EMotionFX/Code/Tests/ProvidesUI/AnimGraph/Transitions/RemoveTransition.cpp index c4d4504335..db4ca21fe5 100644 --- a/Gems/EMotionFX/Code/Tests/ProvidesUI/AnimGraph/Transitions/RemoveTransition.cpp +++ b/Gems/EMotionFX/Code/Tests/ProvidesUI/AnimGraph/Transitions/RemoveTransition.cpp @@ -73,7 +73,6 @@ namespace EMotionFX // Select the transition in the anim graph model. const QModelIndex& modelIndex = animGraphModel.FindFirstModelIndex(transition); - const EMStudio::AnimGraphModel::ModelItemType itemType = modelIndex.data(EMStudio::AnimGraphModel::ROLE_MODEL_ITEM_TYPE).value(); ASSERT_TRUE(modelIndex.isValid()) << "Anim graph transition has an invalid model index."; animGraphModel.GetSelectionModel().select(QItemSelection(modelIndex, modelIndex), QItemSelectionModel::Current | QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); diff --git a/Gems/EMotionFX/Code/Tests/ProvidesUI/AnimGraph/Transitions/RemoveTransitionCondition.cpp b/Gems/EMotionFX/Code/Tests/ProvidesUI/AnimGraph/Transitions/RemoveTransitionCondition.cpp index 5dbe52c2c4..c07a2f9611 100644 --- a/Gems/EMotionFX/Code/Tests/ProvidesUI/AnimGraph/Transitions/RemoveTransitionCondition.cpp +++ b/Gems/EMotionFX/Code/Tests/ProvidesUI/AnimGraph/Transitions/RemoveTransitionCondition.cpp @@ -76,7 +76,6 @@ namespace EMotionFX // Select the transition in the anim graph model. const QModelIndex& modelIndex = animGraphModel.FindFirstModelIndex(transition); - const EMStudio::AnimGraphModel::ModelItemType itemType = modelIndex.data(EMStudio::AnimGraphModel::ROLE_MODEL_ITEM_TYPE).value(); ASSERT_TRUE(modelIndex.isValid()) << "Anim graph transition has an invalid model index."; animGraphModel.GetSelectionModel().select(QItemSelection(modelIndex, modelIndex), QItemSelectionModel::Current | QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); diff --git a/Gems/EMotionFX/Code/Tests/SimulatedObjectSetupTests.cpp b/Gems/EMotionFX/Code/Tests/SimulatedObjectSetupTests.cpp index f37f571982..2660931e07 100644 --- a/Gems/EMotionFX/Code/Tests/SimulatedObjectSetupTests.cpp +++ b/Gems/EMotionFX/Code/Tests/SimulatedObjectSetupTests.cpp @@ -406,7 +406,6 @@ namespace SimulatedObjectSetupTests const float newGravityFactor = 1.2f; const float newFriction = 0.3f; const bool newPinned = true; - const bool newStretchable = true; joint.SetConeAngleLimit(newConeAngleLimit); joint.SetMass(newMass); diff --git a/Gems/EMotionFX/Code/Tests/UI/LODSkinnedMeshTests.cpp b/Gems/EMotionFX/Code/Tests/UI/LODSkinnedMeshTests.cpp index 65bb056654..6e5e14e9fc 100644 --- a/Gems/EMotionFX/Code/Tests/UI/LODSkinnedMeshTests.cpp +++ b/Gems/EMotionFX/Code/Tests/UI/LODSkinnedMeshTests.cpp @@ -32,7 +32,6 @@ #include #include -#include #include namespace EMotionFX @@ -73,7 +72,6 @@ namespace EMotionFX struct DataMembers { - testing::NiceMock m_renderer; testing::NiceMock m_system; }; diff --git a/Gems/EditorPythonBindings/Code/Source/PythonMarshalComponent.cpp b/Gems/EditorPythonBindings/Code/Source/PythonMarshalComponent.cpp index af21420b62..fd12635325 100644 --- a/Gems/EditorPythonBindings/Code/Source/PythonMarshalComponent.cpp +++ b/Gems/EditorPythonBindings/Code/Source/PythonMarshalComponent.cpp @@ -697,14 +697,12 @@ namespace EditorPythonBindings class TypeConverterDictionary final : public PythonMarshalComponent::TypeConverter { - AZ::GenericClassInfo* m_genericClassInfo = nullptr; const AZ::SerializeContext::ClassData* m_classData = nullptr; const AZ::TypeId m_typeId = {}; public: - TypeConverterDictionary(AZ::GenericClassInfo* genericClassInfo, const AZ::SerializeContext::ClassData* classData, const AZ::TypeId& typeId) - : m_genericClassInfo(genericClassInfo) - , m_classData(classData) + TypeConverterDictionary([[maybe_unused]] AZ::GenericClassInfo* genericClassInfo, const AZ::SerializeContext::ClassData* classData, const AZ::TypeId& typeId) + : m_classData(classData) , m_typeId(typeId) { } @@ -1376,7 +1374,6 @@ namespace EditorPythonBindings class TypeConverterPair final : public PythonMarshalComponent::TypeConverter { - AZ::GenericClassInfo* m_genericClassInfo = nullptr; const AZ::SerializeContext::ClassData* m_classData = nullptr; const AZ::TypeId m_typeId = {}; @@ -1403,9 +1400,8 @@ namespace EditorPythonBindings } public: - TypeConverterPair(AZ::GenericClassInfo* genericClassInfo, const AZ::SerializeContext::ClassData* classData, const AZ::TypeId& typeId) - : m_genericClassInfo(genericClassInfo) - , m_classData(classData) + TypeConverterPair([[maybe_unused]] AZ::GenericClassInfo* genericClassInfo, const AZ::SerializeContext::ClassData* classData, const AZ::TypeId& typeId) + : m_classData(classData) , m_typeId(typeId) { } diff --git a/Gems/ExpressionEvaluation/Code/Source/ElementInformationSerializer.inl b/Gems/ExpressionEvaluation/Code/Source/ElementInformationSerializer.inl index 9796bbb39b..c2cd377039 100644 --- a/Gems/ExpressionEvaluation/Code/Source/ElementInformationSerializer.inl +++ b/Gems/ExpressionEvaluation/Code/Source/ElementInformationSerializer.inl @@ -107,7 +107,8 @@ namespace AZ ( rapidjson::Value& outputValue , const void* inputValue , const void* defaultValue - , const Uuid& valueTypeId, JsonSerializerContext& context) override + , [[maybe_unused]] const Uuid& valueTypeId + , JsonSerializerContext& context) override { namespace JSR = JsonSerializationResult; diff --git a/Gems/ExpressionEvaluation/Code/Source/ExpressionPrimitivesSerializers.inl b/Gems/ExpressionEvaluation/Code/Source/ExpressionPrimitivesSerializers.inl index 1eaee38702..be9ddb4f20 100644 --- a/Gems/ExpressionEvaluation/Code/Source/ExpressionPrimitivesSerializers.inl +++ b/Gems/ExpressionEvaluation/Code/Source/ExpressionPrimitivesSerializers.inl @@ -89,7 +89,8 @@ namespace AZ ( rapidjson::Value& outputValue , const void* inputValue , const void* defaultValue - , const Uuid& valueTypeId, JsonSerializerContext& context) override + , [[maybe_unused]] const Uuid& valueTypeId + , JsonSerializerContext& context) override { namespace JSR = JsonSerializationResult; diff --git a/Gems/Gestures/Code/Include/Gestures/GestureRecognizerClickOrTap.inl b/Gems/Gestures/Code/Include/Gestures/GestureRecognizerClickOrTap.inl index 57716c7d9f..9333c5cbc9 100644 --- a/Gems/Gestures/Code/Include/Gestures/GestureRecognizerClickOrTap.inl +++ b/Gems/Gestures/Code/Include/Gestures/GestureRecognizerClickOrTap.inl @@ -9,6 +9,8 @@ #include #include #include +#include +#include //////////////////////////////////////////////////////////////////////////////////////////////////// inline void Gestures::RecognizerClickOrTap::Config::Reflect(AZ::ReflectContext* context) diff --git a/Gems/Gestures/Code/Include/Gestures/GestureRecognizerDrag.inl b/Gems/Gestures/Code/Include/Gestures/GestureRecognizerDrag.inl index 2c1af6fbc9..642ae9b852 100644 --- a/Gems/Gestures/Code/Include/Gestures/GestureRecognizerDrag.inl +++ b/Gems/Gestures/Code/Include/Gestures/GestureRecognizerDrag.inl @@ -8,6 +8,7 @@ #include #include +#include #include //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Gems/Gestures/Code/Include/Gestures/GestureRecognizerHold.h b/Gems/Gestures/Code/Include/Gestures/GestureRecognizerHold.h index 87c53d815a..facdd899c8 100644 --- a/Gems/Gestures/Code/Include/Gestures/GestureRecognizerHold.h +++ b/Gems/Gestures/Code/Include/Gestures/GestureRecognizerHold.h @@ -10,6 +10,7 @@ #include "IGestureRecognizer.h" #include +#include #include //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Gems/Gestures/Code/Include/Gestures/GestureRecognizerHold.inl b/Gems/Gestures/Code/Include/Gestures/GestureRecognizerHold.inl index b399639f6d..a85acfe466 100644 --- a/Gems/Gestures/Code/Include/Gestures/GestureRecognizerHold.inl +++ b/Gems/Gestures/Code/Include/Gestures/GestureRecognizerHold.inl @@ -8,6 +8,7 @@ #include #include +#include #include //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Gems/Gestures/Code/Include/Gestures/GestureRecognizerPinch.inl b/Gems/Gestures/Code/Include/Gestures/GestureRecognizerPinch.inl index f6c0427b2c..1a198eab59 100644 --- a/Gems/Gestures/Code/Include/Gestures/GestureRecognizerPinch.inl +++ b/Gems/Gestures/Code/Include/Gestures/GestureRecognizerPinch.inl @@ -8,6 +8,7 @@ #include #include +#include #include //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Gems/Gestures/Code/Include/Gestures/GestureRecognizerRotate.inl b/Gems/Gestures/Code/Include/Gestures/GestureRecognizerRotate.inl index 9dff9a115a..6cc82f47dc 100644 --- a/Gems/Gestures/Code/Include/Gestures/GestureRecognizerRotate.inl +++ b/Gems/Gestures/Code/Include/Gestures/GestureRecognizerRotate.inl @@ -9,6 +9,7 @@ #include #include #include +#include //////////////////////////////////////////////////////////////////////////////////////////////////// inline void Gestures::RecognizerRotate::Config::Reflect(AZ::ReflectContext* context) diff --git a/Gems/Gestures/Code/Include/Gestures/GestureRecognizerSwipe.h b/Gems/Gestures/Code/Include/Gestures/GestureRecognizerSwipe.h index d745454d69..bf0181e2b9 100644 --- a/Gems/Gestures/Code/Include/Gestures/GestureRecognizerSwipe.h +++ b/Gems/Gestures/Code/Include/Gestures/GestureRecognizerSwipe.h @@ -8,7 +8,7 @@ #pragma once #include "IGestureRecognizer.h" - +#include #include //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Gems/GradientSignal/Code/Include/GradientSignal/SmoothStep.h b/Gems/GradientSignal/Code/Include/GradientSignal/SmoothStep.h index f60cf4804c..0489fa4893 100644 --- a/Gems/GradientSignal/Code/Include/GradientSignal/SmoothStep.h +++ b/Gems/GradientSignal/Code/Include/GradientSignal/SmoothStep.h @@ -37,7 +37,6 @@ namespace GradientSignal float output = 0.0f; const float value = AZ::GetClamp(inputValue, 0.0f, 1.0f); - const float valueFalloffRange = AZ::GetClamp(m_falloffRange, 0.0f, 1.0f); const float valueFalloffStrength = AZ::GetClamp(m_falloffStrength, 0.0f, 1.0f); float min = m_falloffMidpoint - m_falloffRange / 2.0f; diff --git a/Gems/GradientSignal/Code/Source/Editor/EditorImageProcessingSystemComponent.cpp b/Gems/GradientSignal/Code/Source/Editor/EditorImageProcessingSystemComponent.cpp index 52c96c143c..e665d46468 100644 --- a/Gems/GradientSignal/Code/Source/Editor/EditorImageProcessingSystemComponent.cpp +++ b/Gems/GradientSignal/Code/Source/Editor/EditorImageProcessingSystemComponent.cpp @@ -108,7 +108,7 @@ namespace GradientSignal if(settingsExist) { - menu->addAction("Edit Gradient Image Settings...", [this, source, settingsPath]() + menu->addAction("Edit Gradient Image Settings...", [settingsPath]() { bool result = false; AZ::Data::AssetInfo assetInfo; @@ -123,7 +123,7 @@ namespace GradientSignal } else { - menu->addAction("Enable Gradient Image Settings", [this, source, settingsPath]() + menu->addAction("Enable Gradient Image Settings", [settingsPath]() { GradientSignal::ImageSettings imageSettings; AZ::Utils::SaveObjectToFile(settingsPath, AZ::DataStream::ST_XML, &imageSettings); diff --git a/Gems/GraphCanvas/Code/Source/Components/NodePropertyDisplays/AssetIdNodePropertyDisplay.cpp b/Gems/GraphCanvas/Code/Source/Components/NodePropertyDisplays/AssetIdNodePropertyDisplay.cpp index afafa8350d..ce08f9b448 100644 --- a/Gems/GraphCanvas/Code/Source/Components/NodePropertyDisplays/AssetIdNodePropertyDisplay.cpp +++ b/Gems/GraphCanvas/Code/Source/Components/NodePropertyDisplays/AssetIdNodePropertyDisplay.cpp @@ -156,6 +156,4 @@ namespace GraphCanvas m_proxyWidget = nullptr; } } - -#include } diff --git a/Gems/GraphCanvas/Code/Source/Components/NodePropertyDisplays/AssetIdNodePropertyDisplay.h b/Gems/GraphCanvas/Code/Source/Components/NodePropertyDisplays/AssetIdNodePropertyDisplay.h index 0067d75bac..5b35386547 100644 --- a/Gems/GraphCanvas/Code/Source/Components/NodePropertyDisplays/AssetIdNodePropertyDisplay.h +++ b/Gems/GraphCanvas/Code/Source/Components/NodePropertyDisplays/AssetIdNodePropertyDisplay.h @@ -7,13 +7,11 @@ */ #pragma once -#if !defined(Q_MOC_RUN) #include #include #include #include -#endif class QGraphicsProxyWidget; diff --git a/Gems/GraphCanvas/Code/Source/Components/NodePropertyDisplays/ComboBoxNodePropertyDisplay.cpp b/Gems/GraphCanvas/Code/Source/Components/NodePropertyDisplays/ComboBoxNodePropertyDisplay.cpp index 9206d32d65..6d0590ed99 100644 --- a/Gems/GraphCanvas/Code/Source/Components/NodePropertyDisplays/ComboBoxNodePropertyDisplay.cpp +++ b/Gems/GraphCanvas/Code/Source/Components/NodePropertyDisplays/ComboBoxNodePropertyDisplay.cpp @@ -403,6 +403,4 @@ namespace GraphCanvas m_menuDisplayDirty = true; } } - -#include } diff --git a/Gems/GraphCanvas/Code/Source/Components/NodePropertyDisplays/ComboBoxNodePropertyDisplay.h b/Gems/GraphCanvas/Code/Source/Components/NodePropertyDisplays/ComboBoxNodePropertyDisplay.h index 8f0bb05421..3044456046 100644 --- a/Gems/GraphCanvas/Code/Source/Components/NodePropertyDisplays/ComboBoxNodePropertyDisplay.h +++ b/Gems/GraphCanvas/Code/Source/Components/NodePropertyDisplays/ComboBoxNodePropertyDisplay.h @@ -9,7 +9,6 @@ class QEvent; -#if !defined(Q_MOC_RUN) #include #include @@ -18,7 +17,6 @@ class QEvent; #include #include #include -#endif namespace GraphCanvas { diff --git a/Gems/GraphCanvas/Code/Source/Components/NodePropertyDisplays/EntityIdNodePropertyDisplay.cpp b/Gems/GraphCanvas/Code/Source/Components/NodePropertyDisplays/EntityIdNodePropertyDisplay.cpp index 01dab4c53b..21c5fffa86 100644 --- a/Gems/GraphCanvas/Code/Source/Components/NodePropertyDisplays/EntityIdNodePropertyDisplay.cpp +++ b/Gems/GraphCanvas/Code/Source/Components/NodePropertyDisplays/EntityIdNodePropertyDisplay.cpp @@ -208,6 +208,4 @@ namespace GraphCanvas m_proxyWidget = nullptr; } } - -#include } diff --git a/Gems/GraphCanvas/Code/Source/Components/NodePropertyDisplays/EntityIdNodePropertyDisplay.h b/Gems/GraphCanvas/Code/Source/Components/NodePropertyDisplays/EntityIdNodePropertyDisplay.h index 322ceef941..63b6d3d301 100644 --- a/Gems/GraphCanvas/Code/Source/Components/NodePropertyDisplays/EntityIdNodePropertyDisplay.h +++ b/Gems/GraphCanvas/Code/Source/Components/NodePropertyDisplays/EntityIdNodePropertyDisplay.h @@ -9,7 +9,6 @@ class QEvent; -#if !defined(Q_MOC_RUN) #include #include @@ -17,7 +16,6 @@ class QEvent; #include #include #include -#endif namespace GraphCanvas { diff --git a/Gems/GraphCanvas/Code/Source/Components/Nodes/Group/NodeGroupFrameComponent.cpp b/Gems/GraphCanvas/Code/Source/Components/Nodes/Group/NodeGroupFrameComponent.cpp index c317e8044a..f6a7efd7fb 100644 --- a/Gems/GraphCanvas/Code/Source/Components/Nodes/Group/NodeGroupFrameComponent.cpp +++ b/Gems/GraphCanvas/Code/Source/Components/Nodes/Group/NodeGroupFrameComponent.cpp @@ -2295,8 +2295,6 @@ namespace GraphCanvas { QScopedValueRollback allowMovement(m_allowMovement, false); - QRectF rect = boundingRect(); - qreal originalHeight = boundingRect().height(); qreal newHeight = boundingRect().height() + (newSize.height() - oldSize.height()); diff --git a/Gems/GraphCanvas/Code/Source/Components/SceneComponent.cpp b/Gems/GraphCanvas/Code/Source/Components/SceneComponent.cpp index eefde088bb..52e7892364 100644 --- a/Gems/GraphCanvas/Code/Source/Components/SceneComponent.cpp +++ b/Gems/GraphCanvas/Code/Source/Components/SceneComponent.cpp @@ -1070,8 +1070,6 @@ namespace GraphCanvas // SceneComponent /////////////////// - static const char* k_copyPasteKey = "GraphCanvasScene"; - void SceneComponent::Reflect(AZ::ReflectContext* context) { GraphSerialization::Reflect(context); @@ -3262,8 +3260,6 @@ namespace GraphCanvas { for (const auto& sceneMember : sceneMemberList) { - QRectF boundingArea; - QGraphicsItem* sceneItem = nullptr; VisualRequestBus::EventResult(sceneItem, sceneMember->GetId(), &VisualRequests::AsGraphicsItem); @@ -3292,8 +3288,6 @@ namespace GraphCanvas { for (const auto& sceneMember : sceneMemberList) { - QRectF boundingArea; - QGraphicsItem* sceneItem = nullptr; VisualRequestBus::EventResult(sceneItem, sceneMember->GetId(), &VisualRequests::AsGraphicsItem); diff --git a/Gems/GraphCanvas/Code/Source/Translation/TranslationBuilder.cpp b/Gems/GraphCanvas/Code/Source/Translation/TranslationBuilder.cpp index 9b8d67aa62..bac58c3ba1 100644 --- a/Gems/GraphCanvas/Code/Source/Translation/TranslationBuilder.cpp +++ b/Gems/GraphCanvas/Code/Source/Translation/TranslationBuilder.cpp @@ -11,8 +11,6 @@ namespace GraphCanvas { - constexpr const char* s_graphCanvasTranslationBuilderName = "GraphCanvasTranslationBuilder"; - AZ::Uuid TranslationAssetWorker::GetUUID() { return AZ::Uuid::CreateString("{459EF910-CAAF-465A-BA19-C91979DA5729}"); diff --git a/Gems/GraphCanvas/Code/Source/Translation/TranslationDatabase.cpp b/Gems/GraphCanvas/Code/Source/Translation/TranslationDatabase.cpp index 158b310d7c..17c59d17bc 100644 --- a/Gems/GraphCanvas/Code/Source/Translation/TranslationDatabase.cpp +++ b/Gems/GraphCanvas/Code/Source/Translation/TranslationDatabase.cpp @@ -33,10 +33,10 @@ namespace GraphCanvas m_database.clear(); - AZStd::function reloadFn = [this]() + AZStd::function reloadFn = []() { // Collects all script assets for reloading - AZ::Data::AssetCatalogRequests::AssetEnumerationCB collectAssetsCb = [this](const AZ::Data::AssetId, const AZ::Data::AssetInfo& info) + AZ::Data::AssetCatalogRequests::AssetEnumerationCB collectAssetsCb = [](const AZ::Data::AssetId, const AZ::Data::AssetInfo& info) { // Check asset type if (info.m_assetType == azrtti_typeid()) diff --git a/Gems/GraphCanvas/Code/Source/Translation/TranslationSerializer.cpp b/Gems/GraphCanvas/Code/Source/Translation/TranslationSerializer.cpp index dd6ee187c0..3875f76d92 100644 --- a/Gems/GraphCanvas/Code/Source/Translation/TranslationSerializer.cpp +++ b/Gems/GraphCanvas/Code/Source/Translation/TranslationSerializer.cpp @@ -20,14 +20,6 @@ namespace GraphCanvas static constexpr char variant[] = "variant"; static constexpr char entries[] = "entries"; } - - static const AZStd::string_view RequiredFields[] = - { - Field::key, - Field::context, - Field::variant, - Field::entries - }; } AZ_CLASS_ALLOCATOR_IMPL(TranslationFormatSerializer, AZ::SystemAllocator, 0); diff --git a/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/GraphicsItems/ParticleGraphicsItem.cpp b/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/GraphicsItems/ParticleGraphicsItem.cpp index 26ee857cd8..a6ec4484cf 100644 --- a/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/GraphicsItems/ParticleGraphicsItem.cpp +++ b/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/GraphicsItems/ParticleGraphicsItem.cpp @@ -117,7 +117,6 @@ namespace GraphCanvas void ParticleGraphicsItem::paint([[maybe_unused]] QPainter* painter, [[maybe_unused]] const QStyleOptionGraphicsItem* option, [[maybe_unused]] QWidget* widget) { - static const float k_pulseWidth = 60.0f; painter->save(); float alpha = m_configuration.m_alphaStart; diff --git a/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Styling/Parser.cpp b/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Styling/Parser.cpp index d391ecf418..5d15c9fcd0 100644 --- a/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Styling/Parser.cpp +++ b/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Styling/Parser.cpp @@ -291,8 +291,6 @@ namespace QColor ParseColor(const QString& color) { - QColor result; - QRegularExpressionMatch match; if ((match = hexColor.match(color)).hasMatch()) { @@ -520,34 +518,6 @@ namespace } } - QFont::Capitalization ParseFontVariant(const QString& value) - { - if (QString::compare(value, QLatin1String("normal"), Qt::CaseInsensitive) == 0) - { - return QFont::MixedCase; - } - else if (QString::compare(value, QLatin1String("all-uppercase"), Qt::CaseInsensitive) == 0) - { - return QFont::AllUppercase; - } - else if (QString::compare(value, QLatin1String("all-lowercase"), Qt::CaseInsensitive) == 0) - { - return QFont::AllLowercase; - } - else if (QString::compare(value, QLatin1String("small-caps"), Qt::CaseInsensitive) == 0) - { - return QFont::SmallCaps; - } - else if (QString::compare(value, QLatin1String("capitalize"), Qt::CaseInsensitive) == 0) - { - return QFont::Capitalize; - } - else - { - return{}; - } - } - bool IsFontStyleValid(const QString& value) { if (QString::compare(value, QLatin1String("normal"), Qt::CaseInsensitive) == 0 || @@ -640,16 +610,6 @@ namespace return{}; } - AZStd::string CreateStyleName(const Styling::Style& style) - { - const Styling::SelectorVector selectors = style.GetSelectors(); - return std::accumulate(selectors.cbegin(), selectors.cend(), AZStd::string(), [](const AZStd::string& a, const Styling::Selector& s) { - return a + (a.empty() ? "" : ", ") + s.ToString(); - }); - } - - - } // namespace diff --git a/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Utils/GraphUtils.cpp b/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Utils/GraphUtils.cpp index 93ee795ec6..40284efcdf 100644 --- a/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Utils/GraphUtils.cpp +++ b/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Utils/GraphUtils.cpp @@ -1898,8 +1898,6 @@ namespace GraphCanvas targetConnectionType = ConnectionType::CT_Invalid; } - NodeId nodeId = initializingEndpoint.GetNodeId(); - AZStd::vector< SlotId > slotIds; NodeRequestBus::EventResult(slotIds, initializingEndpoint.GetNodeId(), &NodeRequests::GetSlotIds); @@ -2307,7 +2305,6 @@ namespace GraphCanvas AZ::EntityId anchorEntity; float minDistance = -1; - QPointF offset; AZStd::vector nearbyEntities; FloatingElementAnchor floatingAnchor; @@ -2425,10 +2422,6 @@ namespace GraphCanvas // - Overall Alignment is a bit...non-deterministic right now, and can change for some reason. AZStd::queue< OrganizationHelper* > termimnalOrganizationHelpers; - QPointF minTerminalPointSpot(0,0); - - AZ::Vector2 anchorPoint = CalculateAlignmentAnchorPoint(alignConfig); - // Tail recursed loop. while (!nextLayer.empty()) { @@ -2487,10 +2480,6 @@ namespace GraphCanvas OrganizationHelper* helper = termimnalOrganizationHelpers.front(); termimnalOrganizationHelpers.pop(); - NodeId nodeId = helper->m_nodeId; - - QRectF totalBoundingRect = helper->m_boundingArea; - OrganizationSpaceAllocationHelper leftAllocation; OrganizationSpaceAllocationHelper rightAllocation; diff --git a/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Utils/QtVectorMath.h b/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Utils/QtVectorMath.h index 8361d57e9a..5b572714f2 100644 --- a/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Utils/QtVectorMath.h +++ b/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Utils/QtVectorMath.h @@ -58,18 +58,8 @@ namespace GraphCanvas } // Find the line between the two rectangles. - QPointF direction = rectA.center() - rectB.center(); QLineF directionLine(rectA.center(), rectB.center()); - QLineF aLine1; - QLineF aLine2; - QLineF aFinalLine; - - QLineF bLine1; - QLineF bLine2; - QLineF bFinalLine; - - // Not strictly correct, but correct enough. // // Finds the two points on the line from center to center, and returns the distance between them. diff --git a/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Widgets/ConstructPresetDialog/ConstructPresetDialog.cpp b/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Widgets/ConstructPresetDialog/ConstructPresetDialog.cpp index 73655cf41d..bde2135b9e 100644 --- a/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Widgets/ConstructPresetDialog/ConstructPresetDialog.cpp +++ b/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Widgets/ConstructPresetDialog/ConstructPresetDialog.cpp @@ -445,7 +445,6 @@ namespace GraphCanvas if (newIndex >= 0) { - QModelIndex index = m_presetsModel->index(newIndex, 0); m_ui->constructTypes->setCurrentIndex(newIndex); } } diff --git a/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Widgets/GraphCanvasGraphicsView/GraphCanvasGraphicsView.cpp b/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Widgets/GraphCanvasGraphicsView/GraphCanvasGraphicsView.cpp index f0b4d264ca..fa7e051035 100644 --- a/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Widgets/GraphCanvasGraphicsView/GraphCanvasGraphicsView.cpp +++ b/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Widgets/GraphCanvasGraphicsView/GraphCanvasGraphicsView.cpp @@ -1488,7 +1488,6 @@ namespace GraphCanvas void GraphCanvasGraphicsView::SaveViewParams() { - QPointF centerPoint = mapToScene(rect().center()); QPointF anchorPoint = mapToScene(rect().topLeft()); m_viewParams.m_anchorPointX = aznumeric_cast(anchorPoint.x()); diff --git a/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Widgets/NodePalette/Model/NodePaletteSortFilterProxyModel.cpp b/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Widgets/NodePalette/Model/NodePaletteSortFilterProxyModel.cpp index 89e0ef3aac..33d11f998e 100644 --- a/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Widgets/NodePalette/Model/NodePaletteSortFilterProxyModel.cpp +++ b/Gems/GraphCanvas/Code/StaticLib/GraphCanvas/Widgets/NodePalette/Model/NodePaletteSortFilterProxyModel.cpp @@ -202,8 +202,6 @@ namespace GraphCanvas AZStd::list exploreItems; exploreItems.push_back(treeItem); - const QModelIndex k_flagIndex; - while (!exploreItems.empty()) { const GraphCanvas::GraphCanvasTreeItem* currentItem = exploreItems.front(); diff --git a/Gems/ImGui/Code/Source/ImGuiManager.cpp b/Gems/ImGui/Code/Source/ImGuiManager.cpp index 427af6d7dc..6fc1ea8b71 100644 --- a/Gems/ImGui/Code/Source/ImGuiManager.cpp +++ b/Gems/ImGui/Code/Source/ImGuiManager.cpp @@ -81,59 +81,6 @@ namespace const auto& it = AZStd::find(touches.cbegin(), touches.cend(), inputChannelId); return it != touches.cend() ? static_cast(it - touches.cbegin()) : UINT_MAX; } - - /** - Utility function to map an AzFrameworkInput controller button to its integer index. - - @param inputChannelId the ID for an AzFrameworkInput controller button. - @return the index of the indicated button, or -1 if not found. - */ - unsigned int GetAzControllerButtonIndex(const InputChannelId& inputChannelId) - { - const auto& buttons = InputDeviceGamepad::Button::All; - const auto& triggers = InputDeviceGamepad::Trigger::All; - const auto& it = AZStd::find(buttons.cbegin(), buttons.cend(), inputChannelId); - if (it != buttons.cend()) - { - return static_cast(it - buttons.cbegin()); - } - else - { - const auto& it2 = AZStd::find(triggers.cbegin(), triggers.cend(), inputChannelId); - if (it2 != triggers.cend()) - { - return static_cast(it2 - triggers.cbegin()) + AZ_ARRAY_SIZE(InputDeviceGamepad::Button::All); - } - } - - return UINT_MAX; - } - - /** - Utility function to map an AzFrameworkInput thumbstick movement to its integer index. - - @param inputChannelId the ID for an AzFrameworkInput thumbstick movement. - @return the index of the indicated button, or -1 if not found. - */ - unsigned int GetAzControllerThumbstickIndex(const InputChannelId& inputChannelId) - { - const auto& thumbstickMovements = InputDeviceGamepad::ThumbStickDirection::All; - const auto& it = AZStd::find(thumbstickMovements.cbegin(), thumbstickMovements.cend(), inputChannelId); - return it != thumbstickMovements.cend() ? static_cast(it - thumbstickMovements.cbegin()) : UINT_MAX; - } - - /** - Utility function to map an AzFrameworkInput thumbstick movement amountto its integer index. - - @param inputChannelId the ID for an AzFrameworkInput thumbstick movement amount. - @return the index of the indicated button, or -1 if not found. - */ - unsigned int GetAzControllerThumbstickAmountIndex(const InputChannelId& inputChannelId) - { - const auto& thumbstickMovementAmounts = InputDeviceGamepad::ThumbStickAxis1D::All; - const auto& it = AZStd::find(thumbstickMovementAmounts.cbegin(), thumbstickMovementAmounts.cend(), inputChannelId); - return it != thumbstickMovementAmounts.cend() ? static_cast(it - thumbstickMovementAmounts.cbegin()) : UINT_MAX; - } } void ImGuiManager::Initialize() diff --git a/Gems/ImGui/Code/Source/ImGuiManager.h b/Gems/ImGui/Code/Source/ImGuiManager.h index 1b24aa9806..52862205a5 100644 --- a/Gems/ImGui/Code/Source/ImGuiManager.h +++ b/Gems/ImGui/Code/Source/ImGuiManager.h @@ -81,7 +81,6 @@ namespace ImGui private: ImGuiContext* m_imguiContext = nullptr; - int m_fontTextureId = -1; DisplayState m_clientMenuBarState = DisplayState::Hidden; DisplayState m_editorWindowState = DisplayState::Hidden; diff --git a/Gems/LandscapeCanvas/Code/Source/Editor/MainWindow.cpp b/Gems/LandscapeCanvas/Code/Source/Editor/MainWindow.cpp index 2204034185..836eec682e 100644 --- a/Gems/LandscapeCanvas/Code/Source/Editor/MainWindow.cpp +++ b/Gems/LandscapeCanvas/Code/Source/Editor/MainWindow.cpp @@ -955,14 +955,14 @@ namespace LandscapeCanvasEditor auto redoAction = new QAction(QObject::tr("&Redo"), this); redoAction->setShortcut(AzQtComponents::RedoKeySequence); - QObject::connect(redoAction, &QAction::triggered, [this] { + QObject::connect(redoAction, &QAction::triggered, [] { GetLegacyEditor()->Redo(); }); menu->insertAction(separatorAction, redoAction); auto undoAction = new QAction(QObject::tr("&Undo"), this); undoAction->setShortcut(QKeySequence::Undo); - QObject::connect(undoAction, &QAction::triggered, [this] { + QObject::connect(undoAction, &QAction::triggered, [] { GetLegacyEditor()->Undo(); }); menu->insertAction(redoAction, undoAction); @@ -2852,7 +2852,7 @@ namespace LandscapeCanvasEditor // For any node with an Entity Name slot, we need to replace the string property display with a read-only version // instead until we have support for listening for GraphModel slot value changes. We need to delay this because // when the node is added, the slots haven't been added to the element map yet. - QTimer::singleShot(0, [this, node, graphId]() { + QTimer::singleShot(0, [node, graphId]() { GraphModel::SlotPtr slot = node->GetSlot(LandscapeCanvas::ENTITY_NAME_SLOT_ID); if (slot) { @@ -2976,7 +2976,7 @@ namespace LandscapeCanvasEditor AzToolsFramework::EntityIdList vegetationAreaIds; m_serializeContext->EnumerateObject(component, // beginElemCB - [this, &previewEntityId, &inboundShapeEntityId, &gradientSamplerIds, &vegetationAreaIds](void *instance, [[maybe_unused]] const AZ::SerializeContext::ClassData *classData, const AZ::SerializeContext::ClassElement *classElement) -> bool + [&previewEntityId, &inboundShapeEntityId, &gradientSamplerIds, &vegetationAreaIds](void *instance, [[maybe_unused]] const AZ::SerializeContext::ClassData *classData, const AZ::SerializeContext::ClassElement *classElement) -> bool { if (classElement && (classElement->m_typeId == azrtti_typeid())) { diff --git a/Gems/LmbrCentral/Code/Source/Ai/NavigationComponent.cpp b/Gems/LmbrCentral/Code/Source/Ai/NavigationComponent.cpp index fbeb26706e..9086f40ede 100644 --- a/Gems/LmbrCentral/Code/Source/Ai/NavigationComponent.cpp +++ b/Gems/LmbrCentral/Code/Source/Ai/NavigationComponent.cpp @@ -748,7 +748,7 @@ namespace LmbrCentral PathFollowResult result; - const bool arrived = pathFollower->Update( + [[maybe_unused]] const bool arrived = pathFollower->Update( result, AZVec3ToLYVec3(agentPosition), AZVec3ToLYVec3(agentVelocity), diff --git a/Gems/LmbrCentral/Code/Source/Builders/DependencyBuilder/DependencyBuilderWorker.cpp b/Gems/LmbrCentral/Code/Source/Builders/DependencyBuilder/DependencyBuilderWorker.cpp index c67dad89b3..dc060ee7cf 100644 --- a/Gems/LmbrCentral/Code/Source/Builders/DependencyBuilder/DependencyBuilderWorker.cpp +++ b/Gems/LmbrCentral/Code/Source/Builders/DependencyBuilder/DependencyBuilderWorker.cpp @@ -12,9 +12,8 @@ namespace DependencyBuilder { - DependencyBuilderWorker::DependencyBuilderWorker(AZStd::string jobKey, bool critical) + DependencyBuilderWorker::DependencyBuilderWorker(AZStd::string jobKey, [[maybe_unused]] bool critical) : m_jobKey(jobKey) - , m_critical(critical) { } diff --git a/Gems/LmbrCentral/Code/Source/Builders/DependencyBuilder/DependencyBuilderWorker.h b/Gems/LmbrCentral/Code/Source/Builders/DependencyBuilder/DependencyBuilderWorker.h index 91e657dc2d..76c46fde35 100644 --- a/Gems/LmbrCentral/Code/Source/Builders/DependencyBuilder/DependencyBuilderWorker.h +++ b/Gems/LmbrCentral/Code/Source/Builders/DependencyBuilder/DependencyBuilderWorker.h @@ -38,7 +38,6 @@ namespace DependencyBuilder private: AZStd::string m_jobKey; - bool m_critical = false; bool m_isShuttingDown = false; }; } diff --git a/Gems/LmbrCentral/Code/Source/Shape/CapsuleShape.cpp b/Gems/LmbrCentral/Code/Source/Shape/CapsuleShape.cpp index a47041f767..fb2d2bd8ae 100644 --- a/Gems/LmbrCentral/Code/Source/Shape/CapsuleShape.cpp +++ b/Gems/LmbrCentral/Code/Source/Shape/CapsuleShape.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include namespace LmbrCentral diff --git a/Gems/LmbrCentral/Code/Source/Shape/CompoundShapeComponent.cpp b/Gems/LmbrCentral/Code/Source/Shape/CompoundShapeComponent.cpp index fa6f3e3702..7f4c58512d 100644 --- a/Gems/LmbrCentral/Code/Source/Shape/CompoundShapeComponent.cpp +++ b/Gems/LmbrCentral/Code/Source/Shape/CompoundShapeComponent.cpp @@ -8,7 +8,6 @@ #include "CompoundShapeComponent.h" #include -#include "Cry_GeoOverlap.h" namespace LmbrCentral @@ -147,7 +146,7 @@ namespace LmbrCentral { m_currentlyActiveChildren++; ShapeComponentNotificationsBus::MultiHandler::BusConnect(id); - + if (ShapeComponentRequestsBus::Handler::BusIsConnected() && CompoundShapeComponentRequestsBus::Handler::BusIsConnected()) { EBUS_EVENT_ID(GetEntityId(), ShapeComponentNotificationsBus, OnShapeChanged, ShapeComponentNotifications::ShapeChangeReasons::ShapeChanged); diff --git a/Gems/LmbrCentral/Code/Source/Shape/CylinderShape.cpp b/Gems/LmbrCentral/Code/Source/Shape/CylinderShape.cpp index 85f28bcbbd..3c65dafbbc 100644 --- a/Gems/LmbrCentral/Code/Source/Shape/CylinderShape.cpp +++ b/Gems/LmbrCentral/Code/Source/Shape/CylinderShape.cpp @@ -243,7 +243,6 @@ namespace LmbrCentral AZ::Vector3 diff = m_intersectionDataCache.m_baseCenterPoint - point; return diff.GetLengthSq(); } - return Distance::Point_CylinderSq( point, m_intersectionDataCache.m_baseCenterPoint, m_intersectionDataCache.m_baseCenterPoint + m_intersectionDataCache.m_axisVector, diff --git a/Gems/LmbrCentral/Code/Tests/BundlingSystemComponentTests.cpp b/Gems/LmbrCentral/Code/Tests/BundlingSystemComponentTests.cpp index ada7975b62..08251eb716 100644 --- a/Gems/LmbrCentral/Code/Tests/BundlingSystemComponentTests.cpp +++ b/Gems/LmbrCentral/Code/Tests/BundlingSystemComponentTests.cpp @@ -138,7 +138,6 @@ namespace UnitTest // cache as test/bundle/staticdata.pak and should be loaded below // The Pak has a catalog describing the contents which should automatically update our central asset catalog const char testCSVAsset[] = "staticdata/csv/bundlingsystemtestgameproperties.csv"; - const char testCSVAssetPak[] = "test/bundle/staticdata.pak"; const char testMTLAsset[] = "materials/water_test.mtl"; const char testMTLAssetPak[] = "test/TestMaterials.pak"; @@ -167,7 +166,6 @@ namespace UnitTest const char testCSVAssetPak[] = "test/bundle/staticdata.pak"; // This asset lives only within LmbrCentral/Assets/Test/Bundle/ping.pak - const char testDDSAsset[] = "textures/test/ping.dds"; const char testDDSAssetPak[] = "test/bundle/ping.pak"; size_t bundleCount{ 0 }; diff --git a/Gems/LyShine/Code/Editor/Animation/AnimationContext.cpp b/Gems/LyShine/Code/Editor/Animation/AnimationContext.cpp index c2c05277a8..8f8864106b 100644 --- a/Gems/LyShine/Code/Editor/Animation/AnimationContext.cpp +++ b/Gems/LyShine/Code/Editor/Animation/AnimationContext.cpp @@ -521,7 +521,7 @@ void CUiAnimationContext::OnEditorNotifyEvent(EEditorNotifyEvent event) case eNotify_OnBeginLayerExport: if (m_pSequence) { - m_sequenceName = m_pSequence->GetName(); + m_sequenceName = QString::fromUtf8(m_pSequence->GetName().c_str()); } else { diff --git a/Gems/LyShine/Code/Editor/Animation/Controls/UiSplineCtrlEx.cpp b/Gems/LyShine/Code/Editor/Animation/Controls/UiSplineCtrlEx.cpp index cf5c1b2d8f..94a4c77593 100644 --- a/Gems/LyShine/Code/Editor/Animation/Controls/UiSplineCtrlEx.cpp +++ b/Gems/LyShine/Code/Editor/Animation/Controls/UiSplineCtrlEx.cpp @@ -824,8 +824,6 @@ void SplineWidget::DrawSpline(QPainter* painter, SSplineInfo& splineInfo, float { const QPen pOldPen = painter->pen(); - const QRect rcClip = painter->clipBoundingRect().intersected(m_rcSpline).toRect(); - ////////////////////////////////////////////////////////////////////////// ISplineInterpolator* pSpline = splineInfo.pSpline; ISplineInterpolator* pDetailSpline = splineInfo.pDetailSpline; diff --git a/Gems/LyShine/Code/Editor/Animation/Controls/UiTimelineCtrl.h b/Gems/LyShine/Code/Editor/Animation/Controls/UiTimelineCtrl.h index d1aeaacb00..701d187ddc 100644 --- a/Gems/LyShine/Code/Editor/Animation/Controls/UiTimelineCtrl.h +++ b/Gems/LyShine/Code/Editor/Animation/Controls/UiTimelineCtrl.h @@ -134,7 +134,6 @@ protected: void DrawFrameTicks(QPainter* dc); private: - bool m_bAutoDelete; QRect m_rcClient; QRect m_rcTimeline; float m_fTimeMarker; diff --git a/Gems/LyShine/Code/Editor/Animation/UiAVCustomizeTrackColorsDlg.cpp b/Gems/LyShine/Code/Editor/Animation/UiAVCustomizeTrackColorsDlg.cpp index 533625c762..b1412a2d7c 100644 --- a/Gems/LyShine/Code/Editor/Animation/UiAVCustomizeTrackColorsDlg.cpp +++ b/Gems/LyShine/Code/Editor/Animation/UiAVCustomizeTrackColorsDlg.cpp @@ -63,7 +63,6 @@ namespace { eUiAnimParamType_User, "Muted", QColor(255, 224, 224) }, }; - const int kButtonsIdBase = 0x7fff; const int kMaxRows = 20; const int kColumnWidth = 300; const int kRowHeight = 24; diff --git a/Gems/LyShine/Code/Editor/Animation/UiAVEventsDialog.cpp b/Gems/LyShine/Code/Editor/Animation/UiAVEventsDialog.cpp index b45cee6948..910307c71a 100644 --- a/Gems/LyShine/Code/Editor/Animation/UiAVEventsDialog.cpp +++ b/Gems/LyShine/Code/Editor/Animation/UiAVEventsDialog.cpp @@ -18,12 +18,6 @@ // CUiAVEventsDialog dialog -namespace -{ - const int kCountSubItemIndex = 1; - const int kTimeSubItemIndex = 2; -} - class UiAVEventsModel : public QAbstractTableModel { diff --git a/Gems/LyShine/Code/Editor/Animation/UiAVSequenceProps.cpp b/Gems/LyShine/Code/Editor/Animation/UiAVSequenceProps.cpp index db8a96830b..a2df73cf26 100644 --- a/Gems/LyShine/Code/Editor/Animation/UiAVSequenceProps.cpp +++ b/Gems/LyShine/Code/Editor/Animation/UiAVSequenceProps.cpp @@ -45,7 +45,7 @@ CUiAVSequenceProps::~CUiAVSequenceProps() // CUiAVSequenceProps message handlers bool CUiAVSequenceProps::OnInitDialog() { - QString name = m_pSequence->GetName(); + QString name = QString::fromUtf8(m_pSequence->GetName().c_str()); ui->NAME->setText(name); ui->MOVE_SCALE_KEYS->setChecked(false); @@ -135,7 +135,7 @@ void CUiAVSequenceProps::OnOK() ac->UpdateTimeRange(); } - QString seqName = m_pSequence->GetName(); + QString seqName = QString::fromUtf8(m_pSequence->GetName().c_str()); if (name != seqName) { // Rename sequence. diff --git a/Gems/LyShine/Code/Editor/Animation/UiAnimViewAnimNode.cpp b/Gems/LyShine/Code/Editor/Animation/UiAnimViewAnimNode.cpp index 3646e5a413..41397ce265 100644 --- a/Gems/LyShine/Code/Editor/Animation/UiAnimViewAnimNode.cpp +++ b/Gems/LyShine/Code/Editor/Animation/UiAnimViewAnimNode.cpp @@ -149,8 +149,6 @@ void CUiAnimViewAnimNode::UiElementPropertyChanged() bool valueChanged = false; - const float time = GetSequence()->GetTime(); - if (m_nodeEntityId.IsValid() && !m_azEntityDataCache.empty()) { AZ::Entity* pNodeEntity = nullptr; @@ -537,9 +535,6 @@ void CUiAnimViewAnimNode::BindToEditorObjects() CUiAnimViewSequenceNotificationContext context(GetSequence()); - CUiAnimViewAnimNode* pDirector = GetDirector(); - const bool bBelongsToActiveDirector = pDirector ? pDirector->IsActiveDirector() : true; - // if this node represents an AZ entity then register for updates if (m_nodeEntityId.IsValid()) { @@ -1246,7 +1241,7 @@ CUiAnimViewAnimNodeBundle CUiAnimViewAnimNode::GetAnimNodesByName(const char* pN { CUiAnimViewAnimNodeBundle bundle; - QString nodeName = GetName(); + QString nodeName = QString::fromUtf8(GetName().c_str()); if (GetNodeType() == eUiAVNT_AnimNode && QString::compare(pName, nodeName, Qt::CaseInsensitive) == 0) { bundle.AppendAnimNode(this); @@ -1266,17 +1261,15 @@ CUiAnimViewAnimNodeBundle CUiAnimViewAnimNode::GetAnimNodesByName(const char* pN } ////////////////////////////////////////////////////////////////////////// -const char* CUiAnimViewAnimNode::GetParamName(const CUiAnimParamType& paramType) const +AZStd::string CUiAnimViewAnimNode::GetParamName(const CUiAnimParamType& paramType) const { - const char* pName = m_pAnimNode->GetParamName(paramType); - return pName ? pName : ""; + return m_pAnimNode->GetParamName(paramType); } ////////////////////////////////////////////////////////////////////////// -const char* CUiAnimViewAnimNode::GetParamNameForTrack(const CUiAnimParamType& paramType, const IUiAnimTrack* track) const +AZStd::string CUiAnimViewAnimNode::GetParamNameForTrack(const CUiAnimParamType& paramType, const IUiAnimTrack* track) const { - const char* pName = m_pAnimNode->GetParamNameForTrack(paramType, track); - return pName ? pName : ""; + return m_pAnimNode->GetParamNameForTrack(paramType, track); } ////////////////////////////////////////////////////////////////////////// @@ -1413,7 +1406,7 @@ void CUiAnimViewAnimNode::UpdateDynamicParams() void CUiAnimViewAnimNode::CopyKeysToClipboard(XmlNodeRef& xmlNode, const bool bOnlySelectedKeys, const bool bOnlyFromSelectedTracks) { XmlNodeRef childNode = xmlNode->createNode("Node"); - childNode->setAttr("name", GetName()); + childNode->setAttr("name", GetName().c_str()); childNode->setAttr("type", GetType()); for (auto iter = m_childNodes.begin(); iter != m_childNodes.end(); ++iter) @@ -1557,7 +1550,7 @@ bool CUiAnimViewAnimNode::IsValidReparentingTo(CUiAnimViewAnimNode* pNewParent) } // Check if the new parent already contains a node with this name - CUiAnimViewAnimNodeBundle foundNodes = pNewParent->GetAnimNodesByName(GetName()); + CUiAnimViewAnimNodeBundle foundNodes = pNewParent->GetAnimNodesByName(GetName().c_str()); if (foundNodes.GetCount() > 1 || (foundNodes.GetCount() == 1 && foundNodes.GetNode(0) != this)) { return false; @@ -1632,7 +1625,7 @@ void CUiAnimViewAnimNode::OnSelectionChanged(const bool bSelected) { if (m_pAnimNode) { - const EUiAnimNodeType animNodeType = GetType(); + [[maybe_unused]] const EUiAnimNodeType animNodeType = GetType(); assert(animNodeType == eUiAnimNodeType_Camera || animNodeType == eUiAnimNodeType_Entity || animNodeType == eUiAnimNodeType_GeomCache); const EUiAnimNodeFlags flags = (EUiAnimNodeFlags)m_pAnimNode->GetFlags(); diff --git a/Gems/LyShine/Code/Editor/Animation/UiAnimViewAnimNode.h b/Gems/LyShine/Code/Editor/Animation/UiAnimViewAnimNode.h index 72dc7344ec..abc4a84c8c 100644 --- a/Gems/LyShine/Code/Editor/Animation/UiAnimViewAnimNode.h +++ b/Gems/LyShine/Code/Editor/Animation/UiAnimViewAnimNode.h @@ -118,7 +118,7 @@ public: virtual bool IsActive(); // Name setter/getter - virtual const char* GetName() const override { return m_pAnimNode->GetName(); } + AZStd::string GetName() const override { return m_pAnimNode->GetName(); } virtual bool SetName(const char* pName) override; virtual bool CanBeRenamed() const override; @@ -164,8 +164,8 @@ public: // Param unsigned int GetParamCount() const; CUiAnimParamType GetParamType(unsigned int index) const; - const char* GetParamName(const CUiAnimParamType& paramType) const; - const char* GetParamNameForTrack(const CUiAnimParamType& paramType, const IUiAnimTrack* track) const; + AZStd::string GetParamName(const CUiAnimParamType& paramType) const; + AZStd::string GetParamNameForTrack(const CUiAnimParamType& paramType, const IUiAnimTrack* track) const; bool IsParamValid(const CUiAnimParamType& param) const; IUiAnimNode::ESupportedParamFlags GetParamFlags(const CUiAnimParamType& paramType) const; EUiAnimValue GetParamValueType(const CUiAnimParamType& paramType) const; diff --git a/Gems/LyShine/Code/Editor/Animation/UiAnimViewDialog.cpp b/Gems/LyShine/Code/Editor/Animation/UiAnimViewDialog.cpp index 6a3afe2036..a9f76cd443 100644 --- a/Gems/LyShine/Code/Editor/Animation/UiAnimViewDialog.cpp +++ b/Gems/LyShine/Code/Editor/Animation/UiAnimViewDialog.cpp @@ -70,24 +70,12 @@ ////////////////////////////////////////////////////////////////////////// namespace { - const char* s_kUiAnimViewLayoutSection = "UiAnimViewLayout"; - const char* s_kUiAnimViewSection = "DockingPaneLayouts\\UiAnimView"; - const char* s_kSplitterEntry = "Splitter"; - const char* s_kVersionEntry = "UiAnimViewLayoutVersion"; - const char* s_kUiAnimViewSettingsSection = "UiAnimView"; const char* s_kSnappingModeEntry = "SnappingMode"; const char* s_kFrameSnappingFPSEntry = "FrameSnappingFPS"; const char* s_kTickDisplayModeEntry = "TickDisplayMode"; - const char* s_kDefaultTracksEntry = "DefaultTracks"; - - const char* s_kRebarVersionEntry = "UiAnimViewReBarVersion"; - const char* s_kRebarBandEntryPrefix = "ReBarBand"; const char* s_kNoSequenceComboBoxEntry = "--- No Sequence ---"; - - const int TRACKVIEW_LAYOUT_VERSION = 0x0001; // Bump this up on every substantial pane layout change - const int TRACKVIEW_REBAR_VERSION = 0x0002; // Bump this up on every substantial rebar change } ////////////////////////////////////////////////////////////////////////// @@ -992,7 +980,7 @@ void CUiAnimViewDialog::ReloadSequencesComboBox() for (unsigned int k = 0; k < numSequences; ++k) { CUiAnimViewSequence* pSequence = pSequenceManager->GetSequenceByIndex(k); - QString fullname = pSequence->GetName(); + QString fullname = QString::fromUtf8(pSequence->GetName().c_str()); m_sequencesComboBox->addItem(fullname); } } @@ -1132,7 +1120,7 @@ void CUiAnimViewDialog::OnSequenceChanged(CUiAnimViewSequence* pSequence) if (pSequence) { - m_currentSequenceName = pSequence->GetName(); + m_currentSequenceName = QString::fromUtf8(pSequence->GetName().c_str()); pSequence->Reset(true); SaveZoomScrollSettings(); @@ -1733,7 +1721,7 @@ void CUiAnimViewDialog::OnNodeRenamed(CUiAnimViewNode* pNode, const char* pOldNa { if (m_currentSequenceName == QString(pOldName)) { - m_currentSequenceName = pNode->GetName(); + m_currentSequenceName = QString::fromUtf8(pNode->GetName().c_str()); } ReloadSequencesComboBox(); diff --git a/Gems/LyShine/Code/Editor/Animation/UiAnimViewDopeSheetBase.cpp b/Gems/LyShine/Code/Editor/Animation/UiAnimViewDopeSheetBase.cpp index 4e67fb520e..8672f539bf 100644 --- a/Gems/LyShine/Code/Editor/Animation/UiAnimViewDopeSheetBase.cpp +++ b/Gems/LyShine/Code/Editor/Animation/UiAnimViewDopeSheetBase.cpp @@ -192,7 +192,6 @@ void CUiAnimViewDopeSheetBase::SetTimeRange(float start, float end) void CUiAnimViewDopeSheetBase::SetTimeScale(float timeScale, float fAnchorTime) { const double fOldOffset = -fAnchorTime * m_timeScale; - const double fOldScale = m_timeScale; timeScale = std::max(timeScale, 0.001f); timeScale = std::min(timeScale, 100000.0f); @@ -1308,8 +1307,6 @@ void CUiAnimViewDopeSheetBase::OnCaptureChanged() ////////////////////////////////////////////////////////////////////////// bool CUiAnimViewDopeSheetBase::IsOkToAddKeyHere(const CUiAnimViewTrack* pTrack, float time) const { - const float timeEpsilon = 0.05f; - for (unsigned int i = 0; i < pTrack->GetKeyCount(); ++i) { CUiAnimViewKeyHandle keyHandle = const_cast(pTrack)->GetKey(i); @@ -1795,8 +1792,6 @@ void CUiAnimViewDopeSheetBase::AcceptUndo() { if (UiAnimUndo::IsRecording()) { - const QPoint mousePos = mapFromGlobal(QCursor::pos()); - if (m_mouseMode == eUiAVMouseMode_Paste) { UiAnimUndoManager::Get()->Cancel(); @@ -2242,7 +2237,6 @@ void CUiAnimViewDopeSheetBase::DrawBoolTrack(const Range& timeRange, QPainter* p { int x0 = TimeToClient(timeRange.start); float t0 = timeRange.start; - QRect trackRect; const QBrush prevBrush = painter->brush(); painter->setBrush(m_visibilityBrush); @@ -2980,7 +2974,7 @@ void CUiAnimViewDopeSheetBase::DrawNodeTrack(CUiAnimViewAnimNode* pAnimNode, QPa const QRect textRect = trackRect.adjusted(4, 0, -4, 0); - QString sAnimNodeName = pAnimNode->GetName(); + QString sAnimNodeName = QString::fromUtf8(pAnimNode->GetName().c_str()); const bool hasObsoleteTrack = pAnimNode->HasObsoleteTrack(); if (hasObsoleteTrack) diff --git a/Gems/LyShine/Code/Editor/Animation/UiAnimViewFindDlg.cpp b/Gems/LyShine/Code/Editor/Animation/UiAnimViewFindDlg.cpp index 511866db43..0b4ce7f633 100644 --- a/Gems/LyShine/Code/Editor/Animation/UiAnimViewFindDlg.cpp +++ b/Gems/LyShine/Code/Editor/Animation/UiAnimViewFindDlg.cpp @@ -61,8 +61,8 @@ void CUiAnimViewFindDlg::FillData() { IUiAnimNode* pNode = seq->GetNode(i); ObjName obj; - obj.m_objName = pNode->GetName(); - obj.m_directorName = pNode->HasDirectorAsParent() ? pNode->HasDirectorAsParent()->GetName() : ""; + obj.m_objName = QString::fromUtf8(pNode->GetName().c_str()); + obj.m_directorName = pNode->HasDirectorAsParent() ? QString::fromUtf8(pNode->HasDirectorAsParent()->GetName().c_str()) : ""; AZStd::string fullname = seq->GetName(); obj.m_seqName = fullname.c_str(); m_objs.push_back(obj); diff --git a/Gems/LyShine/Code/Editor/Animation/UiAnimViewNewSequenceDialog.cpp b/Gems/LyShine/Code/Editor/Animation/UiAnimViewNewSequenceDialog.cpp index 3dd49574fd..e7ad1b91ea 100644 --- a/Gems/LyShine/Code/Editor/Animation/UiAnimViewNewSequenceDialog.cpp +++ b/Gems/LyShine/Code/Editor/Animation/UiAnimViewNewSequenceDialog.cpp @@ -46,7 +46,7 @@ void CUiAVNewSequenceDialog::OnOK() for (unsigned int k = 0; k < CUiAnimViewSequenceManager::GetSequenceManager()->GetCount(); ++k) { CUiAnimViewSequence* pSequence = CUiAnimViewSequenceManager::GetSequenceManager()->GetSequenceByIndex(k); - QString fullname = pSequence->GetName(); + QString fullname = QString::fromUtf8(pSequence->GetName().c_str()); if (fullname.compare(m_sequenceName, Qt::CaseInsensitive) == 0) { diff --git a/Gems/LyShine/Code/Editor/Animation/UiAnimViewNode.cpp b/Gems/LyShine/Code/Editor/Animation/UiAnimViewNode.cpp index 2b14a38015..fd9207bc13 100644 --- a/Gems/LyShine/Code/Editor/Animation/UiAnimViewNode.cpp +++ b/Gems/LyShine/Code/Editor/Animation/UiAnimViewNode.cpp @@ -14,16 +14,12 @@ //////////////////////////////////////////////////////////////////////////// void CUiAnimViewKeyConstHandle::GetKey(IKey* pKey) const { - assert(m_bIsValid); - m_pTrack->GetKey(m_keyIndex, pKey); } //////////////////////////////////////////////////////////////////////////// float CUiAnimViewKeyConstHandle::GetTime() const { - assert(m_bIsValid); - return m_pTrack->GetKeyTime(m_keyIndex); } @@ -598,7 +594,7 @@ bool CUiAnimViewNode::operator<(const CUiAnimViewNode& otherNode) const if (thisTypeOrder == otherTypeOrder) { // Same node type, sort by name - return azstricmp(thisAnimNode.GetName(), otherAnimNode.GetName()) < 0; + return thisAnimNode.GetName() < otherAnimNode.GetName(); } return thisTypeOrder < otherTypeOrder; @@ -610,7 +606,7 @@ bool CUiAnimViewNode::operator<(const CUiAnimViewNode& otherNode) const if (thisTrack.GetParameterType() == otherTrack.GetParameterType()) { // Same parameter type, sort by name - return azstricmp(thisTrack.GetName(), otherTrack.GetName()) < 0; + return thisTrack.GetName() < otherTrack.GetName(); } return thisTrack.GetParameterType() < otherTrack.GetParameterType(); diff --git a/Gems/LyShine/Code/Editor/Animation/UiAnimViewNode.h b/Gems/LyShine/Code/Editor/Animation/UiAnimViewNode.h index 5a82d1be7f..80946eb317 100644 --- a/Gems/LyShine/Code/Editor/Animation/UiAnimViewNode.h +++ b/Gems/LyShine/Code/Editor/Animation/UiAnimViewNode.h @@ -19,13 +19,11 @@ class CUiAnimViewKeyConstHandle { public: CUiAnimViewKeyConstHandle() - : m_bIsValid(false) - , m_keyIndex(0) + : m_keyIndex(0) , m_pTrack(nullptr) {} CUiAnimViewKeyConstHandle(const CUiAnimViewTrack* pTrack, unsigned int keyIndex) - : m_bIsValid(true) - , m_keyIndex(keyIndex) + : m_keyIndex(keyIndex) , m_pTrack(pTrack) {} void GetKey(IKey* pKey) const; @@ -33,7 +31,6 @@ public: const CUiAnimViewTrack* GetTrack() const { return m_pTrack; } private: - bool m_bIsValid; unsigned int m_keyIndex; const CUiAnimViewTrack* m_pTrack; }; @@ -159,7 +156,7 @@ public: virtual ~CUiAnimViewNode() {} // Name - virtual const char* GetName() const = 0; + virtual AZStd::string GetName() const = 0; virtual bool SetName([[maybe_unused]] const char* pName) { return false; }; virtual bool CanBeRenamed() const { return false; } diff --git a/Gems/LyShine/Code/Editor/Animation/UiAnimViewNodes.cpp b/Gems/LyShine/Code/Editor/Animation/UiAnimViewNodes.cpp index 74d2c7d4fb..472100b334 100644 --- a/Gems/LyShine/Code/Editor/Animation/UiAnimViewNodes.cpp +++ b/Gems/LyShine/Code/Editor/Animation/UiAnimViewNodes.cpp @@ -413,7 +413,7 @@ CUiAnimViewNodesCtrl::CRecord* CUiAnimViewNodesCtrl::AddAnimNodeRecord(CRecord* { CRecord* pNewRecord = new CRecord(pAnimNode); - pNewRecord->setText(0, pAnimNode->GetName()); + pNewRecord->setText(0, QString::fromUtf8(pAnimNode->GetName().c_str())); UpdateUiAnimNodeRecord(pNewRecord, pAnimNode); pParentRecord->insertChild(GetInsertPosition(pParentRecord, pAnimNode), pNewRecord); FillNodesRec(pNewRecord, pAnimNode); @@ -426,7 +426,7 @@ CUiAnimViewNodesCtrl::CRecord* CUiAnimViewNodesCtrl::AddTrackRecord(CRecord* pPa { CRecord* pNewTrackRecord = new CRecord(pTrack); pNewTrackRecord->setSizeHint(0, QSize(30, 18)); - pNewTrackRecord->setText(0, pTrack->GetName()); + pNewTrackRecord->setText(0, QString::fromUtf8(pTrack->GetName().c_str())); UpdateTrackRecord(pNewTrackRecord, pTrack); pParentRecord->insertChild(GetInsertPosition(pParentRecord, pTrack), pNewTrackRecord); FillNodesRec(pNewTrackRecord, pTrack); @@ -576,7 +576,7 @@ void CUiAnimViewNodesCtrl::UpdateUiAnimNodeRecord(CRecord* pRecord, CUiAnimViewA int nNodeImage = GetIconIndexForNode(nodeType); assert(m_imageList.contains(nNodeImage)); - QString nodeName = pAnimNode->GetName(); + QString nodeName = QString::fromUtf8(pAnimNode->GetName().c_str()); pRecord->setIcon(0, m_imageList[nNodeImage]); @@ -635,7 +635,7 @@ void CUiAnimViewNodesCtrl::OnFillItems() m_nodeToRecordMap.clear(); CRecord* pRootGroupRec = new CRecord(pSequence); - pRootGroupRec->setText(0, pSequence->GetName()); + pRootGroupRec->setText(0, QString::fromUtf8(pSequence->GetName().c_str())); QFont f = font(); f.setBold(true); pRootGroupRec->setData(0, Qt::FontRole, f); @@ -987,7 +987,7 @@ void CUiAnimViewNodesCtrl::OnNMRclick(QPoint point) if (pAnimNode) { QString matName; - GetMatNameAndSubMtlIndexFromName(matName, pAnimNode->GetName()); + GetMatNameAndSubMtlIndexFromName(matName, pAnimNode->GetName().c_str()); QString newMatName; newMatName = QStringLiteral("%1.[%2]").arg(matName).arg(cmd - eMI_SelectSubmaterialBase + 1); UiAnimUndo undo("Rename Animation node"); @@ -1096,9 +1096,6 @@ void CUiAnimViewNodesCtrl::AddGroupNodeAddItems(UiAnimContextMenu& contextMenu, contextMenu.main.addAction("Add Event Node")->setData(eMI_AddEvent); } - const bool bIsDirectorOrSequence = (pAnimNode->GetType() == eUiAnimNodeType_Director || pAnimNode->GetNodeType() == eUiAVNT_Sequence); - - #if UI_ANIMATION_REMOVED contextMenu.main.addAction("Add Comment Node")->setData(eMI_AddCommentNode); contextMenu.main.addAction("Add Console Variable")->setData(eMI_AddConsoleVariable); @@ -1232,7 +1229,7 @@ int CUiAnimViewNodesCtrl::ShowPopupMenuSingleSelection(UiAnimContextMenu& contex if (bOnNode && !pNode->IsGroupNode()) { AddMenuSeperatorConditional(contextMenu.main, bAppended); - QString string = QString("%1 Tracks").arg(pAnimNode->GetName()); + QString string = QString("%1 Tracks").arg(QString::fromUtf8(pAnimNode->GetName().c_str())); contextMenu.main.addAction(string)->setEnabled(false); bool bAppendedTrackFlag = false; @@ -1250,7 +1247,7 @@ int CUiAnimViewNodesCtrl::ShowPopupMenuSingleSelection(UiAnimContextMenu& contex continue; } - QAction* a = contextMenu.main.addAction(QString(" %1").arg(pTrack2->GetName())); + QAction* a = contextMenu.main.addAction(QString(" %1").arg(QString::fromUtf8(pTrack2->GetName().c_str()))); a->setData(eMI_ShowHideBase + childIndex); a->setCheckable(true); a->setChecked(!pTrack2->IsHidden()); @@ -1386,7 +1383,7 @@ void CUiAnimViewNodesCtrl::FillAutoCompletionListForFilter() for (unsigned int i = 0; i < animNodeCount; ++i) { - strings << QString(animNodes.GetNode(i)->GetName()); + strings << QString::fromUtf8(animNodes.GetNode(i)->GetName().c_str()); } } else @@ -1690,7 +1687,7 @@ void CUiAnimViewNodesCtrl::OnNodeRenamed(CUiAnimViewNode* pNode, [[maybe_unused] if (!m_bIgnoreNotifications) { CRecord* pNodeRecord = GetNodeRecord(pNode); - pNodeRecord->setText(0, pNode->GetName()); + pNodeRecord->setText(0, QString::fromUtf8(pNode->GetName().c_str())); update(); } diff --git a/Gems/LyShine/Code/Editor/Animation/UiAnimViewNodes.h b/Gems/LyShine/Code/Editor/Animation/UiAnimViewNodes.h index a5cce764e3..38cc6d8384 100644 --- a/Gems/LyShine/Code/Editor/Animation/UiAnimViewNodes.h +++ b/Gems/LyShine/Code/Editor/Animation/UiAnimViewNodes.h @@ -56,7 +56,7 @@ public: CRecord(CUiAnimViewNode* pNode = nullptr); CUiAnimViewNode* GetNode() const { return m_pNode; } bool IsGroup() const { return m_pNode->GetChildCount() != 0; } - const QString GetName() const { return m_pNode->GetName(); } + const QString GetName() const { return QString::fromUtf8(m_pNode->GetName().c_str()); } // Workaround: CXTPReportRecord::IsVisible is // unreliable after the last visible element @@ -182,7 +182,6 @@ private: // Drag and drop CUiAnimViewAnimNodeBundle m_draggedNodes; - CUiAnimViewAnimNode* m_pDragTarget; std::unordered_map m_nodeToRecordMap; diff --git a/Gems/LyShine/Code/Editor/Animation/UiAnimViewSequence.cpp b/Gems/LyShine/Code/Editor/Animation/UiAnimViewSequence.cpp index d8888124a4..5d89957397 100644 --- a/Gems/LyShine/Code/Editor/Animation/UiAnimViewSequence.cpp +++ b/Gems/LyShine/Code/Editor/Animation/UiAnimViewSequence.cpp @@ -334,7 +334,7 @@ void CUiAnimViewSequence::OnNodeRenamed(CUiAnimViewNode* pNode, const char* pOld bool bLightAnimationSetActive = GetFlags() & IUiAnimSequence::eSeqFlags_LightAnimationSet; if (bLightAnimationSetActive) { - UpdateLightAnimationRefs(pOldName, pNode->GetName()); + UpdateLightAnimationRefs(pOldName, pNode->GetName().c_str()); } if (m_bNoNotifications) @@ -488,11 +488,12 @@ void CUiAnimViewSequence::SelectSelectedNodesInViewport() assert(UiAnimUndo::IsRecording()); CUiAnimViewAnimNodeBundle selectedNodes = GetSelectedAnimNodes(); - const unsigned int numSelectedNodes = selectedNodes.GetCount(); std::vector entitiesToBeSelected; #if UI_ANIMATION_REMOVED // lights + const unsigned int numSelectedNodes = selectedNodes.GetCount(); + // Also select objects that refer to light animation const bool bLightAnimationSetActive = GetFlags() & IUiAnimSequence::eSeqFlags_LightAnimationSet; if (bLightAnimationSetActive) diff --git a/Gems/LyShine/Code/Editor/Animation/UiAnimViewSequence.h b/Gems/LyShine/Code/Editor/Animation/UiAnimViewSequence.h index 69c933509f..3aa8d74563 100644 --- a/Gems/LyShine/Code/Editor/Animation/UiAnimViewSequence.h +++ b/Gems/LyShine/Code/Editor/Animation/UiAnimViewSequence.h @@ -86,7 +86,7 @@ public: // IUiAnimViewNode virtual EUiAnimViewNodeType GetNodeType() const override { return eUiAVNT_Sequence; } - virtual const char* GetName() const override { return m_pAnimSequence->GetName(); } + AZStd::string GetName() const override { return m_pAnimSequence->GetName(); } virtual bool SetName(const char* pName) override; virtual bool CanBeRenamed() const override { return true; } diff --git a/Gems/LyShine/Code/Editor/Animation/UiAnimViewSequenceManager.cpp b/Gems/LyShine/Code/Editor/Animation/UiAnimViewSequenceManager.cpp index 7a0d637a9e..4cfeeaff6a 100644 --- a/Gems/LyShine/Code/Editor/Animation/UiAnimViewSequenceManager.cpp +++ b/Gems/LyShine/Code/Editor/Animation/UiAnimViewSequenceManager.cpp @@ -58,7 +58,7 @@ CUiAnimViewSequence* CUiAnimViewSequenceManager::GetSequenceByName(QString name) { CUiAnimViewSequence* pSequence = (*iter).get(); - if (pSequence->GetName() == name) + if (QString::fromUtf8(pSequence->GetName().c_str()) == name) { return pSequence; } @@ -156,8 +156,8 @@ void CUiAnimViewSequenceManager::SortSequences() std::stable_sort(m_sequences.begin(), m_sequences.end(), [](const std::unique_ptr& a, const std::unique_ptr& b) -> bool { - QString aName = a.get()->GetName(); - QString bName = b.get()->GetName(); + QString aName = QString::fromUtf8(a.get()->GetName().c_str()); + QString bName = QString::fromUtf8(b.get()->GetName().c_str()); return aName < bName; }); } diff --git a/Gems/LyShine/Code/Editor/Animation/UiAnimViewSequenceManager.h b/Gems/LyShine/Code/Editor/Animation/UiAnimViewSequenceManager.h index e26a1ceec3..f29f0e58e1 100644 --- a/Gems/LyShine/Code/Editor/Animation/UiAnimViewSequenceManager.h +++ b/Gems/LyShine/Code/Editor/Animation/UiAnimViewSequenceManager.h @@ -15,6 +15,7 @@ #include #include "UiEditorAnimationBus.h" #include "UiAnimUndoManager.h" +#include "CryCommon/StlUtils.h" #include diff --git a/Gems/LyShine/Code/Editor/Animation/UiAnimViewSplineCtrl.cpp b/Gems/LyShine/Code/Editor/Animation/UiAnimViewSplineCtrl.cpp index 8edd13f8cc..e071a3e631 100644 --- a/Gems/LyShine/Code/Editor/Animation/UiAnimViewSplineCtrl.cpp +++ b/Gems/LyShine/Code/Editor/Animation/UiAnimViewSplineCtrl.cpp @@ -28,7 +28,7 @@ public: CUndoUiAnimViewSplineCtrl(CUiAnimViewSplineCtrl* pCtrl, std::vector& splineContainer) : CUndoAnimKeySelection(CUiAnimViewSequenceManager::GetSequenceManager()->GetAnimationContext()->GetSequence()) { - m_sequenceName = CUiAnimViewSequenceManager::GetSequenceManager()->GetAnimationContext()->GetSequence()->GetName(); + m_sequenceName = QString::fromUtf8(CUiAnimViewSequenceManager::GetSequenceManager()->GetAnimationContext()->GetSequence()->GetName().c_str()); m_pCtrl = pCtrl; @@ -589,7 +589,6 @@ void CUiAnimViewSplineCtrl::mouseMoveEvent(QMouseEvent* event) CUiAnimViewSequenceNotificationContext context(pSequence); - QPoint cMousePosPrev = m_cMousePos; m_cMousePos = point; if (m_editMode == SelectMode) diff --git a/Gems/LyShine/Code/Editor/Animation/UiAnimViewTrack.cpp b/Gems/LyShine/Code/Editor/Animation/UiAnimViewTrack.cpp index 2984e152cd..fe120d7f33 100644 --- a/Gems/LyShine/Code/Editor/Animation/UiAnimViewTrack.cpp +++ b/Gems/LyShine/Code/Editor/Animation/UiAnimViewTrack.cpp @@ -16,6 +16,7 @@ #include "UiEditorAnimationBus.h" #include +#include ////////////////////////////////////////////////////////////////////////// void CUiAnimViewTrackBundle::AppendTrack(CUiAnimViewTrack* pTrack) @@ -404,7 +405,7 @@ void CUiAnimViewTrack::RestoreFromMemento(const CUiAnimViewTrackMemento& memento } ////////////////////////////////////////////////////////////////////////// -const char* CUiAnimViewTrack::GetName() const +AZStd::string CUiAnimViewTrack::GetName() const { CUiAnimViewNode* pParentNode = GetParentNode(); @@ -629,7 +630,7 @@ void CUiAnimViewTrack::CopyKeysToClipboard(XmlNodeRef& xmlNode, const bool bOnly EBUS_EVENT_RESULT(animationSystem, UiEditorAnimationBus, GetAnimationSystem); XmlNodeRef childNode = xmlNode->newChild("Track"); - childNode->setAttr("name", GetName()); + childNode->setAttr("name", GetName().c_str()); GetParameterType().Serialize(animationSystem, childNode, false); childNode->setAttr("valueType", GetValueType()); diff --git a/Gems/LyShine/Code/Editor/Animation/UiAnimViewTrack.h b/Gems/LyShine/Code/Editor/Animation/UiAnimViewTrack.h index a2e38edc51..b16dbf6dfa 100644 --- a/Gems/LyShine/Code/Editor/Animation/UiAnimViewTrack.h +++ b/Gems/LyShine/Code/Editor/Animation/UiAnimViewTrack.h @@ -73,7 +73,7 @@ public: CUiAnimViewAnimNode* GetAnimNode() const; // Name getter - virtual const char* GetName() const; + AZStd::string GetName() const override; // CUiAnimViewNode virtual EUiAnimViewNodeType GetNodeType() const override { return eUiAVNT_Track; } diff --git a/Gems/LyShine/Code/Editor/Animation/Util/UiEditorUtils.cpp b/Gems/LyShine/Code/Editor/Animation/Util/UiEditorUtils.cpp index 82d764491f..41f7300002 100644 --- a/Gems/LyShine/Code/Editor/Animation/Util/UiEditorUtils.cpp +++ b/Gems/LyShine/Code/Editor/Animation/Util/UiEditorUtils.cpp @@ -120,7 +120,7 @@ QColor ColorLinearToGamma(ColorF col) g = (float)(g <= 0.0031308 ? (12.92 * g) : (1.055 * pow((double)g, 1.0 / 2.4) - 0.055)); b = (float)(b <= 0.0031308 ? (12.92 * b) : (1.055 * pow((double)b, 1.0 / 2.4) - 0.055)); - return QColor(FtoI(r * 255.0f), FtoI(g * 255.0f), FtoI(b * 255.0f)); + return QColor(int(r * 255.0f), int(g * 255.0f), int(b * 255.0f)); } ////////////////////////////////////////////////////////////////////////// diff --git a/Gems/LyShine/Code/Editor/ComponentHelpers.cpp b/Gems/LyShine/Code/Editor/ComponentHelpers.cpp index b2c3d20025..d7ba13cb7c 100644 --- a/Gems/LyShine/Code/Editor/ComponentHelpers.cpp +++ b/Gems/LyShine/Code/Editor/ComponentHelpers.cpp @@ -764,7 +764,7 @@ namespace ComponentHelpers QObject::connect(action, &QAction::triggered, hierarchy, - [serializeContext, hierarchy, componentClass, items]([[maybe_unused]] bool checked) + [hierarchy, componentClass, items]([[maybe_unused]] bool checked) { EBUS_EVENT(UiEditorInternalNotificationBus, OnBeginUndoableEntitiesChange); diff --git a/Gems/LyShine/Code/Editor/EditorMenu.cpp b/Gems/LyShine/Code/Editor/EditorMenu.cpp index 840bd206ab..8a6c93de6b 100644 --- a/Gems/LyShine/Code/Editor/EditorMenu.cpp +++ b/Gems/LyShine/Code/Editor/EditorMenu.cpp @@ -704,7 +704,7 @@ void EditorWindow::AddMenu_View() action->setEnabled(canvasLoaded); QObject::connect(action, &QAction::triggered, - [this]([[maybe_unused]] bool checked) + []([[maybe_unused]] bool checked) { gEnv->pCryFont->ReloadAllFonts(); }); diff --git a/Gems/LyShine/Code/Editor/EditorWindow.cpp b/Gems/LyShine/Code/Editor/EditorWindow.cpp index 8d7e20492d..5ae1eb44b9 100644 --- a/Gems/LyShine/Code/Editor/EditorWindow.cpp +++ b/Gems/LyShine/Code/Editor/EditorWindow.cpp @@ -2103,24 +2103,6 @@ void EditorWindow::RestoreModeSettings(UiEditorMode mode) settings.endGroup(); // UI canvas editor } -static const char* UIEDITOR_UNLOAD_SAVED_CANVAS_METRIC_EVENT_NAME = "UiEditorUnloadSavedCanvas"; -static const char* UIEDITOR_CANVAS_ID_ATTRIBUTE_NAME = "CanvasId"; -static const char* UIEDITOR_CANVAS_WIDTH_METRIC_NAME = "CanvasWidth"; -static const char* UIEDITOR_CANVAS_HEIGHT_METRIC_NAME = "CanvasHeight"; -static const char* UIEDITOR_CANVAS_MAX_HIERARCHY_DEPTH_METRIC_NAME = "MaxHierarchyDepth"; -static const char* UIEDITOR_CANVAS_NUM_ELEMENT_METRIC_NAME = "NumElement"; -static const char* UIEDITOR_CANVAS_NUM_ELEMENTS_WITH_COMPONENT_PREFIX_METRIC_NAME = "Num"; -static const char* UIEDITOR_CANVAS_NUM_ELEMENTS_WITH_CUSTOM_COMPONENT_METRIC_NAME = "NumCustomElement"; -static const char* UIEDITOR_CANVAS_NUM_UNIQUE_CUSTOM_COMPONENT_NAME = "NumUniqueCustomComponent"; -static const char* UIEDITOR_CANVAS_NUM_AVAILABLE_CUSTOM_COMPONENT_NAME = "NumAvailableCustomComponent"; -static const char* UIEDITOR_CANVAS_NUM_ANCHOR_PRESETS_ATTRIBUTE_NAME = "NumAnchorPreset"; -static const char* UIEDITOR_CANVAS_NUM_ANCHOR_CUSTOM_ATTRIBUTE_NAME = "NumAnchorCustom"; -static const char* UIEDITOR_CANVAS_NUM_PIVOT_PRESETS_ATTRIBUTE_NAME = "NumPivotPreset"; -static const char* UIEDITOR_CANVAS_NUM_PIVOT_CUSTOM_ATTRIBUTE_NAME = "NumPivotCustom"; -static const char* UIEDITOR_CANVAS_NUM_ROTATED_ELEMENT_METRIC_NAME = "NumRotatedElement"; -static const char* UIEDITOR_CANVAS_NUM_SCALED_ELEMENT_METRIC_NAME = "NumScaledElement"; -static const char* UIEDITOR_CANVAS_NUM_SCALE_TO_DEVICE_ELEMENT_METRIC_NAME = "NumScaleToDeviceElement"; - int EditorWindow::GetCanvasMaxHierarchyDepth(const LyShine::EntityArray& rootChildElements) { int depth = 0; diff --git a/Gems/LyShine/Code/Editor/HierarchyMenu.cpp b/Gems/LyShine/Code/Editor/HierarchyMenu.cpp index ab0c250434..004fe53354 100644 --- a/Gems/LyShine/Code/Editor/HierarchyMenu.cpp +++ b/Gems/LyShine/Code/Editor/HierarchyMenu.cpp @@ -236,14 +236,14 @@ void HierarchyMenu::SliceMenuItems(HierarchyWidget* hierarchy, if (showMask & Show::kNewSlice) { QAction* action = addAction("Make Cascaded Slice from Selected Slices && Entities..."); - QObject::connect(action, &QAction::triggered, hierarchy, [hierarchy, selectedEntities] + QObject::connect(action, &QAction::triggered, hierarchy, [hierarchy] { hierarchy->GetEditorWindow()->GetSliceManager()->MakeSliceFromSelectedItems(hierarchy, true); } ); action = addAction(QObject::tr("Make Detached Slice from Selected Entities...")); - QObject::connect(action, &QAction::triggered, hierarchy, [hierarchy, selectedEntities] + QObject::connect(action, &QAction::triggered, hierarchy, [hierarchy] { hierarchy->GetEditorWindow()->GetSliceManager()->MakeSliceFromSelectedItems(hierarchy, false); } @@ -330,7 +330,7 @@ void HierarchyMenu::SliceMenuItems(HierarchyWidget* hierarchy, slicesAddedToMenu.push_back(sliceAsset.GetId()); QAction* action = menu->addAction(assetPath.c_str()); - QObject::connect(action, &QAction::triggered, [this, hierarchy, sliceAsset] + QObject::connect(action, &QAction::triggered, [hierarchy, sliceAsset] { hierarchy->GetEditorWindow()->EditSliceInNewTab(sliceAsset.GetId()); } diff --git a/Gems/LyShine/Code/Editor/HierarchyWidget.h b/Gems/LyShine/Code/Editor/HierarchyWidget.h index 324eda207b..0dbe423b38 100644 --- a/Gems/LyShine/Code/Editor/HierarchyWidget.h +++ b/Gems/LyShine/Code/Editor/HierarchyWidget.h @@ -29,6 +29,8 @@ class HierarchyWidget public: + AZ_CLASS_ALLOCATOR(HierarchyWidget, AZ::SystemAllocator, 0); + HierarchyWidget(EditorWindow* editorWindow); virtual ~HierarchyWidget(); diff --git a/Gems/LyShine/Code/Editor/MainToolbar.cpp b/Gems/LyShine/Code/Editor/MainToolbar.cpp index ee2d3db7b5..dd0ab39f89 100644 --- a/Gems/LyShine/Code/Editor/MainToolbar.cpp +++ b/Gems/LyShine/Code/Editor/MainToolbar.cpp @@ -32,7 +32,7 @@ MainToolbar::MainToolbar(EditorWindow* parent) QObject::connect(m_zoomFactorSpinBox, QOverload::of(&AzQtComponents::DoubleSpinBox::valueChanged), - [this, parent](double value) + [parent](double value) { parent->GetViewport()->GetViewportInteraction()->SetCanvasZoomPercent(static_cast(value)); }); diff --git a/Gems/LyShine/Code/Editor/PropertiesContainer.h b/Gems/LyShine/Code/Editor/PropertiesContainer.h index 0d47444281..209a2354ad 100644 --- a/Gems/LyShine/Code/Editor/PropertiesContainer.h +++ b/Gems/LyShine/Code/Editor/PropertiesContainer.h @@ -119,7 +119,6 @@ private: PropertiesWidget* m_propertiesWidget; EditorWindow* m_editorWindow; - QWidget* m_containerWidget; QWidget* m_componentListContents; QVBoxLayout* m_rowLayout; QLineEdit* m_selectedEntityDisplayNameWidget; diff --git a/Gems/LyShine/Code/Editor/PropertyHandlerAnchor.cpp b/Gems/LyShine/Code/Editor/PropertyHandlerAnchor.cpp index 8e00b6f277..5ffba22df6 100644 --- a/Gems/LyShine/Code/Editor/PropertyHandlerAnchor.cpp +++ b/Gems/LyShine/Code/Editor/PropertyHandlerAnchor.cpp @@ -350,10 +350,8 @@ void PropertyHandlerAnchor::WriteGUIValuesIntoProperty(size_t index, PropertyAnc } } -bool PropertyHandlerAnchor::ReadValuesIntoGUI(size_t index, PropertyAnchorCtrl* GUI, const property_t& instance, [[maybe_unused]] AzToolsFramework::InstanceDataNode* node) +bool PropertyHandlerAnchor::ReadValuesIntoGUI([[maybe_unused]] size_t index, PropertyAnchorCtrl* GUI, const property_t& instance, [[maybe_unused]] AzToolsFramework::InstanceDataNode* node) { - (int)index; - AzQtComponents::VectorInput* ctrl = GUI->GetPropertyVectorCtrl(); ctrl->blockSignals(true); diff --git a/Gems/LyShine/Code/Editor/PropertyHandlerChar.cpp b/Gems/LyShine/Code/Editor/PropertyHandlerChar.cpp index b3cacec065..d99cd9bf20 100644 --- a/Gems/LyShine/Code/Editor/PropertyHandlerChar.cpp +++ b/Gems/LyShine/Code/Editor/PropertyHandlerChar.cpp @@ -27,19 +27,16 @@ void PropertyHandlerChar::ConsumeAttribute(AzToolsFramework::PropertyStringLineE { } -void PropertyHandlerChar::WriteGUIValuesIntoProperty(size_t index, AzToolsFramework::PropertyStringLineEditCtrl* GUI, property_t& instance, [[maybe_unused]] AzToolsFramework::InstanceDataNode* node) +void PropertyHandlerChar::WriteGUIValuesIntoProperty([[maybe_unused]] size_t index, AzToolsFramework::PropertyStringLineEditCtrl* GUI, property_t& instance, [[maybe_unused]] AzToolsFramework::InstanceDataNode* node) { - (int)index; AZStd::string str = GUI->value(); wchar_t character = '\0'; AZStd::to_wstring(&character, 1, str.c_str()); instance = character; } -bool PropertyHandlerChar::ReadValuesIntoGUI(size_t index, AzToolsFramework::PropertyStringLineEditCtrl* GUI, const property_t& instance, [[maybe_unused]] AzToolsFramework::InstanceDataNode* node) +bool PropertyHandlerChar::ReadValuesIntoGUI([[maybe_unused]] size_t index, AzToolsFramework::PropertyStringLineEditCtrl* GUI, const property_t& instance, [[maybe_unused]] AzToolsFramework::InstanceDataNode* node) { - (int)index; - GUI->blockSignals(true); { // NOTE: this assumes the uint32_t can be interpreted as a wchar_t, it seems to diff --git a/Gems/LyShine/Code/Editor/PropertyHandlerDirectory.cpp b/Gems/LyShine/Code/Editor/PropertyHandlerDirectory.cpp index 1f3e28b077..5a464b2210 100644 --- a/Gems/LyShine/Code/Editor/PropertyHandlerDirectory.cpp +++ b/Gems/LyShine/Code/Editor/PropertyHandlerDirectory.cpp @@ -53,7 +53,7 @@ PropertyDirectoryCtrl::PropertyDirectoryCtrl(QWidget* parent) QObject::connect(refreshButton, &QPushButton::clicked, - [this]([[maybe_unused]] bool checked) + []([[maybe_unused]] bool checked) { UiEditorRefreshDirectoryNotificationBus::Broadcast(&UiEditorRefreshDirectoryNotificationInterface::OnRefreshDirectory); }); diff --git a/Gems/LyShine/Code/Editor/PropertyHandlerOffset.cpp b/Gems/LyShine/Code/Editor/PropertyHandlerOffset.cpp index 22f87b5b53..b8a34ae314 100644 --- a/Gems/LyShine/Code/Editor/PropertyHandlerOffset.cpp +++ b/Gems/LyShine/Code/Editor/PropertyHandlerOffset.cpp @@ -106,10 +106,8 @@ void PropertyHandlerOffset::WriteGUIValuesIntoProperty(size_t index, AzQtCompone EBUS_EVENT_ID(id, UiTransform2dBus, SetOffsets, newInternalOffset); } -bool PropertyHandlerOffset::ReadValuesIntoGUI(size_t index, AzQtComponents::VectorInput* GUI, const UiTransform2dInterface::Offsets& instance, AzToolsFramework::InstanceDataNode* node) +bool PropertyHandlerOffset::ReadValuesIntoGUI([[maybe_unused]] size_t index, AzQtComponents::VectorInput* GUI, const UiTransform2dInterface::Offsets& instance, AzToolsFramework::InstanceDataNode* node) { - (int)index; - // IMPORTANT: We DON'T need to do validation of data here because that's // done for us BEFORE we get here. We DO need to set the labels here. diff --git a/Gems/LyShine/Code/Editor/PropertyHandlerPivot.cpp b/Gems/LyShine/Code/Editor/PropertyHandlerPivot.cpp index 47d98cf68a..3f89b2fe74 100644 --- a/Gems/LyShine/Code/Editor/PropertyHandlerPivot.cpp +++ b/Gems/LyShine/Code/Editor/PropertyHandlerPivot.cpp @@ -143,10 +143,8 @@ void PropertyHandlerPivot::WriteGUIValuesIntoProperty(size_t index, PropertyPivo } } -bool PropertyHandlerPivot::ReadValuesIntoGUI(size_t index, PropertyPivotCtrl* GUI, const property_t& instance, [[maybe_unused]] AzToolsFramework::InstanceDataNode* node) +bool PropertyHandlerPivot::ReadValuesIntoGUI([[maybe_unused]] size_t index, PropertyPivotCtrl* GUI, const property_t& instance, [[maybe_unused]] AzToolsFramework::InstanceDataNode* node) { - (int)index; - AzQtComponents::VectorInput* ctrl = GUI->GetPropertyVectorCtrl(); ctrl->blockSignals(true); diff --git a/Gems/LyShine/Code/Editor/SpriteBorderEditor.cpp b/Gems/LyShine/Code/Editor/SpriteBorderEditor.cpp index 04f655123c..93d77bd174 100644 --- a/Gems/LyShine/Code/Editor/SpriteBorderEditor.cpp +++ b/Gems/LyShine/Code/Editor/SpriteBorderEditor.cpp @@ -227,7 +227,6 @@ void SpriteBorderEditor::DisplaySelectedCell(AZ::u32 cellIndex) // Determine how much we need to scale the view to fit the cell // contents to the displayed properties image. const AZ::Vector2 cellSize = m_sprite->GetCellSize(cellIndex); - const AZ::Vector2 cellScale = AZ::Vector2(m_unscaledSpriteSheet.size().width() / cellSize.GetX(), m_unscaledSpriteSheet.size().height() / cellSize.GetY()); // Scale-to-fit, while preserving aspect ratio. QRect croppedRect = m_unscaledSpriteSheet.rect(); diff --git a/Gems/LyShine/Code/Editor/ViewportInteraction.h b/Gems/LyShine/Code/Editor/ViewportInteraction.h index 100d1fdb1e..a104d87634 100644 --- a/Gems/LyShine/Code/Editor/ViewportInteraction.h +++ b/Gems/LyShine/Code/Editor/ViewportInteraction.h @@ -261,7 +261,6 @@ private: // data AZStd::string m_cursorStr; QCursor m_cursorRotate; - bool m_inObjectPickMode = false; ViewportInteraction::InteractionMode m_interactionModeBeforePickMode; AZ::EntityId m_hoverElement; bool m_entityPickedOnMousePress; // used to ignore mouse move/release events if element was picked on the mouse press diff --git a/Gems/LyShine/Code/Source/Animation/2DSpline.h b/Gems/LyShine/Code/Source/Animation/2DSpline.h index b831bd669a..92494ed78f 100644 --- a/Gems/LyShine/Code/Source/Animation/2DSpline.h +++ b/Gems/LyShine/Code/Source/Animation/2DSpline.h @@ -694,7 +694,6 @@ namespace UiSpline Vec2 interpolate_tangent(float time, float& u) { Vec2 tangent; - const float epsilon = 0.001f; int curr = seek_key(time); int next = curr + 1; assert(0 <= curr && next < num_keys()); diff --git a/Gems/LyShine/Code/Source/Animation/AnimNode.cpp b/Gems/LyShine/Code/Source/Animation/AnimNode.cpp index a87dae6fbd..9086d68f01 100644 --- a/Gems/LyShine/Code/Source/Animation/AnimNode.cpp +++ b/Gems/LyShine/Code/Source/Animation/AnimNode.cpp @@ -41,15 +41,6 @@ ////////////////////////////////////////////////////////////////////////// static const EUiAnimCurveType DEFAULT_TRACK_TYPE = eUiAnimCurveType_BezierFloat; -// Old serialization values that are no longer -// defined in IUiAnimationSystem.h, but needed for conversion: -static const int OLD_ACURVE_GOTO = 21; -static const int OLD_APARAM_PARTICLE_COUNT_SCALE = 95; -static const int OLD_APARAM_PARTICLE_PULSE_PERIOD = 96; -static const int OLD_APARAM_PARTICLE_SCALE = 97; -static const int OLD_APARAM_PARTICLE_SPEED_SCALE = 98; -static const int OLD_APARAM_PARTICLE_STRENGTH = 99; - ////////////////////////////////////////////////////////////////////////// // CUiAnimNode. ////////////////////////////////////////////////////////////////////////// @@ -65,7 +56,7 @@ int CUiAnimNode::GetTrackCount() const return static_cast(m_tracks.size()); } -const char* CUiAnimNode::GetParamName(const CUiAnimParamType& paramType) const +AZStd::string CUiAnimNode::GetParamName(const CUiAnimParamType& paramType) const { SParamInfo info; if (GetParamInfoFromType(paramType, info)) @@ -636,7 +627,7 @@ void CUiAnimNode::Serialize(XmlNodeRef& xmlNode, bool bLoading, bool bLoadEmptyT EUiAnimNodeType nodeType = GetType(); static_cast(GetUiAnimationSystem())->SerializeNodeType(nodeType, xmlNode, bLoading, IUiAnimSequence::kSequenceVersion, m_flags); - xmlNode->setAttr("Name", GetName()); + xmlNode->setAttr("Name", GetName().c_str()); // Don't store expanded or selected flags int flags = GetFlags() & ~(eUiAnimNodeFlags_Expanded | eUiAnimNodeFlags_EntitySelected); diff --git a/Gems/LyShine/Code/Source/Animation/AnimNode.h b/Gems/LyShine/Code/Source/Animation/AnimNode.h index dc3144dfba..6ac198a5c7 100644 --- a/Gems/LyShine/Code/Source/Animation/AnimNode.h +++ b/Gems/LyShine/Code/Source/Animation/AnimNode.h @@ -39,7 +39,7 @@ public: , valueType(_valueType) , flags(_flags) {}; - const char* name; // parameter name. + AZStd::string name; // parameter name. CUiAnimParamType paramType; // parameter id. EUiAnimValue valueType; // value type, defines type of track to use for animating this parameter. ESupportedParamFlags flags; // combination of flags from ESupportedParamFlags. @@ -58,7 +58,7 @@ public: ////////////////////////////////////////////////////////////////////////// void SetName(const char* name) override { m_name = name; }; - const char* GetName() { return m_name.c_str(); }; + AZStd::string GetName() override { return m_name; }; void SetSequence(IUiAnimSequence* pSequence) override { m_pSequence = pSequence; } // Return Animation Sequence that owns this node. @@ -81,7 +81,7 @@ public: ////////////////////////////////////////////////////////////////////////// bool IsParamValid(const CUiAnimParamType& paramType) const; - virtual const char* GetParamName(const CUiAnimParamType& param) const; + AZStd::string GetParamName(const CUiAnimParamType& param) const override; virtual EUiAnimValue GetParamValueType(const CUiAnimParamType& paramType) const; virtual IUiAnimNode::ESupportedParamFlags GetParamFlags(const CUiAnimParamType& paramType) const; virtual unsigned int GetParamCount() const { return 0; }; diff --git a/Gems/LyShine/Code/Source/Animation/AnimSplineTrack.h b/Gems/LyShine/Code/Source/Animation/AnimSplineTrack.h index cd94277795..0bc625155a 100644 --- a/Gems/LyShine/Code/Source/Animation/AnimSplineTrack.h +++ b/Gems/LyShine/Code/Source/Animation/AnimSplineTrack.h @@ -47,7 +47,7 @@ public: virtual int GetSubTrackCount() const { return 0; }; virtual IUiAnimTrack* GetSubTrack([[maybe_unused]] int nIndex) const { return 0; }; - virtual const char* GetSubTrackName([[maybe_unused]] int nIndex) const { return NULL; }; + AZStd::string GetSubTrackName([[maybe_unused]] int nIndex) const override { return AZStd::string(); }; virtual void SetSubTrackName([[maybe_unused]] int nIndex, [[maybe_unused]] const char* name) { assert(0); } virtual const CUiAnimParamType& GetParameterType() const { return m_nParamType; }; diff --git a/Gems/LyShine/Code/Source/Animation/AnimTrack.h b/Gems/LyShine/Code/Source/Animation/AnimTrack.h index df0ae3a805..9645572e3e 100644 --- a/Gems/LyShine/Code/Source/Animation/AnimTrack.h +++ b/Gems/LyShine/Code/Source/Animation/AnimTrack.h @@ -32,7 +32,7 @@ public: virtual int GetSubTrackCount() const { return 0; }; virtual IUiAnimTrack* GetSubTrack([[maybe_unused]] int nIndex) const { return 0; }; - virtual const char* GetSubTrackName([[maybe_unused]] int nIndex) const { return NULL; }; + AZStd::string GetSubTrackName([[maybe_unused]] int nIndex) const override { return AZStd::string(); }; virtual void SetSubTrackName([[maybe_unused]] int nIndex, [[maybe_unused]] const char* name) { assert(0); } virtual const CUiAnimParamType& GetParameterType() const { return m_nParamType; }; diff --git a/Gems/LyShine/Code/Source/Animation/AzEntityNode.cpp b/Gems/LyShine/Code/Source/Animation/AzEntityNode.cpp index 814d1404b4..cc4e70e010 100644 --- a/Gems/LyShine/Code/Source/Animation/AzEntityNode.cpp +++ b/Gems/LyShine/Code/Source/Animation/AzEntityNode.cpp @@ -27,18 +27,6 @@ #define s_nodeParams s_nodeParamsEnt #define AddSupportedParam AddSupportedParamEnt -static const float TIMEJUMPED_TRANSITION_TIME = 1.0f; -static const float EPSILON = 0.01f; - -static const char* s_VariablePrefixes[] = -{ - "n", "i", "b", "f", "s", "ei", "es", - "shader", "clr", "color", "vector", - "snd", "sound", "dialog", "tex", "texture", - "obj", "object", "file", "text", "equip", "reverbpreset", "eaxpreset", - "aianchor", "customaction", "gametoken", "seq_", "mission_", "seqid_", "lightanimation_" -}; - ////////////////////////////////////////////////////////////////////////// namespace { @@ -56,16 +44,7 @@ namespace param.flags = (IUiAnimNode::ESupportedParamFlags)flags; nodeParams.push_back(param); } - - // Quat::IsEquivalent has numerical problems with very similar values - bool CompareRotation(const Quat& q1, const Quat& q2, float epsilon) - { - return (fabs_tpl(q1.v.x - q2.v.x) <= epsilon) - && (fabs_tpl(q1.v.y - q2.v.y) <= epsilon) - && (fabs_tpl(q1.v.z - q2.v.z) <= epsilon) - && (fabs_tpl(q1.w - q2.w) <= epsilon); - } -}; +} ////////////////////////////////////////////////////////////////////////// CUiAnimAzEntityNode::CUiAnimAzEntityNode(const int id) @@ -384,7 +363,7 @@ void CUiAnimAzEntityNode::ComputeOffsetsFromElementNames() } ////////////////////////////////////////////////////////////////////////// -const char* CUiAnimAzEntityNode::GetParamName(const CUiAnimParamType& param) const +AZStd::string CUiAnimAzEntityNode::GetParamName(const CUiAnimParamType& param) const { SParamInfo info; if (GetParamInfoFromType(param, info)) @@ -402,7 +381,7 @@ const char* CUiAnimAzEntityNode::GetParamName(const CUiAnimParamType& param) con } ////////////////////////////////////////////////////////////////////////// -const char* CUiAnimAzEntityNode::GetParamNameForTrack(const CUiAnimParamType& param, const IUiAnimTrack* track) const +AZStd::string CUiAnimAzEntityNode::GetParamNameForTrack(const CUiAnimParamType& param, const IUiAnimTrack* track) const { // for Az Component Fields we use the name from the ClassElement if (param == eUiAnimParamType_AzComponentField) diff --git a/Gems/LyShine/Code/Source/Animation/AzEntityNode.h b/Gems/LyShine/Code/Source/Animation/AzEntityNode.h index 56680f1094..9771ac7be3 100644 --- a/Gems/LyShine/Code/Source/Animation/AzEntityNode.h +++ b/Gems/LyShine/Code/Source/Animation/AzEntityNode.h @@ -91,8 +91,8 @@ public: ////////////////////////////////////////////////////////////////////////// virtual unsigned int GetParamCount() const; virtual CUiAnimParamType GetParamType(unsigned int nIndex) const; - virtual const char* GetParamName(const CUiAnimParamType& param) const; - const char* GetParamNameForTrack(const CUiAnimParamType& param, const IUiAnimTrack* track) const override; + AZStd::string GetParamName(const CUiAnimParamType& param) const override; + AZStd::string GetParamNameForTrack(const CUiAnimParamType& param, const IUiAnimTrack* track) const override; static int GetParamCountStatic(); static bool GetParamInfoStatic(int nIndex, SParamInfo& info); diff --git a/Gems/LyShine/Code/Source/Animation/CompoundSplineTrack.cpp b/Gems/LyShine/Code/Source/Animation/CompoundSplineTrack.cpp index dee96ee22a..a9b7dde6cd 100644 --- a/Gems/LyShine/Code/Source/Animation/CompoundSplineTrack.cpp +++ b/Gems/LyShine/Code/Source/Animation/CompoundSplineTrack.cpp @@ -386,10 +386,10 @@ IUiAnimTrack* UiCompoundSplineTrack::GetSubTrack(int nIndex) const } ////////////////////////////////////////////////////////////////////////// -const char* UiCompoundSplineTrack::GetSubTrackName(int nIndex) const +AZStd::string UiCompoundSplineTrack::GetSubTrackName(int nIndex) const { assert(nIndex >= 0 && nIndex < m_nDimensions); - return m_subTrackNames[nIndex].c_str(); + return m_subTrackNames[nIndex]; } diff --git a/Gems/LyShine/Code/Source/Animation/CompoundSplineTrack.h b/Gems/LyShine/Code/Source/Animation/CompoundSplineTrack.h index 3ae230d4e4..127b6593fb 100644 --- a/Gems/LyShine/Code/Source/Animation/CompoundSplineTrack.h +++ b/Gems/LyShine/Code/Source/Animation/CompoundSplineTrack.h @@ -37,7 +37,7 @@ public: virtual int GetSubTrackCount() const { return m_nDimensions; }; virtual IUiAnimTrack* GetSubTrack(int nIndex) const; - virtual const char* GetSubTrackName(int nIndex) const; + AZStd::string GetSubTrackName(int nIndex) const override; virtual void SetSubTrackName(int nIndex, const char* name); virtual EUiAnimCurveType GetCurveType() { return eUiAnimCurveType_BezierFloat; }; diff --git a/Gems/LyShine/Code/Source/Animation/TrackEventTrack.h b/Gems/LyShine/Code/Source/Animation/TrackEventTrack.h index bbfba486c8..5896b19a2a 100644 --- a/Gems/LyShine/Code/Source/Animation/TrackEventTrack.h +++ b/Gems/LyShine/Code/Source/Animation/TrackEventTrack.h @@ -9,6 +9,7 @@ #pragma once #include +#include "CryCommon/StlUtils.h" #include "AnimTrack.h" #include "AnimKey.h" diff --git a/Gems/LyShine/Code/Source/Animation/UiAnimationSystem.cpp b/Gems/LyShine/Code/Source/Animation/UiAnimationSystem.cpp index 35fde93e83..012eaacd1b 100644 --- a/Gems/LyShine/Code/Source/Animation/UiAnimationSystem.cpp +++ b/Gems/LyShine/Code/Source/Animation/UiAnimationSystem.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -106,7 +107,6 @@ void UiAnimationSystem::DoNodeStaticInitialisation() bool UiAnimationSystem::Load(const char* pszFile, const char* pszMission) { INDENT_LOG_DURING_SCOPE (true, "UI Animation system is loading the file '%s' (mission='%s')", pszFile, pszMission); - LOADING_TIME_PROFILE_SECTION(GetISystem()); XmlNodeRef rootNode = m_pSystem->LoadXmlFromFile(pszFile); if (!rootNode) @@ -731,11 +731,11 @@ void UiAnimationSystem::StillUpdate() ////////////////////////////////////////////////////////////////////////// void UiAnimationSystem::ShowPlayedSequencesDebug() { - f32 green[4] = {0, 1, 0, 1}; - f32 purple[4] = {1, 0, 1, 1}; - f32 white[4] = {1, 1, 1, 1}; + //f32 green[4] = {0, 1, 0, 1}; + //f32 purple[4] = {1, 0, 1, 1}; + //f32 white[4] = {1, 1, 1, 1}; float y = 10.0f; - std::vector names; + AZStd::vector names; for (PlayingSequences::iterator it = m_playingSequences.begin(); it != m_playingSequences.end(); ++it) { @@ -746,8 +746,9 @@ void UiAnimationSystem::ShowPlayedSequencesDebug() continue; } - const char* fullname = playingSequence.sequence->GetName(); - gEnv->pRenderer->Draw2dLabel(1.0f, y, 1.3f, green, false, "Sequence %s : %f (x %f)", fullname, playingSequence.currentTime, playingSequence.currentSpeed); + AZ_Assert(false,"gEnv->pRenderer is always null so it can't be used here"); + //const char* fullname = playingSequence.sequence->GetName(); + //gEnv->pRenderer->Draw2dLabel(1.0f, y, 1.3f, green, false, "Sequence %s : %f (x %f)", fullname, playingSequence.currentTime, playingSequence.currentSpeed); y += 16.0f; @@ -755,23 +756,18 @@ void UiAnimationSystem::ShowPlayedSequencesDebug() { // Checks nodes which happen to be in several sequences. // Those can be a bug, since several sequences may try to control the same entity. - const char* name = playingSequence.sequence->GetNode(i)->GetName(); + AZStd::string name = playingSequence.sequence->GetNode(i)->GetName(); bool alreadyThere = false; - for (size_t k = 0; k < names.size(); ++k) + if (AZStd::find(names.begin(), names.end(), name) != names.end()) { - if (strcmp(names[k], name) == 0) - { - alreadyThere = true; - break; - } + alreadyThere = true; } - - if (alreadyThere == false) + else { names.push_back(name); } - gEnv->pRenderer->Draw2dLabel((21.0f + 100.0f * i), ((i % 2) ? (y + 8.0f) : y), 1.0f, alreadyThere ? white : purple, false, "%s", name); + //gEnv->pRenderer->Draw2dLabel((21.0f + 100.0f * i), ((i % 2) ? (y + 8.0f) : y), 1.0f, alreadyThere ? white : purple, false, "%s", name.c_str()); } y += 32.0f; diff --git a/Gems/LyShine/Code/Source/Animation/UiAnimationSystem.h b/Gems/LyShine/Code/Source/Animation/UiAnimationSystem.h index 8b2d6937ad..c1dbdcfcda 100644 --- a/Gems/LyShine/Code/Source/Animation/UiAnimationSystem.h +++ b/Gems/LyShine/Code/Source/Animation/UiAnimationSystem.h @@ -11,6 +11,7 @@ #include #include +#include struct PlayingUIAnimSequence { @@ -165,13 +166,13 @@ private: CTimeValue m_lastUpdateTime; - typedef AZStd::vector > Sequences; + using Sequences = AZStd::vector >; Sequences m_sequences; PlayingSequences m_playingSequences; - typedef std::vector TUiAnimationListenerVec; - typedef std::map TUiAnimationListenerMap; + using TUiAnimationListenerVec = AZStd::vector; + using TUiAnimationListenerMap = AZStd::map ; // a container which maps sequences to all interested listeners // listeners is a vector (could be a set in case we have a lot of listeners, stl::push_back_unique!) diff --git a/Gems/LyShine/Code/Source/LyShine.cpp b/Gems/LyShine/Code/Source/LyShine.cpp index a3beefe924..2cee4e92eb 100644 --- a/Gems/LyShine/Code/Source/LyShine.cpp +++ b/Gems/LyShine/Code/Source/LyShine.cpp @@ -124,10 +124,9 @@ AllocateConstIntCVar(CLyShine, CV_ui_RunUnitTestsOnStartup); #endif //////////////////////////////////////////////////////////////////////////////////////////////////// -CLyShine::CLyShine(ISystem* system) +CLyShine::CLyShine([[maybe_unused]] ISystem* system) : AzFramework::InputChannelEventListener(AzFramework::InputChannelEventListener::GetPriorityUI()) , AzFramework::InputTextEventListener(AzFramework::InputTextEventListener::GetPriorityUI()) - , m_system(system) , m_draw2d(new CDraw2d) , m_uiRenderer(new UiRenderer) , m_uiCanvasManager(new UiCanvasManager) diff --git a/Gems/LyShine/Code/Source/LyShine.h b/Gems/LyShine/Code/Source/LyShine.h index 19a4e664e5..065ad59f80 100644 --- a/Gems/LyShine/Code/Source/LyShine.h +++ b/Gems/LyShine/Code/Source/LyShine.h @@ -155,8 +155,6 @@ private: // static member functions private: // data - ISystem* m_system; // store a pointer to system rather than relying on env.pSystem - std::unique_ptr m_draw2d; // using a pointer rather than an instance to avoid including Draw2d.h std::unique_ptr m_uiRenderer; // using a pointer rather than an instance to avoid including UiRenderer.h AZStd::shared_ptr m_uiRendererForEditor; diff --git a/Gems/LyShine/Code/Source/LyShineLoadScreen.cpp b/Gems/LyShine/Code/Source/LyShineLoadScreen.cpp index 64a577efa2..279c0527bd 100644 --- a/Gems/LyShine/Code/Source/LyShineLoadScreen.cpp +++ b/Gems/LyShine/Code/Source/LyShineLoadScreen.cpp @@ -61,8 +61,11 @@ namespace LyShine { return false; } - - if (!gEnv || !gEnv->pRenderer || !gEnv->pLyShine) + //TODO: gEnv->pRenderer is always null, fix the logic below + AZ_ErrorOnce(nullptr, false, "NotifyGameLoadStart needs to be removed/ported to use Atom"); + return false; +#if 0 + if (!gEnv || gEnv->pRenderer || !gEnv->pLyShine) { return false; } @@ -87,6 +90,7 @@ namespace LyShine } return m_isPlaying; +#endif } bool LyShineLoadScreenComponent::NotifyLevelLoadStart(bool usingLoadingThread) @@ -97,7 +101,11 @@ namespace LyShine return false; } - if (!gEnv || !gEnv->pRenderer || !gEnv->pLyShine) + AZ_ErrorOnce(nullptr, false, "NotifyLevelLoadStart needs to be removed/ported to use Atom"); + return false; + //TODO: gEnv->pRenderer is always null, fix the logic below +#if 0 + if (!gEnv || gEnv->pRenderer || !gEnv->pLyShine) { return false; } @@ -123,6 +131,7 @@ namespace LyShine } return m_isPlaying; +#endif } void LyShineLoadScreenComponent::NotifyLoadEnd() @@ -130,10 +139,13 @@ namespace LyShine Reset(); } - void LyShineLoadScreenComponent::UpdateAndRender(float deltaTimeInSeconds) + void LyShineLoadScreenComponent::UpdateAndRender([[maybe_unused]] float deltaTimeInSeconds) { AZ_Assert(m_isPlaying, "LyShineLoadScreenComponent should not be connected to LoadScreenUpdateNotificationBus while not playing"); + AZ_ErrorOnce(nullptr, m_isPlaying && gEnv && gEnv->pLyShine, "UpdateAndRender needs to be removed/ported to use Atom"); + //TODO: gEnv->pRenderer is always null, fix the logic below +#if 0 if (m_isPlaying && gEnv && gEnv->pLyShine && gEnv->pRenderer) { AZ_Assert(GetCurrentThreadId() == gEnv->mMainThreadId, "UpdateAndRender should only be called from the main thread"); @@ -148,6 +160,7 @@ namespace LyShine gEnv->pLyShine->Render(); gEnv->pRenderer->EndFrame(); } +#endif } void LyShineLoadScreenComponent::LoadThreadUpdate([[maybe_unused]] float deltaTimeInSeconds) diff --git a/Gems/LyShine/Code/Source/LyShineSystemComponent.cpp b/Gems/LyShine/Code/Source/LyShineSystemComponent.cpp index f05cbc04d4..d3d2d5655e 100644 --- a/Gems/LyShine/Code/Source/LyShineSystemComponent.cpp +++ b/Gems/LyShine/Code/Source/LyShineSystemComponent.cpp @@ -342,8 +342,6 @@ namespace LyShine // Build a map of entity Ids to their parent Ids, for faster lookup during processing. for (AZ::Entity* exportParentEntity : exportSliceEntities) { - AZ::EntityId exportParentId = exportParentEntity->GetId(); - UiElementComponent* exportParentComponent = exportParentEntity->FindComponent(); if (!exportParentComponent) { diff --git a/Gems/LyShine/Code/Source/RenderGraph.cpp b/Gems/LyShine/Code/Source/RenderGraph.cpp index 51f62fc7ad..7ecda5eee3 100644 --- a/Gems/LyShine/Code/Source/RenderGraph.cpp +++ b/Gems/LyShine/Code/Source/RenderGraph.cpp @@ -21,9 +21,6 @@ namespace LyShine { - static const char* s_maskIncrProfileMarker = "UI_MASK_STENCIL_INCR"; - static const char* s_maskDecrProfileMarker = "UI_MASK_STENCIL_DECR"; - enum UiColorOp { ColorOp_Unused = 0, // reusing shader flag value, FixedPipelineEmu shader uses 0 to mean eCO_NOSET @@ -150,7 +147,7 @@ namespace LyShine // [LYSHINE_ATOM_TODO][ATOM-15073] - need to combine into a single DrawIndexed call to take advantage of the draw call // optimization done by this RenderGraph. This option will be added to DynamicDrawContext. For // now we could combine the vertices ourselves - for (const IRenderer::DynUiPrimitive& primitive : m_primitives) + for (const DynUiPrimitive& primitive : m_primitives) { dynamicDraw->DrawIndexed(primitive.m_vertices, primitive.m_numVertices, primitive.m_indices, primitive.m_numIndices, AZ::RHI::IndexFormat::Uint16, drawSrg); } @@ -159,7 +156,7 @@ namespace LyShine } //////////////////////////////////////////////////////////////////////////////////////////////////// - void PrimitiveListRenderNode::AddPrimitive(IRenderer::DynUiPrimitive* primitive) + void PrimitiveListRenderNode::AddPrimitive(DynUiPrimitive* primitive) { // always clear the next pointer before adding to list primitive->m_next = nullptr; @@ -170,9 +167,9 @@ namespace LyShine } //////////////////////////////////////////////////////////////////////////////////////////////////// - IRenderer::DynUiPrimitiveList& PrimitiveListRenderNode::GetPrimitives() const + DynUiPrimitiveList& PrimitiveListRenderNode::GetPrimitives() const { - return const_cast(m_primitives); + return const_cast(m_primitives); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -194,7 +191,7 @@ namespace LyShine } //////////////////////////////////////////////////////////////////////////////////////////////////// - bool PrimitiveListRenderNode::HasSpaceToAddPrimitive(IRenderer::DynUiPrimitive* primitive) const + bool PrimitiveListRenderNode::HasSpaceToAddPrimitive(DynUiPrimitive* primitive) const { return primitive->m_numVertices + m_totalNumVertices < std::numeric_limits::max(); } @@ -218,9 +215,9 @@ namespace LyShine { size_t numPrims = m_primitives.size(); size_t primCount = 0; - const IRenderer::DynUiPrimitive* lastPrim = nullptr; + const DynUiPrimitive* lastPrim = nullptr; int highestTexUnit = 0; - for (const IRenderer::DynUiPrimitive& primitive : m_primitives) + for (const DynUiPrimitive& primitive : m_primitives) { if (primCount > numPrims) { @@ -709,25 +706,8 @@ namespace LyShine } } - void RenderGraph::AddPrimitive( - IRenderer::DynUiPrimitive* primitive, - ITexture* texture, - bool isClampTextureMode, - bool isTextureSRGB, - bool isTexturePremultipliedAlpha, - BlendMode blendMode) - { - // LYSHINE_ATOM_TODO - this function will be removed when all IRenderer references are gone from UI components - AZ_UNUSED(primitive); - AZ_UNUSED(texture); - AZ_UNUSED(isClampTextureMode); - AZ_UNUSED(isTextureSRGB); - AZ_UNUSED(isTexturePremultipliedAlpha); - AZ_UNUSED(blendMode); - } - //////////////////////////////////////////////////////////////////////////////////////////////////// - void RenderGraph::AddPrimitiveAtom(IRenderer::DynUiPrimitive* primitive, const AZ::Data::Instance& texture, + void RenderGraph::AddPrimitiveAtom(DynUiPrimitive* primitive, const AZ::Data::Instance& texture, bool isClampTextureMode, bool isTextureSRGB, bool isTexturePremultipliedAlpha, BlendMode blendMode) { AZStd::vector* renderNodeList = m_renderNodeListStack.top(); @@ -800,15 +780,7 @@ namespace LyShine } //////////////////////////////////////////////////////////////////////////////////////////////////// - void RenderGraph::AddAlphaMaskPrimitive([[maybe_unused]] IRenderer::DynUiPrimitive* primitive, - [[maybe_unused]] ITexture* texture, [[maybe_unused]] ITexture* maskTexture, - [[maybe_unused]] bool isClampTextureMode, [[maybe_unused]] bool isTextureSRGB, [[maybe_unused]] bool isTexturePremultipliedAlpha, [[maybe_unused]] BlendMode blendMode) - { - // LYSHINE_ATOM_TODO - this function will be removed when all IRenderer references are gone from UI components - } - - //////////////////////////////////////////////////////////////////////////////////////////////////// - void RenderGraph::AddAlphaMaskPrimitiveAtom(IRenderer::DynUiPrimitive* primitive, + void RenderGraph::AddAlphaMaskPrimitiveAtom(DynUiPrimitive* primitive, AZ::Data::Instance contentAttachmentImage, AZ::Data::Instance maskAttachmentImage, bool isClampTextureMode, @@ -892,7 +864,7 @@ namespace LyShine } //////////////////////////////////////////////////////////////////////////////////////////////////// - IRenderer::DynUiPrimitive* RenderGraph::GetDynamicQuadPrimitive(const AZ::Vector2* positions, uint32 packedColor) + DynUiPrimitive* RenderGraph::GetDynamicQuadPrimitive(const AZ::Vector2* positions, uint32 packedColor) { const int numVertsInQuad = 4; const int numIndicesInQuad = 6; @@ -1181,10 +1153,10 @@ namespace LyShine const PrimitiveListRenderNode* primListRenderNode = static_cast(renderNode); - IRenderer::DynUiPrimitiveList& primitives = primListRenderNode->GetPrimitives(); + DynUiPrimitiveList& primitives = primListRenderNode->GetPrimitives(); info.m_numPrimitives += static_cast(primitives.size()); { - for (const IRenderer::DynUiPrimitive& primitive : primitives) + for (const DynUiPrimitive& primitive : primitives) { info.m_numTriangles += primitive.m_numIndices / 3; } @@ -1365,10 +1337,10 @@ namespace LyShine previousNodeAlreadyCounted = false; } - IRenderer::DynUiPrimitiveList& primitives = primListRenderNode->GetPrimitives(); + DynUiPrimitiveList& primitives = primListRenderNode->GetPrimitives(); int numPrimitives = static_cast(primitives.size()); int numTriangles = 0; - for (const IRenderer::DynUiPrimitive& primitive : primitives) + for (const DynUiPrimitive& primitive : primitives) { numTriangles += primitive.m_numIndices / 3; } diff --git a/Gems/LyShine/Code/Source/RenderGraph.h b/Gems/LyShine/Code/Source/RenderGraph.h index bc5bd094c8..a7ef0919c6 100644 --- a/Gems/LyShine/Code/Source/RenderGraph.h +++ b/Gems/LyShine/Code/Source/RenderGraph.h @@ -79,8 +79,8 @@ namespace LyShine , const AZ::Matrix4x4& modelViewProjMat , AZ::RHI::Ptr dynamicDraw) override; - void AddPrimitive(IRenderer::DynUiPrimitive* primitive); - IRenderer::DynUiPrimitiveList& GetPrimitives() const; + void AddPrimitive(DynUiPrimitive* primitive); + DynUiPrimitiveList& GetPrimitives() const; int GetOrAddTexture(const AZ::Data::Instance& texture, bool isClampTextureMode); int GetNumTextures() const { return m_numTextures; } @@ -92,7 +92,7 @@ namespace LyShine bool GetIsPremultiplyAlpha() const { return m_preMultiplyAlpha; } AlphaMaskType GetAlphaMaskType() const { return m_alphaMaskType; } - bool HasSpaceToAddPrimitive(IRenderer::DynUiPrimitive* primitive) const; + bool HasSpaceToAddPrimitive(DynUiPrimitive* primitive) const; // Search to see if this texture is already used by this texture unit, returns -1 if not used int FindTexture(const AZ::Data::Instance& texture, bool isClampTextureMode) const; @@ -122,7 +122,7 @@ namespace LyShine int m_totalNumVertices; int m_totalNumIndices; - IRenderer::DynUiPrimitiveList m_primitives; + DynUiPrimitiveList m_primitives; }; // A mask render node handles using one set of render nodes to mask another set of render nodes @@ -268,14 +268,7 @@ namespace LyShine void EndRenderToTexture() override; - void AddPrimitive(IRenderer::DynUiPrimitive* primitive, ITexture* texture, - bool isClampTextureMode, bool isTextureSRGB, bool isTexturePremultipliedAlpha, BlendMode blendMode) override; - - void AddAlphaMaskPrimitive(IRenderer::DynUiPrimitive* primitive, - ITexture* texture, ITexture* maskTexture, - bool isClampTextureMode, bool isTextureSRGB, bool isTexturePremultipliedAlpha, BlendMode blendMode) override; - - IRenderer::DynUiPrimitive* GetDynamicQuadPrimitive(const AZ::Vector2* positions, uint32 packedColor) override; + DynUiPrimitive* GetDynamicQuadPrimitive(const AZ::Vector2* positions, uint32 packedColor) override; bool IsRenderingToMask() const override; void SetIsRenderingToMask(bool isRenderingToMask) override; @@ -287,11 +280,11 @@ namespace LyShine // ~IRenderGraph // LYSHINE_ATOM_TODO - this can be renamed back to AddPrimitive after removal of IRenderer from all UI components - void AddPrimitiveAtom(IRenderer::DynUiPrimitive* primitive, const AZ::Data::Instance& texture, + void AddPrimitiveAtom(DynUiPrimitive* primitive, const AZ::Data::Instance& texture, bool isClampTextureMode, bool isTextureSRGB, bool isTexturePremultipliedAlpha, BlendMode blendMode); //! Add an indexed triangle list primitive to the render graph which will use maskTexture as an alpha (gradient) mask - void AddAlphaMaskPrimitiveAtom(IRenderer::DynUiPrimitive* primitive, + void AddAlphaMaskPrimitiveAtom(DynUiPrimitive* primitive, AZ::Data::Instance contentAttachmentImage, AZ::Data::Instance maskAttachmentImage, bool isClampTextureMode, @@ -341,7 +334,7 @@ namespace LyShine struct DynamicQuad { SVF_P2F_C4B_T2F_F4B m_quadVerts[4]; - IRenderer::DynUiPrimitive m_primitive; + DynUiPrimitive m_primitive; }; protected: // member functions diff --git a/Gems/LyShine/Code/Source/Sprite.cpp b/Gems/LyShine/Code/Source/Sprite.cpp index 7f293e57a3..5c7adae481 100644 --- a/Gems/LyShine/Code/Source/Sprite.cpp +++ b/Gems/LyShine/Code/Source/Sprite.cpp @@ -509,20 +509,16 @@ ISprite::Borders CSprite::GetTextureSpaceCellUvBorders(int cellIndex) const if (CellIndexWithinRange(cellIndex)) { const float cellWidth = GetCellUvSize(cellIndex).GetX(); - const float cellMinUCoord = GetCellUvCoords(cellIndex).TopLeft().GetX(); const float cellNormalizedLeftBorder = GetCellUvBorders(cellIndex).m_left * cellWidth; textureSpaceBorders.m_left = cellNormalizedLeftBorder; - const float cellMaxUCoord = GetCellUvCoords(cellIndex).TopRight().GetX(); const float cellNormalizedRightBorder = GetCellUvBorders(cellIndex).m_right * cellWidth; textureSpaceBorders.m_right = cellNormalizedRightBorder; const float cellHeight = GetCellUvSize(cellIndex).GetY(); - const float cellMinVCoord = GetCellUvCoords(cellIndex).TopLeft().GetY(); const float cellNormalizedTopBorder = GetCellUvBorders(cellIndex).m_top * cellHeight; textureSpaceBorders.m_top = cellNormalizedTopBorder; - const float cellMaxVCoord = GetCellUvCoords(cellIndex).BottomLeft().GetY(); const float cellNormalizedBottomBorder = GetCellUvBorders(cellIndex).m_bottom * cellHeight; textureSpaceBorders.m_bottom = cellNormalizedBottomBorder; } diff --git a/Gems/LyShine/Code/Source/Tests/internal/test_UiTransform2dComponent.cpp b/Gems/LyShine/Code/Source/Tests/internal/test_UiTransform2dComponent.cpp index 89b88cd8f6..bea66101fa 100644 --- a/Gems/LyShine/Code/Source/Tests/internal/test_UiTransform2dComponent.cpp +++ b/Gems/LyShine/Code/Source/Tests/internal/test_UiTransform2dComponent.cpp @@ -904,7 +904,6 @@ namespace AZ::EntityId testElemId = CreateElementWithTransform2dComponent(canvas, "UiTransfrom2DTestElement:Offsets"); - AZ::Vector2 parentSize(canvas->GetCanvasSize()); UiTransform2dInterface::Offsets expectedOffsets(-50, -50, 50, 50); UiTransform2dInterface::Offsets actualOffsets; @@ -971,7 +970,6 @@ namespace AZ::EntityId testElemId = CreateElementWithTransform2dComponent(canvas, "UiTransfrom2DTestElement:LocalSize"); - AZ::Vector2 parentSize(canvas->GetCanvasSize()); float expectedWidth = 100; float actualWidth = 1; float expectedHeight = 100; diff --git a/Gems/LyShine/Code/Source/UiCanvasComponent.cpp b/Gems/LyShine/Code/Source/UiCanvasComponent.cpp index 9d17f90f0b..4b5f072966 100644 --- a/Gems/LyShine/Code/Source/UiCanvasComponent.cpp +++ b/Gems/LyShine/Code/Source/UiCanvasComponent.cpp @@ -3637,9 +3637,13 @@ void UiCanvasComponent::DestroyRenderTarget() if (m_renderTargetHandle > 0) { ISystem::CrySystemNotificationBus::Handler::BusDisconnect(); +#ifdef LYSHINE_ATOM_TODO // [LYN-3359] Support RTT using Atom gEnv->pRenderer->DestroyDepthSurface(m_renderTargetDepthSurface); +#endif m_renderTargetDepthSurface = nullptr; +#ifdef LYSHINE_ATOM_TODO // [LYN-3359] Support RTT using Atom gEnv->pRenderer->DestroyRenderTarget(m_renderTargetHandle); +#endif m_renderTargetHandle = -1; } } diff --git a/Gems/LyShine/Code/Source/UiCanvasManager.cpp b/Gems/LyShine/Code/Source/UiCanvasManager.cpp index d13a8f5034..04cb5c4a1f 100644 --- a/Gems/LyShine/Code/Source/UiCanvasManager.cpp +++ b/Gems/LyShine/Code/Source/UiCanvasManager.cpp @@ -13,6 +13,7 @@ #include "UiGameEntityContext.h" #include +#include #include #include diff --git a/Gems/LyShine/Code/Source/UiElementComponent.cpp b/Gems/LyShine/Code/Source/UiElementComponent.cpp index d06b87cf6a..0aa57e4041 100644 --- a/Gems/LyShine/Code/Source/UiElementComponent.cpp +++ b/Gems/LyShine/Code/Source/UiElementComponent.cpp @@ -27,6 +27,8 @@ #include #include +#include + #include "UiTransform2dComponent.h" #include "IConsole.h" diff --git a/Gems/LyShine/Code/Source/UiFaderComponent.cpp b/Gems/LyShine/Code/Source/UiFaderComponent.cpp index e7eca04c59..d9309a7505 100644 --- a/Gems/LyShine/Code/Source/UiFaderComponent.cpp +++ b/Gems/LyShine/Code/Source/UiFaderComponent.cpp @@ -575,7 +575,7 @@ void UiFaderComponent::RenderRttFader(LyShine::IRenderGraph* renderGraph, UiElem AZ::Color clearColor(0.0f, 0.0f, 0.0f, 0.0f); // Start building the render to texture node in the render graph - LyShine::RenderGraph* lyRenderGraph = dynamic_cast(renderGraph); + LyShine::RenderGraph* lyRenderGraph = static_cast(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570 lyRenderGraph->BeginRenderToTexture(attachmentImage, m_viewportTopLeft, m_viewportSize, clearColor); // We don't want this fader or parent faders to affect what is rendered to the render target since we will @@ -615,7 +615,7 @@ void UiFaderComponent::RenderRttFader(LyShine::IRenderGraph* renderGraph, UiElem // Add a primitive to render a quad using the render target we have created { - LyShine::RenderGraph* lyRenderGraph = dynamic_cast(renderGraph); + LyShine::RenderGraph* lyRenderGraph = static_cast(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570 if (lyRenderGraph) { // Set the texture and other render state required diff --git a/Gems/LyShine/Code/Source/UiFaderComponent.h b/Gems/LyShine/Code/Source/UiFaderComponent.h index 560c1beaaa..218eab3794 100644 --- a/Gems/LyShine/Code/Source/UiFaderComponent.h +++ b/Gems/LyShine/Code/Source/UiFaderComponent.h @@ -169,5 +169,5 @@ private: // data int m_renderTargetHeight = 0; //! cached rendering data for performance optimization of rendering the render target to screen - IRenderer::DynUiPrimitive m_cachedPrimitive; + DynUiPrimitive m_cachedPrimitive; }; diff --git a/Gems/LyShine/Code/Source/UiImageComponent.cpp b/Gems/LyShine/Code/Source/UiImageComponent.cpp index d279beeee9..fac8a83c71 100644 --- a/Gems/LyShine/Code/Source/UiImageComponent.cpp +++ b/Gems/LyShine/Code/Source/UiImageComponent.cpp @@ -280,7 +280,7 @@ namespace AZ::Data::Instance image; if (sprite) { - CSprite* cSprite = dynamic_cast(sprite); // LYSHINE_ATOM_TODO - find a different solution from downcasting + CSprite* cSprite = static_cast(sprite); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570 if (cSprite) { image = cSprite->GetImage(); @@ -484,7 +484,7 @@ void UiImageComponent::Render(LyShine::IRenderGraph* renderGraph) bool isTextureSRGB = IsSpriteTypeRenderTarget() && m_isRenderTargetSRGB; bool isTexturePremultipliedAlpha = false; // we are not rendering from a render target with alpha in it - LyShine::RenderGraph* lyRenderGraph = dynamic_cast(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting + LyShine::RenderGraph* lyRenderGraph = static_cast(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570 if (lyRenderGraph) { lyRenderGraph->AddPrimitiveAtom(&m_cachedPrimitive, image, isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, m_blendMode); @@ -1536,7 +1536,6 @@ void UiImageComponent::RenderSingleQuad(const AZ::Vector2* positions, const AZ:: IDraw2d::Rounding pixelRounding = IsPixelAligned() ? IDraw2d::Rounding::Nearest : IDraw2d::Rounding::None; const uint32 numVertices = 4; SVF_P2F_C4B_T2F_F4B vertices[numVertices]; - const float z = 1.0f; // depth test disabled, if writing Z this will write at far plane for (int i = 0; i < numVertices; ++i) { AZ::Vector2 roundedPoint = Draw2dHelper::RoundXY(positions[i], pixelRounding); @@ -1596,7 +1595,6 @@ void UiImageComponent::RenderLinearFilledQuad(const AZ::Vector2* positions, cons IDraw2d::Rounding pixelRounding = IsPixelAligned() ? IDraw2d::Rounding::Nearest : IDraw2d::Rounding::None; const uint32 numVertices = 4; SVF_P2F_C4B_T2F_F4B vertices[numVertices]; - const float z = 1.0f; // depth test disabled, if writing Z this will write at far plane for (int i = 0; i < numVertices; ++i) { diff --git a/Gems/LyShine/Code/Source/UiImageComponent.h b/Gems/LyShine/Code/Source/UiImageComponent.h index 4cffbc4b88..0b93d5f8e5 100644 --- a/Gems/LyShine/Code/Source/UiImageComponent.h +++ b/Gems/LyShine/Code/Source/UiImageComponent.h @@ -294,6 +294,6 @@ private: // data bool m_isAlphaOverridden; // cached rendering data for performance optimization - IRenderer::DynUiPrimitive m_cachedPrimitive; + DynUiPrimitive m_cachedPrimitive; bool m_isRenderCacheDirty = true; }; diff --git a/Gems/LyShine/Code/Source/UiImageSequenceComponent.cpp b/Gems/LyShine/Code/Source/UiImageSequenceComponent.cpp index 086aed9f58..d954cf2747 100644 --- a/Gems/LyShine/Code/Source/UiImageSequenceComponent.cpp +++ b/Gems/LyShine/Code/Source/UiImageSequenceComponent.cpp @@ -97,7 +97,7 @@ void UiImageSequenceComponent::Render(LyShine::IRenderGraph* renderGraph) return; } - CSprite* sprite = dynamic_cast(m_spriteList[m_sequenceIndex]); + CSprite* sprite = static_cast(m_spriteList[m_sequenceIndex]); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570 // get fade value (tracked by UiRenderer) and compute the desired alpha for the image float fade = renderGraph->GetAlphaFade(); @@ -105,7 +105,6 @@ void UiImageSequenceComponent::Render(LyShine::IRenderGraph* renderGraph) if (m_isRenderCacheDirty) { - const int defaultIndex = 0; uint32 packedColor = 0xffffffff; switch (m_imageType) { @@ -166,7 +165,7 @@ void UiImageSequenceComponent::Render(LyShine::IRenderGraph* renderGraph) LyShine::BlendMode blendMode = LyShine::BlendMode::Normal; // Add the quad to the render graph - LyShine::RenderGraph* lyRenderGraph = dynamic_cast(renderGraph); + LyShine::RenderGraph* lyRenderGraph = static_cast(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570 if (lyRenderGraph) { lyRenderGraph->AddPrimitiveAtom(&m_cachedPrimitive, image, @@ -542,7 +541,6 @@ void UiImageSequenceComponent::RenderSingleQuad(const AZ::Vector2* positions, co IDraw2d::Rounding pixelRounding = IsPixelAligned() ? IDraw2d::Rounding::Nearest : IDraw2d::Rounding::None; const uint32 numVertices = 4; SVF_P2F_C4B_T2F_F4B vertices[numVertices]; - const float z = 1.0f; // depth test disabled, if writing Z this will write at far plane for (int i = 0; i < numVertices; ++i) { AZ::Vector2 roundedPoint = Draw2dHelper::RoundXY(positions[i], pixelRounding); diff --git a/Gems/LyShine/Code/Source/UiImageSequenceComponent.h b/Gems/LyShine/Code/Source/UiImageSequenceComponent.h index fb8087f525..84be0021f4 100644 --- a/Gems/LyShine/Code/Source/UiImageSequenceComponent.h +++ b/Gems/LyShine/Code/Source/UiImageSequenceComponent.h @@ -157,6 +157,6 @@ private: // data ImageType m_imageType = ImageType::Fixed; //!< Affects how the texture/sprite is mapped to the image rectangle // cached rendering data for performance optimization - IRenderer::DynUiPrimitive m_cachedPrimitive; + DynUiPrimitive m_cachedPrimitive; bool m_isRenderCacheDirty = true; }; diff --git a/Gems/LyShine/Code/Source/UiMaskComponent.cpp b/Gems/LyShine/Code/Source/UiMaskComponent.cpp index d6ed468deb..b6ffc2ae89 100644 --- a/Gems/LyShine/Code/Source/UiMaskComponent.cpp +++ b/Gems/LyShine/Code/Source/UiMaskComponent.cpp @@ -722,7 +722,7 @@ void UiMaskComponent::RenderUsingGradientMask(LyShine::IRenderGraph* renderGraph // mask render target { // Start building the render to texture node in the render graph - LyShine::RenderGraph* lyRenderGraph = dynamic_cast(renderGraph); + LyShine::RenderGraph* lyRenderGraph = static_cast(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570 lyRenderGraph->BeginRenderToTexture(maskAttachmentImage, m_viewportTopLeft, m_viewportSize, clearColor); // Render the visual component for this element (if there is one) plus the child mask element (if there is one) @@ -735,7 +735,7 @@ void UiMaskComponent::RenderUsingGradientMask(LyShine::IRenderGraph* renderGraph // content render target { // Start building the render to texture node for the content render target in the render graph - LyShine::RenderGraph* lyRenderGraph = dynamic_cast(renderGraph); + LyShine::RenderGraph* lyRenderGraph = static_cast(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570 lyRenderGraph->BeginRenderToTexture(contentAttachmentImage, m_viewportTopLeft, m_viewportSize, clearColor); // Render the "content" - the child elements excluding the child mask element (if any) @@ -772,7 +772,7 @@ void UiMaskComponent::RenderUsingGradientMask(LyShine::IRenderGraph* renderGraph // Add a primitive to do the alpha mask { - LyShine::RenderGraph* lyRenderGraph = dynamic_cast(renderGraph); + LyShine::RenderGraph* lyRenderGraph = static_cast(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570 if (lyRenderGraph) { // Set the texture and other render state required diff --git a/Gems/LyShine/Code/Source/UiMaskComponent.h b/Gems/LyShine/Code/Source/UiMaskComponent.h index 8635f048f5..8e04fa0b4f 100644 --- a/Gems/LyShine/Code/Source/UiMaskComponent.h +++ b/Gems/LyShine/Code/Source/UiMaskComponent.h @@ -205,7 +205,7 @@ private: // data int m_renderTargetHeight = 0; //! cached rendering data for performance optimization of rendering the render target to screen - IRenderer::DynUiPrimitive m_cachedPrimitive; + DynUiPrimitive m_cachedPrimitive; #ifndef _RELEASE //! This variable is only used to prevent spamming a warning message each frame (for nested stencil masks) diff --git a/Gems/LyShine/Code/Source/UiParticleEmitterComponent.cpp b/Gems/LyShine/Code/Source/UiParticleEmitterComponent.cpp index 0adf2fb2de..c6fd144d3a 100644 --- a/Gems/LyShine/Code/Source/UiParticleEmitterComponent.cpp +++ b/Gems/LyShine/Code/Source/UiParticleEmitterComponent.cpp @@ -785,7 +785,7 @@ void UiParticleEmitterComponent::Render(LyShine::IRenderGraph* renderGraph) AZ::Data::Instance image; if (m_sprite) { - CSprite* sprite = dynamic_cast(m_sprite); + CSprite* sprite = static_cast(m_sprite); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570 if (sprite) { image = sprite->GetImage(); @@ -843,7 +843,7 @@ void UiParticleEmitterComponent::Render(LyShine::IRenderGraph* renderGraph) m_cachedPrimitive.m_numVertices = totalVerticesInserted; m_cachedPrimitive.m_numIndices = totalParticlesInserted * indicesPerParticle; - LyShine::RenderGraph* lyRenderGraph = dynamic_cast(renderGraph); + LyShine::RenderGraph* lyRenderGraph = static_cast(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570 if (lyRenderGraph) { lyRenderGraph->AddPrimitiveAtom(&m_cachedPrimitive, image, isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, m_blendMode); diff --git a/Gems/LyShine/Code/Source/UiParticleEmitterComponent.h b/Gems/LyShine/Code/Source/UiParticleEmitterComponent.h index cb8152265d..452e0ad01a 100644 --- a/Gems/LyShine/Code/Source/UiParticleEmitterComponent.h +++ b/Gems/LyShine/Code/Source/UiParticleEmitterComponent.h @@ -349,5 +349,5 @@ protected: // data AZStd::vector m_particleContainer; AZ::u32 m_particleBufferSize = 0; - IRenderer::DynUiPrimitive m_cachedPrimitive; + DynUiPrimitive m_cachedPrimitive; }; diff --git a/Gems/LyShine/Code/Source/UiRenderer.cpp b/Gems/LyShine/Code/Source/UiRenderer.cpp index c52c249d20..07a9f77007 100644 --- a/Gems/LyShine/Code/Source/UiRenderer.cpp +++ b/Gems/LyShine/Code/Source/UiRenderer.cpp @@ -313,8 +313,6 @@ AZ::Vector2 UiRenderer::GetViewportSize() auto windowContext = viewportContext->GetWindowContext(); const AZ::RHI::Viewport& viewport = windowContext->GetViewport(); - const float viewX = viewport.m_minX; - const float viewY = viewport.m_minY; const float viewWidth = viewport.m_maxX - viewport.m_minX; const float viewHeight = viewport.m_maxY - viewport.m_minY; return AZ::Vector2(viewWidth, viewHeight); diff --git a/Gems/LyShine/Code/Source/UiScrollBoxComponent.cpp b/Gems/LyShine/Code/Source/UiScrollBoxComponent.cpp index 88317b840f..8b634b32fb 100644 --- a/Gems/LyShine/Code/Source/UiScrollBoxComponent.cpp +++ b/Gems/LyShine/Code/Source/UiScrollBoxComponent.cpp @@ -1500,7 +1500,6 @@ AZ::Vector2 UiScrollBoxComponent::ConstrainOffset(AZ::Vector2 proposedOffset, AZ // add the requested scroll offset to the content rect to get the proposed position // The content has already need moved by the requested offset all but latestOffsetDelta - UiTransformInterface::Rect origContentRect = contentRect; contentRect.MoveBy(latestOffsetDelta); if (contentRect.GetWidth() <= parentRect.GetWidth()) diff --git a/Gems/LyShine/Code/Source/UiTextComponent.cpp b/Gems/LyShine/Code/Source/UiTextComponent.cpp index f9544a9954..1c8189fa2a 100644 --- a/Gems/LyShine/Code/Source/UiTextComponent.cpp +++ b/Gems/LyShine/Code/Source/UiTextComponent.cpp @@ -1827,10 +1827,10 @@ void UiTextComponent::Render(LyShine::IRenderGraph* renderGraph) for (UiTransformInterface::RectPoints& rect : rectPoints) { - IRenderer::DynUiPrimitive* primitive = renderGraph->GetDynamicQuadPrimitive(rect.pt, packedColor); + DynUiPrimitive* primitive = renderGraph->GetDynamicQuadPrimitive(rect.pt, packedColor); primitive->m_next = nullptr; - LyShine::RenderGraph* lyRenderGraph = dynamic_cast(renderGraph); + LyShine::RenderGraph* lyRenderGraph = static_cast(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570 if (lyRenderGraph) { lyRenderGraph->AddPrimitiveAtom(primitive, systemImage, isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, blendMode); @@ -1856,7 +1856,7 @@ void UiTextComponent::Render(LyShine::IRenderGraph* renderGraph) } bool isClampTextureMode = true; - LyShine::RenderGraph* lyRenderGraph = dynamic_cast(renderGraph); + LyShine::RenderGraph* lyRenderGraph = static_cast(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570 if (lyRenderGraph) { lyRenderGraph->AddPrimitiveAtom(&batch->m_cachedPrimitive, texture, @@ -1871,7 +1871,7 @@ void UiTextComponent::Render(LyShine::IRenderGraph* renderGraph) for (RenderCacheBatch* batch : m_renderCache.m_batches) { - AZ::FFont* font = static_cast(batch->m_font); // LYSHINE_ATOM_TODO - find a different solution from downcasting FFont to IFont + AZ::FFont* font = static_cast(batch->m_font); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570 AZ::Data::Instance fontImage = font->GetFontImage(); if (fontImage) { @@ -1894,7 +1894,7 @@ void UiTextComponent::Render(LyShine::IRenderGraph* renderGraph) // because there is no padding on the left of the glyphs. bool isClampTextureMode = false; - LyShine::RenderGraph* lyRenderGraph = static_cast(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting + LyShine::RenderGraph* lyRenderGraph = static_cast(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570 if (lyRenderGraph) { lyRenderGraph->AddPrimitiveAtom(&batch->m_cachedPrimitive, fontImage, @@ -2662,8 +2662,6 @@ void UiTextComponent::GetClickableTextRects(UiClickableTextInterface::ClickableT AZ::Vector2 pos = CalculateAlignedPositionWithYOffset(points); const DrawBatchLines& drawBatchLines = GetDrawBatchLines(); - int requestFontSize = GetRequestFontSize(); - STextDrawContext fontContext(GetTextDrawContextPrototype(requestFontSize, drawBatchLines.fontSizeScale)); float newlinePosYIncrement = 0.0f; for (auto& drawBatchLine : drawBatchLines.batchLines) @@ -3344,7 +3342,6 @@ void UiTextComponent::GetTextRect(UiTransformInterface::RectPoints& rect, const // get the "no scale rotate" element box UiTransformInterface::RectPoints elemRect; EBUS_EVENT_ID(GetEntityId(), UiTransformBus, GetCanvasSpacePointsNoScaleRotate, elemRect); - AZ::Vector2 elemSize = elemRect.GetAxisAlignedSize(); // given the text alignment work out the box of the actual text rect = elemRect; diff --git a/Gems/LyShine/Code/Source/UiTextComponent.h b/Gems/LyShine/Code/Source/UiTextComponent.h index 600f0dc148..cc1f9bf393 100644 --- a/Gems/LyShine/Code/Source/UiTextComponent.h +++ b/Gems/LyShine/Code/Source/UiTextComponent.h @@ -153,8 +153,8 @@ public: //types InlineImage* image = nullptr; - AZ::Vector2 size; //!< The size in pixels of the batch content - + AZ::Vector2 size; //!< The size in pixels of the batch content + float yOffset; //!< While calculating, the yOffset is set to the offset from the text draw y position. //!< Once all batches in the line are calculated, the yOffset will become the offset //!< from the y draw position of the batch line @@ -475,7 +475,7 @@ protected: // member functions //! Handles overflow and shrink-to-text settings to text void HandleOverflowText(UiTextComponent::DrawBatchLines& drawBatchLinesOut); - //! Handles shrink-to-fit for text, if applicable. + //! Handles shrink-to-fit for text, if applicable. void HandleShrinkToFit(UiTextComponent::DrawBatchLines& drawBatchLinesOut, float availableHeight = -1.0f); //! Handles the "uniform" shrink-to-fit setting. @@ -506,18 +506,18 @@ protected: // member functions void GetDrawBatchStartPositions(DrawBatchStartPositions& startPositions, DrawBatchLine* lineToEllipsis, const AZ::Vector2& currentElementSize); //! Returns the draw batch that will have ellipsis inserted, along with required position information to do so. - DrawBatch* GetDrawBatchToEllipseAndPositions(const char* ellipseText, - const STextDrawContext& ctx, - const AZ::Vector2& currentElementSize, + DrawBatch* GetDrawBatchToEllipseAndPositions(const char* ellipseText, + const STextDrawContext& ctx, + const AZ::Vector2& currentElementSize, DrawBatchStartPositions* startPositions, - float* drawBatchStartPos, + float* drawBatchStartPos, float* ellipsisPos); //! Removes all draw batches following the given DrawBatch on the given DrawBatchLine. void TruncateDrawBatches(DrawBatchLine* lineToTruncate, const DrawBatch* truncateAfterBatch); //! Given a draw batch, get the character index where ellipsis should be inserted in the string. - int GetStartEllipseIndexInDrawBatch(const DrawBatch* drawBatchToEllipse, + int GetStartEllipseIndexInDrawBatch(const DrawBatch* drawBatchToEllipse, const STextDrawContext& ctx, const float drawBatchStartPos, const float ellipsePos); @@ -546,7 +546,7 @@ protected: // member functions //! Given rect points and number of lines of text to display, returns the position to display text. //! //! The number of lines of text determines the Y offset of the first line to display. For - //! top-aligned text, this offset will be zero (regardless of the number of lines of text) + //! top-aligned text, this offset will be zero (regardless of the number of lines of text) //! because the first line to display will always be displayed at the top of the rect, while //! bottom-aligned text will be offset by the number of lines to display, and vertically //! centered text will be offset by half of that amount. @@ -608,13 +608,13 @@ private: // types ColorB m_color; IFFont* m_font; uint32 m_fontTextureVersion; - IRenderer::DynUiPrimitive m_cachedPrimitive; + DynUiPrimitive m_cachedPrimitive; }; struct RenderCacheImageBatch { AZ::Data::Instance m_texture; - IRenderer::DynUiPrimitive m_cachedPrimitive; + DynUiPrimitive m_cachedPrimitive; }; struct RenderCacheData @@ -642,11 +642,11 @@ private: // data //!< font size. In GetTextDrawContextPrototype, this value ultimately gets converted to pixels and //!< stored in STextDrawContext::m_tracking. This value and STextDrawContext::m_tracking aren't //!< necessarily 1:1, just as m_fontSize and STextDrawContext::m_size aren't necessarily 1:1. - //!< Although the component values of m_charSpacing and m_fontSize are unaffected by scaling, - //!< scaling (such as scaling performed by shrink-to-fit overflow handling) is applied to these + //!< Although the component values of m_charSpacing and m_fontSize are unaffected by scaling, + //!< scaling (such as scaling performed by shrink-to-fit overflow handling) is applied to these //!< values and the resulting scaled value is stored in STextDrawContext for rendering. As a result, //!< it's possible for the value of m_charSpacing to never change, but STextDrawContext::m_tracking - //!< can vary in value independently of m_charSpacing as the font size (and/or scaled font size) + //!< can vary in value independently of m_charSpacing as the font size (and/or scaled font size) //!< changes over time. See also DrawBatchLines::fontSizeScale. float m_lineSpacing; diff --git a/Gems/LyShine/Code/Source/UiTextInputComponent.cpp b/Gems/LyShine/Code/Source/UiTextInputComponent.cpp index df2d85eb74..e789301572 100644 --- a/Gems/LyShine/Code/Source/UiTextInputComponent.cpp +++ b/Gems/LyShine/Code/Source/UiTextInputComponent.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -27,6 +28,7 @@ #include #include + #include "UiNavigationHelpers.h" #include "UiSerialize.h" #include "Sprite.h" diff --git a/Gems/LyShine/Code/Source/UiTransform2dComponent.cpp b/Gems/LyShine/Code/Source/UiTransform2dComponent.cpp index 48b2c2a8c4..40839fac66 100644 --- a/Gems/LyShine/Code/Source/UiTransform2dComponent.cpp +++ b/Gems/LyShine/Code/Source/UiTransform2dComponent.cpp @@ -23,6 +23,9 @@ #include "UiElementComponent.h" #include "UiCanvasComponent.h" +#include +#include + namespace { bool AxisAlignedBoxesIntersect(const AZ::Vector2& minA, const AZ::Vector2& maxA, const AZ::Vector2& minB, const AZ::Vector2& maxB) @@ -273,7 +276,7 @@ AZ::Vector2 UiTransform2dComponent::GetViewportSpacePivot() AZ::Matrix4x4 transform; parentTransformComponent->GetTransformToViewport(transform); - point3 = transform * point3; + point3 = transform * point3; } return AZ::Vector2(point3.GetX(), point3.GetY()); @@ -1454,7 +1457,7 @@ AZ::EntityId UiTransform2dComponent::GetAncestorWithSameDimensionScaleToDevice(S LyShine::EntityArray UiTransform2dComponent::GetDescendantsWithSameDimensionScaleToDevice(ScaleToDeviceMode scaleToDeviceMode) const { // Check if any descendants have their scale to device mode set in the same dimension - auto HasSameDimensionScaleToDevice = [this, scaleToDeviceMode](const AZ::Entity* entity) + auto HasSameDimensionScaleToDevice = [scaleToDeviceMode](const AZ::Entity* entity) { ScaleToDeviceMode descendantScaleToDeviceMode = ScaleToDeviceMode::None; EBUS_EVENT_ID_RESULT(descendantScaleToDeviceMode, entity->GetId(), UiTransformBus, GetScaleToDeviceMode); diff --git a/Gems/LyShine/Code/Source/World/UiCanvasOnMeshComponent.cpp b/Gems/LyShine/Code/Source/World/UiCanvasOnMeshComponent.cpp index 81a68a5a9e..395e0dfc32 100644 --- a/Gems/LyShine/Code/Source/World/UiCanvasOnMeshComponent.cpp +++ b/Gems/LyShine/Code/Source/World/UiCanvasOnMeshComponent.cpp @@ -101,190 +101,6 @@ namespace } #endif - //////////////////////////////////////////////////////////////////////////////////////////////////// - bool GetBarycentricCoordinates(const Vec3& a, const Vec3& b, const Vec3& c, const Vec3& p, float& u, float& v, float& w, float fBorder) - { - // Compute vectors - Vec3 v0 = b - a; - Vec3 v1 = c - a; - Vec3 v2 = p - a; - - // Compute dot products - float dot00 = v0.Dot(v0); - float dot01 = v0.Dot(v1); - float dot02 = v0.Dot(v2); - float dot11 = v1.Dot(v1); - float dot12 = v1.Dot(v2); - - // Compute barycentric coordinates - float invDenom = 1.f / (dot00 * dot11 - dot01 * dot01); - v = (dot11 * dot02 - dot01 * dot12) * invDenom; - w = (dot00 * dot12 - dot01 * dot02) * invDenom; - u = 1.f - v - w; - - // Check if point is in triangle - return (u >= -fBorder) && (v >= -fBorder) && (w >= -fBorder); - } - - //////////////////////////////////////////////////////////////////////////////////////////////////// - bool SnapToPlaneAndGetBarycentricCoordinates(const Vec3& a, const Vec3& b, const Vec3& c, const Vec3& p, float& u, float& v, float& w) - { - // get face normal - Vec3 uVec = b - a; - Vec3 vVec = c - a; - Vec3 faceNormal = uVec.cross(vVec); - faceNormal.NormalizeSafe(); - Vec3 aToPt = p - a; - float dist = aToPt.Dot(faceNormal); - float distSq = dist * dist; - float triLenSq = uVec.len2() + vVec.len2(); - - // Is the point "close enough" to the plane of the triangle? - if (distSq < triLenSq * 0.1f) - { - // snap the point to the plane of the triangle - Vec3 coplanarP = p - dist * faceNormal; - - return GetBarycentricCoordinates(a, b, c, coplanarP, u, v, w, 0.0f); - } - - return false; - } - - //////////////////////////////////////////////////////////////////////////////////////////////////// - Vec2 ConvertBarycentricCoordsToUVCoords(float u, float v, float w, Vec2 uv0, Vec2 uv1, Vec2 uv2) - { - float arrVertWeight[3] = { max(0.f, u), max(0.f, v), max(0.f, w) }; - float fDiv = 1.f / (arrVertWeight[0] + arrVertWeight[1] + arrVertWeight[2]); - arrVertWeight[0] *= fDiv; - arrVertWeight[1] *= fDiv; - arrVertWeight[2] *= fDiv; - - Vec2 uvResult = uv0 * arrVertWeight[0] + uv1 * arrVertWeight[1] + uv2 * arrVertWeight[2]; - return uvResult; - } - - //////////////////////////////////////////////////////////////////////////////////////////////////// - bool GetTexCoordFromRayHitOnIndexedMesh( - int triIndex, - Vec3 hitPoint, - [[maybe_unused]] const IPhysicalEntity* collider, - [[maybe_unused]] int partIndex, - const Matrix34& slotWorldTM, - const IIndexedMesh* indexedMesh, - Vec2& texCoord) - { - IIndexedMesh::SMeshDescription meshDesc; - indexedMesh->GetMeshDescription(meshDesc); - -#if UI_CANVAS_ON_MESH_DEBUG - DrawSphere(hitPoint, debugHitColor, debugDrawSphereSize); -#endif - - // triIndex is -1 if this is not a mesh collision (i.e. collided with a parametric primitive) - if (triIndex >= 0 && triIndex * 3 <= meshDesc.m_nIndexCount) - { - // convert TriIndex into the indices into the index buffer - int i0 = triIndex * 3; - int i1 = i0 + 1; - int i2 = i0 + 2; - - // get the vertex indices from the index buffer - int vIndex0 = meshDesc.m_pIndices[i0]; - int vIndex1 = meshDesc.m_pIndices[i1]; - int vIndex2 = meshDesc.m_pIndices[i2]; - - // get verts in local space - Vec3 v0 = meshDesc.m_pVerts[vIndex0]; - Vec3 v1 = meshDesc.m_pVerts[vIndex1]; - Vec3 v2 = meshDesc.m_pVerts[vIndex2]; - - // get verts in world space - Vec3 wv0 = slotWorldTM.TransformPoint(v0); - Vec3 wv1 = slotWorldTM.TransformPoint(v1); - Vec3 wv2 = slotWorldTM.TransformPoint(v2); - - -#if UI_CANVAS_ON_MESH_DEBUG - DrawCollisionMeshTrianglePoints(triIndex, collider, partIndex, slotWorldTM); -#endif - - float u, v, w; - if (SnapToPlaneAndGetBarycentricCoordinates(wv0, wv1, wv2, hitPoint, u, v, w)) - { -#if UI_CANVAS_ON_MESH_DEBUG - DrawTrianglePoints(wv0, wv1, wv2, debugRenderMeshAttempt1Color, debugDrawSphereSize); -#endif - - // get the texcoord for each vert of the triangle - Vec2 uv0 = meshDesc.m_pTexCoord[vIndex0].GetUV(); - Vec2 uv1 = meshDesc.m_pTexCoord[vIndex1].GetUV(); - Vec2 uv2 = meshDesc.m_pTexCoord[vIndex2].GetUV(); - - texCoord = ConvertBarycentricCoordsToUVCoords(u, v, w, uv0, uv1, uv2); - - return true; - } - } - - // If we got here then EITHER, the iPrim is 0xffffffff meaning that the collision - // was a primitive rather than a mesh collision OR the iPrim is not the right - // triangle index in the render mesh. This sometimes happens, presumably due to - // some modifications that are made automatically to the collision mesh by the - // physics system or something to do with how the IndexedMesh is generated on - // demand in IStatObj:::GetIndexedMesh. - // We do have the collision point though. So we go through all the triangles in - // the render mesh and try to find the right triangle. - // NOTE: This could be optimized by converting the hit point to local space. - // NOTE: Currently we use the first triangle where the point is "close enough" to the plane - // of the triangle and the barycentric calculation says that the point is within the - // triangle. This "close enough" test is rather arbitrary and could get a false positive in - // some edge cases. - // Another approach would be to go through all the triangles doing the barycentric - // test and keep track of which one that passes is closest to the plane of the triangle. - int triCount = meshDesc.m_nIndexCount / 3; - for (int i = 0; i < triCount; ++i) - { - // convert TriIndex into the indices into the index buffer - int i0 = i * 3; - int i1 = i0 + 1; - int i2 = i0 + 2; - - // get the vertex indices from the index buffer - int vIndex0 = meshDesc.m_pIndices[i0]; - int vIndex1 = meshDesc.m_pIndices[i1]; - int vIndex2 = meshDesc.m_pIndices[i2]; - - // get verts in local space - Vec3 v0 = meshDesc.m_pVerts[vIndex0]; - Vec3 v1 = meshDesc.m_pVerts[vIndex1]; - Vec3 v2 = meshDesc.m_pVerts[vIndex2]; - - // get verts in world space - Vec3 wv0 = slotWorldTM.TransformPoint(v0); - Vec3 wv1 = slotWorldTM.TransformPoint(v1); - Vec3 wv2 = slotWorldTM.TransformPoint(v2); - - float u, v, w; - if (SnapToPlaneAndGetBarycentricCoordinates(wv0, wv1, wv2, hitPoint, u, v, w)) - { -#if UI_CANVAS_ON_MESH_DEBUG - DrawTrianglePoints(wv0, wv1, wv2, debugRenderMeshAttempt2Color, debugDrawSphereSize); -#endif - - // get the texcoord for each vert of the triangle - Vec2 uv0 = meshDesc.m_pTexCoord[vIndex0].GetUV(); - Vec2 uv1 = meshDesc.m_pTexCoord[vIndex1].GetUV(); - Vec2 uv2 = meshDesc.m_pTexCoord[vIndex2].GetUV(); - - texCoord = ConvertBarycentricCoordsToUVCoords(u, v, w, uv0, uv1, uv2); - - return true; - } - } - - return false; - } } // Anonymous namespace //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Gems/LyShine/Code/Tests/LyShineEditorTest.cpp b/Gems/LyShine/Code/Tests/LyShineEditorTest.cpp index 597874d5d6..ff4e054ac7 100644 --- a/Gems/LyShine/Code/Tests/LyShineEditorTest.cpp +++ b/Gems/LyShine/Code/Tests/LyShineEditorTest.cpp @@ -54,7 +54,6 @@ #include #include #include -#include AZ_UNIT_TEST_HOOK(DEFAULT_UNIT_TEST_ENV); @@ -80,7 +79,6 @@ protected: m_data = AZStd::make_unique(); memset(&m_data->m_stubEnv, 0, sizeof(SSystemGlobalEnvironment)); - m_data->m_stubEnv.pRenderer = &m_data->m_renderer; m_data->m_stubEnv.pSystem = &m_data->m_mockSystem; gEnv = &m_data->m_stubEnv; @@ -212,7 +210,6 @@ protected: struct DataMembers { SSystemGlobalEnvironment m_stubEnv; - NiceMock m_renderer; NiceMock m_mockSystem; }; diff --git a/Gems/LyShine/Code/Tests/SpriteTest.cpp b/Gems/LyShine/Code/Tests/SpriteTest.cpp index 84b47955b4..ff9095a7d9 100644 --- a/Gems/LyShine/Code/Tests/SpriteTest.cpp +++ b/Gems/LyShine/Code/Tests/SpriteTest.cpp @@ -8,7 +8,6 @@ #include "LyShineTest.h" #include -#include #include #include @@ -42,23 +41,13 @@ namespace UnitTest { LyShineTest::SetupEnvironment(); - m_data = AZStd::make_unique(); - m_env->m_stubEnv.pRenderer = &m_data->m_renderer; } void TearDown() override { - m_data.reset(); - LyShineTest::TearDown(); } - struct DataMembers - { - testing::NiceMock m_renderer; - }; - - AZStd::unique_ptr m_data; }; #ifdef LYSHINE_ATOM_TODO // [LYN-3359] - render target support using Atom diff --git a/Gems/LyShine/Code/Tests/TextInputComponentTest.cpp b/Gems/LyShine/Code/Tests/TextInputComponentTest.cpp index 6a9560da27..97c178a557 100644 --- a/Gems/LyShine/Code/Tests/TextInputComponentTest.cpp +++ b/Gems/LyShine/Code/Tests/TextInputComponentTest.cpp @@ -8,7 +8,6 @@ #include "LyShineTest.h" -#include #include "UiGameEntityContext.h" #include "UiElementComponent.h" #include "UiTransform2dComponent.h" @@ -118,13 +117,10 @@ namespace UnitTest m_priorEnv = gEnv; gEnv = &m_env->m_stubEnv; - m_data = AZStd::make_unique(); - m_env->m_stubEnv.pRenderer = &m_data->m_renderer; } void TearDown() override { - m_data.reset(); m_env.reset(); gEnv = m_priorEnv; @@ -140,12 +136,7 @@ namespace UnitTest SSystemGlobalEnvironment m_stubEnv; }; - struct DataMembers - { - testing::NiceMock m_renderer; - }; - AZStd::unique_ptr m_data; AZStd::unique_ptr m_env; SSystemGlobalEnvironment* m_priorEnv = nullptr; diff --git a/Gems/LyShineExamples/Code/Source/UiCustomImageComponent.h b/Gems/LyShineExamples/Code/Source/UiCustomImageComponent.h index ccd886df87..f696228f5a 100644 --- a/Gems/LyShineExamples/Code/Source/UiCustomImageComponent.h +++ b/Gems/LyShineExamples/Code/Source/UiCustomImageComponent.h @@ -136,7 +136,7 @@ namespace LyShineExamples float m_overrideAlpha; // cached rendering data for performance optimization - IRenderer::DynUiPrimitive m_cachedPrimitive; + DynUiPrimitive m_cachedPrimitive; bool m_isRenderCacheDirty = true; }; } diff --git a/Gems/Maestro/Code/Source/Cinematics/AnimComponentNode.h b/Gems/Maestro/Code/Source/Cinematics/AnimComponentNode.h index 5ad3ab6f94..43f49e8b80 100644 --- a/Gems/Maestro/Code/Source/Cinematics/AnimComponentNode.h +++ b/Gems/Maestro/Code/Source/Cinematics/AnimComponentNode.h @@ -152,14 +152,14 @@ private: { m_displayName = other.m_displayName; m_animNodeParamInfo.paramType = other.m_displayName; - m_animNodeParamInfo.name = &m_displayName[0]; + m_animNodeParamInfo.name = m_displayName; } BehaviorPropertyInfo& operator=(const AZStd::string& str) { // TODO: clean this up - this weird memory sharing was copied from legacy Cry - could be better. m_displayName = str; m_animNodeParamInfo.paramType = str; // set type to AnimParamType::ByString by assigning a string - m_animNodeParamInfo.name = &m_displayName[0]; + m_animNodeParamInfo.name = m_displayName; return *this; } diff --git a/Gems/Maestro/Code/Source/Cinematics/AnimNode.cpp b/Gems/Maestro/Code/Source/Cinematics/AnimNode.cpp index 828e5ad20f..c141dc51c8 100644 --- a/Gems/Maestro/Code/Source/Cinematics/AnimNode.cpp +++ b/Gems/Maestro/Code/Source/Cinematics/AnimNode.cpp @@ -77,7 +77,7 @@ int CAnimNode::GetTrackCount() const return static_cast(m_tracks.size()); } -const char* CAnimNode::GetParamName(const CAnimParamType& paramType) const +AZStd::string CAnimNode::GetParamName(const CAnimParamType& paramType) const { SParamInfo info; if (GetParamInfoFromType(paramType, info)) diff --git a/Gems/Maestro/Code/Source/Cinematics/AnimNode.h b/Gems/Maestro/Code/Source/Cinematics/AnimNode.h index 418d667c34..7c56d8f641 100644 --- a/Gems/Maestro/Code/Source/Cinematics/AnimNode.h +++ b/Gems/Maestro/Code/Source/Cinematics/AnimNode.h @@ -86,7 +86,7 @@ public: ////////////////////////////////////////////////////////////////////////// bool IsParamValid(const CAnimParamType& paramType) const; - virtual const char* GetParamName(const CAnimParamType& param) const; + AZStd::string GetParamName(const CAnimParamType& param) const override; virtual AnimValueType GetParamValueType(const CAnimParamType& paramType) const; virtual IAnimNode::ESupportedParamFlags GetParamFlags(const CAnimParamType& paramType) const; virtual unsigned int GetParamCount() const { return 0; }; diff --git a/Gems/Maestro/Code/Source/Cinematics/AnimSequence.h b/Gems/Maestro/Code/Source/Cinematics/AnimSequence.h index f69017c3a6..0a1d4a931c 100644 --- a/Gems/Maestro/Code/Source/Cinematics/AnimSequence.h +++ b/Gems/Maestro/Code/Source/Cinematics/AnimSequence.h @@ -18,6 +18,8 @@ #include "TrackEventTrack.h" +#include + class CAnimSequence : public IAnimSequence { diff --git a/Gems/Maestro/Code/Source/Cinematics/AnimSplineTrack.h b/Gems/Maestro/Code/Source/Cinematics/AnimSplineTrack.h index 5167a8e7b1..46dcb63daa 100644 --- a/Gems/Maestro/Code/Source/Cinematics/AnimSplineTrack.h +++ b/Gems/Maestro/Code/Source/Cinematics/AnimSplineTrack.h @@ -54,7 +54,7 @@ public: virtual int GetSubTrackCount() const { return 0; }; virtual IAnimTrack* GetSubTrack([[maybe_unused]] int nIndex) const { return 0; }; - virtual const char* GetSubTrackName([[maybe_unused]] int nIndex) const { return NULL; }; + AZStd::string GetSubTrackName([[maybe_unused]] int nIndex) const { return AZStd::string(); }; virtual void SetSubTrackName([[maybe_unused]] int nIndex, [[maybe_unused]] const char* name) { assert(0); } void SetNode(IAnimNode* node) override { m_node = node; } diff --git a/Gems/Maestro/Code/Source/Cinematics/AnimTrack.h b/Gems/Maestro/Code/Source/Cinematics/AnimTrack.h index b65dad1323..e16f64c7c1 100644 --- a/Gems/Maestro/Code/Source/Cinematics/AnimTrack.h +++ b/Gems/Maestro/Code/Source/Cinematics/AnimTrack.h @@ -37,7 +37,7 @@ public: virtual int GetSubTrackCount() const { return 0; }; virtual IAnimTrack* GetSubTrack([[maybe_unused]] int nIndex) const { return 0; }; - virtual const char* GetSubTrackName([[maybe_unused]] int nIndex) const { return NULL; }; + AZStd::string GetSubTrackName([[maybe_unused]] int nIndex) const override { return AZStd::string(); }; virtual void SetSubTrackName([[maybe_unused]] int nIndex, [[maybe_unused]] const char* name) { assert(0); } virtual const CAnimParamType& GetParameterType() const { return m_nParamType; }; diff --git a/Gems/Maestro/Code/Source/Cinematics/CompoundSplineTrack.cpp b/Gems/Maestro/Code/Source/Cinematics/CompoundSplineTrack.cpp index 884a90b200..d134d5f0f7 100644 --- a/Gems/Maestro/Code/Source/Cinematics/CompoundSplineTrack.cpp +++ b/Gems/Maestro/Code/Source/Cinematics/CompoundSplineTrack.cpp @@ -346,10 +346,10 @@ IAnimTrack* CCompoundSplineTrack::GetSubTrack(int nIndex) const } ////////////////////////////////////////////////////////////////////////// -const char* CCompoundSplineTrack::GetSubTrackName(int nIndex) const +AZStd::string CCompoundSplineTrack::GetSubTrackName(int nIndex) const { assert(nIndex >= 0 && nIndex < m_nDimensions); - return m_subTrackNames[nIndex].c_str(); + return m_subTrackNames[nIndex]; } diff --git a/Gems/Maestro/Code/Source/Cinematics/CompoundSplineTrack.h b/Gems/Maestro/Code/Source/Cinematics/CompoundSplineTrack.h index b0a2733316..443bad584b 100644 --- a/Gems/Maestro/Code/Source/Cinematics/CompoundSplineTrack.h +++ b/Gems/Maestro/Code/Source/Cinematics/CompoundSplineTrack.h @@ -38,7 +38,7 @@ public: virtual int GetSubTrackCount() const { return m_nDimensions; }; virtual IAnimTrack* GetSubTrack(int nIndex) const; - virtual const char* GetSubTrackName(int nIndex) const; + AZStd::string GetSubTrackName(int nIndex) const; virtual void SetSubTrackName(int nIndex, const char* name); virtual EAnimCurveType GetCurveType() { return eAnimCurveType_BezierFloat; }; diff --git a/Gems/Maestro/Code/Source/Cinematics/MaterialNode.cpp b/Gems/Maestro/Code/Source/Cinematics/MaterialNode.cpp index 74b0fb1063..9a54b21d7f 100644 --- a/Gems/Maestro/Code/Source/Cinematics/MaterialNode.cpp +++ b/Gems/Maestro/Code/Source/Cinematics/MaterialNode.cpp @@ -217,7 +217,7 @@ bool CAnimMaterialNode::GetParamInfoFromType(const CAnimParamType& paramId, SPar } ////////////////////////////////////////////////////////////////////////// -const char* CAnimMaterialNode::GetParamName(const CAnimParamType& param) const +AZStd::string CAnimMaterialNode::GetParamName(const CAnimParamType& param) const { if (param.GetType() == AnimParamType::ByString) { diff --git a/Gems/Maestro/Code/Source/Cinematics/MaterialNode.h b/Gems/Maestro/Code/Source/Cinematics/MaterialNode.h index 003312c426..63f287f513 100644 --- a/Gems/Maestro/Code/Source/Cinematics/MaterialNode.h +++ b/Gems/Maestro/Code/Source/Cinematics/MaterialNode.h @@ -37,7 +37,7 @@ public: ////////////////////////////////////////////////////////////////////////// virtual unsigned int GetParamCount() const; virtual CAnimParamType GetParamType(unsigned int nIndex) const; - virtual const char* GetParamName(const CAnimParamType& paramType) const; + AZStd::string GetParamName(const CAnimParamType& paramType) const override; virtual void GetKeyValueRange(float& fMin, float& fMax) const { fMin = m_fMinKeyValue; fMax = m_fMaxKeyValue; }; virtual void SetKeyValueRange(float fMin, float fMax){ m_fMinKeyValue = fMin; m_fMaxKeyValue = fMax; }; diff --git a/Gems/Maestro/Code/Source/Cinematics/Movie.cpp b/Gems/Maestro/Code/Source/Cinematics/Movie.cpp index cf51ef3729..467ab37dab 100644 --- a/Gems/Maestro/Code/Source/Cinematics/Movie.cpp +++ b/Gems/Maestro/Code/Source/Cinematics/Movie.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -973,9 +974,6 @@ void CMovieSystem::StillUpdate() ////////////////////////////////////////////////////////////////////////// void CMovieSystem::ShowPlayedSequencesDebug() { - f32 green[4] = {0, 1, 0, 1}; - f32 purple[4] = {1, 0, 1, 1}; - f32 white[4] = {1, 1, 1, 1}; float y = 10.0f; std::vector names; diff --git a/Gems/Maestro/Code/Source/Cinematics/Movie.h b/Gems/Maestro/Code/Source/Cinematics/Movie.h index 6ac857d652..7c8edd15ae 100644 --- a/Gems/Maestro/Code/Source/Cinematics/Movie.h +++ b/Gems/Maestro/Code/Source/Cinematics/Movie.h @@ -16,6 +16,7 @@ #include #include "IMovieSystem.h" +#include "IShader.h" struct PlayingSequence { diff --git a/Gems/Maestro/Code/Source/Cinematics/SceneNode.cpp b/Gems/Maestro/Code/Source/Cinematics/SceneNode.cpp index 79841e671b..10014a8700 100644 --- a/Gems/Maestro/Code/Source/Cinematics/SceneNode.cpp +++ b/Gems/Maestro/Code/Source/Cinematics/SceneNode.cpp @@ -42,8 +42,6 @@ #define s_nodeParams s_nodeParamsSene #define AddSupportedParam AddSupportedParamScene -float const kDefaultCameraFOV = 60.0f; - namespace { bool s_nodeParamsInitialized = false; StaticInstance> s_nodeParams; @@ -697,7 +695,6 @@ void CAnimSceneNode::InterpolateCameras(SCameraParams& retInterpolatedCameraPara return; } - static const float EPSILON_TIME = 0.01f; // consider times within EPSILON_TIME of beginning of blend time to be at the beginning of blend time float interpolatedFoV; ISceneCamera* secondCamera = static_cast(new CComponentEntitySceneCamera(secondKey.cameraAzEntityId)); diff --git a/Gems/Maestro/Code/Source/Cinematics/ScreenFaderTrack.cpp b/Gems/Maestro/Code/Source/Cinematics/ScreenFaderTrack.cpp index 9ac19f91ea..1b2fbe0baf 100644 --- a/Gems/Maestro/Code/Source/Cinematics/ScreenFaderTrack.cpp +++ b/Gems/Maestro/Code/Source/Cinematics/ScreenFaderTrack.cpp @@ -9,7 +9,7 @@ #include #include "ScreenFaderTrack.h" -#include +#include //----------------------------------------------------------------------------- CScreenFaderTrack::CScreenFaderTrack() diff --git a/Gems/Maestro/Code/Source/Cinematics/SoundTrack.h b/Gems/Maestro/Code/Source/Cinematics/SoundTrack.h index ac6eca4f03..58ba8c78c6 100644 --- a/Gems/Maestro/Code/Source/Cinematics/SoundTrack.h +++ b/Gems/Maestro/Code/Source/Cinematics/SoundTrack.h @@ -11,6 +11,7 @@ #define CRYINCLUDE_CRYMOVIE_SOUNDTRACK_H #include "AnimTrack.h" +#include struct SSoundInfo { diff --git a/Gems/Maestro/Code/Source/Cinematics/Tests/AssetBlendTrackTest.cpp b/Gems/Maestro/Code/Source/Cinematics/Tests/AssetBlendTrackTest.cpp index e995795198..09bbe640d4 100644 --- a/Gems/Maestro/Code/Source/Cinematics/Tests/AssetBlendTrackTest.cpp +++ b/Gems/Maestro/Code/Source/Cinematics/Tests/AssetBlendTrackTest.cpp @@ -20,7 +20,6 @@ namespace AssetBlendTrackTest const AZ::Data::AssetId KEY1_ASSET_ID = AZ::Data::AssetId(AZ::Uuid("{86CE36B5-D996-4CEF-943E-3F12008694E1}"), 1); const AZ::Data::AssetId KEY2_ASSET_ID = AZ::Data::AssetId(AZ::Uuid("{94D54D20-BACC-4A60-8A03-0DC9B5033E03}"), 2); const AZ::Data::AssetId KEY3_ASSET_ID = AZ::Data::AssetId(AZ::Uuid("{94D54D20-BACC-4A60-8A03-0DC9B5033E03}"), 3); - const float KEY_TIME = 1.0f; ///////////////////////////////////////////////////////////////////////////////////// // Testing sub-class diff --git a/Gems/Maestro/Code/Source/Cinematics/Tests/EntityNodeTest.cpp b/Gems/Maestro/Code/Source/Cinematics/Tests/EntityNodeTest.cpp index 064f1ba6a7..763fa67c78 100644 --- a/Gems/Maestro/Code/Source/Cinematics/Tests/EntityNodeTest.cpp +++ b/Gems/Maestro/Code/Source/Cinematics/Tests/EntityNodeTest.cpp @@ -15,8 +15,6 @@ namespace EntityNodeTest { - // dummy entity id - const int ENTITY_ID = 0; // consants to set up test key frame, at 1.0 seconds, lasting for 1.0 seconds const int KEY_IDX = 0; const float KEY_TIME = 1.0f; @@ -113,7 +111,6 @@ namespace EntityNodeTest TEST_F(CryMovie_CharacterTrackAnimator_Test, CryMovieUnitTest_CharacterTrackAnimator_ComputeAnimKeyNormalizedTime_Loop) { const float NORMALIZED_CLIP_START = .0f; - const float NORMALIZED_CLIP_END = 1.0f; const float ERROR_TOLERANCE = 0.0001f; ICharacterKey key; m_dummyTrack.GetKey(EntityNodeTest::KEY_IDX, &key); diff --git a/Gems/Maestro/Code/Source/Cinematics/TrackEventTrack.h b/Gems/Maestro/Code/Source/Cinematics/TrackEventTrack.h index 3993194bcf..13a6549220 100644 --- a/Gems/Maestro/Code/Source/Cinematics/TrackEventTrack.h +++ b/Gems/Maestro/Code/Source/Cinematics/TrackEventTrack.h @@ -15,6 +15,7 @@ #include "IMovieSystem.h" #include "AnimTrack.h" #include "AnimKey.h" +#include "StlUtils.h" class CAnimStringTable : public IAnimStringTable diff --git a/Gems/Microphone/Code/Source/Platform/Android/MicrophoneSystemComponent_Android.cpp b/Gems/Microphone/Code/Source/Platform/Android/MicrophoneSystemComponent_Android.cpp index f30bef03ae..1e696f7978 100644 --- a/Gems/Microphone/Code/Source/Platform/Android/MicrophoneSystemComponent_Android.cpp +++ b/Gems/Microphone/Code/Source/Platform/Android/MicrophoneSystemComponent_Android.cpp @@ -121,53 +121,51 @@ namespace Audio AZStd::size_t GetData(void** outputData, AZStd::size_t numFrames, const SAudioInputConfig& targetConfig, bool shouldDeinterleave) { - - bool changeSampleType = (targetConfig.m_sampleType != m_config.m_sampleType); - bool changeSampleRate = (targetConfig.m_sampleRate != m_config.m_sampleRate); - bool changeNumChannels = (targetConfig.m_numChannels != m_config.m_numChannels); - #if defined(USE_LIBSAMPLERATE) return {}; #else - if (changeSampleType || changeNumChannels) - { - // Without the SRC library, any change is unsupported! - return {}; - } - else if (changeSampleRate) - { - if(targetConfig.m_sampleRate > m_config.m_sampleRate) + bool changeSampleType = (targetConfig.m_sampleType != m_config.m_sampleType); + bool changeSampleRate = (targetConfig.m_sampleRate != m_config.m_sampleRate); + bool changeNumChannels = (targetConfig.m_numChannels != m_config.m_numChannels); + if (changeSampleType || changeNumChannels) { - AZ_Error("MacOSMicrophone", false, "Target sample rate is larger than source sample rate, this is not supported"); + // Without the SRC library, any change is unsupported! return {}; } - - auto sourceBuffer = new AZ::s16[numFrames]; - AZStd::size_t targetSize = GetDownsampleSize(numFrames, m_config.m_sampleRate, targetConfig.m_sampleRate); - auto targetBuffer = new AZ::s16[targetSize]; - - numFrames = m_captureData->ConsumeData(reinterpret_cast(&sourceBuffer), numFrames, m_config.m_numChannels, false); - - - if(numFrames > 0) + else if (changeSampleRate) { - Downsample(sourceBuffer, numFrames, m_config.m_sampleRate, targetBuffer, targetSize, targetConfig.m_sampleRate); + if(targetConfig.m_sampleRate > m_config.m_sampleRate) + { + AZ_Error("MacOSMicrophone", false, "Target sample rate is larger than source sample rate, this is not supported"); + return {}; + } - numFrames = targetSize; - // swap target data to output - ::memcpy(*outputData, targetBuffer, targetSize * 2); //*2 as two bytes per frame + auto sourceBuffer = new AZ::s16[numFrames]; + AZStd::size_t targetSize = GetDownsampleSize(numFrames, m_config.m_sampleRate, targetConfig.m_sampleRate); + auto targetBuffer = new AZ::s16[targetSize]; + + numFrames = m_captureData->ConsumeData(reinterpret_cast(&sourceBuffer), numFrames, m_config.m_numChannels, false); + + + if(numFrames > 0) + { + Downsample(sourceBuffer, numFrames, m_config.m_sampleRate, targetBuffer, targetSize, targetConfig.m_sampleRate); + + numFrames = targetSize; + // swap target data to output + ::memcpy(*outputData, targetBuffer, targetSize * 2); //*2 as two bytes per frame + } + + delete [] sourceBuffer; + delete [] targetBuffer; + + return numFrames; + } + else + { + // No change to the data from Input to Output + return m_captureData->ConsumeData(outputData, numFrames, m_config.m_numChannels, shouldDeinterleave); } - - delete [] sourceBuffer; - delete [] targetBuffer; - - return numFrames; - } - else - { - // No change to the data from Input to Output - return m_captureData->ConsumeData(outputData, numFrames, m_config.m_numChannels, shouldDeinterleave); - } #endif } diff --git a/Gems/Microphone/Code/Source/Platform/Mac/MicrophoneSystemComponent_Mac.mm b/Gems/Microphone/Code/Source/Platform/Mac/MicrophoneSystemComponent_Mac.mm index 1f7cef7b0c..567f2db6b2 100644 --- a/Gems/Microphone/Code/Source/Platform/Mac/MicrophoneSystemComponent_Mac.mm +++ b/Gems/Microphone/Code/Source/Platform/Mac/MicrophoneSystemComponent_Mac.mm @@ -241,13 +241,14 @@ public: AZStd::size_t GetData(void** outputData, AZStd::size_t numFrames, const SAudioInputConfig& targetConfig, bool shouldDeinterleave) override { - bool changeSampleType = (targetConfig.m_sampleType != m_config.m_sampleType); - bool changeSampleRate = (targetConfig.m_sampleRate != m_config.m_sampleRate); - bool changeNumChannels = (targetConfig.m_numChannels != m_config.m_numChannels); #if defined(USE_LIBSAMPLERATE) // pending port of LIBSAMPLERATE to MacOS return {}; #else + bool changeSampleType = (targetConfig.m_sampleType != m_config.m_sampleType); + bool changeSampleRate = (targetConfig.m_sampleRate != m_config.m_sampleRate); + bool changeNumChannels = (targetConfig.m_numChannels != m_config.m_numChannels); + if (changeSampleType || changeNumChannels) { // Without the SRC library, any change is unsupported! diff --git a/Gems/Microphone/Code/Source/Platform/iOS/MicrophoneSystemComponent_iOS.mm b/Gems/Microphone/Code/Source/Platform/iOS/MicrophoneSystemComponent_iOS.mm index fe8580723a..a3d4f9434f 100644 --- a/Gems/Microphone/Code/Source/Platform/iOS/MicrophoneSystemComponent_iOS.mm +++ b/Gems/Microphone/Code/Source/Platform/iOS/MicrophoneSystemComponent_iOS.mm @@ -187,13 +187,14 @@ public: AZStd::size_t GetData(void** outputData, AZStd::size_t numFrames, const SAudioInputConfig& targetConfig, bool shouldDeinterleave) override { - bool changeSampleType = (targetConfig.m_sampleType != m_config.m_sampleType); - bool changeSampleRate = (targetConfig.m_sampleRate != m_config.m_sampleRate); - bool changeNumChannels = (targetConfig.m_numChannels != m_config.m_numChannels); #if defined(USE_LIBSAMPLERATE) // pending port of LIBSAMPLERATE to iOS return {}; #else + bool changeSampleType = (targetConfig.m_sampleType != m_config.m_sampleType); + bool changeSampleRate = (targetConfig.m_sampleRate != m_config.m_sampleRate); + bool changeNumChannels = (targetConfig.m_numChannels != m_config.m_numChannels); + if (changeSampleType || changeNumChannels) { // Without the SRC library, any change is unsupported! diff --git a/Gems/Multiplayer/Code/Source/Components/LocalPredictionPlayerInputComponent.cpp b/Gems/Multiplayer/Code/Source/Components/LocalPredictionPlayerInputComponent.cpp index 936f2ea92c..452cb31a7a 100644 --- a/Gems/Multiplayer/Code/Source/Components/LocalPredictionPlayerInputComponent.cpp +++ b/Gems/Multiplayer/Code/Source/Components/LocalPredictionPlayerInputComponent.cpp @@ -40,7 +40,6 @@ namespace Multiplayer AzNetworking::StringifySerializer::ValueMap differences = clientMap; for (auto iter = server.GetValueMap().begin(); iter != server.GetValueMap().end(); ++iter) { - auto serverValueIter = clientMap.find(iter->first); if (iter->second == differences[iter->first]) { differences.erase(iter->first); @@ -492,7 +491,6 @@ namespace Multiplayer { const double deltaTime = static_cast(deltaTimeMs) / 1000.0; const double clientInputRateSec = static_cast(static_cast(cl_InputRateMs)) / 1000.0; - const double maxRewindHistory = static_cast(static_cast(cl_MaxRewindHistoryMs)) / 1000.0; // Update banked time accumulator m_clientBankedTime -= deltaTime; diff --git a/Gems/Multiplayer/Code/Source/Debug/MultiplayerDebugSystemComponent.cpp b/Gems/Multiplayer/Code/Source/Debug/MultiplayerDebugSystemComponent.cpp index 27a4dff485..422b2f0cae 100644 --- a/Gems/Multiplayer/Code/Source/Debug/MultiplayerDebugSystemComponent.cpp +++ b/Gems/Multiplayer/Code/Source/Debug/MultiplayerDebugSystemComponent.cpp @@ -230,7 +230,6 @@ namespace Multiplayer void DrawNetworkingStats() { const float TEXT_BASE_WIDTH = ImGui::CalcTextSize("A").x; - const float TEXT_BASE_HEIGHT = ImGui::GetTextLineHeightWithSpacing(); const ImGuiTableFlags flags = ImGuiTableFlags_BordersV | ImGuiTableFlags_BordersOuterH @@ -383,7 +382,6 @@ namespace Multiplayer void DrawMultiplayerStats() { const float TEXT_BASE_WIDTH = ImGui::CalcTextSize("A").x; - const float TEXT_BASE_HEIGHT = ImGui::GetTextLineHeightWithSpacing(); IMultiplayer* multiplayer = AZ::Interface::Get(); MultiplayerComponentRegistry* componentRegistry = GetMultiplayerComponentRegistry(); diff --git a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp index b0a8350982..f248d7bbf2 100644 --- a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp +++ b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp @@ -748,7 +748,6 @@ namespace Multiplayer { m_initEvent.Signal(m_networkInterface); - const AZ::Aabb worldBounds = AZ::Aabb::CreateFromMinMax(AZ::Vector3(-16384.0f), AZ::Vector3(16384.0f)); //const AZ::Aabb worldBounds = AZ::Interface.Get()->GetWorldBounds(); AZStd::unique_ptr newDomain = AZStd::make_unique(); m_networkEntityManager.Initialize(InvalidHostId, AZStd::move(newDomain)); @@ -894,9 +893,8 @@ namespace Multiplayer // Unfortunately necessary, as NotifyPreRender can update transforms and thus cause a deadlock inside the vis system AZStd::vector gatheredEntities; - AzFramework::IEntityBoundsUnion* entityBoundsUnion = AZ::Interface::Get(); AZ::Interface::Get()->GetDefaultVisibilityScene()->Enumerate(viewFrustum, - [&gatheredEntities, entityBoundsUnion](const AzFramework::IVisibilityScene::NodeData& nodeData) + [&gatheredEntities](const AzFramework::IVisibilityScene::NodeData& nodeData) { gatheredEntities.reserve(gatheredEntities.size() + nodeData.m_entries.size()); for (AzFramework::VisibilityEntry* visEntry : nodeData.m_entries) diff --git a/Gems/Multiplayer/Code/Source/NetworkEntity/EntityReplication/PropertySubscriber.h b/Gems/Multiplayer/Code/Source/NetworkEntity/EntityReplication/PropertySubscriber.h index f5615f3d52..286509b798 100644 --- a/Gems/Multiplayer/Code/Source/NetworkEntity/EntityReplication/PropertySubscriber.h +++ b/Gems/Multiplayer/Code/Source/NetworkEntity/EntityReplication/PropertySubscriber.h @@ -40,7 +40,6 @@ namespace Multiplayer // The last packet to have been received about this entity AzNetworking::PacketId m_lastReceivedPacketId = AzNetworking::InvalidPacketId; - AZ::TimeMs m_lastRecievedTimeMs = AZ::TimeMs{ 0 }; AZ::TimeMs m_markForRemovalTimeMs = AZ::TimeMs{ 0 }; }; } diff --git a/Gems/Multiplayer/Code/Source/ReplicationWindows/ServerToClientReplicationWindow.cpp b/Gems/Multiplayer/Code/Source/ReplicationWindows/ServerToClientReplicationWindow.cpp index ba9740f8db..3677eb8b5c 100644 --- a/Gems/Multiplayer/Code/Source/ReplicationWindows/ServerToClientReplicationWindow.cpp +++ b/Gems/Multiplayer/Code/Source/ReplicationWindows/ServerToClientReplicationWindow.cpp @@ -181,9 +181,9 @@ namespace Multiplayer void ServerToClientReplicationWindow::DebugDraw() const { - static const float BoundaryStripeHeight = 1.0f; - static const float BoundaryStripeSpacing = 0.5f; - static const int32_t BoundaryStripeCount = 10; + //static const float BoundaryStripeHeight = 1.0f; + //static const float BoundaryStripeSpacing = 0.5f; + //static const int32_t BoundaryStripeCount = 10; //if (auto localEnt = m_ControlledEntity.lock()) //{ @@ -289,7 +289,6 @@ namespace Multiplayer } const bool isQueueFull = (m_candidateQueue.size() >= sv_MaxEntitiesToTrackReplication); // See if have the maximum number of entities in our set - const bool isBetterChoice = !m_candidateQueue.empty() && (priority > m_candidateQueue.top().m_priority); // Check if the new thing we are adding is better than the worst item in our set const bool isInReplicationSet = m_replicationSet.find(entityHandle) != m_replicationSet.end(); if (!isInReplicationSet) { diff --git a/Gems/Multiplayer/Code/Source/ReplicationWindows/ServerToClientReplicationWindow.h b/Gems/Multiplayer/Code/Source/ReplicationWindows/ServerToClientReplicationWindow.h index 391693812d..bfaa351095 100644 --- a/Gems/Multiplayer/Code/Source/ReplicationWindows/ServerToClientReplicationWindow.h +++ b/Gems/Multiplayer/Code/Source/ReplicationWindows/ServerToClientReplicationWindow.h @@ -76,7 +76,6 @@ namespace Multiplayer //NetBindComponent* m_controlledNetBindComponent = nullptr; const AzNetworking::IConnection* m_connection = nullptr; - float m_minPriorityReplicated = 0.0f; ///< Lowest replicated entity priority in last update // Cached values to detect a poor network connection uint32_t m_lastCheckedSentPackets = 0; diff --git a/Gems/MultiplayerCompression/Code/Tests/MultiplayerCompressionTest.cpp b/Gems/MultiplayerCompression/Code/Tests/MultiplayerCompressionTest.cpp index 1c3eda6709..572dffbe60 100644 --- a/Gems/MultiplayerCompression/Code/Tests/MultiplayerCompressionTest.cpp +++ b/Gems/MultiplayerCompression/Code/Tests/MultiplayerCompressionTest.cpp @@ -67,8 +67,6 @@ TEST_F(MultiplayerCompressionTest, MultiplayerCompression_CompressTest) EXPECT_TRUE(uncompressedSize = buffer.GetSize()); EXPECT_TRUE(memcmp(pDecompressedBuffer, buffer.GetBuffer(), uncompressedSize) == 0); - const AZ::u64 unmarshalTime = (AZStd::chrono::system_clock::now() - startTime).count(); - delete [] pCompressedBuffer; delete [] pDecompressedBuffer; diff --git a/Gems/NvCloth/Code/Tests/System/FabricCookerTest.cpp b/Gems/NvCloth/Code/Tests/System/FabricCookerTest.cpp index f6f9947223..c5a22d02d1 100644 --- a/Gems/NvCloth/Code/Tests/System/FabricCookerTest.cpp +++ b/Gems/NvCloth/Code/Tests/System/FabricCookerTest.cpp @@ -140,9 +140,6 @@ namespace UnitTest TEST(NvClothSystem, FactoryCooker_CopyInternalCookedData_CopiedDataMatchesSource) { - const AZ::u32 data[] = { 0, 2, 45, 64, 125 }; - const size_t numDataElements = sizeof(data) / sizeof(data[0]); - nv::cloth::CookedData nvCookedData; nvCookedData.mNumParticles = 0; diff --git a/Gems/PhysX/Code/Editor/ConfigStringLineEditCtrl.cpp b/Gems/PhysX/Code/Editor/ConfigStringLineEditCtrl.cpp index 1e506263be..4cf5204917 100644 --- a/Gems/PhysX/Code/Editor/ConfigStringLineEditCtrl.cpp +++ b/Gems/PhysX/Code/Editor/ConfigStringLineEditCtrl.cpp @@ -257,16 +257,16 @@ namespace PhysX void ConfigStringLineEditHandler::WriteGUIValuesIntoProperty(size_t index, ConfigStringLineEditCtrl* GUI, property_t& instance, AzToolsFramework::InstanceDataNode* node) { - (int)index; - (void)node; + AZ_UNUSED(index); + AZ_UNUSED(node); AZStd::string val = GUI->Value(); instance = static_cast(val); } bool ConfigStringLineEditHandler::ReadValuesIntoGUI(size_t index, ConfigStringLineEditCtrl* GUI, const property_t& instance, AzToolsFramework::InstanceDataNode* node) { - (int)index; - (void)node; + AZ_UNUSED(index); + AZ_UNUSED(node); AZStd::string val = instance; GUI->setValue(val); return false; diff --git a/Gems/PhysX/Code/Editor/EditorClassConverters.cpp b/Gems/PhysX/Code/Editor/EditorClassConverters.cpp index dfa30dc0b4..e55ac6bbda 100644 --- a/Gems/PhysX/Code/Editor/EditorClassConverters.cpp +++ b/Gems/PhysX/Code/Editor/EditorClassConverters.cpp @@ -65,7 +65,6 @@ namespace PhysX { // collision group id AzPhysics::CollisionGroups::Id collisionGroupId; - const int baseColliderComponentIndex = classElement.FindElement(AZ_CRC("BaseClass1", 0xd4925735)); FindElementRecursiveAndGetData(classElement, AZ_CRC("CollisionGroupId", 0x84fe4bbe), collisionGroupId); // collider config diff --git a/Gems/PhysX/Code/Editor/EditorSubComponentModeAngleCone.cpp b/Gems/PhysX/Code/Editor/EditorSubComponentModeAngleCone.cpp index 7e9a59093f..778fce1546 100644 --- a/Gems/PhysX/Code/Editor/EditorSubComponentModeAngleCone.cpp +++ b/Gems/PhysX/Code/Editor/EditorSubComponentModeAngleCone.cpp @@ -334,15 +334,13 @@ namespace PhysX } void EditorSubComponentModeAngleCone::ConfigureLinearView( - float axisLength, const AZ::Color& axis1Color, const AZ::Color& axis2Color, + float axisLength, [[maybe_unused]] const AZ::Color& axis1Color, const AZ::Color& axis2Color, const AZ::Color& axis3Color) { const float coneLength = 0.28f; const float coneRadius = 0.07f; const float lineWidth = 0.05f; - const AZ::Color axesColor[] = { axis1Color, axis2Color, axis3Color }; - const auto configureLinearView = [lineWidth, coneLength, axisLength, coneRadius]( AzToolsFramework::LinearManipulator* linearManipulator, const AZ::Color& color) { diff --git a/Gems/PhysX/Code/Editor/EditorSubComponentModeSnap.cpp b/Gems/PhysX/Code/Editor/EditorSubComponentModeSnap.cpp index cef48a7cf5..5220b2e274 100644 --- a/Gems/PhysX/Code/Editor/EditorSubComponentModeSnap.cpp +++ b/Gems/PhysX/Code/Editor/EditorSubComponentModeSnap.cpp @@ -99,7 +99,6 @@ namespace PhysX debugDisplay.PushMatrix(localTransform); const float xAxisLineLength = 15.0f; - const float yzAxisArrowLength = 1.0f; debugDisplay.SetColor(AZ::Color(1.0f, 0.0f, 0.0f, 1.0f)); debugDisplay.DrawLine(AZ::Vector3(0.0f, 0.0f, 0.0f), AZ::Vector3(xAxisLineLength, 0.0f, 0.0f)); diff --git a/Gems/PhysX/Code/Source/EditorBallJointComponent.cpp b/Gems/PhysX/Code/Source/EditorBallJointComponent.cpp index d196b4644d..da000baeed 100644 --- a/Gems/PhysX/Code/Source/EditorBallJointComponent.cpp +++ b/Gems/PhysX/Code/Source/EditorBallJointComponent.cpp @@ -237,7 +237,6 @@ namespace PhysX debugDisplay.PushMatrix(localTransform); const float xAxisArrowLength = 2.0f; - const float yzAxisArrowLength = 1.0f; debugDisplay.SetColor(AZ::Color(1.0f, 0.0f, 0.0f, 1.0f)); debugDisplay.DrawArrow(AZ::Vector3(0.0f, 0.0f, 0.0f), AZ::Vector3(xAxisArrowLength, 0.0f, 0.0f)); diff --git a/Gems/PhysX/Code/Source/EditorShapeColliderComponent.cpp b/Gems/PhysX/Code/Source/EditorShapeColliderComponent.cpp index 7ff62e0fc6..57bfe17a30 100644 --- a/Gems/PhysX/Code/Source/EditorShapeColliderComponent.cpp +++ b/Gems/PhysX/Code/Source/EditorShapeColliderComponent.cpp @@ -58,10 +58,10 @@ namespace PhysX { if (m_shapeType == ShapeType::Cylinder) { - return AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::Show; + return AZ::Edit::PropertyVisibility::Show; } - return AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::Hide; + return AZ::Edit::PropertyVisibility::Hide; } void EditorShapeColliderComponent::Reflect(AZ::ReflectContext* context) diff --git a/Gems/PhysX/Code/Source/Utils.cpp b/Gems/PhysX/Code/Source/Utils.cpp index 0b7ab9436b..8a76d6d986 100644 --- a/Gems/PhysX/Code/Source/Utils.cpp +++ b/Gems/PhysX/Code/Source/Utils.cpp @@ -654,10 +654,6 @@ namespace PhysX const AZ::Quaternion& colliderRelativeRotation, const AZ::Vector3& nonUniformScale) { - AZ::Transform transform = GetColliderWorldTransform(worldTransform, - colliderRelativePosition, - colliderRelativeRotation); - for (AZ::Vector3& point : pointsInOut) { point = worldTransform.TransformPoint(nonUniformScale * diff --git a/Gems/PhysX/Code/Tests/Benchmarks/PhysXCharactersRagdollBenchmarks.cpp b/Gems/PhysX/Code/Tests/Benchmarks/PhysXCharactersRagdollBenchmarks.cpp index 575ff7b4b7..8febfcddfc 100644 --- a/Gems/PhysX/Code/Tests/Benchmarks/PhysXCharactersRagdollBenchmarks.cpp +++ b/Gems/PhysX/Code/Tests/Benchmarks/PhysXCharactersRagdollBenchmarks.cpp @@ -225,7 +225,6 @@ namespace PhysX::Benchmarks } //enable and position the ragdolls - const int ragdollsPerCol = static_cast(RagdollConstants::TerrainSize / 10.0f) - 1; int idx = 0; for (auto& ragdoll : ragdolls) { diff --git a/Gems/PhysX/Code/Tests/Benchmarks/PhysXJointBenchmarks.cpp b/Gems/PhysX/Code/Tests/Benchmarks/PhysXJointBenchmarks.cpp index 37f099ec1c..17468b5cc6 100644 --- a/Gems/PhysX/Code/Tests/Benchmarks/PhysXJointBenchmarks.cpp +++ b/Gems/PhysX/Code/Tests/Benchmarks/PhysXJointBenchmarks.cpp @@ -40,9 +40,6 @@ namespace PhysX::Benchmarks //! used in BM_Joints_Snake static const float SnakeSegmentLength = 2.5f; - //! The size of the test terrain - static const float TerrainSize = 1000.0f; - //! Constant seed to use with random number generation static const long long RandGenSeed = 74111105110116; //(Number generated by concatenating 'Joint' ascii character codes (74 111 105 110 116) @@ -82,9 +79,6 @@ namespace PhysX::Benchmarks static const float SwingingJointUpperLimit = 90.0f; static const float SwingingJointLowerLimit = -180.0f; - //newtons cradle positioning - static const float ParentNewtonsCradleSpacing = 1.05f; - static const float NewtonsCradleArmLength = 10.0f; } // namespace JointSettings } // namespace JointConstants diff --git a/Gems/PhysX/Code/Tests/Benchmarks/PhysXRigidBodyBenchmarks.cpp b/Gems/PhysX/Code/Tests/Benchmarks/PhysXRigidBodyBenchmarks.cpp index b02a3962cc..0117e9737b 100644 --- a/Gems/PhysX/Code/Tests/Benchmarks/PhysXRigidBodyBenchmarks.cpp +++ b/Gems/PhysX/Code/Tests/Benchmarks/PhysXRigidBodyBenchmarks.cpp @@ -175,7 +175,6 @@ namespace PhysX::Benchmarks const int numRigidBodies = static_cast(state.range(0)); //common settings for each rigid body - const float boxSize = 5.0f; const float boxSizeWithSpacing = RigidBodyConstants::RigidBodys::BoxSize + 2.0f; const int boxesPerCol = static_cast(RigidBodyConstants::TerrainSize / boxSizeWithSpacing) - 1; int spawnColIdx = 0; @@ -399,7 +398,7 @@ namespace PhysX::Benchmarks return rand.GetRandomFloat() * 25.0f + 5.0f; }; - Utils::GenerateEntityIdFuncPtr entityIdGenerator = [&rand](int idx) -> AZ::EntityId { + Utils::GenerateEntityIdFuncPtr entityIdGenerator = [](int idx) -> AZ::EntityId { return AZ::EntityId(static_cast(idx) + RigidBodyConstants::RigidBodys::RigidBodyEntityIdStart); }; auto boxShapeConfiguration = AZStd::make_shared(AZ::Vector3(RigidBodyConstants::RigidBodys::BoxSize)); diff --git a/Gems/PhysX/Code/Tests/CharacterControllerTests.cpp b/Gems/PhysX/Code/Tests/CharacterControllerTests.cpp index 53a7e20be6..c4cb4cc4ad 100644 --- a/Gems/PhysX/Code/Tests/CharacterControllerTests.cpp +++ b/Gems/PhysX/Code/Tests/CharacterControllerTests.cpp @@ -247,7 +247,6 @@ namespace PhysX for (int i = 0; i < 50; i++) { basis.Update(desiredVelocity); - AZ::Vector3 velocity = basis.m_controller->GetVelocity(); EXPECT_TRUE(basis.m_controller->GetVelocity().IsClose(AZ::Vector3::CreateZero())); } @@ -260,7 +259,6 @@ namespace PhysX for (int i = 0; i < 50; i++) { basis.Update(desiredVelocity); - AZ::Vector3 velocity = basis.m_controller->GetVelocity(); EXPECT_TRUE(basis.m_controller->GetVelocity().IsClose(desiredVelocity)); } } diff --git a/Gems/PhysX/Code/Tests/PhysXMultithreadingTest.cpp b/Gems/PhysX/Code/Tests/PhysXMultithreadingTest.cpp index cb200113bb..a0013402b1 100644 --- a/Gems/PhysX/Code/Tests/PhysXMultithreadingTest.cpp +++ b/Gems/PhysX/Code/Tests/PhysXMultithreadingTest.cpp @@ -140,11 +140,9 @@ namespace PhysX Log_Help(m_threadDesc.m_name, "Thread %d - sleeping for %dms\n", AZStd::this_thread::get_id(), m_waitTimeMilliseconds); AZStd::this_thread::sleep_for(AZStd::chrono::milliseconds(m_waitTimeMilliseconds)); Log_Help(m_threadDesc.m_name, "Thread %d - running cast\n", AZStd::this_thread::get_id()); - AZStd::chrono::system_clock::time_point startTime = AZStd::chrono::system_clock::now(); RunRequest(); - AZStd::chrono::microseconds exeTimeUS = AZStd::chrono::system_clock::now() - startTime; Log_Help(m_threadDesc.m_name, "Thread %d - complete - time %dus\n", AZStd::this_thread::get_id(), exeTimeUS.count()); } diff --git a/Gems/PhysX/Code/Tests/PhysXSceneQueryTests.cpp b/Gems/PhysX/Code/Tests/PhysXSceneQueryTests.cpp index caacf5dce2..48ae2e37d7 100644 --- a/Gems/PhysX/Code/Tests/PhysXSceneQueryTests.cpp +++ b/Gems/PhysX/Code/Tests/PhysXSceneQueryTests.cpp @@ -737,11 +737,11 @@ namespace PhysX auto* sceneInterface = AZ::Interface::Get(); //setup bodies - AzPhysics::SimulatedBodyHandle sphereHandle = TestUtils::AddSphereToScene(m_testSceneHandle, + TestUtils::AddSphereToScene(m_testSceneHandle, AZ::Vector3(10.0f, 0.0f, 0.0f), 3.0f); AzPhysics::SimulatedBodyHandle boxHandle = TestUtils::AddBoxToScene(m_testSceneHandle, AZ::Vector3(7.0f, 4.0f, 0.0f), AZ::Vector3(1.0f)); - AzPhysics::SimulatedBodyHandle capsuleHandle = TestUtils::AddCapsuleToScene(m_testSceneHandle, + TestUtils::AddCapsuleToScene(m_testSceneHandle, AZ::Vector3(15.0f, 0.0f, 0.0f), 3.0f, 1.0f); //Create request @@ -769,11 +769,11 @@ namespace PhysX auto* sceneInterface = AZ::Interface::Get(); //setup bodies - AzPhysics::SimulatedBodyHandle sphereHandle = TestUtils::AddSphereToScene(m_testSceneHandle, + TestUtils::AddSphereToScene(m_testSceneHandle, AZ::Vector3(10.0f, 0.0f, 0.0f), 3.0f); AzPhysics::SimulatedBodyHandle boxHandle = TestUtils::AddBoxToScene(m_testSceneHandle, AZ::Vector3(7.0f, 4.0f, 0.0f), AZ::Vector3(1.0f)); - AzPhysics::SimulatedBodyHandle capsuleHandle = TestUtils::AddCapsuleToScene(m_testSceneHandle, + TestUtils::AddCapsuleToScene(m_testSceneHandle, AZ::Vector3(15.0f, 0.0f, 0.0f), 3.0f, 1.0f); //Box Overlap Request @@ -824,9 +824,9 @@ namespace PhysX auto* sceneInterface = AZ::Interface::Get(); //setup bodies - AzPhysics::SimulatedBodyHandle sphereHandle = TestUtils::AddSphereToScene(m_testSceneHandle, + TestUtils::AddSphereToScene(m_testSceneHandle, AZ::Vector3(10.0f, 0.0f, 0.0f), 3.0f); - AzPhysics::SimulatedBodyHandle boxHandle = TestUtils::AddBoxToScene(m_testSceneHandle, + TestUtils::AddBoxToScene(m_testSceneHandle, AZ::Vector3(7.0f, 4.0f, 0.0f), AZ::Vector3(1.0f)); AzPhysics::SimulatedBodyHandle capsuleHandle = TestUtils::AddCapsuleToScene(m_testSceneHandle, AZ::Vector3(15.0f, 0.0f, 0.0f), 3.0f, 1.0f); @@ -863,9 +863,9 @@ namespace PhysX //setup bodies AzPhysics::SimulatedBodyHandle sphereHandle = TestUtils::AddSphereToScene(m_testSceneHandle, AZ::Vector3(10.0f, 0.0f, 0.0f), 3.0f, AzPhysics::CollisionLayer(0)); - AzPhysics::SimulatedBodyHandle boxHandle = TestUtils::AddBoxToScene(m_testSceneHandle, + TestUtils::AddBoxToScene(m_testSceneHandle, AZ::Vector3(12.0f, 0.0f, 0.0f), AZ::Vector3(1.0f), AzPhysics::CollisionLayer(1)); - AzPhysics::SimulatedBodyHandle capsuleHandle = TestUtils::AddCapsuleToScene(m_testSceneHandle, + TestUtils::AddCapsuleToScene(m_testSceneHandle, AZ::Vector3(14.0f, 0.0f, 0.0f), 3.0f, 1.0f, AzPhysics::CollisionLayer(2)); //Create Request diff --git a/Gems/PhysX/Code/Tests/PhysXSceneTests.cpp b/Gems/PhysX/Code/Tests/PhysXSceneTests.cpp index 5b90ef0004..7baaa34ab5 100644 --- a/Gems/PhysX/Code/Tests/PhysXSceneTests.cpp +++ b/Gems/PhysX/Code/Tests/PhysXSceneTests.cpp @@ -558,7 +558,7 @@ namespace PhysX // add a static simulated body - this is not expected to be reported as an active actor AzPhysics::StaticRigidBodyConfiguration staticConfig; staticConfig.m_colliderAndShapeData = shapeColliderData; - AzPhysics::SimulatedBodyHandle staticSphereHandle = sceneInterface->AddSimulatedBody(m_testSceneHandle, &staticConfig); + sceneInterface->AddSimulatedBody(m_testSceneHandle, &staticConfig); // add a rigid body - this is expect to be reported as an active actor AzPhysics::RigidBodyConfiguration rigidConfig; diff --git a/Gems/PhysX/Code/Tests/PhysXSpecificTest.cpp b/Gems/PhysX/Code/Tests/PhysXSpecificTest.cpp index 6e96db4db2..0c0eee3eb0 100644 --- a/Gems/PhysX/Code/Tests/PhysXSpecificTest.cpp +++ b/Gems/PhysX/Code/Tests/PhysXSpecificTest.cpp @@ -1126,7 +1126,7 @@ namespace PhysX return nullptr; }; - auto RemoveRigidBody = [this](AzPhysics::RigidBody*& rigidBody) + auto RemoveRigidBody = [](AzPhysics::RigidBody*& rigidBody) { auto* sceneInterface = AZ::Interface::Get(); if (rigidBody && sceneInterface) diff --git a/Gems/PhysX/Code/Tests/ShapeColliderComponentTests.cpp b/Gems/PhysX/Code/Tests/ShapeColliderComponentTests.cpp index e3c7d9acfb..cbaf4b4625 100644 --- a/Gems/PhysX/Code/Tests/ShapeColliderComponentTests.cpp +++ b/Gems/PhysX/Code/Tests/ShapeColliderComponentTests.cpp @@ -299,7 +299,6 @@ namespace PhysXEditorTests // the bounding box of the rigid body should reflect the dimensions of the cylinder set above AZ::Aabb aabb = staticBody->GetAabb(); - const float validDiameter = validRadius * 2.0f; // Check that the z positions of the bounding box match that of the cylinder EXPECT_NEAR(aabb.GetMin().GetZ(), -0.5f * validHeight, AZ::Constants::Tolerance); diff --git a/Gems/PhysX/Code/Tests/SystemComponentTest.cpp b/Gems/PhysX/Code/Tests/SystemComponentTest.cpp index cf9bbe3567..11c5e0a115 100644 --- a/Gems/PhysX/Code/Tests/SystemComponentTest.cpp +++ b/Gems/PhysX/Code/Tests/SystemComponentTest.cpp @@ -21,8 +21,6 @@ namespace PhysXEditorTests // Initialize new configs with some non-default values. const AZ::Vector3 newGravity(2.f, 5.f, 7.f); - const float newFixedTimeStep = 0.008f; - const float newMaxTimeStep = 0.034f; AzPhysics::SceneConfiguration newConfiguration; diff --git a/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderWorkerUtility.cpp b/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderWorkerUtility.cpp index af5e49bdeb..0853789b19 100644 --- a/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderWorkerUtility.cpp +++ b/Gems/ScriptCanvas/Code/Builder/ScriptCanvasBuilderWorkerUtility.cpp @@ -486,7 +486,6 @@ namespace ScriptCanvasBuilder AZ::Outcome ProcessTranslationJob(ProcessTranslationJobInput& input) { - const bool saveRawLua{ true }; auto sourceGraph = PrepareSourceGraph(input.buildEntity); auto version = sourceGraph->GetVersion(); @@ -651,11 +650,6 @@ namespace ScriptCanvasBuilder for (const auto& assetDependency : runtimeData.m_requiredAssets) { - auto filterScripts = [](const AZ::Data::Asset& asset) - { - return asset.GetType() != azrtti_typeid(); - }; - if (AZ::Data::AssetManager::Instance().GetAsset(assetDependency.GetId(), assetDependency.GetType(), AZ::Data::AssetLoadBehavior::PreLoad)) { jobProduct.m_dependencies.push_back({ assetDependency.GetId(), {} }); diff --git a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetHelpers.cpp b/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetHelpers.cpp index 554bb31b25..884fa2d5c9 100644 --- a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetHelpers.cpp +++ b/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetHelpers.cpp @@ -41,7 +41,6 @@ namespace ScriptCanvasEditor bool sourceInfoFound{}; AzToolsFramework::AssetSystemRequestBus::BroadcastResult(sourceInfoFound, &AzToolsFramework::AssetSystemRequestBus::Events::GetSourceInfoBySourcePath, fullPath.data(), catalogAssetInfo, watchFolder); - auto saveAssetId = sourceInfoFound ? catalogAssetInfo.m_assetId : AZ::Data::AssetId(AZ::Uuid::CreateRandom()); if (sourceInfoFound) { outAssetInfo = catalogAssetInfo; diff --git a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetHolder.cpp b/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetHolder.cpp index 5c62844e9f..a42a9bad48 100644 --- a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetHolder.cpp +++ b/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasAssetHolder.cpp @@ -67,7 +67,7 @@ namespace ScriptCanvasEditor { AssetTrackerNotificationBus::Handler::BusConnect(m_scriptCanvasAsset.GetId()); - Callbacks::OnAssetReadyCallback onAssetReady = [this](ScriptCanvasMemoryAsset& asset) + Callbacks::OnAssetReadyCallback onAssetReady = [](ScriptCanvasMemoryAsset& asset) { AssetHelpers::DumpAssetInfo(asset.GetFileAssetId(), "ScriptCanvasAssetHolder::Init"); }; diff --git a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasMemoryAsset.cpp b/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasMemoryAsset.cpp index e7dc2343f2..165007b79b 100644 --- a/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasMemoryAsset.cpp +++ b/Gems/ScriptCanvas/Code/Editor/Assets/ScriptCanvasMemoryAsset.cpp @@ -374,7 +374,6 @@ namespace ScriptCanvasEditor } else { - AZ::Data::AssetId assetId = asset.GetId(); Internal::MemoryAssetSystemNotificationBus::Broadcast(&Internal::MemoryAssetSystemNotifications::OnAssetReloaded, this); } } @@ -392,7 +391,6 @@ namespace ScriptCanvasEditor } else { - AZ::Data::AssetId assetId = asset.GetId(); Internal::MemoryAssetSystemNotificationBus::Broadcast(&Internal::MemoryAssetSystemNotifications::OnAssetError, this); } } @@ -505,7 +503,7 @@ namespace ScriptCanvasEditor m_pendingSave.emplace_back(normPath); m_assetSaveFinalizer.Reset(); - m_assetSaveFinalizer.Start(this, fileInfo, saveInfo, onSaveCallback, AssetSaveFinalizer::OnCompleteHandler([this, saveInfo](AZ::Data::AssetId /*assetId*/) + m_assetSaveFinalizer.Start(this, fileInfo, saveInfo, onSaveCallback, AssetSaveFinalizer::OnCompleteHandler([](AZ::Data::AssetId /*assetId*/) { })); } diff --git a/Gems/ScriptCanvas/Code/Editor/Components/EditorGraph.cpp b/Gems/ScriptCanvas/Code/Editor/Components/EditorGraph.cpp index 325c348d9c..1899951638 100644 --- a/Gems/ScriptCanvas/Code/Editor/Components/EditorGraph.cpp +++ b/Gems/ScriptCanvas/Code/Editor/Components/EditorGraph.cpp @@ -1034,16 +1034,9 @@ namespace ScriptCanvasEditor if (connection) { - ScriptCanvas::Endpoint scSourceEndpoint = connection->GetSourceEndpoint(); - GraphCanvas::Endpoint sourceEndpoint = ConvertToGraphCanvasEndpoint(scSourceEndpoint); - - ScriptCanvas::Endpoint scTargetEndpoint = connection->GetTargetEndpoint(); - GraphCanvas::Endpoint targetEndpoint = ConvertToGraphCanvasEndpoint(scTargetEndpoint); - ScriptCanvas::GraphNotificationBus::Event(GetScriptCanvasId(), &ScriptCanvas::GraphNotifications::OnDisonnectionComplete, connectionId); DisconnectById(scConnectionId); - } } @@ -2666,8 +2659,6 @@ namespace ScriptCanvasEditor AZStd::vector< GraphCanvas::SlotId > slotIds; GraphCanvas::NodeRequestBus::EventResult(slotIds, nodeId, &GraphCanvas::NodeRequests::GetSlotIds); - GraphCanvas::GraphId graphCanvasGraphId = GetGraphCanvasGraphId(); - for (const GraphCanvas::SlotId& slotId : slotIds) { GraphCanvas::SlotType slotType = GraphCanvas::SlotTypes::Invalid; diff --git a/Gems/ScriptCanvas/Code/Editor/Nodes/NodeDisplayUtils.cpp b/Gems/ScriptCanvas/Code/Editor/Nodes/NodeDisplayUtils.cpp index b9e96938af..8d616f0a68 100644 --- a/Gems/ScriptCanvas/Code/Editor/Nodes/NodeDisplayUtils.cpp +++ b/Gems/ScriptCanvas/Code/Editor/Nodes/NodeDisplayUtils.cpp @@ -744,7 +744,6 @@ namespace ScriptCanvasEditor::Nodes return graphCanvasNodeId; } - auto busId = senderNode->GetBusSlotId(); for (const auto& slot : senderNode->GetSlots()) { if (slot.IsVisible()) diff --git a/Gems/ScriptCanvas/Code/Editor/Nodes/NodeUtils.cpp b/Gems/ScriptCanvas/Code/Editor/Nodes/NodeUtils.cpp index 000dafed88..3c5e74cbeb 100644 --- a/Gems/ScriptCanvas/Code/Editor/Nodes/NodeUtils.cpp +++ b/Gems/ScriptCanvas/Code/Editor/Nodes/NodeUtils.cpp @@ -14,27 +14,6 @@ #include -namespace -{ - ScriptCanvas::ConnectionType ToScriptCanvasConnectionType(GraphCanvas::ConnectionType connectionType) - { - ScriptCanvas::ConnectionType scriptCanvasConnectionType = ScriptCanvas::ConnectionType::Unknown; - switch (connectionType) - { - case GraphCanvas::CT_Input: - scriptCanvasConnectionType = ScriptCanvas::ConnectionType::Input; - break; - case GraphCanvas::CT_Output: - scriptCanvasConnectionType = ScriptCanvas::ConnectionType::Output; - break; - default: - break; - } - - return scriptCanvasConnectionType; - } -} - namespace ScriptCanvasEditor::Nodes { void CopyTranslationKeyedNameToDatumLabel(const AZ::EntityId& graphCanvasNodeId, diff --git a/Gems/ScriptCanvas/Code/Editor/SystemComponent.cpp b/Gems/ScriptCanvas/Code/Editor/SystemComponent.cpp index b80bba75c2..4b60fd357c 100644 --- a/Gems/ScriptCanvas/Code/Editor/SystemComponent.cpp +++ b/Gems/ScriptCanvas/Code/Editor/SystemComponent.cpp @@ -332,7 +332,7 @@ namespace ScriptCanvasEditor if (isScriptCanvasAsset) { - auto scriptCanvasEditorCallback = [this]([[maybe_unused]] const char* fullSourceFileNameInCall, const AZ::Uuid& sourceUUIDInCall) + auto scriptCanvasEditorCallback = []([[maybe_unused]] const char* fullSourceFileNameInCall, const AZ::Uuid& sourceUUIDInCall) { AZ::Outcome openOutcome = AZ::Failure(AZStd::string()); const SourceAssetBrowserEntry* fullDetails = SourceAssetBrowserEntry::GetSourceByUuid(sourceUUIDInCall); diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/LoggingPanel/PivotTree/PivotTreeWidget.cpp b/Gems/ScriptCanvas/Code/Editor/View/Widgets/LoggingPanel/PivotTree/PivotTreeWidget.cpp index 7a84fc3965..a34b42bed8 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/LoggingPanel/PivotTree/PivotTreeWidget.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/LoggingPanel/PivotTree/PivotTreeWidget.cpp @@ -14,7 +14,7 @@ // Disable warnings in moc code AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") #include -AZ_POP_DISABLE_OVERRIDE_WARNING +AZ_POP_DISABLE_WARNING namespace ScriptCanvasEditor { diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/NodePalette/NodePaletteModel.cpp b/Gems/ScriptCanvas/Code/Editor/View/Widgets/NodePalette/NodePaletteModel.cpp index 0949daa458..38def487e6 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/NodePalette/NodePaletteModel.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/NodePalette/NodePaletteModel.cpp @@ -87,16 +87,6 @@ namespace return AZ::FindAttribute(attribute, method->m_attributes) != nullptr; // warning C4800: 'AZ::Attribute *': forcing value to bool 'true' or 'false' (performance warning) } - bool HasAttribute(const AZ::BehaviorClass* behaviorClass, AZ::Crc32 attributeCrc) - { - AZ::Attribute* attribute = AZ::FindAttribute(attributeCrc, behaviorClass->m_attributes); - if (attribute) - { - return true; - } - return false; - } - // Checks for and returns the Category attribute from an AZ::AttributeArray AZStd::string GetCategoryPath(const AZ::AttributeArray& attributes, const AZ::BehaviorContext& behaviorContext) { diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/NodeUsageTreeItem.cpp b/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/NodeUsageTreeItem.cpp index ddcdaad161..4dce7ce384 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/NodeUsageTreeItem.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/StatisticsDialog/NodeUsageTreeItem.cpp @@ -152,8 +152,6 @@ namespace ScriptCanvasEditor m_assetType = assetType; - const bool loadBlocking = false; - auto onAssetReady = [](ScriptCanvasMemoryAsset&) {}; AssetTrackerRequestBus::Broadcast(&AssetTrackerRequests::Load, m_assetId, m_assetType, onAssetReady); } diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/ValidationPanel/GraphValidationDockWidget.cpp b/Gems/ScriptCanvas/Code/Editor/View/Widgets/ValidationPanel/GraphValidationDockWidget.cpp index 3400f2ea66..ded0130001 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/ValidationPanel/GraphValidationDockWidget.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/ValidationPanel/GraphValidationDockWidget.cpp @@ -810,7 +810,6 @@ namespace ScriptCanvasEditor const ScriptCanvas::ValidationEvent* validationEvent = model->FindItemForIndex(m_proxyModel->mapToSource(modelIndex)); AZ::EntityId graphCanvasMemberId; - QRectF focusArea; if (const ScriptCanvas::FocusOnEntityEffect* focusOnEntityEffect = azrtti_cast(validationEvent)) { diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/VariablePanel/VariableDockWidget.cpp b/Gems/ScriptCanvas/Code/Editor/View/Widgets/VariablePanel/VariableDockWidget.cpp index 60bc7ba0d2..eb2f92f42c 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/VariablePanel/VariableDockWidget.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/VariablePanel/VariableDockWidget.cpp @@ -258,7 +258,7 @@ namespace ScriptCanvasEditor QObject::connect(pasteAction, &QAction::triggered, - [dockWidget, varId](bool) + [dockWidget](bool) { GraphVariablesTableView::HandleVariablePaste(dockWidget->GetActiveScriptCanvasId()); }); diff --git a/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.cpp b/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.cpp index 87bf4cf23c..f4241e3545 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Windows/MainWindow.cpp @@ -323,14 +323,13 @@ namespace ScriptCanvasEditor m_mainWindow->OnWorkspaceRestoreStart(); } - AZ::Data::AssetId focusedAsset = workspace->GetFocusedAssetId(); m_queuedAssetFocus = workspace->GetFocusedAssetId(); for (const auto& assetSaveData : workspace->GetActiveAssetData()) { AssetTrackerNotificationBus::MultiHandler::BusConnect(assetSaveData.m_assetId); - Callbacks::OnAssetReadyCallback onAssetReady = [this, focusedAsset, assetSaveData](ScriptCanvasMemoryAsset& asset) + Callbacks::OnAssetReadyCallback onAssetReady = [this, assetSaveData](ScriptCanvasMemoryAsset& asset) { // If we get an error callback. Just remove it from out active lists. if (asset.IsSourceInError()) @@ -1020,7 +1019,7 @@ namespace ScriptCanvasEditor if (shouldSaveResults == UnsavedChangesOptions::SAVE) { - Callbacks::OnSave saveCB = [this, assetId](bool isSuccessful, AZ::Data::AssetPtr, AZ::Data::AssetId) + Callbacks::OnSave saveCB = [this](bool isSuccessful, AZ::Data::AssetPtr, AZ::Data::AssetId) { if (isSuccessful) { @@ -1610,7 +1609,7 @@ namespace ScriptCanvasEditor return; } - Callbacks::OnAssetReadyCallback onAssetReady = [this, fullPath, assetInfo](ScriptCanvasMemoryAsset&) + Callbacks::OnAssetReadyCallback onAssetReady = [this, assetInfo](ScriptCanvasMemoryAsset&) { ScriptCanvasMemoryAsset::pointer memoryAsset; AssetTrackerRequestBus::BroadcastResult(memoryAsset, &AssetTrackerRequests::GetAsset, assetInfo.m_assetId); @@ -2527,7 +2526,6 @@ namespace ScriptCanvasEditor void MainWindow::UpdateWorkspaceStatus(const ScriptCanvasMemoryAsset& memoryAsset) { AZ::Data::AssetId fileAssetId = memoryAsset.GetFileAssetId(); - AZ::Data::AssetId memoryAssetId = memoryAsset.GetId(); size_t eraseCount = m_loadingAssets.erase(fileAssetId); diff --git a/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/UpgradeTool.cpp b/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/UpgradeTool.cpp index e069c509ce..3d42fdad42 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/UpgradeTool.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/UpgradeTool.cpp @@ -437,7 +437,7 @@ namespace ScriptCanvasEditor auto streamer = AZ::Interface::Get(); AZ::IO::FileRequestPtr flushRequest = streamer->FlushCache(assetToUpgrade.m_relativePath); - streamer->SetRequestCompleteCallback(flushRequest, [this]([[maybe_unused]] AZ::IO::FileRequestHandle request) + streamer->SetRequestCompleteCallback(flushRequest, []([[maybe_unused]] AZ::IO::FileRequestHandle request) { }); streamer->QueueRequest(flushRequest); diff --git a/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/VersionExplorer.cpp b/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/VersionExplorer.cpp index efa7aded40..738cfd8d22 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/VersionExplorer.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Windows/Tools/UpgradeTool/VersionExplorer.cpp @@ -762,7 +762,7 @@ namespace ScriptCanvasEditor rowGoToButton->setEnabled(false); m_inProgressAsset = AZStd::find_if(m_assetsToUpgrade.begin(), m_assetsToUpgrade.end() - , [this, asset](const UpgradeAssets::value_type& assetToUpgrade) + , [asset](const UpgradeAssets::value_type& assetToUpgrade) { return assetToUpgrade.GetId() == asset.GetId(); }); @@ -848,7 +848,6 @@ namespace ScriptCanvasEditor const QTextCursor oldCursor = m_ui->textEdit->textCursor(); QScrollBar* scrollBar = m_ui->textEdit->verticalScrollBar(); - const int oldScrollValue = scrollBar->value(); m_ui->textEdit->moveCursor(QTextCursor::End); QTextCursor textCursor = m_ui->textEdit->textCursor(); diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Core.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Core.cpp index a5e73005c1..c45dc01c35 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Core.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Core.cpp @@ -54,8 +54,6 @@ namespace ScriptCanvas auto lhsIter = lhs.begin(); auto rhsIter = rhs.begin(); - const bool isCaseSensitive = false; - for (; lhsIter != lhs.end(); ++lhsIter, ++rhsIter) { if (!AZ::StringFunc::Equal(lhsIter->c_str(), rhsIter->c_str())) diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Node.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Node.cpp index 4b9113d39c..059b560cb0 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Node.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Node.cpp @@ -1467,8 +1467,6 @@ namespace ScriptCanvas return slot.GetDataType(); } - Endpoint endpoint = slot.GetEndpoint(); - auto connectedNodes = GetConnectedNodes(slot); for (auto endpointPair : connectedNodes) diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/NodeFunctionGeneric.h b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/NodeFunctionGeneric.h index 90acd4fdc9..cb6c4bf942 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/NodeFunctionGeneric.h +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/NodeFunctionGeneric.h @@ -80,9 +80,7 @@ namespace ScriptCanvas using ResultType = FunctionTraits::result_type;\ static const size_t s_numArgs = FunctionTraits::arity;\ static const size_t s_numNames = SCRIPT_CANVAS_FUNCTION_VAR_ARGS(__VA_ARGS__);\ - static const size_t s_argsSlotIndicesStart = 2;\ - static const size_t s_resultsSlotIndicesStart = s_argsSlotIndicesStart + s_numArgs;\ - static const size_t s_numResults = ScriptCanvas::Internal::extended_tuple_size::value;\ + /*static const size_t s_numResults = ScriptCanvas::Internal::extended_tuple_size::value;*/\ \ static const char* GetArgName(size_t i)\ {\ @@ -150,7 +148,7 @@ namespace ScriptCanvas { static int indices[] = { inputDatumIndices... }; static_assert(sizeof...(Is) == AZ_ARRAY_SIZE(indices), "size of default values doesn't match input datum indices for them"); - std::initializer_list { (MoreHelp(node, indices[Is], AZStd::forward(args)), 0)... }; + [[maybe_unused]] std::initializer_list dummy = { (MoreHelp(node, indices[Is], AZStd::forward(args)), 0)... }; } template diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/SubgraphInterfaceUtility.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/SubgraphInterfaceUtility.cpp index d8cdbc7585..74a41eb2c6 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/SubgraphInterfaceUtility.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/SubgraphInterfaceUtility.cpp @@ -13,7 +13,6 @@ namespace SubgraphInterfaceUtilityCpp { - const constexpr size_t k_uniqueOutIndex = 0; const constexpr size_t k_signatureIndex = 1; const constexpr AZ::u64 k_defaultOutIdSignature = 0x3ACF20E73ACF20E7ull; diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Execution/Interpreted/ExecutionInterpretedAPI.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Execution/Interpreted/ExecutionInterpretedAPI.cpp index e01a3a0e7a..cc2058f249 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Execution/Interpreted/ExecutionInterpretedAPI.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Execution/Interpreted/ExecutionInterpretedAPI.cpp @@ -34,8 +34,6 @@ namespace ExecutionInterpretedAPICpp constexpr size_t k_StringFastSize = 32; - constexpr size_t k_MaxNodeableOuts = 64; - constexpr size_t k_UuidSize = 16; constexpr unsigned char k_Bad = 77; diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Grammar/ParsingUtilities.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Grammar/ParsingUtilities.cpp index caae465964..dc33e6bae6 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Grammar/ParsingUtilities.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Grammar/ParsingUtilities.cpp @@ -707,8 +707,6 @@ namespace ScriptCanvas return false; } - auto id = execution->GetId(); - if (ActivatesSelf(execution)) { return true; diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Grammar/Primitives.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Grammar/Primitives.cpp index ee7c1ee2d2..59f12481e7 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Grammar/Primitives.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Grammar/Primitives.cpp @@ -55,7 +55,6 @@ namespace ScriptCanvas AZStd::vector tokens; AzFramework::StringFunc::Tokenize(name, tokens, Grammar::k_luaSpecialCharacters); AZStd::string joinResult; - const size_t length = tokens.size(); for (auto& token : tokens) { joinResult.append(token); diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Core/FunctionDefinitionNode.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Core/FunctionDefinitionNode.cpp index 071528d5b4..6cda0b75dd 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Core/FunctionDefinitionNode.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Core/FunctionDefinitionNode.cpp @@ -166,7 +166,7 @@ namespace ScriptCanvas } }, { - [this]() + []() { DisallowReentrantExecutionContract* reentrantContract = aznew DisallowReentrantExecutionContract(); return reentrantContract; diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Core/ReceiveScriptEvent.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Core/ReceiveScriptEvent.cpp index 8a86347aa3..b874077834 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Core/ReceiveScriptEvent.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Core/ReceiveScriptEvent.cpp @@ -86,7 +86,6 @@ namespace ScriptCanvas if (!wasConfigured) { - AZ::Uuid addressTypeId = m_definition.GetAddressType(); AZ::Uuid addressId = m_definition.GetAddressTypeProperty().GetId(); if (m_definition.IsAddressRequired()) diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Logic/Sequencer.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Logic/Sequencer.cpp index 2033f92430..c889c6ca17 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Logic/Sequencer.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Logic/Sequencer.cpp @@ -16,8 +16,6 @@ namespace ScriptCanvas { namespace Logic { - static const int NUMBER_OF_OUTPUTS = 8; - Sequencer::Sequencer() : Node() , m_selectedIndex(0) diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Operators/Containers/OperatorAt.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Operators/Containers/OperatorAt.cpp index 868ad34650..e44fd0b1f1 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Operators/Containers/OperatorAt.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Operators/Containers/OperatorAt.cpp @@ -23,7 +23,7 @@ namespace ScriptCanvas if (sourceType == SourceType::SourceInput) { ContractDescriptor supportsMethodContract; - supportsMethodContract.m_createFunc = [this]() -> SupportsMethodContract* { return aznew SupportsMethodContract("At"); }; + supportsMethodContract.m_createFunc = []() -> SupportsMethodContract* { return aznew SupportsMethodContract("At"); }; contractDescs.push_back(AZStd::move(supportsMethodContract)); } } diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Operators/Containers/OperatorBack.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Operators/Containers/OperatorBack.cpp index e665d145e9..66d33d4c8f 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Operators/Containers/OperatorBack.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Operators/Containers/OperatorBack.cpp @@ -23,7 +23,7 @@ namespace ScriptCanvas if (sourceType == SourceType::SourceInput) { ContractDescriptor supportsMethodContract; - supportsMethodContract.m_createFunc = [this]() -> SupportsMethodContract* { return aznew SupportsMethodContract("Back"); }; + supportsMethodContract.m_createFunc = []() -> SupportsMethodContract* { return aznew SupportsMethodContract("Back"); }; contractDescs.push_back(AZStd::move(supportsMethodContract)); } } diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Operators/Containers/OperatorErase.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Operators/Containers/OperatorErase.cpp index adcf8c4ff8..ebb7a8233a 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Operators/Containers/OperatorErase.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Operators/Containers/OperatorErase.cpp @@ -59,7 +59,7 @@ namespace ScriptCanvas if (sourceType == SourceType::SourceInput) { ContractDescriptor supportsMethodContract; - supportsMethodContract.m_createFunc = [this]() -> SupportsMethodContract* { return aznew SupportsMethodContract("Erase"); }; + supportsMethodContract.m_createFunc = []() -> SupportsMethodContract* { return aznew SupportsMethodContract("Erase"); }; contractDescs.push_back(AZStd::move(supportsMethodContract)); } } diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Operators/Containers/OperatorFront.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Operators/Containers/OperatorFront.cpp index 15f80896cd..d83711adbe 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Operators/Containers/OperatorFront.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Operators/Containers/OperatorFront.cpp @@ -23,7 +23,7 @@ namespace ScriptCanvas if (sourceType == SourceType::SourceInput) { ContractDescriptor supportsMethodContract; - supportsMethodContract.m_createFunc = [this]() -> SupportsMethodContract* { return aznew SupportsMethodContract("Front"); }; + supportsMethodContract.m_createFunc = []() -> SupportsMethodContract* { return aznew SupportsMethodContract("Front"); }; contractDescs.push_back(AZStd::move(supportsMethodContract)); } } diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Operators/Containers/OperatorInsert.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Operators/Containers/OperatorInsert.cpp index 30efece944..7374b3442f 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Operators/Containers/OperatorInsert.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Operators/Containers/OperatorInsert.cpp @@ -21,7 +21,7 @@ namespace ScriptCanvas if (sourceType == SourceType::SourceInput) { ContractDescriptor supportsMethodContract; - supportsMethodContract.m_createFunc = [this]() -> SupportsMethodContract* { return aznew SupportsMethodContract("Insert"); }; + supportsMethodContract.m_createFunc = []() -> SupportsMethodContract* { return aznew SupportsMethodContract("Insert"); }; contractDescs.push_back(AZStd::move(supportsMethodContract)); } } diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Operators/Containers/OperatorPushBack.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Operators/Containers/OperatorPushBack.cpp index 04f6b0756e..5793d06aec 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Operators/Containers/OperatorPushBack.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Operators/Containers/OperatorPushBack.cpp @@ -21,7 +21,7 @@ namespace ScriptCanvas if (sourceType == SourceType::SourceInput) { ContractDescriptor supportsMethodContract; - supportsMethodContract.m_createFunc = [this]() -> SupportsMethodContract* { return aznew SupportsMethodContract("PushBack"); }; + supportsMethodContract.m_createFunc = []() -> SupportsMethodContract* { return aznew SupportsMethodContract("PushBack"); }; contractDescs.push_back(AZStd::move(supportsMethodContract)); } } diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Spawning/SpawnNodeable.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Spawning/SpawnNodeable.cpp index d11e916d42..e28ed9dce8 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Spawning/SpawnNodeable.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Spawning/SpawnNodeable.cpp @@ -101,7 +101,7 @@ namespace ScriptCanvas::Nodeables::Spawning return; } - auto preSpawnCB = [this, translation, rotation, scale]([[maybe_unused]] AzFramework::EntitySpawnTicket::Id ticketId, + auto preSpawnCB = [translation, rotation, scale]([[maybe_unused]] AzFramework::EntitySpawnTicket::Id ticketId, AzFramework::SpawnableEntityContainerView view) { AZ::Entity* rootEntity = *view.begin(); diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Variable/VariableData.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Variable/VariableData.cpp index 7474ebbf35..9869602c84 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Variable/VariableData.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Variable/VariableData.cpp @@ -144,7 +144,6 @@ namespace ScriptCanvas GraphVariable* VariableData::FindVariable(VariableId variableId) { - AZStd::pair resultPair; auto foundIt = m_variableMap.find(variableId); return foundIt != m_variableMap.end() ? &foundIt->second : nullptr; } diff --git a/Gems/ScriptCanvas/Code/Source/PerformanceStatistician.cpp b/Gems/ScriptCanvas/Code/Source/PerformanceStatistician.cpp index e5a5b3cd19..826490e487 100644 --- a/Gems/ScriptCanvas/Code/Source/PerformanceStatistician.cpp +++ b/Gems/ScriptCanvas/Code/Source/PerformanceStatistician.cpp @@ -104,7 +104,6 @@ namespace ScriptCanvas void PerformanceStatistician::OnStartTrackingRequested() { m_accumulatedStats.tickCount = 0; - m_accumulatedTickCountRemaining; m_accumulatedStartTime = AZStd::chrono::system_clock::now(); } diff --git a/Gems/ScriptCanvasDeveloper/Code/Editor/Include/ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/UtilityStates.h b/Gems/ScriptCanvasDeveloper/Code/Editor/Include/ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/UtilityStates.h index e6cdf0e390..429331e054 100644 --- a/Gems/ScriptCanvasDeveloper/Code/Editor/Include/ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/UtilityStates.h +++ b/Gems/ScriptCanvasDeveloper/Code/Editor/Include/ScriptCanvasDeveloperEditor/EditorAutomation/EditorAutomationStates/UtilityStates.h @@ -139,7 +139,6 @@ namespace ScriptCanvasDeveloper void OnStateActionsComplete() override; private: - int m_row = 0; int m_rowCount = 0; MoveMouseToViewRowAction* m_mouseToRow = nullptr; diff --git a/Gems/ScriptCanvasDeveloper/Code/Editor/Source/AutomationActions/NodePaletteFullCreation.cpp b/Gems/ScriptCanvasDeveloper/Code/Editor/Source/AutomationActions/NodePaletteFullCreation.cpp index 35dc250a33..3a66aefe6b 100644 --- a/Gems/ScriptCanvasDeveloper/Code/Editor/Source/AutomationActions/NodePaletteFullCreation.cpp +++ b/Gems/ScriptCanvasDeveloper/Code/Editor/Source/AutomationActions/NodePaletteFullCreation.cpp @@ -92,8 +92,6 @@ namespace ScriptCanvasDeveloperEditor int m_heightOffset = 0; int m_maxRowHeight = 0; - - int creationCounter = 100; }; void NodePaletteFullCreationAction() diff --git a/Gems/ScriptCanvasDeveloper/Code/Editor/Source/EditorAutomation/EditorAutomationActions/EditorMouseActions.cpp b/Gems/ScriptCanvasDeveloper/Code/Editor/Source/EditorAutomation/EditorAutomationActions/EditorMouseActions.cpp index cf757af1ec..0ef306f638 100644 --- a/Gems/ScriptCanvasDeveloper/Code/Editor/Source/EditorAutomation/EditorAutomationActions/EditorMouseActions.cpp +++ b/Gems/ScriptCanvasDeveloper/Code/Editor/Source/EditorAutomation/EditorAutomationActions/EditorMouseActions.cpp @@ -155,7 +155,6 @@ namespace ScriptCanvasDeveloper m_startPosition = QCursor::pos(); } - QPointF currentPosition = QCursor::pos(); QPointF targetPoint = m_targetPosition; float percentage = aznumeric_cast(m_tickCount)/aznumeric_cast(m_tickDuration); @@ -170,6 +169,7 @@ namespace ScriptCanvasDeveloper #if defined(AZ_COMPILER_MSVC) INPUT osInput = { 0 }; + QPointF currentPosition = QCursor::pos(); osInput.type = INPUT_MOUSE; osInput.mi.mouseData = 0; diff --git a/Gems/ScriptCanvasDeveloper/Code/Editor/Source/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/VariableActions.cpp b/Gems/ScriptCanvasDeveloper/Code/Editor/Source/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/VariableActions.cpp index d46f52bfdf..72203f6710 100644 --- a/Gems/ScriptCanvasDeveloper/Code/Editor/Source/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/VariableActions.cpp +++ b/Gems/ScriptCanvasDeveloper/Code/Editor/Source/EditorAutomation/EditorAutomationActions/ScriptCanvasActions/VariableActions.cpp @@ -275,7 +275,6 @@ namespace ScriptCanvasDeveloper } QRegion region = m_graphPalette->visibleRegion(); - QRect boundingRegion = region.boundingRect(); m_indexIsVisible = region.contains(m_graphPalette->visualRect(m_displayIndex).center()); } diff --git a/Gems/ScriptCanvasDeveloper/Code/Editor/Source/EditorAutomation/EditorAutomationStates/UtilityStates.cpp b/Gems/ScriptCanvasDeveloper/Code/Editor/Source/EditorAutomation/EditorAutomationStates/UtilityStates.cpp index 459dc82542..6b0636fbdd 100644 --- a/Gems/ScriptCanvasDeveloper/Code/Editor/Source/EditorAutomation/EditorAutomationStates/UtilityStates.cpp +++ b/Gems/ScriptCanvasDeveloper/Code/Editor/Source/EditorAutomation/EditorAutomationStates/UtilityStates.cpp @@ -187,7 +187,6 @@ namespace ScriptCanvasDeveloper DeleteVariableRowFromPaletteState::DeleteVariableRowFromPaletteState(int row) : NamedAutomationState("DeleteVariableRowFromPaletteState") - , m_row(row) , m_clickAction(Qt::MouseButton::LeftButton) , m_deleteAction(VK_DELETE) { diff --git a/Gems/ScriptCanvasDeveloper/Code/Editor/Source/EditorAutomationTestDialog.h b/Gems/ScriptCanvasDeveloper/Code/Editor/Source/EditorAutomationTestDialog.h index 0284e2588e..84597a991c 100644 --- a/Gems/ScriptCanvasDeveloper/Code/Editor/Source/EditorAutomationTestDialog.h +++ b/Gems/ScriptCanvasDeveloper/Code/Editor/Source/EditorAutomationTestDialog.h @@ -133,7 +133,5 @@ namespace ScriptCanvasDeveloper QLabel* m_errorTestLabel = nullptr; QLabel* m_runLabel = nullptr; QMainWindow* m_scriptCanvasWindow = nullptr; - - QWindow* m_canvasWindow = nullptr; }; } diff --git a/Gems/ScriptCanvasDeveloper/Code/Editor/Source/EditorAutomationTests/VariableTests.cpp b/Gems/ScriptCanvasDeveloper/Code/Editor/Source/EditorAutomationTests/VariableTests.cpp index 860d9af27a..c259a626ee 100644 --- a/Gems/ScriptCanvasDeveloper/Code/Editor/Source/EditorAutomationTests/VariableTests.cpp +++ b/Gems/ScriptCanvasDeveloper/Code/Editor/Source/EditorAutomationTests/VariableTests.cpp @@ -669,7 +669,6 @@ namespace ScriptCanvasDeveloper VariableLifeCycleTest::VariableLifeCycleTest(AZStd::string name, AZStd::vector dataTypes, CreateVariableAction::CreationType creationType) : EditorAutomationTest(name.c_str()) - , m_creationType(creationType) , m_typesToMake(dataTypes) { m_variableTypeId = "ActiveVariableTypeId"; diff --git a/Gems/ScriptCanvasDeveloper/Code/Editor/Source/EditorAutomationTests/VariableTests.h b/Gems/ScriptCanvasDeveloper/Code/Editor/Source/EditorAutomationTests/VariableTests.h index d4438d222a..252227cf17 100644 --- a/Gems/ScriptCanvasDeveloper/Code/Editor/Source/EditorAutomationTests/VariableTests.h +++ b/Gems/ScriptCanvasDeveloper/Code/Editor/Source/EditorAutomationTests/VariableTests.h @@ -256,14 +256,11 @@ namespace ScriptCanvasDeveloper int SetupNextVariable(); - CreateVariableAction::CreationType m_creationType = CreateVariableAction::CreationType::AutoComplete; - ScriptCanvas::VariableId m_activeVariableId; AZStd::vector m_createVariables; AZStd::vector m_typesToMake; bool m_createVariablesNodesViaContextMenu = true; - bool m_closedGraph = false; int m_activeIndex = 0; GraphCanvas::ViewId m_viewId; diff --git a/Gems/ScriptCanvasDeveloper/Code/Editor/Source/WrapperMock.cpp b/Gems/ScriptCanvasDeveloper/Code/Editor/Source/WrapperMock.cpp index f26c36573c..6663a7a5cd 100644 --- a/Gems/ScriptCanvasDeveloper/Code/Editor/Source/WrapperMock.cpp +++ b/Gems/ScriptCanvasDeveloper/Code/Editor/Source/WrapperMock.cpp @@ -67,7 +67,6 @@ namespace ScriptCanvasDeveloper ScriptCanvasEditor::NodeIdPair nodePair; - const AZ::Vector2 scenePointVec2 = AZ::Vector2(aznumeric_cast(scenePoint.x()), aznumeric_cast(scenePoint.y())); if (result == addMock) { ScriptCanvasEditor::EditorGraphRequestBus::EventResult(nodePair, scriptCanvasId, &ScriptCanvasEditor::EditorGraphRequests::CreateCustomNode, azrtti_typeid(), AZ::Vector2(aznumeric_cast(scenePoint.x()), aznumeric_cast(scenePoint.y()))); diff --git a/Gems/ScriptCanvasPhysics/Code/Tests/ScriptCanvasPhysicsTest.cpp b/Gems/ScriptCanvasPhysics/Code/Tests/ScriptCanvasPhysicsTest.cpp index 14eb69d669..ac6109ce30 100644 --- a/Gems/ScriptCanvasPhysics/Code/Tests/ScriptCanvasPhysicsTest.cpp +++ b/Gems/ScriptCanvasPhysics/Code/Tests/ScriptCanvasPhysicsTest.cpp @@ -313,7 +313,6 @@ namespace ScriptCanvasPhysicsTests .WillByDefault(Return(m_hitResult)); // given raycast data - const AZ::Vector3 start = AZ::Vector3::CreateZero(); const AZ::Vector3 direction = AZ::Vector3(0.f,1.f,0.f); const float distance = 1.f; const AZStd::string collisionGroup = "default"; @@ -346,7 +345,6 @@ namespace ScriptCanvasPhysicsTests .WillByDefault(Return(m_hitResult)); // given raycast data - const AZ::Vector3 start = AZ::Vector3::CreateZero(); const AZ::Vector3 direction = AZ::Vector3(0.f,1.f,0.f); const float distance = 1.f; const AZStd::string collisionGroup = "default"; @@ -385,7 +383,6 @@ namespace ScriptCanvasPhysicsTests .WillByDefault(Return(m_hitResult)); // given shapecast data - const AZ::Vector3 start = AZ::Vector3::CreateZero(); const AZ::Vector3 direction = AZ::Vector3(0.f,1.f,0.f); const float distance = 1.f; const AZStd::string collisionGroup = "default"; diff --git a/Gems/ScriptCanvasTesting/Code/Tests/ScriptCanvas_Core.cpp b/Gems/ScriptCanvasTesting/Code/Tests/ScriptCanvas_Core.cpp index 406163108d..2f51f47230 100644 --- a/Gems/ScriptCanvasTesting/Code/Tests/ScriptCanvas_Core.cpp +++ b/Gems/ScriptCanvasTesting/Code/Tests/ScriptCanvas_Core.cpp @@ -360,16 +360,16 @@ TEST_F(ScriptCanvasTestFixture, ValueTypes) double numberDoubleValue = *numberDouble.GetAs(); Datum numberHex(Datum(0xff)); - /*int numberHexValue =*/ *numberHex.GetAs(); + [[maybe_unused]] int numberHexValue = *numberHex.GetAs(); Datum numberPi(Datum(3.14f)); float numberPiValue = *numberPi.GetAs(); Datum numberSigned(Datum(-100)); - /*int numberSignedValue =*/ *numberSigned.GetAs(); + [[maybe_unused]] int numberSignedValue = *numberSigned.GetAs(); Datum numberUnsigned(Datum(100u)); - /*unsigned int numberUnsignedValue =*/ *numberUnsigned.GetAs(); + [[maybe_unused]] unsigned int numberUnsignedValue = *numberUnsigned.GetAs(); Datum numberDoublePi(Datum(6.28)); double numberDoublePiValue = *numberDoublePi.GetAs(); @@ -472,8 +472,6 @@ TEST_F(ScriptCanvasTestFixture, Contracts) delete graph->GetEntity(); } -const int k_executionCount = 998; - TEST_F(ScriptCanvasTestFixture, While) { RunUnitTestGraph("LY_SC_UnitTest_While", ScriptCanvas::ExecutionMode::Interpreted); diff --git a/Gems/ScriptCanvasTesting/Code/Tests/ScriptCanvas_Variables.cpp b/Gems/ScriptCanvasTesting/Code/Tests/ScriptCanvas_Variables.cpp index 7b91768d84..01472f2e88 100644 --- a/Gems/ScriptCanvasTesting/Code/Tests/ScriptCanvas_Variables.cpp +++ b/Gems/ScriptCanvasTesting/Code/Tests/ScriptCanvas_Variables.cpp @@ -207,28 +207,24 @@ TEST_F(ScriptCanvasTestFixture, RemoveVariableTest) GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, "FirstVector3", vector3Datum1, false); EXPECT_TRUE(addPropertyOutcome); EXPECT_TRUE(addPropertyOutcome.GetValue().IsValid()); - const VariableId firstVector3Id = addPropertyOutcome.GetValue(); ++numVariablesAdded; addPropertyOutcome = AZ::Failure(AZStd::string("Uninitialized")); GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, "SecondVector3", vector3Datum2, false); EXPECT_TRUE(addPropertyOutcome); EXPECT_TRUE(addPropertyOutcome.GetValue().IsValid()); - const VariableId secondVector3Id = addPropertyOutcome.GetValue(); ++numVariablesAdded; addPropertyOutcome = AZ::Failure(AZStd::string("Uninitialized")); GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, "FirstVector4", vector4Datum, false); EXPECT_TRUE(addPropertyOutcome); EXPECT_TRUE(addPropertyOutcome.GetValue().IsValid()); - const VariableId firstVector4Id = addPropertyOutcome.GetValue(); ++numVariablesAdded; addPropertyOutcome = AZ::Failure(AZStd::string("Uninitialized")); GraphVariableManagerRequestBus::EventResult(addPropertyOutcome, scriptCanvasId, &GraphVariableManagerRequests::AddVariable, "ProjectionMatrix", behaviorMatrix4x4Datum, false); EXPECT_TRUE(addPropertyOutcome); EXPECT_TRUE(addPropertyOutcome.GetValue().IsValid()); - const VariableId projectionMatrixId = addPropertyOutcome.GetValue(); ++numVariablesAdded; addPropertyOutcome = AZ::Failure(AZStd::string("Uninitialized")); diff --git a/Gems/ScriptEvents/Code/Include/ScriptEvents/ScriptEventsAssetRef.h b/Gems/ScriptEvents/Code/Include/ScriptEvents/ScriptEventsAssetRef.h index 506e1611bd..619dd42483 100644 --- a/Gems/ScriptEvents/Code/Include/ScriptEvents/ScriptEventsAssetRef.h +++ b/Gems/ScriptEvents/Code/Include/ScriptEvents/ScriptEventsAssetRef.h @@ -135,7 +135,6 @@ namespace ScriptEvents AZ::Data::AssetCatalogRequestBus::BroadcastResult(assetInfo, &AZ::Data::AssetCatalogRequests::GetAssetInfoById, m_asset.GetId()); if (assetInfo.m_assetId.IsValid()) { - const AZ::Data::AssetType assetTypeId = azrtti_typeid(); auto& assetManager = AZ::Data::AssetManager::Instance(); m_asset = assetManager.GetAsset(m_asset.GetId(), azrtti_typeid(), m_asset.GetAutoLoadBehavior()); diff --git a/Gems/ScriptEvents/Code/Tests/Tests/ScriptEventsTest_Core.cpp b/Gems/ScriptEvents/Code/Tests/Tests/ScriptEventsTest_Core.cpp index 7ae39db846..6da11deb95 100644 --- a/Gems/ScriptEvents/Code/Tests/Tests/ScriptEventsTest_Core.cpp +++ b/Gems/ScriptEvents/Code/Tests/Tests/ScriptEventsTest_Core.cpp @@ -406,26 +406,6 @@ namespace ScriptEventsTests EXPECT_TRUE(behaviorEbus->m_destroyHandler->Invoke(handler)); - auto onReady = [&assetData, &scriptEventName]() { - const char* renamedMethod = "__METHOD__1__"; - - ScriptEvents::ScriptEventsAsset* loadedScriptAsset = assetData.GetAs(); - EXPECT_TRUE(loadedScriptAsset); - - const ScriptEvents::ScriptEvent& loadedDefinition = loadedScriptAsset->m_definition; - - EXPECT_EQ(loadedDefinition.GetVersion(), 0); - EXPECT_STREQ(loadedDefinition.GetName().data(), scriptEventName.c_str()); - - - ScriptEvents::Method method; - bool foundMethod = loadedDefinition.FindMethod(renamedMethod, method); - EXPECT_TRUE(foundMethod); - EXPECT_EQ(method.GetNameProperty().GetVersion(), 1); - - assetData = {}; - }; - AssetEventHandler assetHandler2(assetId, []() {}, []() {}); assetHandler2.BusConnect(assetId); diff --git a/Gems/SliceFavorites/Code/Source/FavoriteDataModel.cpp b/Gems/SliceFavorites/Code/Source/FavoriteDataModel.cpp index 94b9d78247..6ef49f4a1b 100644 --- a/Gems/SliceFavorites/Code/Source/FavoriteDataModel.cpp +++ b/Gems/SliceFavorites/Code/Source/FavoriteDataModel.cpp @@ -562,7 +562,7 @@ namespace SliceFavorites // Rebuild the menu from the current tree m_favoritesMenu->clear(); - m_favoritesMenu->addAction(QIcon(":/Icons/SliceFavorite_Icon_Manage"), "Manage favorites...", m_favoritesMenu.get(), [this]() + m_favoritesMenu->addAction(QIcon(":/Icons/SliceFavorite_Icon_Manage"), "Manage favorites...", m_favoritesMenu.get(), []() { AzToolsFramework::OpenViewPane(SliceFavorites::ManageSliceFavorites); }); diff --git a/Gems/SurfaceData/Code/Include/SurfaceData/Tests/SurfaceDataTestMocks.h b/Gems/SurfaceData/Code/Include/SurfaceData/Tests/SurfaceDataTestMocks.h index 2f45d22748..11171215f7 100644 --- a/Gems/SurfaceData/Code/Include/SurfaceData/Tests/SurfaceDataTestMocks.h +++ b/Gems/SurfaceData/Code/Include/SurfaceData/Tests/SurfaceDataTestMocks.h @@ -293,7 +293,7 @@ namespace UnitTest SurfaceData::SurfaceDataRegistryHandle GetEntryHandle(AZ::EntityId id, const AZStd::vector& entryList) { // Look up the requested entity Id and see if we have a registered surface entry with that handle. If so, return the handle. - auto result = AZStd::find_if(entryList.begin(), entryList.end(), [this, id](const SurfaceData::SurfaceDataRegistryEntry& entry) { return entry.m_entityId == id; }); + auto result = AZStd::find_if(entryList.begin(), entryList.end(), [id](const SurfaceData::SurfaceDataRegistryEntry& entry) { return entry.m_entityId == id; }); if (result == entryList.end()) { return SurfaceData::InvalidSurfaceDataRegistryHandle; diff --git a/Gems/TextureAtlas/Code/Source/Editor/AtlasBuilderWorker.cpp b/Gems/TextureAtlas/Code/Source/Editor/AtlasBuilderWorker.cpp index ed0d889299..abcdce99b9 100644 --- a/Gems/TextureAtlas/Code/Source/Editor/AtlasBuilderWorker.cpp +++ b/Gems/TextureAtlas/Code/Source/Editor/AtlasBuilderWorker.cpp @@ -33,6 +33,30 @@ namespace TextureAtlasBuilder { + //! Used for sorting ImageDimensions + bool operator<(ImageDimension a, ImageDimension b); + + //! Used to expose the ImageDimension in a pair to AZStd::Sort + bool operator<(IndexImageDimension a, IndexImageDimension b); + + //! Returns true if two coordinate sets overlap + bool Collides(AtlasCoordinates a, AtlasCoordinates b); + + //! Returns true if item collides with any object in list + bool Collides(AtlasCoordinates item, AZStd::vector list); + + //! Returns the portion of the second item that overlaps with the first + AtlasCoordinates GetOverlap(AtlasCoordinates a, AtlasCoordinates b); + + //! Performs an operation that copies a pixel to the output + void SetPixels(AZ::u8* dest, const AZ::u8* source, int destBytes); + + //! Checks if we can insert an image into a slot + bool CanInsert(AtlasCoordinates slot, ImageDimension image, int padding, int farRight, int farBot); + + //! Adds the necessary padding to an Atlas Coordinate + void AddPadding(AtlasCoordinates& slot, int padding, int farRight, int farBot); + //! Counts leading zeros uint32_t CountLeadingZeros32(uint32_t x) { @@ -1411,7 +1435,7 @@ namespace TextureAtlasBuilder // Defines priority so that sorting can be meaningful. It may seem odd that larger items are "less than" smaller // ones, but as this is a deduction of priority, not value, it is correct. - static bool operator<(ImageDimension a, ImageDimension b) + bool operator<(ImageDimension a, ImageDimension b) { // Prioritize first by longest size if ((a.m_width > a.m_height ? a.m_width : a.m_height) != (b.m_width > b.m_height ? b.m_width : b.m_height)) @@ -1431,7 +1455,7 @@ namespace TextureAtlasBuilder } // Exposes priority logic to the sorting algorithm - static bool operator<(IndexImageDimension a, IndexImageDimension b) { return a.second < b.second; } + bool operator<(IndexImageDimension a, IndexImageDimension b) { return a.second < b.second; } // Tests if two coordinate sets intersect bool Collides(AtlasCoordinates a, AtlasCoordinates b) diff --git a/Gems/TextureAtlas/Code/Source/Editor/AtlasBuilderWorker.h b/Gems/TextureAtlas/Code/Source/Editor/AtlasBuilderWorker.h index 7bff2be678..86faeac616 100644 --- a/Gems/TextureAtlas/Code/Source/Editor/AtlasBuilderWorker.h +++ b/Gems/TextureAtlas/Code/Source/Editor/AtlasBuilderWorker.h @@ -200,28 +200,4 @@ namespace TextureAtlasBuilder //! Returns the height of the tallest area static int GetTallest(const ImageDimensionData& imageList); }; - - //! Used for sorting ImageDimensions - static bool operator<(ImageDimension a, ImageDimension b); - - //! Used to expose the ImageDimension in a pair to AZStd::Sort - static bool operator<(IndexImageDimension a, IndexImageDimension b); - - //! Returns true if two coordinate sets overlap - static bool Collides(AtlasCoordinates a, AtlasCoordinates b); - - //! Returns true if item collides with any object in list - static bool Collides(AtlasCoordinates item, AZStd::vector list); - - //! Returns the portion of the second item that overlaps with the first - static AtlasCoordinates GetOverlap(AtlasCoordinates a, AtlasCoordinates b); - - //! Performs an operation that copies a pixel to the output - static void SetPixels(AZ::u8* dest, const AZ::u8* source, int destBytes); - - //! Checks if we can insert an image into a slot - static bool CanInsert(AtlasCoordinates slot, ImageDimension image, int padding, int farRight, int farBot); - - //! Adds the necessary padding to an Atlas Coordinate - static void AddPadding(AtlasCoordinates& slot, int padding, int farRight, int farBot); } diff --git a/Gems/Twitch/Code/Source/TwitchREST.cpp b/Gems/Twitch/Code/Source/TwitchREST.cpp index 7403e927ca..a8aaa83fa0 100644 --- a/Gems/Twitch/Code/Source/TwitchREST.cpp +++ b/Gems/Twitch/Code/Source/TwitchREST.cpp @@ -69,7 +69,7 @@ namespace Twitch { AZStd::string url( BuildBaseURL("users", friendID) + "/friends/notifications"); - AddHTTPRequest(url, Aws::Http::HttpMethod::HTTP_DELETE, GetDefaultHeaders(), [receipt, this](const Aws::Utils::Json::JsonView& /*json*/, Aws::Http::HttpResponseCode httpCode) + AddHTTPRequest(url, Aws::Http::HttpMethod::HTTP_DELETE, GetDefaultHeaders(), [receipt](const Aws::Utils::Json::JsonView& /*json*/, Aws::Http::HttpResponseCode httpCode) { ResultCode rc(ResultCode::TwitchRESTError); @@ -87,7 +87,7 @@ namespace Twitch { AZStd::string url(BuildBaseURL("users", friendID) + "/friends/notifications"); - AddHTTPRequest(url, Aws::Http::HttpMethod::HTTP_GET, GetDefaultHeaders(), [receipt, this](const Aws::Utils::Json::JsonView& json, Aws::Http::HttpResponseCode httpCode) + AddHTTPRequest(url, Aws::Http::HttpMethod::HTTP_GET, GetDefaultHeaders(), [receipt](const Aws::Utils::Json::JsonView& json, Aws::Http::HttpResponseCode httpCode) { ResultCode rc(ResultCode::TwitchRESTError); AZ::s64 count = 0; @@ -203,7 +203,7 @@ namespace Twitch { AZStd::string url(BuildBaseURL("users") + "/friends/relationships/" + friendID); - AddHTTPRequest(url, Aws::Http::HttpMethod::HTTP_PUT, GetDefaultHeaders(), [receipt, this]([[maybe_unused]] const Aws::Utils::Json::JsonView& jsonDoc, Aws::Http::HttpResponseCode httpCode) + AddHTTPRequest(url, Aws::Http::HttpMethod::HTTP_PUT, GetDefaultHeaders(), [receipt]([[maybe_unused]] const Aws::Utils::Json::JsonView& jsonDoc, Aws::Http::HttpResponseCode httpCode) { ResultCode rc(ResultCode::TwitchRESTError); @@ -265,7 +265,7 @@ namespace Twitch { AZStd::string url(BuildBaseURL("users") + "/friends/requests/" + friendID); - AddHTTPRequest(url, Aws::Http::HttpMethod::HTTP_PUT, GetDefaultHeaders(), [receipt, this]([[maybe_unused]] const Aws::Utils::Json::JsonView& jsonDoc, Aws::Http::HttpResponseCode httpCode) + AddHTTPRequest(url, Aws::Http::HttpMethod::HTTP_PUT, GetDefaultHeaders(), [receipt]([[maybe_unused]] const Aws::Utils::Json::JsonView& jsonDoc, Aws::Http::HttpResponseCode httpCode) { ResultCode rc(ResultCode::TwitchRESTError); @@ -282,7 +282,7 @@ namespace Twitch { AZStd::string url(BuildBaseURL("users") + "/friends/requests/" + friendID); - AddHTTPRequest(url, Aws::Http::HttpMethod::HTTP_DELETE, GetDefaultHeaders(), [receipt, this]([[maybe_unused]] const Aws::Utils::Json::JsonView& jsonDoc, Aws::Http::HttpResponseCode httpCode) + AddHTTPRequest(url, Aws::Http::HttpMethod::HTTP_DELETE, GetDefaultHeaders(), [receipt]([[maybe_unused]] const Aws::Utils::Json::JsonView& jsonDoc, Aws::Http::HttpResponseCode httpCode) { ResultCode rc(ResultCode::TwitchRESTError); diff --git a/Gems/Vegetation/Code/Source/Components/BlockerComponent.cpp b/Gems/Vegetation/Code/Source/Components/BlockerComponent.cpp index e26f1aee47..0f45e532d9 100644 --- a/Gems/Vegetation/Code/Source/Components/BlockerComponent.cpp +++ b/Gems/Vegetation/Code/Source/Components/BlockerComponent.cpp @@ -222,7 +222,7 @@ namespace Vegetation for (const auto& id : processedIds) { bool accepted = true; - FilterRequestBus::EnumerateHandlersId(id, [this, &instanceData, &accepted](FilterRequestBus::Events* handler) { + FilterRequestBus::EnumerateHandlersId(id, [&instanceData, &accepted](FilterRequestBus::Events* handler) { accepted = handler->Evaluate(instanceData); return accepted; }); diff --git a/Gems/Vegetation/Code/Source/Components/MeshBlockerComponent.cpp b/Gems/Vegetation/Code/Source/Components/MeshBlockerComponent.cpp index 52461e691c..dc205079fd 100644 --- a/Gems/Vegetation/Code/Source/Components/MeshBlockerComponent.cpp +++ b/Gems/Vegetation/Code/Source/Components/MeshBlockerComponent.cpp @@ -259,7 +259,7 @@ namespace Vegetation for (const auto& id : processedIds) { bool accepted = true; - FilterRequestBus::EnumerateHandlersId(id, [this, &instanceData, &accepted](FilterRequestBus::Events* handler) { + FilterRequestBus::EnumerateHandlersId(id, [&instanceData, &accepted](FilterRequestBus::Events* handler) { accepted = handler->Evaluate(instanceData); return accepted; }); diff --git a/Gems/Vegetation/Code/Source/InstanceSystemComponent.cpp b/Gems/Vegetation/Code/Source/InstanceSystemComponent.cpp index d4185fde6c..dd38daa633 100644 --- a/Gems/Vegetation/Code/Source/InstanceSystemComponent.cpp +++ b/Gems/Vegetation/Code/Source/InstanceSystemComponent.cpp @@ -582,7 +582,7 @@ namespace Vegetation } //offloading garbage collection to job to save time deallocating tasks on main thread - auto garbageCollectionJob = AZ::CreateJobFunction([removedTasksPtr]() mutable {}, true); + auto garbageCollectionJob = AZ::CreateJobFunction([]() mutable {}, true); garbageCollectionJob->Start(); } diff --git a/Gems/Vegetation/Code/Source/PrefabInstanceSpawner.cpp b/Gems/Vegetation/Code/Source/PrefabInstanceSpawner.cpp index 2189929fa3..efeb60d598 100644 --- a/Gems/Vegetation/Code/Source/PrefabInstanceSpawner.cpp +++ b/Gems/Vegetation/Code/Source/PrefabInstanceSpawner.cpp @@ -325,7 +325,7 @@ namespace Vegetation // Create a callback for SpawnAllEntities that will set the transform of the root entity to the correct position / rotation / scale // for our spawned instance. - auto preSpawnCB = [this, world]( + auto preSpawnCB = [world]( [[maybe_unused]] AzFramework::EntitySpawnTicket::Id ticketId, AzFramework::SpawnableEntityContainerView view) { AZ::Entity* rootEntity = *view.begin(); diff --git a/Gems/Vegetation/Code/Tests/VegetationTest.h b/Gems/Vegetation/Code/Tests/VegetationTest.h index 6638b54a40..cf7c9b70a1 100644 --- a/Gems/Vegetation/Code/Tests/VegetationTest.h +++ b/Gems/Vegetation/Code/Tests/VegetationTest.h @@ -77,7 +77,6 @@ namespace UnitTest claimContext.m_existedCallback = [this](const Vegetation::ClaimPoint&, const Vegetation::InstanceData&) { - m_existedCallbackCount; return m_existedCallbackOutput; }; diff --git a/Gems/WhiteBox/Code/Source/Core/WhiteBoxToolApi.cpp b/Gems/WhiteBox/Code/Source/Core/WhiteBoxToolApi.cpp index 961eef2176..7e96c83810 100644 --- a/Gems/WhiteBox/Code/Source/Core/WhiteBoxToolApi.cpp +++ b/Gems/WhiteBox/Code/Source/Core/WhiteBoxToolApi.cpp @@ -40,6 +40,8 @@ AZ_PUSH_DISABLE_WARNING(4702, "-Wunknown-warning-option") // OpenMesh\Core\Utils #include AZ_POP_DISABLE_WARNING +AZ_DECLARE_BUDGET(AzToolsFramework); + namespace OpenMesh { template<> diff --git a/Gems/WhiteBox/Code/Source/EditorWhiteBoxComponentMode.cpp b/Gems/WhiteBox/Code/Source/EditorWhiteBoxComponentMode.cpp index cd9e8090cd..13dc29599d 100644 --- a/Gems/WhiteBox/Code/Source/EditorWhiteBoxComponentMode.cpp +++ b/Gems/WhiteBox/Code/Source/EditorWhiteBoxComponentMode.cpp @@ -397,7 +397,7 @@ namespace WhiteBox const auto edgeHandlesPair = Api::MeshUserEdgeHandles(*whiteBox); - const auto edgeHandles = [whiteBox, edgeSelectionMode, &edgeHandlesPair]() + const auto edgeHandles = [edgeSelectionMode, &edgeHandlesPair]() { switch (edgeSelectionMode) { diff --git a/Gems/WhiteBox/Code/Source/EditorWhiteBoxComponentModeTypes.cpp b/Gems/WhiteBox/Code/Source/EditorWhiteBoxComponentModeTypes.cpp index cbde5f4f4b..ff4961a55c 100644 --- a/Gems/WhiteBox/Code/Source/EditorWhiteBoxComponentModeTypes.cpp +++ b/Gems/WhiteBox/Code/Source/EditorWhiteBoxComponentModeTypes.cpp @@ -11,6 +11,8 @@ #include #include +AZ_DECLARE_BUDGET(AzToolsFramework); + namespace WhiteBox { void DrawEdges( diff --git a/Gems/WhiteBox/Code/Tests/WhiteBoxTest.cpp b/Gems/WhiteBox/Code/Tests/WhiteBoxTest.cpp index 19258209dc..056c85512f 100644 --- a/Gems/WhiteBox/Code/Tests/WhiteBoxTest.cpp +++ b/Gems/WhiteBox/Code/Tests/WhiteBoxTest.cpp @@ -1821,7 +1821,6 @@ namespace UnitTest Api::InitializeAsUnitTriangle(*m_whiteBox); - const auto vertexCount = Api::MeshVertexCount(*m_whiteBox); const auto vertexHandles = Api::MeshVertexHandles(*m_whiteBox); const auto vertexPositions = Api::MeshVertexPositions(*m_whiteBox); diff --git a/Templates/CMakeLists.txt b/Templates/CMakeLists.txt index 300e11ac3e..1a3a45b5ec 100644 --- a/Templates/CMakeLists.txt +++ b/Templates/CMakeLists.txt @@ -6,4 +6,11 @@ # # -ly_install_directory(DIRECTORIES .) +ly_install_directory( + DIRECTORIES + AssetGem + DefaultGem + DefaultProject + MinimalProject + VERBATIM +) diff --git a/cmake/Findo3de.cmake b/cmake/Findo3de.cmake index b0d30f1dcc..26b3719d14 100644 --- a/cmake/Findo3de.cmake +++ b/cmake/Findo3de.cmake @@ -17,23 +17,27 @@ endfunction() o3de_current_file_path(current_path) -# Make sure we are matching LY_ENGINE_NAME_TO_USE with the current engine -file(READ ${current_path}/../engine.json engine_json) -set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${current_path}/../engine.json) +# Make sure the cmake configure dependency added here is a normalized path to engine.json, +# because later it's read again using a path like ${LY_ROOT_FOLDER}/engine.json, which +# is also normalized. They should match to avoid errors on some build systems. +cmake_path(SET engine_json_path NORMALIZE ${current_path}/../engine.json) +file(READ ${engine_json_path} engine_json) +set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${engine_json_path}) string(JSON this_engine_name ERROR_VARIABLE json_error GET ${engine_json} engine_name) if(json_error) - message(FATAL_ERROR "Unable to read key 'engine_name' from '${current_path}/../engine.json', error: ${json_error}") + message(FATAL_ERROR "Unable to read key 'engine_name' from '${engine_json_path}', error: ${json_error}") endif() +# Make sure we are matching LY_ENGINE_NAME_TO_USE with the current engine set(found_matching_engine FALSE) if(this_engine_name STREQUAL LY_ENGINE_NAME_TO_USE) set(found_matching_engine TRUE) endif() find_package_handle_standard_args(o3de - "Could not find an engine with matching ${LY_ENGINE_NAME_TO_USE}" - found_matching_engine + "Could not find an engine with matching ${LY_ENGINE_NAME_TO_USE}" + found_matching_engine ) macro(o3de_initialize) @@ -41,4 +45,4 @@ macro(o3de_initialize) set(LY_PROJECTS ${CMAKE_CURRENT_LIST_DIR}) o3de_current_file_path(current_path) add_subdirectory(${current_path}/.. o3de) -endmacro() \ No newline at end of file +endmacro() diff --git a/cmake/Install.cmake b/cmake/Install.cmake index 5781fc7ae5..34f316e31e 100644 --- a/cmake/Install.cmake +++ b/cmake/Install.cmake @@ -16,17 +16,18 @@ endif() # \arg:DIRECTORIES directories to install # \arg:DESTINATION (optional) destination to install the directory to (relative to CMAKE_PREFIX_PATH) # \arg:EXCLUDE_PATTERNS (optional) patterns to exclude +# \arg:VERBATIM (optional) copies the directories as they are, this excludes the default exclude patterns # # \notes: # - refer to cmake's install(DIRECTORY documentation for more information # - If the directory contains programs/scripts, exclude them from this call and add a specific ly_install_files with # PROGRAMS set. This is necessary to set the proper execution permissions. # - This function will automatically filter out __pycache__, *.egg-info, CMakeLists.txt, *.cmake files. If those files -# need to be installed, use ly_install_files. +# need to be installed, use ly_install_files. Use VERBATIM to exclude such filters. # function(ly_install_directory) - set(options) + set(options VERBATIM) set(oneValueArgs DESTINATION) set(multiValueArgs DIRECTORIES EXCLUDE_PATTERNS) @@ -60,13 +61,15 @@ function(ly_install_directory) endforeach() endif() - # Exclude cmake since that has to be generated - list(APPEND exclude_patterns PATTERN CMakeLists.txt EXCLUDE) - list(APPEND exclude_patterns PATTERN *.cmake EXCLUDE) + if(NOT ly_install_directory_VERBATIM) + # Exclude cmake since that has to be generated + list(APPEND exclude_patterns PATTERN CMakeLists.txt EXCLUDE) + list(APPEND exclude_patterns PATTERN *.cmake EXCLUDE) - # Exclude python-related things that dont need to be installed - list(APPEND exclude_patterns PATTERN __pycache__ EXCLUDE) - list(APPEND exclude_patterns PATTERN *.egg-info EXCLUDE) + # Exclude python-related things that dont need to be installed + list(APPEND exclude_patterns PATTERN __pycache__ EXCLUDE) + list(APPEND exclude_patterns PATTERN *.egg-info EXCLUDE) + endif() install(DIRECTORY ${directory} DESTINATION ${ly_install_directory_DESTINATION} diff --git a/cmake/PAL.cmake b/cmake/PAL.cmake index 341df79f1a..67ed17b6d4 100644 --- a/cmake/PAL.cmake +++ b/cmake/PAL.cmake @@ -112,7 +112,8 @@ function(read_engine_restricted_path output_restricted_path) # Set manifest path to path in the user home directory set(manifest_path ${LY_ROOT_FOLDER}/engine.json) if(EXISTS ${manifest_path}) - o3de_restricted_path(${manifest_path} output_restricted_path) + o3de_restricted_path(${manifest_path} read_restricted_path) + set(${output_restricted_path} ${read_restricted_path} PARENT_SCOPE) endif() endfunction() @@ -133,16 +134,17 @@ ly_set(PAL_HOST_PLATFORM_NAME_LOWERCASE ${PAL_HOST_PLATFORM_NAME_LOWERCASE}) set(PAL_RESTRICTED_PLATFORMS) -string(LENGTH "${O3DE_ENGINE_RESTRICTED_PATH}" engine_restricted_length) file(GLOB pal_restricted_files ${O3DE_ENGINE_RESTRICTED_PATH}/*/cmake/PAL_*.cmake) foreach(pal_restricted_file ${pal_restricted_files}) - string(FIND ${pal_restricted_file} "/cmake/PAL" end) - if(${end} GREATER -1) - math(EXPR platform_length "${end} - ${engine_restricted_length} - 1") - math(EXPR platform_start "${engine_restricted_length} + 1") - string(SUBSTRING ${pal_restricted_file} ${platform_start} ${platform_length} platform) - list(APPEND PAL_RESTRICTED_PLATFORMS "${platform}") - endif() + # Get relative path from restricted root directory + cmake_path(RELATIVE_PATH pal_restricted_file BASE_DIRECTORY ${O3DE_ENGINE_RESTRICTED_PATH} OUTPUT_VARIABLE relative_pal_restricted_file) + # Split relative restricted path into path segments + string(REPLACE "/" ";" pal_restricted_segments ${relative_pal_restricted_file}) + # Retrieve the first path segment which should be the restricted platform + list(GET pal_restricted_segments 0 platform) + # Append the new restricted platform + string(TOLOWER ${platform} platform_lower) + list(APPEND PAL_RESTRICTED_PLATFORMS ${platform_lower}) endforeach() ly_set(PAL_RESTRICTED_PLATFORMS ${PAL_RESTRICTED_PLATFORMS}) @@ -186,11 +188,17 @@ function(ly_get_absolute_pal_filename out_name in_name) # Remove one path segment from the end of the current_object_path and prepend it to the list path_segments cmake_path(GET current_object_path PARENT_PATH parent_path) cmake_path(GET current_object_path FILENAME path_segment) - list(PREPEND path_segments_visited path_segment) + list(PREPEND path_segments_visited ${path_segment}) cmake_path(COMPARE current_object_path NOT_EQUAL parent_path is_prev_path_segment) cmake_path(SET current_object_path "${parent_path}") + set(is_prev_path_segment TRUE) while(is_prev_path_segment) + # Remove one path segment from the end of the current_object_path and prepend it to the list path_segments + cmake_path(GET current_object_path PARENT_PATH parent_path) + cmake_path(GET current_object_path FILENAME path_segment) + cmake_path(COMPARE current_object_path NOT_EQUAL parent_path is_prev_path_segment) + cmake_path(SET current_object_path "${parent_path}") # The Path is in a PAL structure # Decompose the path into sections before "Platform" and after "Platform" if(path_segment STREQUAL "Platform") @@ -205,21 +213,17 @@ function(ly_get_absolute_pal_filename out_name in_name) break() endif() - # Remove one path segment from the end of the current_object_path and prepend it to the list path_segments - cmake_path(GET current_object_path PARENT_PATH parent_path) - cmake_path(GET current_object_path FILENAME path_segment) - list(PREPEND path_segments_visited path_segment) - cmake_path(COMPARE current_object_path NOT_EQUAL parent_path is_prev_path_segment) - cmake_path(SET current_object_path "${parent_path}") + list(PREPEND path_segments_visited ${path_segment}) endwhile() # Compose a candidate restricted path and examine if it exists - cmake_path(APPEND object_restricted_path ${pre_platform_paths} "Platform" ${post_platform_paths} + cmake_path(APPEND ${pre_platform_paths} "Platform" ${post_platform_paths} OUTPUT_VARIABLE candidate_PAL_path) if(NOT EXISTS ${candidate_PAL_path}) - if("${candidate_platform_name}" IN_LIST PAL_RESTRICTED_PLATFORMS) + string(TOLOWER ${candidate_platform_name} candidate_platform_name_lower) + if("${candidate_platform_name_lower}" IN_LIST PAL_RESTRICTED_PLATFORMS) cmake_path(APPEND object_restricted_path ${candidate_platform_name} ${object_name} - ${pre_platform_paths} ${post_platform_paths} OUTPUT_VARIABLE candidate_PAL_path) + ${pre_platform_paths} OUTPUT_VARIABLE candidate_PAL_path) endif() endif() if(EXISTS ${candidate_PAL_path}) @@ -227,6 +231,7 @@ function(ly_get_absolute_pal_filename out_name in_name) endif() endif() endif() + cmake_path(ABSOLUTE_PATH full_name BASE_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) set(${out_name} ${full_name} PARENT_SCOPE) endfunction() diff --git a/cmake/Platform/Common/Clang/Configurations_clang.cmake b/cmake/Platform/Common/Clang/Configurations_clang.cmake index 94584e342f..17a89fc1cd 100644 --- a/cmake/Platform/Common/Clang/Configurations_clang.cmake +++ b/cmake/Platform/Common/Clang/Configurations_clang.cmake @@ -33,11 +33,6 @@ ly_append_configurations_options( -Wno-tautological-compare -Wno-undefined-var-template -Wno-unknown-pragmas - -Wno-unused-function - -Wno-unused-private-field - -Wno-unused-value - -Wno-unused-variable - -Wno-unused-lambda-capture # Workaround for compiler seeing file case differently from what OS show in console. -Wno-nonportable-include-path diff --git a/cmake/Platform/Common/MSVC/Configurations_msvc.cmake b/cmake/Platform/Common/MSVC/Configurations_msvc.cmake index 9353e4eb1c..7c7120fe15 100644 --- a/cmake/Platform/Common/MSVC/Configurations_msvc.cmake +++ b/cmake/Platform/Common/MSVC/Configurations_msvc.cmake @@ -40,12 +40,12 @@ ly_append_configurations_options( # Enabling warnings that are disabled by default from /W4 # https://docs.microsoft.com/en-us/cpp/preprocessor/compiler-warnings-that-are-off-by-default?view=vs-2019 /we4296 # 'operator': expression is always false - # /we4426 # optimization flags changed after including header, may be due to #pragma optimize() - # /we4464 # relative include path contains '..' - # /we4619 # #pragma warning: there is no warning number 'number' - # /we4777 # 'function' : format string 'string' requires an argument of type 'type1', but variadic argument number has type 'type2' - # /we5031 # #pragma warning(pop): likely mismatch, popping warning state pushed in different file - # /WE5032 # detected #pragma warning(push) with no corresponding #pragma warning(pop) + /we5233 # explicit lambda capture 'identifier' is not used + /we4426 # optimization flags changed after including header, may be due to #pragma optimize() + #/we4619 # #pragma warning: there is no warning number 'number'. Unfortunately some versions of MSVC 16.X dont filter this warning coming from external headers and Qt has a bad warning in QtCore/qvector.h(340,12) + /we4777 # 'function' : format string 'string' requires an argument of type 'type1', but variadic argument number has type 'type2 + /we5031 # #pragma warning(pop): likely mismatch, popping warning state pushed in different file + /we5032 # detected #pragma warning(push) with no corresponding #pragma warning(pop) /Zc:forScope # Force Conformance in for Loop Scope /diagnostics:caret # Compiler diagnostic options: includes the column where the issue was found and places a caret (^) under the location in the line of code where the issue was detected.