Fix several viewport issues (#1045)

* Fix some FOV calculation viewport issues:
-Avoid calculating FOV if we've got an invalid viewport
-Don't override game mode FOV, let the active camera components manage it instead

* Fix viewport font positioning

This updates code in a few places to respect an API change/fix made to AtomFont - also switched the default value of m_virtual800x600ScreenSize to false as it's really behavior you want to opt into

* Don't activate CameraComponentController when in the Editor / not in game mode
This commit is contained in:
Nicholas Van Sickle
2021-06-01 12:20:15 -07:00
committed by GitHub
parent 853cf291be
commit 087677b326
6 changed files with 28 additions and 29 deletions
@@ -1328,7 +1328,7 @@ namespace AZ::AtomBridge
params.m_hAlign = center ? AzFramework::TextHorizontalAlignment::Center : AzFramework::TextHorizontalAlignment::Left; //! Horizontal text alignment
params.m_monospace = false; //! disable character proportional spacing
params.m_depthTest = false; //! Test character against the depth buffer
params.m_virtual800x600ScreenSize = true; //! Text placement and size are scaled relative to a virtual 800x600 resolution
params.m_virtual800x600ScreenSize = false; //! Text placement and size are scaled in viewport pixel coordinates
params.m_scaleWithWindow = false; //! Font gets bigger as the window gets bigger
params.m_multiline = true; //! text respects ascii newline characters
@@ -1364,7 +1364,7 @@ namespace AZ::AtomBridge
params.m_hAlign = center ? AzFramework::TextHorizontalAlignment::Center : AzFramework::TextHorizontalAlignment::Left; //! Horizontal text alignment
params.m_monospace = false; //! disable character proportional spacing
params.m_depthTest = false; //! Test character against the depth buffer
params.m_virtual800x600ScreenSize = true; //! Text placement and size are scaled relative to a virtual 800x600 resolution
params.m_virtual800x600ScreenSize = false; //! Text placement and size are scaled in viewport pixel coordinates
params.m_scaleWithWindow = false; //! Font gets bigger as the window gets bigger
params.m_multiline = true; //! text respects ascii newline characters
@@ -162,7 +162,7 @@ namespace AZ::Render
m_drawParams.m_hAlign = AzFramework::TextHorizontalAlignment::Right;
m_drawParams.m_monospace = false;
m_drawParams.m_depthTest = false;
m_drawParams.m_virtual800x600ScreenSize = true;
m_drawParams.m_virtual800x600ScreenSize = false;
m_drawParams.m_scaleWithWindow = false;
m_drawParams.m_multiline = true;
m_drawParams.m_lineSpacing = 0.5f;
@@ -240,7 +240,9 @@ namespace Camera
CameraBus::Handler::BusConnect();
CameraNotificationBus::Broadcast(&CameraNotificationBus::Events::OnCameraAdded, m_entityId);
if (m_config.m_makeActiveViewOnActivation)
// Activate our camera if we're running from the launcher or Editor game mode
// Otherwise, let the Editor keep managing the active camera
if (m_config.m_makeActiveViewOnActivation && (!gEnv || !gEnv->IsEditor() || gEnv->IsEditorGameMode()))
{
MakeActiveView();
}
@@ -34,20 +34,9 @@ namespace Camera
auto controllerConfig = m_controller.GetConfiguration();
controllerConfig.m_editorEntityId = GetEntityId().operator AZ::u64();
// The Editor manages active camera state, so while we're in Editor we explicitly
// disable the request to make this the active view at edit component activation time.
bool prevShouldActivateViewOnActivation = controllerConfig.m_makeActiveViewOnActivation;
controllerConfig.m_makeActiveViewOnActivation = false;
m_controller.SetConfiguration(controllerConfig);
// Call base class activate, which in turn calls Activate on our controller.
EditorCameraComponentBase::Activate();
// Reset the original `m_makeActiveViewOnActivation' setting, so that the intended value is serialized, used in BuildGameEntity, etc.
controllerConfig.m_makeActiveViewOnActivation = prevShouldActivateViewOnActivation;
m_controller.SetConfiguration(controllerConfig);
AzFramework::EntityDebugDisplayEventBus::Handler::BusConnect(GetEntityId());
EditorCameraNotificationBus::Handler::BusConnect();
EditorCameraViewRequestBus::Handler::BusConnect(GetEntityId());