Camera Component, Editor Viewport Widget refactoring.

- Handle changing of active camera entirely inside CameraComponentController
- Remove a LOT of legacy Cry things related to cameras
- Add a CameraSystemComponent to handle ActiveCameraRequestBus and CameraSystemRequestBus

Signed-off-by: Yuriy Toporovskyy <toporovskyy.y@gmail.com>
This commit is contained in:
Yuriy Toporovskyy
2021-08-04 10:39:57 -04:00
parent 6d2765ef42
commit 73fee0c57e
47 changed files with 1126 additions and 6046 deletions
@@ -24,7 +24,7 @@ namespace Camera
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<CameraComponentConfig, AZ::ComponentConfig>()
->Version(3)
->Version(4)
->Field("Orthographic", &CameraComponentConfig::m_orthographic)
->Field("Orthographic Half Width", &CameraComponentConfig::m_orthographicHalfWidth)
->Field("Field of View", &CameraComponentConfig::m_fov)
@@ -51,6 +51,7 @@ namespace Camera
->Attribute(AZ::Edit::Attributes::Visibility, &CameraComponentConfig::GetOrthographicParameterVisibility)
->Attribute(AZ::Edit::Attributes::Min, 0.001f)
->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ::Edit::PropertyRefreshLevels::ValuesOnly)
->DataElement(AZ::Edit::UIHandlers::Default, &CameraComponentConfig::m_fov, "Field of view", "Vertical field of view in degrees")
->Attribute(AZ::Edit::Attributes::Min, MIN_FOV)
->Attribute(AZ::Edit::Attributes::Suffix, " degrees")
@@ -130,6 +131,11 @@ namespace Camera
void CameraComponentController::DeactivateAtomView()
{
if (!IsActiveView())
{
return;
}
auto atomViewportRequests = AZ::Interface<AZ::RPI::ViewportContextRequestsInterface>::Get();
if (atomViewportRequests)
{
@@ -413,6 +419,11 @@ namespace Camera
void CameraComponentController::MakeActiveView()
{
if (IsActiveView())
{
return;
}
// Set Legacy Cry view, if it exists
if (m_viewSystem)
{
@@ -433,6 +444,11 @@ namespace Camera
CameraNotificationBus::Broadcast(&CameraNotificationBus::Events::OnActiveViewChanged, m_entityId);
}
bool CameraComponentController::IsActiveView()
{
return AZ::RPI::ViewportContextNotificationBus::Handler::BusIsConnected();
}
void CameraComponentController::OnTransformChanged([[maybe_unused]] const AZ::Transform& local, const AZ::Transform& world)
{
if (m_updatingTransformFromEntity)
@@ -459,6 +475,17 @@ namespace Camera
UpdateCamera();
}
void CameraComponentController::OnViewportDefaultViewChanged(AZ::RPI::ViewPtr view)
{
if (m_atomCamera != view)
{
// Note that when disconnected from this bus, this signals that we are not the active view
// There is nothing else to do here: leave our view on the viewport context stack, don't need
// to update properties. The viewport context system should handle it all!
AZ::RPI::ViewportContextNotificationBus::Handler::BusDisconnect();
}
}
AZ::RPI::ViewPtr CameraComponentController::GetView() const
{
return m_atomCamera;