summaryrefslogtreecommitdiff
path: root/core/math
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-07-28 09:25:25 +0200
committerGitHub <noreply@github.com>2022-07-28 09:25:25 +0200
commit13a9d5e3c01b43ab29fac353320c36ac54cc4e84 (patch)
treef1466bcfaad445ea4b7c79b54ae58fd49cb2d4da /core/math
parent9a81b129f6d09b818e741e5c314f1fbd84fd8ff8 (diff)
parent4b13a6dcb88c12cf71029c089f5fffb4cd53807a (diff)
Merge pull request #63378 from nathanfranke/t3d-errors
Add equal checks to Transform3D::looking_at and Transform3D::set_look_at, fixes misleading error.
Diffstat (limited to 'core/math')
-rw-r--r--core/math/transform_3d.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/core/math/transform_3d.cpp b/core/math/transform_3d.cpp
index 76b31daa76..44248c274f 100644
--- a/core/math/transform_3d.cpp
+++ b/core/math/transform_3d.cpp
@@ -70,12 +70,18 @@ void Transform3D::rotate_basis(const Vector3 &p_axis, real_t p_angle) {
}
Transform3D Transform3D::looking_at(const Vector3 &p_target, const Vector3 &p_up) const {
+#ifdef MATH_CHECKS
+ ERR_FAIL_COND_V_MSG(origin.is_equal_approx(p_target), Transform3D(), "The transform's origin and target can't be equal.");
+#endif
Transform3D t = *this;
t.basis = Basis::looking_at(p_target - origin, p_up);
return t;
}
void Transform3D::set_look_at(const Vector3 &p_eye, const Vector3 &p_target, const Vector3 &p_up) {
+#ifdef MATH_CHECKS
+ ERR_FAIL_COND_MSG(p_eye.is_equal_approx(p_target), "The eye and target vectors can't be equal.");
+#endif
basis = Basis::looking_at(p_target - p_eye, p_up);
origin = p_eye;
}