Fix ImGui rendering in-Editor
-Ensure ViewportContext rendertick notifications always fire -Use viewport size to determine ImGui resolution, ensure OnViewportSizeChanged is always up-to-date for the default viewport context
This commit is contained in:
@@ -77,6 +77,8 @@ namespace AZ
|
||||
void OnRenderPipelineAdded(RenderPipelinePtr pipeline) override;
|
||||
//! Ensures our default view remains set when our scene's render pipelines are modified.
|
||||
void OnRenderPipelineRemoved(RenderPipeline* pipeline) override;
|
||||
//! OnBeginPrepareRender is forwarded to our RenderTick notification to allow subscribers to do rendering.
|
||||
void OnBeginPrepareRender() override;
|
||||
|
||||
//WindowNotificationBus interface
|
||||
//! Used to fire a notification when our window resizes
|
||||
|
||||
@@ -104,12 +104,16 @@ namespace AZ
|
||||
// add the current pipeline to next render tick if it's not already added.
|
||||
if (m_currentPipeline && m_currentPipeline->GetRenderMode() != RenderPipeline::RenderMode::RenderOnce)
|
||||
{
|
||||
ViewportContextNotificationBus::Event(GetName(), &ViewportContextNotificationBus::Events::OnRenderTick);
|
||||
ViewportContextIdNotificationBus::Event(GetId(), &ViewportContextIdNotificationBus::Events::OnRenderTick);
|
||||
m_currentPipeline->AddToRenderTickOnce();
|
||||
}
|
||||
}
|
||||
|
||||
void ViewportContext::OnBeginPrepareRender()
|
||||
{
|
||||
ViewportContextNotificationBus::Event(GetName(), &ViewportContextNotificationBus::Events::OnRenderTick);
|
||||
ViewportContextIdNotificationBus::Event(GetId(), &ViewportContextIdNotificationBus::Events::OnRenderTick);
|
||||
}
|
||||
|
||||
AZ::Name ViewportContext::GetName() const
|
||||
{
|
||||
return m_name;
|
||||
|
||||
@@ -57,9 +57,14 @@ namespace AZ
|
||||
return;
|
||||
}
|
||||
viewportData.context = viewportContext;
|
||||
auto onSizeChanged = [contextName, viewportId](AzFramework::WindowSize size)
|
||||
auto onSizeChanged = [this, viewportId](AzFramework::WindowSize size)
|
||||
{
|
||||
ViewportContextNotificationBus::Event(contextName, &ViewportContextNotificationBus::Events::OnViewportSizeChanged, size);
|
||||
// Ensure we emit OnViewportSizeChanged with the correct name.
|
||||
auto viewportContext = this->GetViewportContextById(viewportId);
|
||||
if (viewportContext)
|
||||
{
|
||||
ViewportContextNotificationBus::Event(viewportContext->GetName(), &ViewportContextNotificationBus::Events::OnViewportSizeChanged, size);
|
||||
}
|
||||
ViewportContextIdNotificationBus::Event(viewportId, &ViewportContextIdNotificationBus::Events::OnViewportSizeChanged, size);
|
||||
};
|
||||
viewportContext->m_name = contextName;
|
||||
@@ -174,6 +179,8 @@ namespace AZ
|
||||
GetOrCreateViewStackForContext(newContextName);
|
||||
viewportContext->m_name = newContextName;
|
||||
UpdateViewForContext(newContextName);
|
||||
// Ensure anyone listening on per-name viewport size updates gets notified.
|
||||
ViewportContextNotificationBus::Event(newContextName, &ViewportContextNotificationBus::Events::OnViewportSizeChanged, viewportContext->GetViewportSize());
|
||||
}
|
||||
|
||||
void ViewportContextManager::EnumerateViewportContexts(AZStd::function<void(ViewportContextPtr)> visitorFunction)
|
||||
|
||||
Reference in New Issue
Block a user