summaryrefslogtreecommitdiffstats
path: root/core/math/basis.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-05-24 08:46:53 +0200
committerRémi Verschelde <rverschelde@gmail.com>2023-05-24 08:46:53 +0200
commit6f34a234397b9c536efa3d9eb90b9e521135301e (patch)
tree3db1e2feb2355631d9655d38e2020e1236d3f236 /core/math/basis.cpp
parent852740a6272fb5366c66f7fe47595997b16c3014 (diff)
parent5fdc1232eff45e31ee53f58e618de6c58d3f7203 (diff)
downloadredot-engine-6f34a234397b9c536efa3d9eb90b9e521135301e.tar.gz
Merge pull request #76082 from reduz/ability-to-look-at-in-model-space
Add the ability to look-at in model-space.
Diffstat (limited to 'core/math/basis.cpp')
-rw-r--r--core/math/basis.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/core/math/basis.cpp b/core/math/basis.cpp
index bfd902c7e2..1481dbc32e 100644
--- a/core/math/basis.cpp
+++ b/core/math/basis.cpp
@@ -1016,12 +1016,15 @@ void Basis::rotate_sh(real_t *p_values) {
p_values[8] = d4 * s_scale_dst4;
}
-Basis Basis::looking_at(const Vector3 &p_target, const Vector3 &p_up) {
+Basis Basis::looking_at(const Vector3 &p_target, const Vector3 &p_up, bool p_use_model_front) {
#ifdef MATH_CHECKS
ERR_FAIL_COND_V_MSG(p_target.is_zero_approx(), Basis(), "The target vector can't be zero.");
ERR_FAIL_COND_V_MSG(p_up.is_zero_approx(), Basis(), "The up vector can't be zero.");
#endif
- Vector3 v_z = -p_target.normalized();
+ Vector3 v_z = p_target.normalized();
+ if (!p_use_model_front) {
+ v_z = -v_z;
+ }
Vector3 v_x = p_up.cross(v_z);
#ifdef MATH_CHECKS
ERR_FAIL_COND_V_MSG(v_x.is_zero_approx(), Basis(), "The target vector and up vector can't be parallel to each other.");