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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user