From 1f0fcf2aa27ed3bd3a353ce40ba583afd7ef5887 Mon Sep 17 00:00:00 2001
From: lsemp3d <58790905+lsemp3d@users.noreply.github.com>
Date: Wed, 4 Aug 2021 08:42:26 -0700
Subject: [PATCH] Updates GetDirectionVector nodes to also return the distance
between the points
Signed-off-by: lsemp3d <58790905+lsemp3d@users.noreply.github.com>
---
.../Editor/Translation/scriptcanvas_en_us.ts | 43 +++++++++++++++----
.../Libraries/Math/Vector2Nodes.h | 8 ++--
.../Libraries/Math/Vector3Nodes.h | 8 ++--
.../Libraries/Math/Vector4Nodes.h | 8 ++--
4 files changed, 47 insertions(+), 20 deletions(-)
diff --git a/Assets/Editor/Translation/scriptcanvas_en_us.ts b/Assets/Editor/Translation/scriptcanvas_en_us.ts
index 22cd00aaea..937f6a4d96 100644
--- a/Assets/Editor/Translation/scriptcanvas_en_us.ts
+++ b/Assets/Editor/Translation/scriptcanvas_en_us.ts
@@ -2778,7 +2778,7 @@
VECTOR2_DIRECTIONTO_TOOLTIP
- Returns a direction vector between two points, by default the direction will be normalized, but it may be optionally scaled using the Scale parameter if different from 1.0
+ Returns a direction vector between two points and the distance between them, by default the direction will be normalized, it may be optionally scaled using the Scale parameter if different from 1.0VECTOR2_DIRECTIONTO_CATEGORY
@@ -2800,14 +2800,23 @@
VECTOR2_DIRECTIONTO_IN_TOOLTIP
-
+ VECTOR2_DIRECTIONTO_OUTPUT0_NAMEC++ Type: const Vector2DirectionVECTOR2_DIRECTIONTO_OUTPUT0_TOOLTIP
-
+ The direction between To and From normalized and optionally scaled
+
+
+ VECTOR2_DIRECTIONTO_OUTPUT1_NAME
+ C++ Type: float
+ Distance
+
+
+ VECTOR2_DIRECTIONTO_OUTPUT1_TOOLTIP
+ The distance between To and FromVECTOR2_DIRECTIONTO_PARAM0_NAME
@@ -32334,7 +32343,7 @@ An Entity can be selected by using the pick button, or by dragging an Entity fro
VECTOR4_DIRECTIONTO_TOOLTIP
- Returns a direction vector between two points, by default the direction will be normalized, but it may be optionally scaled using the Scale parameter if different from 1.0
+ Returns a direction vector between two points and the distance between them, by default the direction will be normalized, it may be optionally scaled using the Scale parameter if different from 1.0VECTOR4_DIRECTIONTO_CATEGORY
@@ -32363,7 +32372,16 @@ An Entity can be selected by using the pick button, or by dragging an Entity fro
VECTOR4_DIRECTIONTO_OUTPUT0_TOOLTIP
-
+ The direction between To and From normalized and optionally scaled
+
+
+ VECTOR4_DIRECTIONTO_OUTPUT1_NAME
+ C++ Type: float
+ Distance
+
+
+ VECTOR4_DIRECTIONTO_OUTPUT1_TOOLTIP
+ The distance between To and FromVECTOR4_DIRECTIONTO_PARAM0_NAME
@@ -37606,7 +37624,7 @@ An Entity can be selected by using the pick button, or by dragging an Entity fro
VECTOR3_DIRECTIONTO_TOOLTIP
- Returns a direction vector between two points, by default the direction will be normalized, but it may be optionally scaled using the Scale parameter if different from 1.0
+ Returns a direction vector between two points and the distance between them, by default the direction will be normalized, it may be optionally scaled using the Scale parameter if different from 1.0VECTOR3_DIRECTIONTO_CATEGORY
@@ -37628,14 +37646,23 @@ An Entity can be selected by using the pick button, or by dragging an Entity fro
VECTOR3_DIRECTIONTO_IN_TOOLTIP
-
+ VECTOR3_DIRECTIONTO_OUTPUT0_NAMEC++ Type: const Vector3DirectionVECTOR3_DIRECTIONTO_OUTPUT0_TOOLTIP
-
+ The direction between To and From normalized and optionally scaled
+
+
+ VECTOR3_DIRECTIONTO_OUTPUT1_NAME
+ C++ Type: float
+ Distance
+
+
+ VECTOR3_DIRECTIONTO_OUTPUT1_TOOLTIP
+ The distance between To and FromVECTOR3_DIRECTIONTO_PARAM0_NAME
diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Math/Vector2Nodes.h b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Math/Vector2Nodes.h
index 5caff9ff25..670c9f31a1 100644
--- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Math/Vector2Nodes.h
+++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Math/Vector2Nodes.h
@@ -250,14 +250,14 @@ namespace ScriptCanvas
SetDefaultValuesByIndex<2>::_(node, Data::NumberType(1.));
}
- AZ_INLINE Vector2Type DirectionTo(const Vector2Type from, const Vector2Type to, NumberType optionalScale = 1.f)
+ AZ_INLINE std::tuple DirectionTo(const Vector2Type from, const Vector2Type to, NumberType optionalScale = 1.f)
{
Vector2Type r = to - from;
- r.Normalize();
+ float length = r.NormalizeWithLength();
r.SetLength(optionalScale);
- return r;
+ return std::make_tuple(r, length);
}
- SCRIPT_CANVAS_GENERIC_FUNCTION_NODE_WITH_DEFAULTS(DirectionTo, DirectionToDefaults, k_categoryName, "{49A2D7F6-6CD3-420E-8A79-D46B00DB6CED}", "Returns a direction vector between two points, by default the direction will be normalized, but it may be optionally scaled using the Scale parameter if different from 1.0", "From", "To", "Scale");
+ SCRIPT_CANVAS_GENERIC_FUNCTION_NODE_WITH_DEFAULTS(DirectionTo, DirectionToDefaults, k_categoryName, "{49A2D7F6-6CD3-420E-8A79-D46B00DB6CED}", "Returns a direction vector between two points and the distance between them, by default the direction will be normalized, but it may be optionally scaled using the Scale parameter if different from 1.0", "From", "To", "Scale");
using Registrar = RegistrarGeneric <
AbsoluteNode
diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Math/Vector3Nodes.h b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Math/Vector3Nodes.h
index 24a1710655..492bc83e33 100644
--- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Math/Vector3Nodes.h
+++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Math/Vector3Nodes.h
@@ -336,14 +336,14 @@ namespace ScriptCanvas
SetDefaultValuesByIndex<2>::_(node, Data::NumberType(1.));
}
- AZ_INLINE Vector3Type DirectionTo(const Vector3Type from, const Vector3Type to, NumberType optionalScale = 1.f)
+ AZ_INLINE std::tuple DirectionTo(const Vector3Type from, const Vector3Type to, NumberType optionalScale = 1.f)
{
Vector3Type r = to - from;
- r.Normalize();
+ float length = r.NormalizeWithLength();
r.SetLength(optionalScale);
- return r;
+ return std::make_tuple(r, length);
}
- SCRIPT_CANVAS_GENERIC_FUNCTION_NODE_WITH_DEFAULTS(DirectionTo, DirectionToDefaults, k_categoryName, "{28FBD529-4C9A-4E34-B8A0-A13B5DB3C331}", "Returns a direction vector between two points, by default the direction will be normalized, but it may be optionally scaled using the Scale parameter if different from 1.0", "From", "To", "Scale");
+ SCRIPT_CANVAS_GENERIC_FUNCTION_NODE_WITH_DEFAULTS(DirectionTo, DirectionToDefaults, k_categoryName, "{28FBD529-4C9A-4E34-B8A0-A13B5DB3C331}", "Returns a direction vector between two points and the distance between them, by default the direction will be normalized, but it may be optionally scaled using the Scale parameter if different from 1.0", "From", "To", "Scale");
using Registrar = RegistrarGeneric <
diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Math/Vector4Nodes.h b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Math/Vector4Nodes.h
index d420affd9a..26099c59c6 100644
--- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Math/Vector4Nodes.h
+++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Libraries/Math/Vector4Nodes.h
@@ -221,14 +221,14 @@ namespace ScriptCanvas
SetDefaultValuesByIndex<2>::_(node, Data::NumberType(1.));
}
- AZ_INLINE Vector4Type DirectionTo(const Vector4Type from, const Vector4Type to, NumberType optionalScale = 1.f)
+ AZ_INLINE std::tuple DirectionTo(const Vector4Type from, const Vector4Type to, NumberType optionalScale = 1.f)
{
Vector4Type r = to - from;
- r.Normalize();
+ float length = r.NormalizeWithLength();
r.SetLength(optionalScale);
- return r;
+ return std::make_tuple(r, length);
}
- SCRIPT_CANVAS_GENERIC_FUNCTION_NODE_WITH_DEFAULTS(DirectionTo, DirectionToDefaults, k_categoryName, "{463762DE-E541-4AFE-80C2-FED1C5273319}", "Returns a direction vector between two points, by default the direction will be normalized, but it may be optionally scaled using the Scale parameter if different from 1.0", "From", "To", "Scale");
+ SCRIPT_CANVAS_GENERIC_FUNCTION_NODE_WITH_DEFAULTS(DirectionTo, DirectionToDefaults, k_categoryName, "{463762DE-E541-4AFE-80C2-FED1C5273319}", false, "Returns a direction vector between two points and the distance between them, by default the direction will be normalized, but it may be optionally scaled using the Scale parameter if different from 1.0", "From", "To", "Scale");
using Registrar = RegistrarGeneric <
AbsoluteNode,