diff options
author | Ferenc Arn <tagcup@yahoo.com> | 2017-05-22 17:06:42 -0500 |
---|---|---|
committer | Ferenc Arn <tagcup@yahoo.com> | 2017-05-31 13:58:31 -0500 |
commit | a1c8896d9d1b4806ad59502aa17c9b6e87d5eb74 (patch) | |
tree | c8224c414cf681a07d4e39d068f7e69b7af75531 /core/math/transform.cpp | |
parent | 9e2b3f0903a74c009825561559d20bfc48062446 (diff) | |
download | redot-engine-a1c8896d9d1b4806ad59502aa17c9b6e87d5eb74.tar.gz |
Fix PathFollow rotations.
Used parallel transport to move the object along the curve. Also introduced a few more math checks useful for debugging.
Diffstat (limited to 'core/math/transform.cpp')
-rw-r--r-- | core/math/transform.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/core/math/transform.cpp b/core/math/transform.cpp index e53e6cf519..7a50214596 100644 --- a/core/math/transform.cpp +++ b/core/math/transform.cpp @@ -82,7 +82,10 @@ Transform Transform::looking_at(const Vector3 &p_target, const Vector3 &p_up) co } void Transform::set_look_at(const Vector3 &p_eye, const Vector3 &p_target, const Vector3 &p_up) { - +#ifdef MATH_CHECKS + ERR_FAIL_COND(p_eye == p_target); + ERR_FAIL_COND(p_up.length() == 0); +#endif // Reference: MESA source code Vector3 v_x, v_y, v_z; @@ -96,6 +99,9 @@ void Transform::set_look_at(const Vector3 &p_eye, const Vector3 &p_target, const v_y = p_up; v_x = v_y.cross(v_z); +#ifdef MATH_CHECKS + ERR_FAIL_COND(v_x.length() == 0); +#endif /* Recompute Y = Z cross X */ v_y = v_z.cross(v_x); @@ -103,9 +109,8 @@ void Transform::set_look_at(const Vector3 &p_eye, const Vector3 &p_target, const v_x.normalize(); v_y.normalize(); - basis.set_axis(0, v_x); - basis.set_axis(1, v_y); - basis.set_axis(2, v_z); + basis.set(v_x, v_y, v_z); + origin = p_eye; } |