Camera fixes follow-up (#5703)
* allow unconstrained camera when tracking transform and fix some camera interpolation issues Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * tests for interpolation fixes Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * add test for camera constraints change Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * updates following review feeedback Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
9f9aa8f2a6
commit
593f03efb4
+2
-1
@@ -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;
|
||||
|
||||
+8
-1
@@ -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.
|
||||
|
||||
+19
-4
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user