first pass of changing transform to use float for scale internally rather than Vector3

This commit is contained in:
greerdv
2021-04-27 18:12:46 +01:00
parent 540f0dcd98
commit b113f09a71
76 changed files with 487 additions and 546 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
@@ -47,21 +47,10 @@ namespace ScriptCanvas
AZ::Transform currentTransform = AZ::Transform::CreateIdentity();
AZ::TransformBus::EventResult(currentTransform, targetEntity, &AZ::TransformInterface::GetWorldTM);
AZ::Vector3 position = currentTransform.GetTranslation();
AZ::Quaternion currentRotation = currentTransform.GetRotation();
currentTransform.SetRotation((rotation * currentTransform.GetRotation().GetNormalized()));
AZ::Quaternion newRotation = (rotation * currentRotation);
newRotation.Normalize();
AZ::Transform newTransform = AZ::Transform::CreateIdentity();
newTransform.SetScale(currentTransform.GetScale());
newTransform.SetRotation(newRotation);
newTransform.SetTranslation(position);
AZ::TransformBus::Event(targetEntity, &AZ::TransformInterface::SetWorldTM, newTransform);
AZ::TransformBus::Event(targetEntity, &AZ::TransformInterface::SetWorldTM, currentTransform);
}
}
@@ -44,22 +44,12 @@ namespace ScriptCanvas
{
AZ::Quaternion rotation = AZ::ConvertEulerDegreesToQuaternion(angles);
AZ::Transform currentTransform = AZ::Transform::CreateIdentity();
AZ::TransformBus::EventResult(currentTransform, targetEntity, &AZ::TransformInterface::GetWorldTM);
AZ::Transform transform = AZ::Transform::CreateIdentity();
AZ::TransformBus::EventResult(transform, targetEntity, &AZ::TransformInterface::GetWorldTM);
AZ::Vector3 position = currentTransform.GetTranslation();
AZ::Quaternion currentRotation = currentTransform.GetRotation();
transform.SetRotation((rotation * transform.GetRotation()).GetNormalized());
AZ::Quaternion newRotation = (rotation * currentRotation);
newRotation.Normalize();
AZ::Transform newTransform = AZ::Transform::CreateIdentity();
newTransform.CreateScale(currentTransform.ExtractScale());
newTransform.SetRotation(newRotation);
newTransform.SetTranslation(position);
AZ::TransformBus::Event(targetEntity, &AZ::TransformInterface::SetWorldTM, newTransform);
AZ::TransformBus::Event(targetEntity, &AZ::TransformInterface::SetWorldTM, transform);
}
}
}
@@ -26,9 +26,9 @@ 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> ExtractScale(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");