Skip to content

Commit 94d7497

Browse files
Flarkkdsnopek
authored andcommitted
Add p_use_model_front to Basis::looking_at()
(cherry picked from commit 02fd535)
1 parent bf26191 commit 94d7497

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

include/godot_cpp/variant/basis.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ struct _NO_DISCARD_ Basis {
224224

225225
operator Quaternion() const { return get_quaternion(); }
226226

227-
static Basis looking_at(const Vector3 &p_target, const Vector3 &p_up = Vector3(0, 1, 0));
227+
static Basis looking_at(const Vector3 &p_target, const Vector3 &p_up = Vector3(0, 1, 0), bool p_use_model_front = false);
228228

229229
Basis(const Quaternion &p_quaternion) { set_quaternion(p_quaternion); }
230230
Basis(const Quaternion &p_quaternion, const Vector3 &p_scale) { set_quaternion_scale(p_quaternion, p_scale); }

src/variant/basis.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,12 +1037,15 @@ void Basis::rotate_sh(real_t *p_values) {
10371037
p_values[8] = d4 * s_scale_dst4;
10381038
}
10391039

1040-
Basis Basis::looking_at(const Vector3 &p_target, const Vector3 &p_up) {
1040+
Basis Basis::looking_at(const Vector3 &p_target, const Vector3 &p_up, bool p_use_model_front) {
10411041
#ifdef MATH_CHECKS
10421042
ERR_FAIL_COND_V_MSG(p_target.is_zero_approx(), Basis(), "The target vector can't be zero.");
10431043
ERR_FAIL_COND_V_MSG(p_up.is_zero_approx(), Basis(), "The up vector can't be zero.");
10441044
#endif
1045-
Vector3 v_z = -p_target.normalized();
1045+
Vector3 v_z = p_target.normalized();
1046+
if (!p_use_model_front) {
1047+
v_z = -v_z;
1048+
}
10461049
Vector3 v_x = p_up.cross(v_z);
10471050
#ifdef MATH_CHECKS
10481051
ERR_FAIL_COND_V_MSG(v_x.is_zero_approx(), Basis(), "The target vector and up vector can't be parallel to each other.");

0 commit comments

Comments
 (0)