Entering the Game Mode when the SlideAlongAxisBasedOnAngle in the Camera Rig is set results in an assert (#5410)
* Fixed assert and added None behavior. Signed-off-by: AMZN-Igarri <82394219+AMZN-Igarri@users.noreply.github.com> * cleaned up file Signed-off-by: AMZN-Igarri <82394219+AMZN-Igarri@users.noreply.github.com> * Switched over to checkboxes Signed-off-by: AMZN-Igarri <82394219+AMZN-Igarri@users.noreply.github.com> * Fixed naming. Signed-off-by: AMZN-Igarri <82394219+AMZN-Igarri@users.noreply.github.com> * Fixed naming Signed-off-by: AMZN-Igarri <82394219+AMZN-Igarri@users.noreply.github.com> * Fixed serialize version and zero vector normalization Signed-off-by: AMZN-Igarri <82394219+AMZN-Igarri@users.noreply.github.com> * Cleaned up format. Signed-off-by: AMZN-Igarri <82394219+AMZN-Igarri@users.noreply.github.com> * Fixed Warnings Signed-off-by: AMZN-Igarri <82394219+AMZN-Igarri@users.noreply.github.com>
This commit is contained in:
-11
@@ -24,17 +24,6 @@ namespace Camera
|
||||
Z_Axis = 2
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// These are intended to be used as an index and needs to be implicitly
|
||||
/// convertible to int. See StartingPointCameraUtilities.h for examples
|
||||
enum VectorComponentType : int
|
||||
{
|
||||
X_Component = 0,
|
||||
Y_Component = 1,
|
||||
Z_Component = 2,
|
||||
None = 3,
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// These are intended to be used as an index and needs to be implicitly
|
||||
/// convertible to int. See StartingPointCameraUtilities.h for examples
|
||||
|
||||
+5
-13
@@ -16,24 +16,16 @@ namespace Camera
|
||||
{
|
||||
const char* GetNameFromUuid(const AZ::Uuid& uuid);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// This methods will 0 out a vector component and re-normalize it
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void MaskComponentFromNormalizedVector(AZ::Vector3& v, VectorComponentType vectorComponentType);
|
||||
//! This methods will 0 out specified vector components and re-normalize it
|
||||
void MaskComponentFromNormalizedVector(AZ::Vector3& v, bool ignoreX, bool ignoreY, bool ignoreZ);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// This will calculate the requested Euler angle from a given AZ::Quaternion
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! This will calculate the requested Euler angle from a given AZ::Quaternion
|
||||
float GetEulerAngleFromTransform(const AZ::Transform& rotation, EulerAngleType eulerAngleType);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// This will calculate an AZ::Transform based on an Euler angle
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! This will calculate an AZ::Transform based on an Euler angle
|
||||
AZ::Transform CreateRotationFromEulerAngle(EulerAngleType rotationType, float radians);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Creates the Quaternion representing the rotation looking down the vector
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//! Creates the Quaternion representing the rotation looking down the vector
|
||||
AZ::Quaternion CreateQuaternionFromViewVector(const AZ::Vector3 lookVector);
|
||||
|
||||
} //namespace Camera
|
||||
|
||||
+12
-9
@@ -20,10 +20,12 @@ namespace Camera
|
||||
if (serializeContext)
|
||||
{
|
||||
serializeContext->Class<SlideAlongAxisBasedOnAngle>()
|
||||
->Version(1)
|
||||
->Version(2)
|
||||
->Field("Axis to slide along", &SlideAlongAxisBasedOnAngle::m_axisToSlideAlong)
|
||||
->Field("Angle Type", &SlideAlongAxisBasedOnAngle::m_angleTypeToChangeFor)
|
||||
->Field("Vector Component To Ignore", &SlideAlongAxisBasedOnAngle::m_vectorComponentToIgnore)
|
||||
->Field("Ignore X Component", &SlideAlongAxisBasedOnAngle::m_ignoreX)
|
||||
->Field("Ignore Y Component", &SlideAlongAxisBasedOnAngle::m_ignoreY)
|
||||
->Field("Ignore Z Component", &SlideAlongAxisBasedOnAngle::m_ignoreZ)
|
||||
->Field("Max Positive Slide Distance", &SlideAlongAxisBasedOnAngle::m_maximumPositiveSlideDistance)
|
||||
->Field("Max Negative Slide Distance", &SlideAlongAxisBasedOnAngle::m_maximumNegativeSlideDistance);
|
||||
|
||||
@@ -40,15 +42,16 @@ namespace Camera
|
||||
->EnumAttribute(EulerAngleType::Pitch, "Pitch")
|
||||
->EnumAttribute(EulerAngleType::Roll, "Roll")
|
||||
->EnumAttribute(EulerAngleType::Yaw, "Yaw")
|
||||
->DataElement(AZ::Edit::UIHandlers::ComboBox, &SlideAlongAxisBasedOnAngle::m_vectorComponentToIgnore, "Vector Component To Ignore", "The Vector Component To Ignore")
|
||||
->EnumAttribute(VectorComponentType::None, "None")
|
||||
->EnumAttribute(VectorComponentType::X_Component, "X")
|
||||
->EnumAttribute(VectorComponentType::Y_Component, "Y")
|
||||
->EnumAttribute(VectorComponentType::Z_Component, "Z")
|
||||
->DataElement(0, &SlideAlongAxisBasedOnAngle::m_maximumPositiveSlideDistance, "Max Positive Slide Distance", "The maximum distance to slide in the positive")
|
||||
->Attribute(AZ::Edit::Attributes::Suffix, "m")
|
||||
->DataElement(0, &SlideAlongAxisBasedOnAngle::m_maximumNegativeSlideDistance, "Max Negative Slide Distance", "The maximum distance to slide in the negative")
|
||||
->Attribute(AZ::Edit::Attributes::Suffix, "m");
|
||||
->Attribute(AZ::Edit::Attributes::Suffix, "m")
|
||||
->ClassElement(AZ::Edit::ClassElements::Group, "Vector Components To Ignore")
|
||||
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
|
||||
->DataElement(0, &SlideAlongAxisBasedOnAngle::m_ignoreX, "X", "When active, the X Component will be ignored.")
|
||||
->DataElement(0, &SlideAlongAxisBasedOnAngle::m_ignoreY, "Y", "When active, the Y Component will be ignored.")
|
||||
->DataElement(0, &SlideAlongAxisBasedOnAngle::m_ignoreZ, "Z", "When active, the Z Component will be ignored.")
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,7 +63,7 @@ namespace Camera
|
||||
float slideScale = currentPositionOnRange > 0.0f ? m_maximumPositiveSlideDistance : m_maximumNegativeSlideDistance;
|
||||
|
||||
AZ::Vector3 basis = outLookAtTargetTransform.GetBasis(m_axisToSlideAlong);
|
||||
MaskComponentFromNormalizedVector(basis, m_vectorComponentToIgnore);
|
||||
MaskComponentFromNormalizedVector(basis, m_ignoreX, m_ignoreY, m_ignoreZ);
|
||||
|
||||
outLookAtTargetTransform.SetTranslation(outLookAtTargetTransform.GetTranslation() + basis * currentPositionOnRange * slideScale);
|
||||
}
|
||||
|
||||
+3
-1
@@ -43,8 +43,10 @@ namespace Camera
|
||||
// Reflected data
|
||||
RelativeAxisType m_axisToSlideAlong = ForwardBackward;
|
||||
EulerAngleType m_angleTypeToChangeFor = Pitch;
|
||||
VectorComponentType m_vectorComponentToIgnore = None;
|
||||
float m_maximumPositiveSlideDistance = 0.0f;
|
||||
float m_maximumNegativeSlideDistance = 0.0f;
|
||||
bool m_ignoreX = false;
|
||||
bool m_ignoreY = false;
|
||||
bool m_ignoreZ = false;
|
||||
};
|
||||
} // namespace Camera
|
||||
|
||||
+14
-26
@@ -26,38 +26,32 @@ namespace Camera
|
||||
return "";
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// This methods will 0 out a vector component and re-normalize it
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void MaskComponentFromNormalizedVector(AZ::Vector3& v, VectorComponentType vectorComponentType)
|
||||
void MaskComponentFromNormalizedVector(AZ::Vector3& v, bool ignoreX, bool ignoreY, bool ignoreZ)
|
||||
{
|
||||
switch (vectorComponentType)
|
||||
{
|
||||
case X_Component:
|
||||
|
||||
if (ignoreX)
|
||||
{
|
||||
v.SetX(0.f);
|
||||
break;
|
||||
}
|
||||
case Y_Component:
|
||||
|
||||
if (ignoreY)
|
||||
{
|
||||
v.SetY(0.f);
|
||||
break;
|
||||
}
|
||||
case Z_Component:
|
||||
|
||||
if (ignoreZ)
|
||||
{
|
||||
v.SetZ(0.f);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
AZ_Assert(false, "MaskComponentFromNormalizedVector: VectorComponentType - unexpected value");
|
||||
break;
|
||||
|
||||
if (v.IsZero())
|
||||
{
|
||||
AZ_Warning("StartingPointCameraUtilities", false, "MaskComponentFromNormalizedVector: trying to normalize zero vector.")
|
||||
return;
|
||||
}
|
||||
v.Normalize();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// This will calculate the requested Euler angle from a given AZ::Quaternion
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
float GetEulerAngleFromTransform(const AZ::Transform& rotation, EulerAngleType eulerAngleType)
|
||||
{
|
||||
AZ::Vector3 angles = rotation.GetEulerDegrees();
|
||||
@@ -70,14 +64,11 @@ namespace Camera
|
||||
case Yaw:
|
||||
return angles.GetZ();
|
||||
default:
|
||||
AZ_Warning("", false, "GetEulerAngleFromRotation: eulerAngleType - value not supported");
|
||||
AZ_Warning("StartingPointCameraUtilities", false, "GetEulerAngleFromRotation: eulerAngleType - value not supported");
|
||||
return 0.f;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// This will calculate an AZ::Transform based on an Euler angle
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
AZ::Transform CreateRotationFromEulerAngle(EulerAngleType rotationType, float radians)
|
||||
{
|
||||
switch (rotationType)
|
||||
@@ -89,14 +80,11 @@ namespace Camera
|
||||
case Yaw:
|
||||
return AZ::Transform::CreateRotationZ(radians);
|
||||
default:
|
||||
AZ_Warning("", false, "CreateRotationFromEulerAngle: rotationType - value not supported");
|
||||
AZ_Warning("StartingPointCameraUtilities", false, "CreateRotationFromEulerAngle: rotationType - value not supported");
|
||||
return AZ::Transform::Identity();
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// Creates the Quaternion representing the rotation looking down the vector
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
AZ::Quaternion CreateQuaternionFromViewVector(const AZ::Vector3 lookVector)
|
||||
{
|
||||
float twoDimensionLength = AZ::Vector2(lookVector.GetX(), lookVector.GetY()).GetLength();
|
||||
|
||||
Reference in New Issue
Block a user