Prevent the camera from easily being set to an invalid orientation (#6203)
* add temporary debug logging Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * improvement for box select sometimes getting stuck on Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * add temporary debug logging Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * improvement for box select sometimes getting stuck on Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * remove temporary logging Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * fixes for camera pitch issues Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * missed file with camera pitch fixes Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * remove debug logs Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com> * add some tests for new pitch constraint updates Signed-off-by: Tom Hulton-Harrop <82228511+hultonha@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
a8ef23e4ae
commit
b54215552c
@@ -15,6 +15,8 @@
|
||||
#include <AzToolsFramework/ToolsComponents/TransformComponent.h>
|
||||
#include <EditorModularViewportCameraComposer.h>
|
||||
|
||||
#include <GotoPositionDlg.h>
|
||||
|
||||
namespace UnitTest
|
||||
{
|
||||
class EditorCameraFixture : public ::testing::Test
|
||||
@@ -257,4 +259,35 @@ namespace UnitTest
|
||||
EXPECT_THAT(interpolating, ::testing::IsFalse());
|
||||
EXPECT_THAT(nextInterpolationBegan, ::testing::IsTrue());
|
||||
}
|
||||
|
||||
TEST(GotoPositionPitchConstraints, GoToPositionPitchIsSetToPlusOrMinusNinetyDegrees)
|
||||
{
|
||||
float minPitch = 0.0f;
|
||||
float maxPitch = 0.0f;
|
||||
|
||||
GotoPositionPitchConstraints m_gotoPositionContraints;
|
||||
m_gotoPositionContraints.DeterminePitchRange(
|
||||
[&minPitch, &maxPitch](const float minPitchDegrees, const float maxPitchDegrees)
|
||||
{
|
||||
minPitch = minPitchDegrees;
|
||||
maxPitch = maxPitchDegrees;
|
||||
});
|
||||
|
||||
using ::testing::FloatNear;
|
||||
EXPECT_THAT(minPitch, FloatNear(-90.0f, AZ::Constants::FloatEpsilon));
|
||||
EXPECT_THAT(maxPitch, FloatNear(90.0f, AZ::Constants::FloatEpsilon));
|
||||
}
|
||||
|
||||
TEST(GotoPositionPitchConstraints, GoToPositionPitchClampsFinalPitchValueWithTolerance)
|
||||
{
|
||||
const auto [expectedMinPitchRadians, expectedMaxPitchRadians] = AzFramework::CameraPitchMinMaxRadiansWithTolerance();
|
||||
|
||||
GotoPositionPitchConstraints m_gotoPositionContraints;
|
||||
const float minClampedPitchRadians = m_gotoPositionContraints.PitchClampedRadians(-90.0f);
|
||||
const float maxClampedPitchRadians = m_gotoPositionContraints.PitchClampedRadians(90.0f);
|
||||
|
||||
using ::testing::FloatNear;
|
||||
EXPECT_THAT(minClampedPitchRadians, FloatNear(expectedMinPitchRadians, AZ::Constants::FloatEpsilon));
|
||||
EXPECT_THAT(maxClampedPitchRadians, FloatNear(expectedMaxPitchRadians, AZ::Constants::FloatEpsilon));
|
||||
}
|
||||
} // namespace UnitTest
|
||||
|
||||
Reference in New Issue
Block a user