Debian Codegraph @

scene/animation/animation_player.cpp

raw symbols SCIP
1 /**************************************************************************/
2 /* animation_player.cpp */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29 /**************************************************************************/
30
31 #include "animation_player.h"
32 #include "animation_player.compat.inc"
33
34 #include "core/config/engine.h"
35
36 bool AnimationPlayer::_set(const StringName &p_name, const Variant &p_value) {
37 String name = p_name;
38 if (name.begins_with("playback/play")) { // For backward compatibility.
39 set_current_animation(p_value);
40 } else if (name.begins_with("next/")) {
41 String which = name.get_slicec('/', 1);
42 animation_set_next(which, p_value);
43 } else if (p_name == SceneStringName(blend_times)) {
44 Array array = p_value;
45 int len = array.size();
46 ERR_FAIL_COND_V(len % 3, false);
47
48 for (int i = 0; i < len / 3; i++) {
49 StringName from = array[i * 3 + 0];
50 StringName to = array[i * 3 + 1];
51 float time = array[i * 3 + 2];
52 set_blend_time(from, to, time);
53 }
54 #ifndef DISABLE_DEPRECATED
55 } else if (p_name == "method_call_mode") {
56 set_callback_mode_method(static_cast<AnimationCallbackModeMethod>((int)p_value));
57 } else if (p_name == "playback_process_mode") {
58 set_callback_mode_process(static_cast<AnimationCallbackModeProcess>((int)p_value));
59 } else if (p_name == "playback_active") {
60 set_active(p_value);
61 #endif // DISABLE_DEPRECATED
62 } else {
63 return false;
64 }
65 return true;
66 }
67
68 bool AnimationPlayer::_get(const StringName &p_name, Variant &r_ret) const {
69 String name = p_name;
70
71 if (name == "playback/play") { // For backward compatibility.
72
73 r_ret = get_current_animation();
74
75 } else if (name.begins_with("next/")) {
76 String which = name.get_slicec('/', 1);
77 r_ret = animation_get_next(which);
78
79 } else if (p_name == SceneStringName(blend_times)) {
80 Vector<BlendKey> keys;
81 for (const KeyValue<BlendKey, double> &E : blend_times) {
82 keys.ordered_insert(E.key);
83 }
84
85 Array array;
86 for (int i = 0; i < keys.size(); i++) {
87 array.push_back(keys[i].from);
88 array.push_back(keys[i].to);
89 array.push_back(blend_times.get(keys[i]));
90 }
91
92 r_ret = array;
93 #ifndef DISABLE_DEPRECATED
94 } else if (name == "method_call_mode") {
95 r_ret = get_callback_mode_method();
96 } else if (name == "playback_process_mode") {
97 r_ret = get_callback_mode_process();
98 } else if (name == "playback_active") {
99 r_ret = is_active();
100 #endif // DISABLE_DEPRECATED
101 } else {
102 return false;
103 }
104
105 return true;
106 }
107
108 void AnimationPlayer::_validate_property(PropertyInfo &p_property) const {
109 if (Engine::get_singleton()->is_editor_hint() && p_property.name == "current_animation") {
110 List<String> names;
111
112 for (const KeyValue<StringName, AnimationData> &E : animation_set) {
113 names.push_back(E.key);
114 }
115 names.push_front("[stop]");
116 String hint;
117 for (List<String>::Element *E = names.front(); E; E = E->next()) {
118 if (E != names.front()) {
119 hint += ",";
120 }
121 hint += E->get();
122 }
123
124 p_property.hint_string = hint;
125 } else if (!auto_capture && p_property.name.begins_with("playback_auto_capture_")) {
126 p_property.usage = PROPERTY_USAGE_NONE;
127 }
128 }
129
130 void AnimationPlayer::_get_property_list(List<PropertyInfo> *p_list) const {
131 List<PropertyInfo> anim_names;
132
133 for (const KeyValue<StringName, AnimationData> &E : animation_set) {
134 AHashMap<StringName, StringName>::ConstIterator F = animation_next_set.find(E.key);
135 if (F && F->value != StringName()) {
136 anim_names.push_back(PropertyInfo(Variant::STRING, "next/" + String(E.key), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL));
137 }
138 }
139
140 for (const PropertyInfo &E : anim_names) {
141 p_list->push_back(E);
142 }
143
144 p_list->push_back(PropertyInfo(Variant::ARRAY, "blend_times", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL));
145 }
146
147 void AnimationPlayer::_notification(int p_what) {
148 switch (p_what) {
149 case NOTIFICATION_READY: {
150 if (!Engine::get_singleton()->is_editor_hint() && animation_set.has(autoplay)) {
151 set_active(active);
152 play(autoplay);
153 _check_immediately_after_start();
154 }
155 } break;
156 }
157 }
158
159 void AnimationPlayer::_process_playback_data(PlaybackData &cd, double p_delta, float p_blend, bool p_seeked, bool p_internal_seeked, bool p_started, bool p_is_current) {
160 double speed = speed_scale * cd.speed_scale;
161 bool backwards = std::signbit(speed); // Negative zero means playing backwards too.
162 double delta = p_started ? 0 : p_delta * speed;
163 double next_pos = cd.pos + delta;
164
165 double start = cd.get_start_time();
166 double end = cd.get_end_time();
167
168 Animation::LoopedFlag looped_flag = Animation::LOOPED_FLAG_NONE;
169
170 switch (cd.from->animation->get_loop_mode()) {
171 case Animation::LOOP_NONE: {
172 if (Animation::is_less_approx(next_pos, start)) {
173 next_pos = start;
174 } else if (Animation::is_greater_approx(next_pos, end)) {
175 next_pos = end;
176 }
177 delta = next_pos - cd.pos; // Fix delta (after determination of backwards because negative zero is lost here).
178 } break;
179
180 case Animation::LOOP_LINEAR: {
181 if (Animation::is_less_approx(next_pos, start) && Animation::is_greater_or_equal_approx(cd.pos, start)) {
182 looped_flag = Animation::LOOPED_FLAG_START;
183 }
184 if (Animation::is_greater_approx(next_pos, end) && Animation::is_less_or_equal_approx(cd.pos, end)) {
185 looped_flag = Animation::LOOPED_FLAG_END;
186 }
187 next_pos = Math::fposmod(next_pos - start, end - start) + start;
188 } break;
189
190 case Animation::LOOP_PINGPONG: {
191 if (Animation::is_less_approx(next_pos, start) && Animation::is_greater_or_equal_approx(cd.pos, start)) {
192 cd.speed_scale *= -1.0;
193 looped_flag = Animation::LOOPED_FLAG_START;
194 }
195 if (Animation::is_greater_approx(next_pos, end) && Animation::is_less_or_equal_approx(cd.pos, end)) {
196 cd.speed_scale *= -1.0;
197 looped_flag = Animation::LOOPED_FLAG_END;
198 }
199 next_pos = Math::pingpong(next_pos - start, end - start) + start;
200 } break;
201
202 default:
203 break;
204 }
205
206 double prev_pos = cd.pos; // The animation may be changed during process, so it is safer that the state is changed before process.
207
208 // End detection.
209 if (p_is_current) {
210 if (cd.from->animation->get_loop_mode() == Animation::LOOP_NONE) {
211 if (!backwards && Animation::is_less_or_equal_approx(prev_pos, end) && Math::is_equal_approx(next_pos, end)) {
212 // Playback finished.
213 next_pos = end; // Snap to the edge.
214 end_reached = true;
215 end_notify = Animation::is_less_approx(prev_pos, end); // Notify only if not already at the end.
216 p_blend = 1.0;
217 }
218 if (backwards && Animation::is_greater_or_equal_approx(prev_pos, start) && Math::is_equal_approx(next_pos, start)) {
219 // Playback finished.
220 next_pos = start; // Snap to the edge.
221 end_reached = true;
222 end_notify = Animation::is_greater_approx(prev_pos, start); // Notify only if not already at the beginning.
223 p_blend = 1.0;
224 }
225 }
226 }
227
228 cd.pos = next_pos;
229
230 PlaybackInfo pi;
231 if (p_started) {
232 pi.time = prev_pos;
233 pi.delta = 0;
234 pi.start = start;
235 pi.end = end;
236 pi.seeked = true;
237 } else {
238 pi.time = next_pos;
239 pi.delta = delta;
240 pi.start = start;
241 pi.end = end;
242 pi.seeked = p_seeked;
243 }
244 if (Math::is_zero_approx(pi.delta) && backwards) {
245 pi.delta = -0.0; // Sign is needed to handle converted Continuous track from Discrete track correctly.
246 }
247 // Immediately after playback, discrete keys should be retrieved with EXACT mode since behind keys must be ignored at that time.
248 pi.is_external_seeking = !p_internal_seeked && !p_started;
249 pi.looped_flag = looped_flag;
250 pi.weight = p_blend;
251 make_animation_instance(cd.from->name, pi);
252 }
253
254 float AnimationPlayer::get_current_blend_amount() {
255 Playback &c = playback;
256 float blend = 1.0;
257 for (const Blend &b : c.blend) {
258 blend = blend - b.blend_left;
259 }
260 return MAX(0, blend);
261 }
262
263 void AnimationPlayer::_blend_playback_data(double p_delta, bool p_started) {
264 Playback &c = playback;
265
266 bool seeked = c.seeked; // The animation may be changed during process, so it is safer that the state is changed before process.
267 bool internal_seeked = c.internal_seeked;
268
269 if (!Math::is_zero_approx(p_delta)) {
270 c.seeked = false;
271 c.internal_seeked = false;
272 }
273
274 // Second, process current animation to check if the animation end reached.
275 _process_playback_data(c.current, p_delta, get_current_blend_amount(), seeked, internal_seeked, p_started, true);
276
277 // Finally, if not end the animation, do blending.
278 if (end_reached) {
279 playback.blend.clear();
280 if (end_notify) {
281 finished_anim = playback.assigned;
282 }
283 return;
284 }
285 List<List<Blend>::Element *> to_erase;
286 for (List<Blend>::Element *E = c.blend.front(); E; E = E->next()) {
287 Blend &b = E->get();
288 b.blend_left = MAX(0, b.blend_left - Math::abs(speed_scale * p_delta) / b.blend_time);
289 if (Animation::is_less_or_equal_approx(b.blend_left, 0)) {
290 to_erase.push_back(E);
291 b.blend_left = CMP_EPSILON; // May want to play last frame.
292 }
293 // Note: There may be issues if an animation event triggers an animation change while this blend is active,
294 // so it is best to use "deferred" calls instead of "immediate" for animation events that can trigger new animations.
295 _process_playback_data(b.data, p_delta, b.blend_left, false, false, false);
296 }
297 for (List<Blend>::Element *&E : to_erase) {
298 c.blend.erase(E);
299 }
300 }
301
302 bool AnimationPlayer::_blend_pre_process(double p_delta, int p_track_count, const AHashMap<NodePath, int> &p_track_map) {
303 if (!playback.current.from) {
304 _set_process(false);
305 return false;
306 }
307
308 tmp_from = playback.current.from->animation->get_instance_id();
309 end_reached = false;
310 end_notify = false;
311
312 finished_anim = StringName();
313
314 bool started = playback.started; // The animation may be changed during process, so it is safer that the state is changed before process.
315 if (playback.started) {
316 playback.started = false;
317 }
318
319 AnimationData *prev_from = playback.current.from;
320 _blend_playback_data(p_delta, started);
321
322 if (prev_from != playback.current.from) {
323 return false; // Animation has been changed in the process (may be caused by method track), abort process.
324 }
325
326 return true;
327 }
328
329 void AnimationPlayer::_blend_capture(double p_delta) {
330 blend_capture(p_delta * Math::abs(speed_scale));
331 }
332
333 void AnimationPlayer::_blend_post_process() {
334 if (end_reached) {
335 // If the method track changes current animation, the animation is not finished.
336 if (tmp_from == playback.current.from->animation->get_instance_id()) {
337 if (!playback_queue.is_empty()) {
338 if (!finished_anim.is_empty()) {
339 emit_signal(SceneStringName(animation_finished), finished_anim);
340 // Abort if playback_queue is cleared by animation_finished signal.
341 if (playback_queue.is_empty()) {
342 end_reached = false;
343 end_notify = false;
344 tmp_from = ObjectID();
345 return;
346 }
347 }
348 String old = playback.assigned;
349 play(playback_queue.front()->get());
350 String new_name = playback.assigned;
351 playback_queue.pop_front();
352 if (end_notify) {
353 emit_signal(SceneStringName(animation_changed), old, new_name);
354 }
355 } else {
356 _clear_caches();
357 playing = false;
358 _set_process(false);
359 if (end_notify) {
360 if (!finished_anim.is_empty()) {
361 emit_signal(SceneStringName(animation_finished), finished_anim);
362 }
363 emit_signal(SNAME("current_animation_changed"), "");
364 if (movie_quit_on_finish && OS::get_singleton()->has_feature("movie")) {
365 print_line(vformat("Movie Maker mode is enabled. Quitting on animation finish as requested by: %s", get_path()));
366 get_tree()->quit();
367 }
368 }
369 }
370 }
371 end_reached = false;
372 end_notify = false;
373 }
374 tmp_from = ObjectID();
375 }
376
377 void AnimationPlayer::queue(const StringName &p_name) {
378 if (!is_playing()) {
379 play(p_name);
380 } else {
381 playback_queue.push_back(p_name);
382 }
383 }
384
385 TypedArray<StringName> AnimationPlayer::get_queue() {
386 TypedArray<StringName> ret;
387 for (const StringName &E : playback_queue) {
388 ret.push_back(E);
389 }
390
391 return ret;
392 }
393
394 void AnimationPlayer::clear_queue() {
395 playback_queue.clear();
396 }
397
398 void AnimationPlayer::play_backwards(const StringName &p_name, double p_custom_blend) {
399 play(p_name, p_custom_blend, -1, true);
400 }
401
402 void AnimationPlayer::play_section_with_markers_backwards(const StringName &p_name, const StringName &p_start_marker, const StringName &p_end_marker, double p_custom_blend) {
403 play_section_with_markers(p_name, p_start_marker, p_end_marker, p_custom_blend, -1, true);
404 }
405
406 void AnimationPlayer::play_section_backwards(const StringName &p_name, double p_start_time, double p_end_time, double p_custom_blend) {
407 play_section(p_name, p_start_time, p_end_time, p_custom_blend, -1, true);
408 }
409
410 void AnimationPlayer::play(const StringName &p_name, double p_custom_blend, float p_custom_scale, bool p_from_end) {
411 if (auto_capture) {
412 play_with_capture(p_name, auto_capture_duration, p_custom_blend, p_custom_scale, p_from_end, auto_capture_transition_type, auto_capture_ease_type);
413 } else {
414 _play(p_name, p_custom_blend, p_custom_scale, p_from_end);
415 }
416 }
417
418 void AnimationPlayer::_play(const StringName &p_name, double p_custom_blend, float p_custom_scale, bool p_from_end) {
419 play_section_with_markers(p_name, StringName(), StringName(), p_custom_blend, p_custom_scale, p_from_end);
420 }
421
422 void AnimationPlayer::play_section_with_markers(const StringName &p_name, const StringName &p_start_marker, const StringName &p_end_marker, double p_custom_blend, float p_custom_scale, bool p_from_end) {
423 StringName name = p_name;
424
425 if (name == StringName()) {
426 name = playback.assigned;
427 }
428
429 ERR_FAIL_COND_MSG(!animation_set.has(name), vformat("Animation not found: %s.", name));
430
431 Ref<Animation> animation = animation_set[name].animation;
432
433 ERR_FAIL_COND_MSG(p_start_marker == p_end_marker && p_start_marker, vformat("Start marker and end marker cannot be the same marker: %s.", p_start_marker));
434 ERR_FAIL_COND_MSG(p_start_marker && !animation->has_marker(p_start_marker), vformat("Marker %s not found in animation: %s.", p_start_marker, name));
435 ERR_FAIL_COND_MSG(p_end_marker && !animation->has_marker(p_end_marker), vformat("Marker %s not found in animation: %s.", p_end_marker, name));
436
437 double start_time = p_start_marker ? animation->get_marker_time(p_start_marker) : -1;
438 double end_time = p_end_marker ? animation->get_marker_time(p_end_marker) : -1;
439
440 ERR_FAIL_COND_MSG(p_start_marker && p_end_marker && Animation::is_greater_approx(start_time, end_time), vformat("End marker %s is placed earlier than start marker %s in animation: %s.", p_end_marker, p_start_marker, name));
441
442 if (p_start_marker && Animation::is_less_approx(start_time, 0)) {
443 WARN_PRINT_ED(vformat("Negative time start marker: %s is invalid in the section, so the start of the animation: %s is used instead.", p_start_marker, playback.current.from->animation->get_name()));
444 }
445 if (p_end_marker && Animation::is_less_approx(end_time, 0)) {
446 WARN_PRINT_ED(vformat("Negative time end marker: %s is invalid in the section, so the end of the animation: %s is used instead.", p_end_marker, playback.current.from->animation->get_name()));
447 }
448
449 play_section(name, start_time, end_time, p_custom_blend, p_custom_scale, p_from_end);
450 }
451
452 void AnimationPlayer::play_section(const StringName &p_name, double p_start_time, double p_end_time, double p_custom_blend, float p_custom_scale, bool p_from_end) {
453 StringName name = p_name;
454
455 if (name == StringName()) {
456 name = playback.assigned;
457 }
458
459 ERR_FAIL_COND_MSG(!animation_set.has(name), vformat("Animation not found: %s.", name));
460 ERR_FAIL_COND_MSG(p_start_time >= 0 && p_end_time >= 0 && Math::is_equal_approx(p_start_time, p_end_time), "Start time and end time must not equal to each other.");
461 ERR_FAIL_COND_MSG(p_start_time >= 0 && p_end_time >= 0 && Animation::is_greater_approx(p_start_time, p_end_time), vformat("Start time %f is greater than end time %f.", p_start_time, p_end_time));
462
463 Playback &c = playback;
464
465 if (c.current.from) {
466 double blend_time = 0.0;
467 // Find if it can blend.
468 BlendKey bk;
469 bk.from = c.current.from->name;
470 bk.to = name;
471
472 if (Animation::is_greater_or_equal_approx(p_custom_blend, 0)) {
473 blend_time = p_custom_blend;
474 } else if (blend_times.has(bk)) {
475 blend_time = blend_times[bk];
476 } else {
477 bk.from = "*";
478 if (blend_times.has(bk)) {
479 blend_time = blend_times[bk];
480 } else {
481 bk.from = c.current.from->name;
482 bk.to = "*";
483
484 if (blend_times.has(bk)) {
485 blend_time = blend_times[bk];
486 }
487 }
488 }
489
490 if (Animation::is_less_approx(p_custom_blend, 0) && Math::is_zero_approx(blend_time) && default_blend_time) {
491 blend_time = default_blend_time;
492 }
493 if (Animation::is_greater_approx(blend_time, 0)) {
494 Blend b;
495 b.data = c.current;
496 b.blend_left = get_current_blend_amount();
497 b.blend_time = blend_time;
498 c.blend.push_back(b);
499 } else {
500 c.blend.clear();
501 }
502 }
503
504 if (get_current_animation() != p_name) {
505 _clear_playing_caches();
506 }
507
508 c.current.from = &animation_set[name];
509 c.current.speed_scale = p_custom_scale;
510 c.current.start_time = p_start_time;
511 c.current.end_time = p_end_time;
512
513 double start = playback.current.get_start_time();
514 double end = playback.current.get_end_time();
515
516 if (!end_reached) {
517 playback_queue.clear();
518 }
519
520 if (c.assigned != name) { // Reset.
521 c.current.pos = p_from_end ? end : start;
522 c.assigned = name;
523 emit_signal(SNAME("current_animation_changed"), c.assigned);
524 } else {
525 if (p_from_end && Animation::is_less_or_equal_approx(c.current.pos, start)) {
526 // Animation reset but played backwards, set position to the end.
527 seek_internal(end, true, true, true);
528 } else if (!p_from_end && Animation::is_greater_or_equal_approx(c.current.pos, end)) {
529 // Animation resumed but already ended, set position to the beginning.
530 seek_internal(start, true, true, true);
531 } else if (playing) {
532 return;
533 }
534 }
535
536 c.seeked = false;
537 c.started = true;
538
539 _set_process(true); // Always process when starting an animation.
540 playing = true;
541
542 emit_signal(SceneStringName(animation_started), c.assigned);
543
544 if (is_inside_tree() && Engine::get_singleton()->is_editor_hint()) {
545 return; // No next in this case.
546 }
547
548 StringName next = animation_get_next(p_name);
549 if (next != StringName() && animation_set.has(next)) {
550 queue(next);
551 }
552 }
553
554 void AnimationPlayer::_capture(const StringName &p_name, bool p_from_end, double p_duration, Tween::TransitionType p_trans_type, Tween::EaseType p_ease_type) {
555 StringName name = p_name;
556 if (name == StringName()) {
557 name = playback.assigned;
558 }
559
560 Ref<Animation> anim = get_animation(name);
561 if (anim.is_null() || !anim->is_capture_included()) {
562 return;
563 }
564 if (std::signbit(p_duration)) {
565 double max_dur = 0;
566 double current_pos = playback.current.pos;
567 if (playback.assigned != name) {
568 current_pos = p_from_end ? anim->get_length() : 0;
569 }
570 for (int i = 0; i < anim->get_track_count(); i++) {
571 if (anim->track_get_type(i) != Animation::TYPE_VALUE) {
572 continue;
573 }
574 if (anim->value_track_get_update_mode(i) != Animation::UPDATE_CAPTURE) {
575 continue;
576 }
577 if (anim->track_get_key_count(i) == 0) {
578 continue;
579 }
580 max_dur = MAX(max_dur, p_from_end ? current_pos - anim->track_get_key_time(i, anim->track_get_key_count(i) - 1) : anim->track_get_key_time(i, 0) - current_pos);
581 }
582 p_duration = max_dur;
583 }
584 if (Math::is_zero_approx(p_duration)) {
585 return;
586 }
587 capture(name, p_duration, p_trans_type, p_ease_type);
588 }
589
590 void AnimationPlayer::play_with_capture(const StringName &p_name, double p_duration, double p_custom_blend, float p_custom_scale, bool p_from_end, Tween::TransitionType p_trans_type, Tween::EaseType p_ease_type) {
591 _capture(p_name, p_from_end, p_duration, p_trans_type, p_ease_type);
592 _play(p_name, p_custom_blend, p_custom_scale, p_from_end);
593 }
594
595 bool AnimationPlayer::is_playing() const {
596 return playing;
597 }
598
599 void AnimationPlayer::set_current_animation(const StringName &p_animation) {
600 if (p_animation == SNAME("[stop]") || p_animation.is_empty()) {
601 // It should be call deferred and handled only when is_playing() == true to prevent infinite loops caused by seeking within stop().
602 // Especially when the key current_animation = "[stop]" is placed at the beginning of an animation,
603 // this line is called when the animation changes, so is_playing() == true must be checked.
604 if (is_playing()) {
605 callable_mp(this, &AnimationPlayer::stop).call_deferred(false);
606 }
607 } else if (!is_playing()) {
608 play(p_animation);
609 } else if (playback.assigned != p_animation) {
610 float speed = playback.current.speed_scale;
611 play(p_animation, -1.0, speed, std::signbit(speed));
612 } else {
613 // Same animation, do not replay from start.
614 }
615 }
616
617 StringName AnimationPlayer::get_current_animation() const {
618 return (is_playing() ? playback.assigned : StringName());
619 }
620
621 void AnimationPlayer::set_assigned_animation(const StringName &p_animation) {
622 if (is_playing()) {
623 float speed = playback.current.speed_scale;
624 play(p_animation, -1.0, speed, std::signbit(speed));
625 } else {
626 ERR_FAIL_COND_MSG(!animation_set.has(p_animation), vformat("Animation not found: %s.", p_animation.operator String()));
627 playback.current.pos = 0;
628 playback.current.from = &animation_set[p_animation];
629 playback.current.start_time = -1;
630 playback.current.end_time = -1;
631 playback.assigned = p_animation;
632 emit_signal(SNAME("current_animation_changed"), playback.assigned);
633 }
634 }
635
636 StringName AnimationPlayer::get_assigned_animation() const {
637 return playback.assigned;
638 }
639
640 void AnimationPlayer::pause() {
641 _stop_internal(false, false);
642 }
643
644 void AnimationPlayer::stop(bool p_keep_state) {
645 _stop_internal(true, p_keep_state);
646 }
647
648 void AnimationPlayer::set_speed_scale(float p_speed) {
649 speed_scale = p_speed;
650 }
651
652 float AnimationPlayer::get_speed_scale() const {
653 return speed_scale;
654 }
655
656 float AnimationPlayer::get_playing_speed() const {
657 if (!playing) {
658 return 0;
659 }
660 return speed_scale * playback.current.speed_scale;
661 }
662
663 void AnimationPlayer::seek_internal(double p_time, bool p_update, bool p_update_only, bool p_is_internal_seek) {
664 if (!active) {
665 return;
666 }
667
668 bool is_backward = Animation::is_less_approx(p_time, playback.current.pos);
669
670 _check_immediately_after_start();
671
672 playback.current.pos = p_time;
673 if (!playback.current.from) {
674 if (playback.assigned) {
675 ERR_FAIL_COND_MSG(!animation_set.has(playback.assigned), vformat("Animation not found: %s.", playback.assigned));
676 playback.current.from = &animation_set[playback.assigned];
677 }
678 if (!playback.current.from) {
679 return; // There is no animation.
680 }
681 }
682
683 double start = playback.current.get_start_time();
684 double end = playback.current.get_end_time();
685
686 // Clamp the seek position.
687 p_time = CLAMP(p_time, start, end);
688
689 playback.seeked = true;
690 playback.internal_seeked = p_is_internal_seek;
691
692 if (p_update) {
693 _process_animation(is_backward ? -0.0 : 0.0, p_update_only);
694 playback.seeked = false; // If animation was proceeded here, no more seek in internal process.
695 }
696 }
697
698 void AnimationPlayer::seek(double p_time, bool p_update, bool p_update_only) {
699 seek_internal(p_time, p_update, p_update_only);
700 }
701
702 void AnimationPlayer::advance(double p_time) {
703 _check_immediately_after_start();
704 AnimationMixer::advance(p_time);
705 }
706
707 void AnimationPlayer::_check_immediately_after_start() {
708 if (playback.started) {
709 _process_animation(0); // Force process current key for Discrete/Method/Audio/AnimationPlayback. Then, started flag is cleared.
710 }
711 }
712
713 bool AnimationPlayer::is_valid() const {
714 return (playback.current.from);
715 }
716
717 double AnimationPlayer::get_current_animation_position() const {
718 ERR_FAIL_NULL_V_MSG(playback.current.from, 0, "AnimationPlayer has no current animation.");
719 return playback.current.pos;
720 }
721
722 double AnimationPlayer::get_current_animation_length() const {
723 ERR_FAIL_NULL_V_MSG(playback.current.from, 0, "AnimationPlayer has no current animation.");
724 return playback.current.from->animation->get_length();
725 }
726
727 void AnimationPlayer::set_section_with_markers(const StringName &p_start_marker, const StringName &p_end_marker) {
728 ERR_FAIL_NULL_MSG(playback.current.from, "AnimationPlayer has no current animation.");
729 ERR_FAIL_COND_MSG(p_start_marker == p_end_marker && p_start_marker, vformat("Start marker and end marker cannot be the same marker: %s.", p_start_marker));
730 ERR_FAIL_COND_MSG(p_start_marker && !playback.current.from->animation->has_marker(p_start_marker), vformat("Marker %s not found in animation: %s.", p_start_marker, playback.current.from->animation->get_name()));
731 ERR_FAIL_COND_MSG(p_end_marker && !playback.current.from->animation->has_marker(p_end_marker), vformat("Marker %s not found in animation: %s.", p_end_marker, playback.current.from->animation->get_name()));
732 double start_time = p_start_marker ? playback.current.from->animation->get_marker_time(p_start_marker) : -1;
733 double end_time = p_end_marker ? playback.current.from->animation->get_marker_time(p_end_marker) : -1;
734 if (p_start_marker && Animation::is_less_approx(start_time, 0)) {
735 WARN_PRINT_ONCE_ED(vformat("Marker %s time must be positive in animation: %s.", p_start_marker, playback.current.from->animation->get_name()));
736 }
737 if (p_end_marker && Animation::is_less_approx(end_time, 0)) {
738 WARN_PRINT_ONCE_ED(vformat("Marker %s time must be positive in animation: %s.", p_end_marker, playback.current.from->animation->get_name()));
739 }
740 set_section(start_time, end_time);
741 }
742
743 void AnimationPlayer::set_section(double p_start_time, double p_end_time) {
744 ERR_FAIL_NULL_MSG(playback.current.from, "AnimationPlayer has no current animation.");
745 ERR_FAIL_COND_MSG(Animation::is_greater_or_equal_approx(p_start_time, 0) && Animation::is_greater_or_equal_approx(p_end_time, 0) && Animation::is_greater_or_equal_approx(p_start_time, p_end_time), vformat("Start time %f is greater than end time %f.", p_start_time, p_end_time));
746 playback.current.start_time = p_start_time;
747 playback.current.end_time = p_end_time;
748 playback.current.pos = CLAMP(playback.current.pos, playback.current.get_start_time(), playback.current.get_end_time());
749 }
750
751 void AnimationPlayer::reset_section() {
752 playback.current.start_time = -1;
753 playback.current.end_time = -1;
754 }
755
756 double AnimationPlayer::get_section_start_time() const {
757 ERR_FAIL_NULL_V_MSG(playback.current.from, playback.current.start_time, "AnimationPlayer has no current animation.");
758 return playback.current.get_start_time();
759 }
760
761 double AnimationPlayer::get_section_end_time() const {
762 ERR_FAIL_NULL_V_MSG(playback.current.from, playback.current.end_time, "AnimationPlayer has no current animation.");
763 return playback.current.get_end_time();
764 }
765
766 bool AnimationPlayer::has_section() const {
767 return Animation::is_greater_or_equal_approx(playback.current.start_time, 0) || Animation::is_greater_or_equal_approx(playback.current.end_time, 0);
768 }
769
770 void AnimationPlayer::set_autoplay(const StringName &p_name) {
771 if (is_inside_tree() && !Engine::get_singleton()->is_editor_hint()) {
772 WARN_PRINT("Setting autoplay after the node has been added to the scene has no effect.");
773 }
774
775 autoplay = p_name;
776 }
777
778 StringName AnimationPlayer::get_autoplay() const {
779 return autoplay;
780 }
781
782 void AnimationPlayer::set_movie_quit_on_finish_enabled(bool p_enabled) {
783 movie_quit_on_finish = p_enabled;
784 }
785
786 bool AnimationPlayer::is_movie_quit_on_finish_enabled() const {
787 return movie_quit_on_finish;
788 }
789
790 void AnimationPlayer::_stop_internal(bool p_reset, bool p_keep_state) {
791 _clear_caches();
792 Playback &c = playback;
793 double start = c.current.from ? playback.current.get_start_time() : 0;
794 if (p_reset) {
795 c.blend.clear();
796 if (p_keep_state) {
797 c.current.pos = start;
798 } else {
799 seek_internal(start, true, true, true);
800 }
801 c.current.from = nullptr;
802 c.current.speed_scale = 1;
803 emit_signal(SNAME("current_animation_changed"), "");
804 }
805 _set_process(false);
806 playback_queue.clear();
807 playing = false;
808 }
809
810 void AnimationPlayer::animation_set_next(const StringName &p_animation, const StringName &p_next) {
811 ERR_FAIL_COND_MSG(!animation_set.has(p_animation), vformat("Animation not found: %s.", p_animation));
812 animation_next_set[p_animation] = p_next;
813 }
814
815 StringName AnimationPlayer::animation_get_next(const StringName &p_animation) const {
816 if (!animation_next_set.has(p_animation)) {
817 return StringName();
818 }
819 return animation_next_set[p_animation];
820 }
821
822 void AnimationPlayer::set_default_blend_time(double p_default) {
823 default_blend_time = p_default;
824 }
825
826 double AnimationPlayer::get_default_blend_time() const {
827 return default_blend_time;
828 }
829
830 void AnimationPlayer::set_blend_time(const StringName &p_animation1, const StringName &p_animation2, double p_time) {
831 ERR_FAIL_COND_MSG(!animation_set.has(p_animation1), vformat("Animation not found: %s.", p_animation1));
832 ERR_FAIL_COND_MSG(!animation_set.has(p_animation2), vformat("Animation not found: %s.", p_animation2));
833 ERR_FAIL_COND_MSG(p_time < 0, "Blend time cannot be smaller than 0.");
834
835 BlendKey bk;
836 bk.from = p_animation1;
837 bk.to = p_animation2;
838 if (Math::is_zero_approx(p_time)) {
839 blend_times.erase(bk);
840 } else {
841 blend_times[bk] = p_time;
842 }
843 }
844
845 double AnimationPlayer::get_blend_time(const StringName &p_animation1, const StringName &p_animation2) const {
846 BlendKey bk;
847 bk.from = p_animation1;
848 bk.to = p_animation2;
849
850 if (blend_times.has(bk)) {
851 return blend_times[bk];
852 } else {
853 return 0;
854 }
855 }
856
857 void AnimationPlayer::set_auto_capture(bool p_auto_capture) {
858 auto_capture = p_auto_capture;
859 notify_property_list_changed();
860 }
861
862 bool AnimationPlayer::is_auto_capture() const {
863 return auto_capture;
864 }
865
866 void AnimationPlayer::set_auto_capture_duration(double p_auto_capture_duration) {
867 auto_capture_duration = p_auto_capture_duration;
868 }
869
870 double AnimationPlayer::get_auto_capture_duration() const {
871 return auto_capture_duration;
872 }
873
874 void AnimationPlayer::set_auto_capture_transition_type(Tween::TransitionType p_auto_capture_transition_type) {
875 auto_capture_transition_type = p_auto_capture_transition_type;
876 }
877
878 Tween::TransitionType AnimationPlayer::get_auto_capture_transition_type() const {
879 return auto_capture_transition_type;
880 }
881
882 void AnimationPlayer::set_auto_capture_ease_type(Tween::EaseType p_auto_capture_ease_type) {
883 auto_capture_ease_type = p_auto_capture_ease_type;
884 }
885
886 Tween::EaseType AnimationPlayer::get_auto_capture_ease_type() const {
887 return auto_capture_ease_type;
888 }
889
890 #ifdef TOOLS_ENABLED
891 void AnimationPlayer::get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const {
892 const String pf = p_function;
893 if (p_idx == 0 && (pf == "play" || pf == "play_backwards" || pf == "has_animation" || pf == "queue")) {
894 List<StringName> al;
895 get_animation_list(&al);
896 for (const StringName &name : al) {
897 r_options->push_back(String(name).quote());
898 }
899 }
900 AnimationMixer::get_argument_options(p_function, p_idx, r_options);
901 }
902 #endif
903
904 void AnimationPlayer::_animation_removed(const StringName &p_name, const StringName &p_library) {
905 AnimationMixer::_animation_removed(p_name, p_library);
906
907 StringName name = p_library == StringName() ? p_name : StringName(String(p_library) + "/" + String(p_name));
908
909 if (!animation_set.has(name)) {
910 return; // No need to update because not the one from the library being used.
911 }
912
913 _animation_set_cache_update();
914
915 // Erase blends if needed
916 List<BlendKey> to_erase;
917 for (const KeyValue<BlendKey, double> &E : blend_times) {
918 BlendKey bk = E.key;
919 if (bk.from == name || bk.to == name) {
920 to_erase.push_back(bk);
921 }
922 }
923
924 while (to_erase.size()) {
925 blend_times.erase(to_erase.front()->get());
926 to_erase.pop_front();
927 }
928 }
929
930 void AnimationPlayer::_rename_animation(const StringName &p_from_name, const StringName &p_to_name) {
931 AnimationMixer::_rename_animation(p_from_name, p_to_name);
932
933 // Rename autoplay or blends if needed.
934 List<BlendKey> to_erase;
935 HashMap<BlendKey, double, BlendKey> to_insert;
936 for (const KeyValue<BlendKey, double> &E : blend_times) {
937 BlendKey bk = E.key;
938 BlendKey new_bk = bk;
939 bool erase = false;
940 if (bk.from == p_from_name) {
941 new_bk.from = p_to_name;
942 erase = true;
943 }
944 if (bk.to == p_from_name) {
945 new_bk.to = p_to_name;
946 erase = true;
947 }
948
949 if (erase) {
950 to_erase.push_back(bk);
951 to_insert[new_bk] = E.value;
952 }
953 }
954
955 while (to_erase.size()) {
956 blend_times.erase(to_erase.front()->get());
957 to_erase.pop_front();
958 }
959
960 while (to_insert.size()) {
961 blend_times[to_insert.begin()->key] = to_insert.begin()->value;
962 to_insert.remove(to_insert.begin());
963 }
964
965 if (autoplay == p_from_name) {
966 autoplay = p_to_name;
967 }
968 }
969
970 void AnimationPlayer::_bind_methods() {
971 ClassDB::bind_method(D_METHOD("animation_set_next", "animation_from", "animation_to"), &AnimationPlayer::animation_set_next);
972 ClassDB::bind_method(D_METHOD("animation_get_next", "animation_from"), &AnimationPlayer::animation_get_next);
973
974 ClassDB::bind_method(D_METHOD("set_blend_time", "animation_from", "animation_to", "sec"), &AnimationPlayer::set_blend_time);
975 ClassDB::bind_method(D_METHOD("get_blend_time", "animation_from", "animation_to"), &AnimationPlayer::get_blend_time);
976
977 ClassDB::bind_method(D_METHOD("set_default_blend_time", "sec"), &AnimationPlayer::set_default_blend_time);
978 ClassDB::bind_method(D_METHOD("get_default_blend_time"), &AnimationPlayer::get_default_blend_time);
979
980 ClassDB::bind_method(D_METHOD("set_auto_capture", "auto_capture"), &AnimationPlayer::set_auto_capture);
981 ClassDB::bind_method(D_METHOD("is_auto_capture"), &AnimationPlayer::is_auto_capture);
982 ClassDB::bind_method(D_METHOD("set_auto_capture_duration", "auto_capture_duration"), &AnimationPlayer::set_auto_capture_duration);
983 ClassDB::bind_method(D_METHOD("get_auto_capture_duration"), &AnimationPlayer::get_auto_capture_duration);
984 ClassDB::bind_method(D_METHOD("set_auto_capture_transition_type", "auto_capture_transition_type"), &AnimationPlayer::set_auto_capture_transition_type);
985 ClassDB::bind_method(D_METHOD("get_auto_capture_transition_type"), &AnimationPlayer::get_auto_capture_transition_type);
986 ClassDB::bind_method(D_METHOD("set_auto_capture_ease_type", "auto_capture_ease_type"), &AnimationPlayer::set_auto_capture_ease_type);
987 ClassDB::bind_method(D_METHOD("get_auto_capture_ease_type"), &AnimationPlayer::get_auto_capture_ease_type);
988
989 ClassDB::bind_method(D_METHOD("play", "name", "custom_blend", "custom_speed", "from_end"), &AnimationPlayer::play, DEFVAL(StringName()), DEFVAL(-1), DEFVAL(1.0), DEFVAL(false));
990 ClassDB::bind_method(D_METHOD("play_section_with_markers", "name", "start_marker", "end_marker", "custom_blend", "custom_speed", "from_end"), &AnimationPlayer::play_section_with_markers, DEFVAL(StringName()), DEFVAL(StringName()), DEFVAL(StringName()), DEFVAL(-1), DEFVAL(1.0), DEFVAL(false));
991 ClassDB::bind_method(D_METHOD("play_section", "name", "start_time", "end_time", "custom_blend", "custom_speed", "from_end"), &AnimationPlayer::play_section, DEFVAL(StringName()), DEFVAL(-1), DEFVAL(-1), DEFVAL(-1), DEFVAL(1.0), DEFVAL(false));
992 ClassDB::bind_method(D_METHOD("play_backwards", "name", "custom_blend"), &AnimationPlayer::play_backwards, DEFVAL(StringName()), DEFVAL(-1));
993 ClassDB::bind_method(D_METHOD("play_section_with_markers_backwards", "name", "start_marker", "end_marker", "custom_blend"), &AnimationPlayer::play_section_with_markers_backwards, DEFVAL(StringName()), DEFVAL(StringName()), DEFVAL(StringName()), DEFVAL(-1));
994 ClassDB::bind_method(D_METHOD("play_section_backwards", "name", "start_time", "end_time", "custom_blend"), &AnimationPlayer::play_section_backwards, DEFVAL(StringName()), DEFVAL(-1), DEFVAL(-1), DEFVAL(-1));
995 ClassDB::bind_method(D_METHOD("play_with_capture", "name", "duration", "custom_blend", "custom_speed", "from_end", "trans_type", "ease_type"), &AnimationPlayer::play_with_capture, DEFVAL(StringName()), DEFVAL(-1.0), DEFVAL(-1), DEFVAL(1.0), DEFVAL(false), DEFVAL(Tween::TRANS_LINEAR), DEFVAL(Tween::EASE_IN));
996 ClassDB::bind_method(D_METHOD("pause"), &AnimationPlayer::pause);
997 ClassDB::bind_method(D_METHOD("stop", "keep_state"), &AnimationPlayer::stop, DEFVAL(false));
998 ClassDB::bind_method(D_METHOD("is_playing"), &AnimationPlayer::is_playing);
999 ClassDB::bind_method(D_METHOD("is_animation_active"), &AnimationPlayer::is_valid);
1000
1001 ClassDB::bind_method(D_METHOD("set_current_animation", "animation"), &AnimationPlayer::set_current_animation);
1002 ClassDB::bind_method(D_METHOD("get_current_animation"), &AnimationPlayer::get_current_animation);
1003 ClassDB::bind_method(D_METHOD("set_assigned_animation", "animation"), &AnimationPlayer::set_assigned_animation);
1004 ClassDB::bind_method(D_METHOD("get_assigned_animation"), &AnimationPlayer::get_assigned_animation);
1005 ClassDB::bind_method(D_METHOD("queue", "name"), &AnimationPlayer::queue);
1006 ClassDB::bind_method(D_METHOD("get_queue"), &AnimationPlayer::get_queue);
1007 ClassDB::bind_method(D_METHOD("clear_queue"), &AnimationPlayer::clear_queue);
1008
1009 ClassDB::bind_method(D_METHOD("set_speed_scale", "speed"), &AnimationPlayer::set_speed_scale);
1010 ClassDB::bind_method(D_METHOD("get_speed_scale"), &AnimationPlayer::get_speed_scale);
1011 ClassDB::bind_method(D_METHOD("get_playing_speed"), &AnimationPlayer::get_playing_speed);
1012
1013 ClassDB::bind_method(D_METHOD("set_autoplay", "name"), &AnimationPlayer::set_autoplay);
1014 ClassDB::bind_method(D_METHOD("get_autoplay"), &AnimationPlayer::get_autoplay);
1015
1016 ClassDB::bind_method(D_METHOD("find_animation", "animation"), &AnimationPlayer::find_animation);
1017 ClassDB::bind_method(D_METHOD("find_animation_library", "animation"), &AnimationPlayer::find_animation_library);
1018
1019 ClassDB::bind_method(D_METHOD("set_movie_quit_on_finish_enabled", "enabled"), &AnimationPlayer::set_movie_quit_on_finish_enabled);
1020 ClassDB::bind_method(D_METHOD("is_movie_quit_on_finish_enabled"), &AnimationPlayer::is_movie_quit_on_finish_enabled);
1021
1022 ClassDB::bind_method(D_METHOD("get_current_animation_position"), &AnimationPlayer::get_current_animation_position);
1023 ClassDB::bind_method(D_METHOD("get_current_animation_length"), &AnimationPlayer::get_current_animation_length);
1024
1025 ClassDB::bind_method(D_METHOD("set_section_with_markers", "start_marker", "end_marker"), &AnimationPlayer::set_section_with_markers, DEFVAL(StringName()), DEFVAL(StringName()));
1026 ClassDB::bind_method(D_METHOD("set_section", "start_time", "end_time"), &AnimationPlayer::set_section, DEFVAL(-1), DEFVAL(-1));
1027 ClassDB::bind_method(D_METHOD("reset_section"), &AnimationPlayer::reset_section);
1028
1029 ClassDB::bind_method(D_METHOD("get_section_start_time"), &AnimationPlayer::get_section_start_time);
1030 ClassDB::bind_method(D_METHOD("get_section_end_time"), &AnimationPlayer::get_section_end_time);
1031 ClassDB::bind_method(D_METHOD("has_section"), &AnimationPlayer::has_section);
1032
1033 ClassDB::bind_method(D_METHOD("seek", "seconds", "update", "update_only"), &AnimationPlayer::seek, DEFVAL(false), DEFVAL(false));
1034
1035 ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "current_animation", PROPERTY_HINT_ENUM, "", PROPERTY_USAGE_EDITOR), "set_current_animation", "get_current_animation");
1036 ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "assigned_animation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_assigned_animation", "get_assigned_animation");
1037 ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "autoplay", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_autoplay", "get_autoplay");
1038 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "current_animation_length", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_current_animation_length");
1039 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "current_animation_position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_current_animation_position");
1040
1041 ADD_GROUP("Playback Options", "playback_");
1042 ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playback_auto_capture"), "set_auto_capture", "is_auto_capture");
1043 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "playback_auto_capture_duration", PROPERTY_HINT_NONE, "suffix:s"), "set_auto_capture_duration", "get_auto_capture_duration");
1044 ADD_PROPERTY(PropertyInfo(Variant::INT, "playback_auto_capture_transition_type", PROPERTY_HINT_ENUM, "Linear,Sine,Quint,Quart,Quad,Expo,Elastic,Cubic,Circ,Bounce,Back,Spring"), "set_auto_capture_transition_type", "get_auto_capture_transition_type");
1045 ADD_PROPERTY(PropertyInfo(Variant::INT, "playback_auto_capture_ease_type", PROPERTY_HINT_ENUM, "In,Out,InOut,OutIn"), "set_auto_capture_ease_type", "get_auto_capture_ease_type");
1046 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "playback_default_blend_time", PROPERTY_HINT_RANGE, "0,4096,0.01,suffix:s"), "set_default_blend_time", "get_default_blend_time");
1047
1048 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "speed_scale", PROPERTY_HINT_RANGE, "-4,4,0.001,or_less,or_greater"), "set_speed_scale", "get_speed_scale");
1049 ADD_PROPERTY(PropertyInfo(Variant::BOOL, "movie_quit_on_finish"), "set_movie_quit_on_finish_enabled", "is_movie_quit_on_finish_enabled");
1050
1051 ADD_SIGNAL(MethodInfo(SNAME("current_animation_changed"), PropertyInfo(Variant::STRING_NAME, "name")));
1052 ADD_SIGNAL(MethodInfo(SNAME("animation_changed"), PropertyInfo(Variant::STRING_NAME, "old_name"), PropertyInfo(Variant::STRING_NAME, "new_name")));
1053 }
1054
1055 AnimationPlayer::AnimationPlayer() {
1056 }
1057
1058 AnimationPlayer::~AnimationPlayer() {
1059 }