Merge pull request #1039 from aws-lumberyard-dev/transform-float-scale-3

refactor vector scale in Transform to float scale
This commit is contained in:
greerdv
2021-05-28 21:20:03 +01:00
committed by GitHub
38 changed files with 254 additions and 386 deletions
@@ -2527,15 +2527,15 @@ namespace ScriptCanvas
{
Data::TransformType copy(source);
AZ::Vector3 pos = copy.GetTranslation();
AZ::Vector3 scale = copy.ExtractScale();
float scale = copy.ExtractUniformScale();
AZ::Vector3 rotation = AZ::ConvertTransformToEulerDegrees(copy);
return AZStd::string::format
( "(Position: X: %f, Y: %f, Z: %f,"
" Rotation: X: %f, Y: %f, Z: %f,"
" Scale: X: %f, Y: %f, Z: %f)"
" Scale: %f)"
, static_cast<float>(pos.GetX()), static_cast<float>(pos.GetY()), static_cast<float>(pos.GetZ())
, static_cast<float>(rotation.GetX()), static_cast<float>(rotation.GetY()), static_cast<float>(rotation.GetZ())
, static_cast<float>(scale.GetX()), static_cast<float>(scale.GetY()), static_cast<float>(scale.GetZ()));
, scale);
}
AZStd::string Datum::ToStringVector2(const AZ::Vector2& source) const
@@ -26,12 +26,12 @@ namespace ScriptCanvas
using namespace MathNodeUtilities;
static const char* k_categoryName = "Math/Transform";
AZ_INLINE std::tuple<Vector3Type, TransformType> ExtractScale(TransformType source)
AZ_INLINE std::tuple<NumberType, TransformType> ExtractUniformScale(TransformType source)
{
auto scale(source.ExtractScale());
auto scale(source.ExtractUniformScale());
return std::make_tuple( scale, source );
}
SCRIPT_CANVAS_GENERIC_FUNCTION_MULTI_RESULTS_NODE(ExtractScale, k_categoryName, "{8DFE5247-0950-4CD1-87E6-0CAAD42F1637}", "returns a vector which is the length of the scale components, and a transform with the scale extracted ", "Source", "Scale", "Extracted");
SCRIPT_CANVAS_GENERIC_FUNCTION_MULTI_RESULTS_NODE(ExtractUniformScale, k_categoryName, "{8DFE5247-0950-4CD1-87E6-0CAAD42F1637}", "returns the uniform scale as a float, and a transform with the scale extracted ", "Source", "Uniform Scale", "Extracted");
AZ_INLINE TransformType FromMatrix3x3(Matrix3x3Type source)
{
@@ -57,11 +57,11 @@ namespace ScriptCanvas
}
SCRIPT_CANVAS_GENERIC_FUNCTION_NODE(FromRotationAndTranslation, k_categoryName, "{99A4D55D-6EFB-4E24-8113-F5B46DE3A194}", "returns a transform from the rotation and the translation", "Rotation", "Translation");
AZ_INLINE TransformType FromScale(Vector3Type scale)
AZ_INLINE TransformType FromScale(NumberType scale)
{
return TransformType::CreateScale(scale);
return TransformType::CreateUniformScale(scale);
}
SCRIPT_CANVAS_GENERIC_FUNCTION_NODE(FromScale, k_categoryName, "{4B6454BC-015C-41BB-9C78-34ADBCF70187}", "returns a scale matrix and the translation set to zero", "Scale");
SCRIPT_CANVAS_GENERIC_FUNCTION_NODE(FromScale, k_categoryName, "{4B6454BC-015C-41BB-9C78-34ADBCF70187}", "returns a transform which applies the specified uniform Scale, but no rotation or translation", "Scale");
AZ_INLINE TransformType FromTranslation(Vector3Type translation)
{
@@ -145,12 +145,12 @@ namespace ScriptCanvas
}
SCRIPT_CANVAS_GENERIC_FUNCTION_NODE(Multiply3x3ByVector3, k_categoryName, "{4F2ABFC6-2E93-4A9D-8639-C7967DB318DB}", "returns Source's 3x3 upper matrix post multiplied by Multiplier", "Source", "Multiplier");
AZ_INLINE TransformType MultiplyByScale(TransformType source, Vector3Type scale)
AZ_INLINE TransformType MultiplyByUniformScale(TransformType source, NumberType scale)
{
source.MultiplyByScale(scale);
source.MultiplyByUniformScale(scale);
return source;
}
SCRIPT_CANVAS_GENERIC_FUNCTION_NODE(MultiplyByScale, k_categoryName, "{90472D62-65A8-40C1-AB08-FA66D793F689}", "returns Source multiplied by the scale matrix produced by Scale", "Source", "Scale");
SCRIPT_CANVAS_GENERIC_FUNCTION_NODE(MultiplyByUniformScale, k_categoryName, "{90472D62-65A8-40C1-AB08-FA66D793F689}", "returns Source multiplied uniformly by Scale", "Source", "Scale");
AZ_INLINE TransformType MultiplyByTransform(const TransformType& a, const TransformType& b)
{
@@ -194,16 +194,16 @@ namespace ScriptCanvas
}
SCRIPT_CANVAS_GENERIC_FUNCTION_NODE(RotationZDegrees, k_categoryName, "{F848306A-C07C-4586-B52F-BEEE489045D2}", "returns a transform representing a rotation Degrees around the Z-Axis", "Degrees");
AZ_INLINE Vector3Type ToScale(const TransformType& source)
AZ_INLINE NumberType ToScale(const TransformType& source)
{
return source.GetScale();
return source.GetUniformScale();
}
SCRIPT_CANVAS_GENERIC_FUNCTION_NODE(ToScale, k_categoryName, "{063C58AD-F567-464D-A432-F298FE3953A6}", "returns the scale part of the Source, the length of the scale components", "Source");
SCRIPT_CANVAS_GENERIC_FUNCTION_NODE(ToScale, k_categoryName, "{063C58AD-F567-464D-A432-F298FE3953A6}", "returns the uniform scale of the Source", "Source");
using Registrar = RegistrarGeneric
<
#if ENABLE_EXTENDED_MATH_SUPPORT
ExtractScaleNode ,
ExtractUniformScaleNode ,
#endif
FromMatrix3x3AndTranslationNode
, FromMatrix3x3Node
@@ -230,7 +230,7 @@ namespace ScriptCanvas
, Multiply3x3ByVector3Node
#endif
, MultiplyByScaleNode
, MultiplyByUniformScaleNode
, MultiplyByTransformNode
, MultiplyByVector3Node
, MultiplyByVector4Node