diff options
Diffstat (limited to 'scene/animation')
-rw-r--r-- | scene/animation/animation_blend_tree.cpp | 1 | ||||
-rw-r--r-- | scene/animation/animation_player.cpp | 17 | ||||
-rw-r--r-- | scene/animation/animation_tree.cpp | 23 | ||||
-rw-r--r-- | scene/animation/root_motion_view.cpp | 19 | ||||
-rw-r--r-- | scene/animation/root_motion_view.h | 4 |
5 files changed, 60 insertions, 4 deletions
diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp index 946a1246ff..6dcd5ca8ea 100644 --- a/scene/animation/animation_blend_tree.cpp +++ b/scene/animation/animation_blend_tree.cpp @@ -1036,6 +1036,7 @@ bool AnimationNodeBlendTree::_set(const StringName &p_name, const Variant &p_val String name = p_name; if (name.begins_with("nodes/")) { + String node_name = name.get_slicec('/', 1); String what = name.get_slicec('/', 2); diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index a4322bf713..eac2c8d0c1 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -660,7 +660,22 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float nc->audio_start = p_time; } } else if (nc->audio_playing) { - if (nc->audio_start > p_time || (nc->audio_len > 0 && p_time - nc->audio_start < nc->audio_len)) { + + bool loop = a->has_loop(); + + bool stop = false; + + if (!loop && p_time < nc->audio_start) { + stop = true; + } else if (nc->audio_len > 0) { + float len = nc->audio_start > p_time ? (a->get_length() - nc->audio_start) + p_time : p_time - nc->audio_start; + + if (len > nc->audio_len) { + stop = true; + } + } + + if (stop) { //time to stop nc->node->call("stop"); nc->audio_playing = false; diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index 011c4eb470..83ec9f819b 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -1041,7 +1041,22 @@ void AnimationTree::_process_graph(float p_delta) { t->start = time; } } else if (t->playing) { - if (t->start > time || (t->len > 0 && time - t->start < t->len)) { + + bool loop = a->has_loop(); + + bool stop = false; + + if (!loop && time < t->start) { + stop = true; + } else if (t->len > 0) { + float len = t->start > time ? (a->get_length() - t->start) + time : time - t->start; + + if (len > t->len) { + stop=true; + } + } + + if (stop) { //time to stop t->object->call("stop"); t->playing = false; @@ -1050,6 +1065,12 @@ void AnimationTree::_process_graph(float p_delta) { } } + float db = Math::linear2db(MAX(blend,0.00001)); + if (t->object->has_method("set_unit_db")) { + t->object->call("set_unit_db", db); + } else { + t->object->call("set_volume_db", db); + } } break; case Animation::TYPE_ANIMATION: { diff --git a/scene/animation/root_motion_view.cpp b/scene/animation/root_motion_view.cpp index 8443995720..a28c63064a 100644 --- a/scene/animation/root_motion_view.cpp +++ b/scene/animation/root_motion_view.cpp @@ -37,6 +37,14 @@ float RootMotionView::get_radius() const { return radius; } +void RootMotionView::set_zero_y(bool p_zero_y) { + zero_y = p_zero_y; +} + +bool RootMotionView::get_zero_y() const { + return zero_y; +} + void RootMotionView::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { @@ -77,9 +85,11 @@ void RootMotionView::_notification(int p_what) { transform.orthonormalize(); //dont want scale, too imprecise transform.affine_invert(); - accumulated = accumulated * transform; + accumulated = transform * accumulated; accumulated.origin.x = Math::fposmod(accumulated.origin.x, cell_size); - accumulated.origin.y = Math::fposmod(accumulated.origin.y, cell_size); + if (zero_y) { + accumulated.origin.y = 0; + } accumulated.origin.z = Math::fposmod(accumulated.origin.z, cell_size); VS::get_singleton()->immediate_clear(immediate); @@ -142,13 +152,18 @@ void RootMotionView::_bind_methods() { ClassDB::bind_method(D_METHOD("set_radius", "size"), &RootMotionView::set_radius); ClassDB::bind_method(D_METHOD("get_radius"), &RootMotionView::get_radius); + ClassDB::bind_method(D_METHOD("set_zero_y", "enable"), &RootMotionView::set_zero_y); + ClassDB::bind_method(D_METHOD("get_zero_y"), &RootMotionView::get_zero_y); + ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "animation_path", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "AnimationTree"), "set_animation_path", "get_animation_path"); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "cell_size", PROPERTY_HINT_RANGE, "0.1,16,0.01,or_greater"), "set_cell_size", "get_cell_size"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius", PROPERTY_HINT_RANGE, "0.1,16,0.01,or_greater"), "set_radius", "get_radius"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "zero_y"), "set_zero_y", "get_zero_y"); } RootMotionView::RootMotionView() { + zero_y = true; radius = 10; cell_size = 1; set_process_internal(true); diff --git a/scene/animation/root_motion_view.h b/scene/animation/root_motion_view.h index 65e9ff480b..611183d364 100644 --- a/scene/animation/root_motion_view.h +++ b/scene/animation/root_motion_view.h @@ -13,6 +13,7 @@ public: bool use_in_game; Color color; bool first; + bool zero_y; Transform accumulated; @@ -33,6 +34,9 @@ public: void set_radius(float p_radius); float get_radius() const; + void set_zero_y(bool p_zero_y); + bool get_zero_y() const; + virtual AABB get_aabb() const; virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const; |