update scriptcanvas to handle uniform scale on transform

This commit is contained in:
greerdv
2021-05-28 11:54:12 +01:00
parent c35c1d67e7
commit e556cdbba5
2 changed files with 14 additions and 14 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)
{
@@ -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