summaryrefslogtreecommitdiffstats
path: root/scene/animation
diff options
context:
space:
mode:
Diffstat (limited to 'scene/animation')
-rw-r--r--scene/animation/animation_blend_tree.cpp16
-rw-r--r--scene/animation/animation_blend_tree.h7
-rw-r--r--scene/animation/animation_mixer.cpp12
-rw-r--r--scene/animation/animation_mixer.h1
4 files changed, 35 insertions, 1 deletions
diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp
index e172286d05..d0773fc83f 100644
--- a/scene/animation/animation_blend_tree.cpp
+++ b/scene/animation/animation_blend_tree.cpp
@@ -1003,6 +1003,14 @@ String AnimationNodeTimeSeek::get_caption() const {
return "TimeSeek";
}
+void AnimationNodeTimeSeek::set_explicit_elapse(bool p_enable) {
+ explicit_elapse = p_enable;
+}
+
+bool AnimationNodeTimeSeek::is_explicit_elapse() const {
+ return explicit_elapse;
+}
+
AnimationNode::NodeTimeInfo AnimationNodeTimeSeek::_process(const AnimationMixer::PlaybackInfo p_playback_info, bool p_test_only) {
double cur_seek_pos = get_parameter(seek_pos_request);
@@ -1011,7 +1019,7 @@ AnimationNode::NodeTimeInfo AnimationNodeTimeSeek::_process(const AnimationMixer
if (Animation::is_greater_or_equal_approx(cur_seek_pos, 0)) {
pi.time = cur_seek_pos;
pi.seeked = true;
- pi.is_external_seeking = true;
+ pi.is_external_seeking = explicit_elapse;
set_parameter(seek_pos_request, -1.0); // Reset.
}
@@ -1022,6 +1030,12 @@ AnimationNodeTimeSeek::AnimationNodeTimeSeek() {
add_input("in");
}
+void AnimationNodeTimeSeek::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_explicit_elapse", "enable"), &AnimationNodeTimeSeek::set_explicit_elapse);
+ ClassDB::bind_method(D_METHOD("is_explicit_elapse"), &AnimationNodeTimeSeek::is_explicit_elapse);
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "explicit_elapse"), "set_explicit_elapse", "is_explicit_elapse");
+}
+
/////////////////////////////////////////////////
bool AnimationNodeTransition::_set(const StringName &p_path, const Variant &p_value) {
diff --git a/scene/animation/animation_blend_tree.h b/scene/animation/animation_blend_tree.h
index 5c912f0095..c48d799eea 100644
--- a/scene/animation/animation_blend_tree.h
+++ b/scene/animation/animation_blend_tree.h
@@ -302,6 +302,10 @@ class AnimationNodeTimeSeek : public AnimationNode {
GDCLASS(AnimationNodeTimeSeek, AnimationNode);
StringName seek_pos_request = PNAME("seek_request");
+ bool explicit_elapse = true;
+
+protected:
+ static void _bind_methods();
public:
virtual void get_parameter_list(List<PropertyInfo> *r_list) const override;
@@ -311,6 +315,9 @@ public:
virtual NodeTimeInfo _process(const AnimationMixer::PlaybackInfo p_playback_info, bool p_test_only = false) override;
+ void set_explicit_elapse(bool p_enable);
+ bool is_explicit_elapse() const;
+
AnimationNodeTimeSeek();
};
diff --git a/scene/animation/animation_mixer.cpp b/scene/animation/animation_mixer.cpp
index 3724277896..d4c8af4a4c 100644
--- a/scene/animation/animation_mixer.cpp
+++ b/scene/animation/animation_mixer.cpp
@@ -33,6 +33,8 @@
#include "core/config/engine.h"
#include "core/config/project_settings.h"
+#include "core/string/print_string.h"
+#include "core/string/string_name.h"
#include "scene/2d/audio_stream_player_2d.h"
#include "scene/animation/animation_player.h"
#include "scene/audio/audio_stream_player.h"
@@ -270,6 +272,16 @@ bool AnimationMixer::has_animation_library(const StringName &p_name) const {
return false;
}
+StringName AnimationMixer::get_animation_library_name(const Ref<AnimationLibrary> &p_animation_library) const {
+ ERR_FAIL_COND_V(p_animation_library.is_null(), StringName());
+ for (const AnimationLibraryData &lib : animation_libraries) {
+ if (lib.library == p_animation_library) {
+ return lib.name;
+ }
+ }
+ return StringName();
+}
+
StringName AnimationMixer::find_animation_library(const Ref<Animation> &p_animation) const {
for (const KeyValue<StringName, AnimationData> &E : animation_set) {
if (E.value.animation == p_animation) {
diff --git a/scene/animation/animation_mixer.h b/scene/animation/animation_mixer.h
index a1f1a754dc..82deccaa95 100644
--- a/scene/animation/animation_mixer.h
+++ b/scene/animation/animation_mixer.h
@@ -410,6 +410,7 @@ public:
void get_animation_library_list(List<StringName> *p_animations) const;
Ref<AnimationLibrary> get_animation_library(const StringName &p_name) const;
bool has_animation_library(const StringName &p_name) const;
+ StringName get_animation_library_name(const Ref<AnimationLibrary> &p_animation_library) const;
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);