Merging upstream

Signed-off-by: Dayo Lawal <lawalfua@amazon.com>
This commit is contained in:
Dayo Lawal
2021-08-05 14:20:25 -05:00
598 changed files with 11008 additions and 7322 deletions
@@ -96,7 +96,10 @@ namespace AtomToolsFramework
void OnExceptionMessage(AZStd::string_view message) override;
////////////////////////////////////////////////////////////////////////
//! Executable target name generally used as a prefix for logging and other saved files
virtual AZStd::string GetBuildTargetName() const;
//! List of filters for assets that need to be pre-built to run the application
virtual AZStd::vector<AZStd::string> GetCriticalAssetFilters() const;
virtual void LoadSettings();
@@ -16,37 +16,62 @@
namespace AtomToolsFramework
{
class ModernViewportCameraControllerInstance;
class ModularViewportCameraControllerInstance;
//! A function object to represent returning a camera controller priority.
using CameraControllerPriorityFn =
AZStd::function<AzFramework::ViewportControllerPriority(const AzFramework::CameraSystem& cameraSystem)>;
//! The default behavior for what priority the camera controller should respond to events at.
//! @note This can change based on the state of the camera controller/system.
AzFramework::ViewportControllerPriority DefaultCameraControllerPriority(const AzFramework::CameraSystem& cameraSystem);
//! Builder class to create and configure a ModularViewportCameraControllerInstance.
class ModularViewportCameraController
: public AzFramework::MultiViewportController<
ModernViewportCameraControllerInstance, AzFramework::ViewportControllerPriority::DispatchToAllPriorities>
ModularViewportCameraControllerInstance,
AzFramework::ViewportControllerPriority::DispatchToAllPriorities>
{
public:
friend ModularViewportCameraControllerInstance;
using CameraListBuilder = AZStd::function<void(AzFramework::Cameras&)>;
using CameraPropsBuilder = AZStd::function<void(AzFramework::CameraProps&)>;
using CameraPriorityBuilder = AZStd::function<void(CameraControllerPriorityFn&)>;
//! Sets the camera list builder callback used to populate new ModernViewportCameraControllerInstances
//! Sets the camera list builder callback used to populate new ModularViewportCameraControllerInstances.
void SetCameraListBuilderCallback(const CameraListBuilder& builder);
//! Sets the camera props builder callback used to populate new ModernViewportCameraControllerInstances
//! Sets the camera props builder callback used to populate new ModularViewportCameraControllerInstances.
void SetCameraPropsBuilderCallback(const CameraPropsBuilder& builder);
//! Sets up a camera list based on this controller's CameraListBuilderCallback
void SetupCameras(AzFramework::Cameras& cameras);
//! Sets up properties shared across all cameras
void SetupCameraProperies(AzFramework::CameraProps& cameraProps);
//! Sets the camera controller priority builder callback used to populate new ModularViewportCameraControllerInstances.
void SetCameraPriorityBuilderCallback(const CameraPriorityBuilder& builder);
private:
//! Sets up a camera list based on this controller's CameraListBuilderCallback.
void SetupCameras(AzFramework::Cameras& cameras);
//! Sets up properties shared across all cameras.
void SetupCameraProperties(AzFramework::CameraProps& cameraProps);
//! Sets up how the camera controller should decide at what priority level to respond to.
void SetupCameraControllerPriority(CameraControllerPriorityFn& cameraPriorityFn);
//! Builder to generate a list of CameraInputs to run in the ModularViewportCameraControllerInstance.
CameraListBuilder m_cameraListBuilder;
//! Builder to define custom camera properties to use for things such as rotate and translate interpolation.
CameraPropsBuilder m_cameraPropsBuilder;
//! Builder to define what priority level the camera controller should respond to events at.
CameraPriorityBuilder m_cameraControllerPriorityBuilder;
};
class ModernViewportCameraControllerInstance final
: public AzFramework::MultiViewportControllerInstanceInterface<ModularViewportCameraController>,
public ModularViewportCameraControllerRequestBus::Handler,
private AzFramework::ViewportDebugDisplayEventBus::Handler
//! A customizable camera controller that can be configured to run a varying set of CameraInput instances.
//! The controller can also be animated from its current transform to a new translation and orientation.
class ModularViewportCameraControllerInstance final
: public AzFramework::MultiViewportControllerInstanceInterface<ModularViewportCameraController>
, public ModularViewportCameraControllerRequestBus::Handler
, private AzFramework::ViewportDebugDisplayEventBus::Handler
{
public:
explicit ModernViewportCameraControllerInstance(AzFramework::ViewportId viewportId, ModularViewportCameraController* controller);
~ModernViewportCameraControllerInstance() override;
explicit ModularViewportCameraControllerInstance(AzFramework::ViewportId viewportId, ModularViewportCameraController* controller);
~ModularViewportCameraControllerInstance() override;
// MultiViewportControllerInstanceInterface overrides ...
bool HandleInputChannelEvent(const AzFramework::ViewportControllerInputEvent& event) override;
@@ -60,25 +85,35 @@ namespace AtomToolsFramework
// AzFramework::ViewportDebugDisplayEventBus overrides ...
void DisplayViewport(const AzFramework::ViewportInfo& viewportInfo, AzFramework::DebugDisplayRequests& debugDisplay) override;
//! The current mode the camera controller is in.
enum class CameraMode
{
Control,
Animation
Control, //!< The camera is being driven by user input.
Animation //!< The camera is being animated (interpolated) from one transform to another.
};
AzFramework::Camera m_camera;
AzFramework::Camera m_targetCamera;
AzFramework::CameraSystem m_cameraSystem;
AzFramework::CameraProps m_cameraProps;
//! Encapsulates an animation (interpolation) between two transforms.
struct CameraAnimation
{
//! The transform of the camera at the start of the animation.
AZ::Transform m_transformStart = AZ::Transform::CreateIdentity();
AZ::Transform m_transformEnd = AZ::Transform::CreateIdentity(); //!< The transform of the camera at the end of the animation.
float m_time = 0.0f; //!< The interpolation amount between the start and end transforms (in the range 0.0 - 1.0).
};
AZ::Transform m_transformStart = AZ::Transform::CreateIdentity();
AZ::Transform m_transformEnd = AZ::Transform::CreateIdentity();
float m_animationT = 0.0f;
CameraMode m_cameraMode = CameraMode::Control;
AzFramework::Camera m_camera; //!< The current camera state (pitch/yaw/position/look-distance).
AzFramework::Camera m_targetCamera; //!< The target (next) camera state that m_camera is catching up to.
AzFramework::CameraSystem m_cameraSystem; //!< The camera system responsible for managing all CameraInputs.
AzFramework::CameraProps m_cameraProps; //!< Camera properties to control rotate and translate smoothness.
CameraControllerPriorityFn m_priorityFn; //!< Controls at what priority the camera controller should respond to events.
CameraAnimation m_cameraAnimation; //!< Camera animation state (used during CameraMode::Animation).
CameraMode m_cameraMode = CameraMode::Control; //!< The current mode the camera is operating in.
AZStd::optional<AZ::Vector3> m_lookAtAfterInterpolation; //!< The look at point after an interpolation has finished.
//!< Will be cleared when the view changes (camera looks away).
bool m_updatingTransform = false;
//! Flag to prevent circular updates of the camera transform (while the viewport transform is being updated internally).
bool m_updatingTransformInternally = false;
//! Listen for camera view changes outside of the camera controller.
AZ::RPI::ViewportContext::MatrixChangedEvent::Handler m_cameraViewMatrixChangeHandler;
};
} // namespace AtomToolsFramework