summaryrefslogtreecommitdiffstats
path: root/scene/resources/animation.cpp
diff options
context:
space:
mode:
authorSilc Lizard (Tokage) Renew <61938263+TokageItLab@users.noreply.github.com>2024-01-06 02:21:38 +0900
committerSilc Lizard (Tokage) Renew <61938263+TokageItLab@users.noreply.github.com>2024-01-08 21:48:19 +0900
commita51958a2a0620aa1a9b9a168259379511f9521ad (patch)
tree7a68023f03f7aa4c9b2d91bc480c6c678b621dcc /scene/resources/animation.cpp
parent35da70f953f6eeba6ba7b13795029d7a134a61fd (diff)
downloadredot-engine-a51958a2a0620aa1a9b9a168259379511f9521ad.tar.gz
Remove Object pointer/solve types conflict in AnimationTrackCache
Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
Diffstat (limited to 'scene/resources/animation.cpp')
-rw-r--r--scene/resources/animation.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp
index 1ab11cfdf0..e503c79bed 100644
--- a/scene/resources/animation.cpp
+++ b/scene/resources/animation.cpp
@@ -979,6 +979,7 @@ Animation::TrackType Animation::track_get_type(int p_track) const {
void Animation::track_set_path(int p_track, const NodePath &p_path) {
ERR_FAIL_INDEX(p_track, tracks.size());
tracks[p_track]->path = p_path;
+ _track_update_hash(p_track);
emit_changed();
}
@@ -996,6 +997,27 @@ int Animation::find_track(const NodePath &p_path, const TrackType p_type) const
return -1;
};
+Animation::TrackType Animation::get_cache_type(TrackType p_type) {
+ if (p_type == Animation::TYPE_BEZIER) {
+ return Animation::TYPE_VALUE;
+ }
+ if (p_type == Animation::TYPE_ROTATION_3D || p_type == Animation::TYPE_SCALE_3D) {
+ return Animation::TYPE_POSITION_3D; // Reference them as position3D tracks, even if they modify rotation or scale.
+ }
+ return p_type;
+}
+
+void Animation::_track_update_hash(int p_track) {
+ NodePath track_path = tracks[p_track]->path;
+ TrackType track_cache_type = get_cache_type(tracks[p_track]->type);
+ tracks[p_track]->thash = StringName(String(track_path.get_concatenated_names()) + String(track_path.get_concatenated_subnames()) + itos(track_cache_type)).hash();
+}
+
+Animation::TypeHash Animation::track_get_type_hash(int p_track) const {
+ ERR_FAIL_INDEX_V(p_track, tracks.size(), 0);
+ return tracks[p_track]->thash;
+}
+
void Animation::track_set_interpolation_type(int p_track, InterpolationType p_interp) {
ERR_FAIL_INDEX(p_track, tracks.size());
tracks[p_track]->interpolation = p_interp;