summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThaddeus Crews <repiteo@outlook.com>2024-11-26 13:04:48 -0600
committerThaddeus Crews <repiteo@outlook.com>2024-11-26 13:04:48 -0600
commit33093c2029cf51a5f9b048c7d32248a567ee6487 (patch)
treed3e01d42e83f2bcccbdf8cde79fe39f92d835f1f
parent04786f0ee8df06f4238327789b10e0c2e09c4c7e (diff)
parent38d274b021b551c11a3436c2f4f1898dcb2994ca (diff)
downloadredot-engine-33093c2029cf51a5f9b048c7d32248a567ee6487.tar.gz
Merge pull request #99619 from TokageItLab/flippable
Make flipping flag consider influence in LookAtModifier3D
-rw-r--r--scene/3d/look_at_modifier_3d.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/scene/3d/look_at_modifier_3d.cpp b/scene/3d/look_at_modifier_3d.cpp
index 47a8a9050e..04dae61dce 100644
--- a/scene/3d/look_at_modifier_3d.cpp
+++ b/scene/3d/look_at_modifier_3d.cpp
@@ -545,6 +545,8 @@ void LookAtModifier3D::_process_modification() {
}
// Detect flipping.
+ bool is_not_max_influence = influence < 1.0;
+ bool is_flippable = use_angle_limitation || is_not_max_influence;
Vector3::Axis current_forward_axis = get_axis_from_bone_axis(forward_axis);
if (is_intersecting_axis(prev_forward_vector, forward_vector, current_forward_axis, secondary_rotation_axis) ||
is_intersecting_axis(prev_forward_vector, forward_vector, primary_rotation_axis, primary_rotation_axis, true) ||
@@ -552,16 +554,20 @@ void LookAtModifier3D::_process_modification() {
(prev_forward_vector != Vector3(0, 0, 0) && forward_vector == Vector3(0, 0, 0)) ||
(prev_forward_vector == Vector3(0, 0, 0) && forward_vector != Vector3(0, 0, 0))) {
init_transition();
- } else if (use_angle_limitation && signbit(prev_forward_vector[secondary_rotation_axis]) != signbit(forward_vector[secondary_rotation_axis])) {
+ } else if (is_flippable && signbit(prev_forward_vector[secondary_rotation_axis]) != signbit(forward_vector[secondary_rotation_axis])) {
// Flipping by angle_limitation can be detected by sign of secondary rotation axes during forward_vector is rotated more than 90 degree from forward_axis (means dot production is negative).
Vector3 prev_forward_vector_nrm = forward_vector.normalized();
Vector3 rest_forward_vector = get_vector_from_bone_axis(forward_axis);
if (symmetry_limitation) {
- if (!Math::is_equal_approx(primary_limit_angle, (float)Math_TAU) && prev_forward_vector_nrm.dot(rest_forward_vector) < 0 && forward_vector_nrm.dot(rest_forward_vector) < 0) {
+ if ((is_not_max_influence || !Math::is_equal_approx(primary_limit_angle, (float)Math_TAU)) &&
+ prev_forward_vector_nrm.dot(rest_forward_vector) < 0 &&
+ forward_vector_nrm.dot(rest_forward_vector) < 0) {
init_transition();
}
} else {
- if (!Math::is_equal_approx(primary_positive_limit_angle + primary_negative_limit_angle, (float)Math_TAU) && prev_forward_vector_nrm.dot(rest_forward_vector) < 0 && forward_vector_nrm.dot(rest_forward_vector) < 0) {
+ if ((is_not_max_influence || !Math::is_equal_approx(primary_positive_limit_angle + primary_negative_limit_angle, (float)Math_TAU)) &&
+ prev_forward_vector_nrm.dot(rest_forward_vector) < 0 &&
+ forward_vector_nrm.dot(rest_forward_vector) < 0) {
init_transition();
}
}
@@ -576,7 +582,7 @@ void LookAtModifier3D::_process_modification() {
delta = get_physics_process_delta_time();
}
remaining = MAX(0, remaining - time_step * delta);
- if (use_angle_limitation) {
+ if (is_flippable) {
// Interpolate through the rest same as AnimationTree blending for preventing to penetrate the bone into the body.
Quaternion rest = skeleton->get_bone_rest(bone).basis.get_rotation_quaternion();
float weight = Tween::run_equation(transition_type, ease_type, 1 - remaining, 0.0, 1.0, 1.0);