From 8fd5c30e136e62887842916b26491c691a625e26 Mon Sep 17 00:00:00 2001 From: nvsickle Date: Wed, 12 May 2021 17:47:10 -0700 Subject: [PATCH] Address some build/review feedback --- Code/Sandbox/Editor/ViewportTitleDlg.cpp | 7 ++-- .../AtomFont/Code/Source/FFont.cpp | 1 - ...AtomViewportDisplayInfoSystemComponent.cpp | 32 +++++++++---------- .../AtomViewportDisplayInfoSystemComponent.h | 1 + 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/Code/Sandbox/Editor/ViewportTitleDlg.cpp b/Code/Sandbox/Editor/ViewportTitleDlg.cpp index 159fccfd64..d7c8929540 100644 --- a/Code/Sandbox/Editor/ViewportTitleDlg.cpp +++ b/Code/Sandbox/Editor/ViewportTitleDlg.cpp @@ -187,11 +187,8 @@ void CViewportTitleDlg::OnToggleDisplayInfo() state, &AZ::AtomBridge::AtomViewportInfoDisplayRequestBus::Events::GetDisplayState ); - state = static_cast(static_cast(state)+1); - if (state == AZ::AtomBridge::ViewportInfoDisplayState::Invalid) - { - state = AZ::AtomBridge::ViewportInfoDisplayState::NoInfo; - } + state = static_cast( + (static_cast(state)+1) % static_cast(AZ::AtomBridge::ViewportInfoDisplayState::Invalid)); // SetDisplayState will fire OnViewportInfoDisplayStateChanged and notify us, no need to call UpdateDisplayInfo. AZ::AtomBridge::AtomViewportInfoDisplayRequestBus::Broadcast( &AZ::AtomBridge::AtomViewportInfoDisplayRequestBus::Events::SetDisplayState, diff --git a/Gems/AtomLyIntegration/AtomFont/Code/Source/FFont.cpp b/Gems/AtomLyIntegration/AtomFont/Code/Source/FFont.cpp index be0f87100a..cc14014e48 100644 --- a/Gems/AtomLyIntegration/AtomFont/Code/Source/FFont.cpp +++ b/Gems/AtomLyIntegration/AtomFont/Code/Source/FFont.cpp @@ -1684,7 +1684,6 @@ AZ::FFont::DrawParameters AZ::FFont::ExtractDrawParameters(const AzFramework::Te return internalParams; } - //Code mostly duplicated from CRenderer::Draw2dTextWithDepth float posX = params.m_position.GetX(); float posY = params.m_position.GetY(); internalParams.m_viewportContext = AZ::Interface::Get()->GetViewportContextById(params.m_drawViewportId); diff --git a/Gems/AtomLyIntegration/AtomViewportDisplayInfo/Code/Source/AtomViewportDisplayInfoSystemComponent.cpp b/Gems/AtomLyIntegration/AtomViewportDisplayInfo/Code/Source/AtomViewportDisplayInfoSystemComponent.cpp index c9128c001f..ed6b910b76 100644 --- a/Gems/AtomLyIntegration/AtomViewportDisplayInfo/Code/Source/AtomViewportDisplayInfoSystemComponent.cpp +++ b/Gems/AtomLyIntegration/AtomViewportDisplayInfo/Code/Source/AtomViewportDisplayInfoSystemComponent.cpp @@ -111,25 +111,26 @@ namespace AZ::Render void AtomViewportDisplayInfoSystemComponent::DrawLine(AZStd::string_view line, AZ::Color color) { m_drawParams.m_color = color; - AzFramework::FontDrawInterface* fontDrawInterface = - AZ::Interface::Get()->GetDefaultFontDrawInterface(); - AZ::Vector2 textSize = fontDrawInterface->GetTextSize(m_drawParams, line); - fontDrawInterface->DrawScreenAlignedText2d(m_drawParams, line); + AZ::Vector2 textSize = m_fontDrawInterface->GetTextSize(m_drawParams, line); + m_fontDrawInterface->DrawScreenAlignedText2d(m_drawParams, line); m_drawParams.m_position.SetY(m_drawParams.m_position.GetY() + textSize.GetY() + m_lineSpacing); } void AtomViewportDisplayInfoSystemComponent::OnRenderTick() { - auto fontQueryInterface = AZ::Interface::Get(); - if (!fontQueryInterface) + if (!m_fontDrawInterface) { - return; + auto fontQueryInterface = AZ::Interface::Get(); + if (!fontQueryInterface) + { + return; + } + m_fontDrawInterface = + fontQueryInterface->GetDefaultFontDrawInterface(); } - AzFramework::FontDrawInterface* fontDrawInterface = - fontQueryInterface->GetDefaultFontDrawInterface(); AZ::RPI::ViewportContextPtr viewportContext = GetViewportContext(); - if (!fontDrawInterface || !viewportContext || !viewportContext->GetRenderScene()) + if (!m_fontDrawInterface || !viewportContext || !viewportContext->GetRenderScene()) { return; } @@ -167,7 +168,7 @@ namespace AZ::Render m_drawParams.m_lineSpacing = 0.5f; // Calculate line spacing based on the font's actual line height - const float lineHeight = fontDrawInterface->GetTextSize(m_drawParams, " ").GetY(); + const float lineHeight = m_fontDrawInterface->GetTextSize(m_drawParams, " ").GetY(); m_lineSpacing = lineHeight * m_drawParams.m_lineSpacing; DrawRendererInfo(); @@ -234,7 +235,7 @@ namespace AZ::Render int count = 1; if (auto passAsParent = pass->AsParent()) { - for (const auto child : passAsParent->GetChildren()) + for (const auto& child : passAsParent->GetChildren()) { count += containingPassCount(child); } @@ -243,10 +244,10 @@ namespace AZ::Render }; const int numPasses = containingPassCount(rootPass); DrawLine(AZStd::string::format( - "Total Passes: %d Vertex Count: %d Primitive Count: %d", + "Total Passes: %d Vertex Count: %lld Primitive Count: %lld", numPasses, - stats.m_vertexCount, - stats.m_primitiveCount + aznumeric_cast(stats.m_vertexCount), + aznumeric_cast(stats.m_primitiveCount) )); } @@ -269,7 +270,6 @@ namespace AZ::Render } m_lastMemoryUpdate = currentTime; - int peakUsageMB = aznumeric_cast(processMemInfo.PeakPagefileUsage >> 20); int currentUsageMB = aznumeric_cast(processMemInfo.PagefileUsage >> 20); DrawLine(AZStd::string::format("Mem=%d Peak=%d", currentUsageMB, peakUsageMB)); diff --git a/Gems/AtomLyIntegration/AtomViewportDisplayInfo/Code/Source/AtomViewportDisplayInfoSystemComponent.h b/Gems/AtomLyIntegration/AtomViewportDisplayInfo/Code/Source/AtomViewportDisplayInfoSystemComponent.h index ac6c2bab65..08bec4a1d2 100644 --- a/Gems/AtomLyIntegration/AtomViewportDisplayInfo/Code/Source/AtomViewportDisplayInfoSystemComponent.h +++ b/Gems/AtomLyIntegration/AtomViewportDisplayInfo/Code/Source/AtomViewportDisplayInfoSystemComponent.h @@ -68,6 +68,7 @@ namespace AZ AZStd::string m_rendererDescription; AzFramework::TextDrawParameters m_drawParams; + AzFramework::FontDrawInterface* m_fontDrawInterface = nullptr; float m_lineSpacing; AZStd::chrono::duration m_fpsInterval = AZStd::chrono::seconds(1); AZStd::deque m_fpsHistory;