Merge commit '593f03efb4996ae8bb8e1f53a55e2ba00e022449' into puvvadar/gitflow_211118_o3de

This commit is contained in:
puvvadar
2021-11-18 09:37:11 -08:00
10 changed files with 197 additions and 29 deletions
@@ -112,7 +112,8 @@ namespace AtomToolsFramework
void UpdateViewport(const AzFramework::ViewportControllerUpdateEvent& event) override;
// ModularViewportCameraControllerRequestBus overrides ...
void InterpolateToTransform(const AZ::Transform& worldFromLocal) override;
bool InterpolateToTransform(const AZ::Transform& worldFromLocal) override;
bool IsInterpolating() const override;
void StartTrackingTransform(const AZ::Transform& worldFromLocal) override;
void StopTrackingTransform() override;
bool IsTrackingTransform() const override;
@@ -23,13 +23,20 @@ namespace AtomToolsFramework
class ModularViewportCameraControllerRequests : public AZ::EBusTraits
{
public:
static inline constexpr float InterpolateToTransformDuration = 1.0f;
using BusIdType = AzFramework::ViewportId;
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
//! Begin a smooth transition of the camera to the requested transform.
//! @param worldFromLocal The transform of where the camera should end up.
virtual void InterpolateToTransform(const AZ::Transform& worldFromLocal) = 0;
//! @return Returns true if the call began an interpolation and false otherwise. Calls to InterpolateToTransform
//! will have no effect if an interpolation is currently in progress.
virtual bool InterpolateToTransform(const AZ::Transform& worldFromLocal) = 0;
//! Returns if the camera is currently interpolating to a new transform.
virtual bool IsInterpolating() const = 0;
//! Start tracking a transform.
//! Store the current camera transform and move to the next camera transform.
@@ -235,7 +235,10 @@ namespace AtomToolsFramework
return t * t * t * (t * (t * 6.0f - 15.0f) + 10.0f);
};
m_cameraAnimation.m_time = AZ::GetClamp(m_cameraAnimation.m_time + event.m_deltaTime.count(), 0.0f, 1.0f);
m_cameraAnimation.m_time = AZ::GetClamp(
m_cameraAnimation.m_time +
(event.m_deltaTime.count() / ModularViewportCameraControllerRequests::InterpolateToTransformDuration),
0.0f, 1.0f);
const auto& [transformStart, transformEnd, animationTime] = m_cameraAnimation;
@@ -263,10 +266,22 @@ namespace AtomToolsFramework
m_updatingTransformInternally = false;
}
void ModularViewportCameraControllerInstance::InterpolateToTransform(const AZ::Transform& worldFromLocal)
bool ModularViewportCameraControllerInstance::InterpolateToTransform(const AZ::Transform& worldFromLocal)
{
m_cameraMode = CameraMode::Animation;
m_cameraAnimation = CameraAnimation{ CombinedCameraTransform(), worldFromLocal, 0.0f };
if (!IsInterpolating())
{
m_cameraMode = CameraMode::Animation;
m_cameraAnimation = CameraAnimation{ CombinedCameraTransform(), worldFromLocal, 0.0f };
return true;
}
return false;
}
bool ModularViewportCameraControllerInstance::IsInterpolating() const
{
return m_cameraMode == CameraMode::Animation;
}
void ModularViewportCameraControllerInstance::StartTrackingTransform(const AZ::Transform& worldFromLocal)