summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.cpp4
-rw-r--r--scene/animation/animation_blend_tree.cpp18
-rw-r--r--scene/animation/animation_blend_tree.h7
3 files changed, 16 insertions, 13 deletions
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp
index b83976270f..eb3c432ee7 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp
@@ -692,7 +692,9 @@ void AnimationNodeBlendTreeEditor::_notification(int p_what) {
Ref<Animation> anim = player->get_animation(an->get_animation());
if (anim.is_valid()) {
E->get()->set_max(anim->get_length());
- E->get()->set_value(an->get_playback_time());
+ //StringName path = AnimationTreeEditor::get_singleton()->get_base_path() + E->get().input_node;
+ StringName time_path = AnimationTreeEditor::get_singleton()->get_base_path() + String(E->key()) + "/time";
+ E->get()->set_value(AnimationTreeEditor::get_singleton()->get_tree()->get(time_path));
}
}
}
diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp
index b037596fda..a08639089e 100644
--- a/scene/animation/animation_blend_tree.cpp
+++ b/scene/animation/animation_blend_tree.cpp
@@ -40,12 +40,11 @@ StringName AnimationNodeAnimation::get_animation() const {
return animation;
}
-float AnimationNodeAnimation::get_playback_time() const {
- return time;
-}
-
Vector<String> (*AnimationNodeAnimation::get_editable_animation_list)() = NULL;
+void AnimationNodeAnimation::get_parameter_list(List<PropertyInfo> *r_list) const {
+ r_list->push_back(PropertyInfo(Variant::REAL, time, PROPERTY_HINT_NONE, "", 0));
+}
void AnimationNodeAnimation::_validate_property(PropertyInfo &property) const {
if (property.name == "animation" && get_editable_animation_list) {
@@ -70,6 +69,8 @@ float AnimationNodeAnimation::process(float p_time, bool p_seek) {
AnimationPlayer *ap = state->player;
ERR_FAIL_COND_V(!ap, 0);
+ float time = get_parameter(this->time);
+
if (!ap->has_animation(animation)) {
AnimationNodeBlendTree *tree = Object::cast_to<AnimationNodeBlendTree>(parent);
@@ -86,6 +87,8 @@ float AnimationNodeAnimation::process(float p_time, bool p_seek) {
Ref<Animation> anim = ap->get_animation(animation);
+ float step;
+
if (p_seek) {
time = p_time;
step = 0;
@@ -109,6 +112,8 @@ float AnimationNodeAnimation::process(float p_time, bool p_seek) {
blend_animation(animation, time, step, p_seek, 1.0);
+ set_parameter(this->time, time);
+
return anim_size - time;
}
@@ -120,16 +125,13 @@ void AnimationNodeAnimation::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_animation", "name"), &AnimationNodeAnimation::set_animation);
ClassDB::bind_method(D_METHOD("get_animation"), &AnimationNodeAnimation::get_animation);
- ClassDB::bind_method(D_METHOD("get_playback_time"), &AnimationNodeAnimation::get_playback_time);
-
ADD_PROPERTY(PropertyInfo(Variant::STRING, "animation"), "set_animation", "get_animation");
}
AnimationNodeAnimation::AnimationNodeAnimation() {
last_version = 0;
skip = false;
- time = 0;
- step = 0;
+ time = "time";
}
////////////////////////////////////////////////////////
diff --git a/scene/animation/animation_blend_tree.h b/scene/animation/animation_blend_tree.h
index 4ca11e464b..5adb7fd71a 100644
--- a/scene/animation/animation_blend_tree.h
+++ b/scene/animation/animation_blend_tree.h
@@ -38,10 +38,9 @@ class AnimationNodeAnimation : public AnimationRootNode {
GDCLASS(AnimationNodeAnimation, AnimationRootNode);
StringName animation;
+ StringName time;
uint64_t last_version;
- float time;
- float step;
bool skip;
protected:
@@ -50,6 +49,8 @@ protected:
static void _bind_methods();
public:
+ void get_parameter_list(List<PropertyInfo> *r_list) const;
+
static Vector<String> (*get_editable_animation_list)();
virtual String get_caption() const;
@@ -58,8 +59,6 @@ public:
void set_animation(const StringName &p_name);
StringName get_animation() const;
- float get_playback_time() const;
-
AnimationNodeAnimation();
};