summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Snopek <dsnopek@gmail.com>2024-10-17 16:02:02 +0200
committerGitHub <noreply@github.com>2024-10-17 16:02:02 +0200
commit96675a814b9038b7da57607c34b8e7e69b8c1678 (patch)
tree880635da75704e5975cbe8b3fa1c3a6e6015f78b /src
parent291147e21b9d03938cff7d7e38bbe4365f029762 (diff)
parent02fd535454773edb1a8c4b52d5b851e863660246 (diff)
downloadredot-cpp-96675a814b9038b7da57607c34b8e7e69b8c1678.tar.gz
Merge pull request #1625 from Flarkk/looking_at
Add `p_use_model_front` to `Basis::looking_at()`
Diffstat (limited to 'src')
-rw-r--r--src/variant/basis.cpp7
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.");