diff --git a/Code/CryEngine/CrySystem/SystemInit.cpp b/Code/CryEngine/CrySystem/SystemInit.cpp index 8347e3f1f0..cecde6046e 100644 --- a/Code/CryEngine/CrySystem/SystemInit.cpp +++ b/Code/CryEngine/CrySystem/SystemInit.cpp @@ -247,7 +247,7 @@ CUNIXConsole* pUnixConsole; #define LOCALIZATION_TRANSLATIONS_LIST_FILE_NAME "Libs/Localization/localization.xml" -#define LOAD_LEGACY_RENDERER_FOR_EDITOR false // If you set this to false you must for now also set 'ed_useAtomNativeViewport' to true (see /Code/Sandbox/Editor/ViewManager.cpp) +#define LOAD_LEGACY_RENDERER_FOR_EDITOR true // If you set this to false you must for now also set 'ed_useAtomNativeViewport' to true (see /Code/Sandbox/Editor/ViewManager.cpp) #define LOAD_LEGACY_RENDERER_FOR_LAUNCHER false ////////////////////////////////////////////////////////////////////////// diff --git a/Code/CryEngine/RenderDll/Common/Textures/TextureManager.cpp b/Code/CryEngine/RenderDll/Common/Textures/TextureManager.cpp index e8c0c085a9..8af1faade7 100644 --- a/Code/CryEngine/RenderDll/Common/Textures/TextureManager.cpp +++ b/Code/CryEngine/RenderDll/Common/Textures/TextureManager.cpp @@ -131,80 +131,20 @@ void CTextureManager::LoadDefaultTextures() #endif }; - // Reduced list of default textures to load. - const TextureEntry texturesFromFileReduced[] = + for (const TextureEntry& entry : texturesFromFile) { - {"NoTextureCM", "EngineAssets/TextureMsg/ReplaceMeCM.tif", FT_DONT_RELEASE | FT_DONT_STREAM }, - {"White", "EngineAssets/Textures/White.tif", FT_DONT_RELEASE | FT_DONT_STREAM }, - {"Gray", "EngineAssets/Textures/Grey.dds", FT_DONT_RELEASE | FT_DONT_STREAM }, - {"Black", "EngineAssets/Textures/Black.tif", FT_DONT_RELEASE | FT_DONT_STREAM }, - {"BlackAlpha", "EngineAssets/Textures/BlackAlpha.tif", FT_DONT_RELEASE | FT_DONT_STREAM }, - {"BlackCM", "EngineAssets/Textures/BlackCM.tif", FT_DONT_RELEASE | FT_DONT_STREAM }, - {"FlatBump", "EngineAssets/Textures/White_ddn.tif", FT_DONT_RELEASE | FT_DONT_STREAM | FT_TEX_NORMAL_MAP }, - {"AverageMemoryUsage", "EngineAssets/Icons/AverageMemoryUsage.tif", FT_DONT_RELEASE | FT_DONT_STREAM }, - {"LowMemoryUsage", "EngineAssets/Icons/LowMemoryUsage.tif", FT_DONT_RELEASE | FT_DONT_STREAM }, - {"HighMemoryUsage", "EngineAssets/Icons/HighMemoryUsage.tif", FT_DONT_RELEASE | FT_DONT_STREAM }, - {"LivePreview", "EngineAssets/Icons/LivePreview.tif", FT_DONT_RELEASE | FT_DONT_STREAM }, -#if !defined(_RELEASE) - {"NoTexture", "EngineAssets/TextureMsg/ReplaceMe.tif", FT_DONT_RELEASE | FT_DONT_STREAM }, - {"IconTextureCompiling", "EngineAssets/TextureMsg/TextureCompiling.tif", FT_DONT_RELEASE | FT_DONT_STREAM }, - {"IconTextureCompiling_a", "EngineAssets/TextureMsg/TextureCompiling_a.tif", FT_DONT_RELEASE | FT_DONT_STREAM }, - {"IconTextureCompiling_cm", "EngineAssets/TextureMsg/TextureCompiling_cm.tif", FT_DONT_RELEASE | FT_DONT_STREAM }, - {"IconTextureCompiling_ddn", "EngineAssets/TextureMsg/TextureCompiling_ddn.tif", FT_DONT_RELEASE | FT_DONT_STREAM }, - {"IconTextureCompiling_ddna", "EngineAssets/TextureMsg/TextureCompiling_ddna.tif", FT_DONT_RELEASE | FT_DONT_STREAM }, - {"DefaultMergedDetail", "EngineAssets/Textures/GreyAlpha.tif", FT_DONT_RELEASE | FT_DONT_STREAM }, - {"MipMapDebug", "EngineAssets/TextureMsg/MipMapDebug.tif", FT_DONT_RELEASE | FT_DONT_STREAM }, - {"ColorBlue", "EngineAssets/TextureMsg/color_Blue.tif", FT_DONT_RELEASE | FT_DONT_STREAM }, - {"ColorCyan", "EngineAssets/TextureMsg/color_Cyan.tif", FT_DONT_RELEASE | FT_DONT_STREAM }, - {"ColorGreen", "EngineAssets/TextureMsg/color_Green.tif", FT_DONT_RELEASE | FT_DONT_STREAM }, - {"ColorPurple", "EngineAssets/TextureMsg/color_Purple.tif", FT_DONT_RELEASE | FT_DONT_STREAM }, - {"ColorRed", "EngineAssets/TextureMsg/color_Red.tif", FT_DONT_RELEASE | FT_DONT_STREAM }, - {"ColorWhite", "EngineAssets/TextureMsg/color_White.tif", FT_DONT_RELEASE | FT_DONT_STREAM }, - {"ColorYellow", "EngineAssets/TextureMsg/color_Yellow.tif", FT_DONT_RELEASE | FT_DONT_STREAM }, - {"ColorOrange", "EngineAssets/TextureMsg/color_Orange.tif", FT_DONT_RELEASE | FT_DONT_STREAM }, - {"ColorMagenta", "EngineAssets/TextureMsg/color_Magenta.tif", FT_DONT_RELEASE | FT_DONT_STREAM }, -#else - {"NoTexture", "EngineAssets/TextureMsg/ReplaceMeRelease.tif", FT_DONT_RELEASE | FT_DONT_STREAM }, -#endif - }; - - // Loop over the appropriate texture list and load the textures, storing them in a map keyed by texture name. - // Use reduced subset of textures for Other. - //if (AZ::Interface::Get()) - //{ - // for (const TextureEntry& entry : texturesFromFileReduced) - // { - // // Use EF_LoadTexture rather than CTexture::ForName - // CTexture* pNewTexture = static_cast(gEnv->pRenderer->EF_LoadTexture(entry.szFileName, entry.flags)); - // if (pNewTexture) - // { - // CCryNameTSCRC texEntry(entry.szTextureName); - // m_DefaultTextures[texEntry] = pNewTexture; - // } - // else - // { - // AZ_Assert(false, "Error - CTextureManager failed to load default texture %s", entry.szFileName); - // AZ_Warning("[Shaders System]", false, "Error - CTextureManager failed to load default texture %s", entry.szFileName); - // } - // } - //} - //else - //{ - for (const TextureEntry& entry : texturesFromFile) + CTexture* pNewTexture = CTexture::ForName(entry.szFileName, entry.flags, eTF_Unknown); + if (pNewTexture) { - CTexture* pNewTexture = CTexture::ForName(entry.szFileName, entry.flags, eTF_Unknown); - if (pNewTexture) - { - CCryNameTSCRC texEntry(entry.szTextureName); - m_DefaultTextures[texEntry] = pNewTexture; - } - else - { - AZ_Assert(false, "Error - CTextureManager failed to load default texture %s", entry.szFileName); - AZ_Warning("[Shaders System]", false, "Error - CTextureManager failed to load default texture %s", entry.szFileName); - } + CCryNameTSCRC texEntry(entry.szTextureName); + m_DefaultTextures[texEntry] = pNewTexture; } - //} + else + { + AZ_Assert(false, "Error - CTextureManager failed to load default texture %s", entry.szFileName); + AZ_Warning("[Shaders System]", false, "Error - CTextureManager failed to load default texture %s", entry.szFileName); + } + } m_texNoTexture = GetDefaultTexture("NoTexture"); m_texNoTextureCM = GetDefaultTexture("NoTextureCM"); diff --git a/Code/Sandbox/Editor/EditorViewportWidget.cpp b/Code/Sandbox/Editor/EditorViewportWidget.cpp index f7365e74e0..6ece24acd2 100644 --- a/Code/Sandbox/Editor/EditorViewportWidget.cpp +++ b/Code/Sandbox/Editor/EditorViewportWidget.cpp @@ -875,11 +875,7 @@ void EditorViewportWidget::OnBeginPrepareRender() fov = 2 * atanf((h * tan(fov / 2)) / maxTargetHeight); } } -#if 1 // ATOMSHIM FIXUP - m_Camera.SetFrustum(w, h, fov, fNearZ, 8000.0f); -#else m_Camera.SetFrustum(w, h, fov, fNearZ, gEnv->p3DEngine->GetMaxViewDistance()); -#endif } GetIEditor()->GetSystem()->SetViewCamera(m_Camera); diff --git a/Code/Sandbox/Editor/EditorViewportWidget.cpp.orig b/Code/Sandbox/Editor/EditorViewportWidget.cpp.orig new file mode 100644 index 0000000000..d3455fd003 --- /dev/null +++ b/Code/Sandbox/Editor/EditorViewportWidget.cpp.orig @@ -0,0 +1,2880 @@ +/* +* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +* its licensors. +* +* For complete copyright and license terms please see the LICENSE at the root of this +* distribution (the "License"). All use of this software is governed by the License, +* or, if provided, by the license below or the license accompanying this file. Do not +* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* +*/ +// Original file Copyright Crytek GMBH or its affiliates, used under license. + +// Description : implementation filefov + + +#include "EditorDefs.h" + +#include "EditorViewportWidget.h" + +// Qt +#include +#include +#include +#include +#include +#include + +// AzCore +#include +#include +#include +#include + +// AzFramework +#include +#include +#include +#if defined(AZ_PLATFORM_WINDOWS) +# include +#endif // defined(AZ_PLATFORM_WINDOWS) +#include // for AzFramework::InputDeviceMouse +#include +#include + +// AzQtComponents +#include + +// AzToolsFramework +#include +#include +#include + +// AtomToolsFramework +#include + +// CryCommon +#include +#include + +// AzFramework +#include + +// Editor +#include "Util/fastlib.h" +#include "CryEditDoc.h" +#include "GameEngine.h" +#include "EditTool.h" +#include "ViewManager.h" +#include "Objects/DisplayContext.h" +#include "DisplaySettings.h" +#include "Include/IObjectManager.h" +#include "Include/IDisplayViewport.h" +#include "Objects/ObjectManager.h" +#include "ProcessInfo.h" +#include "IPostEffectGroup.h" +#include "EditorPreferencesPageGeneral.h" +#include "ViewportManipulatorController.h" +#include "LegacyViewportCameraController.h" +#include "ModernViewportCameraController.h" + +#include "ViewPane.h" +#include "CustomResolutionDlg.h" +#include "AnimationContext.h" +#include "Objects/SelectionGroup.h" +#include "Core/QtEditorApplication.h" + +// ComponentEntityEditorPlugin +#include + +// LmbrCentral +#include + +// Atom +#include +#include +#include +#include + +#include + +AZ_CVAR( + bool, ed_visibility_logTiming, false, nullptr, AZ::ConsoleFunctorFlags::Null, + "Output the timing of the new IVisibilitySystem query"); + +EditorViewportWidget* EditorViewportWidget::m_pPrimaryViewport = nullptr; + +#if AZ_TRAIT_OS_PLATFORM_APPLE +void StopFixedCursorMode(); +void StartFixedCursorMode(QObject *viewport); +#endif + +#define RENDER_MESH_TEST_DISTANCE (0.2f) +#define CURSOR_FONT_HEIGHT 8.0f + +AZ_CVAR( + bool, ed_useNewCameraSystem, false, nullptr, AZ::ConsoleFunctorFlags::Null, + "Use the new Editor camera system (the Atom-native Editor viewport (experimental) must also be enabled)"); + +namespace AZ::ViewportHelpers +{ + static const char TextCantCreateCameraNoLevel[] = "Cannot create camera when no level is loaded."; + + class EditorEntityNotifications + : public AzToolsFramework::EditorEntityContextNotificationBus::Handler + { + public: + EditorEntityNotifications(EditorViewportWidget& renderViewport) + : m_renderViewport(renderViewport) + { + AzToolsFramework::EditorEntityContextNotificationBus::Handler::BusConnect(); + } + + ~EditorEntityNotifications() override + { + AzToolsFramework::EditorEntityContextNotificationBus::Handler::BusDisconnect(); + } + + // AzToolsFramework::EditorEntityContextNotificationBus + void OnStartPlayInEditor() override + { + m_renderViewport.OnStartPlayInEditor(); + } + void OnStopPlayInEditor() override + { + m_renderViewport.OnStopPlayInEditor(); + } + private: + EditorViewportWidget& m_renderViewport; + }; +} // namespace AZ::ViewportHelpers + +////////////////////////////////////////////////////////////////////////// +// EditorViewportWidget +////////////////////////////////////////////////////////////////////////// + +EditorViewportWidget::EditorViewportWidget(const QString& name, QWidget* parent) + : QtViewport(parent) + , m_Camera(GetIEditor()->GetSystem()->GetViewCamera()) + , m_camFOV(gSettings.viewports.fDefaultFov) + , m_defaultViewName(name) + , m_renderViewport(nullptr) //m_renderViewport is initialized later, in SetViewportId +{ + // need this to be set in order to allow for language switching on Windows + setAttribute(Qt::WA_InputMethodEnabled); + LockCameraMovement(true); + + EditorViewportWidget::SetViewTM(m_Camera.GetMatrix()); + m_defaultViewTM.SetIdentity(); + + if (GetIEditor()->GetViewManager()->GetSelectedViewport() == nullptr) + { + GetIEditor()->GetViewManager()->SelectViewport(this); + } + + GetIEditor()->RegisterNotifyListener(this); + + m_displayContext.pIconManager = GetIEditor()->GetIconManager(); + GetIEditor()->GetUndoManager()->AddListener(this); + + m_PhysicalLocation.SetIdentity(); + + // The renderer requires something, so don't allow us to shrink to absolutely nothing + // This won't in fact stop the viewport from being shrunk, when it's the centralWidget for + // the MainWindow, but it will stop the viewport from getting resize events + // once it's smaller than that, which from the renderer's perspective works out + // to be the same thing. + setMinimumSize(50, 50); + + OnCreate(); + + setMouseTracking(true); + + Camera::EditorCameraRequestBus::Handler::BusConnect(); + m_editorEntityNotifications = AZStd::make_unique(*this); + AzFramework::AssetCatalogEventBus::Handler::BusConnect(); + + auto handleCameraChange = [this](const AZ::Matrix4x4&) + { + UpdateCameraFromViewportContext(); + }; + + m_cameraViewMatrixChangeHandler = AZ::RPI::ViewportContext::MatrixChangedEvent::Handler(handleCameraChange); + m_cameraProjectionMatrixChangeHandler = AZ::RPI::ViewportContext::MatrixChangedEvent::Handler(handleCameraChange); + + m_manipulatorManager = GetIEditor()->GetViewManager()->GetManipulatorManager(); + if (!m_pPrimaryViewport) + { + SetAsActiveViewport(); + } +} + +////////////////////////////////////////////////////////////////////////// +EditorViewportWidget::~EditorViewportWidget() +{ + if (m_pPrimaryViewport == this) + { + m_pPrimaryViewport = nullptr; + } + + DisconnectViewportInteractionRequestBus(); + m_editorEntityNotifications.reset(); + Camera::EditorCameraRequestBus::Handler::BusDisconnect(); + OnDestroy(); + GetIEditor()->GetUndoManager()->RemoveListener(this); + GetIEditor()->UnregisterNotifyListener(this); +} + +////////////////////////////////////////////////////////////////////////// +// EditorViewportWidget message handlers +////////////////////////////////////////////////////////////////////////// +int EditorViewportWidget::OnCreate() +{ + m_renderer = GetIEditor()->GetRenderer(); + m_engine = GetIEditor()->Get3DEngine(); + assert(m_engine); + + CreateRenderContext(); + + return 0; +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::resizeEvent(QResizeEvent* event) +{ + PushDisableRendering(); + QtViewport::resizeEvent(event); + PopDisableRendering(); + + const QRect rcWindow = rect().translated(mapToGlobal(QPoint())); + + gEnv->pSystem->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_MOVE, rcWindow.left(), rcWindow.top()); + + m_rcClient = rect(); + m_rcClient.setBottomRight(WidgetToViewport(m_rcClient.bottomRight())); + + gEnv->pSystem->GetISystemEventDispatcher()->OnSystemEvent(ESYSTEM_EVENT_RESIZE, width(), height()); + + if (gEnv->pRenderer) + { + gEnv->pRenderer->EF_DisableTemporalEffects(); + } + + // We queue the window resize event because the render overlay may be hidden. + // If the render overlay is not visible, the native window that is backing it will + // also be hidden, and it will not resize until it becomes visible. + m_windowResizedEvent = true; +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::paintEvent([[maybe_unused]] QPaintEvent* event) +{ + // Do not call CViewport::OnPaint() for painting messages + // FIXME: paintEvent() isn't the best place for such logic. Should listen to proper eNotify events and to the stuff there instead. (Repeats for other view port classes too). + CGameEngine* ge = GetIEditor()->GetGameEngine(); + if ((ge && ge->IsLevelLoaded()) || (GetType() != ET_ViewportCamera)) + { + setRenderOverlayVisible(true); + } + else + { + setRenderOverlayVisible(false); + QPainter painter(this); // device context for painting + + // draw gradient background + const QRect rc = rect(); + QLinearGradient gradient(rc.topLeft(), rc.bottomLeft()); + gradient.setColorAt(0, QColor(80, 80, 80)); + gradient.setColorAt(1, QColor(200, 200, 200)); + painter.fillRect(rc, gradient); + + // if we have some level loaded/loading/new + // we draw a text + if (!GetIEditor()->GetLevelFolder().isEmpty()) + { + const int kFontSize = 200; + const char* kFontName = "Arial"; + const QColor kTextColor(255, 255, 255); + const QColor kTextShadowColor(0, 0, 0); + const QFont font(kFontName, kFontSize / 10.0); + painter.setFont(font); + + QString friendlyName = QFileInfo(GetIEditor()->GetLevelName()).fileName(); + const QString strMsg = tr("Preparing level %1...").arg(friendlyName); + + // draw text shadow + painter.setPen(kTextShadowColor); + painter.drawText(rc, Qt::AlignCenter, strMsg); + painter.setPen(kTextColor); + // offset rect for normal text + painter.drawText(rc.translated(-1, -1), Qt::AlignCenter, strMsg); + } + } +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::mousePressEvent(QMouseEvent* event) +{ + GetIEditor()->GetViewManager()->SelectViewport(this); + + QtViewport::mousePressEvent(event); +} + +AzToolsFramework::ViewportInteraction::MousePick EditorViewportWidget::BuildMousePickInternal(const QPoint& point) const +{ + using namespace AzToolsFramework::ViewportInteraction; + + MousePick mousePick; + mousePick.m_screenCoordinates = AzFramework::ScreenPoint(point.x(), point.y()); + const auto& ray = m_renderViewport->ViewportScreenToWorldRay(point); + if (ray.has_value()) + { + mousePick.m_rayOrigin = ray.value().origin; + mousePick.m_rayDirection = ray.value().direction; + } + return mousePick; +} + +AzToolsFramework::ViewportInteraction::MousePick EditorViewportWidget::BuildMousePick(const QPoint& point) +{ + using namespace AzToolsFramework::ViewportInteraction; + + PreWidgetRendering(); + const MousePick mousePick = BuildMousePickInternal(point); + PostWidgetRendering(); + return mousePick; +} + +AzToolsFramework::ViewportInteraction::MouseInteraction EditorViewportWidget::BuildMouseInteractionInternal( + const AzToolsFramework::ViewportInteraction::MouseButtons buttons, + const AzToolsFramework::ViewportInteraction::KeyboardModifiers modifiers, + const AzToolsFramework::ViewportInteraction::MousePick& mousePick) const +{ + using namespace AzToolsFramework::ViewportInteraction; + + MouseInteraction mouse; + mouse.m_interactionId.m_cameraId = m_viewEntityId; + mouse.m_interactionId.m_viewportId = GetViewportId(); + mouse.m_mouseButtons = buttons; + mouse.m_mousePick = mousePick; + mouse.m_keyboardModifiers = modifiers; + return mouse; +} + +AzToolsFramework::ViewportInteraction::MouseInteraction EditorViewportWidget::BuildMouseInteraction( + const Qt::MouseButtons buttons, const Qt::KeyboardModifiers modifiers, const QPoint& point) +{ + using namespace AzToolsFramework::ViewportInteraction; + + return BuildMouseInteractionInternal( + BuildMouseButtons(buttons), + BuildKeyboardModifiers(modifiers), + BuildMousePick(WidgetToViewport(point))); +} + +void EditorViewportWidget::InjectFakeMouseMove(int deltaX, int deltaY, Qt::MouseButtons buttons) +{ + // this is required, otherwise the user will see the context menu + OnMouseMove(Qt::NoModifier, buttons, QCursor::pos() + QPoint(deltaX, deltaY)); + // we simply move the prev mouse position, so the change will be picked up + // by the next ProcessMouse call + m_prevMousePos -= QPoint(deltaX, deltaY); +} + +////////////////////////////////////////////////////////////////////////// +bool EditorViewportWidget::event(QEvent* event) +{ + switch (event->type()) + { + case QEvent::WindowActivate: + GetIEditor()->GetViewManager()->SelectViewport(this); + // also kill the keys; if we alt-tab back to the viewport, or come back from the debugger, it's done (and there's no guarantee we'll get the keyrelease event anyways) + m_keyDown.clear(); + break; + + case QEvent::Shortcut: + // a shortcut should immediately clear us, otherwise the release event never gets sent + m_keyDown.clear(); + break; + } + + return QtViewport::event(event); +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::ResetContent() +{ + QtViewport::ResetContent(); +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::UpdateContent(int flags) +{ + QtViewport::UpdateContent(flags); + if (flags & eUpdateObjects) + { + m_bUpdateViewport = true; + } +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::Update() +{ + FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR); + + if (Editor::EditorQtApplication::instance()->isMovingOrResizing()) + { + return; + } + + if (!m_engine || m_rcClient.isEmpty() || GetIEditor()->IsInMatEditMode()) + { + return; + } + + if (!isVisible()) + { + return; + } + + m_updatingCameraPosition = true; + auto transform = LYTransformToAZTransform(m_Camera.GetMatrix()); + m_renderViewport->GetViewportContext()->SetCameraTransform(transform); + AZ::Matrix4x4 clipMatrix; + AZ::MakePerspectiveFovMatrixRH( + clipMatrix, + m_Camera.GetFov(), + aznumeric_cast(width()) / aznumeric_cast(height()), + m_Camera.GetNearPlane(), + m_Camera.GetFarPlane(), + true + ); + m_renderViewport->GetViewportContext()->SetCameraProjectionMatrix(clipMatrix); + m_updatingCameraPosition = false; + + + // Don't wait for changes to update the focused viewport. + if (CheckRespondToInput()) + { + m_bUpdateViewport = true; + } + + // While Renderer doesn't support fast rendering of the scene to more then 1 viewport + // render only focused viewport if more then 1 are opened and always update is off. + if (!m_isOnPaint && m_viewManager->GetNumberOfGameViewports() > 1 && GetType() == ET_ViewportCamera) + { + if (m_pPrimaryViewport != this) + { + if (CheckRespondToInput()) // If this is the focused window, set primary viewport. + { + SetAsActiveViewport(); + } + else if (!m_bUpdateViewport) // Skip this viewport. + { + return; + } + } + } + + const bool isGameMode = GetIEditor()->IsInGameMode(); + const bool isSimulationMode = GetIEditor()->GetGameEngine()->GetSimulationMode(); + + // Allow debug visualization in both 'game' (Ctrl-G) and 'simulation' (Ctrl-P) modes + if (isGameMode || isSimulationMode) + { + if (!IsRenderingDisabled()) + { + // Disable rendering to avoid recursion into Update() + PushDisableRendering(); + + // draw debug visualizations + if (m_debugDisplay) + { + const AZ::u32 prevState = m_debugDisplay->GetState(); + m_debugDisplay->SetState( + e_Mode3D | e_AlphaBlended | e_FillModeSolid | e_CullModeBack | e_DepthWriteOn | e_DepthTestOn); + + AzFramework::EntityDebugDisplayEventBus::Broadcast( + &AzFramework::EntityDebugDisplayEvents::DisplayEntityViewport, + AzFramework::ViewportInfo{ GetViewportId() }, *m_debugDisplay); + + m_debugDisplay->SetState(prevState); + } + + QtViewport::Update(); + PopDisableRendering(); + } + + // Game mode rendering is handled by CryAction + if (isGameMode) + { + return; + } + } + + // Prevents rendering recursion due to recursive Paint messages. + if (IsRenderingDisabled()) + { + return; + } + + PushDisableRendering(); + + m_viewTM = m_Camera.GetMatrix(); // synchronize. + + // Render + { + // TODO: Move out this logic to a controller and refactor to work with Atom + // m_renderer->SetClearColor(Vec3(0.4f, 0.4f, 0.4f)); + // 3D engine stats + GetIEditor()->GetSystem()->RenderBegin(); + + OnRender(); + + ProcessRenderLisneters(m_displayContext); + + m_displayContext.Flush2D(); + + // m_renderer->SwitchToNativeResolutionBackbuffer(); + + // 3D engine stats + + CCamera CurCamera = gEnv->pSystem->GetViewCamera(); + gEnv->pSystem->SetViewCamera(m_Camera); + + // Post Render Callback + { + PostRenderers::iterator itr = m_postRenderers.begin(); + PostRenderers::iterator end = m_postRenderers.end(); + for (; itr != end; ++itr) + { + (*itr)->OnPostRender(); + } + } + + GetIEditor()->GetSystem()->RenderEnd(m_bRenderStats); + + gEnv->pSystem->SetViewCamera(CurCamera); + } + + { + auto start = std::chrono::steady_clock::now(); + + m_entityVisibilityQuery.UpdateVisibility(GetCameraState()); + + if (ed_visibility_logTiming) + { + auto stop = std::chrono::steady_clock::now(); + std::chrono::duration diff = stop - start; + AZ_Printf("Visibility", "FindVisibleEntities (new) - Duration: %f", diff); + } + } + + QtViewport::Update(); + + PopDisableRendering(); + m_bUpdateViewport = false; +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::SetViewEntity(const AZ::EntityId& viewEntityId, bool lockCameraMovement) +{ + // if they've picked the same camera, then that means they want to toggle + if (viewEntityId.IsValid() && viewEntityId != m_viewEntityId) + { + LockCameraMovement(lockCameraMovement); + m_viewEntityId = viewEntityId; + AZStd::string entityName; + AZ::ComponentApplicationBus::BroadcastResult(entityName, &AZ::ComponentApplicationRequests::GetEntityName, viewEntityId); + SetName(QString("Camera entity: %1").arg(entityName.c_str())); + } + else + { + SetDefaultCamera(); + } + + PostCameraSet(); +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::ResetToViewSourceType(const ViewSourceType& viewSourceType) +{ + LockCameraMovement(true); + m_pCameraFOVVariable = nullptr; + m_viewEntityId.SetInvalid(); + m_cameraObjectId = GUID_NULL; + m_viewSourceType = viewSourceType; + SetViewTM(GetViewTM()); +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::PostCameraSet() +{ + if (m_viewPane) + { + m_viewPane->OnFOVChanged(GetFOV()); + } + + GetIEditor()->Notify(eNotify_CameraChanged); + QScopedValueRollback rb(m_ignoreSetViewFromEntityPerspective, true); + Camera::EditorCameraNotificationBus::Broadcast( + &Camera::EditorCameraNotificationBus::Events::OnViewportViewEntityChanged, m_viewEntityId); +} + +////////////////////////////////////////////////////////////////////////// +CBaseObject* EditorViewportWidget::GetCameraObject() const +{ + CBaseObject* pCameraObject = nullptr; + + if (m_viewSourceType == ViewSourceType::SequenceCamera) + { + m_cameraObjectId = GetViewManager()->GetCameraObjectId(); + } + if (m_cameraObjectId != GUID_NULL) + { + // Find camera object from id. + pCameraObject = GetIEditor()->GetObjectManager()->FindObject(m_cameraObjectId); + } + else if (m_viewSourceType == ViewSourceType::CameraComponent || m_viewSourceType == ViewSourceType::AZ_Entity) + { + AzToolsFramework::ComponentEntityEditorRequestBus::EventResult( + pCameraObject, m_viewEntityId, &AzToolsFramework::ComponentEntityEditorRequests::GetSandboxObject); + } + return pCameraObject; +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::OnEditorNotifyEvent(EEditorNotifyEvent event) +{ + static ICVar* outputToHMD = gEnv->pConsole->GetCVar("output_to_hmd"); + AZ_Assert(outputToHMD, "cvar output_to_hmd is undeclared"); + + switch (event) + { + case eNotify_OnBeginGameMode: + { + if (GetIEditor()->GetViewManager()->GetGameViewport() == this) + { + m_preGameModeViewTM = GetViewTM(); + // this should only occur for the main viewport and no others. + ShowCursor(); + + // If the user has selected game mode, enable outputting to any attached HMD and properly size the context + // to the resolution specified by the VR device. + if (gSettings.bEnableGameModeVR) + { + const AZ::VR::HMDDeviceInfo* deviceInfo = nullptr; + EBUS_EVENT_RESULT(deviceInfo, AZ::VR::HMDDeviceRequestBus, GetDeviceInfo); + AZ_Warning("Render Viewport", deviceInfo, "No VR device detected"); + + if (deviceInfo) + { + // Note: This may also need to adjust the viewport size + outputToHMD->Set(1); + SetActiveWindow(); + SetFocus(); + SetSelected(true); + } + } + SetCurrentCursor(STD_CURSOR_GAME); + } + } + break; + + case eNotify_OnEndGameMode: + if (GetIEditor()->GetViewManager()->GetGameViewport() == this) + { + SetCurrentCursor(STD_CURSOR_DEFAULT); + if (gSettings.bEnableGameModeVR) + { + outputToHMD->Set(0); + } + m_bInRotateMode = false; + m_bInMoveMode = false; + m_bInOrbitMode = false; + m_bInZoomMode = false; + + RestoreViewportAfterGameMode(); + } + break; + + case eNotify_OnCloseScene: + m_renderViewport->SetScene(nullptr); + SetDefaultCamera(); + break; + + case eNotify_OnEndSceneOpen: + UpdateScene(); + break; + + case eNotify_OnBeginNewScene: + PushDisableRendering(); + break; + + case eNotify_OnEndNewScene: + PopDisableRendering(); + + { + AZ::Aabb terrainAabb = AZ::Aabb::CreateFromPoint(AZ::Vector3::CreateZero()); + AzFramework::Terrain::TerrainDataRequestBus::BroadcastResult(terrainAabb, &AzFramework::Terrain::TerrainDataRequests::GetTerrainAabb); + float sx = terrainAabb.GetXExtent(); + float sy = terrainAabb.GetYExtent(); + + Matrix34 viewTM; + viewTM.SetIdentity(); + // Initial camera will be at middle of the map at the height of 2 + // meters above the terrain (default terrain height is 32) + viewTM.SetTranslation(Vec3(sx * 0.5f, sy * 0.5f, 34.0f)); + SetViewTM(viewTM); + } + break; + + case eNotify_OnBeginTerrainCreate: + PushDisableRendering(); + break; + + case eNotify_OnEndTerrainCreate: + PopDisableRendering(); + + { + AZ::Aabb terrainAabb = AZ::Aabb::CreateFromPoint(AZ::Vector3::CreateZero()); + AzFramework::Terrain::TerrainDataRequestBus::BroadcastResult(terrainAabb, &AzFramework::Terrain::TerrainDataRequests::GetTerrainAabb); + float sx = terrainAabb.GetXExtent(); + float sy = terrainAabb.GetYExtent(); + + Matrix34 viewTM; + viewTM.SetIdentity(); + // Initial camera will be at middle of the map at the height of 2 + // meters above the terrain (default terrain height is 32) + viewTM.SetTranslation(Vec3(sx * 0.5f, sy * 0.5f, 34.0f)); + SetViewTM(viewTM); + } + break; + + case eNotify_OnBeginLayerExport: + case eNotify_OnBeginSceneSave: + PushDisableRendering(); + break; + case eNotify_OnEndLayerExport: + case eNotify_OnEndSceneSave: + PopDisableRendering(); + break; + + case eNotify_OnBeginLoad: // disables viewport input when starting to load an existing level + case eNotify_OnBeginCreate: // disables viewport input when starting to create a new level + m_freezeViewportInput = true; + break; + + case eNotify_OnEndLoad: // enables viewport input when finished loading an existing level + case eNotify_OnEndCreate: // enables viewport input when finished creating a new level + m_freezeViewportInput = false; + break; + } +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::OnRender() +{ + if (m_rcClient.isEmpty()) + { + // Even in null rendering, update the view camera. + // This is necessary so that automated editor tests using the null renderer to test systems like dynamic vegetation + // are still able to manipulate the current logical camera position, even if nothing is rendered. + GetIEditor()->GetSystem()->SetViewCamera(m_Camera); + GetIEditor()->GetRenderer()->SetCamera(gEnv->pSystem->GetViewCamera()); + m_engine->RenderWorld(0, SRenderingPassInfo::CreateGeneralPassRenderingInfo(m_Camera), __FUNCTION__); + return; + } + + FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR); +} + +void EditorViewportWidget::OnBeginPrepareRender() +{ + if (!m_debugDisplay) + { + AzFramework::DebugDisplayRequestBus::BusPtr debugDisplayBus; + AzFramework::DebugDisplayRequestBus::Bind(debugDisplayBus, GetViewportId()); + AZ_Assert(debugDisplayBus, "Invalid DebugDisplayRequestBus."); + + m_debugDisplay = AzFramework::DebugDisplayRequestBus::FindFirstHandler(debugDisplayBus); + } + + if (!m_debugDisplay) + { + return; + } + + m_isOnPaint = true; + Update(); + m_isOnPaint = false; + + float fNearZ = GetIEditor()->GetConsoleVar("cl_DefaultNearPlane"); + float fFarZ = m_Camera.GetFarPlane(); + + CBaseObject* cameraObject = GetCameraObject(); + if (cameraObject) + { + AZ::Matrix3x3 lookThroughEntityCorrection = AZ::Matrix3x3::CreateIdentity(); + if (m_viewEntityId.IsValid()) + { + Camera::CameraRequestBus::EventResult(fNearZ, m_viewEntityId, &Camera::CameraComponentRequests::GetNearClipDistance); + Camera::CameraRequestBus::EventResult(fFarZ, m_viewEntityId, &Camera::CameraComponentRequests::GetFarClipDistance); + LmbrCentral::EditorCameraCorrectionRequestBus::EventResult( + lookThroughEntityCorrection, m_viewEntityId, &LmbrCentral::EditorCameraCorrectionRequests::GetTransformCorrection); + } + + m_viewTM = cameraObject->GetWorldTM() * AZMatrix3x3ToLYMatrix3x3(lookThroughEntityCorrection); + m_viewTM.OrthonormalizeFast(); + + m_Camera.SetMatrix(m_viewTM); + + int w = m_rcClient.width(); + int h = m_rcClient.height(); + + m_Camera.SetFrustum(w, h, GetFOV(), fNearZ, fFarZ); + } + else if (m_viewEntityId.IsValid()) + { + Camera::CameraRequestBus::EventResult(fNearZ, m_viewEntityId, &Camera::CameraComponentRequests::GetNearClipDistance); + Camera::CameraRequestBus::EventResult(fFarZ, m_viewEntityId, &Camera::CameraComponentRequests::GetFarClipDistance); + int w = m_rcClient.width(); + int h = m_rcClient.height(); + + m_Camera.SetFrustum(w, h, GetFOV(), fNearZ, fFarZ); + } + else + { + // Normal camera. + m_cameraObjectId = GUID_NULL; + int w = m_rcClient.width(); + int h = m_rcClient.height(); + + float fov = gSettings.viewports.fDefaultFov; + + // match viewport fov to default / selected title menu fov + if (GetFOV() != fov) + { + if (m_viewPane) + { + m_viewPane->OnFOVChanged(fov); + SetFOV(fov); + } + } + + // Just for editor: Aspect ratio fix when changing the viewport + if (!GetIEditor()->IsInGameMode()) + { + float viewportAspectRatio = float( w ) / h; + float targetAspectRatio = GetAspectRatio(); + if (targetAspectRatio > viewportAspectRatio) + { + // Correct for vertical FOV change. + float maxTargetHeight = float( w ) / targetAspectRatio; + fov = 2 * atanf((h * tan(fov / 2)) / maxTargetHeight); + } + } +#if 1 // ATOMSHIM FIXUP + m_Camera.SetFrustum(w, h, fov, fNearZ, 8000.0f); +#else + m_Camera.SetFrustum(w, h, fov, fNearZ, gEnv->p3DEngine->GetMaxViewDistance()); +#endif + } + + GetIEditor()->GetSystem()->SetViewCamera(m_Camera); + + if (GetIEditor()->IsInGameMode()) + { + return; + } + + PreWidgetRendering(); + + RenderAll(); + + // Draw 2D helpers. + TransformationMatrices backupSceneMatrices; + m_debugDisplay->DepthTestOff(); + //m_renderer->Set2DMode(m_rcClient.right(), m_rcClient.bottom(), backupSceneMatrices); + auto prevState = m_debugDisplay->GetState(); + m_debugDisplay->SetState(e_Mode3D | e_AlphaBlended | e_FillModeSolid | e_CullModeBack | e_DepthWriteOn | e_DepthTestOn); + + if (gSettings.viewports.bShowSafeFrame) + { + UpdateSafeFrame(); + RenderSafeFrame(); + } + + AzFramework::ViewportDebugDisplayEventBus::Event( + AzToolsFramework::GetEntityContextId(), &AzFramework::ViewportDebugDisplayEvents::DisplayViewport2d, + AzFramework::ViewportInfo{GetViewportId()}, *m_debugDisplay); + + m_debugDisplay->SetState(prevState); + m_debugDisplay->DepthTestOn(); + + PostWidgetRendering(); +<<<<<<< HEAD + +#if 0 // ATOMSHIM FIXUP + if (!m_renderer->IsStereoEnabled()) +#endif + { + GetIEditor()->GetSystem()->RenderStatistics(); + } +======= +>>>>>>> upstream/main +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::RenderAll() +{ + if (!m_debugDisplay) + { + return; + } + + // allow the override of in-editor visualization + AzFramework::ViewportDebugDisplayEventBus::Event( + AzToolsFramework::GetEntityContextId(), &AzFramework::ViewportDebugDisplayEvents::DisplayViewport, + AzFramework::ViewportInfo{ GetViewportId() }, *m_debugDisplay); + + m_entityVisibilityQuery.DisplayVisibility(*m_debugDisplay); + + if (m_manipulatorManager != nullptr) + { + using namespace AzToolsFramework::ViewportInteraction; + + m_debugDisplay->DepthTestOff(); + m_manipulatorManager->DrawManipulators( + *m_debugDisplay, GetCameraState(), + BuildMouseInteractionInternal( + MouseButtons(TranslateMouseButtons(QGuiApplication::mouseButtons())), + BuildKeyboardModifiers(QGuiApplication::queryKeyboardModifiers()), + BuildMousePickInternal(WidgetToViewport(mapFromGlobal(QCursor::pos()))))); + m_debugDisplay->DepthTestOn(); + } +} + +////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::UpdateSafeFrame() +{ + m_safeFrame = m_rcClient; + + if (m_safeFrame.height() == 0) + { + return; + } + + const bool allowSafeFrameBiggerThanViewport = false; + + float safeFrameAspectRatio = float( m_safeFrame.width()) / m_safeFrame.height(); + float targetAspectRatio = GetAspectRatio(); + bool viewportIsWiderThanSafeFrame = (targetAspectRatio <= safeFrameAspectRatio); + if (viewportIsWiderThanSafeFrame || allowSafeFrameBiggerThanViewport) + { + float maxSafeFrameWidth = m_safeFrame.height() * targetAspectRatio; + float widthDifference = m_safeFrame.width() - maxSafeFrameWidth; + + m_safeFrame.setLeft(m_safeFrame.left() + widthDifference * 0.5); + m_safeFrame.setRight(m_safeFrame.right() - widthDifference * 0.5); + } + else + { + float maxSafeFrameHeight = m_safeFrame.width() / targetAspectRatio; + float heightDifference = m_safeFrame.height() - maxSafeFrameHeight; + + m_safeFrame.setTop(m_safeFrame.top() + heightDifference * 0.5); + m_safeFrame.setBottom(m_safeFrame.bottom() - heightDifference * 0.5); + } + + m_safeFrame.adjust(0, 0, -1, -1); // <-- aesthetic improvement. + + const float SAFE_ACTION_SCALE_FACTOR = 0.05f; + m_safeAction = m_safeFrame; + m_safeAction.adjust(m_safeFrame.width() * SAFE_ACTION_SCALE_FACTOR, m_safeFrame.height() * SAFE_ACTION_SCALE_FACTOR, + -m_safeFrame.width() * SAFE_ACTION_SCALE_FACTOR, -m_safeFrame.height() * SAFE_ACTION_SCALE_FACTOR); + + const float SAFE_TITLE_SCALE_FACTOR = 0.1f; + m_safeTitle = m_safeFrame; + m_safeTitle.adjust(m_safeFrame.width() * SAFE_TITLE_SCALE_FACTOR, m_safeFrame.height() * SAFE_TITLE_SCALE_FACTOR, + -m_safeFrame.width() * SAFE_TITLE_SCALE_FACTOR, -m_safeFrame.height() * SAFE_TITLE_SCALE_FACTOR); +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::RenderSafeFrame() +{ + RenderSafeFrame(m_safeFrame, 0.75f, 0.75f, 0, 0.8f); + RenderSafeFrame(m_safeAction, 0, 0.85f, 0.80f, 0.8f); + RenderSafeFrame(m_safeTitle, 0.80f, 0.60f, 0, 0.8f); +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::RenderSafeFrame(const QRect& frame, float r, float g, float b, float a) +{ + m_debugDisplay->SetColor(r, g, b, a); + + const int LINE_WIDTH = 2; + for (int i = 0; i < LINE_WIDTH; i++) + { + AZ::Vector3 topLeft(frame.left() + i, frame.top() + i, 0); + AZ::Vector3 bottomRight(frame.right() - i, frame.bottom() - i, 0); + m_debugDisplay->DrawWireBox(topLeft, bottomRight); + } +} + +////////////////////////////////////////////////////////////////////////// +float EditorViewportWidget::GetAspectRatio() const +{ + return gSettings.viewports.fDefaultAspectRatio; +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::RenderSnapMarker() +{ + if (!gSettings.snap.markerDisplay) + { + return; + } + + QPoint point = QCursor::pos(); + ScreenToClient(point); + Vec3 p = MapViewToCP(point); + + DisplayContext& dc = m_displayContext; + + float fScreenScaleFactor = GetScreenScaleFactor(p); + + Vec3 x(1, 0, 0); + Vec3 y(0, 1, 0); + Vec3 z(0, 0, 1); + x = x * gSettings.snap.markerSize * fScreenScaleFactor * 0.1f; + y = y * gSettings.snap.markerSize * fScreenScaleFactor * 0.1f; + z = z * gSettings.snap.markerSize * fScreenScaleFactor * 0.1f; + + dc.SetColor(gSettings.snap.markerColor); + dc.DrawLine(p - x, p + x); + dc.DrawLine(p - y, p + y); + dc.DrawLine(p - z, p + z); + + point = WorldToView(p); + + int s = 8; + dc.DrawLine2d(point + QPoint(-s, -s), point + QPoint(s, -s), 0); + dc.DrawLine2d(point + QPoint(-s, s), point + QPoint(s, s), 0); + dc.DrawLine2d(point + QPoint(-s, -s), point + QPoint(-s, s), 0); + dc.DrawLine2d(point + QPoint(s, -s), point + QPoint(s, s), 0); +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::OnMenuResolutionCustom() +{ + CCustomResolutionDlg resDlg(width(), height(), parentWidget()); + if (resDlg.exec() == QDialog::Accepted) + { + ResizeView(resDlg.GetWidth(), resDlg.GetHeight()); + + const QString text = QString::fromLatin1("%1 x %2").arg(resDlg.GetWidth()).arg(resDlg.GetHeight()); + + QStringList customResPresets; + CViewportTitleDlg::LoadCustomPresets("ResPresets", "ResPresetFor2ndView", customResPresets); + CViewportTitleDlg::UpdateCustomPresets(text, customResPresets); + CViewportTitleDlg::SaveCustomPresets("ResPresets", "ResPresetFor2ndView", customResPresets); + } +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::OnMenuCreateCameraEntityFromCurrentView() +{ + Camera::EditorCameraSystemRequestBus::Broadcast(&Camera::EditorCameraSystemRequests::CreateCameraEntityFromViewport); +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::OnMenuSelectCurrentCamera() +{ + CBaseObject* pCameraObject = GetCameraObject(); + + if (pCameraObject && !pCameraObject->IsSelected()) + { + GetIEditor()->BeginUndo(); + IObjectManager* pObjectManager = GetIEditor()->GetObjectManager(); + pObjectManager->ClearSelection(); + pObjectManager->SelectObject(pCameraObject); + GetIEditor()->AcceptUndo("Select Current Camera"); + } +} + +AzFramework::CameraState EditorViewportWidget::GetCameraState() +{ + return m_renderViewport->GetCameraState(); +} + +bool EditorViewportWidget::GridSnappingEnabled() +{ + return GetViewManager()->GetGrid()->IsEnabled(); +} + +float EditorViewportWidget::GridSize() +{ + const CGrid* grid = GetViewManager()->GetGrid(); + return grid->scale * grid->size; +} + +bool EditorViewportWidget::ShowGrid() +{ + return gSettings.viewports.bShowGridGuide; +} + +bool EditorViewportWidget::AngleSnappingEnabled() +{ + return GetViewManager()->GetGrid()->IsAngleSnapEnabled(); +} + +float EditorViewportWidget::AngleStep() +{ + return GetViewManager()->GetGrid()->GetAngleSnap(); +} + +AZ::Vector3 EditorViewportWidget::PickTerrain(const QPoint& point) +{ + FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR); + + return LYVec3ToAZVec3(ViewToWorld(point, nullptr, true)); +} + +AZ::EntityId EditorViewportWidget::PickEntity(const QPoint& point) +{ + FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR); + + PreWidgetRendering(); + + AZ::EntityId entityId; + HitContext hitInfo; + hitInfo.view = this; + if (HitTest(point, hitInfo)) + { + if (hitInfo.object && (hitInfo.object->GetType() == OBJTYPE_AZENTITY)) + { + auto entityObject = static_cast(hitInfo.object); + entityId = entityObject->GetAssociatedEntityId(); + } + } + + PostWidgetRendering(); + + return entityId; +} + +float EditorViewportWidget::TerrainHeight(const AZ::Vector2& position) +{ + return GetIEditor()->GetTerrainElevation(position.GetX(), position.GetY()); +} + +void EditorViewportWidget::FindVisibleEntities(AZStd::vector& visibleEntitiesOut) +{ + FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR); + + visibleEntitiesOut.assign(m_entityVisibilityQuery.Begin(), m_entityVisibilityQuery.End()); +} + +QPoint EditorViewportWidget::ViewportWorldToScreen(const AZ::Vector3& worldPosition) +{ + return m_renderViewport->ViewportWorldToScreen(worldPosition); +} + +bool EditorViewportWidget::IsViewportInputFrozen() +{ + return m_freezeViewportInput; +} + +void EditorViewportWidget::FreezeViewportInput(bool freeze) +{ + m_freezeViewportInput = freeze; +} + +QWidget* EditorViewportWidget::GetWidgetForViewportContextMenu() +{ + return this; +} + +void EditorViewportWidget::BeginWidgetContext() +{ + PreWidgetRendering(); +} + +void EditorViewportWidget::EndWidgetContext() +{ + PostWidgetRendering(); +} + +bool EditorViewportWidget::ShowingWorldSpace() +{ + using namespace AzToolsFramework::ViewportInteraction; + return BuildKeyboardModifiers(QGuiApplication::queryKeyboardModifiers()).Shift(); +} + +void EditorViewportWidget::SetViewportId(int id) +{ + CViewport::SetViewportId(id); + + // Now that we have an ID, we can initialize our viewport. + m_renderViewport = new AtomToolsFramework::RenderViewportWidget(id, this); + m_defaultViewportContextName = m_renderViewport->GetViewportContext()->GetName(); + QBoxLayout* layout = new QBoxLayout(QBoxLayout::Direction::TopToBottom, this); + layout->setContentsMargins(QMargins()); + layout->addWidget(m_renderViewport); + + auto viewportContext = m_renderViewport->GetViewportContext(); + viewportContext->ConnectViewMatrixChangedHandler(m_cameraViewMatrixChangeHandler); + viewportContext->ConnectProjectionMatrixChangedHandler(m_cameraProjectionMatrixChangeHandler); + + m_renderViewport->GetControllerList()->Add(AZStd::make_shared()); + + if (ed_useNewCameraSystem) + { + m_renderViewport->GetControllerList()->Add(AZStd::make_shared()); + } + else + { + m_renderViewport->GetControllerList()->Add(AZStd::make_shared()); + } + + UpdateScene(); + + if (m_pPrimaryViewport == this) + { + SetAsActiveViewport(); + } +} + +void EditorViewportWidget::ConnectViewportInteractionRequestBus() +{ + AzToolsFramework::ViewportInteraction::ViewportFreezeRequestBus::Handler::BusConnect(GetViewportId()); + AzToolsFramework::ViewportInteraction::MainEditorViewportInteractionRequestBus::Handler::BusConnect(GetViewportId()); + m_viewportUi.ConnectViewportUiBus(GetViewportId()); + + AzFramework::InputSystemCursorConstraintRequestBus::Handler::BusConnect(); +} + +void EditorViewportWidget::DisconnectViewportInteractionRequestBus() +{ + AzFramework::InputSystemCursorConstraintRequestBus::Handler::BusDisconnect(); + + m_viewportUi.DisconnectViewportUiBus(); + AzToolsFramework::ViewportInteraction::MainEditorViewportInteractionRequestBus::Handler::BusDisconnect(); + AzToolsFramework::ViewportInteraction::ViewportFreezeRequestBus::Handler::BusDisconnect(); +} + +namespace AZ::ViewportHelpers +{ + void ToggleBool(bool* variable, bool* disableVariableIfOn) + { + *variable = !*variable; + if (*variable && disableVariableIfOn) + { + *disableVariableIfOn = false; + } + } + + void ToggleInt(int* variable) + { + *variable = !*variable; + } + + void AddCheckbox(QMenu* menu, const QString& text, bool* variable, bool* disableVariableIfOn = nullptr) + { + QAction* action = menu->addAction(text); + QObject::connect(action, &QAction::triggered, action, [variable, disableVariableIfOn] { ToggleBool(variable, disableVariableIfOn); + }); + action->setCheckable(true); + action->setChecked(*variable); + } + + void AddCheckbox(QMenu* menu, const QString& text, int* variable) + { + QAction* action = menu->addAction(text); + QObject::connect(action, &QAction::triggered, action, [variable] { ToggleInt(variable); + }); + action->setCheckable(true); + action->setChecked(*variable); + } +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::OnTitleMenu(QMenu* menu) +{ + const int nWireframe = gEnv->pConsole->GetCVar("r_wireframe")->GetIVal(); + QAction* action = menu->addAction(tr("Wireframe")); + connect(action, &QAction::triggered, action, []() + { + ICVar* piVar(gEnv->pConsole->GetCVar("r_wireframe")); + int nRenderMode = piVar->GetIVal(); + if (nRenderMode != R_WIREFRAME_MODE) + { + piVar->Set(R_WIREFRAME_MODE); + } + else + { + piVar->Set(R_SOLID_MODE); + } + }); + action->setCheckable(true); + action->setChecked(nWireframe == R_WIREFRAME_MODE); + + const bool bDisplayLabels = GetIEditor()->GetDisplaySettings()->IsDisplayLabels(); + action = menu->addAction(tr("Labels")); + connect(action, &QAction::triggered, this, [bDisplayLabels] {GetIEditor()->GetDisplaySettings()->DisplayLabels(!bDisplayLabels); + }); + action->setCheckable(true); + action->setChecked(bDisplayLabels); + + AZ::ViewportHelpers::AddCheckbox(menu, tr("Show Safe Frame"), &gSettings.viewports.bShowSafeFrame); + AZ::ViewportHelpers::AddCheckbox(menu, tr("Show Construction Plane"), &gSettings.snap.constructPlaneDisplay); + AZ::ViewportHelpers::AddCheckbox(menu, tr("Show Trigger Bounds"), &gSettings.viewports.bShowTriggerBounds); + AZ::ViewportHelpers::AddCheckbox(menu, tr("Show Icons"), &gSettings.viewports.bShowIcons, &gSettings.viewports.bShowSizeBasedIcons); + AZ::ViewportHelpers::AddCheckbox(menu, tr("Show Size-based Icons"), &gSettings.viewports.bShowSizeBasedIcons, &gSettings.viewports.bShowIcons); + AZ::ViewportHelpers::AddCheckbox(menu, tr("Show Helpers of Frozen Objects"), &gSettings.viewports.nShowFrozenHelpers); + + if (!m_predefinedAspectRatios.IsEmpty()) + { + QMenu* aspectRatiosMenu = menu->addMenu(tr("Target Aspect Ratio")); + + for (size_t i = 0; i < m_predefinedAspectRatios.GetCount(); ++i) + { + const QString& aspectRatioString = m_predefinedAspectRatios.GetName(i); + QAction* aspectRatioAction = aspectRatiosMenu->addAction(aspectRatioString); + connect(aspectRatioAction, &QAction::triggered, this, [i, this] { + const float aspect = m_predefinedAspectRatios.GetValue(i); + gSettings.viewports.fDefaultAspectRatio = aspect; + }); + aspectRatioAction->setCheckable(true); + aspectRatioAction->setChecked(m_predefinedAspectRatios.IsCurrent(i)); + } + } + + // Set ourself as the active viewport so the following actions create a camera from this view + GetIEditor()->GetViewManager()->SelectViewport(this); + + CGameEngine* gameEngine = GetIEditor()->GetGameEngine(); + + if (Camera::EditorCameraSystemRequestBus::HasHandlers()) + { + action = menu->addAction(tr("Create camera entity from current view")); + connect(action, &QAction::triggered, this, &EditorViewportWidget::OnMenuCreateCameraEntityFromCurrentView); + + if (!gameEngine || !gameEngine->IsLevelLoaded()) + { + action->setEnabled(false); + action->setToolTip(tr(AZ::ViewportHelpers::TextCantCreateCameraNoLevel)); + menu->setToolTipsVisible(true); + } + } + + if (!gameEngine || !gameEngine->IsLevelLoaded()) + { + action->setEnabled(false); + action->setToolTip(tr(AZ::ViewportHelpers::TextCantCreateCameraNoLevel)); + menu->setToolTipsVisible(true); + } + + if (GetCameraObject()) + { + action = menu->addAction(tr("Select Current Camera")); + connect(action, &QAction::triggered, this, &EditorViewportWidget::OnMenuSelectCurrentCamera); + } + + // Add Cameras. + bool bHasCameras = AddCameraMenuItems(menu); + EditorViewportWidget* pFloatingViewport = nullptr; + + if (GetIEditor()->GetViewManager()->GetViewCount() > 1) + { + for (int i = 0; i < GetIEditor()->GetViewManager()->GetViewCount(); ++i) + { + CViewport* vp = GetIEditor()->GetViewManager()->GetView(i); + if (!vp) + { + continue; + } + + if (viewport_cast(vp) == nullptr) + { + continue; + } + + if (vp->GetViewportId() == MAX_NUM_VIEWPORTS - 1) + { + menu->addSeparator(); + + QMenu* floatViewMenu = menu->addMenu(tr("Floating View")); + + pFloatingViewport = (EditorViewportWidget*)vp; + pFloatingViewport->AddCameraMenuItems(floatViewMenu); + + if (bHasCameras) + { + floatViewMenu->addSeparator(); + } + + QMenu* resolutionMenu = floatViewMenu->addMenu(tr("Resolution")); + + QStringList customResPresets; + CViewportTitleDlg::LoadCustomPresets("ResPresets", "ResPresetFor2ndView", customResPresets); + CViewportTitleDlg::AddResolutionMenus(resolutionMenu, [this](int width, int height) { ResizeView(width, height); }, customResPresets); + if (!resolutionMenu->actions().isEmpty()) + { + resolutionMenu->addSeparator(); + } + QAction* customResolutionAction = resolutionMenu->addAction(tr("Custom...")); + connect(customResolutionAction, &QAction::triggered, this, &EditorViewportWidget::OnMenuResolutionCustom); + break; + } + } + } +} + +////////////////////////////////////////////////////////////////////////// +bool EditorViewportWidget::AddCameraMenuItems(QMenu* menu) +{ + if (!menu->isEmpty()) + { + menu->addSeparator(); + } + + AZ::ViewportHelpers::AddCheckbox(menu, "Lock Camera Movement", &m_bLockCameraMovement); + menu->addSeparator(); + + // Camera Sub menu + QMenu* customCameraMenu = menu->addMenu(tr("Camera")); + + QAction* action = customCameraMenu->addAction("Editor Camera"); + action->setCheckable(true); + action->setChecked(m_viewSourceType == ViewSourceType::None); + connect(action, &QAction::triggered, this, &EditorViewportWidget::SetDefaultCamera); + + AZ::EBusAggregateResults getCameraResults; + Camera::CameraBus::BroadcastResult(getCameraResults, &Camera::CameraRequests::GetCameras); + + const int numCameras = getCameraResults.values.size(); + + // only enable if we're editing a sequence in Track View and have cameras in the level + bool enableSequenceCameraMenu = (GetIEditor()->GetAnimation()->GetSequence() && numCameras); + + action = customCameraMenu->addAction(tr("Sequence Camera")); + action->setCheckable(true); + action->setChecked(m_viewSourceType == ViewSourceType::SequenceCamera); + action->setEnabled(enableSequenceCameraMenu); + connect(action, &QAction::triggered, this, &EditorViewportWidget::SetSequenceCamera); + + QVector additionalCameras; + additionalCameras.reserve(getCameraResults.values.size()); + + for (const AZ::EntityId& entityId : getCameraResults.values) + { + AZStd::string entityName; + AZ::ComponentApplicationBus::BroadcastResult(entityName, &AZ::ComponentApplicationRequests::GetEntityName, entityId); + action = new QAction(QString(entityName.c_str()), nullptr); + additionalCameras.append(action); + action->setCheckable(true); + action->setChecked(m_viewEntityId == entityId && m_viewSourceType == ViewSourceType::CameraComponent); + connect(action, &QAction::triggered, this, [this, entityId](bool isChecked) + { + if (isChecked) + { + SetComponentCamera(entityId); + } + else + { + SetDefaultCamera(); + } + }); + } + + std::sort(additionalCameras.begin(), additionalCameras.end(), [] (QAction* a1, QAction* a2) { + return QString::compare(a1->text(), a2->text(), Qt::CaseInsensitive) < 0; + }); + + for (QAction* cameraAction : additionalCameras) + { + customCameraMenu->addAction(cameraAction); + } + + action = customCameraMenu->addAction(tr("Look through entity")); + AzToolsFramework::EntityIdList selectedEntityList; + AzToolsFramework::ToolsApplicationRequests::Bus::BroadcastResult(selectedEntityList, &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntities); + action->setCheckable(selectedEntityList.size() > 0 || m_viewSourceType == ViewSourceType::AZ_Entity); + action->setEnabled(selectedEntityList.size() > 0 || m_viewSourceType == ViewSourceType::AZ_Entity); + action->setChecked(m_viewSourceType == ViewSourceType::AZ_Entity); + connect(action, &QAction::triggered, this, [this](bool isChecked) + { + if (isChecked) + { + AzToolsFramework::EntityIdList selectedEntityList; + AzToolsFramework::ToolsApplicationRequests::Bus::BroadcastResult(selectedEntityList, &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntities); + if (selectedEntityList.size()) + { + SetEntityAsCamera(*selectedEntityList.begin()); + } + } + else + { + SetDefaultCamera(); + } + }); + return true; +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::ResizeView(int width, int height) +{ + const QRect rView = rect().translated(mapToGlobal(QPoint())); + int deltaWidth = width - rView.width(); + int deltaHeight = height - rView.height(); + + if (window()->isFullScreen()) + { + setGeometry(rView.left(), rView.top(), rView.width() + deltaWidth, rView.height() + deltaHeight); + } + else + { + QWidget* window = this->window(); + if (window->isMaximized()) + { + window->showNormal(); + } + + const QSize deltaSize = QSize(width, height) - size(); + window->move(0, 0); + window->resize(window->size() + deltaSize); + } +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::ToggleCameraObject() +{ + if (m_viewSourceType == ViewSourceType::SequenceCamera) + { + gEnv->p3DEngine->GetPostEffectBaseGroup()->SetParam("Dof_Active", 0.0f); + ResetToViewSourceType(ViewSourceType::LegacyCamera); + } + else + { + ResetToViewSourceType(ViewSourceType::SequenceCamera); + } + PostCameraSet(); + GetIEditor()->GetAnimation()->ForceAnimation(); +} + + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::SetCamera(const CCamera& camera) +{ + m_Camera = camera; + SetViewTM(m_Camera.GetMatrix()); +} + +////////////////////////////////////////////////////////////////////////// +float EditorViewportWidget::GetCameraMoveSpeed() const +{ + return gSettings.cameraMoveSpeed; +} + +////////////////////////////////////////////////////////////////////////// +float EditorViewportWidget::GetCameraRotateSpeed() const +{ + return gSettings.cameraRotateSpeed; +} + +////////////////////////////////////////////////////////////////////////// +bool EditorViewportWidget::GetCameraInvertYRotation() const +{ + return gSettings.invertYRotation; +} + +////////////////////////////////////////////////////////////////////////// +float EditorViewportWidget::GetCameraInvertPan() const +{ + return gSettings.invertPan; +} + +////////////////////////////////////////////////////////////////////////// +EditorViewportWidget* EditorViewportWidget::GetPrimaryViewport() +{ + return m_pPrimaryViewport; +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::focusOutEvent([[maybe_unused]] QFocusEvent* event) +{ + // if we lose focus, the keyboard map needs to be cleared immediately + if (!m_keyDown.isEmpty()) + { + m_keyDown.clear(); + + releaseKeyboard(); + } +} + +void EditorViewportWidget::keyPressEvent(QKeyEvent* event) +{ + // Special case Escape key and bubble way up to the top level parent so that it can cancel us out of any active tool + // or clear the current selection + if (event->key() == Qt::Key_Escape) + { + QCoreApplication::sendEvent(GetIEditor()->GetEditorMainWindow(), event); + } + + // NOTE: we keep track of keypresses and releases explicitly because the OS/Qt will insert a slight delay between sending + // keyevents when the key is held down. This is standard, but makes responding to key events for game style input silly + // because we want the movement to be butter smooth. + if (!event->isAutoRepeat()) + { + m_keyDown.insert(event->key()); + } + + QtViewport::keyPressEvent(event); + +#if defined(AZ_PLATFORM_WINDOWS) + // In game mode on windows we need to forward raw text events to the input system. + if (GetIEditor()->IsInGameMode() && GetType() == ET_ViewportCamera) + { + // Get the QString as a '\0'-terminated array of unsigned shorts. + // The result remains valid until the string is modified. + const ushort* codeUnitsUTF16 = event->text().utf16(); + while (ushort codeUnitUTF16 = *codeUnitsUTF16) + { + AzFramework::RawInputNotificationBusWindows::Broadcast(&AzFramework::RawInputNotificationsWindows::OnRawInputCodeUnitUTF16Event, codeUnitUTF16); + ++codeUnitsUTF16; + } + } +#endif // defined(AZ_PLATFORM_WINDOWS) +} + +void EditorViewportWidget::SetViewTM(const Matrix34& viewTM, bool bMoveOnly) +{ + Matrix34 camMatrix = viewTM; + + // If no collision flag set do not check for terrain elevation. + if (GetType() == ET_ViewportCamera) + { + if ((GetIEditor()->GetDisplaySettings()->GetSettings() & SETTINGS_NOCOLLISION) == 0) + { + Vec3 p = camMatrix.GetTranslation(); + bool adjustCameraElevation = true; + auto terrain = AzFramework::Terrain::TerrainDataRequestBus::FindFirstHandler(); + if (terrain) + { + AZ::Aabb terrainAabb(terrain->GetTerrainAabb()); + + // Adjust the AABB to include all Z values. Since the goal here is to snap the camera to the terrain height if + // it's below the terrain, we only want to verify the camera is within the XY bounds of the terrain to adjust the elevation. + terrainAabb.SetMin(AZ::Vector3(terrainAabb.GetMin().GetX(), terrainAabb.GetMin().GetY(), -AZ::Constants::FloatMax)); + terrainAabb.SetMax(AZ::Vector3(terrainAabb.GetMax().GetX(), terrainAabb.GetMax().GetY(), AZ::Constants::FloatMax)); + + if (!terrainAabb.Contains(LYVec3ToAZVec3(p))) + { + adjustCameraElevation = false; + } + else if (terrain->GetIsHoleFromFloats(p.x, p.y)) + { + adjustCameraElevation = false; + } + } + + if (adjustCameraElevation) + { + float z = GetIEditor()->GetTerrainElevation(p.x, p.y); + if (p.z < z + 0.25) + { + p.z = z + 0.25; + camMatrix.SetTranslation(p); + } + } + } + + // Also force this position on game. + if (GetIEditor()->GetGameEngine()) + { + GetIEditor()->GetGameEngine()->SetPlayerViewMatrix(viewTM); + } + } + + CBaseObject* cameraObject = GetCameraObject(); + if (cameraObject) + { + // Ignore camera movement if locked. + if (IsCameraMovementLocked() || (!GetIEditor()->GetAnimation()->IsRecordMode() && !IsCameraObjectMove())) + { + return; + } + + AZ::Matrix3x3 lookThroughEntityCorrection = AZ::Matrix3x3::CreateIdentity(); + if (m_viewEntityId.IsValid()) + { + LmbrCentral::EditorCameraCorrectionRequestBus::EventResult( + lookThroughEntityCorrection, m_viewEntityId, + &LmbrCentral::EditorCameraCorrectionRequests::GetInverseTransformCorrection); + } + + if (m_pressedKeyState != KeyPressedState::PressedInPreviousFrame) + { + CUndo undo("Move Camera"); + if (bMoveOnly) + { + // specify eObjectUpdateFlags_UserInput so that an undo command gets logged + cameraObject->SetWorldPos(camMatrix.GetTranslation(), eObjectUpdateFlags_UserInput); + } + else + { + // specify eObjectUpdateFlags_UserInput so that an undo command gets logged + cameraObject->SetWorldTM(camMatrix * AZMatrix3x3ToLYMatrix3x3(lookThroughEntityCorrection), eObjectUpdateFlags_UserInput); + } + } + else + { + if (bMoveOnly) + { + // Do not specify eObjectUpdateFlags_UserInput, so that an undo command does not get logged; we covered it already when m_pressedKeyState was PressedThisFrame + cameraObject->SetWorldPos(camMatrix.GetTranslation()); + } + else + { + // Do not specify eObjectUpdateFlags_UserInput, so that an undo command does not get logged; we covered it already when m_pressedKeyState was PressedThisFrame + cameraObject->SetWorldTM(camMatrix * AZMatrix3x3ToLYMatrix3x3(lookThroughEntityCorrection)); + } + } + + using namespace AzToolsFramework; + ComponentEntityObjectRequestBus::Event(cameraObject, &ComponentEntityObjectRequestBus::Events::UpdatePreemptiveUndoCache); + } + else if (m_viewEntityId.IsValid()) + { + // Ignore camera movement if locked. + if (IsCameraMovementLocked() || (!GetIEditor()->GetAnimation()->IsRecordMode() && !IsCameraObjectMove())) + { + return; + } + + if (m_pressedKeyState != KeyPressedState::PressedInPreviousFrame) + { + CUndo undo("Move Camera"); + if (bMoveOnly) + { + AZ::TransformBus::Event( + m_viewEntityId, &AZ::TransformInterface::SetWorldTranslation, + LYVec3ToAZVec3(camMatrix.GetTranslation())); + } + else + { + AZ::TransformBus::Event( + m_viewEntityId, &AZ::TransformInterface::SetWorldTM, + LYTransformToAZTransform(camMatrix)); + } + } + else + { + if (bMoveOnly) + { + AZ::TransformBus::Event( + m_viewEntityId, &AZ::TransformInterface::SetWorldTranslation, + LYVec3ToAZVec3(camMatrix.GetTranslation())); + } + else + { + AZ::TransformBus::Event( + m_viewEntityId, &AZ::TransformInterface::SetWorldTM, + LYTransformToAZTransform(camMatrix)); + } + } + + AzToolsFramework::PropertyEditorGUIMessages::Bus::Broadcast( + &AzToolsFramework::PropertyEditorGUIMessages::RequestRefresh, + AzToolsFramework::PropertyModificationRefreshLevel::Refresh_AttributesAndValues); + } + + if (m_pressedKeyState == KeyPressedState::PressedThisFrame) + { + m_pressedKeyState = KeyPressedState::PressedInPreviousFrame; + } + + QtViewport::SetViewTM(camMatrix); + + m_Camera.SetMatrix(camMatrix); +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::RenderSelectedRegion() +{ + if (!m_engine) + { + return; + } + + AABB box; + GetIEditor()->GetSelectedRegion(box); + if (box.IsEmpty()) + { + return; + } + + float x1 = box.min.x; + float y1 = box.min.y; + float x2 = box.max.x; + float y2 = box.max.y; + + DisplayContext& dc = m_displayContext; + + float fMaxSide = MAX(y2 - y1, x2 - x1); + if (fMaxSide < 0.1f) + { + return; + } + float fStep = fMaxSide / 100.0f; + + float fMinZ = 0; + float fMaxZ = 0; + + // Draw yellow border lines. + dc.SetColor(1, 1, 0, 1); + float offset = 0.01f; + Vec3 p1, p2; + + const float defaultTerrainHeight = AzFramework::Terrain::TerrainDataRequests::GetDefaultTerrainHeight(); + auto terrain = AzFramework::Terrain::TerrainDataRequestBus::FindFirstHandler(); + + for (float y = y1; y < y2; y += fStep) + { + p1.x = x1; + p1.y = y; + p1.z = terrain ? terrain->GetHeightFromFloats(p1.x, p1.y) + offset : defaultTerrainHeight + offset; + + p2.x = x1; + p2.y = y + fStep; + p2.z = terrain ? terrain->GetHeightFromFloats(p2.x, p2.y) + offset : defaultTerrainHeight + offset; + dc.DrawLine(p1, p2); + + p1.x = x2; + p1.y = y; + p1.z = terrain ? terrain->GetHeightFromFloats(p1.x, p1.y) + offset : defaultTerrainHeight + offset; + + p2.x = x2; + p2.y = y + fStep; + p2.z = terrain ? terrain->GetHeightFromFloats(p2.x, p2.y) + offset : defaultTerrainHeight + offset; + dc.DrawLine(p1, p2); + + fMinZ = min(fMinZ, min(p1.z, p2.z)); + fMaxZ = max(fMaxZ, max(p1.z, p2.z)); + } + for (float x = x1; x < x2; x += fStep) + { + p1.x = x; + p1.y = y1; + p1.z = terrain ? terrain->GetHeightFromFloats(p1.x, p1.y) + offset : defaultTerrainHeight + offset; + + p2.x = x + fStep; + p2.y = y1; + p2.z = terrain ? terrain->GetHeightFromFloats(p2.x, p2.y) + offset : defaultTerrainHeight + offset; + dc.DrawLine(p1, p2); + + p1.x = x; + p1.y = y2; + p1.z = terrain ? terrain->GetHeightFromFloats(p1.x, p1.y) + offset : defaultTerrainHeight + offset; + + p2.x = x + fStep; + p2.y = y2; + p2.z = terrain ? terrain->GetHeightFromFloats(p2.x, p2.y) + offset : defaultTerrainHeight + offset; + dc.DrawLine(p1, p2); + + fMinZ = min(fMinZ, min(p1.z, p2.z)); + fMaxZ = max(fMaxZ, max(p1.z, p2.z)); + } + + { + // Draw a box area + float fBoxOver = fMaxSide / 5.0f; + float fBoxHeight = fBoxOver + fMaxZ - fMinZ; + + ColorB boxColor(64, 64, 255, 128); // light blue + ColorB transparent(boxColor.r, boxColor.g, boxColor.b, 0); + + Vec3 base[] = { + Vec3(x1, y1, fMinZ), + Vec3(x2, y1, fMinZ), + Vec3(x2, y2, fMinZ), + Vec3(x1, y2, fMinZ) + }; + + + // Generate vertices + static AABB boxPrev(AABB::RESET); + static std::vector verts; + static std::vector colors; + + if (!IsEquivalent(boxPrev, box)) + { + verts.resize(0); + colors.resize(0); + for (int i = 0; i < 4; ++i) + { + Vec3& p = base[i]; + + verts.push_back(p); + verts.push_back(Vec3(p.x, p.y, p.z + fBoxHeight)); + verts.push_back(Vec3(p.x, p.y, p.z + fBoxHeight + fBoxOver)); + + colors.push_back(boxColor); + colors.push_back(boxColor); + colors.push_back(transparent); + } + boxPrev = box; + } + + // Generate indices + const int numInds = 4 * 12; + static vtx_idx inds[numInds]; + static bool bNeedIndsInit = true; + if (bNeedIndsInit) + { + vtx_idx* pInds = &inds[0]; + + for (int i = 0; i < 4; ++i) + { + int over = 0; + if (i == 3) + { + over = -12; + } + + int ind = i * 3; + *pInds++ = ind; + *pInds++ = ind + 3 + over; + *pInds++ = ind + 1; + + *pInds++ = ind + 1; + *pInds++ = ind + 3 + over; + *pInds++ = ind + 4 + over; + + ind = i * 3 + 1; + *pInds++ = ind; + *pInds++ = ind + 3 + over; + *pInds++ = ind + 1; + + *pInds++ = ind + 1; + *pInds++ = ind + 3 + over; + *pInds++ = ind + 4 + over; + } + bNeedIndsInit = false; + } + + // Draw lines + for (int i = 0; i < 4; ++i) + { + Vec3& p = base[i]; + + dc.DrawLine(p, Vec3(p.x, p.y, p.z + fBoxHeight), ColorF(1, 1, 0, 1), ColorF(1, 1, 0, 1)); + dc.DrawLine(Vec3(p.x, p.y, p.z + fBoxHeight), Vec3(p.x, p.y, p.z + fBoxHeight + fBoxOver), ColorF(1, 1, 0, 1), ColorF(1, 1, 0, 0)); + } + + // Draw volume + dc.DepthWriteOff(); + dc.CullOff(); + dc.pRenderAuxGeom->DrawTriangles(&verts[0], verts.size(), &inds[0], numInds, &colors[0]); + dc.CullOn(); + dc.DepthWriteOn(); + } +} + +Vec3 EditorViewportWidget::WorldToView3D(const Vec3& wp, [[maybe_unused]] int nFlags) const +{ + Vec3 out(0, 0, 0); + float x, y, z; + + ProjectToScreen(wp.x, wp.y, wp.z, &x, &y, &z); + if (_finite(x) && _finite(y) && _finite(z)) + { + out.x = (x / 100) * m_rcClient.width(); + out.y = (y / 100) * m_rcClient.height(); + out.x /= QHighDpiScaling::factor(windowHandle()->screen()); + out.y /= QHighDpiScaling::factor(windowHandle()->screen()); + out.z = z; + } + return out; +} + +////////////////////////////////////////////////////////////////////////// +QPoint EditorViewportWidget::WorldToView(const Vec3& wp) const +{ + return m_renderViewport->ViewportWorldToScreen(LYVec3ToAZVec3(wp)); +} +////////////////////////////////////////////////////////////////////////// +QPoint EditorViewportWidget::WorldToViewParticleEditor(const Vec3& wp, int width, int height) const +{ + QPoint p; + float x, y, z; + + ProjectToScreen(wp.x, wp.y, wp.z, &x, &y, &z); + if (_finite(x) || _finite(y)) + { + p.rx() = (x / 100) * width; + p.ry() = (y / 100) * height; + } + else + { + QPoint(0, 0); + } + return p; +} + +////////////////////////////////////////////////////////////////////////// +Vec3 EditorViewportWidget::ViewToWorld(const QPoint& vp, bool* collideWithTerrain, bool onlyTerrain, bool bSkipVegetation, bool bTestRenderMesh, bool* collideWithObject) const +{ + AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::Editor); + + AZ_UNUSED(collideWithTerrain) + AZ_UNUSED(onlyTerrain) + AZ_UNUSED(bTestRenderMesh) + AZ_UNUSED(bSkipVegetation) + AZ_UNUSED(bSkipVegetation) + AZ_UNUSED(collideWithObject) + + auto ray = m_renderViewport->ViewportScreenToWorldRay(vp); + if (!ray.has_value()) + { + return Vec3(0, 0, 0); + } + + const float maxDistance = 10000.f; + Vec3 v = AZVec3ToLYVec3(ray.value().direction) * maxDistance; + + if (!_finite(v.x) || !_finite(v.y) || !_finite(v.z)) + { + return Vec3(0, 0, 0); + } + + Vec3 colp = AZVec3ToLYVec3(ray.value().origin) + 0.002f * v; + + return colp; +} + +////////////////////////////////////////////////////////////////////////// +Vec3 EditorViewportWidget::ViewToWorldNormal(const QPoint& vp, bool onlyTerrain, bool bTestRenderMesh) +{ + AZ_UNUSED(vp) + AZ_UNUSED(onlyTerrain) + AZ_UNUSED(bTestRenderMesh) + + AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::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 +{ + SRayHitInfo hitInfo; + hitInfo.bUseCache = false; + hitInfo.bInFirstHit = false; + hitInfo.inRay.origin = vInPos; + hitInfo.inRay.direction = vInDir.GetNormalized(); + hitInfo.inReferencePoint = vInPos; + hitInfo.fMaxHitDistance = 0; + bool bRes = GetIEditor()->Get3DEngine()->RenderMeshRayIntersection(pRenderMesh, hitInfo, nullptr); + vOutPos = hitInfo.vHitPos; + vOutNormal = hitInfo.vHitNormal; + return bRes; +} + +void EditorViewportWidget::UnProjectFromScreen(float sx, float sy, float sz, float* px, float* py, float* pz) const +{ + AZ::Vector3 wp; + wp = m_renderViewport->ViewportScreenToWorld({(int)sx, m_rcClient.bottom() - ((int)sy)}, sz).value_or(wp); + *px = wp.GetX(); + *py = wp.GetY(); + *pz = wp.GetZ(); +} + +void EditorViewportWidget::ProjectToScreen(float ptx, float pty, float ptz, float* sx, float* sy, float* sz) const +{ + QPoint screenPosition = m_renderViewport->ViewportWorldToScreen(AZ::Vector3{ptx, pty, ptz}); + *sx = screenPosition.x(); + *sy = screenPosition.y(); + *sz = 0.f; +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::ViewToWorldRay(const QPoint& vp, Vec3& raySrc, Vec3& rayDir) const +{ + QRect rc = m_rcClient; + + Vec3 pos0, pos1; + float wx, wy, wz; + UnProjectFromScreen(vp.x(), rc.bottom() - vp.y(), 0, &wx, &wy, &wz); + if (!_finite(wx) || !_finite(wy) || !_finite(wz)) + { + return; + } + if (fabs(wx) > 1000000 || fabs(wy) > 1000000 || fabs(wz) > 1000000) + { + return; + } + pos0(wx, wy, wz); + UnProjectFromScreen(vp.x(), rc.bottom() - vp.y(), 1, &wx, &wy, &wz); + if (!_finite(wx) || !_finite(wy) || !_finite(wz)) + { + return; + } + if (fabs(wx) > 1000000 || fabs(wy) > 1000000 || fabs(wz) > 1000000) + { + return; + } + pos1(wx, wy, wz); + + Vec3 v = (pos1 - pos0); + v = v.GetNormalized(); + + raySrc = pos0; + rayDir = v; +} + +////////////////////////////////////////////////////////////////////////// +float EditorViewportWidget::GetScreenScaleFactor(const Vec3& worldPoint) const +{ + float dist = m_Camera.GetPosition().GetDistance(worldPoint); + if (dist < m_Camera.GetNearPlane()) + { + dist = m_Camera.GetNearPlane(); + } + return dist; +} +////////////////////////////////////////////////////////////////////////// +float EditorViewportWidget::GetScreenScaleFactor(const CCamera& camera, const Vec3& object_position) +{ + Vec3 camPos = camera.GetPosition(); + float dist = camPos.GetDistance(object_position); + return dist; +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::OnDestroy() +{ + DestroyRenderContext(); +} + +////////////////////////////////////////////////////////////////////////// +bool EditorViewportWidget::CheckRespondToInput() const +{ + if (!Editor::EditorQtApplication::IsActive()) + { + return false; + } + + if (!hasFocus() && !m_renderViewport->hasFocus()) + { + return false; + } + + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool EditorViewportWidget::HitTest(const QPoint& point, HitContext& hitInfo) +{ + hitInfo.camera = &m_Camera; + hitInfo.pExcludedObject = GetCameraObject(); + return QtViewport::HitTest(point, hitInfo); +} + +////////////////////////////////////////////////////////////////////////// +bool EditorViewportWidget::IsBoundsVisible(const AABB& box) const +{ + // If at least part of bbox is visible then its visible. + return m_Camera.IsAABBVisible_F(AABB(box.min, box.max)); +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::CenterOnSelection() +{ + if (!GetIEditor()->GetSelection()->IsEmpty()) + { + // Get selection bounds & center + CSelectionGroup* sel = GetIEditor()->GetSelection(); + AABB selectionBounds = sel->GetBounds(); + CenterOnAABB(selectionBounds); + } +} + +void EditorViewportWidget::CenterOnAABB(const AABB& aabb) +{ + Vec3 selectionCenter = aabb.GetCenter(); + + // Minimum center size is 40cm + const float minSelectionRadius = 0.4f; + const float selectionSize = std::max(minSelectionRadius, aabb.GetRadius()); + + // Move camera 25% further back than required + const float centerScale = 1.25f; + + // Decompose original transform matrix + const Matrix34& originalTM = GetViewTM(); + AffineParts affineParts; + affineParts.SpectralDecompose(originalTM); + + // Forward vector is y component of rotation matrix + Matrix33 rotationMatrix(affineParts.rot); + const Vec3 viewDirection = rotationMatrix.GetColumn1().GetNormalized(); + + // Compute adjustment required by FOV != 90 degrees + const float fov = GetFOV(); + const float fovScale = (1.0f / tan(fov * 0.5f)); + + // Compute new transform matrix + const float distanceToTarget = selectionSize * fovScale * centerScale; + const Vec3 newPosition = selectionCenter - (viewDirection * distanceToTarget); + Matrix34 newTM = Matrix34(rotationMatrix, newPosition); + + // Set new orbit distance + m_orbitDistance = distanceToTarget; + m_orbitDistance = fabs(m_orbitDistance); + + SetViewTM(newTM); +} + +void EditorViewportWidget::CenterOnSliceInstance() +{ + AzToolsFramework::EntityIdList selectedEntityList; + AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(selectedEntityList, &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntities); + + AZ::SliceComponent::SliceInstanceAddress sliceAddress; + AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(sliceAddress, + &AzToolsFramework::ToolsApplicationRequestBus::Events::FindCommonSliceInstanceAddress, selectedEntityList); + + if (!sliceAddress.IsValid()) + { + return; + } + + AZ::EntityId sliceRootEntityId; + AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(sliceRootEntityId, + &AzToolsFramework::ToolsApplicationRequestBus::Events::GetRootEntityIdOfSliceInstance, sliceAddress); + + if (!sliceRootEntityId.IsValid()) + { + return; + } + + AzToolsFramework::ToolsApplicationRequestBus::Broadcast( + &AzToolsFramework::ToolsApplicationRequestBus::Events::SetSelectedEntities, AzToolsFramework::EntityIdList{sliceRootEntityId}); + + const AZ::SliceComponent::InstantiatedContainer* instantiatedContainer = sliceAddress.GetInstance()->GetInstantiated(); + + AABB aabb(Vec3(std::numeric_limits::max()), Vec3(-std::numeric_limits::max())); + for (AZ::Entity* entity : instantiatedContainer->m_entities) + { + CEntityObject* entityObject = nullptr; + AzToolsFramework::ComponentEntityEditorRequestBus::EventResult(entityObject, entity->GetId(), + &AzToolsFramework::ComponentEntityEditorRequestBus::Events::GetSandboxObject); + AABB box; + entityObject->GetBoundBox(box); + aabb.Add(box.min); + aabb.Add(box.max); + } + CenterOnAABB(aabb); +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::SetFOV(float fov) +{ + if (m_pCameraFOVVariable) + { + m_pCameraFOVVariable->Set(fov); + } + else + { + m_camFOV = fov; + } + + if (m_viewPane) + { + m_viewPane->OnFOVChanged(fov); + } +} + +////////////////////////////////////////////////////////////////////////// +float EditorViewportWidget::GetFOV() const +{ + if (m_viewSourceType == ViewSourceType::SequenceCamera) + { + CBaseObject* cameraObject = GetCameraObject(); + + AZ::EntityId cameraEntityId; + AzToolsFramework::ComponentEntityObjectRequestBus::EventResult(cameraEntityId, cameraObject, &AzToolsFramework::ComponentEntityObjectRequestBus::Events::GetAssociatedEntityId); + if (cameraEntityId.IsValid()) + { + // component Camera + float fov = DEFAULT_FOV; + Camera::CameraRequestBus::EventResult(fov, cameraEntityId, &Camera::CameraComponentRequests::GetFov); + return AZ::DegToRad(fov); + } + } + + if (m_pCameraFOVVariable) + { + float fov; + m_pCameraFOVVariable->Get(fov); + return fov; + } + else if (m_viewEntityId.IsValid()) + { + float fov = AZ::RadToDeg(m_camFOV); + Camera::CameraRequestBus::EventResult(fov, m_viewEntityId, &Camera::CameraComponentRequests::GetFov); + return AZ::DegToRad(fov); + } + + return m_camFOV; +} + +////////////////////////////////////////////////////////////////////////// +bool EditorViewportWidget::CreateRenderContext() +{ + return true; +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::DestroyRenderContext() +{ +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::SetDefaultCamera() +{ + if (IsDefaultCamera()) + { + return; + } + ResetToViewSourceType(ViewSourceType::None); + gEnv->p3DEngine->GetPostEffectBaseGroup()->SetParam("Dof_Active", 0.0f); + GetViewManager()->SetCameraObjectId(m_cameraObjectId); + SetName(m_defaultViewName); + SetViewTM(m_defaultViewTM); + PostCameraSet(); +} + +////////////////////////////////////////////////////////////////////////// +bool EditorViewportWidget::IsDefaultCamera() const +{ + return m_viewSourceType == ViewSourceType::None; +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::SetSequenceCamera() +{ + if (m_viewSourceType == ViewSourceType::SequenceCamera) + { + // Reset if we were checked before + SetDefaultCamera(); + } + else + { + ResetToViewSourceType(ViewSourceType::SequenceCamera); + + SetName(tr("Sequence Camera")); + SetViewTM(GetViewTM()); + + GetViewManager()->SetCameraObjectId(m_cameraObjectId); + PostCameraSet(); + + // ForceAnimation() so Track View will set the Camera params + // if a camera is animated in the sequences. + if (GetIEditor() && GetIEditor()->GetAnimation()) + { + GetIEditor()->GetAnimation()->ForceAnimation(); + } + } +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::SetComponentCamera(const AZ::EntityId& entityId) +{ + ResetToViewSourceType(ViewSourceType::CameraComponent); + SetViewEntity(entityId); +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::SetEntityAsCamera(const AZ::EntityId& entityId, bool lockCameraMovement) +{ + ResetToViewSourceType(ViewSourceType::AZ_Entity); + SetViewEntity(entityId, lockCameraMovement); +} + +void EditorViewportWidget::SetFirstComponentCamera() +{ + AZ::EBusAggregateResults results; + Camera::CameraBus::BroadcastResult(results, &Camera::CameraRequests::GetCameras); + AZStd::sort_heap(results.values.begin(), results.values.end()); + AZ::EntityId entityId; + if (results.values.size() > 0) + { + entityId = results.values[0]; + } + SetComponentCamera(entityId); +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::SetSelectedCamera() +{ + AZ::EBusAggregateResults cameraList; + Camera::CameraBus::BroadcastResult(cameraList, &Camera::CameraRequests::GetCameras); + if (cameraList.values.size() > 0) + { + AzToolsFramework::EntityIdList selectedEntityList; + AzToolsFramework::ToolsApplicationRequests::Bus::BroadcastResult(selectedEntityList, &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntities); + for (const AZ::EntityId& entityId : selectedEntityList) + { + if (AZStd::find(cameraList.values.begin(), cameraList.values.end(), entityId) != cameraList.values.end()) + { + SetComponentCamera(entityId); + } + } + } +} + +////////////////////////////////////////////////////////////////////////// +bool EditorViewportWidget::IsSelectedCamera() const +{ + CBaseObject* pCameraObject = GetCameraObject(); + if (pCameraObject && pCameraObject == GetIEditor()->GetSelectedObject()) + { + return true; + } + + AzToolsFramework::EntityIdList selectedEntityList; + AzToolsFramework::ToolsApplicationRequests::Bus::BroadcastResult( + selectedEntityList, &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntities); + + if ((m_viewSourceType == ViewSourceType::CameraComponent || m_viewSourceType == ViewSourceType::AZ_Entity) + && !selectedEntityList.empty() + && AZStd::find(selectedEntityList.begin(), selectedEntityList.end(), m_viewEntityId) != selectedEntityList.end()) + { + return true; + } + + return false; +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::CycleCamera() +{ + // None -> Sequence -> LegacyCamera -> ... LegacyCamera -> CameraComponent -> ... CameraComponent -> None + // AZ_Entity has been intentionally left out of the cycle for now. + switch (m_viewSourceType) + { + case EditorViewportWidget::ViewSourceType::None: + { + SetFirstComponentCamera(); + break; + } + case EditorViewportWidget::ViewSourceType::SequenceCamera: + { + AZ_Error("EditorViewportWidget", false, "Legacy cameras no longer exist, unable to set sequence camera."); + break; + } + case EditorViewportWidget::ViewSourceType::LegacyCamera: + { + AZ_Warning("EditorViewportWidget", false, "Legacy cameras no longer exist, using first found component camera instead."); + SetFirstComponentCamera(); + break; + } + case EditorViewportWidget::ViewSourceType::CameraComponent: + { + AZ::EBusAggregateResults results; + Camera::CameraBus::BroadcastResult(results, &Camera::CameraRequests::GetCameras); + AZStd::sort_heap(results.values.begin(), results.values.end()); + auto&& currentCameraIterator = AZStd::find(results.values.begin(), results.values.end(), m_viewEntityId); + if (currentCameraIterator != results.values.end()) + { + ++currentCameraIterator; + if (currentCameraIterator != results.values.end()) + { + SetComponentCamera(*currentCameraIterator); + break; + } + } + SetDefaultCamera(); + break; + } + case EditorViewportWidget::ViewSourceType::AZ_Entity: + { + // we may decide to have this iterate over just selected entities + SetDefaultCamera(); + break; + } + default: + { + SetDefaultCamera(); + break; + } + } +} + +void EditorViewportWidget::SetViewFromEntityPerspective(const AZ::EntityId& entityId) +{ + SetViewAndMovementLockFromEntityPerspective(entityId, false); +} + +void EditorViewportWidget::SetViewAndMovementLockFromEntityPerspective(const AZ::EntityId& entityId, bool lockCameraMovement) +{ + if (!m_ignoreSetViewFromEntityPerspective) + { + SetEntityAsCamera(entityId, lockCameraMovement); + } +} + +bool EditorViewportWidget::GetActiveCameraPosition(AZ::Vector3& cameraPos) +{ + if (m_pPrimaryViewport == this) + { + if (GetIEditor()->IsInGameMode()) + { + const Vec3 camPos = m_engine->GetRenderingCamera().GetPosition(); + cameraPos = LYVec3ToAZVec3(camPos); + } + else + { + // Use viewTM, which is synced with the camera and guaranteed to be up-to-date + cameraPos = LYVec3ToAZVec3(m_viewTM.GetTranslation()); + } + + return true; + } + + return false; +} + +void EditorViewportWidget::OnStartPlayInEditor() +{ + if (m_viewEntityId.IsValid()) + { + m_viewEntityIdCachedForEditMode = m_viewEntityId; + AZ::EntityId runtimeEntityId; + AzToolsFramework::EditorEntityContextRequestBus::Broadcast( + &AzToolsFramework::EditorEntityContextRequestBus::Events::MapEditorIdToRuntimeId, + m_viewEntityId, runtimeEntityId); + + m_viewEntityId = runtimeEntityId; + } +} + +void EditorViewportWidget::OnStopPlayInEditor() +{ + if (m_viewEntityIdCachedForEditMode.IsValid()) + { + m_viewEntityId = m_viewEntityIdCachedForEditMode; + m_viewEntityIdCachedForEditMode.SetInvalid(); + } +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::OnCameraFOVVariableChanged([[maybe_unused]] IVariable* var) +{ + if (m_viewPane) + { + m_viewPane->OnFOVChanged(GetFOV()); + } +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::HideCursor() +{ + if (m_bCursorHidden || !gSettings.viewports.bHideMouseCursorWhenCaptured) + { + return; + } + + qApp->setOverrideCursor(Qt::BlankCursor); +#if AZ_TRAIT_OS_PLATFORM_APPLE + StartFixedCursorMode(this); +#endif + m_bCursorHidden = true; +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::ShowCursor() +{ + if (!m_bCursorHidden || !gSettings.viewports.bHideMouseCursorWhenCaptured) + { + return; + } + +#if AZ_TRAIT_OS_PLATFORM_APPLE + StopFixedCursorMode(); +#endif + qApp->restoreOverrideCursor(); + m_bCursorHidden = false; +} + +bool EditorViewportWidget::IsKeyDown(Qt::Key key) const +{ + return m_keyDown.contains(key); +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::PushDisableRendering() +{ + assert(m_disableRenderingCount >= 0); + ++m_disableRenderingCount; +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::PopDisableRendering() +{ + assert(m_disableRenderingCount >= 1); + --m_disableRenderingCount; +} + +////////////////////////////////////////////////////////////////////////// +bool EditorViewportWidget::IsRenderingDisabled() const +{ + return m_disableRenderingCount > 0; +} + +////////////////////////////////////////////////////////////////////////// +QPoint EditorViewportWidget::WidgetToViewport(const QPoint &point) const +{ + return point * WidgetToViewportFactor(); +} + +QPoint EditorViewportWidget::ViewportToWidget(const QPoint &point) const +{ + return point / WidgetToViewportFactor(); +} + +////////////////////////////////////////////////////////////////////////// +QSize EditorViewportWidget::WidgetToViewport(const QSize &size) const +{ + return size * WidgetToViewportFactor(); +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::BeginUndoTransaction() +{ + PushDisableRendering(); +} + +////////////////////////////////////////////////////////////////////////// +void EditorViewportWidget::EndUndoTransaction() +{ + PopDisableRendering(); + Update(); +} + +void EditorViewportWidget::UpdateCurrentMousePos(const QPoint& newPosition) +{ + m_prevMousePos = m_mousePos; + m_mousePos = newPosition; +} + +void* EditorViewportWidget::GetSystemCursorConstraintWindow() const +{ + AzFramework::SystemCursorState systemCursorState = AzFramework::SystemCursorState::Unknown; + + AzFramework::InputSystemCursorRequestBus::EventResult( + systemCursorState, AzFramework::InputDeviceMouse::Id, &AzFramework::InputSystemCursorRequests::GetSystemCursorState); + + const bool systemCursorConstrained = + (systemCursorState == AzFramework::SystemCursorState::ConstrainedAndHidden || + systemCursorState == AzFramework::SystemCursorState::ConstrainedAndVisible); + + return systemCursorConstrained ? renderOverlayHWND() : nullptr; +} + +void EditorViewportWidget::BuildDragDropContext(AzQtComponents::ViewportDragContext& context, const QPoint& pt) +{ + const auto scaledPoint = WidgetToViewport(pt); + QtViewport::BuildDragDropContext(context, scaledPoint); +} + +void EditorViewportWidget::RestoreViewportAfterGameMode() +{ + Matrix34 preGameModeViewTM = m_preGameModeViewTM; + + QString text = QString("You are exiting Game Mode. Would you like to restore the camera in the viewport to where it was before you entered Game Mode?

This option can always be changed in the General Preferences tab of the Editor Settings, by toggling the \"%1\" option.

").arg(EditorPreferencesGeneralRestoreViewportCameraSettingName); + QString restoreOnExitGameModePopupDisabledRegKey("Editor/AutoHide/ViewportCameraRestoreOnExitGameMode"); + + // Read the popup disabled registry value + QSettings settings; + QVariant restoreOnExitGameModePopupDisabledRegValue = settings.value(restoreOnExitGameModePopupDisabledRegKey); + + // Has the user previously disabled being asked about restoring the camera on exiting game mode? + if (restoreOnExitGameModePopupDisabledRegValue.isNull()) + { + // No, ask them now + QMessageBox messageBox(QMessageBox::Question, "Lumberyard", text, QMessageBox::StandardButtons(QMessageBox::No | QMessageBox::Yes), this); + messageBox.setDefaultButton(QMessageBox::Yes); + + QCheckBox* checkBox = new QCheckBox(QStringLiteral("Do not show this message again")); + messageBox.setCheckBox(checkBox); + + // Unconstrain the system cursor and make it visible before we show the dialog box, otherwise the user can't see the cursor. + AzFramework::InputSystemCursorRequestBus::Event(AzFramework::InputDeviceMouse::Id, + &AzFramework::InputSystemCursorRequests::SetSystemCursorState, + AzFramework::SystemCursorState::UnconstrainedAndVisible); + + int response = messageBox.exec(); + + if (checkBox->isChecked()) + { + settings.setValue(restoreOnExitGameModePopupDisabledRegKey, response); + } + + // Update the value only if the popup hasn't previously been disabled and the value has changed + bool newSetting = (response == QMessageBox::Yes); + if (newSetting != GetIEditor()->GetEditorSettings()->restoreViewportCamera) + { + GetIEditor()->GetEditorSettings()->restoreViewportCamera = newSetting; + GetIEditor()->GetEditorSettings()->Save(); + } + } + + bool restoreViewportCamera = GetIEditor()->GetEditorSettings()->restoreViewportCamera; + if (restoreViewportCamera) + { + SetViewTM(preGameModeViewTM); + } + else + { + SetViewTM(m_gameTM); + } +} + +void EditorViewportWidget::UpdateScene() +{ + AZStd::vector scenes; + AzFramework::SceneSystemRequestBus::BroadcastResult(scenes, &AzFramework::SceneSystemRequests::GetAllScenes); + if (scenes.size() > 0) + { + AZ::RPI::SceneNotificationBus::Handler::BusDisconnect(); + auto scene = scenes[0]; + m_renderViewport->SetScene(scene); + AZ::RPI::SceneNotificationBus::Handler::BusConnect(m_renderViewport->GetViewportContext()->GetRenderScene()->GetId()); + } +} + +void EditorViewportWidget::UpdateCameraFromViewportContext() +{ + // If we're not updating because the cry camera position changed, we should make sure our position gets copied back to the Cry Camera + if (m_updatingCameraPosition) + { + return; + } + + auto cameraState = m_renderViewport->GetCameraState(); + AZ::Matrix3x4 matrix; + matrix.SetBasisAndTranslation(cameraState.m_side, cameraState.m_forward, cameraState.m_up, cameraState.m_position); + auto m = AZMatrix3x4ToLYMatrix3x4(matrix); + SetViewTM(m); + SetFOV(cameraState.m_fovOrZoom); + m_Camera.SetZRange(cameraState.m_nearClip, cameraState.m_farClip); +} + +void EditorViewportWidget::SetAsActiveViewport() +{ + auto viewportContextManager = AZ::Interface::Get(); + + const AZ::Name defaultContextName = viewportContextManager->GetDefaultViewportContextName(); + + // If another viewport was active before, restore its name to its per-ID one. + if (m_pPrimaryViewport && m_pPrimaryViewport != this && m_pPrimaryViewport->m_renderViewport) + { + auto viewportContext = m_pPrimaryViewport->m_renderViewport->GetViewportContext(); + if (viewportContext) + { + // Remove the old viewport's camera from the stack, as it's no longer the owning viewport + viewportContextManager->PopView(defaultContextName, viewportContext->GetDefaultView()); + viewportContextManager->RenameViewportContext(viewportContext, m_pPrimaryViewport->m_defaultViewportContextName); + } + } + + m_pPrimaryViewport = this; + if (m_renderViewport) + { + auto viewportContext = m_renderViewport->GetViewportContext(); + if (viewportContext) + { + // Push our camera onto the default viewport's view stack to preserve camera state continuity + // Other views can still be pushed on top of our view for e.g. game mode + viewportContextManager->PushView(defaultContextName, viewportContext->GetDefaultView()); + viewportContextManager->RenameViewportContext(viewportContext, defaultContextName); + } + } +} + +#include diff --git a/Code/Sandbox/Editor/Material/MaterialManager.cpp b/Code/Sandbox/Editor/Material/MaterialManager.cpp index 8f4269bb3e..dee903dfe4 100644 --- a/Code/Sandbox/Editor/Material/MaterialManager.cpp +++ b/Code/Sandbox/Editor/Material/MaterialManager.cpp @@ -550,7 +550,6 @@ void CMaterialManager::ReloadDirtyMaterials() } } } - } ////////////////////////////////////////////////////////////////////////// diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_CRELensOptics.cpp b/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_CRELensOptics.cpp deleted file mode 100644 index 7b642b95e7..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_CRELensOptics.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#include "CryRenderOther_precompiled.h" -#include "../Common/RendElements/CRELensOptics.h" - - -CRELensOptics::CRELensOptics(void) -{ - mfSetType(eDATA_LensOptics); - mfUpdateFlags(FCEF_TRANSFORM); -} -CRELensOptics::~CRELensOptics(void) {} - -bool CRELensOptics::mfCompile([[maybe_unused]] CParserBin& Parser, [[maybe_unused]] SParserFrame& Frame){ return true; } - -void CRELensOptics::mfPrepare([[maybe_unused]] bool bCheckOverflow) {} - -bool CRELensOptics::mfDraw([[maybe_unused]] CShader* ef, [[maybe_unused]] SShaderPass* sfm) { return true; } \ No newline at end of file diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_DevBuffer.cpp b/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_DevBuffer.cpp deleted file mode 100644 index 01e16e49d5..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_DevBuffer.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#include "CryRenderOther_precompiled.h" - -////////////////////////////////////////////////////////////////////////////////////// -buffer_handle_t CDeviceBufferManager::Create_Locked(BUFFER_BIND_TYPE, BUFFER_USAGE, size_t) -{ - return buffer_handle_t(); -} - -////////////////////////////////////////////////////////////////////////////////////// -void CDeviceBufferManager::Destroy_Locked(buffer_handle_t) -{ -} - -////////////////////////////////////////////////////////////////////////////////////// -void* CDeviceBufferManager::BeginRead_Locked([[maybe_unused]] buffer_handle_t handle) -{ - return nullptr; -} - -////////////////////////////////////////////////////////////////////////////////////// -void* CDeviceBufferManager::BeginWrite_Locked([[maybe_unused]] buffer_handle_t handle) -{ - return nullptr; -} - -////////////////////////////////////////////////////////////////////////////////////// -void CDeviceBufferManager::EndReadWrite_Locked([[maybe_unused]] buffer_handle_t handle) -{ -} - -////////////////////////////////////////////////////////////////////////////////////// -bool CDeviceBufferManager::UpdateBuffer_Locked([[maybe_unused]] buffer_handle_t handle, const void*, size_t) -{ - return false; -} - -////////////////////////////////////////////////////////////////////////////////////// -size_t CDeviceBufferManager::Size_Locked(buffer_handle_t) -{ - return 0; -} - -////////////////////////////////////////////////////////////////////////////////////// -CDeviceBufferManager::CDeviceBufferManager() -{ -} - -////////////////////////////////////////////////////////////////////////////////////// -CDeviceBufferManager::~CDeviceBufferManager() -{ -} - -////////////////////////////////////////////////////////////////////////////////////// -void CDeviceBufferManager::LockDevMan() -{ -} - -////////////////////////////////////////////////////////////////////////////////////// -void CDeviceBufferManager::UnlockDevMan() -{ -} - -////////////////////////////////////////////////////////////////////////////////////// -bool CDeviceBufferManager::Init() -{ - return true; -} - -////////////////////////////////////////////////////////////////////////////////////// -bool CDeviceBufferManager::Shutdown() -{ - return true; -} - -////////////////////////////////////////////////////////////////////////////////////// -void CDeviceBufferManager::Sync([[maybe_unused]] uint32 framdid) -{ -} - -////////////////////////////////////////////////////////////////////////////////////// -void CDeviceBufferManager::Update(uint32, [[maybe_unused]] bool called_during_loading) -{ -} - -////////////////////////////////////////////////////////////////////////////////////// -buffer_handle_t CDeviceBufferManager::Create( - [[maybe_unused]] BUFFER_BIND_TYPE type - , [[maybe_unused]] BUFFER_USAGE usage - , [[maybe_unused]] size_t size) -{ - return ~0u; -} - -////////////////////////////////////////////////////////////////////////////////////// -void CDeviceBufferManager::Destroy([[maybe_unused]] buffer_handle_t handle) -{ -} - -////////////////////////////////////////////////////////////////////////////////////// -void* CDeviceBufferManager::BeginRead([[maybe_unused]] buffer_handle_t handle) -{ - return NULL; -} - -////////////////////////////////////////////////////////////////////////////////////// -void* CDeviceBufferManager::BeginWrite([[maybe_unused]] buffer_handle_t handle) -{ - return NULL; -} - -////////////////////////////////////////////////////////////////////////////////////// -void CDeviceBufferManager::EndReadWrite([[maybe_unused]] buffer_handle_t handle) -{ -} - -////////////////////////////////////////////////////////////////////////////////////// -bool CDeviceBufferManager::UpdateBuffer([[maybe_unused]] buffer_handle_t handle, [[maybe_unused]] const void* src, [[maybe_unused]] size_t size) -{ - return true; -} - -///////////////////////////////////////////////////////////// -// Legacy interface -// -// Use with care, can be removed at any point! -////////////////////////////////////////////////////////////////////////////////////// -void CDeviceBufferManager::ReleaseVBuffer(CVertexBuffer* pVB) -{ - SAFE_DELETE(pVB); -} -////////////////////////////////////////////////////////////////////////////////////// -void CDeviceBufferManager::ReleaseIBuffer(CIndexBuffer* pIB) -{ - SAFE_DELETE(pIB); -} -////////////////////////////////////////////////////////////////////////////////////// -CVertexBuffer* CDeviceBufferManager::CreateVBuffer([[maybe_unused]] size_t nVerts, const AZ::Vertex::Format& vertexFormat, [[maybe_unused]] const char* szName, [[maybe_unused]] BUFFER_USAGE usage) -{ - CVertexBuffer* pVB = new CVertexBuffer(NULL, vertexFormat); - return pVB; -} -////////////////////////////////////////////////////////////////////////////////////// -CIndexBuffer* CDeviceBufferManager::CreateIBuffer([[maybe_unused]] size_t nInds, [[maybe_unused]] const char* szNam, [[maybe_unused]] BUFFER_USAGE usage) -{ - CIndexBuffer* pIB = new CIndexBuffer(NULL); - return pIB; -} -////////////////////////////////////////////////////////////////////////////////////// -bool CDeviceBufferManager::UpdateVBuffer([[maybe_unused]] CVertexBuffer* pVB, [[maybe_unused]] void* pVerts, [[maybe_unused]] size_t nVerts) -{ - return true; -} -////////////////////////////////////////////////////////////////////////////////////// -bool CDeviceBufferManager::UpdateIBuffer([[maybe_unused]] CIndexBuffer* pIB, [[maybe_unused]] void* pInds, [[maybe_unused]] size_t nInds) -{ - return true; -} -////////////////////////////////////////////////////////////////////////////////////// -CVertexBuffer::~CVertexBuffer() -{ -} -////////////////////////////////////////////////////////////////////////////////////// -CIndexBuffer::~CIndexBuffer() -{ -} - -namespace AzRHI -{ - ConstantBuffer::~ConstantBuffer() - {} - - void ConstantBuffer::AddRef() - {} - - AZ::u32 ConstantBuffer::Release() - { - return 0; - } -} diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_PostProcess.cpp b/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_PostProcess.cpp deleted file mode 100644 index 2596662259..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_PostProcess.cpp +++ /dev/null @@ -1,258 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -/* -Todo: -* Erradicate StretchRect usage -* Cleanup code -* When we have a proper static branching support use it instead of shader switches inside code -*/ -#include "CryRenderOther_precompiled.h" -#include "AtomShim_Renderer.h" -#include "I3DEngine.h" -#include "../Common/PostProcess/PostEffects.h" - -///////////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////////////// - -AZStd::unique_ptr CMotionBlur::m_Objects[3]; -CThreadSafeRendererContainer CMotionBlur::m_FillData[RT_COMMAND_BUF_COUNT]; - -bool CPostAA::Preprocess() -{ - return true; -} - -void CPostAA::Render() -{ -} - -void CMotionBlur::InsertNewElements() -{ -} - -void CMotionBlur::FreeData() -{ -} - -bool CMotionBlur::Preprocess() -{ - return true; -} - -void CMotionBlur::Render() -{ -} - -void CMotionBlur::GetPrevObjToWorldMat([[maybe_unused]] CRenderObject* pObj, Matrix44A& res) -{ - res = Matrix44(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); -} - -void CMotionBlur::OnBeginFrame() -{ -} - - -bool CSunShafts::Preprocess() -{ - return true; -} - -void CSunShafts::Render() -{ -} - - -void CFilterSharpening::Render() -{ -} -void CFilterBlurring::Render() -{ -} - - -void CUnderwaterGodRays::Render() -{ -} - -void CVolumetricScattering::Render() -{ -} - -void CWaterDroplets::Render() -{ -} - -void CWaterFlow::Render() -{ -} - - -void CWaterRipples::AddHit([[maybe_unused]] const Vec3& vPos, [[maybe_unused]] const float scale, [[maybe_unused]] const float strength) -{ -} - -void CWaterRipples::DEBUG_DrawWaterHits() -{ -} - -bool CWaterRipples::Preprocess() -{ - return true; -} - -void CWaterRipples::Reset([[maybe_unused]] bool bOnSpecChange) -{ -} - -void CWaterRipples::Render() -{ -} - -void CScreenFrost::Render() -{ -} - -bool CRainDrops::Preprocess() -{ - return true; -} -void CRainDrops::Render() -{ -} - -bool CFlashBang::Preprocess() -{ - return true; -} - -void CFlashBang::Render() -{ -} - -void CAlienInterference::Render() -{ -} - -void CGhostVision::Render() -{ -} - -void CHudSilhouettes::Render() -{ -} - -void CColorGrading::Render() -{ -} - -void CWaterVolume::Render() -{ -} - -void CSceneRain::CreateBuffers([[maybe_unused]] uint16 nVerts, [[maybe_unused]] void*& pINpVB, [[maybe_unused]] SVF_P3F_C4B_T2F* pVtxList) -{ -} - -int CSceneRain::CreateResources() -{ - return 1; -} - -void CSceneRain::Release() -{ -} - -void CSceneRain::Render() -{ -} - -bool CSceneSnow::Preprocess() -{ - return true; -} -void CSceneSnow::Render() -{ -} - -int CSceneSnow::CreateResources() -{ - return 1; -} - -void CSceneSnow::Release() -{ -} - -void CImageGhosting::Render() -{ -} - -void CFilterKillCamera::Render() -{ -} - -void CUberGamePostProcess::Render() -{ -} - -void CSoftAlphaTest::Render() -{ -} - -void CScreenBlood::Render() { } - -void CPost3DRenderer::Render() -{ -} - -///////////////////////////////////////////////////////////////////////////////////////////////////// - - -namespace WaterVolumeStaticData -{ - void GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer){} -} -///////////////////////////////////////////////////////////////////////////////////////////////////// - -bool CSceneRain::Preprocess() { return true; } -//void CSceneRain::Render() {} -void CSceneRain::Reset([[maybe_unused]] bool bOnSpecChange) {} -void CSceneRain::OnLostDevice() {} - -const char* CSceneRain::GetName() const {return 0; } -const char* CRainDrops::GetName() const {return 0; } - -///////////////////////////////////////////////////////////////////////////////////////////////////// - -void CSceneSnow::Reset([[maybe_unused]] bool bOnSpecChange) {} - - -const char* CSceneSnow::GetName() const {return 0; } - -///////////////////////////////////////////////////////////////////////////////////////////////////// - -bool CREPostProcess::mfDraw([[maybe_unused]] CShader* ef, [[maybe_unused]] SShaderPass* sfm) -{ - return true; -} - -///////////////////////////////////////////////////////////////////////////////////////////////////// - -void ScreenFader::Render() -{ - -} - -///////////////////////////////////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_RERender.cpp b/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_RERender.cpp deleted file mode 100644 index ca5b0a9c4a..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_RERender.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#include "CryRenderOther_precompiled.h" -#include "AtomShim_Renderer.h" -#include "I3DEngine.h" - -//======================================================================= - -bool CRESky::mfDraw([[maybe_unused]] CShader* ef, [[maybe_unused]] SShaderPass* sfm) -{ - return true; -} - -bool CREHDRSky::mfDraw([[maybe_unused]] CShader* ef, [[maybe_unused]] SShaderPass* sfm) -{ - return true; -} - -bool CREFogVolume::mfDraw([[maybe_unused]] CShader* ef, [[maybe_unused]] SShaderPass* sfm) -{ - return true; -} - -bool CREWaterVolume::mfDraw([[maybe_unused]] CShader* ef, [[maybe_unused]] SShaderPass* sfm) -{ - return true; -} - -void CREWaterOcean::FrameUpdate() -{ -} - -void CREWaterOcean::Create([[maybe_unused]] uint32 nVerticesCount, [[maybe_unused]] SVF_P3F_C4B_T2F* pVertices, [[maybe_unused]] uint32 nIndicesCount, [[maybe_unused]] const void* pIndices, [[maybe_unused]] uint32 nIndexSizeof) -{ -} - -void CREWaterOcean::ReleaseOcean() -{ -} - -bool CREWaterOcean::mfDraw([[maybe_unused]] CShader* ef, [[maybe_unused]] SShaderPass* sfm) -{ - return true; -} - -CREOcclusionQuery::~CREOcclusionQuery() -{ - mfReset(); -} - -void CREOcclusionQuery::mfReset() -{ - m_nOcclusionID = 0; -} - -uint32 CREOcclusionQuery::m_nQueriesPerFrameCounter = 0; -uint32 CREOcclusionQuery::m_nReadResultNowCounter = 0; -uint32 CREOcclusionQuery::m_nReadResultTryCounter = 0; - -bool CREOcclusionQuery::mfDraw([[maybe_unused]] CShader* ef, [[maybe_unused]] SShaderPass* sfm) -{ - return true; -} -bool CREOcclusionQuery::mfReadResult_Now(void) -{ - return true; -} -bool CREOcclusionQuery::mfReadResult_Try([[maybe_unused]] uint32 nDefaultNumSamples) -{ - return true; -} -bool CREOcclusionQuery::RT_ReadResult_Try([[maybe_unused]] uint32 nDefaultNumSamples) -{ - return true; -} - -bool CREMeshImpl::mfPreDraw([[maybe_unused]] SShaderPass* sl) -{ - return true; -} - -bool CREMeshImpl::mfDraw([[maybe_unused]] CShader* ef, [[maybe_unused]] SShaderPass* sl) -{ - return true; -} - -bool CREHDRProcess::mfDraw([[maybe_unused]] CShader* ef, [[maybe_unused]] SShaderPass* sfm) -{ - return true; -} - -bool CREDeferredShading::mfDraw([[maybe_unused]] CShader* ef, [[maybe_unused]] SShaderPass* sfm) -{ - return true; -} - -bool CREBeam::mfDraw([[maybe_unused]] CShader* ef, [[maybe_unused]] SShaderPass* sl) -{ - return true; -} - -bool CREImposter::mfDraw([[maybe_unused]] CShader* ef, [[maybe_unused]] SShaderPass* pPass) -{ - return true; -} - -bool CRECloud::mfDraw([[maybe_unused]] CShader* ef, [[maybe_unused]] SShaderPass* pPass) -{ - return true; -} - -bool CRECloud::UpdateImposter([[maybe_unused]] CRenderObject* pObj) -{ - return true; -} - -bool CRECloud::GenerateCloudImposter([[maybe_unused]] CShader* pShader, [[maybe_unused]] CShaderResources* pRes, [[maybe_unused]] CRenderObject* pObject) -{ - return true; -} - -bool CREImposter::UpdateImposter() -{ - return true; -} - -bool CREVolumeObject::mfDraw([[maybe_unused]] CShader* ef, [[maybe_unused]] SShaderPass* sfm) -{ - return true; -} - -#if !defined(EXCLUDE_DOCUMENTATION_PURPOSE) -bool CREPrismObject::mfDraw([[maybe_unused]] CShader* ef, [[maybe_unused]] SShaderPass* sfm) -{ - return true; -} -#endif // EXCLUDE_DOCUMENTATION_PURPOSE - -bool CREGameEffect::mfDraw([[maybe_unused]] CShader* ef, [[maybe_unused]] SShaderPass* sfm) -{ - return true; -} - -void CRELensOptics::ClearResources() -{ -} - -#if defined(USE_GEOM_CACHES) -bool CREGeomCache::mfDraw([[maybe_unused]] CShader* pShader, [[maybe_unused]] SShaderPass* pShaderPass) -{ - return true; -} -#endif diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_RendPipeline.cpp b/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_RendPipeline.cpp deleted file mode 100644 index 1686c56400..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_RendPipeline.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -// Description : NULL device specific implementation using shaders pipeline. - - -#include "CryRenderOther_precompiled.h" -#include "AtomShim_Renderer.h" -#include "Common/RenderView.h" -#include "RenderBus.h" - -//============================================================================================ -// Init Shaders rendering - -void CAtomShimRenderer::EF_Init() -{ - m_RP.m_MaxVerts = 600; - m_RP.m_MaxTris = 300; - - //================================================== - // Init RenderObjects - { - m_RP.m_nNumObjectsInPool = 384; // magic number set by Cry. The regular pipe uses a constant set to 1024 - - if (m_RP.m_ObjectsPool != nullptr) - { - for (int j = 0; j < (int)(m_RP.m_nNumObjectsInPool * RT_COMMAND_BUF_COUNT); j++) - { - CRenderObject* pRendObj = &m_RP.m_ObjectsPool[j]; - pRendObj->~CRenderObject(); - } - CryModuleMemalignFree(m_RP.m_ObjectsPool); - } - - // we use a plain allocation and placement new here to garantee the alignment, when using array new, the compiler can store it's size and break the alignment - m_RP.m_ObjectsPool = (CRenderObject*)CryModuleMemalign(sizeof(CRenderObject) * (m_RP.m_nNumObjectsInPool * RT_COMMAND_BUF_COUNT), 16); - for (int j = 0; j < (int)(m_RP.m_nNumObjectsInPool * RT_COMMAND_BUF_COUNT); j++) - { - new(&m_RP.m_ObjectsPool[j])CRenderObject(); - } - - - CRenderObject** arrPrefill = (CRenderObject**)(alloca(m_RP.m_nNumObjectsInPool * sizeof(CRenderObject*))); - for (int j = 0; j < RT_COMMAND_BUF_COUNT; j++) - { - for (int k = 0; k < m_RP.m_nNumObjectsInPool; ++k) - { - arrPrefill[k] = &m_RP.m_ObjectsPool[j * m_RP.m_nNumObjectsInPool + k]; - } - - m_RP.m_TempObjects[j].PrefillContainer(arrPrefill, m_RP.m_nNumObjectsInPool); - m_RP.m_TempObjects[j].resize(0); - } - } - // Init identity RenderObject - SAFE_DELETE(m_RP.m_pIdendityRenderObject); - m_RP.m_pIdendityRenderObject = aznew CRenderObject(); - m_RP.m_pIdendityRenderObject->Init(); - m_RP.m_pIdendityRenderObject->m_II.m_AmbColor = Col_White; - m_RP.m_pIdendityRenderObject->m_II.m_Matrix.SetIdentity(); - m_RP.m_pIdendityRenderObject->m_RState = 0; - m_RP.m_pIdendityRenderObject->m_ObjFlags |= FOB_RENDERER_IDENDITY_OBJECT; - -} - -void CAtomShimRenderer::FX_SetClipPlane ([[maybe_unused]] bool bEnable, [[maybe_unused]] float* pPlane, [[maybe_unused]] bool bRefract) -{ -} - -void CAtomShimRenderer::FX_PipelineShutdown([[maybe_unused]] bool bFastShutdown) -{ - uint32 i, j; - - for (int n = 0; n < 2; n++) - { - for (j = 0; j < 2; j++) - { - for (i = 0; i < CREClientPoly::m_PolysStorage[n][j].Num(); i++) - { - CREClientPoly::m_PolysStorage[n][j][i]->Release(false); - } - CREClientPoly::m_PolysStorage[n][j].Free(); - } - } -} - -void CAtomShimRenderer::EF_Release([[maybe_unused]] int nFlags) -{ -} - -//========================================================================== - -void CAtomShimRenderer::FX_SetState(int st, int AlphaRef, [[maybe_unused]] int RestoreState) -{ - m_RP.m_CurState = st; - m_RP.m_CurAlphaRef = AlphaRef; -} -void CRenderer::FX_SetStencilState([[maybe_unused]] int st, [[maybe_unused]] uint32 nStencRef, [[maybe_unused]] uint32 nStencMask, [[maybe_unused]] uint32 nStencWriteMask, [[maybe_unused]] bool bForceFullReadMask) -{ -} - -//================================================================================= - -// Initialize of the new shader pipeline (only 2d) -void CRenderer::FX_Start([[maybe_unused]] CShader* ef, [[maybe_unused]] int nTech, [[maybe_unused]] CShaderResources* Res, [[maybe_unused]] IRenderElement* re) -{ - m_RP.m_Frame++; -} - -void CRenderer::FX_CheckOverflow([[maybe_unused]] int nVerts, [[maybe_unused]] int nInds, [[maybe_unused]] IRenderElement* re, [[maybe_unused]] int* nNewVerts, [[maybe_unused]] int* nNewInds) -{ -} - -uint32 CRenderer::EF_GetDeferredLightsNum([[maybe_unused]] const eDeferredLightType eLightType) -{ - return 0; -} - -int CRenderer::EF_AddDeferredLight([[maybe_unused]] const CDLight& pLight, float, [[maybe_unused]] const SRenderingPassInfo& passInfo, [[maybe_unused]] const SRendItemSorter& rendItemSorter) -{ - return 0; -} - -void CRenderer::EF_ClearDeferredLightsList() -{ -} - -void CRenderer::EF_ReleaseDeferredData() -{ -} - -uint8 CRenderer::EF_AddDeferredClipVolume([[maybe_unused]] const IClipVolume* pClipVolume) -{ - return 0; -} - - -bool CRenderer::EF_SetDeferredClipVolumeBlendData([[maybe_unused]] const IClipVolume* pClipVolume, [[maybe_unused]] const SClipVolumeBlendInfo& blendInfo) -{ - return false; -} - -void CRenderer::EF_ClearDeferredClipVolumesList() -{ -} - -//======================================================================================== - -void CAtomShimRenderer::EF_EndEf3D([[maybe_unused]] const int nFlags, [[maybe_unused]] const int nPrecacheUpdateId, [[maybe_unused]] const int nNearPrecacheUpdateId, [[maybe_unused]] const SRenderingPassInfo& passInfo) -{ - //m_RP.m_TI[m_RP.m_nFillThreadID].m_RealTime = iTimer->GetCurrTime(); - EF_RemovePolysFromScene(); - - // Only render the UI Canvas and the Console on the main window - // If we're not in the editor, don't bother to check viewport. - if (!gEnv->IsEditor() || m_currContext == nullptr || m_currContext->m_isMainViewport) - { - EBUS_EVENT(AZ::RenderNotificationsBus, OnScene3DEnd); - } - - int nThreadID = m_pRT->GetThreadList(); - SRendItem::m_RecurseLevel[nThreadID]--; -} - -//double timeFtoI, timeFtoL, timeQRound; -//int sSome; -void CAtomShimRenderer::EF_EndEf2D([[maybe_unused]] const bool bSort) -{ -} - -void CRenderView::PrepareForRendering() {} - -void CRenderView::PrepareForWriting() {} - -void CRenderView::ClearRenderItems() {} - -void CRenderView::FreeRenderItems() {} - -CRenderView::CRenderView() {} - -CRenderView::~CRenderView() {} - diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_RenderAuxGeom.cpp b/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_RenderAuxGeom.cpp deleted file mode 100644 index 955b240514..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_RenderAuxGeom.cpp +++ /dev/null @@ -1,688 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#include "CryRenderOther_precompiled.h" -#include "AtomShim_Renderer.h" -#include "AtomShim_RenderAuxGeom.h" - -#include -#include -#include - -CAtomShimRenderAuxGeom* CAtomShimRenderAuxGeom::s_pThis = NULL; - -namespace -{ - using DrawFunction = AZStd::function; - void Handle16BitIndices(const vtx_idx* ind, uint32_t numIndices, DrawFunction drawFunc) - { - constexpr bool copyIndicesToUint32 = sizeof(vtx_idx) != sizeof(uint32_t); // mobile platforms use 16 bit vtx_idx - if constexpr(copyIndicesToUint32) - { - uint32_t* indices = new uint32_t[numIndices]; - for (int i = 0; i < numIndices; ++i) - { - indices[i] = ind[i]; - } - drawFunc(indices); - delete[] indices; - } - else - { - // re-interpret because on mobile vtx_idx is a uint16 - // Additionally the else case should not be taken on mobile - // because sizeof(uint16) < sizeof(uint32). - const uint32_t* indices = reinterpret_cast(ind); - drawFunc(indices); - } - } - - AZ::RPI::AuxGeomDraw::DrawStyle LyDrawStyleToAZDrawStyle(bool bSolid, EBoundingBoxDrawStyle bbDrawStyle) - { - AZ::RPI::AuxGeomDraw::DrawStyle drawStyle = AZ::RPI::AuxGeomDraw::DrawStyle::Solid; - if (!bSolid) - { - drawStyle = AZ::RPI::AuxGeomDraw::DrawStyle::Line; - } - else if (bbDrawStyle == eBBD_Extremes_Color_Encoded) - { - drawStyle = AZ::RPI::AuxGeomDraw::DrawStyle::Shaded; // Not the same but shows a difference - } - return drawStyle; - } - - AZ::Aabb LyAABBToAZAabbWithFixup(const AABB& source) - { - AABB fixed; - fixed.min.x = AZStd::min(source.min.x, source.max.x); - fixed.min.y = AZStd::min(source.min.y, source.max.y); - fixed.min.z = AZStd::min(source.min.z, source.max.z); - fixed.max.x = AZStd::max(source.min.x, source.max.x); - fixed.max.y = AZStd::max(source.min.y, source.max.y); - fixed.max.z = AZStd::max(source.min.z, source.max.z); - return LyAABBToAZAabb(fixed); - } - -} - -CAtomShimRenderAuxGeom::CAtomShimRenderAuxGeom(CAtomShimRenderer& renderer) - : m_renderer(&renderer) -{ -} - -CAtomShimRenderAuxGeom::~CAtomShimRenderAuxGeom() -{ -} - -void CAtomShimRenderAuxGeom::BeginFrame() -{ -} - -void CAtomShimRenderAuxGeom::EndFrame() -{ -} - -void CAtomShimRenderAuxGeom::SetViewProjOverride(const AZ::Matrix4x4& viewProj) -{ - auto defaultScene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); - if (auto auxGeom = AZ::RPI::AuxGeomFeatureProcessorInterface::GetDrawQueueForScene(defaultScene)) - { - m_viewProjOverrideIndex = auxGeom->AddViewProjOverride(viewProj); - } -} - -void CAtomShimRenderAuxGeom::UnsetViewProjOverride() -{ - m_viewProjOverrideIndex = -1; -} - -void CAtomShimRenderAuxGeom::SetRenderFlags(const SAuxGeomRenderFlags& renderFlags) -{ - m_cryRenderFlags = renderFlags; - m_drawArgs.m_depthTest = renderFlags.GetDepthTestFlag() == EAuxGeomPublicRenderflags_DepthTest::e_DepthTestOff ? - AZ::RPI::AuxGeomDraw::DepthTest::Off : AZ::RPI::AuxGeomDraw::DepthTest::On; -} - -SAuxGeomRenderFlags CAtomShimRenderAuxGeom::GetRenderFlags() -{ - return m_cryRenderFlags; -} - -void CAtomShimRenderAuxGeom::DrawPoint(const Vec3& v, const ColorB& col, uint8 size /* = 1 */) -{ - DrawPoints(&v, 1, col, size); -} - -void CAtomShimRenderAuxGeom::DrawPoints(const Vec3* v, uint32 numPoints, const ColorB* col, uint8 size /* = 1 */) -{ - auto defaultScene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); - if (auto auxGeom = AZ::RPI::AuxGeomFeatureProcessorInterface::GetDrawQueueForScene(defaultScene)) - { - AZ::Vector3* points = new AZ::Vector3[numPoints]; - AZ::Color* colors = new AZ::Color[numPoints]; - for (int i = 0; i < numPoints; ++i) - { - points[i] = LYVec3ToAZVec3(v[i]); - colors[i] = LYColorBToAZColor(col[i]); - } - AZ::RPI::AuxGeomDraw::AuxGeomDynamicDrawArguments drawArgs(m_drawArgs); - drawArgs.m_verts = points; - drawArgs.m_vertCount = numPoints; - drawArgs.m_colors = colors; - drawArgs.m_colorCount = numPoints; - drawArgs.m_size = size; - drawArgs.m_viewProjectionOverrideIndex = m_viewProjOverrideIndex; - - auxGeom->DrawPoints(drawArgs); - - delete[] points; - } -} - -void CAtomShimRenderAuxGeom::DrawPoints(const Vec3* v, uint32 numPoints, const ColorB& col, uint8 size /* = 1 */) -{ - auto defaultScene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); - if (auto auxGeom = AZ::RPI::AuxGeomFeatureProcessorInterface::GetDrawQueueForScene(defaultScene)) - { - AZ::Vector3* points = new AZ::Vector3[numPoints]; - for (int i = 0; i < numPoints; ++i) - { - points[i] = LYVec3ToAZVec3(v[i]); - } - AZ::Color color = LYColorBToAZColor(col); - - AZ::RPI::AuxGeomDraw::AuxGeomDynamicDrawArguments drawArgs; - drawArgs.m_verts = points; - drawArgs.m_vertCount = numPoints; - drawArgs.m_colors = &color; - drawArgs.m_colorCount = 1; - drawArgs.m_size = size; - drawArgs.m_viewProjectionOverrideIndex = m_viewProjOverrideIndex; - - auxGeom->DrawPoints(drawArgs); - - delete[] points; - } -} - -void CAtomShimRenderAuxGeom::DrawLine(const Vec3& v0, const ColorB& colV0, const Vec3& v1, const ColorB& colV1, float thickness /* = 1.0f */) -{ - const Vec3 verts[2] = {v0, v1}; - const ColorB colors[2] = {colV0, colV1}; - DrawLines(verts, 2, colors, thickness); -} - -void CAtomShimRenderAuxGeom::DrawLines(const Vec3* v, uint32 numPoints, const ColorB& col, float thickness /* = 1.0f */) -{ - auto defaultScene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); - if (auto auxGeom = AZ::RPI::AuxGeomFeatureProcessorInterface::GetDrawQueueForScene(defaultScene)) - { - AZ::Vector3* points = new AZ::Vector3[numPoints]; - for (int i = 0; i < numPoints; ++i) - { - points[i] = LYVec3ToAZVec3(v[i]); - } - - AZ::Color color = LYColorBToAZColor(col); - - AZ::RPI::AuxGeomDraw::AuxGeomDynamicDrawArguments drawArgs(m_drawArgs); - drawArgs.m_verts = points; - drawArgs.m_vertCount = numPoints; - drawArgs.m_colors = &color; - drawArgs.m_colorCount = 1; - drawArgs.m_size = thickness; - drawArgs.m_viewProjectionOverrideIndex = m_viewProjOverrideIndex; - auxGeom->DrawLines(drawArgs); - - delete[] points; - } -} - -void CAtomShimRenderAuxGeom::DrawLines(const Vec3* v, uint32 numPoints, const ColorB* col, float thickness /* = 1.0f */) -{ - auto defaultScene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); - if (auto auxGeom = AZ::RPI::AuxGeomFeatureProcessorInterface::GetDrawQueueForScene(defaultScene)) - { - AZ::Vector3* points = new AZ::Vector3[numPoints]; - AZ::Color* colors = new AZ::Color[numPoints]; - for (int i = 0; i < numPoints; ++i) - { - points[i] = LYVec3ToAZVec3(v[i]); - colors[i] = LYColorBToAZColor(col[i]); - } - - AZ::RPI::AuxGeomDraw::AuxGeomDynamicDrawArguments drawArgs(m_drawArgs); - drawArgs.m_verts = points; - drawArgs.m_vertCount = numPoints; - drawArgs.m_colors = colors; - drawArgs.m_colorCount = numPoints; - drawArgs.m_size = thickness; - drawArgs.m_viewProjectionOverrideIndex = m_viewProjOverrideIndex; - - auxGeom->DrawLines(drawArgs); - - delete[] points; - delete[] colors; - } -} - -void CAtomShimRenderAuxGeom::DrawLines(const Vec3* v, uint32 numPoints, const vtx_idx* ind, uint32 numIndices, const ColorB& col, float thickness /* = 1.0f */) -{ - auto defaultScene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); - if (auto auxGeom = AZ::RPI::AuxGeomFeatureProcessorInterface::GetDrawQueueForScene(defaultScene)) - { - AZ::Vector3* points = new AZ::Vector3[numPoints]; - for (int i = 0; i < numPoints; ++i) - { - points[i] = LYVec3ToAZVec3(v[i]); - } - - AZ::Color color = LYColorBToAZColor(col); - - AZ::RPI::AuxGeomDraw::AuxGeomDynamicIndexedDrawArguments drawArgs(m_drawArgs); - drawArgs.m_verts = points; - drawArgs.m_vertCount = numPoints; - drawArgs.m_indexCount = numIndices; - drawArgs.m_colors = &color; - drawArgs.m_colorCount = 1; - drawArgs.m_size = thickness; - drawArgs.m_viewProjectionOverrideIndex = m_viewProjOverrideIndex; - - Handle16BitIndices( - ind, numIndices, - [&drawArgs, auxGeom](const uint32_t* indices) - { - drawArgs.m_indices = indices; - auxGeom->DrawLines(drawArgs); - } - ); - - delete[] points; - } -} - -void CAtomShimRenderAuxGeom::DrawLines(const Vec3* v, uint32 numPoints, const vtx_idx* ind, uint32 numIndices, const ColorB* col, float thickness /* = 1.0f */) -{ - auto defaultScene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); - if (auto auxGeom = AZ::RPI::AuxGeomFeatureProcessorInterface::GetDrawQueueForScene(defaultScene)) - { - AZ::Vector3* points = new AZ::Vector3[numPoints]; - AZ::Color* colors = new AZ::Color[numPoints]; - for (int i = 0; i < numPoints; ++i) - { - points[i] = LYVec3ToAZVec3(v[i]); - colors[i] = LYColorBToAZColor(col[i]); - } - - AZ::RPI::AuxGeomDraw::AuxGeomDynamicIndexedDrawArguments drawArgs(m_drawArgs); - drawArgs.m_verts = points; - drawArgs.m_vertCount = numPoints; - drawArgs.m_indexCount = numIndices; - drawArgs.m_colors = colors; - drawArgs.m_colorCount = numPoints; - drawArgs.m_size = thickness; - drawArgs.m_viewProjectionOverrideIndex = m_viewProjOverrideIndex; - - Handle16BitIndices( - ind, numIndices, - [&drawArgs, auxGeom](const uint32_t* indices) - { - drawArgs.m_indices = indices; - auxGeom->DrawLines(drawArgs); - } - ); - - delete[] points; - delete[] colors; - } -} - -void CAtomShimRenderAuxGeom::DrawPolyline(const Vec3* v, uint32 numPoints, bool closed, const ColorB& col, float thickness /* = 1.0f */) -{ - auto defaultScene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); - if (auto auxGeom = AZ::RPI::AuxGeomFeatureProcessorInterface::GetDrawQueueForScene(defaultScene)) - { - AZ::Vector3* points = new AZ::Vector3[numPoints]; - for (int i = 0; i < numPoints; ++i) - { - points[i] = LYVec3ToAZVec3(v[i]); - } - - AZ::Color color = LYColorBToAZColor(col); - AZ::RPI::AuxGeomDraw::PolylineEnd polylineClosed = closed ? AZ::RPI::AuxGeomDraw::PolylineEnd::Closed : AZ::RPI::AuxGeomDraw::PolylineEnd::Open; - - AZ::RPI::AuxGeomDraw::AuxGeomDynamicDrawArguments drawArgs; - drawArgs.m_verts = points; - drawArgs.m_vertCount = numPoints; - drawArgs.m_colors = &color; - drawArgs.m_colorCount = 1; - drawArgs.m_size = thickness; - drawArgs.m_viewProjectionOverrideIndex = m_viewProjOverrideIndex; - - auxGeom->DrawPolylines(drawArgs, polylineClosed); - - delete[] points; - } -} - -void CAtomShimRenderAuxGeom::DrawPolyline(const Vec3* v, uint32 numPoints, bool closed, const ColorB* col, float thickness /* = 1.0f */) -{ - auto defaultScene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); - if (auto auxGeom = AZ::RPI::AuxGeomFeatureProcessorInterface::GetDrawQueueForScene(defaultScene)) - { - AZ::Vector3* points = new AZ::Vector3[numPoints]; - AZ::Color* colors = new AZ::Color[numPoints]; - for (int i = 0; i < numPoints; ++i) - { - points[i] = LYVec3ToAZVec3(v[i]); - colors[i] = LYColorBToAZColor(col[i]); - } - - AZ::RPI::AuxGeomDraw::PolylineEnd polylineClosed = closed ? AZ::RPI::AuxGeomDraw::PolylineEnd::Closed : AZ::RPI::AuxGeomDraw::PolylineEnd::Open; - - AZ::RPI::AuxGeomDraw::AuxGeomDynamicDrawArguments drawArgs; - drawArgs.m_verts = points; - drawArgs.m_vertCount = numPoints; - drawArgs.m_colors = colors; - drawArgs.m_colorCount = numPoints; - drawArgs.m_size = thickness; - drawArgs.m_viewProjectionOverrideIndex = m_viewProjOverrideIndex; - auxGeom->DrawPolylines(drawArgs, polylineClosed); - - delete[] points; - delete[] colors; - } -} - -void CAtomShimRenderAuxGeom::DrawTriangle(const Vec3& v0, const ColorB& colV0, const Vec3& v1, const ColorB& colV1, const Vec3& v2, const ColorB& colV2) -{ - auto defaultScene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); - if (auto auxGeom = AZ::RPI::AuxGeomFeatureProcessorInterface::GetDrawQueueForScene(defaultScene)) - { - AZ::Vector3 points[3] = - { - LYVec3ToAZVec3(v0), - LYVec3ToAZVec3(v1), - LYVec3ToAZVec3(v2), - }; - - AZ::Color colors[3] = - { - LYColorBToAZColor(colV0), - LYColorBToAZColor(colV1), - LYColorBToAZColor(colV2), - }; - - AZ::RPI::AuxGeomDraw::AuxGeomDynamicDrawArguments drawArgs; - drawArgs.m_verts = points; - drawArgs.m_vertCount = 3; - drawArgs.m_colors = colors; - drawArgs.m_colorCount = 3; - drawArgs.m_opacityType = (colV0.a == 0xFF && colV1.a == 0xFF && colV2.a == 0xFF) ? AZ::RPI::AuxGeomDraw::OpacityType::Opaque : AZ::RPI::AuxGeomDraw::OpacityType::Translucent; - drawArgs.m_viewProjectionOverrideIndex = m_viewProjOverrideIndex; - - auxGeom->DrawTriangles(drawArgs); - } -} - -void CAtomShimRenderAuxGeom::DrawTriangles(const Vec3* v, uint32 numPoints, const ColorB& col) -{ - auto defaultScene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); - if (auto auxGeom = AZ::RPI::AuxGeomFeatureProcessorInterface::GetDrawQueueForScene(defaultScene)) - { - AZ::Vector3* points = new AZ::Vector3[numPoints]; - for (int i = 0; i < numPoints; ++i) - { - points[i] = LYVec3ToAZVec3(v[i]); - } - AZ::Color color = LYColorBToAZColor(col); - - AZ::RPI::AuxGeomDraw::AuxGeomDynamicDrawArguments drawArgs; - drawArgs.m_verts = points; - drawArgs.m_vertCount = numPoints; - drawArgs.m_colors = &color; - drawArgs.m_colorCount = 1; - drawArgs.m_viewProjectionOverrideIndex = m_viewProjOverrideIndex; - - auxGeom->DrawTriangles(drawArgs); - delete[] points; - } -} - -void CAtomShimRenderAuxGeom::DrawTriangles(const Vec3* v, uint32 numPoints, const ColorB* col) -{ - auto defaultScene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); - if (auto auxGeom = AZ::RPI::AuxGeomFeatureProcessorInterface::GetDrawQueueForScene(defaultScene)) - { - AZ::Vector3* points = new AZ::Vector3[numPoints]; - AZ::Color* colors = new AZ::Color[numPoints]; - for (int i = 0; i < numPoints; ++i) - { - points[i] = LYVec3ToAZVec3(v[i]); - colors[i] = LYColorBToAZColor(col[i]); - } - - AZ::RPI::AuxGeomDraw::AuxGeomDynamicDrawArguments drawArgs; - drawArgs.m_verts = points; - drawArgs.m_vertCount = 3; - drawArgs.m_colors = colors; - drawArgs.m_colorCount = numPoints; - drawArgs.m_viewProjectionOverrideIndex = m_viewProjOverrideIndex; - - auxGeom->DrawTriangles(drawArgs); - delete[] points; - delete[] colors; - } -} - -void CAtomShimRenderAuxGeom::DrawTriangles(const Vec3* v, uint32 numPoints, const vtx_idx* ind, uint32 numIndices, const ColorB& col) -{ - auto defaultScene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); - if (auto auxGeom = AZ::RPI::AuxGeomFeatureProcessorInterface::GetDrawQueueForScene(defaultScene)) - { - AZ::Vector3* points = new AZ::Vector3[numPoints]; - for (int i = 0; i < numPoints; ++i) - { - points[i] = LYVec3ToAZVec3(v[i]); - } - AZ::Color color = LYColorBToAZColor(col); - - AZ::RPI::AuxGeomDraw::AuxGeomDynamicIndexedDrawArguments drawArgs(m_drawArgs); - drawArgs.m_verts = points; - drawArgs.m_vertCount = numPoints; - drawArgs.m_indexCount = numIndices; - drawArgs.m_colors = &color; - drawArgs.m_colorCount = 1; - drawArgs.m_viewProjectionOverrideIndex = m_viewProjOverrideIndex; - - Handle16BitIndices( - ind, numIndices, - [&drawArgs, auxGeom](const uint32_t* indices) - { - drawArgs.m_indices = indices; - auxGeom->DrawTriangles(drawArgs); - } - ); - - delete[] points; - } -} - -void CAtomShimRenderAuxGeom::DrawTriangles(const Vec3* v, uint32 numPoints, const vtx_idx* ind, uint32 numIndices, const ColorB* col) -{ - auto defaultScene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); - if (auto auxGeom = AZ::RPI::AuxGeomFeatureProcessorInterface::GetDrawQueueForScene(defaultScene)) - { - AZ::Vector3* points = new AZ::Vector3[numPoints]; - AZ::Color* colors = new AZ::Color[numPoints]; - for (int i = 0; i < numPoints; ++i) - { - points[i] = LYVec3ToAZVec3(v[i]); - colors[i] = LYColorBToAZColor(col[i]); - } - - AZ::RPI::AuxGeomDraw::AuxGeomDynamicIndexedDrawArguments drawArgs(m_drawArgs); - drawArgs.m_verts = points; - drawArgs.m_vertCount = numPoints; - drawArgs.m_indexCount = numIndices; - drawArgs.m_colors = colors; - drawArgs.m_colorCount = numPoints; - drawArgs.m_viewProjectionOverrideIndex = m_viewProjOverrideIndex; - - Handle16BitIndices( - ind, numIndices, - [&drawArgs, auxGeom](const uint32_t* indices) - { - drawArgs.m_indices = indices; - auxGeom->DrawTriangles(drawArgs); - } - ); - - delete[] points; - delete[] colors; - } -} - -void CAtomShimRenderAuxGeom::DrawQuad(float width, float height, const Matrix34& matWorld, const ColorB& col, bool drawShaded) -{ - auto defaultScene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); - if (auto auxGeom = AZ::RPI::AuxGeomFeatureProcessorInterface::GetDrawQueueForScene(defaultScene)) - { - AZ::RPI::AuxGeomDraw::DrawStyle drawStyle = drawShaded ? AZ::RPI::AuxGeomDraw::DrawStyle::Shaded : AZ::RPI::AuxGeomDraw::DrawStyle::Solid; - AZ::Matrix3x4 local2World = LYTransformToAZMatrix3x4(matWorld); - auxGeom->DrawQuad(width, height, local2World, LYColorBToAZColor(col), drawStyle, m_drawArgs.m_depthTest); - } -} - -void CAtomShimRenderAuxGeom::DrawAABB(const AABB& aabb, bool bSolid, const ColorB& col, const EBoundingBoxDrawStyle& bbDrawStyle) -{ - auto defaultScene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); - if (auto auxGeom = AZ::RPI::AuxGeomFeatureProcessorInterface::GetDrawQueueForScene(defaultScene)) - { - auxGeom->DrawAabb(LyAABBToAZAabbWithFixup(aabb), LYColorBToAZColor(col), LyDrawStyleToAZDrawStyle(bSolid, bbDrawStyle), m_drawArgs.m_depthTest); - } -} - -void CAtomShimRenderAuxGeom::DrawAABBs(const AABB* aabb, uint32 aabbCount, bool bSolid, const ColorB& col, const EBoundingBoxDrawStyle& bbDrawStyle) -{ - auto defaultScene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); - if (auto auxGeom = AZ::RPI::AuxGeomFeatureProcessorInterface::GetDrawQueueForScene(defaultScene)) - { - for (int i = 0; i < aabbCount; ++aabbCount) - { - auxGeom->DrawAabb( - LyAABBToAZAabbWithFixup(aabb[i]), - LYColorBToAZColor(col), - LyDrawStyleToAZDrawStyle(bSolid, bbDrawStyle), - m_drawArgs.m_depthTest, - AZ::RPI::AuxGeomDraw::DepthWrite::On, - AZ::RPI::AuxGeomDraw::FaceCullMode::Back, - m_viewProjOverrideIndex); - } - } -} - -void CAtomShimRenderAuxGeom::DrawAABB(const AABB& aabb, const Matrix34& matWorld, bool bSolid, const ColorB& col, const EBoundingBoxDrawStyle& bbDrawStyle) -{ - auto defaultScene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); - if (auto auxGeom = AZ::RPI::AuxGeomFeatureProcessorInterface::GetDrawQueueForScene(defaultScene)) - { - AZ::Matrix3x4 transform = LYTransformToAZMatrix3x4(matWorld); - auxGeom->DrawAabb( - LyAABBToAZAabbWithFixup(aabb), - transform, - LYColorBToAZColor(col), - LyDrawStyleToAZDrawStyle(bSolid, bbDrawStyle), - m_drawArgs.m_depthTest, - AZ::RPI::AuxGeomDraw::DepthWrite::On, - AZ::RPI::AuxGeomDraw::FaceCullMode::Back, - m_viewProjOverrideIndex); - } -} - -void CAtomShimRenderAuxGeom::DrawOBB(const OBB& obb, const Vec3& pos, bool bSolid, const ColorB& col, const EBoundingBoxDrawStyle& bbDrawStyle) -{ - auto defaultScene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); - if (auto auxGeom = AZ::RPI::AuxGeomFeatureProcessorInterface::GetDrawQueueForScene(defaultScene)) - { - auxGeom->DrawObb(LyOBBtoAZObb(obb), LYVec3ToAZVec3(pos), LYColorBToAZColor(col), LyDrawStyleToAZDrawStyle(bSolid, bbDrawStyle), m_drawArgs.m_depthTest); - } -} - -void CAtomShimRenderAuxGeom::DrawOBB(const OBB& obb, const Matrix34& matWorld, bool bSolid, const ColorB& col, const EBoundingBoxDrawStyle& bbDrawStyle) -{ - auto defaultScene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); - if (auto auxGeom = AZ::RPI::AuxGeomFeatureProcessorInterface::GetDrawQueueForScene(defaultScene)) - { - AZ::Matrix3x4 transform = LYTransformToAZMatrix3x4(matWorld); - auxGeom->DrawObb(LyOBBtoAZObb(obb), transform, LYColorBToAZColor(col), LyDrawStyleToAZDrawStyle(bSolid, bbDrawStyle), m_drawArgs.m_depthTest); - } -} - -void CAtomShimRenderAuxGeom::DrawSphere(const Vec3& pos, float radius, const ColorB& col, bool drawShaded) -{ - auto defaultScene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); - if (auto auxGeom = AZ::RPI::AuxGeomFeatureProcessorInterface::GetDrawQueueForScene(defaultScene)) - { - AZ::RPI::AuxGeomDraw::DrawStyle drawStyle = drawShaded ? AZ::RPI::AuxGeomDraw::DrawStyle::Shaded : AZ::RPI::AuxGeomDraw::DrawStyle::Solid; - auxGeom->DrawSphere(LYVec3ToAZVec3(pos), radius, LYColorBToAZColor(col), drawStyle, m_drawArgs.m_depthTest); - } -} - -void CAtomShimRenderAuxGeom::DrawDisk(const Vec3& pos, const Vec3& dir, float radius, const ColorB& col, bool drawShaded) -{ - auto defaultScene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); - if (auto auxGeom = AZ::RPI::AuxGeomFeatureProcessorInterface::GetDrawQueueForScene(defaultScene)) - { - AZ::RPI::AuxGeomDraw::DrawStyle drawStyle = drawShaded ? AZ::RPI::AuxGeomDraw::DrawStyle::Shaded : AZ::RPI::AuxGeomDraw::DrawStyle::Solid; - auxGeom->DrawDisk(LYVec3ToAZVec3(pos), LYVec3ToAZVec3(dir), radius, LYColorBToAZColor(col), drawStyle, m_drawArgs.m_depthTest); - } -} - -void CAtomShimRenderAuxGeom::DrawCone(const Vec3& pos, const Vec3& dir, float radius, float height, const ColorB& col, bool drawShaded) -{ - auto defaultScene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); - if (auto auxGeom = AZ::RPI::AuxGeomFeatureProcessorInterface::GetDrawQueueForScene(defaultScene)) - { - AZ::RPI::AuxGeomDraw::DrawStyle drawStyle = drawShaded ? AZ::RPI::AuxGeomDraw::DrawStyle::Shaded : AZ::RPI::AuxGeomDraw::DrawStyle::Solid; - auxGeom->DrawCone(LYVec3ToAZVec3(pos), LYVec3ToAZVec3(dir), radius, height, LYColorBToAZColor(col), drawStyle, m_drawArgs.m_depthTest); - } -} - -void CAtomShimRenderAuxGeom::DrawCylinder(const Vec3& pos, const Vec3& dir, float radius, float height, const ColorB& col, bool drawShaded) -{ - auto defaultScene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); - if (auto auxGeom = AZ::RPI::AuxGeomFeatureProcessorInterface::GetDrawQueueForScene(defaultScene)) - { - AZ::RPI::AuxGeomDraw::DrawStyle drawStyle = drawShaded ? AZ::RPI::AuxGeomDraw::DrawStyle::Shaded : AZ::RPI::AuxGeomDraw::DrawStyle::Solid; - auxGeom->DrawCylinder(LYVec3ToAZVec3(pos), LYVec3ToAZVec3(dir), radius, height, LYColorBToAZColor(col), drawStyle, m_drawArgs.m_depthTest); - } -} - -void CAtomShimRenderAuxGeom::DrawBone(const Vec3& p, const Vec3& c, ColorB col) -{ - Vec3 vBoneVec = c - p; - float fBoneLength = vBoneVec.GetLength(); - - if (fBoneLength < 1e-4) - { - return; - } - - Matrix33 m33 = Matrix33::CreateRotationV0V1(Vec3(1, 0, 0), vBoneVec / fBoneLength); - Matrix34 m34 = Matrix34(m33, p); - - f32 t = min(0.01f, fBoneLength * 0.05f); - - //bone points in x-direction - Vec3 s = Vec3(ZERO); - Vec3 m0 = Vec3(t, +t, +t); - Vec3 m1 = Vec3(t, -t, +t); - Vec3 m2 = Vec3(t, -t, -t); - Vec3 m3 = Vec3(t, +t, -t); - Vec3 e = Vec3(fBoneLength, 0, 0); - - Vec3 VBuffer[6]; - ColorB CBuffer[6]; - - VBuffer[0] = m34 * s; - CBuffer[0] = RGBA8(0xff, 0x1f, 0x1f, 0x00); //start of bone (joint) - - VBuffer[1] = m34 * m0; - CBuffer[1] = col; - VBuffer[2] = m34 * m1; - CBuffer[2] = col; - VBuffer[3] = m34 * m2; - CBuffer[3] = col; - VBuffer[4] = m34 * m3; - CBuffer[4] = col; - - VBuffer[5] = m34 * e; - CBuffer[5] = RGBA8(0x07, 0x0f, 0x1f, 0x00); //end of bone - - - DrawLine(VBuffer[0], CBuffer[0], VBuffer[1], CBuffer[1]); - DrawLine(VBuffer[0], CBuffer[0], VBuffer[2], CBuffer[2]); - DrawLine(VBuffer[0], CBuffer[0], VBuffer[3], CBuffer[3]); - DrawLine(VBuffer[0], CBuffer[0], VBuffer[4], CBuffer[4]); - - DrawLine(VBuffer[1], CBuffer[1], VBuffer[2], CBuffer[2]); - DrawLine(VBuffer[2], CBuffer[2], VBuffer[3], CBuffer[3]); - DrawLine(VBuffer[3], CBuffer[3], VBuffer[4], CBuffer[4]); - DrawLine(VBuffer[4], CBuffer[4], VBuffer[1], CBuffer[1]); - - DrawLine(VBuffer[5], CBuffer[5], VBuffer[1], CBuffer[1]); - DrawLine(VBuffer[5], CBuffer[5], VBuffer[2], CBuffer[2]); - DrawLine(VBuffer[5], CBuffer[5], VBuffer[3], CBuffer[3]); - DrawLine(VBuffer[5], CBuffer[5], VBuffer[4], CBuffer[4]); -} diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_RenderAuxGeom.h b/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_RenderAuxGeom.h deleted file mode 100644 index 50dc262e8d..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_RenderAuxGeom.h +++ /dev/null @@ -1,105 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#ifndef CRYINCLUDE_CRYENGINE_RENDERDLL_XRENDERATOMSHIM_ATOMSHIMRENDERAUXGEOM_H -#define CRYINCLUDE_CRYENGINE_RENDERDLL_XRENDERATOMSHIM_ATOMSHIMRENDERAUXGEOM_H -#pragma once -#include "../Common/RenderAuxGeom.h" -#include -#include - -class CAtomShimRenderer; -class ICrySizer; - -class CAtomShimRenderAuxGeom - : public IRenderAuxGeom -{ -public: - // interface - virtual void SetRenderFlags(const SAuxGeomRenderFlags& renderFlags); - virtual SAuxGeomRenderFlags GetRenderFlags(); - - virtual void Flush() {} - virtual void Commit([[maybe_unused]] uint frames = 0) {} - virtual void Process() {} - - virtual void DrawPoint(const Vec3& v, const ColorB& col, uint8 size = 1); - virtual void DrawPoints(const Vec3* v, uint32 numPoints, const ColorB& col, uint8 size = 1); - virtual void DrawPoints(const Vec3* v, uint32 numPoints, const ColorB* col, uint8 size = 1); - - virtual void DrawLine(const Vec3& v0, const ColorB& colV0, const Vec3& v1, const ColorB& colV1, float thickness = 1.0f); - virtual void DrawLines(const Vec3* v, uint32 numPoints, const ColorB& col, float thickness = 1.0f); - virtual void DrawLines(const Vec3* v, uint32 numPoints, const ColorB* col, float thickness = 1.0f); - virtual void DrawLines(const Vec3* v, uint32 numPoints, const vtx_idx* ind, uint32 numIndices, const ColorB& col, float thickness = 1.0f); - virtual void DrawLines(const Vec3* v, uint32 numPoints, const vtx_idx* ind, uint32 numIndices, const ColorB* col, float thickness = 1.0f); - virtual void DrawPolyline(const Vec3* v, uint32 numPoints, bool closed, const ColorB& col, float thickness = 1.0f); - virtual void DrawPolyline(const Vec3* v, uint32 numPoints, bool closed, const ColorB* col, float thickness = 1.0f); - - virtual void DrawTriangle(const Vec3& v0, const ColorB& colV0, const Vec3& v1, const ColorB& colV1, const Vec3& v2, const ColorB& colV2); - virtual void DrawTriangles(const Vec3* v, uint32 numPoints, const ColorB& col); - virtual void DrawTriangles(const Vec3* v, uint32 numPoints, const ColorB* col); - virtual void DrawTriangles(const Vec3* v, uint32 numPoints, const vtx_idx* ind, uint32 numIndices, const ColorB& col); - virtual void DrawTriangles(const Vec3* v, uint32 numPoints, const vtx_idx* ind, uint32 numIndices, const ColorB* col); - - virtual void DrawQuad(float width, float height, const Matrix34& matWorld, const ColorB& col, bool drawShaded = true); - - virtual void DrawAABB(const AABB& aabb, bool bSolid, const ColorB& col, const EBoundingBoxDrawStyle& bbDrawStyle); - virtual void DrawAABBs(const AABB* aabb, uint32 aabbCount, bool bSolid, const ColorB& col, const EBoundingBoxDrawStyle& bbDrawStyle); - virtual void DrawAABB(const AABB& aabb, const Matrix34& matWorld, bool bSolid, const ColorB& col, const EBoundingBoxDrawStyle& bbDrawStyle); - - virtual void DrawOBB(const OBB& obb, const Vec3& pos, bool bSolid, const ColorB& col, const EBoundingBoxDrawStyle& bbDrawStyle); - virtual void DrawOBB(const OBB& obb, const Matrix34& matWorld, bool bSolid, const ColorB& col, const EBoundingBoxDrawStyle& bbDrawStyle); - - virtual void DrawSphere(const Vec3& pos, float radius, const ColorB& col, bool drawShaded = true); - virtual void DrawDisk(const Vec3& pos, const Vec3& dir, float radius, const ColorB& col, bool drawShaded = true); - virtual void DrawCone(const Vec3& pos, const Vec3& dir, float radius, float height, const ColorB& col, bool drawShaded = true); - virtual void DrawCylinder(const Vec3& pos, const Vec3& dir, float radius, float height, const ColorB& col, bool drawShaded = true); - - virtual void DrawBone(const Vec3& rParent, const Vec3& rBone, ColorB col); - - virtual void RenderText([[maybe_unused]] Vec3 pos, [[maybe_unused]] SDrawTextInfo& ti, [[maybe_unused]] const char* forma, [[maybe_unused]] va_list args) {} - virtual void RenderText_NoArgs([[maybe_unused]] Vec3 pos, [[maybe_unused]] SDrawTextInfo& ti, [[maybe_unused]] const char* text) {} - -public: - static CAtomShimRenderAuxGeom* Create(CAtomShimRenderer& renderer) - { - if (s_pThis == NULL) - { - s_pThis = new CAtomShimRenderAuxGeom(renderer); - } - return s_pThis; - } - -public: - ~CAtomShimRenderAuxGeom(); - - void BeginFrame(); - void EndFrame(); - - void SetViewProjOverride(const AZ::Matrix4x4& viewProj); - void UnsetViewProjOverride(); - -private: - CAtomShimRenderAuxGeom(CAtomShimRenderer& renderer); - - int32_t m_viewProjOverrideIndex = -1; - AZ::RPI::AuxGeomDraw::AuxGeomDynamicIndexedDrawArguments m_drawArgs; - - CAtomShimRenderer* m_renderer; - - static CAtomShimRenderAuxGeom* s_pThis; - - SAuxGeomRenderFlags m_cryRenderFlags; -}; - -#endif // NULL_RENDER_AUX_GEOM_H diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_Renderer.cpp b/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_Renderer.cpp deleted file mode 100644 index 838dd9a20c..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_Renderer.cpp +++ /dev/null @@ -1,1678 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -// Description : Implementation of the NULL renderer API - -#include "CryRenderOther_precompiled.h" -#include "AtomShim_Renderer.h" -#include -#include "IStereoRenderer.h" -#include "../Common/Textures/TextureManager.h" - -#include -#include -// init memory pool usage - -#include "GraphicsPipeline/FurBendData.h" - -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include //std::random_device - -CCryNameTSCRC CTexture::s_sClassName = CCryNameTSCRC("CTexture"); -CCryNameTSCRC CHWShader::s_sClassNameVS = CCryNameTSCRC("CHWShader_VS"); -CCryNameTSCRC CHWShader::s_sClassNamePS = CCryNameTSCRC("CHWShader_PS"); -CCryNameTSCRC CShader::s_sClassName = CCryNameTSCRC("CShader"); - -CAtomShimRenderer* gcpAtomShim = NULL; - - #ifdef _DEBUG -// static array used to check that calls to Set2DMode and Unset2DMode are matched. (static array initialized to zeros automatically). -int s_isIn2DMode[RT_COMMAND_BUF_COUNT]; -#endif - -////////////////////////////////////////////////////////////////////// - -class CNullColorGradingController - : public IColorGradingController -{ -public: - virtual int LoadColorChart([[maybe_unused]] const char* pChartFilePath) const { return 0; } - virtual int LoadDefaultColorChart() const { return 0; } - virtual void UnloadColorChart([[maybe_unused]] int texID) const {} - virtual void SetLayers([[maybe_unused]] const SColorChartLayer* pLayers, [[maybe_unused]] uint32 numLayers) {} -}; - -////////////////////////////////////////////////////////////////////// - -class CNullStereoRenderer - : public IStereoRenderer -{ -public: - virtual EStereoDevice GetDevice() { return STEREO_DEVICE_NONE; } - virtual EStereoDeviceState GetDeviceState() { return STEREO_DEVSTATE_UNSUPPORTED_DEVICE; } - virtual void GetInfo(EStereoDevice* device, EStereoMode* mode, EStereoOutput* output, EStereoDeviceState* state) const - { - if (device) - { - *device = STEREO_DEVICE_NONE; - } - if (mode) - { - *mode = STEREO_MODE_NO_STEREO; - } - if (output) - { - *output = STEREO_OUTPUT_STANDARD; - } - if (state) - { - *state = STEREO_DEVSTATE_OK; - } - } - virtual bool GetStereoEnabled() { return false; } - virtual float GetStereoStrength() { return 0; } - virtual float GetMaxSeparationScene([[maybe_unused]] bool half = true) { return 0; } - virtual float GetZeroParallaxPlaneDist() { return 0; } - virtual void GetNVControlValues([[maybe_unused]] bool& stereoEnabled, [[maybe_unused]] float& stereoStrength) {}; - virtual void OnHmdDeviceChanged() {} - virtual bool IsRenderingToHMD() override { return false; } - Status GetStatus() const override { return IStereoRenderer::Status::kIdle; } -}; - -////////////////////////////////////////////////////////////////////// -CAtomShimRenderer::CAtomShimRenderer() -{ - gcpAtomShim = this; - m_pAtomShimRenderAuxGeom = CAtomShimRenderAuxGeom::Create(*this); - m_pAtomShimColorGradingController = new CNullColorGradingController(); - m_pAtomShimStereoRenderer = new CNullStereoRenderer(); - m_pixelAspectRatio = 1.0f; - Camera::ActiveCameraRequestBus::Handler::BusConnect(); -} - -////////////////////////////////////////////////////////////////////////// -bool QueryIsFullscreen() -{ - return false; -} - - -#include - -namespace Platform -{ - WIN_HWND GetNativeWindowHandle(); -} - -////////////////////////////////////////////////////////////////////// -CAtomShimRenderer::~CAtomShimRenderer() -{ - Camera::ActiveCameraRequestBus::Handler::BusDisconnect(); - ShutDown(); - delete m_pAtomShimRenderAuxGeom; - delete m_pAtomShimColorGradingController; - delete m_pAtomShimStereoRenderer; -} - -////////////////////////////////////////////////////////////////////// -void CAtomShimRenderer::EnableTMU([[maybe_unused]] bool enable) -{ -} - -////////////////////////////////////////////////////////////////////// -void CAtomShimRenderer::CheckError([[maybe_unused]] const char* comment) -{ -} - -////////////////////////////////////////////////////////////////////// -void CAtomShimRenderer::BeginFrame() -{ - if (!m_isFinalInitializationDone) - { - // This will cause the default textures (such as the White texture) to be loaded. In legacy renderer it is called in CRenderer::PostInit - // but that is disabled for AtomShim because NULL_RENDERER is defined. Anyway, it would not work if we called it there because the Asset Catalog - // is not yet loaded when CRenderer::PostInit is called and we use it to load Atom textures. - // [GFX TODO] Do we want NULL_RENDERER defined for AtomShim? It would affect a lot of code in AtomShim if we removed that define. - InitSystemResources(FRR_SYSTEM_RESOURCES); - - // In the legacy renderer this is done in CRenderer::PostInit but that is only done is NULL_RENDERER is not defined. - if (gEnv->pCryFont) - { - m_pDefaultFont = gEnv->pCryFont->GetFont("default"); - if (!m_pDefaultFont) - { - CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_ERROR, "Error getting default font"); - } - } - - AZ::Name apiName = AZ::RHI::Factory::Get().GetName(); - if (!apiName.IsEmpty()) - { - m_rendererDescription = AZStd::string::format("Atom using %s RHI", apiName.GetCStr()); - } - - // Initialize dynamic draw which is used for 2d drawing - const char* shaderFilepath = "Shaders/SimpleTextured.azshader"; - m_dynamicDraw = AZ::RPI::DynamicDrawInterface::Get()->CreateDynamicDrawContext( - AZ::RPI::RPISystemInterface::Get()->GetDefaultScene().get()); - AZ::Data::Instance shader = AZ::RPI::LoadShader(shaderFilepath); - m_dynamicDraw->InitShader(shader); - m_dynamicDraw->InitVertexFormat( - {{"POSITION", AZ::RHI::Format::R32G32B32_FLOAT}, - {"COLOR", AZ::RHI::Format::R8G8B8A8_UNORM}, - {"TEXCOORD0", AZ::RHI::Format::R32G32_FLOAT}}); - // enable the ability to change cull mode, blend mode, the depth state - m_dynamicDraw->AddDrawStateOptions( AZ::RPI::DynamicDrawContext::DrawStateOptions::BlendMode - | AZ::RPI::DynamicDrawContext::DrawStateOptions::PrimitiveType - | AZ::RPI::DynamicDrawContext::DrawStateOptions::DepthState - | AZ::RPI::DynamicDrawContext::DrawStateOptions::FaceCullMode); - m_dynamicDraw->EndInit(); - - // declare the two shader variants it will use - AZ::RPI::ShaderOptionList shaderOptionsClamp; - shaderOptionsClamp.push_back(AZ::RPI::ShaderOption(AZ::Name("o_useColorChannels"), AZ::Name("true"))); - shaderOptionsClamp.push_back(AZ::RPI::ShaderOption(AZ::Name("o_clamp"), AZ::Name("true"))); - m_shaderVariantClamp = m_dynamicDraw->UseShaderVariant(shaderOptionsClamp); - AZ::RPI::ShaderOptionList shaderOptionsWrap; - shaderOptionsWrap.push_back(AZ::RPI::ShaderOption(AZ::Name("o_useColorChannels"), AZ::Name("true"))); - shaderOptionsWrap.push_back(AZ::RPI::ShaderOption(AZ::Name("o_clamp"), AZ::Name("false"))); - m_shaderVariantWrap = m_dynamicDraw->UseShaderVariant(shaderOptionsWrap); - - m_dynamicDraw->NewDrawSrg(); - - m_isFinalInitializationDone = true; - } - - if (m_isInFrame) - { - // If there has not been an EndFrame since the latest BeginFrame then ignore this call to BeginFrame. - return; - } - - m_isInFrame = true; - - m_RP.m_TI[m_RP.m_nFillThreadID].m_nFrameID++; - m_RP.m_TI[m_RP.m_nFillThreadID].m_nFrameUpdateID++; - m_RP.m_TI[m_RP.m_nFillThreadID].m_RealTime = iTimer->GetCurrTime(); - - m_RP.m_TI[m_RP.m_nFillThreadID].m_matView.SetIdentity(); - m_RP.m_TI[m_RP.m_nFillThreadID].m_matProj.SetIdentity(); - - m_pAtomShimRenderAuxGeom->BeginFrame(); -} - -////////////////////////////////////////////////////////////////////// -bool CAtomShimRenderer::ChangeDisplay([[maybe_unused]] unsigned int width, [[maybe_unused]] unsigned int height, [[maybe_unused]] unsigned int bpp) -{ - return false; -} - -////////////////////////////////////////////////////////////////////// -void CAtomShimRenderer::ChangeViewport(unsigned int x, unsigned int y, unsigned int width, unsigned int height, bool bMainViewport, float scaleWidth, float scaleHeight) -{ - float fWidth = aznumeric_cast(width); - float fHeight = aznumeric_cast(height); - - width = aznumeric_cast(fWidth * scaleWidth); - height = aznumeric_cast(fHeight * scaleHeight); - - m_MainRTViewport.nX = x; - m_MainRTViewport.nY = y; - m_MainRTViewport.nWidth = width; - m_MainRTViewport.nHeight = height; - - m_width = m_nativeWidth = m_backbufferWidth = width; - m_height = m_nativeHeight = m_backbufferHeight = height; - - if (m_currContext) - { - m_currContext->m_width = width; - m_currContext->m_height = height; - m_currContext->m_isMainViewport = bMainViewport; - } -} - -void CAtomShimRenderer::RenderDebug([[maybe_unused]] bool bRenderStats) -{ -#if !defined(_RELEASE) - // debug render listeners - { - for (TListRenderDebugListeners::iterator itr = m_listRenderDebugListeners.begin(); - itr != m_listRenderDebugListeners.end(); - ++itr) - { - (*itr)->OnDebugDraw(); - } - } -#endif//_RELEASE -} - -void CAtomShimRenderer::EndFrame() -{ - if (!m_isInFrame) - { - // If there has not been a BeginFrame since the latest EndFrame then ignore this call to EndFrame. - // This can happen when EndFrame is called from UnloadLevel. - return; - } - - m_pAtomShimRenderAuxGeom->EndFrame(); - - EF_RenderTextMessages(); - - // Hack: Assume we're just rendering to the default ViewContext - // Proper multi viewport support will be handled after this shim is removed - if (!m_viewportContext) - { - auto viewContextManager = AZ::Interface::Get(); - auto viewportContext = viewContextManager->GetViewportContextByName(viewContextManager->GetDefaultViewportContextName()); - // If the viewportContext exists and is created with the default ID, we can safely assume control - if (viewportContext && viewportContext->GetId() == -10) - { - m_viewportContext = viewportContext; - } - } - - if (m_viewportContext) - { - m_viewportContext->SetRenderScene(AZ::RPI::RPISystemInterface::Get()->GetDefaultScene()); - m_viewportContext->RenderTick(); - } - - m_isInFrame = false; -} - -void CAtomShimRenderer::TryFlush() -{ -} - -void CAtomShimRenderer::GetMemoryUsage([[maybe_unused]] ICrySizer* Sizer) -{ -} - -WIN_HWND CAtomShimRenderer::GetHWND() -{ - return Platform::GetNativeWindowHandle(); -} - -bool CAtomShimRenderer::SetWindowIcon([[maybe_unused]] const char* path) -{ - return false; -} - -ERenderType CAtomShimRenderer::GetRenderType() const -{ - return eRT_Undefined; -} - -const char* CAtomShimRenderer::GetRenderDescription() const -{ - return m_rendererDescription.c_str(); -} - -void TexBlurAnisotropicVertical([[maybe_unused]] CTexture* pTex, [[maybe_unused]] int nAmount, [[maybe_unused]] float fScale, [[maybe_unused]] float fDistribution, [[maybe_unused]] bool bAlphaOnly) -{ -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////// -//IMAGES DRAWING -//////////////////////////////////////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////// -void CAtomShimRenderer::Draw2dImage([[maybe_unused]] float xpos, [[maybe_unused]] float ypos, [[maybe_unused]] float w, [[maybe_unused]] float h, [[maybe_unused]] int texture_id, [[maybe_unused]] float s0, [[maybe_unused]] float t0, [[maybe_unused]] float s1, [[maybe_unused]] float t1, [[maybe_unused]] float angle, [[maybe_unused]] float r, [[maybe_unused]] float g, [[maybe_unused]] float b, [[maybe_unused]] float a, [[maybe_unused]] float z) -{ -} - -////////////////////////////////////////////////////////////////////// -void CAtomShimRenderer::Push2dImage([[maybe_unused]] float xpos, [[maybe_unused]] float ypos, [[maybe_unused]] float w, [[maybe_unused]] float h, [[maybe_unused]] int texture_id, [[maybe_unused]] float s0, [[maybe_unused]] float t0, [[maybe_unused]] float s1, [[maybe_unused]] float t1, [[maybe_unused]] float angle, [[maybe_unused]] float r, [[maybe_unused]] float g, [[maybe_unused]] float b, [[maybe_unused]] float a, [[maybe_unused]] float z, [[maybe_unused]] float stereoDepth) -{ -} - -void CAtomShimRenderer::Draw2dImageList() -{ -} - -////////////////////////////////////////////////////////////////////// -void CAtomShimRenderer::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) -{ - float s[4], t[4]; - - s[0] = s0; - t[0] = 1.0f - t0; - s[1] = s1; - t[1] = 1.0f - t0; - s[2] = s1; - t[2] = 1.0f - t1; - s[3] = s0; - t[3] = 1.0f - t1; - - DrawImageWithUV(xpos, ypos, 0, w, h, texture_id, s, t, r, g, b, a, filtered); -} - -/////////////////////////////////////////// -void CAtomShimRenderer::DrawImageWithUV(float xpos, float ypos, float z, float w, float h, int texture_id, float s[4], float t[4], float r, float g, float b, float a, bool filtered) -{ - SetCullMode(R_CULL_DISABLE); - EF_SetColorOp(eCO_MODULATE, eCO_MODULATE, DEF_TEXARG0, DEF_TEXARG0); - EF_SetSrgbWrite(false); - - DWORD col = D3DRGBA(r, g, b, a); - - SVF_P3F_C4B_T2F vQuad[4]; - - vQuad[0].xyz.x = xpos; - vQuad[0].xyz.y = ypos; - vQuad[0].xyz.z = z; - vQuad[0].st = Vec2(s[0], t[0]); - vQuad[0].color.dcolor = col; - - vQuad[1].xyz.x = xpos + w; - vQuad[1].xyz.y = ypos; - vQuad[1].xyz.z = z; - vQuad[1].st = Vec2(s[1], t[1]); - vQuad[1].color.dcolor = col; - - vQuad[2].xyz.x = xpos; - vQuad[2].xyz.y = ypos + h; - vQuad[2].xyz.z = z; - vQuad[2].st = Vec2(s[3], t[3]); - vQuad[2].color.dcolor = col; - - vQuad[3].xyz.x = xpos + w; - vQuad[3].xyz.y = ypos + h; - vQuad[3].xyz.z = z; - vQuad[3].st = Vec2(s[2], t[2]); - vQuad[3].color.dcolor = col; - - STexState TS; - TS.SetFilterMode(filtered ? FILTER_BILINEAR : FILTER_POINT); - TS.SetClampMode(1, 1, 1); - SetTexture(texture_id); - - DrawDynVB(vQuad, nullptr, 4, 0, prtTriangleStrip); -} - -/////////////////////////////////////////// -void CAtomShimRenderer::DrawBuffer([[maybe_unused]] CVertexBuffer* pVBuf, [[maybe_unused]] CIndexBuffer* pIBuf, [[maybe_unused]] int nNumIndices, [[maybe_unused]] int nOffsIndex, [[maybe_unused]] const PublicRenderPrimitiveType nPrmode, [[maybe_unused]] int nVertStart, [[maybe_unused]] int nVertStop) -{ -} - -/////////////////////////////////////////// -void CAtomShimRenderer::DrawPrimitivesInternal([[maybe_unused]] CVertexBuffer* src, [[maybe_unused]] int vert_num, [[maybe_unused]] const eRenderPrimitiveType prim_type) -{ -} - -/////////////////////////////////////////// -void CRenderMesh::DrawImmediately() -{ -} - -/////////////////////////////////////////// -void CAtomShimRenderer::SetCullMode(int mode) -{ - AZ::RHI::CullMode cullMode = AZ::RHI::CullMode::None; - switch (mode) - { - case R_CULL_FRONT: - cullMode = AZ::RHI::CullMode::Front; - break; - case R_CULL_BACK: - cullMode = AZ::RHI::CullMode::Back; - break; - } - m_dynamicDraw->SetCullMode(cullMode); -} - -/////////////////////////////////////////// -bool CAtomShimRenderer::EnableFog([[maybe_unused]] bool enable) -{ - return false; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////// -//MISC EXTENSIONS -//////////////////////////////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////// -void CAtomShimRenderer::EnableVSync([[maybe_unused]] bool enable) -{ -} - -////////////////////////////////////////////////////////////////////// -void CAtomShimRenderer::SelectTMU([[maybe_unused]] int tnum) -{ -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////// -//MATRIX FUNCTIONS -//////////////////////////////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////// -void CAtomShimRenderer::PushMatrix() -{ -} - -/////////////////////////////////////////// -void CAtomShimRenderer::RotateMatrix([[maybe_unused]] float a, [[maybe_unused]] float x, [[maybe_unused]] float y, [[maybe_unused]] float z) -{ -} - -void CAtomShimRenderer::RotateMatrix([[maybe_unused]] const Vec3& angles) -{ -} - -/////////////////////////////////////////// -void CAtomShimRenderer::TranslateMatrix([[maybe_unused]] float x, [[maybe_unused]] float y, [[maybe_unused]] float z) -{ -} - -void CAtomShimRenderer::MultMatrix([[maybe_unused]] const float* mat) -{ -} - -void CAtomShimRenderer::TranslateMatrix([[maybe_unused]] const Vec3& pos) -{ -} - -/////////////////////////////////////////// -void CAtomShimRenderer::ScaleMatrix([[maybe_unused]] float x, [[maybe_unused]] float y, [[maybe_unused]] float z) -{ -} - -/////////////////////////////////////////// -void CAtomShimRenderer::PopMatrix() -{ -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////// -void CAtomShimRenderer::LoadMatrix([[maybe_unused]] const Matrix34* src) -{ -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////// -//MISC -//////////////////////////////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////// -void CAtomShimRenderer::PushWireframeMode([[maybe_unused]] int mode){} -void CAtomShimRenderer::PopWireframeMode(){} -void CAtomShimRenderer::FX_PushWireframeMode([[maybe_unused]] int mode){} -void CAtomShimRenderer::FX_PopWireframeMode(){} -void CAtomShimRenderer::FX_SetWireframeMode([[maybe_unused]] int mode){} - -/////////////////////////////////////////// -void CAtomShimRenderer::SetCamera(const CCamera& cam) -{ - CacheCameraConfiguration(cam); - CacheCameraTransform(cam); - - int nThreadID = m_pRT->GetThreadList(); - - // Ortho-normalize camera matrix in double precision to minimize numerical errors and improve precision when inverting matrix - Matrix34_tpl mCam34 = cam.GetMatrix(); - mCam34.OrthonormalizeFast(); - - Matrix44_tpl mCam44T = mCam34.GetTransposed(); - Matrix44_tpl mView64; - mathMatrixLookAtInverse(&mView64, &mCam44T); - - Matrix44 mView = (Matrix44_tpl)mView64; - - // Rotate around x-axis by -PI/2 - Matrix44 mViewFinal = mView; - mViewFinal.m01 = mView.m02; - mViewFinal.m02 = -mView.m01; - mViewFinal.m11 = mView.m12; - mViewFinal.m12 = -mView.m11; - mViewFinal.m21 = mView.m22; - mViewFinal.m22 = -mView.m21; - mViewFinal.m31 = mView.m32; - mViewFinal.m32 = -mView.m31; - - m_RP.m_TI[nThreadID].m_matView = mViewFinal; - - mViewFinal.m30 = 0; - mViewFinal.m31 = 0; - mViewFinal.m32 = 0; - m_CameraZeroMatrix[nThreadID] = mViewFinal; - - if (m_RP.m_TI[nThreadID].m_PersFlags & RBPF_MIRRORCAMERA) - { - Matrix44A tmp; - - tmp = Matrix44A(Matrix33::CreateScale(Vec3(1, -1, 1))).GetTransposed(); - m_RP.m_TI[nThreadID].m_matView = tmp * m_RP.m_TI[nThreadID].m_matView; - } - - m_RP.m_TI[nThreadID].m_cam = cam; - - CameraViewParameters viewParameters; - - // Asymmetric frustum - float Near = cam.GetNearPlane(), Far = cam.GetFarPlane(); - - float wT = tanf(cam.GetFov() * 0.5f) * Near, wB = -wT; - float wR = wT * cam.GetProjRatio(), wL = -wR; - - viewParameters.Frustum(wL + cam.GetAsymL(), wR + cam.GetAsymR(), wB + cam.GetAsymB(), wT + cam.GetAsymT(), Near, Far); - - Vec3 vEye = cam.GetPosition(); - Vec3 vAt = vEye + Vec3((f32)mCam34(0, 1), (f32)mCam34(1, 1), (f32)mCam34(2, 1)); - Vec3 vUp = Vec3((f32)mCam34(0, 2), (f32)mCam34(1, 2), (f32)mCam34(2, 2)); - viewParameters.LookAt(vEye, vAt, vUp); - ApplyViewParameters(viewParameters); - - // Set the Atom view for the context to match the given camera - { - AZ::RPI::ViewPtr viewForCurrentContext; - - // If we have a current context (which we have in Editor but not yet in launcher) then use the view from that. - // Otherwise use the default view from the default scene. - if (m_currContext && m_currContext->m_view) - { - viewForCurrentContext = m_currContext->m_view; - } - else - { - AZ::RPI::ScenePtr scene = AZ::RPI::RPISystemInterface::Get()->GetDefaultScene(); - AZ::RPI::RenderPipelinePtr renderPipeline = scene->GetDefaultRenderPipeline(); - if (renderPipeline) - { - viewForCurrentContext = renderPipeline->GetDefaultView(); - } - } - - if (viewForCurrentContext) - { - // Set camera to world transform for view - AZ::Matrix3x4 cameraWorldTransform = LYTransformToAZMatrix3x4(cam.GetMatrix()); - viewForCurrentContext->SetCameraTransform(cameraWorldTransform); - - // Set projection transform for view - // [GFX TODO] [ATOM-1501] Currently we always assume reverse depth - float fov = cam.GetFov(); - float aspectRatio = cam.GetProjRatio(); - float nearPlane = cam.GetNearPlane(); - float farPlane = cam.GetFarPlane(); - AZ::Matrix4x4 viewToClipMatrix; - AZ::MakePerspectiveFovMatrixRH(viewToClipMatrix, fov, aspectRatio, nearPlane, farPlane, true); - viewForCurrentContext->SetViewToClipMatrix(viewToClipMatrix); - } - } -} - -void CAtomShimRenderer::GetViewport(int* x, int* y, int* width, int* height) const -{ - const SViewport& vp = m_MainRTViewport; - *x = vp.nX; - *y = vp.nY; - *width = vp.nWidth; - *height = vp.nHeight; -} - -void CAtomShimRenderer::SetViewport(int x, int y, int width, int height, [[maybe_unused]] int id) -{ - m_MainRTViewport.nX = x; - m_MainRTViewport.nY = y; - m_MainRTViewport.nWidth = width; - m_MainRTViewport.nHeight = height; - - m_width = width; - m_height = height; -} - -void CAtomShimRenderer::SetScissor(int x, int y, int width, int height) -{ - m_dynamicDraw->SetScissor(AZ::RHI::Scissor(x, y, x + width, y + height)); -} - -////////////////////////////////////////////////////////////////////// -void CAtomShimRenderer::GetModelViewMatrix(float* mat) -{ - int nThreadID = m_pRT->GetThreadList(); - *(Matrix44*)mat = m_RP.m_TI[nThreadID].m_matView; -} - -////////////////////////////////////////////////////////////////////// -void CAtomShimRenderer::GetProjectionMatrix(float* mat) -{ - int nThreadID = m_pRT->GetThreadList(); - *(Matrix44*)mat = m_RP.m_TI[nThreadID].m_matProj; -} - -////////////////////////////////////////////////////////////////////// -void CAtomShimRenderer::SetMatrices(float* pProjMat, float* pViewMat) -{ - int nThreadID = m_pRT->GetThreadList(); - m_RP.m_TI[nThreadID].m_matProj = *(Matrix44*)pProjMat; - m_RP.m_TI[nThreadID].m_matView = *(Matrix44*)pViewMat; -} - -////////////////////////////////////////////////////////////////////// -void CAtomShimRenderer::ApplyViewParameters(const CameraViewParameters& viewParameters) -{ - int nThreadID = m_pRT->GetThreadList(); - m_RP.m_TI[nThreadID].m_cam.m_viewParameters = viewParameters; - Matrix44A* m = &m_RP.m_TI[nThreadID].m_matView; - viewParameters.GetModelviewMatrix((float*)m); - if (m_RP.m_TI[nThreadID].m_PersFlags & RBPF_MIRRORCAMERA) - { - Matrix44A tmp; - - tmp = Matrix44A(Matrix33::CreateScale(Vec3(1, -1, 1))).GetTransposed(); - m_RP.m_TI[nThreadID].m_matView = tmp * m_RP.m_TI[nThreadID].m_matView; - } - m = &m_RP.m_TI[nThreadID].m_matProj; - - const bool bReverseDepth = true; // [GFX TODO] [ATOM-1501] Currently we always assume reverse depth - const bool bWasReverseDepth = (m_RP.m_TI[nThreadID].m_PersFlags & RBPF_REVERSE_DEPTH) != 0 ? 1 : 0; - - m_RP.m_TI[nThreadID].m_PersFlags &= ~RBPF_REVERSE_DEPTH; - if (bReverseDepth) - { - mathMatrixPerspectiveOffCenterReverseDepth((Matrix44A*)m, viewParameters.fWL, viewParameters.fWR, viewParameters.fWB, viewParameters.fWT, viewParameters.fNear, viewParameters.fFar); - m_RP.m_TI[nThreadID].m_PersFlags |= RBPF_REVERSE_DEPTH; - } - -} - -// Check if a file exists. This does not go through the AssetCatalog so that it can identify files that exist but aren't processed yet, -// and so that it will work before the AssetCatalog has loaded -bool CheckIfFileExists(const AZStd::string& sourceRelativePath, const AZStd::string& cacheRelativePath) -{ - // If the file exists, it has already been processed and does not need to be modified - bool fileExists = AZ::IO::FileIOBase::GetInstance()->Exists(cacheRelativePath.c_str()); - - if (!fileExists) - { - // If the texture doesn't exist check if it's queued or being compiled. - AzFramework::AssetSystem::AssetStatus status; - AzFramework::AssetSystemRequestBus::BroadcastResult(status, &AzFramework::AssetSystemRequestBus::Events::GetAssetStatus, sourceRelativePath); - - switch (status) - { - case AzFramework::AssetSystem::AssetStatus_Queued: - case AzFramework::AssetSystem::AssetStatus_Compiling: - case AzFramework::AssetSystem::AssetStatus_Compiled: - case AzFramework::AssetSystem::AssetStatus_Failed: - { - // The file is queued, in progress, or finished processing after the initial FileIO check - fileExists = true; - break; - } - case AzFramework::AssetSystem::AssetStatus_Unknown: - case AzFramework::AssetSystem::AssetStatus_Missing: - default: - { - // The file does not exist - fileExists = false; - break; - } - } - } - - return fileExists; -} - -////////////////////////////////////////////////////////////////////// -ITexture* CAtomShimRenderer::EF_LoadTexture(const char * nameTex, const uint32 flags) -{ - AtomShimTexture* atomTexture = nullptr; - - // have to see if it is already loaded - CBaseResource* pBR = CBaseResource::GetResource(CTexture::mfGetClassName(), nameTex, false); - if (pBR) - { - // if a texture with this ID exists but it is not an Atom texture then we return nullptr - CTexture* texture = static_cast(pBR); - AtomShimTexture* atomTexture2 = CastITextureToAtomShimTexture(texture); - if (atomTexture2) - { - atomTexture2->AddRef(); - return atomTexture2; - } - else - { - return nullptr; - } - } - - AZ_Error("CAtomShimRenderer", AzFramework::StringFunc::Path::IsRelative(nameTex), "CAtomShimRenderer::EF_LoadTexture assumes that it will always be given a relative path, but got '%s'", nameTex); - - atomTexture = new AtomShimTexture(flags); - atomTexture->Register(CTexture::mfGetClassName(), nameTex); - atomTexture->SetSourceName( nameTex ); // needs to be normalized? - - AZStd::string sourceRelativePath(nameTex); - AZStd::string cacheRelativePath = sourceRelativePath + ".streamingimage"; - - bool textureExists = false; - textureExists = CheckIfFileExists(sourceRelativePath, cacheRelativePath); - - if(!textureExists) - { - // A lot of cry code uses the .dds extension even when the actual source file is .tif. - // For the .streamingimage file we need the correct source extension before .streamingimage - // So if the file doesn't exist and the extension was .dds then try replacing it with .tif - AZStd::string extension; - AzFramework::StringFunc::Path::GetExtension(nameTex, extension, false); - if (extension == "dds") - { - sourceRelativePath = nameTex; - - static const char* textureExtensions[] = { "png", "tif", "tiff", "tga", "jpg", "jpeg", "bmp", "gif" }; - - for (const char* extensionReplacement : textureExtensions) - { - AzFramework::StringFunc::Path::ReplaceExtension(sourceRelativePath, extensionReplacement); - cacheRelativePath = sourceRelativePath + ".streamingimage"; - - textureExists = CheckIfFileExists(sourceRelativePath, cacheRelativePath); - if (textureExists) - { - break; - } - } - } - } - - if(!textureExists) - { - AZ_Error("CAtomShimRenderer", false, "EF_LoadTexture attempted to load '%s', but it does not exist.", nameTex); - // Since neither the given extension nor the .dds version exist, we'll default to the given extension for hot-reloading in case the file is added to the source folder later - sourceRelativePath = nameTex; - cacheRelativePath = sourceRelativePath + ".streamingimage"; - } - - // now load the texture - // NOTE: CTexture::CreateTexture does the actual setting of texture data in Cry D3D case - // But it also calls CreateDeviceTexture - - { - using namespace AZ; - - // The file may not be in the AssetCatalog at this point if it is still processing or doesn't exist on disk. - // Use GenerateAssetIdTEMP instead of GetAssetIdByPath so that it will return a valid AssetId anyways - Data::AssetId streamingImageAssetId; - Data::AssetCatalogRequestBus::BroadcastResult( - streamingImageAssetId, &Data::AssetCatalogRequestBus::Events::GenerateAssetIdTEMP, - sourceRelativePath.c_str()); - streamingImageAssetId.m_subId = RPI::StreamingImageAsset::GetImageAssetSubId(); - - auto streamingImageAsset = Data::AssetManager::Instance().FindOrCreateAsset(streamingImageAssetId, AZ::Data::AssetLoadBehavior::PreLoad); - - if (!streamingImageAsset.IsReady()) - { - atomTexture->QueueForHotReload(streamingImageAssetId); - } - else - { - atomTexture->CreateFromStreamingImageAsset(streamingImageAsset); - } - } - - atomTexture->SetTexStates(); - - return atomTexture; -} - -////////////////////////////////////////////////////////////////////// -ITexture* CAtomShimRenderer::EF_LoadDefaultTexture(const char * nameTex) -{ - return CTextureManager::Instance()->GetDefaultTexture(nameTex); -} - -////////////////////////////////////////////////////////////////////// -void CAtomShimRenderer::DrawQuad([[maybe_unused]] const Vec3& right, [[maybe_unused]] const Vec3& up, [[maybe_unused]] const Vec3& origin, [[maybe_unused]] int nFlipmode /*=0*/) -{ -} - -////////////////////////////////////////////////////////////////////// -bool CAtomShimRenderer::ProjectToScreen(float ptx, float pty, float ptz, float* sx, float* sy, float* sz) -{ - int nThreadID = m_pRT->GetThreadList(); - SViewport& vp = m_MainRTViewport; - - Vec3 vOut, vIn; - vIn.x = ptx; - vIn.y = pty; - vIn.z = ptz; - - int32 v[4]; - v[0] = vp.nX; - v[1] = vp.nY; - v[2] = vp.nWidth; - v[3] = vp.nHeight; - - Matrix44A mIdent; - mIdent.SetIdentity(); - if (mathVec3Project( - &vOut, - &vIn, - v, - &m_RP.m_TI[nThreadID].m_matProj, - &m_RP.m_TI[nThreadID].m_matView, - &mIdent)) - { - *sx = vOut.x * 100 / vp.nWidth; - *sy = vOut.y * 100 / vp.nHeight; - *sz = (m_RP.m_TI[nThreadID].m_PersFlags & RBPF_REVERSE_DEPTH) ? 1.0f - vOut.z : vOut.z; - - return true; - } - - return false; -} - -static bool InvertMatrixPrecise(Matrix44& out, const float* m) -{ - // Inverts matrix using Gaussian Elimination which is slower but numerically more stable than Cramer's Rule - - float expmat[4][8] = { - { m[0], m[4], m[8], m[12], 1.f, 0.f, 0.f, 0.f }, - { m[1], m[5], m[9], m[13], 0.f, 1.f, 0.f, 0.f }, - { m[2], m[6], m[10], m[14], 0.f, 0.f, 1.f, 0.f }, - { m[3], m[7], m[11], m[15], 0.f, 0.f, 0.f, 1.f } - }; - - float t0, t1, t2, t3, t; - float* r0 = expmat[0], * r1 = expmat[1], * r2 = expmat[2], * r3 = expmat[3]; - - // Choose pivots and eliminate variables - if (fabs(r3[0]) > fabs(r2[0])) - { - std::swap(r3, r2); - } - if (fabs(r2[0]) > fabs(r1[0])) - { - std::swap(r2, r1); - } - if (fabs(r1[0]) > fabs(r0[0])) - { - std::swap(r1, r0); - } - if (r0[0] == 0) - { - return false; - } - t1 = r1[0] / r0[0]; - t2 = r2[0] / r0[0]; - t3 = r3[0] / r0[0]; - t = r0[1]; - r1[1] -= t1 * t; - r2[1] -= t2 * t; - r3[1] -= t3 * t; - t = r0[2]; - r1[2] -= t1 * t; - r2[2] -= t2 * t; - r3[2] -= t3 * t; - t = r0[3]; - r1[3] -= t1 * t; - r2[3] -= t2 * t; - r3[3] -= t3 * t; - t = r0[4]; - if (t != 0.0) - { - r1[4] -= t1 * t; - r2[4] -= t2 * t; - r3[4] -= t3 * t; - } - t = r0[5]; - if (t != 0.0) - { - r1[5] -= t1 * t; - r2[5] -= t2 * t; - r3[5] -= t3 * t; - } - t = r0[6]; - if (t != 0.0) - { - r1[6] -= t1 * t; - r2[6] -= t2 * t; - r3[6] -= t3 * t; - } - t = r0[7]; - if (t != 0.0) - { - r1[7] -= t1 * t; - r2[7] -= t2 * t; - r3[7] -= t3 * t; - } - - if (fabs(r3[1]) > fabs(r2[1])) - { - std::swap(r3, r2); - } - if (fabs(r2[1]) > fabs(r1[1])) - { - std::swap(r2, r1); - } - if (r1[1] == 0) - { - return false; - } - t2 = r2[1] / r1[1]; - t3 = r3[1] / r1[1]; - r2[2] -= t2 * r1[2]; - r3[2] -= t3 * r1[2]; - r2[3] -= t2 * r1[3]; - r3[3] -= t3 * r1[3]; - t = r1[4]; - if (0.0 != t) - { - r2[4] -= t2 * t; - r3[4] -= t3 * t; - } - t = r1[5]; - if (0.0 != t) - { - r2[5] -= t2 * t; - r3[5] -= t3 * t; - } - t = r1[6]; - if (0.0 != t) - { - r2[6] -= t2 * t; - r3[6] -= t3 * t; - } - t = r1[7]; - if (0.0 != t) - { - r2[7] -= t2 * t; - r3[7] -= t3 * t; - } - - if (fabs(r3[2]) > fabs(r2[2])) - { - std::swap(r3, r2); - } - if (r2[2] == 0) - { - return false; - } - t3 = r3[2] / r2[2]; - r3[3] -= t3 * r2[3]; - r3[4] -= t3 * r2[4]; - r3[5] -= t3 * r2[5]; - r3[6] -= t3 * r2[6]; - r3[7] -= t3 * r2[7]; - - if (r3[3] == 0) - { - return false; - } - - // Substitute back - t = 1.0f / r3[3]; - r3[4] *= t; - r3[5] *= t; - r3[6] *= t; - r3[7] *= t; // Row 3 - - t2 = r2[3]; - t = 1.0f / r2[2]; // Row 2 - r2[4] = t * (r2[4] - r3[4] * t2); - r2[5] = t * (r2[5] - r3[5] * t2); - r2[6] = t * (r2[6] - r3[6] * t2); - r2[7] = t * (r2[7] - r3[7] * t2); - t1 = r1[3]; - r1[4] -= r3[4] * t1; - r1[5] -= r3[5] * t1; - r1[6] -= r3[6] * t1; - r1[7] -= r3[7] * t1; - t0 = r0[3]; - r0[4] -= r3[4] * t0; - r0[5] -= r3[5] * t0; - r0[6] -= r3[6] * t0; - r0[7] -= r3[7] * t0; - - t1 = r1[2]; - t = 1.0f / r1[1]; // Row 1 - r1[4] = t * (r1[4] - r2[4] * t1); - r1[5] = t * (r1[5] - r2[5] * t1); - r1[6] = t * (r1[6] - r2[6] * t1); - r1[7] = t * (r1[7] - r2[7] * t1); - t0 = r0[2]; - r0[4] -= r2[4] * t0; - r0[5] -= r2[5] * t0; - r0[6] -= r2[6] * t0, r0[7] -= r2[7] * t0; - - t0 = r0[1]; - t = 1.0f / r0[0]; // Row 0 - r0[4] = t * (r0[4] - r1[4] * t0); - r0[5] = t * (r0[5] - r1[5] * t0); - r0[6] = t * (r0[6] - r1[6] * t0); - r0[7] = t * (r0[7] - r1[7] * t0); - - out.m00 = r0[4]; - out.m01 = r0[5]; - out.m02 = r0[6]; - out.m03 = r0[7]; - out.m10 = r1[4]; - out.m11 = r1[5]; - out.m12 = r1[6]; - out.m13 = r1[7]; - out.m20 = r2[4]; - out.m21 = r2[5]; - out.m22 = r2[6]; - out.m23 = r2[7]; - out.m30 = r3[4]; - out.m31 = r3[5]; - out.m32 = r3[6]; - out.m33 = r3[7]; - - return true; -} - -static int sUnProject(float winx, float winy, float winz, const float model[16], const float proj[16], const int viewport[4], float* objx, float* objy, float* objz) -{ - Vec4 vIn; - vIn.x = (winx - viewport[0]) * 2 / viewport[2] - 1.0f; - vIn.y = (winy - viewport[1]) * 2 / viewport[3] - 1.0f; - vIn.z = winz;//2.0f * winz - 1.0f; - vIn.w = 1.0; - - float m1[16]; - for (int i = 0; i < 4; i++) - { - float ai0 = proj[i], ai1 = proj[4 + i], ai2 = proj[8 + i], ai3 = proj[12 + i]; - m1[i] = ai0 * model[0] + ai1 * model[1] + ai2 * model[2] + ai3 * model[3]; - m1[4 + i] = ai0 * model[4] + ai1 * model[5] + ai2 * model[6] + ai3 * model[7]; - m1[8 + i] = ai0 * model[8] + ai1 * model[9] + ai2 * model[10] + ai3 * model[11]; - m1[12 + i] = ai0 * model[12] + ai1 * model[13] + ai2 * model[14] + ai3 * model[15]; - } - - Matrix44 m; - InvertMatrixPrecise(m, m1); - - Vec4 vOut = m * vIn; - if (vOut.w == 0.0) - { - return false; - } - *objx = vOut.x / vOut.w; - *objy = vOut.y / vOut.w; - *objz = vOut.z / vOut.w; - return true; -} - -int CAtomShimRenderer::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]) -{ - return sUnProject(sx, sy, sz, modelMatrix, projMatrix, viewport, px, py, pz); -} - -////////////////////////////////////////////////////////////////////// -int CAtomShimRenderer::UnProjectFromScreen(float sx, float sy, float sz, - float* px, float* py, float* pz) -{ - float modelMatrix[16]; - float projMatrix[16]; - int viewport[4]; - - const int nThreadID = m_pRT->GetThreadList(); - if (m_RP.m_TI[nThreadID].m_PersFlags & RBPF_REVERSE_DEPTH) - { - sz = 1.0f - sz; - } - - GetModelViewMatrix(modelMatrix); - GetProjectionMatrix(projMatrix); - GetViewport(&viewport[0], &viewport[1], &viewport[2], &viewport[3]); - return sUnProject(sx, sy, sz, modelMatrix, projMatrix, viewport, px, py, pz); -} - -////////////////////////////////////////////////////////////////////// -bool CAtomShimRenderer::ScreenShot([[maybe_unused]] const char* filename, [[maybe_unused]] int width) -{ - return true; -} - -int CAtomShimRenderer::ScreenToTexture([[maybe_unused]] int nTexID) -{ - return 0; -} - -void CAtomShimRenderer::ResetToDefault() -{ -} - -/////////////////////////////////////////// -void CAtomShimRenderer::SetMaterialColor([[maybe_unused]] float r, [[maybe_unused]] float g, [[maybe_unused]] float b, [[maybe_unused]] float a) -{ -} - -////////////////////////////////////////////////////////////////////// -void CAtomShimRenderer::ClearTargetsImmediately([[maybe_unused]] uint32 nFlags) {} -void CAtomShimRenderer::ClearTargetsImmediately([[maybe_unused]] uint32 nFlags, [[maybe_unused]] const ColorF& Colors, [[maybe_unused]] float fDepth) {} -void CAtomShimRenderer::ClearTargetsImmediately([[maybe_unused]] uint32 nFlags, [[maybe_unused]] const ColorF& Colors) {} -void CAtomShimRenderer::ClearTargetsImmediately([[maybe_unused]] uint32 nFlags, [[maybe_unused]] float fDepth) {} - -void CAtomShimRenderer::ClearTargetsLater([[maybe_unused]] uint32 nFlags) {} -void CAtomShimRenderer::ClearTargetsLater([[maybe_unused]] uint32 nFlags, [[maybe_unused]] const ColorF& Colors, [[maybe_unused]] float fDepth) {} -void CAtomShimRenderer::ClearTargetsLater([[maybe_unused]] uint32 nFlags, [[maybe_unused]] const ColorF& Colors) {} -void CAtomShimRenderer::ClearTargetsLater([[maybe_unused]] uint32 nFlags, [[maybe_unused]] float fDepth) {} - -void CAtomShimRenderer::ReadFrameBuffer([[maybe_unused]] unsigned char* pRGB, [[maybe_unused]] int nImageX, [[maybe_unused]] int nSizeX, [[maybe_unused]] int nSizeY, [[maybe_unused]] ERB_Type eRBType, [[maybe_unused]] bool bRGBA, [[maybe_unused]] int nScaledX, [[maybe_unused]] int nScaledY) -{ -} - -void CAtomShimRenderer::ReadFrameBufferFast([[maybe_unused]] uint32* pDstARGBA8, [[maybe_unused]] int dstWidth, [[maybe_unused]] int dstHeight, [[maybe_unused]] bool BGRA) -{ -} - -bool CAtomShimRenderer::CaptureFrameBufferFast([[maybe_unused]] unsigned char* pDstRGBA8, [[maybe_unused]] int destinationWidth, [[maybe_unused]] int destinationHeight) -{ - return false; -} -bool CAtomShimRenderer::CopyFrameBufferFast([[maybe_unused]] unsigned char* pDstRGBA8, [[maybe_unused]] int destinationWidth, [[maybe_unused]] int destinationHeight) -{ - return false; -} - -bool CAtomShimRenderer::InitCaptureFrameBufferFast([[maybe_unused]] uint32 bufferWidth, [[maybe_unused]] uint32 bufferHeight) -{ - return(false); -} - -void CAtomShimRenderer::CloseCaptureFrameBufferFast(void) -{ -} - -bool CAtomShimRenderer::RegisterCaptureFrame([[maybe_unused]] ICaptureFrameListener* pCapture) -{ - return(false); -} -bool CAtomShimRenderer::UnRegisterCaptureFrame([[maybe_unused]] ICaptureFrameListener* pCapture) -{ - return(false); -} - -void CAtomShimRenderer::CaptureFrameBufferCallBack(void) -{ -} - - -void CAtomShimRenderer::SetFogColor([[maybe_unused]] const ColorF& color) -{ -} - -void CAtomShimRenderer::DrawQuad([[maybe_unused]] float dy, [[maybe_unused]] float dx, [[maybe_unused]] float dz, [[maybe_unused]] float x, [[maybe_unused]] float y, [[maybe_unused]] float z) -{ -} - -////////////////////////////////////////////////////////////////////// - -int CAtomShimRenderer::CreateRenderTarget([[maybe_unused]] const char* name, [[maybe_unused]] int nWidth, [[maybe_unused]] int nHeight, [[maybe_unused]] const ColorF& cClear, [[maybe_unused]] ETEX_Format eTF) -{ - return 0; -} - -bool CAtomShimRenderer::ResizeRenderTarget([[maybe_unused]] int nHandle, [[maybe_unused]] int nWidth, [[maybe_unused]] int nHeight) -{ - return true; -} - -bool CAtomShimRenderer::DestroyRenderTarget([[maybe_unused]] int nHandle) -{ - return true; -} - -bool CAtomShimRenderer::SetRenderTarget([[maybe_unused]] int nHandle, [[maybe_unused]] SDepthTexture* pDepthSurf) -{ - return true; -} - -SDepthTexture* CAtomShimRenderer::CreateDepthSurface([[maybe_unused]] int nWidth, [[maybe_unused]] int nHeight, [[maybe_unused]] bool shaderResourceView) -{ - return nullptr; -} - -void CAtomShimRenderer::DestroyDepthSurface([[maybe_unused]] SDepthTexture* pDepthSurf) -{ -} - -void CAtomShimRenderer::WaitForParticleBuffer([[maybe_unused]] threadID nThreadId) -{ -} - -int CAtomShimRenderer::GetOcclusionBuffer([[maybe_unused]] uint16* pOutOcclBuffer, [[maybe_unused]] Matrix44* pmCamBuffe) -{ - return 0; -} - -IColorGradingController* CAtomShimRenderer::GetIColorGradingController() -{ - return m_pAtomShimColorGradingController; -} - -IStereoRenderer* CAtomShimRenderer::GetIStereoRenderer() -{ - return m_pAtomShimStereoRenderer; -} - -ITexture* CAtomShimRenderer::Create2DTexture([[maybe_unused]] const char* name, [[maybe_unused]] int width, [[maybe_unused]] int height, [[maybe_unused]] int numMips, [[maybe_unused]] int flags, [[maybe_unused]] unsigned char* data, [[maybe_unused]] ETEX_Format format) -{ - return nullptr; -} - -//========================================================================================= - - -ILog* iLog; -IConsole* iConsole; -ITimer* iTimer; -ISystem* iSystem; - -StaticInstance g_nullRenderer; - -extern "C" DLL_EXPORT IRenderer * CreateCryRenderInterface(ISystem * pSystem) -{ - ModuleInitISystem(pSystem, "CryRenderer"); - - gbRgb = false; - - iConsole = gEnv->pConsole; - iLog = gEnv->pLog; - iTimer = gEnv->pTimer; - iSystem = gEnv->pSystem; - - CRenderer* rd = g_nullRenderer; - if (rd) - { - rd->InitRenderer(); - } - - std::random_device randDev; - srand(static_cast(randDev())); - - return rd; -} - -class CEngineModule_CryRenderer - : public IEngineModule -{ - CRYINTERFACE_SIMPLE(IEngineModule) - CRYGENERATE_SINGLETONCLASS(CEngineModule_CryRenderer, "EngineModule_CryRenderer", 0x540c91a7338e41d3, 0xaceeac9d55614450) - - virtual const char* GetName() const { - return "CryRenderer"; - } - virtual const char* GetCategory() const {return "CryEngine"; } - - virtual bool Initialize(SSystemGlobalEnvironment& env, [[maybe_unused]] const SSystemInitParams& initParams) - { - ISystem* pSystem = env.pSystem; - env.pRenderer = CreateCryRenderInterface(pSystem); - return env.pRenderer != 0; - } -}; - -CRYREGISTER_SINGLETON_CLASS(CEngineModule_CryRenderer) - -CEngineModule_CryRenderer::CEngineModule_CryRenderer() -{ -}; - -CEngineModule_CryRenderer::~CEngineModule_CryRenderer() -{ -}; - -void COcclusionQuery::Create() -{ -} - -void COcclusionQuery::Release() -{ -} - -void COcclusionQuery::BeginQuery() -{ -} - -void COcclusionQuery::EndQuery() -{ -} - -uint32 COcclusionQuery::GetVisibleSamples([[maybe_unused]] bool bAsynchronous) -{ - return 0; -} - -/*static*/ FurBendData& FurBendData::Get() -{ - static FurBendData s_instance; - return s_instance; -} - -void FurBendData::InsertNewElements() -{ -} - -void FurBendData::FreeData() -{ -} - -void FurBendData::OnBeginFrame() -{ -} - -TArray* CRenderer::EF_GetDeferredLights([[maybe_unused]] const SRenderingPassInfo& passInfo, [[maybe_unused]] const eDeferredLightType eLightType) -{ - static TArray lights; - return &lights; -} - -SRenderLight* CRenderer::EF_GetDeferredLightByID([[maybe_unused]] const uint16 nLightID, [[maybe_unused]] const eDeferredLightType eLightType) -{ - return nullptr; -} - - -void CRenderer::BeginSpawningGeneratingRendItemJobs([[maybe_unused]] int nThreadID) -{ -} - -void CRenderer::BeginSpawningShadowGeneratingRendItemJobs([[maybe_unused]] int nThreadID) -{ -} - -void CRenderer::EndSpawningGeneratingRendItemJobs() -{ -} - -void CAtomShimRenderer::PrecacheResources() -{ -} - -bool CAtomShimRenderer::EF_PrecacheResource([[maybe_unused]] SShaderItem* pSI, [[maybe_unused]] float fMipFactorSI, [[maybe_unused]] float fTimeToReady, [[maybe_unused]] int Flags, [[maybe_unused]] int nUpdateId, [[maybe_unused]] int nCounter) -{ - return true; -} - -ITexture* CAtomShimRenderer::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) -{ - return CTextureManager::Instance()->GetNoTexture(); -} - -void CAtomShimRenderer::FX_ClearTarget([[maybe_unused]] ITexture* pTex) -{ -} - -void CAtomShimRenderer::FX_ClearTarget([[maybe_unused]] SDepthTexture* pTex) -{ -} - -bool CAtomShimRenderer::FX_SetRenderTarget([[maybe_unused]] int nTarget, [[maybe_unused]] void* pTargetSurf, [[maybe_unused]] SDepthTexture* pDepthTarget, [[maybe_unused]] uint32 nTileCount) -{ - return true; -} - -bool CAtomShimRenderer::FX_PushRenderTarget([[maybe_unused]] int nTarget, [[maybe_unused]] void* pTargetSurf, [[maybe_unused]] SDepthTexture* pDepthTarget, [[maybe_unused]] uint32 nTileCount) -{ - return true; -} - -bool CAtomShimRenderer::FX_SetRenderTarget([[maybe_unused]] int nTarget, [[maybe_unused]] CTexture* pTarget, [[maybe_unused]] SDepthTexture* pDepthTarget, [[maybe_unused]] bool bPush, [[maybe_unused]] int nCMSide, [[maybe_unused]] bool bScreenVP, [[maybe_unused]] uint32 nTileCount) -{ - return true; -} - -bool CAtomShimRenderer::FX_PushRenderTarget([[maybe_unused]] int nTarget, [[maybe_unused]] CTexture* pTarget, [[maybe_unused]] SDepthTexture* pDepthTarget, [[maybe_unused]] int nCMSide, [[maybe_unused]] bool bScreenVP, [[maybe_unused]] uint32 nTileCount) -{ - return true; -} -bool CAtomShimRenderer::FX_RestoreRenderTarget([[maybe_unused]] int nTarget) -{ - return true; -} -bool CAtomShimRenderer::FX_PopRenderTarget([[maybe_unused]] int nTarget) -{ - return true; -} - -IDynTexture* CAtomShimRenderer::CreateDynTexture2([[maybe_unused]] uint32 nWidth, [[maybe_unused]] uint32 nHeight, [[maybe_unused]] uint32 nTexFlags, [[maybe_unused]] const char* szSource, [[maybe_unused]] ETexPool eTexPool) -{ - return nullptr; -} - -void CAtomShimRenderer::InitSystemResources([[maybe_unused]] int nFlags) -{ - // This is an override of the implementation in CRenderer and is significantly cut down for the shim. - if (!m_bSystemResourcesInit || m_bDeviceLost == 2) - { - CTextureManager::Instance()->Init(); - m_bSystemResourcesInit = 1; - } -} - -void CAtomShimRenderer::SetTexture(int tnum) -{ - SetTexture(tnum, 0); -} - -void CAtomShimRenderer::SetTexture(int tnum, int nUnit) -{ - SetTextureForUnit(nUnit, tnum); -} - -void CAtomShimRenderer::SetState([[maybe_unused]] int State, [[maybe_unused]] int AlphaRef) -{ - // [GFX TODO] would need to implement this for LyShine mask support and blend mode support -} - -void CAtomShimRenderer::SetTextureForUnit(int unit, int textureId) -{ - AZ_Assert(unit >= 0 && unit < 32, "Invalid texture unit"); - AtomShimTexture* atomTexture = CastITextureToAtomShimTexture(EF_GetTextureByID(textureId)); - m_currentTextureForUnit[unit] = atomTexture; - m_clampFlagPerTextureUnit[unit] = (atomTexture->GetFlags() & FT_STATE_CLAMP) ? true : false; -} - -const AZ::Transform& CAtomShimRenderer::GetActiveCameraTransform() -{ - return m_cameraTransform; -} - -const Camera::Configuration& CAtomShimRenderer::GetActiveCameraConfiguration() -{ - return m_cameraConfiguration; -} - -void CAtomShimRenderer::CacheCameraTransform(const CCamera& camera) -{ - m_cameraTransform = LYTransformToAZTransform(camera.GetMatrix()); -} - -void CAtomShimRenderer::CacheCameraConfiguration(const CCamera& camera) -{ - Camera::Configuration& config = m_cameraConfiguration; - config.m_fovRadians = camera.GetFov(); - config.m_nearClipDistance = camera.GetNearPlane(); - config.m_farClipDistance = camera.GetFarPlane(); - config.m_frustumHeight = config.m_farClipDistance * tanf(config.m_fovRadians / 2) * 2; - config.m_frustumWidth = config.m_frustumHeight * camera.GetViewSurfaceX() / camera.GetViewSurfaceZ(); -} - -void CAtomShimRenderer::DrawStringU( - [[maybe_unused]] IFFont_RenderProxy* pFont, [[maybe_unused]] float x, [[maybe_unused]] float y, [[maybe_unused]] float z, - [[maybe_unused]] const char* pStr, [[maybe_unused]] const bool asciiMultiLine, [[maybe_unused]] const STextDrawContext& ctx) const -{ - // RenderCallback disabled, ICryFont has been directly implemented on Atom by Gems/AtomLyIntegration/AtomFont. -} - -void CAtomShimRenderer::DrawDynVB(SVF_P3F_C4B_T2F* pBuf, uint16* pInds, int nVerts, int nInds, const PublicRenderPrimitiveType nPrimType) -{ - using namespace AZ; - - // if nothing to draw then return - if (!pBuf || !nVerts || (pInds && !nInds) || (nInds && !pInds)) - { - return; - } - - // get view proj materix - Matrix44A matView, matProj; - GetModelViewMatrix(matView.GetData()); - GetProjectionMatrix(matProj.GetData()); - Matrix44A matViewProj = matView * matProj; - Matrix4x4 azMatViewProj = Matrix4x4::CreateFromColumnMajorFloat16(matViewProj.GetData()); - - bool isClamp = m_clampFlagPerTextureUnit[0]; - m_dynamicDraw->SetShaderVariant(isClamp? m_shaderVariantClamp : m_shaderVariantWrap); - - Data::Instance drawSrg = m_dynamicDraw->NewDrawSrg(); - drawSrg->SetConstant(m_viewProjInputIndex, azMatViewProj); - - AtomShimTexture* atomTexture = m_currentTextureForUnit[0]; - drawSrg->SetImageView(m_imageInputIndex, atomTexture->m_imageView.get()); - - drawSrg->Compile(); - - RHI::PrimitiveTopology primitiveType = RHI::PrimitiveTopology::TriangleList; - - switch (nPrimType) - { - case prtTriangleList: - primitiveType = RHI::PrimitiveTopology::TriangleList; - break; - case prtTriangleStrip: - primitiveType = RHI::PrimitiveTopology::TriangleStrip; - break; - case prtLineList: - primitiveType = RHI::PrimitiveTopology::LineList; - break; - case prtLineStrip: - primitiveType = RHI::PrimitiveTopology::LineStrip; - break; - } - - m_dynamicDraw->SetPrimitiveType(primitiveType); - - if (pInds) - { - m_dynamicDraw->DrawIndexed(pBuf, nVerts, pInds, nInds, RHI::IndexFormat::Uint16, drawSrg); - } - else - { - m_dynamicDraw->DrawLinear(pBuf, nVerts, drawSrg); - } -} - -void CAtomShimRenderer::DrawDynUiPrimitiveList( - [[maybe_unused]] DynUiPrimitiveList& primitives, [[maybe_unused]] int totalNumVertices, [[maybe_unused]] int totalNumIndices) -{ - // This function was only used by LyShine and LyShine is moving to Atom implementation. - return; -} - -void CAtomShimRenderer::Set2DMode(uint32 orthoWidth, uint32 orthoHeight, TransformationMatrices& backupMatrices, float znear, float zfar) -{ - Set2DModeNonZeroTopLeft(0.0f, 0.0f, static_cast(orthoWidth), static_cast(orthoHeight), backupMatrices, znear, zfar); -} - -void CAtomShimRenderer::Unset2DMode(const TransformationMatrices& restoringMatrices) -{ - int nThreadID = m_pRT->GetThreadList(); - -#ifdef _DEBUG - // Check that we are already in 2D mode on this thread and decrement the counter used for this check. - AZ_Assert(s_isIn2DMode[nThreadID]-- > 0, "Calls to Set2DMode and Unset2DMode appear mismatched"); -#endif - - m_RP.m_TI[nThreadID].m_matView = restoringMatrices.m_viewMatrix; - m_RP.m_TI[nThreadID].m_matProj = restoringMatrices.m_projectMatrix; - - // The legacy renderer supports nested Set2dMode/Unset2dMode so we use a counter to support that also. - m_isIn2dModeCounter--; - if (m_isIn2dModeCounter > 0) - { - // We're still in 2d mode, so set the viewProjOverride to the current matrix - // For 2d drawing, the view matrix is an identity matrix, so viewProj == proj - AZ::Matrix4x4 viewProj = AZ::Matrix4x4::CreateFromColumnMajorFloat16(m_RP.m_TI[nThreadID].m_matProj.GetData()); - m_pAtomShimRenderAuxGeom->SetViewProjOverride(viewProj); - } - else - { - m_pAtomShimRenderAuxGeom->UnsetViewProjOverride(); - } -} - -void CAtomShimRenderer::Set2DModeNonZeroTopLeft( - float orthoLeft, float orthoTop, float orthoWidth, float orthoHeight, TransformationMatrices& backupMatrices, float znear, float zfar) -{ - int nThreadID = m_pRT->GetThreadList(); - -#ifdef _DEBUG - // Increment the counter used to check that Set2DMode and Unset2DMode are balanced. - // It should never be negative before the increment. - AZ_Assert(s_isIn2DMode[nThreadID]++ >= 0, "Calls to Set2DMode and Unset2DMode appear mismatched"); -#endif - - backupMatrices.m_projectMatrix = m_RP.m_TI[nThreadID].m_matProj; - - // Move the zfar a bit away from the znear if they're the same. - if (AZ::IsClose(znear, zfar, .001f)) - { - zfar += .01f; - } - - float left = orthoLeft; - float right = left + orthoWidth; - float top = orthoTop; - float bottom = top + orthoHeight; - - mathMatrixOrthoOffCenterLH(&m_RP.m_TI[nThreadID].m_matProj, left, right, bottom, top, znear, zfar); - - if (m_RP.m_TI[nThreadID].m_PersFlags & RBPF_REVERSE_DEPTH) - { - // [GFX TODO] [ATOM-661] may need to reverse the depth here (though for 2D it may not be necessary) - } - - backupMatrices.m_viewMatrix = m_RP.m_TI[nThreadID].m_matView; - m_RP.m_TI[nThreadID].m_matView.SetIdentity(); - - m_isIn2dModeCounter++; - - // For 2d drawing, the view matrix is an identity matrix, so viewProj == proj - AZ::Matrix4x4 viewProj = AZ::Matrix4x4::CreateFromColumnMajorFloat16(m_RP.m_TI[nThreadID].m_matProj.GetData()); - m_pAtomShimRenderAuxGeom->SetViewProjOverride(viewProj); -} - -void CAtomShimRenderer::SetColorOp( - [[maybe_unused]] byte eCo, [[maybe_unused]] byte eAo, [[maybe_unused]] byte eCa, [[maybe_unused]] byte eAa) -{ - // this is only used by LY ImGui gem -} diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_Renderer.h b/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_Renderer.h deleted file mode 100644 index a95dfb602c..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_Renderer.h +++ /dev/null @@ -1,617 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#ifndef NULL_RENDERER_H -#define NULL_RENDERER_H - -#if _MSC_VER > 1000 -# pragma once -#endif - -/* -=========================================== -The NULLRenderer interface Class -=========================================== -*/ - -#define MAX_TEXTURE_STAGES 4 - -#include "CryArray.h" -#include "AtomShim_RenderAuxGeom.h" - -#include - -#include - -#include -#include -#include -#include - -#include - -// Forward declaration. -namespace AZ -{ - namespace RHI - { - class Image; - } - - namespace RPI - { - class Scene; - class RenderPipeline; - class WindowContext; - class View; - class ViewportContext; - } -} - -//! A vector of these structs is used to keep track of the different viewports using Atom to render. -//! Each viewport currently has its own scene and pipeline. -struct AtomShimViewContext -{ - HWND m_hWnd; - bool m_isMainViewport; - - // width and height of the viewport. - // These are not fully used currently since each viewport window sends OnWindowResized messages to the WindowContext - // these could instead be sent via the AtomShim in future if desired. - int m_width; - int m_height; - - AZ::RPI::Scene* m_scene = nullptr; - AZStd::shared_ptr m_renderPipeline; - AZStd::shared_ptr m_view; -}; - -#define ATOM_SHIM_TEXTURE_TYPE eTT_MaxTexType - -struct AtomShimTexture - : public CTexture - , public AZ::Data::AssetBus::Handler -{ - AtomShimTexture(uint32 nFlags) : CTexture(nFlags) - { - } - - virtual ~AtomShimTexture(); - - void QueueForHotReload(const AZ::Data::AssetId& assetId); - - void OnAssetReady(AZ::Data::Asset asset) override; - - void CreateFromStreamingImageAsset(const AZ::Data::Asset& streamingImageAsset); - void CreateFromImage(const AZ::Data::Instance& image); - - virtual void SetClamp(bool bEnable) - { - uint32 flags = GetFlags(); - if (bEnable) - { - flags |= FT_STATE_CLAMP; - } - else - { - flags &= ~FT_STATE_CLAMP; - } - SetFlags(flags); - } - - AZ::Data::Instance m_instance; // This is only set for textures loaded from an asset - AZ::RHI::Ptr m_image; // This is only set for textures created dynamically (e.g. font images) - AZ::RHI::Ptr m_imageView; -}; - -////////////////////////////////////////////////////////////////////// -class CAtomShimRenderer - : public CRenderer - , public AZ::Module // This is a base class so that StaticNames in the NameDictionary work in this DLL - , Camera::ActiveCameraRequestBus::Handler -{ -public: - - ////--------------------------------------------------------------------------------------------------------------------- - virtual SRenderPipeline* GetRenderPipeline() override { return nullptr; } - virtual SRenderThread* GetRenderThread() override { return nullptr; } - virtual void FX_SetState(int st, int AlphaRef = -1, int RestoreState = 0) override; - void SetCull([[maybe_unused]] ECull eCull, [[maybe_unused]] bool bSkipMirrorCull = false) override {} - virtual SDepthTexture* GetDepthBufferOrig() override { return nullptr; } - virtual uint32 GetBackBufferWidth() override { return 0; } - virtual uint32 GetBackBufferHeight() override { return 0; }; - virtual const SRenderTileInfo* GetRenderTileInfo() const override { return nullptr; } - - virtual void FX_CommitStates([[maybe_unused]] const SShaderTechnique* pTech, [[maybe_unused]] const SShaderPass* pPass, [[maybe_unused]] bool bUseMaterialState) override {} - virtual void FX_Commit([[maybe_unused]] bool bAllowDIP = false) override {} - virtual long FX_SetVertexDeclaration([[maybe_unused]] int StreamMask, [[maybe_unused]] const AZ::Vertex::Format& vertexFormat) override { return 0; } - virtual void FX_DrawIndexedPrimitive([[maybe_unused]] const eRenderPrimitiveType eType, [[maybe_unused]] const int nVBOffset, [[maybe_unused]] const int nMinVertexIndex, [[maybe_unused]] const int nVerticesCount, [[maybe_unused]] const int nStartIndex, [[maybe_unused]] const int nNumIndices, [[maybe_unused]] bool bInstanced = false) override {} - virtual SDepthTexture* FX_GetDepthSurface([[maybe_unused]] int nWidth, [[maybe_unused]] int nHeight, [[maybe_unused]] bool bAA, [[maybe_unused]] bool shaderResourceView = false) override { return nullptr; } - virtual long FX_SetIStream([[maybe_unused]] const void* pB, [[maybe_unused]] uint32 nOffs, [[maybe_unused]] RenderIndexType idxType) override { return -1; } - virtual long FX_SetVStream([[maybe_unused]] int nID, [[maybe_unused]] const void* pB, [[maybe_unused]] uint32 nOffs, [[maybe_unused]] uint32 nStride, [[maybe_unused]] uint32 nFreq = 1) override { return -1; } - virtual void FX_DrawPrimitive([[maybe_unused]] eRenderPrimitiveType eType, [[maybe_unused]] int nStartVertex, [[maybe_unused]] int nVerticesCount, [[maybe_unused]] int nInstanceVertices = 0) {} - virtual void DrawQuad3D([[maybe_unused]] const Vec3& v0, [[maybe_unused]] const Vec3& v1, [[maybe_unused]] const Vec3& v2, [[maybe_unused]] const Vec3& v3, [[maybe_unused]] const ColorF& color, [[maybe_unused]] float ftx0, [[maybe_unused]] float fty0, [[maybe_unused]] float ftx1, [[maybe_unused]] float fty1) override {} - virtual void DrawQuad([[maybe_unused]] float x0, [[maybe_unused]] float y0, [[maybe_unused]] float x1, [[maybe_unused]] float y1, [[maybe_unused]] const ColorF& color, [[maybe_unused]] float z = 1.0f, [[maybe_unused]] float s0 = 0.0f, [[maybe_unused]] float t0 = 0.0f, [[maybe_unused]] float s1 = 1.0f, [[maybe_unused]] float t1 = 1.0f) override {}; - virtual void FX_ClearTarget(ITexture* pTex) override; - virtual void FX_ClearTarget(SDepthTexture* pTex) override; - - virtual bool FX_SetRenderTarget(int nTarget, void* pTargetSurf, SDepthTexture* pDepthTarget, uint32 nTileCount = 1) override; - virtual bool FX_PushRenderTarget(int nTarget, void* pTargetSurf, SDepthTexture* pDepthTarget, uint32 nTileCount = 1) override; - virtual bool FX_SetRenderTarget(int nTarget, CTexture* pTarget, SDepthTexture* pDepthTarget, bool bPush = false, int nCMSide = -1, bool bScreenVP = false, uint32 nTileCount = 1) override; - virtual bool FX_PushRenderTarget(int nTarget, CTexture* pTarget, SDepthTexture* pDepthTarget, int nCMSide = -1, bool bScreenVP = false, uint32 nTileCount = 1) override; - virtual bool FX_RestoreRenderTarget(int nTarget) override; - virtual bool FX_PopRenderTarget(int nTarget) override; - virtual void FX_SetActiveRenderTargets([[maybe_unused]] bool bAllowDIP = false) override {} - virtual void EF_Scissor([[maybe_unused]] bool bEnable, [[maybe_unused]] int sX, [[maybe_unused]] int sY, [[maybe_unused]] int sWdt, [[maybe_unused]] int sHgt) override {}; - virtual void FX_ResetPipe() override {}; - - ////--------------------------------------------------------------------------------------------------------------------- - - CAtomShimRenderer(); - virtual ~CAtomShimRenderer(); - - 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); - virtual WIN_HWND GetHWND(); - virtual bool SetWindowIcon(const char* path); - - virtual ERenderType GetRenderType() const override; - - virtual const char* GetRenderDescription() const override; - - ///////////////////////////////////////////////////////////////////////////////// - // Render-context management - ///////////////////////////////////////////////////////////////////////////////// - virtual bool SetCurrentContext(WIN_HWND hWnd); - virtual bool CreateContext(WIN_HWND hWnd, bool bAllowMSAA, int SSX, int SSY); - virtual bool DeleteContext(WIN_HWND hWnd); - virtual void MakeMainContextActive(); - virtual WIN_HWND GetCurrentContextHWND() { return m_currContext ? m_currContext->m_hWnd : m_hWnd; } - virtual bool IsCurrentContextMainVP() { return m_currContext ? m_currContext->m_isMainViewport : true; } - - virtual int GetCurrentContextViewportWidth() const { return -1; } - virtual int GetCurrentContextViewportHeight() const { return -1; } - ///////////////////////////////////////////////////////////////////////////////// - - virtual int CreateRenderTarget(const char* name, int nWidth, int nHeight, const ColorF& cClear, ETEX_Format eTF = eTF_R8G8B8A8); - virtual bool ResizeRenderTarget(int nHandle, int nWidth, int nHeight); - virtual bool DestroyRenderTarget(int nHandle); - virtual bool SetRenderTarget(int nHandle, SDepthTexture* pDepthSurf = nullptr); - virtual SDepthTexture* CreateDepthSurface(int nWidth, int nHeight, bool shaderResourceView = false); - virtual void DestroyDepthSurface(SDepthTexture* pDepthSurf); - - virtual int GetOcclusionBuffer(uint16* pOutOcclBuffer, Matrix44* pmCamBuffe); - virtual void WaitForParticleBuffer(threadID nThreadId); - - virtual void GetVideoMemoryUsageStats([[maybe_unused]] size_t& vidMemUsedThisFrame, [[maybe_unused]] size_t& vidMemUsedRecently, [[maybe_unused]] bool bGetPoolsSizes = false) {} - - virtual void SetRenderTile([[maybe_unused]] f32 nTilesPosX, [[maybe_unused]] f32 nTilesPosY, [[maybe_unused]] f32 nTilesGridSizeX, [[maybe_unused]] f32 nTilesGridSizeY) {} - - virtual void EF_InvokeShadowMapRenderJobs([[maybe_unused]] int nFlags){} - //! Fills array of all supported video formats (except low resolution formats) - //! Returns number of formats, also when called with NULL - virtual int EnumDisplayFormats(SDispFormat* Formats); - - //! Return all supported by video card video AA formats - virtual int EnumAAFormats([[maybe_unused]] SAAFormat* Formats) { return 0; } - - //! Changes resolution of the window/device (doen't require to reload the level - virtual bool ChangeResolution(int nNewWidth, int nNewHeight, int nNewColDepth, int nNewRefreshHZ, bool bFullScreen, bool bForce); - - virtual Vec2 SetViewportDownscale([[maybe_unused]] float xscale, [[maybe_unused]] float yscale) { return Vec2(0, 0); } - virtual void SetCurDownscaleFactor([[maybe_unused]] Vec2 sf) {}; - - virtual EScreenAspectRatio GetScreenAspect([[maybe_unused]] int nWidth, [[maybe_unused]] int nHeight) { return eAspect_4_3; } - - virtual void SwitchToNativeResolutionBackbuffer() {} - - virtual void ShutDown(bool bReInit = false); - virtual void ShutDownFast(); - - virtual void BeginFrame(); - virtual void RenderDebug(bool bRernderStats = true); - virtual void EndFrame(); - virtual void LimitFramerate([[maybe_unused]] const int maxFPS, [[maybe_unused]] const bool bUseSleep) {} - - virtual void TryFlush(); - - virtual void Reset (void) {}; - virtual void RT_ReleaseCB(void*){} - - virtual void InitSystemResources(int nFlags); - virtual void ForceGC() {} - virtual void FlushPendingTextureTasks() {} - - virtual void SetTexture(int tnum); - virtual void SetTexture(int tnum, int nUnit); - virtual void SetState(int State, int AlphaRef); - - virtual void DrawStringU(IFFont_RenderProxy* pFont, float x, float y, float z, const char* pStr, bool asciiMultiLine, const STextDrawContext& ctx) const; - virtual void DrawDynVB(SVF_P3F_C4B_T2F* pBuf, uint16* pInds, int nVerts, int nInds, PublicRenderPrimitiveType nPrimType); - virtual void DrawDynUiPrimitiveList(DynUiPrimitiveList& primitives, int totalNumVertices, int totalNumIndices); - - virtual void DrawBuffer(CVertexBuffer* pVBuf, CIndexBuffer* pIBuf, int nNumIndices, int nOffsIndex, const PublicRenderPrimitiveType nPrmode, int nVertStart = 0, int nVertStop = 0); - - virtual void CheckError(const char* comment); - - virtual void DrawLine([[maybe_unused]] const Vec3& vPos1, [[maybe_unused]] const Vec3& vPos2) {}; - virtual void Graph([[maybe_unused]] byte* g, [[maybe_unused]] int x, [[maybe_unused]] int y, [[maybe_unused]] int wdt, [[maybe_unused]] int hgt, [[maybe_unused]] int nC, [[maybe_unused]] int type, [[maybe_unused]] const char* text, [[maybe_unused]] ColorF& color, [[maybe_unused]] float fScale) {}; - - virtual void SetCamera(const CCamera& cam); - virtual void SetViewport(int x, int y, int width, int height, int id = 0); - virtual void SetScissor(int x = 0, int y = 0, int width = 0, int height = 0); - virtual void GetViewport(int* x, int* y, int* width, int* height) const; - - virtual void SetCullMode (int mode = R_CULL_BACK); - virtual bool EnableFog (bool enable); - virtual void SetFogColor(const ColorF& color); - virtual void EnableVSync(bool enable); - - virtual void DrawPrimitivesInternal(CVertexBuffer* src, int vert_num, const eRenderPrimitiveType prim_type); - - virtual void PushMatrix(); - virtual void RotateMatrix(float a, float x, float y, float z); - virtual void RotateMatrix(const Vec3& angels); - virtual void TranslateMatrix(float x, float y, float z); - virtual void ScaleMatrix(float x, float y, float z); - virtual void TranslateMatrix(const Vec3& pos); - virtual void MultMatrix(const float* mat); - virtual void LoadMatrix(const Matrix34* src = 0); - virtual void PopMatrix(); - - virtual void EnableTMU(bool enable); - virtual void SelectTMU(int tnum); - - virtual bool ChangeDisplay(unsigned int width, unsigned int height, unsigned int cbpp); - 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); - - virtual bool SaveTga([[maybe_unused]] unsigned char* sourcedata, [[maybe_unused]] int sourceformat, [[maybe_unused]] int w, [[maybe_unused]] int h, [[maybe_unused]] const char* filename, [[maybe_unused]] bool flip) const { return false; } - - //download an image to video memory. 0 in case of failure - virtual void CreateResourceAsync([[maybe_unused]] SResourceAsync* Resource) {}; - virtual void ReleaseResourceAsync([[maybe_unused]] SResourceAsync* Resource) {}; - void ReleaseResourceAsync(AZStd::unique_ptr Resource) override {}; - virtual unsigned int DownLoadToVideoMemory([[maybe_unused]] const byte* data, [[maybe_unused]] int w, [[maybe_unused]] int h, [[maybe_unused]] int d, [[maybe_unused]] ETEX_Format eTFSrc, [[maybe_unused]] ETEX_Format eTFDst, [[maybe_unused]] int nummipmap, [[maybe_unused]] ETEX_Type eTT, [[maybe_unused]] bool repeat = true, [[maybe_unused]] int filter = FILTER_BILINEAR, [[maybe_unused]] int Id = 0, [[maybe_unused]] const char* szCacheName = NULL, [[maybe_unused]] int flags = 0, [[maybe_unused]] EEndian eEndian = eLittleEndian, [[maybe_unused]] RectI* pRegion = NULL, [[maybe_unused]] bool bAsynDevTexCreation = false) { return 0; } - virtual unsigned int DownLoadToVideoMemory([[maybe_unused]] const byte* data, [[maybe_unused]] int w, [[maybe_unused]] int h, [[maybe_unused]] ETEX_Format eTFSrc, [[maybe_unused]] ETEX_Format eTFDst, [[maybe_unused]] int nummipmap, [[maybe_unused]] bool repeat = true, [[maybe_unused]] int filter = FILTER_BILINEAR, [[maybe_unused]] int Id = 0, [[maybe_unused]] const char* szCacheName = NULL, [[maybe_unused]] int flags = 0, [[maybe_unused]] EEndian eEndian = eLittleEndian, [[maybe_unused]] RectI* pRegion = NULL, [[maybe_unused]] bool bAsynDevTexCreation = false) { return 0; } - virtual unsigned int DownLoadToVideoMemoryCube([[maybe_unused]] const byte* data, [[maybe_unused]] int w, [[maybe_unused]] int h, [[maybe_unused]] ETEX_Format eTFSrc, [[maybe_unused]] ETEX_Format eTFDst, [[maybe_unused]] int nummipmap, [[maybe_unused]] bool repeat = true, [[maybe_unused]] int filter = FILTER_BILINEAR, [[maybe_unused]] int Id = 0, [[maybe_unused]] const char* szCacheName = NULL, [[maybe_unused]] int flags = 0, [[maybe_unused]] EEndian eEndian = eLittleEndian, [[maybe_unused]] RectI* pRegion = NULL, [[maybe_unused]] bool bAsynDevTexCreation = false) { return 0; } - virtual unsigned int DownLoadToVideoMemory3D([[maybe_unused]] const byte* data, [[maybe_unused]] int w, [[maybe_unused]] int h, [[maybe_unused]] int d, [[maybe_unused]] ETEX_Format eTFSrc, [[maybe_unused]] ETEX_Format eTFDst, [[maybe_unused]] int nummipmap, [[maybe_unused]] bool repeat = true, [[maybe_unused]] int filter = FILTER_BILINEAR, [[maybe_unused]] int Id = 0, [[maybe_unused]] const char* szCacheName = NULL, [[maybe_unused]] int flags = 0, [[maybe_unused]] EEndian eEndian = eLittleEndian, [[maybe_unused]] RectI* pRegion = NULL, [[maybe_unused]] bool bAsynDevTexCreation = false) { return 0; } - virtual void UpdateTextureInVideoMemory([[maybe_unused]] uint32 tnum, [[maybe_unused]] const byte* newdata, [[maybe_unused]] int posx, [[maybe_unused]] int posy, [[maybe_unused]] int w, [[maybe_unused]] int h, [[maybe_unused]] ETEX_Format eTFSrc = eTF_R8G8B8A8, [[maybe_unused]] int posz = 0, [[maybe_unused]] int sizez = 1){} - - virtual bool SetGammaDelta(float fGamma); - virtual void RestoreGamma(void) {}; - - virtual void RemoveTexture([[maybe_unused]] unsigned int TextureId) {} - virtual void DeleteFont([[maybe_unused]] IFFont* font) {} - - 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); - 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); - virtual void Draw2dImageList(); - virtual void Draw2dImageStretchMode([[maybe_unused]] bool stretch) {}; - 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); - virtual void DrawImageWithUV(float xpos, float ypos, float z, float w, float h, int texture_id, float s[4], float t[4], float r, float g, float b, float a, bool filtered = true); - - virtual void PushWireframeMode(int mode); - virtual void PopWireframeMode(); - virtual void FX_PushWireframeMode(int mode); - virtual void FX_PopWireframeMode(); - virtual void FX_SetWireframeMode(int mode); - - virtual void FX_PreRender([[maybe_unused]] int Stage) override {} - virtual void FX_PostRender() override {} - - virtual void ResetToDefault(); - virtual void SetDefaultRenderStates() {} - - virtual int GenerateAlphaGlowTexture(float k); - - virtual void ApplyViewParameters(const CameraViewParameters&) override; - virtual void SetMaterialColor(float r, float g, float b, float a); - - virtual void GetMemoryUsage(ICrySizer* Sizer); - - // Project/UnProject. Returns true if successful. - virtual bool ProjectToScreen(float ptx, float pty, float ptz, - float* sx, float* sy, float* sz); - 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]); - virtual int UnProjectFromScreen(float sx, float sy, float sz, - float* px, float* py, float* pz); - - // Shadow Mapping - virtual bool PrepareDepthMap(ShadowMapFrustum* SMSource, int nFrustumLOD = 0, bool bClearPool = false); - virtual void DrawAllShadowsOnTheScreen(); - virtual void OnEntityDeleted([[maybe_unused]] IRenderNode* pRenderNode) {}; - - virtual void FX_SetClipPlane (bool bEnable, float* pPlane, bool bRefract); - - virtual void SetColorOp(byte eCo, byte eAo, byte eCa, byte eAa); - virtual void EF_SetColorOp([[maybe_unused]] byte eCo, [[maybe_unused]] byte eAo, [[maybe_unused]] byte eCa, [[maybe_unused]] byte eAa) {}; - - virtual void SetSrgbWrite([[maybe_unused]] bool srgbWrite) {}; - virtual void EF_SetSrgbWrite([[maybe_unused]] bool sRGBWrite) {}; - - //for editor - virtual void GetModelViewMatrix(float* mat); - virtual void GetProjectionMatrix(float* mat); - - //for texture - virtual ITexture* EF_LoadTexture(const char* nameTex, uint32 flags = 0); - virtual ITexture* EF_LoadDefaultTexture(const char* nameTex); - - virtual void DrawQuad(const Vec3& right, const Vec3& up, const Vec3& origin, int nFlipMode = 0); - virtual void DrawQuad(float dy, float dx, float dz, float x, float y, float z); - // NOTE: deprecated - virtual void ClearTargetsImmediately(uint32 nFlags); - virtual void ClearTargetsImmediately(uint32 nFlags, const ColorF& Colors, float fDepth); - virtual void ClearTargetsImmediately(uint32 nFlags, const ColorF& Colors); - virtual void ClearTargetsImmediately(uint32 nFlags, float fDepth); - - virtual void ClearTargetsLater(uint32 nFlags); - virtual void ClearTargetsLater(uint32 nFlags, const ColorF& Colors, float fDepth); - virtual void ClearTargetsLater(uint32 nFlags, const ColorF& Colors); - virtual void ClearTargetsLater(uint32 nFlags, float fDepth); - - virtual void ReadFrameBuffer(unsigned char* pRGB, int nImageX, int nSizeX, int nSizeY, ERB_Type eRBType, bool bRGBA, int nScaledX = -1, int nScaledY = -1); - virtual void ReadFrameBufferFast(uint32* pDstARGBA8, int dstWidth, int dstHeight, bool BGRA = true); - - virtual bool CaptureFrameBufferFast(unsigned char* pDstRGBA8, int destinationWidth, int destinationHeight); - virtual bool CopyFrameBufferFast(unsigned char* pDstRGBA8, int destinationWidth, int destinationHeight); - virtual bool RegisterCaptureFrame(ICaptureFrameListener* pCapture); - virtual bool UnRegisterCaptureFrame(ICaptureFrameListener* pCapture); - virtual bool InitCaptureFrameBufferFast(uint32 bufferWidth, uint32 bufferHeight); - virtual void CloseCaptureFrameBufferFast(void); - virtual void CaptureFrameBufferCallBack(void); - - - virtual void ReleaseHWShaders() {} - virtual void PrintResourcesLeaks() {} - - //misc - virtual bool ScreenShot(const char* filename = NULL, int width = 0); - - virtual void Set2DMode(uint32 orthoWidth, uint32 orthoHeight, TransformationMatrices& backupMatrices, float znear = -1e10f, float zfar = 1e10f); - virtual void Unset2DMode(const TransformationMatrices& restoringMatrices); - virtual void Set2DModeNonZeroTopLeft(float orthoLeft, float orthoTop, float orthoWidth, float orthoHeight, TransformationMatrices& backupMatrices, float znear = -1e10f, float zfar = 1e10f); - - virtual int ScreenToTexture(int nTexID); - - virtual void DrawPoints([[maybe_unused]] Vec3 v[], [[maybe_unused]] int nump, [[maybe_unused]] ColorF& col, [[maybe_unused]] int flags) {}; - virtual void DrawLines([[maybe_unused]] Vec3 v[], [[maybe_unused]] int nump, [[maybe_unused]] ColorF& col, [[maybe_unused]] int flags, [[maybe_unused]] float fGround) {}; - - virtual void RefreshSystemShaders() {} - - // Shaders/Shaders support - // RE - RenderElement - - virtual void EF_Release(int nFlags); - virtual void FX_PipelineShutdown(bool bFastShutdown = false); - - //========================================================== - // external interface for shaders - //========================================================== - - virtual bool EF_SetLightHole(Vec3 vPos, Vec3 vNormal, int idTex, float fScale = 1.0f, bool bAdditive = true); - - // Draw all shaded REs in the list - virtual void EF_EndEf3D (int nFlags, int nPrecacheUpdateId, int nNearPrecacheUpdateId, const SRenderingPassInfo& passInfo); - - // 2d interface for shaders - virtual void EF_EndEf2D(bool bSort); - virtual bool EF_PrecacheResource(SShaderItem* pSI, float fMipFactor, float fTimeToReady, int Flags, int nUpdateId, int nCounter); - virtual bool EF_PrecacheResource(ITexture* pTP, float fDist, float fTimeToReady, int Flags, int nUpdateId, int nCounter); - virtual void PrecacheResources(); - virtual void PostLevelLoading() {} - virtual void PostLevelUnload() {} - - 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); - - void EF_Init(); - - virtual IDynTexture* MakeDynTextureFromShadowBuffer(int nSize, IDynTexture* pDynTexture); - virtual void MakeSprite(IDynTexture*& rTexturePtr, float _fSpriteDistance, int nTexSize, float angle, float angle2, IStatObj* pStatObj, const float fBrightnessMultiplier, SRendParams& rParms); - virtual uint32 RenderOccludersIntoBuffer([[maybe_unused]] const CCamera& viewCam, [[maybe_unused]] int nTexSize, [[maybe_unused]] PodArray& lstOccluders, [[maybe_unused]] float* pBuffer) { return 0; } - - virtual IRenderAuxGeom* GetIRenderAuxGeom([[maybe_unused]] void* jobID = 0) - { - return m_pAtomShimRenderAuxGeom; - } - - virtual IColorGradingController* GetIColorGradingController(); - virtual IStereoRenderer* GetIStereoRenderer(); - - virtual ITexture* Create2DTexture(const char* name, int width, int height, int numMips, int flags, unsigned char* data, ETEX_Format format); - - ////////////////////////////////////////////////////////////////////// - // All font functions are not implemented since the font is rendered by AtomFont - int FontCreateTexture( - [[maybe_unused]] int Width, [[maybe_unused]] int Height, [[maybe_unused]] byte* pData, - [[maybe_unused]] ETEX_Format eTF = eTF_R8G8B8A8, [[maybe_unused]] bool genMips = false, - [[maybe_unused]] const char* textureName = nullptr) override - { - return -1; - } - bool FontUpdateTexture( - [[maybe_unused]] int nTexId, [[maybe_unused]] int X, [[maybe_unused]] int Y, [[maybe_unused]] int USize, [[maybe_unused]] int VSize, - [[maybe_unused]] byte* pData) override - { - return true; - } - void FontSetTexture([[maybe_unused]] int nTexId, [[maybe_unused]] int nFilterMode) override { } - void FontSetRenderingState([[maybe_unused]] bool overrideViewProjMatrices, [[maybe_unused]] TransformationMatrices& backupMatrices) override { } - void FontSetBlending([[maybe_unused]] int src, [[maybe_unused]] int dst, [[maybe_unused]] int baseState) override { } - void FontRestoreRenderingState([[maybe_unused]] bool overrideViewProjMatrices, [[maybe_unused]] const TransformationMatrices& restoringMatrices) override { } - - virtual void GetLogVBuffers(void) {} - - virtual void RT_PresentFast() {} - - virtual void RT_ForceSwapBuffers() {} - virtual void RT_SwitchToNativeResolutionBackbuffer([[maybe_unused]] bool resolveBackBuffer) {} - - virtual void RT_BeginFrame() {} - virtual void RT_EndFrame() {} - virtual void RT_Init() {} - virtual void RT_ShutDown([[maybe_unused]] uint32 nFlags) {} - virtual bool RT_CreateDevice() { return true; } - virtual void RT_Reset() {} - virtual void RT_SetCull([[maybe_unused]] int nMode) {} - virtual void RT_SetScissor([[maybe_unused]] bool bEnable, [[maybe_unused]] int x, [[maybe_unused]] int y, [[maybe_unused]] int width, [[maybe_unused]] int height){} - virtual void RT_RenderScene([[maybe_unused]] int nFlags, [[maybe_unused]] SThreadInfo& TI, [[maybe_unused]] RenderFunc pRenderFunc) {} - virtual void RT_PrepareStereo([[maybe_unused]] int mode, [[maybe_unused]] int output) {} - virtual void RT_CopyToStereoTex([[maybe_unused]] int channel) {} - virtual void RT_UpdateTrackingStates() {} - virtual void RT_DisplayStereo() {} - virtual void RT_SetCameraInfo() {} - virtual void RT_SetStereoCamera() {} - virtual void RT_ReadFrameBuffer([[maybe_unused]] unsigned char* pRGB, [[maybe_unused]] int nImageX, [[maybe_unused]] int nSizeX, [[maybe_unused]] int nSizeY, [[maybe_unused]] ERB_Type eRBType, [[maybe_unused]] bool bRGBA, [[maybe_unused]] int nScaledX, [[maybe_unused]] int nScaledY) {} - virtual void RT_RenderScene([[maybe_unused]] int nFlags, [[maybe_unused]] SThreadInfo& TI, [[maybe_unused]] int nR, [[maybe_unused]] RenderFunc pRenderFunc) {}; - virtual void RT_CreateResource([[maybe_unused]] SResourceAsync* Res) {}; - virtual void RT_ReleaseResource([[maybe_unused]] SResourceAsync* Res) {}; - virtual void RT_ReleaseRenderResources() {}; - virtual void RT_UnbindResources() {}; - virtual void RT_UnbindTMUs() {}; - virtual void RT_PrecacheDefaultShaders() {}; - virtual void RT_CreateRenderResources() {}; - virtual void RT_ClearTarget([[maybe_unused]] ITexture* pTex, [[maybe_unused]] const ColorF& color) {}; - virtual void RT_RenderDebug([[maybe_unused]] bool bRenderStats = true) {}; - - virtual HRESULT RT_CreateVertexBuffer([[maybe_unused]] UINT Length, [[maybe_unused]] DWORD Usage, [[maybe_unused]] DWORD FVF, [[maybe_unused]] UINT Pool, [[maybe_unused]] void** ppVertexBuffer, [[maybe_unused]] HANDLE* pSharedHandle) { return S_OK; } - virtual HRESULT RT_CreateIndexBuffer([[maybe_unused]] UINT Length, [[maybe_unused]] DWORD Usage, [[maybe_unused]] DWORD Format, [[maybe_unused]] UINT Pool, [[maybe_unused]] void** ppVertexBuffer, [[maybe_unused]] HANDLE* pSharedHandle) { return S_OK; }; - virtual HRESULT RT_CreateVertexShader([[maybe_unused]] DWORD* pBuf, [[maybe_unused]] void** pShader, [[maybe_unused]] void* pInst) { return S_OK; }; - virtual HRESULT RT_CreatePixelShader([[maybe_unused]] DWORD* pBuf, [[maybe_unused]] void** pShader) { return S_OK; }; - virtual void RT_ReleaseVBStream([[maybe_unused]] void* pVB, [[maybe_unused]] int nStream) {}; - virtual void RT_DrawDynVB([[maybe_unused]] int Pool, [[maybe_unused]] uint32 nVerts) {} - virtual void RT_DrawDynVB([[maybe_unused]] SVF_P3F_C4B_T2F* pBuf, [[maybe_unused]] uint16* pInds, [[maybe_unused]] uint32 nVerts, [[maybe_unused]] uint32 nInds, [[maybe_unused]] const PublicRenderPrimitiveType nPrimType) {} - virtual void RT_DrawDynVBUI([[maybe_unused]] SVF_P2F_C4B_T2F_F4B* pBuf, [[maybe_unused]] uint16* pInds, [[maybe_unused]] uint32 nVerts, [[maybe_unused]] uint32 nInds, [[maybe_unused]] const PublicRenderPrimitiveType nPrimType) {} - virtual void RT_DrawStringU([[maybe_unused]] IFFont_RenderProxy* pFont, [[maybe_unused]] float x, [[maybe_unused]] float y, [[maybe_unused]] float z, [[maybe_unused]] const char* pStr, [[maybe_unused]] bool asciiMultiLine, [[maybe_unused]] const STextDrawContext& ctx) const {} - virtual void RT_DrawLines([[maybe_unused]] Vec3 v[], [[maybe_unused]] int nump, [[maybe_unused]] ColorF& col, [[maybe_unused]] int flags, [[maybe_unused]] float fGround) {} - virtual void RT_Draw2dImage([[maybe_unused]] float xpos, [[maybe_unused]] float ypos, [[maybe_unused]] float w, [[maybe_unused]] float h, [[maybe_unused]] CTexture* pTexture, [[maybe_unused]] float s0, [[maybe_unused]] float t0, [[maybe_unused]] float s1, [[maybe_unused]] float t1, [[maybe_unused]] float angle, [[maybe_unused]] DWORD col, [[maybe_unused]] float z) {} - virtual void RT_Push2dImage([[maybe_unused]] float xpos, [[maybe_unused]] float ypos, [[maybe_unused]] float w, [[maybe_unused]] float h, [[maybe_unused]] CTexture* pTexture, [[maybe_unused]] float s0, [[maybe_unused]] float t0, [[maybe_unused]] float s1, [[maybe_unused]] float t1, [[maybe_unused]] float angle, [[maybe_unused]] DWORD col, [[maybe_unused]] float z, [[maybe_unused]] float stereoDepth) {} - virtual void RT_Draw2dImageList() {} - virtual void RT_Draw2dImageStretchMode([[maybe_unused]] bool bStretch) {} - virtual void RT_DrawImageWithUV([[maybe_unused]] float xpos, [[maybe_unused]] float ypos, [[maybe_unused]] float z, [[maybe_unused]] float w, [[maybe_unused]] float h, [[maybe_unused]] int texture_id, [[maybe_unused]] float* s, [[maybe_unused]] float* t, [[maybe_unused]] DWORD col, [[maybe_unused]] bool filtered = true) {} - virtual void EF_ClearTargetsImmediately([[maybe_unused]] uint32 nFlags) {} - virtual void EF_ClearTargetsImmediately([[maybe_unused]] uint32 nFlags, [[maybe_unused]] const ColorF& Colors, [[maybe_unused]] float fDepth, [[maybe_unused]] uint8 nStencil) {} - virtual void EF_ClearTargetsImmediately([[maybe_unused]] uint32 nFlags, [[maybe_unused]] const ColorF& Colors) {} - virtual void EF_ClearTargetsImmediately([[maybe_unused]] uint32 nFlags, [[maybe_unused]] float fDepth, [[maybe_unused]] uint8 nStencil) {} - - virtual void EF_ClearTargetsLater([[maybe_unused]] uint32 nFlags) {} - virtual void EF_ClearTargetsLater([[maybe_unused]] uint32 nFlags, [[maybe_unused]] const ColorF& Colors, [[maybe_unused]] float fDepth, [[maybe_unused]] uint8 nStencil) {} - virtual void EF_ClearTargetsLater([[maybe_unused]] uint32 nFlags, [[maybe_unused]] const ColorF& Colors) {} - virtual void EF_ClearTargetsLater([[maybe_unused]] uint32 nFlags, [[maybe_unused]] float fDepth, [[maybe_unused]] uint8 nStencil) {} - - virtual void RT_PushRenderTarget([[maybe_unused]] int nTarget, [[maybe_unused]] CTexture* pTex, [[maybe_unused]] SDepthTexture* pDS, [[maybe_unused]] int nS) {}; - virtual void RT_PopRenderTarget([[maybe_unused]] int nTarget) {}; - virtual void RT_SetViewport([[maybe_unused]] int x, [[maybe_unused]] int y, [[maybe_unused]] int width, [[maybe_unused]] int height, [[maybe_unused]] int id) {} - - virtual void RT_SetRendererCVar([[maybe_unused]] ICVar* pCVar, [[maybe_unused]] const char* pArgText, [[maybe_unused]] const bool bSilentMode = false) {}; - virtual void SetRendererCVar([[maybe_unused]] ICVar* pCVar, [[maybe_unused]] const char* pArgText, [[maybe_unused]] bool bSilentMode = false) {}; - - virtual void SetMatrices(float* pProjMat, float* pViewMat); - - virtual void PushProfileMarker([[maybe_unused]] const char* label) {} - virtual void PopProfileMarker([[maybe_unused]] const char* label) {} - - virtual void RT_InsertGpuCallback([[maybe_unused]] uint32 context, [[maybe_unused]] GpuCallbackFunc callback) {} - virtual void EnablePipelineProfiler([[maybe_unused]] bool bEnable) {} - - virtual IOpticsElementBase* CreateOptics([[maybe_unused]] EFlareType type) const { return NULL; } - - virtual bool BakeMesh([[maybe_unused]] const SMeshBakingInputParams* pInputParams, [[maybe_unused]] SMeshBakingOutput* pReturnValues) { return false; } - virtual PerInstanceConstantBufferPool* GetPerInstanceConstantBufferPoolPointer() override { return nullptr; } - - IDynTexture* CreateDynTexture2(uint32 nWidth, uint32 nHeight, uint32 nTexFlags, const char* szSource, ETexPool eTexPool) override; - - virtual void BeginProfilerSection([[maybe_unused]] const char* name, [[maybe_unused]] uint32 eProfileLabelFlags = 0) override {} - virtual void EndProfilerSection([[maybe_unused]] const char* name) override {} - virtual void AddProfilerLabel([[maybe_unused]] const char* name) override {} - -#ifdef SUPPORT_HW_MOUSE_CURSOR - virtual IHWMouseCursor* GetIHWMouseCursor() { return NULL; } -#endif - - virtual void StartLoadtimePlayback([[maybe_unused]] ILoadtimeCallback* pCallback) {} - virtual void StopLoadtimePlayback() {} - - // used to track current textures - void SetTextureForUnit(int unit, int textureId); - - void RT_DrawVideoRenderer([[maybe_unused]] AZ::VideoRenderer::IVideoRenderer* pVideoRenderer, [[maybe_unused]] const AZ::VideoRenderer::DrawArguments& drawArguments) override {} - -private: - static constexpr char LogName[] = "CAtomShimRenderer"; - - //! Camera::ActiveCameraSystemRequestBus::Handler overrides... - const AZ::Transform& GetActiveCameraTransform() override; - const Camera::Configuration& GetActiveCameraConfiguration() override; - - void CacheCameraTransform(const CCamera& camera); - void CacheCameraConfiguration(const CCamera& camamera); - - HWND m_hWnd = nullptr; // The main app window - - AZStd::string m_rendererDescription; - - CAtomShimRenderAuxGeom* m_pAtomShimRenderAuxGeom; - IColorGradingController* m_pAtomShimColorGradingController; - IStereoRenderer* m_pAtomShimStereoRenderer; - - AZ::RHI::Ptr m_dynamicDraw; - - AZ::RPI::ShaderVariantId m_shaderVariantWrap; - AZ::RPI::ShaderVariantId m_shaderVariantClamp; - - // cached input indices for dynamic draw's draw srg - AZ::RHI::ShaderInputNameIndex m_imageInputIndex = "m_texture"; - AZ::RHI::ShaderInputNameIndex m_viewProjInputIndex = "m_worldToProj"; - - AZStd::unordered_map m_viewContexts; - AtomShimViewContext* m_currContext = nullptr; - - int m_renderPipelineNameSuffix = 1; - - AtomShimTexture* m_currentTextureForUnit[32]; - bool m_clampFlagPerTextureUnit[32]; - - int m_currentFontTextureId = -1; - - bool m_isFinalInitializationDone = false; - bool m_isInFrame = false; // True when between calls to BeginFrame and EndFrame - - int m_isIn2dModeCounter = 0; - - AZ::Transform m_cameraTransform = AZ::Transform::CreateIdentity(); - Camera::Configuration m_cameraConfiguration; - AZStd::shared_ptr m_viewportContext; - - static AtomShimTexture* CastITextureToAtomShimTexture(ITexture* texture) - { - // If GetDevTexture returns a non-null value then this is not an AtomShim texture - if (!(texture && !texture->GetDevTexture())) - { - return nullptr; - } - - return static_cast(texture); - } -}; - -//============================================================================= - -extern CAtomShimRenderer* gcpAtomShim; - - - -#endif //NULL_RENDERER diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_Shaders.cpp b/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_Shaders.cpp deleted file mode 100644 index 9093c4b3d4..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_Shaders.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#include "CryRenderOther_precompiled.h" -#include "AtomShim_Renderer.h" -#include "I3DEngine.h" - -//============================================================================ - -bool CShader::FXSetTechnique([[maybe_unused]] const CCryNameTSCRC& szName) -{ - return true; -} - -bool CShader::FXSetPSFloat([[maybe_unused]] const CCryNameR& NameParam, [[maybe_unused]] const Vec4* fParams, [[maybe_unused]] int nParams) -{ - return true; -} - -bool CShader::FXSetPSFloat([[maybe_unused]] const char* NameParam, [[maybe_unused]] const Vec4* fParams, [[maybe_unused]] int nParams) -{ - return true; -} - -bool CShader::FXSetVSFloat([[maybe_unused]] const CCryNameR& NameParam, [[maybe_unused]] const Vec4* fParams, [[maybe_unused]] int nParams) -{ - return true; -} - -bool CShader::FXSetVSFloat([[maybe_unused]] const char* NameParam, [[maybe_unused]] const Vec4* fParams, [[maybe_unused]] int nParams) -{ - return true; -} - -bool CShader::FXSetGSFloat([[maybe_unused]] const CCryNameR& NameParam, [[maybe_unused]] const Vec4* fParams, [[maybe_unused]] int nParams) -{ - return true; -} - -bool CShader::FXSetGSFloat([[maybe_unused]] const char* NameParam, [[maybe_unused]] const Vec4* fParams, [[maybe_unused]] int nParams) -{ - return true; -} - -bool CShader::FXSetCSFloat([[maybe_unused]] const CCryNameR& NameParam, [[maybe_unused]] const Vec4* fParams, [[maybe_unused]] int nParams) -{ - return true; -} - -bool CShader::FXSetCSFloat([[maybe_unused]] const char* NameParam, [[maybe_unused]] const Vec4* fParams, [[maybe_unused]] int nParams) -{ - return true; -} -bool CShader::FXBegin([[maybe_unused]] uint32* uiPassCount, [[maybe_unused]] uint32 nFlags) -{ - return true; -} - -bool CShader::FXBeginPass([[maybe_unused]] uint32 uiPass) -{ - return true; -} - -bool CShader::FXEndPass() -{ - return true; -} - -bool CShader::FXEnd() -{ - return true; -} - -bool CShader::FXCommit([[maybe_unused]] const uint32 nFlags) -{ - return true; -} - -//=================================================================================== - -FXShaderCache CHWShader::m_ShaderCache; -FXShaderCacheNames CHWShader::m_ShaderCacheList; - -void CRenderer::RefreshSystemShaders() -{ -} - -SShaderCache::~SShaderCache() -{ - CHWShader::m_ShaderCache.erase(m_Name); - SAFE_DELETE(m_pRes[CACHE_USER]); - SAFE_DELETE(m_pRes[CACHE_READONLY]); -} - -SShaderCache* CHWShader::mfInitCache([[maybe_unused]] const char* name, [[maybe_unused]] CHWShader* pSH, [[maybe_unused]] bool bCheckValid, [[maybe_unused]] uint32 CRC32, [[maybe_unused]] bool bReadOnly, [[maybe_unused]] bool bAsync) -{ - return NULL; -} - -#if !defined(CONSOLE) -bool CHWShader::mfOptimiseCacheFile([[maybe_unused]] SShaderCache* pCache, [[maybe_unused]] bool bForce, [[maybe_unused]] SOptimiseStats* Stats) -{ - return true; -} -#endif - -bool CHWShader::PreactivateShaders() -{ - bool bRes = true; - return bRes; -} -void CHWShader::RT_PreactivateShaders() -{ -} - -const char* CHWShader::GetCurrentShaderCombinations([[maybe_unused]] bool bLevel) -{ - return ""; -} - -void CHWShader::mfFlushPendedShadersWait([[maybe_unused]] int nMaxAllowed) -{ -} - -void CShaderResources::Rebuild([[maybe_unused]] IShader* pSH, [[maybe_unused]] AzRHI::ConstantBufferUsage usage) -{ -} - -void CShaderResources::CloneConstants([[maybe_unused]] const IRenderShaderResources* pSrc) -{ -} - -void CShaderResources::ReleaseConstants() -{ -} - -void CShaderResources::UpdateConstants([[maybe_unused]] IShader* pSH) -{ -} - -void CShader::mfFlushPendedShaders() -{ -} - -void SShaderCache::Cleanup(void) -{ -} - -void CShaderResources::AdjustForSpec() -{ -} - diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_Shadows.cpp b/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_Shadows.cpp deleted file mode 100644 index ee6f80b51d..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_Shadows.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -// Description : Implementation of the shadow maps using NULL device specific implementation -// shadow map calculations - - -#include "CryRenderOther_precompiled.h" -#include "AtomShim_Renderer.h" -#include "../Common/Shadow_Renderer.h" - -#include "I3DEngine.h" - -IDynTexture* CAtomShimRenderer::MakeDynTextureFromShadowBuffer([[maybe_unused]] int nSize, [[maybe_unused]] IDynTexture* pDynTexture) -{ - return NULL; -} - -bool CAtomShimRenderer::PrepareDepthMap([[maybe_unused]] ShadowMapFrustum* SMSource, [[maybe_unused]] int nFrustumLOD, [[maybe_unused]] bool bClearPool) -{ - return true; -} - -void CAtomShimRenderer::DrawAllShadowsOnTheScreen() -{ -} diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_System.cpp b/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_System.cpp deleted file mode 100644 index 3098ed3c3e..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_System.cpp +++ /dev/null @@ -1,190 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -// Description : NULL device specific implementation and extensions handling. - - -#include "CryRenderOther_precompiled.h" -#include "AtomShim_Renderer.h" - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -bool CAtomShimRenderer::SetGammaDelta(const float fGamma) -{ - m_fDeltaGamma = fGamma; - return true; -} - -int CAtomShimRenderer::EnumDisplayFormats([[maybe_unused]] SDispFormat* Formats) -{ - return 0; -} - -bool CAtomShimRenderer::ChangeResolution([[maybe_unused]] int nNewWidth, [[maybe_unused]] int nNewHeight, [[maybe_unused]] int nNewColDepth, [[maybe_unused]] int nNewRefreshHZ, [[maybe_unused]] bool bFullScreen, [[maybe_unused]] bool bForce) -{ - return false; -} - -WIN_HWND CAtomShimRenderer::Init([[maybe_unused]] int x, [[maybe_unused]] int y, int width, int height, [[maybe_unused]] unsigned int cbpp, [[maybe_unused]] int zbpp, [[maybe_unused]] int sbits, [[maybe_unused]] bool fullscreen, [[maybe_unused]] bool isEditor, [[maybe_unused]] WIN_HINSTANCE hinst, WIN_HWND Glhwnd, [[maybe_unused]] bool bReInit, [[maybe_unused]] const SCustomRenderInitArgs* pCustomArgs, [[maybe_unused]] bool bShaderCacheGen) -{ - //======================================= - // Add init code here - //======================================= - - FX_SetWireframeMode(R_SOLID_MODE); - - m_width = width; - m_height = height; - m_backbufferWidth = width; - m_backbufferHeight = height; - m_nativeWidth = width; - m_nativeHeight = height; - m_Features |= RFT_HW_NVIDIA; - - m_hWnd = (HWND)Glhwnd; - - if (!g_shaderGeneralHeap) - { - g_shaderGeneralHeap = CryGetIMemoryManager()->CreateGeneralExpandingMemoryHeap(4 * 1024 * 1024, 0, "Shader General"); - } - - iLog->Log("Init Shaders\n"); - - gRenDev->m_cEF.mfInit(); - EF_Init(); - -#if NULL_SYSTEM_TRAIT_INIT_RETURNTHIS - return (WIN_HWND)this;//it just get checked against NULL anyway -#else - return (WIN_HWND)GetDesktopWindow(); -#endif -} - - -bool CAtomShimRenderer::SetCurrentContext(WIN_HWND hWnd) -{ - auto itr = m_viewContexts.find(hWnd); - if (itr == m_viewContexts.end()) - { - return false; - } - - m_currContext = itr->second; - return true; -} - -bool CAtomShimRenderer::CreateContext(WIN_HWND hWnd, bool /* bAllowMSAA */, int /* SSX */, int /* SSY */) -{ - if (m_viewContexts.find(hWnd) != m_viewContexts.end()) - { - return true; - } - - AZ::RPI::RenderPipelinePtr renderPipeline = AZ::RPI::RPISystemInterface::Get()->GetRenderPipelineForWindow(hWnd); - if (!renderPipeline) - { - return false; - } - - AtomShimViewContext* pContext = new AtomShimViewContext; - pContext->m_hWnd = (HWND)hWnd; - pContext->m_width = m_width; - pContext->m_height = m_height; - pContext->m_isMainViewport = !gEnv->IsEditor(); - - pContext->m_renderPipeline = renderPipeline; - pContext->m_view = renderPipeline->GetDefaultView(); - pContext->m_scene = renderPipeline->GetScene(); - - m_viewContexts[hWnd] = pContext; - m_currContext = pContext; - return true; -} - -bool CAtomShimRenderer::DeleteContext(WIN_HWND hWnd) -{ - // Attempt to find matching context with this window handle - auto contextToDeleteIter = m_viewContexts.find(hWnd); - - if (contextToDeleteIter == m_viewContexts.end()) - { - return false; - } - - AtomShimViewContext* contextToDelete = contextToDeleteIter->second; - - // remove this context from the map of contexts - m_viewContexts.erase(contextToDeleteIter); - - - // If we are deleting the current context then set current context to the first one still in list (if any are left) - if (m_currContext == contextToDelete) - { - if (m_viewContexts.empty()) - { - m_currContext = nullptr; - - m_width = 0; - m_height = 0; - } - else - { - m_currContext = m_viewContexts.begin()->second; - - m_width = m_currContext->m_width; - m_height = m_currContext->m_height; - } - } - - delete contextToDelete; - - return true; -} - -void CAtomShimRenderer::MakeMainContextActive() -{ - if (m_viewContexts.empty()) - { - return; - } - - m_currContext = m_viewContexts.begin()->second; -} - -void CAtomShimRenderer::ShutDown([[maybe_unused]] bool bReInit) -{ - iLog = nullptr; - FreeResources(FRR_ALL); - FX_PipelineShutdown(); -} - -void CAtomShimRenderer::ShutDownFast() -{ - FX_PipelineShutdown(); -} - diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_Textures.cpp b/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_Textures.cpp deleted file mode 100644 index 5bc6b6f872..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_Textures.cpp +++ /dev/null @@ -1,363 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -// Description : NULL device specific texture manager implementation. - -#include "CryRenderOther_precompiled.h" -#include "AtomShim_Renderer.h" -#include -#include - -//================================================================================= - -/////////////////////////////////////////////////////////////////////////////////// - - -void CAtomShimRenderer::MakeSprite(IDynTexture*& rTexturePtr, [[maybe_unused]] float _fSpriteDistance, [[maybe_unused]] int nTexSize, [[maybe_unused]] float angle, [[maybe_unused]] float angle2, [[maybe_unused]] IStatObj* pStatObj, [[maybe_unused]] const float fBrightnessMultiplier, [[maybe_unused]] SRendParams& rParms) -{ - rTexturePtr = NULL; -} - -int CAtomShimRenderer::GenerateAlphaGlowTexture([[maybe_unused]] float k) -{ - return 0; -} - -bool CAtomShimRenderer::EF_SetLightHole([[maybe_unused]] Vec3 vPos, [[maybe_unused]] Vec3 vNormal, [[maybe_unused]] int idTex, [[maybe_unused]] float fScale, [[maybe_unused]] bool bAdditive) -{ - return false; -} - -bool CAtomShimRenderer::EF_PrecacheResource([[maybe_unused]] ITexture* pTP, [[maybe_unused]] float fDist, [[maybe_unused]] float fTimeToReady, [[maybe_unused]] int Flags, [[maybe_unused]] int nUpdateId, [[maybe_unused]] int nCounter) -{ - return false; -} - -bool CTexture::RenderEnvironmentCMHDR([[maybe_unused]] int size, [[maybe_unused]] Vec3& Pos, [[maybe_unused]] TArray& vecData) -{ - return true; -} - -void CTexture::Apply([[maybe_unused]] int nTUnit, [[maybe_unused]] int nState, [[maybe_unused]] int nTMatSlot, [[maybe_unused]] int nSUnit, [[maybe_unused]] SResourceView::KeyType nResViewKey, [[maybe_unused]] EHWShaderClass eSHClass) -{ -} - -#if defined(TEXTURE_GET_SYSTEM_COPY_SUPPORT) -byte* CTexture::Convert([[maybe_unused]] const byte* pSrc, [[maybe_unused]] int nWidth, [[maybe_unused]] int nHeight, [[maybe_unused]] int nMips, [[maybe_unused]] ETEX_Format eTFSrc, [[maybe_unused]] ETEX_Format eTFDst, [[maybe_unused]] int& nOutSize, [[maybe_unused]] bool bLinear) -{ - return NULL; -} -#endif - -void CTexture::ReleaseDeviceTexture([[maybe_unused]] bool bKeepLastMips, [[maybe_unused]] bool bFromUnload) -{ -} - -bool CTexture::Clear([[maybe_unused]] const ColorF& color) -{ - return true; -} - -void CTexture::SetTexStates() -{ - STexState s; - - const bool noMipFiltering = m_nMips <= 1 && !(m_nFlags & FT_FORCE_MIPS); - s.m_nMinFilter = FILTER_LINEAR; - s.m_nMagFilter = FILTER_LINEAR; - s.m_nMipFilter = noMipFiltering ? FILTER_NONE : FILTER_LINEAR; - - const int addrMode = (m_nFlags & FT_STATE_CLAMP || m_eTT == eTT_Cube) ? TADDR_CLAMP : TADDR_WRAP; - s.SetClampMode(addrMode, addrMode, addrMode); - - m_nDefState = (uint16)CTexture::GetTexState(s); -} - -bool CTexture::CreateDeviceTexture([[maybe_unused]] const byte* pData[6]) -{ - return true; -} - -void* CTexture::CreateDeviceResourceView([[maybe_unused]] const SResourceView& rv) -{ - return NULL; -} - -ETEX_Format CTexture::ClosestFormatSupported(ETEX_Format eTFDst) -{ - return eTFDst; -} - -bool CTexture::SetFilterMode(int nFilter) -{ - return s_sDefState.SetFilterMode(nFilter); -} - -bool CTexture::CreateRenderTarget([[maybe_unused]] ETEX_Format eTF, [[maybe_unused]] const ColorF& cClear) -{ - return true; -} - -bool CTexture::SetClampingMode(int nAddressU, int nAddressV, int nAddressW) -{ - return s_sDefState.SetClampMode(nAddressU, nAddressV, nAddressW); -} - -void CTexture::UpdateTexStates() -{ -} - -void CTexture::GenerateCachedShadowMaps() -{ -} - -void CTexture::Readback([[maybe_unused]] AZ::u32 subresourceIndex, StagingHook callback) -{ -} - -//====================================================================================== - -void SEnvTexture::Release() -{ -} - -void SEnvTexture::RT_SetMatrix(void) -{ -} - -bool SDynTexture::RestoreRT([[maybe_unused]] int nRT, [[maybe_unused]] bool bPop) -{ - return true; -} - -bool SDynTexture::ClearRT() -{ - return true; -} - -bool SDynTexture2::ClearRT() -{ - return true; -} - -bool SDynTexture::SetRT([[maybe_unused]] int nRT, [[maybe_unused]] bool bPush, [[maybe_unused]] SDepthTexture* pDepthSurf, [[maybe_unused]] bool bScreenVP) -{ - return true; -} - -bool SDynTexture2::SetRT([[maybe_unused]] int nRT, [[maybe_unused]] bool bPush, [[maybe_unused]] SDepthTexture* pDepthSurf, [[maybe_unused]] bool bScreenVP) -{ - return true; -} - -bool SDynTexture2::RestoreRT([[maybe_unused]] int nRT, [[maybe_unused]] bool bPop) -{ - return true; -} - -bool SDynTexture2::SetRectStates() -{ - return true; -} - -//=============================================================================== - -void STexState::PostCreate() -{ -} - -void STexState::Destroy() -{ -} - -void STexState::Init(const STexState& src) -{ - memcpy(this, &src, sizeof(src)); -} - -void STexState::SetComparisonFilter([[maybe_unused]] bool bEnable) -{ -} - -bool STexState::SetClampMode(int nAddressU, int nAddressV, int nAddressW) -{ - m_nAddressU = nAddressU; - m_nAddressV = nAddressV; - m_nAddressW = nAddressW; - return true; -} - -bool STexState::SetFilterMode([[maybe_unused]] int nFilter) -{ - m_nMinFilter = 0; - m_nMagFilter = 0; - m_nMipFilter = 0; - return true; -} - -void STexState::SetBorderColor(DWORD dwColor) -{ - m_dwBorderColor = dwColor; -} - - -SDepthTexture::~SDepthTexture() -{ -} - -void SDepthTexture::Release([[maybe_unused]] bool bReleaseTex) -{ -} - -ETEX_Format CTexture::TexFormatFromDeviceFormat([[maybe_unused]] D3DFormat nFormat) -{ - return eTF_Unknown; -} - -bool CTexture::RT_CreateDeviceTexture([[maybe_unused]] const byte* pData[6]) -{ - return true; -} - -void CTexture::UpdateTextureRegion([[maybe_unused]] const uint8_t* data, [[maybe_unused]] int X, [[maybe_unused]] int Y, [[maybe_unused]] int Z, [[maybe_unused]] int USize, [[maybe_unused]] int VSize, [[maybe_unused]] int ZSize, [[maybe_unused]] ETEX_Format eTFSrc) -{ -} -void CTexture::RT_UpdateTextureRegion([[maybe_unused]] const uint8_t* data, [[maybe_unused]] int X, [[maybe_unused]] int Y, [[maybe_unused]] int Z, [[maybe_unused]] int USize, [[maybe_unused]] int VSize, [[maybe_unused]] int ZSize, [[maybe_unused]] ETEX_Format eTFSrc) -{ -} - -void CTexture::Unbind() -{ -} - -bool SDynTexture::RT_SetRT([[maybe_unused]] int nRT, [[maybe_unused]] int nWidth, [[maybe_unused]] int nHeight, [[maybe_unused]] bool bPush, [[maybe_unused]] bool bScreenVP) -{ - return true; -} - -bool SDynTexture::RT_Update([[maybe_unused]] int nNewWidth, [[maybe_unused]] int nNewHeight) -{ - return true; -} - -void CTexture::ReleaseSystemTargets(void) {} -void CTexture::ReleaseMiscTargets(void) {} -void CTexture::CreateSystemTargets(void) {} - -//=============================================================================== - -namespace TextureHelpers -{ - bool VerifyTexSuffix([[maybe_unused]] EEfResTextures texSlot, [[maybe_unused]] const char* texPath) - { - return false; - } - - bool VerifyTexSuffix([[maybe_unused]] EEfResTextures texSlot, [[maybe_unused]] const string& texPath) - { - return false; - } - - const char* LookupTexSuffix([[maybe_unused]] EEfResTextures texSlot) - { - return nullptr; - } - - int8 LookupTexPriority([[maybe_unused]] EEfResTextures texSlot) - { - return 0; - } - - CTexture* LookupTexDefault([[maybe_unused]] EEfResTextures texSlot) - { - return nullptr; - } - - CTexture* LookupTexBlank([[maybe_unused]] EEfResTextures texSlot) - { - return nullptr; - } -} - -bool CTexture::Clear() { return true; } - -uint32 CDeviceTexture::TextureDataSize([[maybe_unused]] uint32 nWidth, [[maybe_unused]] uint32 nHeight, [[maybe_unused]] uint32 nDepth, [[maybe_unused]] uint32 nMips, [[maybe_unused]] uint32 nSlices, [[maybe_unused]] const ETEX_Format eTF) -{ - return 0; -} - -AtomShimTexture::~AtomShimTexture() -{ - if(AZ::Data::AssetBus::Handler::BusIsConnected()) - { - AZ::Data::AssetBus::Handler::BusDisconnect(); - } -} - -// Hot-reloading support for the AtomShimTexture. -// This only supports OnAssetReady, not OnAssetReloaded, because it is only intended to handle the case where a texture has not been processed or does not exist. -// The RPI::StreamingImage will handle re-loading if the file changes after it has been loaded initially -void AtomShimTexture::QueueForHotReload(const AZ::Data::AssetId& assetId) -{ - AZ::Data::AssetBus::Handler::BusConnect(assetId); - - // Lyshine may try to load a texture before the ImageSystem wasn't ready - if (AZ::RPI::ImageSystemInterface::Get()) - { - CreateFromImage(AZ::RPI::ImageSystemInterface::Get()->GetSystemImage(AZ::RPI::SystemImage::Magenta)); - } -} - -void AtomShimTexture::OnAssetReady(AZ::Data::Asset asset) -{ - AZ::Data::AssetBus::Handler::BusDisconnect(asset.GetId()); - - AZ::Data::Asset imageAsset = asset; - AZ_Assert(imageAsset, "This should be a streaming image asset"); - - CreateFromStreamingImageAsset(imageAsset); -} - -void AtomShimTexture::CreateFromStreamingImageAsset(const AZ::Data::Asset& imageAsset) -{ - AZ::Data::Instance image = AZ::RPI::StreamingImage::FindOrCreate(imageAsset); - if (!image) - { - AZ_Error("CAtomShimRenderer", false, "Failed to find or create an image instance from image asset '%s'", imageAsset.GetHint().c_str()); - return; - } - - CreateFromImage(image); -} - -void AtomShimTexture::CreateFromImage(const AZ::Data::Instance& image) -{ - AZ::RHI::Format rhiViewFormat = AZ::RHI::Format::Unknown; - AZ::RHI::ImageViewDescriptor viewDesc = AZ::RHI::ImageViewDescriptor(rhiViewFormat); - AZ::RHI::Image* rhiImage = image->GetRHIImage(); - - AZ::RHI::Ptr imageView = rhiImage->GetImageView(viewDesc); - if(!imageView.get()) - { - AZ_Assert(false, "Failed to acquire an image view"); - return; - } - - m_instance = image; - m_image = rhiImage; - m_imageView = imageView; - - SetWidth(rhiImage->GetDescriptor().m_size.m_width); - SetHeight(rhiImage->GetDescriptor().m_size.m_height); -} - diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_TexturesStreaming.cpp b/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_TexturesStreaming.cpp deleted file mode 100644 index 14ecb6ed57..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_TexturesStreaming.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#include "CryRenderOther_precompiled.h" -#include "AtomShim_Renderer.h" -#include "../Common/Textures/TextureStreamPool.h" - -//=============================================================================== - -bool STexPoolItem::IsStillUsedByGPU([[maybe_unused]] uint32 nCurTick) -{ - return false; -} - -STexPoolItem::~STexPoolItem() -{ -} - -void CTexture::InitStreamingDev() -{ -} - -void CTexture::StreamExpandMip([[maybe_unused]] const void* pRawData, [[maybe_unused]] int nMip, [[maybe_unused]] int nBaseMipOffset, [[maybe_unused]] int nSideDelta) -{ -} - -void CTexture::StreamCopyMipsTexToTex([[maybe_unused]] STexPoolItem* pSrcItem, [[maybe_unused]] int nMipSrc, [[maybe_unused]] STexPoolItem* pDestItem, [[maybe_unused]] int nMipDest, [[maybe_unused]] int nNumMips) -{ -} - -bool CTexture::StreamPrepare_Platform() -{ - return true; -} - -int CTexture::StreamTrim([[maybe_unused]] int nToMip) -{ - return 0; -} - -// Just remove item from the texture object and keep Item in Pool list for future use -// This function doesn't release API texture -void CTexture::StreamRemoveFromPool() -{ -} - -void CTexture::StreamCopyMipsTexToMem([[maybe_unused]] int nStartMip, [[maybe_unused]] int nEndMip, [[maybe_unused]] bool bToDevice, [[maybe_unused]] STexPoolItem* pNewPoolItem) -{ -} - -STexPoolItem* CTexture::StreamGetPoolItem([[maybe_unused]] int nStartMip, [[maybe_unused]] int nMips, [[maybe_unused]] bool bShouldBeCreated, [[maybe_unused]] bool bCreateFromMipData, [[maybe_unused]] bool bCanCreate, [[maybe_unused]] bool bForStreamOut) -{ - return NULL; -} - -void CTexture::StreamAssignPoolItem([[maybe_unused]] STexPoolItem* pItem, [[maybe_unused]] int nMinMip) -{ -} - - -CTextureStreamPoolMgr::CTextureStreamPoolMgr() -{ -} - -CTextureStreamPoolMgr::~CTextureStreamPoolMgr() -{ -} - -void CTextureStreamPoolMgr::Flush() -{ -} - -STexPoolItem* CTextureStreamPoolMgr::GetPoolItem([[maybe_unused]] int nWidth, [[maybe_unused]] int nHeight, [[maybe_unused]] int nArraySize, [[maybe_unused]] int nMips, [[maybe_unused]] ETEX_Format eTF, [[maybe_unused]] bool bIsSRGB, [[maybe_unused]] ETEX_Type eTT, [[maybe_unused]] bool bShouldBeCreated, [[maybe_unused]] const char* sName, [[maybe_unused]] STextureInfo* pTI, [[maybe_unused]] bool bCanCreate, [[maybe_unused]] bool bWaitForIdle) -{ - return NULL; -} - -void CTextureStreamPoolMgr::ReleaseItem([[maybe_unused]] STexPoolItem* pItem) -{ -} - -void CTextureStreamPoolMgr::GarbageCollect([[maybe_unused]] size_t* nCurTexPoolSize, [[maybe_unused]] size_t nLowerPoolLimit, [[maybe_unused]] int nMaxItemsToFree) -{ -} - -void CTextureStreamPoolMgr::GetMemoryUsage([[maybe_unused]] ICrySizer* pSizer) -{ -} diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/CMakeLists.txt b/Gems/AtomLyIntegration/CryRenderAtomShim/CMakeLists.txt deleted file mode 100644 index 9ad9958449..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/CMakeLists.txt +++ /dev/null @@ -1,45 +0,0 @@ -# -# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -# its licensors. -# -# For complete copyright and license terms please see the LICENSE at the root of this -# distribution (the "License"). All use of this software is governed by the License, -# or, if provided, by the license below or the license accompanying this file. Do not -# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# - -ly_get_list_relative_pal_filename(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME}) - -include(${pal_dir}/PAL_${PAL_PLATFORM_NAME_LOWERCASE}.cmake) # For PAL_TRAIT_ATOM_CRYRENDEROTHER_SUPPORTED - -if(NOT PAL_TRAIT_ATOM_CRYRENDEROTHER_SUPPORTED) - return() -endif() - -ly_add_target( - NAME CryRenderOther ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE} - NAMESPACE Legacy - FILES_CMAKE - atom_shim_renderer_files.cmake - ${pal_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake - PLATFORM_INCLUDE_FILES - ${pal_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}.cmake - INCLUDE_DIRECTORIES - PRIVATE - . - PCH - BUILD_DEPENDENCIES - PUBLIC - AZ::AzCore - Legacy::CryCommon - Legacy::CryRender.Headers - Legacy::CryRenderNULL.Static - AZ::AtomCore - Gem::Atom_RHI.Reflect - Gem::Atom_RPI.Public -) - -# Atom_AtomBridge.Static is the one that drives loading CryRenderOther, however, CryRenderOther -# is not enabled in every platform, so we define the dependency here -ly_add_dependencies(Atom_AtomBridge.Static CryRenderOther) diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/CryRenderAtomShim.rc b/Gems/AtomLyIntegration/CryRenderAtomShim/CryRenderAtomShim.rc deleted file mode 100644 index 5730d0a537..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/CryRenderAtomShim.rc +++ /dev/null @@ -1,111 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "winres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Russian resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) -#ifdef _WIN32 -LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT -#pragma code_page(1251) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""winres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - -#endif // Russian resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// German (Germany) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) -#ifdef _WIN32 -LANGUAGE LANG_GERMAN, SUBLANG_GERMAN -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000904b0" - BEGIN - VALUE "CompanyName", "Amazon.com, Inc." - VALUE "FileVersion", "1, 0, 0, 1" - VALUE "LegalCopyright", "Portions of this file Copyright (c) Amazon.com, Inc. or its affiliates. All Rights Reserved. Original file Copyright (c) Crytek GMBH. Used under license by Amazon.com, Inc. and its affiliates." - VALUE "ProductName", "Lumberyard" - VALUE "ProductVersion", "1, 0, 0, 1" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x9, 1200 - END -END - -#endif // German (Germany) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/PCH/CryRenderOther_precompiled.h b/Gems/AtomLyIntegration/CryRenderAtomShim/PCH/CryRenderOther_precompiled.h deleted file mode 100644 index 70450d0c5e..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/PCH/CryRenderOther_precompiled.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ - -#pragma once - -#include - -#include -#include -#include -#include "Common/DevBuffer.h" - -#include "XRenderD3D9/DeviceManager/DeviceManager.h" - -#include - -#include "Common/CommonRender.h" -#include -#include "Common/Shaders/ShaderComponents.h" -#include "Common/Shaders/Shader.h" -#include "Common/Shaders/CShader.h" -#include "Common/RenderMesh.h" -#include "Common/RenderPipeline.h" -#include "Common/RenderThread.h" - -#include "Common/Renderer.h" -#include "Common/Textures/Texture.h" - -#include "Common/OcclQuery.h" - -#include "Common/PostProcess/PostProcess.h" - -// All handled render elements (except common ones included in "RendElement.h") -#include "Common/RendElements/CREBeam.h" -#include "Common/RendElements/CREClientPoly.h" -#include "Common/RendElements/CRELensOptics.h" -#include "Common/RendElements/CREHDRProcess.h" -#include "Common/RendElements/CRECloud.h" -#include "Common/RendElements/CREDeferredShading.h" -#include "Common/RendElements/CREMeshImpl.h" diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Android/PAL_android.cmake b/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Android/PAL_android.cmake deleted file mode 100644 index 64ee12d5a7..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Android/PAL_android.cmake +++ /dev/null @@ -1,12 +0,0 @@ -# -# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -# its licensors. -# -# For complete copyright and license terms please see the LICENSE at the root of this -# distribution (the "License"). All use of this software is governed by the License, -# or, if provided, by the license below or the license accompanying this file. Do not -# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# - -set(PAL_TRAIT_ATOM_CRYRENDEROTHER_SUPPORTED TRUE) \ No newline at end of file diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Android/platform_android.cmake b/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Android/platform_android.cmake deleted file mode 100644 index f5b9ea77a2..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Android/platform_android.cmake +++ /dev/null @@ -1,11 +0,0 @@ -# -# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -# its licensors. -# -# For complete copyright and license terms please see the LICENSE at the root of this -# distribution (the "License"). All use of this software is governed by the License, -# or, if provided, by the license below or the license accompanying this file. Do not -# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# - diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Android/platform_android_files.cmake b/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Android/platform_android_files.cmake deleted file mode 100644 index 52ed52bc87..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Android/platform_android_files.cmake +++ /dev/null @@ -1,14 +0,0 @@ -# -# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -# its licensors. -# -# For complete copyright and license terms please see the LICENSE at the root of this -# distribution (the "License"). All use of this software is governed by the License, -# or, if provided, by the license below or the license accompanying this file. Do not -# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# - -set(FILES - ../Common/Unimplemented/AtomShim_Renderer_Unimplemented.cpp -) diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Common/Unimplemented/AtomShim_Renderer_Unimplemented.cpp b/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Common/Unimplemented/AtomShim_Renderer_Unimplemented.cpp deleted file mode 100644 index 50c4d07cc5..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Common/Unimplemented/AtomShim_Renderer_Unimplemented.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates, or -* a third party where indicated. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -#include "CryRenderOther_precompiled.h" - -namespace Platform -{ - WIN_HWND GetNativeWindowHandle() - { - return NULL; - } -} - - diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Linux/PAL_linux.cmake b/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Linux/PAL_linux.cmake deleted file mode 100644 index 64ee12d5a7..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Linux/PAL_linux.cmake +++ /dev/null @@ -1,12 +0,0 @@ -# -# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -# its licensors. -# -# For complete copyright and license terms please see the LICENSE at the root of this -# distribution (the "License"). All use of this software is governed by the License, -# or, if provided, by the license below or the license accompanying this file. Do not -# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# - -set(PAL_TRAIT_ATOM_CRYRENDEROTHER_SUPPORTED TRUE) \ No newline at end of file diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Linux/platform_linux.cmake b/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Linux/platform_linux.cmake deleted file mode 100644 index f5b9ea77a2..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Linux/platform_linux.cmake +++ /dev/null @@ -1,11 +0,0 @@ -# -# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -# its licensors. -# -# For complete copyright and license terms please see the LICENSE at the root of this -# distribution (the "License"). All use of this software is governed by the License, -# or, if provided, by the license below or the license accompanying this file. Do not -# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# - diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Linux/platform_linux_files.cmake b/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Linux/platform_linux_files.cmake deleted file mode 100644 index 52ed52bc87..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Linux/platform_linux_files.cmake +++ /dev/null @@ -1,14 +0,0 @@ -# -# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -# its licensors. -# -# For complete copyright and license terms please see the LICENSE at the root of this -# distribution (the "License"). All use of this software is governed by the License, -# or, if provided, by the license below or the license accompanying this file. Do not -# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# - -set(FILES - ../Common/Unimplemented/AtomShim_Renderer_Unimplemented.cpp -) diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Mac/AtomShim_Renderer_Mac.cpp b/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Mac/AtomShim_Renderer_Mac.cpp deleted file mode 100644 index 63531162bf..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Mac/AtomShim_Renderer_Mac.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates, or -* a third party where indicated. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ - -#include "CryRenderOther_precompiled.h" -#import - -bool UIDeviceIsTablet() -{ - return false; -} - -bool UIKitGetPrimaryPhysicalDisplayDimensions(int& o_widthPixels, int& o_heightPixels) -{ - NSScreen* nativeScreen = [NSScreen mainScreen]; - CGRect screenBounds = [nativeScreen frame]; - CGFloat screenScale = [nativeScreen backingScaleFactor]; - o_widthPixels = static_cast(screenBounds.size.width * screenScale); - o_heightPixels = static_cast(screenBounds.size.height * screenScale); - return true; -} - - diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Mac/PAL_mac.cmake b/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Mac/PAL_mac.cmake deleted file mode 100644 index 64ee12d5a7..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Mac/PAL_mac.cmake +++ /dev/null @@ -1,12 +0,0 @@ -# -# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -# its licensors. -# -# For complete copyright and license terms please see the LICENSE at the root of this -# distribution (the "License"). All use of this software is governed by the License, -# or, if provided, by the license below or the license accompanying this file. Do not -# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# - -set(PAL_TRAIT_ATOM_CRYRENDEROTHER_SUPPORTED TRUE) \ No newline at end of file diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Mac/platform_mac.cmake b/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Mac/platform_mac.cmake deleted file mode 100644 index 209e7f9107..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Mac/platform_mac.cmake +++ /dev/null @@ -1,15 +0,0 @@ -# -# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -# its licensors. -# -# For complete copyright and license terms please see the LICENSE at the root of this -# distribution (the "License"). All use of this software is governed by the License, -# or, if provided, by the license below or the license accompanying this file. Do not -# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# - -set(LY_COMPILE_OPTIONS - PRIVATE - -xobjective-c++ -) \ No newline at end of file diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Mac/platform_mac_files.cmake b/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Mac/platform_mac_files.cmake deleted file mode 100644 index f0296f198b..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Mac/platform_mac_files.cmake +++ /dev/null @@ -1,15 +0,0 @@ -# -# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -# its licensors. -# -# For complete copyright and license terms please see the LICENSE at the root of this -# distribution (the "License"). All use of this software is governed by the License, -# or, if provided, by the license below or the license accompanying this file. Do not -# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# - -set(FILES - ../Common/Unimplemented/AtomShim_Renderer_Unimplemented.cpp - AtomShim_Renderer_Mac.cpp -) diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Windows/AtomShim_Renderer_Windows.cpp b/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Windows/AtomShim_Renderer_Windows.cpp deleted file mode 100644 index ca5dbd8950..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Windows/AtomShim_Renderer_Windows.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates, or -* a third party where indicated. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ - -#include "CryRenderOther_precompiled.h" - -namespace Platform -{ - WIN_HWND GetNativeWindowHandle() - { - return GetDesktopWindow(); - } -} - - diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Windows/PAL_windows.cmake b/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Windows/PAL_windows.cmake deleted file mode 100644 index 64ee12d5a7..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Windows/PAL_windows.cmake +++ /dev/null @@ -1,12 +0,0 @@ -# -# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -# its licensors. -# -# For complete copyright and license terms please see the LICENSE at the root of this -# distribution (the "License"). All use of this software is governed by the License, -# or, if provided, by the license below or the license accompanying this file. Do not -# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# - -set(PAL_TRAIT_ATOM_CRYRENDEROTHER_SUPPORTED TRUE) \ No newline at end of file diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Windows/platform_windows.cmake b/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Windows/platform_windows.cmake deleted file mode 100644 index ad8a620993..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Windows/platform_windows.cmake +++ /dev/null @@ -1,14 +0,0 @@ -# -# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -# its licensors. -# -# For complete copyright and license terms please see the LICENSE at the root of this -# distribution (the "License"). All use of this software is governed by the License, -# or, if provided, by the license below or the license accompanying this file. Do not -# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# - -set(LY_BUILD_DEPENDENCIES - PRIVATE -) \ No newline at end of file diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Windows/platform_windows_files.cmake b/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Windows/platform_windows_files.cmake deleted file mode 100644 index e110029d0d..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/Windows/platform_windows_files.cmake +++ /dev/null @@ -1,14 +0,0 @@ -# -# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -# its licensors. -# -# For complete copyright and license terms please see the LICENSE at the root of this -# distribution (the "License"). All use of this software is governed by the License, -# or, if provided, by the license below or the license accompanying this file. Do not -# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# - -set(FILES - AtomShim_Renderer_Windows.cpp -) diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/iOS/AtomShim_Renderer_iOS.cpp b/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/iOS/AtomShim_Renderer_iOS.cpp deleted file mode 100644 index 90132cdd75..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/iOS/AtomShim_Renderer_iOS.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates, or -* a third party where indicated. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ - -#include "CryRenderOther_precompiled.h" -#import - -using NativeScreenType = UIScreen; -using NativeWindowType = UIWindow; - -bool UIDeviceIsTablet() -{ - if([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) - { - return true; - } - return false; -} - -bool UIKitGetPrimaryPhysicalDisplayDimensions(int& o_widthPixels, int& o_heightPixels) -{ - UIScreen* nativeScreen = [UIScreen mainScreen]; - - CGRect screenBounds = [nativeScreen bounds]; - CGFloat screenScale = [nativeScreen scale]; - - o_widthPixels = static_cast(screenBounds.size.width * screenScale); - o_heightPixels = static_cast(screenBounds.size.height * screenScale); - - const bool isScreenLandscape = o_widthPixels > o_heightPixels; - UIInterfaceOrientation uiOrientation = UIInterfaceOrientationUnknown; -#if defined(__IPHONE_13_0) || defined(__TVOS_13_0) - if(@available(iOS 13.0, tvOS 13.0, *)) - { - UIWindow* foundWindow = nil; - - //Find the key window - NSArray* windows = [[UIApplication sharedApplication] windows]; - for (UIWindow* window in windows) - { - if (window.isKeyWindow) - { - foundWindow = window; - break; - } - } - - //Check if the key window is found - if(foundWindow) - { - uiOrientation = foundWindow.windowScene.interfaceOrientation; - } - else - { - //If no key window is found create a temporary window in order to extract the orientation - //This can happen as this function gets called before the renderer is initialized - CGRect screenBounds = [[UIScreen mainScreen] bounds]; - UIWindow* tempWindow = [[UIWindow alloc] initWithFrame: screenBounds]; - uiOrientation = tempWindow.windowScene.interfaceOrientation; - [tempWindow release]; - } - } -#else - uiOrientation = UIApplication.sharedApplication.statusBarOrientation; -#endif - - const bool isInterfaceLandscape = UIInterfaceOrientationIsLandscape(uiOrientation); - if (isScreenLandscape != isInterfaceLandscape) - { - const int width = o_widthPixels; - o_widthPixels = o_heightPixels; - o_heightPixels = width; - } - - return true; -} - diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/iOS/PAL_ios.cmake b/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/iOS/PAL_ios.cmake deleted file mode 100644 index 64ee12d5a7..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/iOS/PAL_ios.cmake +++ /dev/null @@ -1,12 +0,0 @@ -# -# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -# its licensors. -# -# For complete copyright and license terms please see the LICENSE at the root of this -# distribution (the "License"). All use of this software is governed by the License, -# or, if provided, by the license below or the license accompanying this file. Do not -# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# - -set(PAL_TRAIT_ATOM_CRYRENDEROTHER_SUPPORTED TRUE) \ No newline at end of file diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/iOS/platform_ios.cmake b/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/iOS/platform_ios.cmake deleted file mode 100644 index 0286e6465b..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/iOS/platform_ios.cmake +++ /dev/null @@ -1,15 +0,0 @@ -# -# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -# its licensors. -# -# For complete copyright and license terms please see the LICENSE at the root of this -# distribution (the "License"). All use of this software is governed by the License, -# or, if provided, by the license below or the license accompanying this file. Do not -# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# - -set(LY_COMPILE_OPTIONS - PRIVATE - -xobjective-c++ -) diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/iOS/platform_ios_files.cmake b/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/iOS/platform_ios_files.cmake deleted file mode 100644 index a5a3d98144..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/Platform/iOS/platform_ios_files.cmake +++ /dev/null @@ -1,15 +0,0 @@ -# -# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -# its licensors. -# -# For complete copyright and license terms please see the LICENSE at the root of this -# distribution (the "License"). All use of this software is governed by the License, -# or, if provided, by the license below or the license accompanying this file. Do not -# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# - -set(FILES - ../Common/Unimplemented/AtomShim_Renderer_Unimplemented.cpp - AtomShim_Renderer_iOS.cpp -) diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/atom_shim_renderer_files.cmake b/Gems/AtomLyIntegration/CryRenderAtomShim/atom_shim_renderer_files.cmake deleted file mode 100644 index 0259c65b26..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/atom_shim_renderer_files.cmake +++ /dev/null @@ -1,29 +0,0 @@ -# -# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -# its licensors. -# -# For complete copyright and license terms please see the LICENSE at the root of this -# distribution (the "License"). All use of this software is governed by the License, -# or, if provided, by the license below or the license accompanying this file. Do not -# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# - -set(FILES - AtomShim_DevBuffer.cpp - AtomShim_PostProcess.cpp - AtomShim_Renderer.cpp - AtomShim_RendPipeline.cpp - AtomShim_RERender.cpp - AtomShim_Shaders.cpp - AtomShim_Shadows.cpp - AtomShim_System.cpp - AtomShim_Textures.cpp - AtomShim_TexturesStreaming.cpp - AtomShim_RenderAuxGeom.cpp - AtomShim_Renderer.h - AtomShim_RenderAuxGeom.h - resource.h - AtomShim_CRELensOptics.cpp - PCH/CryRenderOther_precompiled.h -) diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/resource.h b/Gems/AtomLyIntegration/CryRenderAtomShim/resource.h deleted file mode 100644 index ed88839421..0000000000 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/resource.h +++ /dev/null @@ -1,25 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ -// Original file Copyright Crytek GMBH or its affiliates, used under license. - -#define VS_VERSION_INFO 1 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 101 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif