Camera orbit fix (#3963)

* Fix for camera look-at and position being the same when calculating orbit point

Signed-off-by: hultonha <hultonha@amazon.co.uk>

* add unit test to verify camera orbit behavior

Signed-off-by: hultonha <hultonha@amazon.co.uk>
This commit is contained in:
hultonha
2021-09-08 13:37:06 +01:00
committed by GitHub
parent 5c4ce8cd06
commit 6863e9cf9e
2 changed files with 56 additions and 21 deletions
@@ -588,6 +588,12 @@ namespace AzFramework
// pass through the camera's position and look vector for use in the lookAt function
if (const auto lookAt = lookAtFn(targetCamera.Translation(), targetCamera.Rotation().GetBasisY()))
{
// default to internal look at behavior if the look at point matches the camera translation
if (targetCamera.m_lookAt.IsClose(*lookAt))
{
return false;
}
auto transform = AZ::Transform::CreateLookAt(targetCamera.m_lookAt, *lookAt);
nextCamera.m_lookDist = -lookAt->GetDistance(targetCamera.m_lookAt);
UpdateCameraFromTransform(nextCamera, transform);