Merge pull request #708 from aws-lumberyard-dev/Atom/breja/FixDefaultDebugDrawId

Fix AzFramework::g_defaultSceneEntityDebugDisplayId not working for the AtomDebugDisplayViewportInstance
This commit is contained in:
rgba16f
2021-05-17 10:26:40 -05:00
committed by GitHub
2 changed files with 23 additions and 24 deletions
@@ -452,6 +452,15 @@ void EditorViewportWidget::Update()
return;
}
static bool sentOnWindowCreated = false;
if (!sentOnWindowCreated && windowHandle()->isActive())
{
sentOnWindowCreated = true;
AzFramework::WindowSystemNotificationBus::Broadcast(
&AzFramework::WindowSystemNotificationBus::Handler::OnWindowCreated,
reinterpret_cast<AzFramework::NativeWindowHandle>(winId()));
}
m_updatingCameraPosition = true;
if (!ed_useNewCameraSystem)
{
@@ -91,13 +91,9 @@ namespace AZ
AZ_UNUSED(dependent);
}
static const AZ::Crc32 mainViewportEntityDebugDisplayId = AZ_CRC_CE("MainViewportEntityDebugDisplayId");
void AtomBridgeSystemComponent::Init()
{
#if defined(ENABLE_ATOM_DEBUG_DISPLAY) && ENABLE_ATOM_DEBUG_DISPLAY
AZ::RPI::ViewportContextManagerNotificationsBus::Handler::BusConnect();
#endif
}
void AtomBridgeSystemComponent::Activate()
@@ -112,9 +108,7 @@ namespace AZ
void AtomBridgeSystemComponent::Deactivate()
{
#if defined(ENABLE_ATOM_DEBUG_DISPLAY) && ENABLE_ATOM_DEBUG_DISPLAY
AZ::RPI::ViewportContextManagerNotificationsBus::Handler::BusDisconnect();
#endif
RPI::Scene* scene = RPI::RPISystemInterface::Get()->GetDefaultScene().get();
// Check if scene is emptry since scene might be released already when running AtomSampleViewer
if (scene)
@@ -193,36 +187,32 @@ namespace AZ
renderPipeline = bootstrapScene->GetDefaultRenderPipeline();
renderPipeline->SetDefaultView(m_view);
auto auxGeomFP = bootstrapScene->GetFeatureProcessor<RPI::AuxGeomFeatureProcessorInterface>();
if (auxGeomFP)
{
auxGeomFP->GetOrCreateDrawQueueForView(m_view.get());
}
#if defined(ENABLE_ATOM_DEBUG_DISPLAY) && ENABLE_ATOM_DEBUG_DISPLAY
// Make default AtomDebugDisplayViewportInterface for the scene
AZStd::shared_ptr<AtomDebugDisplayViewportInterface> mainEntityDebugDisplay = AZStd::make_shared<AtomDebugDisplayViewportInterface>(mainViewportEntityDebugDisplayId);
m_activeViewportsList[mainViewportEntityDebugDisplayId] = mainEntityDebugDisplay;
#endif
}
else
{
m_view = renderPipeline->GetDefaultView();
}
auto auxGeomFP = bootstrapScene->GetFeatureProcessor<RPI::AuxGeomFeatureProcessorInterface>();
if (auxGeomFP)
{
auxGeomFP->GetOrCreateDrawQueueForView(m_view.get());
}
// Make default AtomDebugDisplayViewportInterface for the scene
AZStd::shared_ptr<AtomDebugDisplayViewportInterface> mainEntityDebugDisplay = AZStd::make_shared<AtomDebugDisplayViewportInterface>(AzFramework::g_defaultSceneEntityDebugDisplayId);
m_activeViewportsList[AzFramework::g_defaultSceneEntityDebugDisplayId] = mainEntityDebugDisplay;
}
void AtomBridgeSystemComponent::OnViewportContextAdded(AZ::RPI::ViewportContextPtr viewportContext)
{
#if defined(ENABLE_ATOM_DEBUG_DISPLAY) && ENABLE_ATOM_DEBUG_DISPLAY
AZStd::shared_ptr<AtomDebugDisplayViewportInterface> viewportDebugDisplay = AZStd::make_shared<AtomDebugDisplayViewportInterface>(viewportContext);
m_activeViewportsList[viewportContext->GetId()] = viewportDebugDisplay;
#endif
}
void AtomBridgeSystemComponent::OnViewportContextRemoved(AzFramework::ViewportId viewportId)
{
#if defined(ENABLE_ATOM_DEBUG_DISPLAY) && ENABLE_ATOM_DEBUG_DISPLAY
AZ_Assert(viewportId != AzFramework::g_defaultSceneEntityDebugDisplayId, "Error trying to remove the default scene draw instance");
m_activeViewportsList.erase(viewportId);
#else
AZ_UNUSED(viewportId);
#endif
}