2023-01-05 13:25:55 +01:00
|
|
|
/**************************************************************************/
|
|
|
|
/* animation_player.h */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
|
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/**************************************************************************/
|
2018-01-05 00:50:27 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
#ifndef ANIMATION_PLAYER_H
|
|
|
|
#define ANIMATION_PLAYER_H
|
|
|
|
|
|
|
|
#include "scene/2d/node_2d.h"
|
2021-10-16 00:04:35 +02:00
|
|
|
#include "scene/3d/mesh_instance_3d.h"
|
2020-03-26 22:49:16 +01:00
|
|
|
#include "scene/3d/node_3d.h"
|
|
|
|
#include "scene/3d/skeleton_3d.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
#include "scene/resources/animation.h"
|
2022-04-07 13:49:28 +02:00
|
|
|
#include "scene/resources/animation_library.h"
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-11-01 21:32:39 +01:00
|
|
|
#ifdef TOOLS_ENABLED
|
2021-06-04 18:03:15 +02:00
|
|
|
class AnimatedValuesBackup : public RefCounted {
|
|
|
|
GDCLASS(AnimatedValuesBackup, RefCounted);
|
2020-12-20 11:46:44 +01:00
|
|
|
|
2017-11-01 21:32:39 +01:00
|
|
|
struct Entry {
|
2021-02-07 22:29:31 +01:00
|
|
|
Object *object = nullptr;
|
2017-11-01 21:32:39 +01:00
|
|
|
Vector<StringName> subpath; // Unused if bone
|
2021-02-07 22:29:31 +01:00
|
|
|
int bone_idx = -1; // -1 if not a bone
|
2017-11-01 21:32:39 +01:00
|
|
|
Variant value;
|
|
|
|
};
|
|
|
|
Vector<Entry> entries;
|
|
|
|
|
|
|
|
friend class AnimationPlayer;
|
2017-10-30 19:43:19 +01:00
|
|
|
|
2020-12-20 11:46:44 +01:00
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-10-30 19:43:19 +01:00
|
|
|
public:
|
|
|
|
void update_skeletons();
|
2020-12-20 11:46:44 +01:00
|
|
|
void restore() const;
|
2017-11-01 21:32:39 +01:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
class AnimationPlayer : public Node {
|
2017-01-03 03:03:46 +01:00
|
|
|
GDCLASS(AnimationPlayer, Node);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
public:
|
2021-02-18 19:52:29 +01:00
|
|
|
enum AnimationProcessCallback {
|
2017-09-30 16:19:07 +02:00
|
|
|
ANIMATION_PROCESS_PHYSICS,
|
2014-02-10 02:10:30 +01:00
|
|
|
ANIMATION_PROCESS_IDLE,
|
2018-08-02 09:22:24 +02:00
|
|
|
ANIMATION_PROCESS_MANUAL,
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
2018-12-08 19:56:20 +01:00
|
|
|
enum AnimationMethodCallMode {
|
|
|
|
ANIMATION_METHOD_CALL_DEFERRED,
|
|
|
|
ANIMATION_METHOD_CALL_IMMEDIATE,
|
|
|
|
};
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
private:
|
|
|
|
enum {
|
|
|
|
NODE_CACHE_UPDATE_MAX = 1024,
|
|
|
|
BLEND_FROM_MAX = 3
|
|
|
|
};
|
|
|
|
|
|
|
|
enum SpecialProperty {
|
|
|
|
SP_NONE,
|
|
|
|
SP_NODE2D_POS,
|
|
|
|
SP_NODE2D_ROT,
|
|
|
|
SP_NODE2D_SCALE,
|
|
|
|
};
|
|
|
|
|
Remove animation 3D transform track, replace by loc/rot/scale tracks.
* `Animation.TYPE_TRANSFORM3D` track is gone.
* Added POSITION_3D, ROTATION_3D, SCALE_3D tracks.
* GLTF2, Collada, FBX importers will only import the track types found.
* Skeleton3D bone poses are now Pos/Rot/Scale, pose matrix removed.
* AnimationPlayer and AnimationTree animate these tracks separately, only when found.
* Removed BakeReset code, is useless with these changes.
This is the first in a series of commits designed to make the animation system in Godot more useful, which includes:
* Better compatibility with Autodesk products
* Better reusability of animations across models (including retargeting).
* Proper animation compression.
* etc.
*Note* GLTF2 animation saving went broken with this PR, needs to be fixed in a subsequent one.
2021-10-12 00:20:58 +02:00
|
|
|
uint32_t setup_pass = 1;
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
struct TrackNodeCache {
|
2015-12-05 18:18:22 +01:00
|
|
|
NodePath path;
|
2020-05-12 17:01:17 +02:00
|
|
|
uint32_t id = 0;
|
2022-05-03 01:43:50 +02:00
|
|
|
Ref<Resource> resource;
|
2020-05-12 17:01:17 +02:00
|
|
|
Node *node = nullptr;
|
|
|
|
Node2D *node_2d = nullptr;
|
2021-03-18 00:35:42 +01:00
|
|
|
#ifndef _3D_DISABLED
|
|
|
|
Node3D *node_3d = nullptr;
|
2020-05-12 17:01:17 +02:00
|
|
|
Skeleton3D *skeleton = nullptr;
|
2021-10-16 00:04:35 +02:00
|
|
|
MeshInstance3D *node_blend_shape = nullptr;
|
|
|
|
int blend_shape_idx = -1;
|
2021-03-18 00:35:42 +01:00
|
|
|
#endif // _3D_DISABLED
|
2020-05-12 17:01:17 +02:00
|
|
|
int bone_idx = -1;
|
2014-02-10 02:10:30 +01:00
|
|
|
// accumulated transforms
|
|
|
|
|
Remove animation 3D transform track, replace by loc/rot/scale tracks.
* `Animation.TYPE_TRANSFORM3D` track is gone.
* Added POSITION_3D, ROTATION_3D, SCALE_3D tracks.
* GLTF2, Collada, FBX importers will only import the track types found.
* Skeleton3D bone poses are now Pos/Rot/Scale, pose matrix removed.
* AnimationPlayer and AnimationTree animate these tracks separately, only when found.
* Removed BakeReset code, is useless with these changes.
This is the first in a series of commits designed to make the animation system in Godot more useful, which includes:
* Better compatibility with Autodesk products
* Better reusability of animations across models (including retargeting).
* Proper animation compression.
* etc.
*Note* GLTF2 animation saving went broken with this PR, needs to be fixed in a subsequent one.
2021-10-12 00:20:58 +02:00
|
|
|
bool loc_used = false;
|
|
|
|
bool rot_used = false;
|
|
|
|
bool scale_used = false;
|
2022-07-25 22:32:26 +02:00
|
|
|
Vector3 init_loc = Vector3(0, 0, 0);
|
|
|
|
Quaternion init_rot = Quaternion(0, 0, 0, 1);
|
|
|
|
Vector3 init_scale = Vector3(1, 1, 1);
|
Remove animation 3D transform track, replace by loc/rot/scale tracks.
* `Animation.TYPE_TRANSFORM3D` track is gone.
* Added POSITION_3D, ROTATION_3D, SCALE_3D tracks.
* GLTF2, Collada, FBX importers will only import the track types found.
* Skeleton3D bone poses are now Pos/Rot/Scale, pose matrix removed.
* AnimationPlayer and AnimationTree animate these tracks separately, only when found.
* Removed BakeReset code, is useless with these changes.
This is the first in a series of commits designed to make the animation system in Godot more useful, which includes:
* Better compatibility with Autodesk products
* Better reusability of animations across models (including retargeting).
* Proper animation compression.
* etc.
*Note* GLTF2 animation saving went broken with this PR, needs to be fixed in a subsequent one.
2021-10-12 00:20:58 +02:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
Vector3 loc_accum;
|
2021-01-20 08:02:02 +01:00
|
|
|
Quaternion rot_accum;
|
2014-02-10 02:10:30 +01:00
|
|
|
Vector3 scale_accum;
|
2021-10-16 00:04:35 +02:00
|
|
|
float blend_shape_accum = 0;
|
2020-05-12 17:01:17 +02:00
|
|
|
uint64_t accum_pass = 0;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2020-05-12 17:01:17 +02:00
|
|
|
bool audio_playing = false;
|
|
|
|
float audio_start = 0.0;
|
|
|
|
float audio_len = 0.0;
|
2018-06-07 17:46:14 +02:00
|
|
|
|
2020-05-12 17:01:17 +02:00
|
|
|
bool animation_playing = false;
|
2018-06-07 17:46:14 +02:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
struct PropertyAnim {
|
2020-05-12 17:01:17 +02:00
|
|
|
TrackNodeCache *owner = nullptr;
|
|
|
|
SpecialProperty special = SP_NONE; //small optimization
|
2017-05-30 22:20:15 +02:00
|
|
|
Vector<StringName> subpath;
|
2020-05-12 17:01:17 +02:00
|
|
|
Object *object = nullptr;
|
2014-02-10 02:10:30 +01:00
|
|
|
Variant value_accum;
|
2020-05-12 17:01:17 +02:00
|
|
|
uint64_t accum_pass = 0;
|
2018-06-07 17:46:14 +02:00
|
|
|
Variant capture;
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
2022-05-13 15:04:37 +02:00
|
|
|
HashMap<StringName, PropertyAnim> property_anim;
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2018-06-07 17:46:14 +02:00
|
|
|
struct BezierAnim {
|
|
|
|
Vector<StringName> bezier_property;
|
2020-05-12 17:01:17 +02:00
|
|
|
TrackNodeCache *owner = nullptr;
|
|
|
|
float bezier_accum = 0.0;
|
|
|
|
Object *object = nullptr;
|
|
|
|
uint64_t accum_pass = 0;
|
2018-06-07 17:46:14 +02:00
|
|
|
};
|
|
|
|
|
2022-05-13 15:04:37 +02:00
|
|
|
HashMap<StringName, BezierAnim> bezier_anim;
|
2018-06-07 17:46:14 +02:00
|
|
|
|
Remove animation 3D transform track, replace by loc/rot/scale tracks.
* `Animation.TYPE_TRANSFORM3D` track is gone.
* Added POSITION_3D, ROTATION_3D, SCALE_3D tracks.
* GLTF2, Collada, FBX importers will only import the track types found.
* Skeleton3D bone poses are now Pos/Rot/Scale, pose matrix removed.
* AnimationPlayer and AnimationTree animate these tracks separately, only when found.
* Removed BakeReset code, is useless with these changes.
This is the first in a series of commits designed to make the animation system in Godot more useful, which includes:
* Better compatibility with Autodesk products
* Better reusability of animations across models (including retargeting).
* Proper animation compression.
* etc.
*Note* GLTF2 animation saving went broken with this PR, needs to be fixed in a subsequent one.
2021-10-12 00:20:58 +02:00
|
|
|
uint32_t last_setup_pass = 0;
|
2020-05-12 17:01:17 +02:00
|
|
|
TrackNodeCache() {}
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct TrackNodeCacheKey {
|
2020-02-12 18:24:06 +01:00
|
|
|
ObjectID id;
|
2021-02-07 22:29:31 +01:00
|
|
|
int bone_idx = -1;
|
2021-10-16 00:04:35 +02:00
|
|
|
int blend_shape_idx = -1;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2022-05-13 15:04:37 +02:00
|
|
|
static uint32_t hash(const TrackNodeCacheKey &p_key) {
|
|
|
|
uint32_t h = hash_one_uint64(p_key.id);
|
2022-06-18 16:20:55 +02:00
|
|
|
h = hash_murmur3_one_32(p_key.bone_idx, h);
|
|
|
|
return hash_fmix32(hash_murmur3_one_32(p_key.blend_shape_idx, h));
|
2022-05-13 15:04:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
inline bool operator==(const TrackNodeCacheKey &p_right) const {
|
|
|
|
return id == p_right.id && bone_idx == p_right.bone_idx && blend_shape_idx == p_right.blend_shape_idx;
|
|
|
|
}
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
inline bool operator<(const TrackNodeCacheKey &p_right) const {
|
2020-05-14 16:41:43 +02:00
|
|
|
if (id == p_right.id) {
|
2021-10-16 00:04:35 +02:00
|
|
|
if (blend_shape_idx == p_right.blend_shape_idx) {
|
|
|
|
return bone_idx < p_right.bone_idx;
|
|
|
|
} else {
|
|
|
|
return blend_shape_idx < p_right.blend_shape_idx;
|
|
|
|
}
|
2020-05-14 16:41:43 +02:00
|
|
|
} else {
|
2020-02-12 18:24:06 +01:00
|
|
|
return id < p_right.id;
|
2020-05-14 16:41:43 +02:00
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-05-13 15:04:37 +02:00
|
|
|
HashMap<TrackNodeCacheKey, TrackNodeCache, TrackNodeCacheKey> node_cache_map;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
TrackNodeCache *cache_update[NODE_CACHE_UPDATE_MAX];
|
2021-02-07 22:29:31 +01:00
|
|
|
int cache_update_size = 0;
|
2014-02-10 02:10:30 +01:00
|
|
|
TrackNodeCache::PropertyAnim *cache_update_prop[NODE_CACHE_UPDATE_MAX];
|
2021-02-07 22:29:31 +01:00
|
|
|
int cache_update_prop_size = 0;
|
2018-06-07 17:46:14 +02:00
|
|
|
TrackNodeCache::BezierAnim *cache_update_bezier[NODE_CACHE_UPDATE_MAX];
|
2021-02-07 22:29:31 +01:00
|
|
|
int cache_update_bezier_size = 0;
|
2022-05-19 17:00:06 +02:00
|
|
|
HashSet<TrackNodeCache *> playing_caches;
|
2018-06-07 17:46:14 +02:00
|
|
|
|
2021-02-07 22:29:31 +01:00
|
|
|
uint64_t accum_pass = 1;
|
|
|
|
float speed_scale = 1.0;
|
2022-09-22 15:54:15 +02:00
|
|
|
double default_blend_time = 0.0;
|
2019-11-19 14:39:10 +01:00
|
|
|
bool is_stopping = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
struct AnimationData {
|
|
|
|
String name;
|
|
|
|
StringName next;
|
|
|
|
Vector<TrackNodeCache *> node_cache;
|
|
|
|
Ref<Animation> animation;
|
2022-04-07 13:49:28 +02:00
|
|
|
StringName animation_library;
|
|
|
|
uint64_t last_update = 0;
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
2022-05-13 15:04:37 +02:00
|
|
|
HashMap<StringName, AnimationData> animation_set;
|
2022-04-07 13:49:28 +02:00
|
|
|
|
|
|
|
struct AnimationLibraryData {
|
|
|
|
StringName name;
|
|
|
|
Ref<AnimationLibrary> library;
|
|
|
|
bool operator<(const AnimationLibraryData &p_data) const { return name.operator String() < p_data.name.operator String(); }
|
|
|
|
};
|
|
|
|
|
|
|
|
LocalVector<AnimationLibraryData> animation_libraries;
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
struct BlendKey {
|
|
|
|
StringName from;
|
|
|
|
StringName to;
|
2022-05-13 15:04:37 +02:00
|
|
|
static uint32_t hash(const BlendKey &p_key) {
|
|
|
|
return hash_one_uint64((uint64_t(p_key.from.hash()) << 32) | uint32_t(p_key.to.hash()));
|
|
|
|
}
|
|
|
|
bool operator==(const BlendKey &bk) const {
|
|
|
|
return from == bk.from && to == bk.to;
|
|
|
|
}
|
|
|
|
bool operator<(const BlendKey &bk) const {
|
|
|
|
if (from == bk.from) {
|
|
|
|
return to < bk.to;
|
|
|
|
} else {
|
|
|
|
return from < bk.from;
|
|
|
|
}
|
|
|
|
}
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
|
|
|
|
2022-09-22 15:54:15 +02:00
|
|
|
HashMap<BlendKey, double, BlendKey> blend_times;
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
struct PlaybackData {
|
2021-02-07 22:29:31 +01:00
|
|
|
AnimationData *from = nullptr;
|
2021-11-26 23:53:48 +01:00
|
|
|
double pos = 0.0;
|
2021-02-07 22:29:31 +01:00
|
|
|
float speed_scale = 1.0;
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
struct Blend {
|
|
|
|
PlaybackData data;
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2022-09-22 15:54:15 +02:00
|
|
|
double blend_time = 0.0;
|
|
|
|
double blend_left = 0.0;
|
2014-02-10 02:10:30 +01:00
|
|
|
};
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
struct Playback {
|
2016-03-09 00:00:52 +01:00
|
|
|
List<Blend> blend;
|
2014-02-10 02:10:30 +01:00
|
|
|
PlaybackData current;
|
|
|
|
StringName assigned;
|
2021-02-07 22:29:31 +01:00
|
|
|
bool seeked = false;
|
|
|
|
bool started = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
} playback;
|
|
|
|
|
|
|
|
List<StringName> queued;
|
|
|
|
|
2021-02-07 22:29:31 +01:00
|
|
|
bool end_reached = false;
|
|
|
|
bool end_notify = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
String autoplay;
|
2021-02-07 22:29:31 +01:00
|
|
|
bool reset_on_save = true;
|
2021-02-18 19:52:29 +01:00
|
|
|
AnimationProcessCallback process_callback = ANIMATION_PROCESS_IDLE;
|
2021-02-07 22:29:31 +01:00
|
|
|
AnimationMethodCallMode method_call_mode = ANIMATION_METHOD_CALL_DEFERRED;
|
2022-06-26 01:38:20 +02:00
|
|
|
bool movie_quit_on_finish = false;
|
2021-02-07 22:29:31 +01:00
|
|
|
bool processing = false;
|
|
|
|
bool active = true;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
NodePath root;
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2022-11-29 10:51:45 +01:00
|
|
|
void _animation_process_animation(AnimationData *p_anim, double p_prev_time, double p_time, double p_delta, float p_interp, bool p_is_current = true, bool p_seeked = false, bool p_started = false, Animation::LoopedFlag p_looped_flag = Animation::LOOPED_FLAG_NONE);
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2021-02-09 21:41:48 +01:00
|
|
|
void _ensure_node_caches(AnimationData *p_anim, Node *p_root_override = nullptr);
|
2021-05-21 08:42:37 +02:00
|
|
|
void _animation_process_data(PlaybackData &cd, double p_delta, float p_blend, bool p_seeked, bool p_started);
|
|
|
|
void _animation_process2(double p_delta, bool p_started);
|
2014-02-10 02:10:30 +01:00
|
|
|
void _animation_update_transforms();
|
2021-05-21 08:42:37 +02:00
|
|
|
void _animation_process(double p_delta);
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void _node_removed(Node *p_node);
|
2019-11-19 14:39:10 +01:00
|
|
|
void _stop_playing_caches(bool p_reset);
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
// bind helpers
|
2020-02-17 22:06:54 +01:00
|
|
|
Vector<String> _get_animation_list() const {
|
2014-02-10 02:10:30 +01:00
|
|
|
List<StringName> animations;
|
|
|
|
get_animation_list(&animations);
|
2020-02-17 22:06:54 +01:00
|
|
|
Vector<String> ret;
|
2014-02-10 02:10:30 +01:00
|
|
|
while (animations.size()) {
|
|
|
|
ret.push_back(animations.front()->get());
|
|
|
|
animations.pop_front();
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2022-06-12 03:14:40 +02:00
|
|
|
void _animation_changed(const StringName &p_name);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
void _set_process(bool p_process, bool p_force = false);
|
2023-01-18 14:02:04 +01:00
|
|
|
void _stop_internal(bool p_reset, bool p_keep_state);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2021-02-07 22:29:31 +01:00
|
|
|
bool playing = false;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2022-04-07 13:49:28 +02:00
|
|
|
uint64_t animation_set_update_pass = 1;
|
|
|
|
void _animation_set_cache_update();
|
|
|
|
void _animation_added(const StringName &p_name, const StringName &p_library);
|
|
|
|
void _animation_removed(const StringName &p_name, const StringName &p_library);
|
|
|
|
void _animation_renamed(const StringName &p_name, const StringName &p_to_name, const StringName &p_library);
|
|
|
|
void _rename_animation(const StringName &p_from_name, const StringName &p_to_name);
|
|
|
|
|
|
|
|
TypedArray<StringName> _get_animation_library_list() const;
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
protected:
|
|
|
|
bool _set(const StringName &p_name, const Variant &p_value);
|
|
|
|
bool _get(const StringName &p_name, Variant &r_ret) const;
|
2022-08-12 22:57:11 +02:00
|
|
|
void _validate_property(PropertyInfo &p_property) const;
|
2014-02-10 02:10:30 +01:00
|
|
|
void _get_property_list(List<PropertyInfo> *p_list) const;
|
|
|
|
void _notification(int p_what);
|
2016-03-09 00:00:52 +01:00
|
|
|
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2022-07-26 11:48:08 +02:00
|
|
|
virtual Variant _post_process_key_value(const Ref<Animation> &p_anim, int p_track, Variant p_value, const Object *p_object, int p_object_idx = -1);
|
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
public:
|
|
|
|
StringName find_animation(const Ref<Animation> &p_animation) const;
|
2022-04-07 13:49:28 +02:00
|
|
|
StringName find_animation_library(const Ref<Animation> &p_animation) const;
|
|
|
|
|
|
|
|
Error add_animation_library(const StringName &p_name, const Ref<AnimationLibrary> &p_animation_library);
|
|
|
|
void remove_animation_library(const StringName &p_name);
|
|
|
|
void rename_animation_library(const StringName &p_name, const StringName &p_new_name);
|
|
|
|
Ref<AnimationLibrary> get_animation_library(const StringName &p_name) const;
|
|
|
|
void get_animation_library_list(List<StringName> *p_animations) const;
|
|
|
|
bool has_animation_library(const StringName &p_name) const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
Ref<Animation> get_animation(const StringName &p_name) const;
|
|
|
|
void get_animation_list(List<StringName> *p_animations) const;
|
2022-04-07 13:49:28 +02:00
|
|
|
bool has_animation(const StringName &p_name) const;
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2022-09-22 15:54:15 +02:00
|
|
|
void set_blend_time(const StringName &p_animation1, const StringName &p_animation2, double p_time);
|
|
|
|
double get_blend_time(const StringName &p_animation1, const StringName &p_animation2) const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
|
|
|
void animation_set_next(const StringName &p_animation, const StringName &p_next);
|
|
|
|
StringName animation_get_next(const StringName &p_animation) const;
|
|
|
|
|
2022-09-22 15:54:15 +02:00
|
|
|
void set_default_blend_time(double p_default);
|
|
|
|
double get_default_blend_time() const;
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2022-09-22 15:54:15 +02:00
|
|
|
void play(const StringName &p_name = StringName(), double p_custom_blend = -1, float p_custom_scale = 1.0, bool p_from_end = false);
|
|
|
|
void play_backwards(const StringName &p_name = StringName(), double p_custom_blend = -1);
|
2014-02-10 02:10:30 +01:00
|
|
|
void queue(const StringName &p_name);
|
2020-02-17 22:06:54 +01:00
|
|
|
Vector<String> get_queue();
|
2014-02-10 02:10:30 +01:00
|
|
|
void clear_queue();
|
2023-01-11 13:39:39 +01:00
|
|
|
void pause();
|
2023-01-18 14:02:04 +01:00
|
|
|
void stop(bool p_keep_state = false);
|
2014-02-10 02:10:30 +01:00
|
|
|
bool is_playing() const;
|
|
|
|
String get_current_animation() const;
|
|
|
|
void set_current_animation(const String &p_anim);
|
2018-01-14 11:28:57 +01:00
|
|
|
String get_assigned_animation() const;
|
|
|
|
void set_assigned_animation(const String &p_anim);
|
2014-02-10 02:10:30 +01:00
|
|
|
void set_active(bool p_active);
|
|
|
|
bool is_active() const;
|
|
|
|
bool is_valid() const;
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2017-01-13 23:36:04 +01:00
|
|
|
void set_speed_scale(float p_speed);
|
|
|
|
float get_speed_scale() const;
|
2018-03-01 19:52:00 +01:00
|
|
|
float get_playing_speed() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2017-08-11 21:10:05 +02:00
|
|
|
void set_autoplay(const String &p_name);
|
2014-02-10 02:10:30 +01:00
|
|
|
String get_autoplay() const;
|
|
|
|
|
2020-12-20 11:46:44 +01:00
|
|
|
void set_reset_on_save_enabled(bool p_enabled);
|
|
|
|
bool is_reset_on_save_enabled() const;
|
|
|
|
|
2021-02-18 19:52:29 +01:00
|
|
|
void set_process_callback(AnimationProcessCallback p_mode);
|
|
|
|
AnimationProcessCallback get_process_callback() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2018-12-08 19:56:20 +01:00
|
|
|
void set_method_call_mode(AnimationMethodCallMode p_mode);
|
|
|
|
AnimationMethodCallMode get_method_call_mode() const;
|
|
|
|
|
2022-06-26 01:38:20 +02:00
|
|
|
void set_movie_quit_on_finish_enabled(bool p_enabled);
|
|
|
|
bool is_movie_quit_on_finish_enabled() const;
|
|
|
|
|
2021-05-21 08:42:37 +02:00
|
|
|
void seek(double p_time, bool p_update = false);
|
2022-09-22 15:54:15 +02:00
|
|
|
void seek_delta(double p_time, double p_delta);
|
|
|
|
double get_current_animation_position() const;
|
|
|
|
double get_current_animation_length() const;
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2022-09-22 15:54:15 +02:00
|
|
|
void advance(double p_time);
|
2014-10-03 05:10:51 +02:00
|
|
|
|
2014-02-10 02:10:30 +01:00
|
|
|
void set_root(const NodePath &p_root);
|
|
|
|
NodePath get_root() const;
|
|
|
|
|
|
|
|
void clear_caches(); ///< must be called by hand if an animation was modified after added
|
2014-12-17 02:31:57 +01:00
|
|
|
|
2020-07-10 12:34:39 +02:00
|
|
|
void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const override;
|
2016-03-09 00:00:52 +01:00
|
|
|
|
2017-11-01 21:32:39 +01:00
|
|
|
#ifdef TOOLS_ENABLED
|
2021-02-09 21:41:48 +01:00
|
|
|
Ref<AnimatedValuesBackup> backup_animated_values(Node *p_root_override = nullptr);
|
2020-12-20 11:46:44 +01:00
|
|
|
Ref<AnimatedValuesBackup> apply_reset(bool p_user_initiated = false);
|
|
|
|
bool can_apply_reset() const;
|
2017-11-01 21:32:39 +01:00
|
|
|
#endif
|
|
|
|
|
2016-03-09 00:00:52 +01:00
|
|
|
AnimationPlayer();
|
2014-02-10 02:10:30 +01:00
|
|
|
~AnimationPlayer();
|
|
|
|
};
|
|
|
|
|
2021-02-18 19:52:29 +01:00
|
|
|
VARIANT_ENUM_CAST(AnimationPlayer::AnimationProcessCallback);
|
2018-12-08 19:56:20 +01:00
|
|
|
VARIANT_ENUM_CAST(AnimationPlayer::AnimationMethodCallMode);
|
2014-02-10 02:10:30 +01:00
|
|
|
|
2022-07-23 23:41:51 +02:00
|
|
|
#endif // ANIMATION_PLAYER_H
|