diff options
| author | Florent Guiocheau <florent.guiocheau@gmail.com> | 2024-10-14 21:45:17 +0200 |
|---|---|---|
| committer | Florent Guiocheau <florent.guiocheau@gmail.com> | 2024-10-14 21:50:12 +0200 |
| commit | 02fd535454773edb1a8c4b52d5b851e863660246 (patch) | |
| tree | 1aa77dceab01e5cc1c2e4295568255b3e56fc25f /src/variant | |
| parent | 6facde3c29abe4d8b0ff365c252c9aeb16fc5f66 (diff) | |
| download | redot-cpp-02fd535454773edb1a8c4b52d5b851e863660246.tar.gz | |
Add p_use_model_front to Basis::looking_at()
Diffstat (limited to 'src/variant')
| -rw-r--r-- | src/variant/basis.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/variant/basis.cpp b/src/variant/basis.cpp index 200cd06..d8a9919 100644 --- a/src/variant/basis.cpp +++ b/src/variant/basis.cpp @@ -1037,12 +1037,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."); |
