Cherry-pick animation fix for 4.2
This commit is contained in:
parent
07cf36d21c
commit
faf17a3ae1
|
@ -273,7 +273,7 @@ void AnimationNodeBlendSpace1D::_add_blend_point(int p_index, const Ref<Animatio
|
||||||
}
|
}
|
||||||
|
|
||||||
double AnimationNodeBlendSpace1D::_process(const AnimationMixer::PlaybackInfo p_playback_info, bool p_test_only) {
|
double AnimationNodeBlendSpace1D::_process(const AnimationMixer::PlaybackInfo p_playback_info, bool p_test_only) {
|
||||||
if (blend_points_used == 0) {
|
if (!blend_points_used) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -445,6 +445,10 @@ void AnimationNodeBlendSpace2D::_blend_triangle(const Vector2 &p_pos, const Vect
|
||||||
double AnimationNodeBlendSpace2D::_process(const AnimationMixer::PlaybackInfo p_playback_info, bool p_test_only) {
|
double AnimationNodeBlendSpace2D::_process(const AnimationMixer::PlaybackInfo p_playback_info, bool p_test_only) {
|
||||||
_update_triangles();
|
_update_triangles();
|
||||||
|
|
||||||
|
if (!blend_points_used) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
Vector2 blend_pos = get_parameter(blend_position);
|
Vector2 blend_pos = get_parameter(blend_position);
|
||||||
int cur_closest = get_parameter(closest);
|
int cur_closest = get_parameter(closest);
|
||||||
double cur_length_internal = get_parameter(length_internal);
|
double cur_length_internal = get_parameter(length_internal);
|
||||||
|
@ -453,7 +457,7 @@ double AnimationNodeBlendSpace2D::_process(const AnimationMixer::PlaybackInfo p_
|
||||||
AnimationMixer::PlaybackInfo pi = p_playback_info;
|
AnimationMixer::PlaybackInfo pi = p_playback_info;
|
||||||
|
|
||||||
if (blend_mode == BLEND_MODE_INTERPOLATED) {
|
if (blend_mode == BLEND_MODE_INTERPOLATED) {
|
||||||
if (triangles.size() == 0) {
|
if (triangles.is_empty()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1572,7 +1572,7 @@ void AnimationMixer::_blend_process(double p_delta, bool p_update_only) {
|
||||||
}
|
}
|
||||||
if (seeked) {
|
if (seeked) {
|
||||||
// Seek.
|
// Seek.
|
||||||
int idx = a->track_find_key(i, time, is_external_seeking ? Animation::FIND_MODE_NEAREST : Animation::FIND_MODE_EXACT);
|
int idx = a->track_find_key(i, time, Animation::FIND_MODE_NEAREST);
|
||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1585,6 +1585,9 @@ void AnimationMixer::_blend_process(double p_delta, bool p_update_only) {
|
||||||
double at_anim_pos = 0.0;
|
double at_anim_pos = 0.0;
|
||||||
switch (anim->get_loop_mode()) {
|
switch (anim->get_loop_mode()) {
|
||||||
case Animation::LOOP_NONE: {
|
case Animation::LOOP_NONE: {
|
||||||
|
if (!is_external_seeking && ((!backward && time >= pos + (double)anim->get_length()) || (backward && time <= pos))) {
|
||||||
|
continue; // Do nothing if current time is outside of length when started.
|
||||||
|
}
|
||||||
at_anim_pos = MIN((double)anim->get_length(), time - pos); // Seek to end.
|
at_anim_pos = MIN((double)anim->get_length(), time - pos); // Seek to end.
|
||||||
} break;
|
} break;
|
||||||
case Animation::LOOP_LINEAR: {
|
case Animation::LOOP_LINEAR: {
|
||||||
|
@ -1596,7 +1599,7 @@ void AnimationMixer::_blend_process(double p_delta, bool p_update_only) {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (player2->is_playing()) {
|
if (player2->is_playing() || !is_external_seeking) {
|
||||||
player2->seek(at_anim_pos, false, p_update_only);
|
player2->seek(at_anim_pos, false, p_update_only);
|
||||||
player2->play(anim_name);
|
player2->play(anim_name);
|
||||||
t->playing = true;
|
t->playing = true;
|
||||||
|
|
|
@ -149,7 +149,7 @@ void AnimationPlayer::_notification(int p_what) {
|
||||||
switch (p_what) {
|
switch (p_what) {
|
||||||
case NOTIFICATION_READY: {
|
case NOTIFICATION_READY: {
|
||||||
if (!Engine::get_singleton()->is_editor_hint() && animation_set.has(autoplay)) {
|
if (!Engine::get_singleton()->is_editor_hint() && animation_set.has(autoplay)) {
|
||||||
set_active(true);
|
set_active(active);
|
||||||
play(autoplay);
|
play(autoplay);
|
||||||
_check_immediately_after_start();
|
_check_immediately_after_start();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1397,6 +1397,15 @@ void Control::_set_position(const Point2 &p_point) {
|
||||||
|
|
||||||
void Control::set_position(const Point2 &p_point, bool p_keep_offsets) {
|
void Control::set_position(const Point2 &p_point, bool p_keep_offsets) {
|
||||||
ERR_MAIN_THREAD_GUARD;
|
ERR_MAIN_THREAD_GUARD;
|
||||||
|
|
||||||
|
#ifdef TOOLS_ENABLED
|
||||||
|
// Can't compute anchors, set position directly and return immediately.
|
||||||
|
if (saving && !is_inside_tree()) {
|
||||||
|
data.pos_cache = p_point;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (p_keep_offsets) {
|
if (p_keep_offsets) {
|
||||||
_compute_anchors(Rect2(p_point, data.size_cache), data.offset, data.anchor);
|
_compute_anchors(Rect2(p_point, data.size_cache), data.offset, data.anchor);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1457,6 +1466,14 @@ void Control::set_size(const Size2 &p_size, bool p_keep_offsets) {
|
||||||
new_size.y = min.y;
|
new_size.y = min.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TOOLS_ENABLED
|
||||||
|
// Can't compute anchors, set size directly and return immediately.
|
||||||
|
if (saving && !is_inside_tree()) {
|
||||||
|
data.size_cache = new_size;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (p_keep_offsets) {
|
if (p_keep_offsets) {
|
||||||
_compute_anchors(Rect2(data.pos_cache, new_size), data.offset, data.anchor);
|
_compute_anchors(Rect2(data.pos_cache, new_size), data.offset, data.anchor);
|
||||||
} else {
|
} else {
|
||||||
|
@ -3135,6 +3152,14 @@ Control *Control::make_custom_tooltip(const String &p_text) const {
|
||||||
void Control::_notification(int p_notification) {
|
void Control::_notification(int p_notification) {
|
||||||
ERR_MAIN_THREAD_GUARD;
|
ERR_MAIN_THREAD_GUARD;
|
||||||
switch (p_notification) {
|
switch (p_notification) {
|
||||||
|
#ifdef TOOLS_ENABLED
|
||||||
|
case NOTIFICATION_EDITOR_PRE_SAVE: {
|
||||||
|
saving = true;
|
||||||
|
} break;
|
||||||
|
case NOTIFICATION_EDITOR_POST_SAVE: {
|
||||||
|
saving = false;
|
||||||
|
} break;
|
||||||
|
#endif
|
||||||
case NOTIFICATION_POSTINITIALIZE: {
|
case NOTIFICATION_POSTINITIALIZE: {
|
||||||
data.initialized = true;
|
data.initialized = true;
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,10 @@ class ThemeContext;
|
||||||
class Control : public CanvasItem {
|
class Control : public CanvasItem {
|
||||||
GDCLASS(Control, CanvasItem);
|
GDCLASS(Control, CanvasItem);
|
||||||
|
|
||||||
|
#ifdef TOOLS_ENABLED
|
||||||
|
bool saving = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Anchor {
|
enum Anchor {
|
||||||
ANCHOR_BEGIN = 0,
|
ANCHOR_BEGIN = 0,
|
||||||
|
|
Loading…
Reference in New Issue