diff options
Diffstat (limited to 'scene/animation')
-rw-r--r-- | scene/animation/animation_blend_space_1d.cpp | 4 | ||||
-rw-r--r-- | scene/animation/animation_blend_space_1d.h | 2 | ||||
-rw-r--r-- | scene/animation/animation_blend_space_2d.cpp | 4 | ||||
-rw-r--r-- | scene/animation/animation_blend_space_2d.h | 2 | ||||
-rw-r--r-- | scene/animation/animation_blend_tree.cpp | 66 | ||||
-rw-r--r-- | scene/animation/animation_blend_tree.h | 22 | ||||
-rw-r--r-- | scene/animation/animation_node_state_machine.cpp | 4 | ||||
-rw-r--r-- | scene/animation/animation_node_state_machine.h | 4 | ||||
-rw-r--r-- | scene/animation/animation_player.cpp | 28 | ||||
-rw-r--r-- | scene/animation/animation_player.h | 12 | ||||
-rw-r--r-- | scene/animation/animation_tree.cpp | 66 | ||||
-rw-r--r-- | scene/animation/animation_tree.h | 40 | ||||
-rw-r--r-- | scene/animation/root_motion_view.h | 4 |
13 files changed, 129 insertions, 129 deletions
diff --git a/scene/animation/animation_blend_space_1d.cpp b/scene/animation/animation_blend_space_1d.cpp index 6e5d964b76..0167992baf 100644 --- a/scene/animation/animation_blend_space_1d.cpp +++ b/scene/animation/animation_blend_space_1d.cpp @@ -219,7 +219,7 @@ void AnimationNodeBlendSpace1D::_add_blend_point(int p_index, const Ref<Animatio } } -float AnimationNodeBlendSpace1D::process(float p_time, bool p_seek) { +double AnimationNodeBlendSpace1D::process(double p_time, bool p_seek) { if (blend_points_used == 0) { return 0.0; } @@ -229,7 +229,7 @@ float AnimationNodeBlendSpace1D::process(float p_time, bool p_seek) { return blend_node(blend_points[0].name, blend_points[0].node, p_time, p_seek, 1.0, FILTER_IGNORE, false); } - float blend_pos = get_parameter(blend_position); + double blend_pos = get_parameter(blend_position); float weights[MAX_BLEND_POINTS] = {}; diff --git a/scene/animation/animation_blend_space_1d.h b/scene/animation/animation_blend_space_1d.h index 8886e6c679..6730c09fd4 100644 --- a/scene/animation/animation_blend_space_1d.h +++ b/scene/animation/animation_blend_space_1d.h @@ -93,7 +93,7 @@ public: void set_value_label(const String &p_label); String get_value_label() const; - float process(float p_time, bool p_seek) override; + double process(double p_time, bool p_seek) override; String get_caption() const override; Ref<AnimationNode> get_child_by_name(const StringName &p_name) override; diff --git a/scene/animation/animation_blend_space_2d.cpp b/scene/animation/animation_blend_space_2d.cpp index d88a9badf4..145e7c605b 100644 --- a/scene/animation/animation_blend_space_2d.cpp +++ b/scene/animation/animation_blend_space_2d.cpp @@ -431,12 +431,12 @@ void AnimationNodeBlendSpace2D::_blend_triangle(const Vector2 &p_pos, const Vect r_weights[2] = w; } -float AnimationNodeBlendSpace2D::process(float p_time, bool p_seek) { +double AnimationNodeBlendSpace2D::process(double p_time, bool p_seek) { _update_triangles(); Vector2 blend_pos = get_parameter(blend_position); int closest = get_parameter(this->closest); - float length_internal = get_parameter(this->length_internal); + double length_internal = get_parameter(this->length_internal); float mind = 0.0; //time of min distance point if (blend_mode == BLEND_MODE_INTERPOLATED) { diff --git a/scene/animation/animation_blend_space_2d.h b/scene/animation/animation_blend_space_2d.h index 65d09a550d..a919fff1d2 100644 --- a/scene/animation/animation_blend_space_2d.h +++ b/scene/animation/animation_blend_space_2d.h @@ -126,7 +126,7 @@ public: void set_y_label(const String &p_label); String get_y_label() const; - virtual float process(float p_time, bool p_seek) override; + virtual double process(double p_time, bool p_seek) override; virtual String get_caption() const override; Vector2 get_closest_point(const Vector2 &p_point); diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp index 4bddae3b14..049f3483ff 100644 --- a/scene/animation/animation_blend_tree.cpp +++ b/scene/animation/animation_blend_tree.cpp @@ -63,11 +63,11 @@ void AnimationNodeAnimation::_validate_property(PropertyInfo &property) const { } } -float AnimationNodeAnimation::process(float p_time, bool p_seek) { +double AnimationNodeAnimation::process(double p_time, bool p_seek) { AnimationPlayer *ap = state->player; ERR_FAIL_COND_V(!ap, 0); - float time = get_parameter(this->time); + double time = get_parameter(this->time); if (!ap->has_animation(animation)) { AnimationNodeBlendTree *tree = Object::cast_to<AnimationNodeBlendTree>(parent); @@ -84,7 +84,7 @@ float AnimationNodeAnimation::process(float p_time, bool p_seek) { Ref<Animation> anim = ap->get_animation(animation); - float step; + double step; if (p_seek) { time = p_time; @@ -94,7 +94,7 @@ float AnimationNodeAnimation::process(float p_time, bool p_seek) { step = p_time; } - float anim_size = anim->get_length(); + double anim_size = anim->get_length(); if (anim->has_loop()) { if (anim_size) { @@ -202,12 +202,12 @@ bool AnimationNodeOneShot::has_filter() const { return true; } -float AnimationNodeOneShot::process(float p_time, bool p_seek) { +double AnimationNodeOneShot::process(double p_time, bool p_seek) { bool active = get_parameter(this->active); bool prev_active = get_parameter(this->prev_active); - float time = get_parameter(this->time); - float remaining = get_parameter(this->remaining); - float time_to_restart = get_parameter(this->time_to_restart); + double time = get_parameter(this->time); + double remaining = get_parameter(this->remaining); + double time_to_restart = get_parameter(this->time_to_restart); if (!active) { //make it as if this node doesn't exist, pass input 0 by. @@ -370,9 +370,9 @@ bool AnimationNodeAdd2::has_filter() const { return true; } -float AnimationNodeAdd2::process(float p_time, bool p_seek) { - float amount = get_parameter(add_amount); - float rem0 = blend_input(0, p_time, p_seek, 1.0, FILTER_IGNORE, !sync); +double AnimationNodeAdd2::process(double p_time, bool p_seek) { + double amount = get_parameter(add_amount); + double rem0 = blend_input(0, p_time, p_seek, 1.0, FILTER_IGNORE, !sync); blend_input(1, p_time, p_seek, amount, FILTER_PASS, !sync); return rem0; @@ -416,10 +416,10 @@ bool AnimationNodeAdd3::has_filter() const { return true; } -float AnimationNodeAdd3::process(float p_time, bool p_seek) { - float amount = get_parameter(add_amount); +double AnimationNodeAdd3::process(double p_time, bool p_seek) { + double amount = get_parameter(add_amount); blend_input(0, p_time, p_seek, MAX(0, -amount), FILTER_PASS, !sync); - float rem0 = blend_input(1, p_time, p_seek, 1.0, FILTER_IGNORE, !sync); + double rem0 = blend_input(1, p_time, p_seek, 1.0, FILTER_IGNORE, !sync); blend_input(2, p_time, p_seek, MAX(0, amount), FILTER_PASS, !sync); return rem0; @@ -452,11 +452,11 @@ String AnimationNodeBlend2::get_caption() const { return "Blend2"; } -float AnimationNodeBlend2::process(float p_time, bool p_seek) { - float amount = get_parameter(blend_amount); +double AnimationNodeBlend2::process(double p_time, bool p_seek) { + double amount = get_parameter(blend_amount); - float rem0 = blend_input(0, p_time, p_seek, 1.0 - amount, FILTER_BLEND, !sync); - float rem1 = blend_input(1, p_time, p_seek, amount, FILTER_PASS, !sync); + double rem0 = blend_input(0, p_time, p_seek, 1.0 - amount, FILTER_BLEND, !sync); + double rem1 = blend_input(1, p_time, p_seek, amount, FILTER_PASS, !sync); return amount > 0.5 ? rem1 : rem0; //hacky but good enough } @@ -507,11 +507,11 @@ bool AnimationNodeBlend3::is_using_sync() const { return sync; } -float AnimationNodeBlend3::process(float p_time, bool p_seek) { - float amount = get_parameter(blend_amount); - float rem0 = blend_input(0, p_time, p_seek, MAX(0, -amount), FILTER_IGNORE, !sync); - float rem1 = blend_input(1, p_time, p_seek, 1.0 - ABS(amount), FILTER_IGNORE, !sync); - float rem2 = blend_input(2, p_time, p_seek, MAX(0, amount), FILTER_IGNORE, !sync); +double AnimationNodeBlend3::process(double p_time, bool p_seek) { + double amount = get_parameter(blend_amount); + double rem0 = blend_input(0, p_time, p_seek, MAX(0, -amount), FILTER_IGNORE, !sync); + double rem1 = blend_input(1, p_time, p_seek, 1.0 - ABS(amount), FILTER_IGNORE, !sync); + double rem2 = blend_input(2, p_time, p_seek, MAX(0, amount), FILTER_IGNORE, !sync); return amount > 0.5 ? rem2 : (amount < -0.5 ? rem0 : rem1); //hacky but good enough } @@ -545,8 +545,8 @@ String AnimationNodeTimeScale::get_caption() const { return "TimeScale"; } -float AnimationNodeTimeScale::process(float p_time, bool p_seek) { - float scale = get_parameter(this->scale); +double AnimationNodeTimeScale::process(double p_time, bool p_seek) { + double scale = get_parameter(this->scale); if (p_seek) { return blend_input(0, p_time, true, 1.0, FILTER_IGNORE, false); } else { @@ -575,12 +575,12 @@ String AnimationNodeTimeSeek::get_caption() const { return "Seek"; } -float AnimationNodeTimeSeek::process(float p_time, bool p_seek) { - float seek_pos = get_parameter(this->seek_pos); +double AnimationNodeTimeSeek::process(double p_time, bool p_seek) { + double seek_pos = get_parameter(this->seek_pos); if (p_seek) { return blend_input(0, p_time, true, 1.0, FILTER_IGNORE, false); } else if (seek_pos >= 0) { - float ret = blend_input(0, seek_pos, true, 1.0, FILTER_IGNORE, false); + double ret = blend_input(0, seek_pos, true, 1.0, FILTER_IGNORE, false); set_parameter(this->seek_pos, -1.0); //reset return ret; } else { @@ -676,13 +676,13 @@ float AnimationNodeTransition::get_cross_fade_time() const { return xfade; } -float AnimationNodeTransition::process(float p_time, bool p_seek) { +double AnimationNodeTransition::process(double p_time, bool p_seek) { int current = get_parameter(this->current); int prev = get_parameter(this->prev); int prev_current = get_parameter(this->prev_current); - float time = get_parameter(this->time); - float prev_xfading = get_parameter(this->prev_xfading); + double time = get_parameter(this->time); + double prev_xfading = get_parameter(this->prev_xfading); bool switched = current != prev_current; @@ -794,7 +794,7 @@ String AnimationNodeOutput::get_caption() const { return "Output"; } -float AnimationNodeOutput::process(float p_time, bool p_seek) { +double AnimationNodeOutput::process(double p_time, bool p_seek) { return blend_input(0, p_time, p_seek, 1.0); } @@ -1007,7 +1007,7 @@ String AnimationNodeBlendTree::get_caption() const { return "BlendTree"; } -float AnimationNodeBlendTree::process(float p_time, bool p_seek) { +double AnimationNodeBlendTree::process(double p_time, bool p_seek) { Ref<AnimationNodeOutput> output = nodes[SceneStringNames::get_singleton()->output].node; return _blend_node("output", nodes[SceneStringNames::get_singleton()->output].connections, this, output, p_time, p_seek, 1.0); } diff --git a/scene/animation/animation_blend_tree.h b/scene/animation/animation_blend_tree.h index d82658c8c2..8508aaf71b 100644 --- a/scene/animation/animation_blend_tree.h +++ b/scene/animation/animation_blend_tree.h @@ -53,7 +53,7 @@ public: static Vector<String> (*get_editable_animation_list)(); virtual String get_caption() const override; - virtual float process(float p_time, bool p_seek) override; + virtual double process(double p_time, bool p_seek) override; void set_animation(const StringName &p_name); StringName get_animation() const; @@ -122,7 +122,7 @@ public: bool is_using_sync() const; virtual bool has_filter() const override; - virtual float process(float p_time, bool p_seek) override; + virtual double process(double p_time, bool p_seek) override; AnimationNodeOneShot(); }; @@ -148,7 +148,7 @@ public: bool is_using_sync() const; virtual bool has_filter() const override; - virtual float process(float p_time, bool p_seek) override; + virtual double process(double p_time, bool p_seek) override; AnimationNodeAdd2(); }; @@ -172,7 +172,7 @@ public: bool is_using_sync() const; virtual bool has_filter() const override; - virtual float process(float p_time, bool p_seek) override; + virtual double process(double p_time, bool p_seek) override; AnimationNodeAdd3(); }; @@ -191,7 +191,7 @@ public: virtual Variant get_parameter_default_value(const StringName &p_parameter) const override; virtual String get_caption() const override; - virtual float process(float p_time, bool p_seek) override; + virtual double process(double p_time, bool p_seek) override; void set_use_sync(bool p_sync); bool is_using_sync() const; @@ -218,7 +218,7 @@ public: void set_use_sync(bool p_sync); bool is_using_sync() const; - float process(float p_time, bool p_seek) override; + double process(double p_time, bool p_seek) override; AnimationNodeBlend3(); }; @@ -236,7 +236,7 @@ public: virtual String get_caption() const override; - float process(float p_time, bool p_seek) override; + double process(double p_time, bool p_seek) override; AnimationNodeTimeScale(); }; @@ -255,7 +255,7 @@ public: virtual String get_caption() const override; - float process(float p_time, bool p_seek) override; + double process(double p_time, bool p_seek) override; AnimationNodeTimeSeek(); }; @@ -313,7 +313,7 @@ public: void set_cross_fade_time(float p_fade); float get_cross_fade_time() const; - float process(float p_time, bool p_seek) override; + double process(double p_time, bool p_seek) override; AnimationNodeTransition(); }; @@ -323,7 +323,7 @@ class AnimationNodeOutput : public AnimationNode { public: virtual String get_caption() const override; - virtual float process(float p_time, bool p_seek) override; + virtual double process(double p_time, bool p_seek) override; AnimationNodeOutput(); }; @@ -390,7 +390,7 @@ public: void get_node_connections(List<NodeConnection> *r_connections) const; virtual String get_caption() const override; - virtual float process(float p_time, bool p_seek) override; + virtual double process(double p_time, bool p_seek) override; void get_node_list(List<StringName> *r_list); diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cpp index bf53b554bf..9fc1dbd0c6 100644 --- a/scene/animation/animation_node_state_machine.cpp +++ b/scene/animation/animation_node_state_machine.cpp @@ -286,7 +286,7 @@ bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *p_sta return true; } -float AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_state_machine, float p_time, bool p_seek) { +double AnimationNodeStateMachinePlayback::process(AnimationNodeStateMachine *p_state_machine, double p_time, bool p_seek) { //if not playing and it can restart, then restart if (!playing && start_request == StringName()) { if (!stop_request && p_state_machine->start_node) { @@ -790,7 +790,7 @@ Vector2 AnimationNodeStateMachine::get_graph_offset() const { return graph_offset; } -float AnimationNodeStateMachine::process(float p_time, bool p_seek) { +double AnimationNodeStateMachine::process(double p_time, bool p_seek) { Ref<AnimationNodeStateMachinePlayback> playback = get_parameter(this->playback); ERR_FAIL_COND_V(playback.is_null(), 0.0); diff --git a/scene/animation/animation_node_state_machine.h b/scene/animation/animation_node_state_machine.h index 9c1bca63c3..6f0e3107fd 100644 --- a/scene/animation/animation_node_state_machine.h +++ b/scene/animation/animation_node_state_machine.h @@ -114,7 +114,7 @@ class AnimationNodeStateMachinePlayback : public Resource { bool _travel(AnimationNodeStateMachine *p_state_machine, const StringName &p_travel); - float process(AnimationNodeStateMachine *p_state_machine, float p_time, bool p_seek); + double process(AnimationNodeStateMachine *p_state_machine, double p_time, bool p_seek); protected: static void _bind_methods(); @@ -210,7 +210,7 @@ public: void set_graph_offset(const Vector2 &p_offset); Vector2 get_graph_offset() const; - virtual float process(float p_time, bool p_seek) override; + virtual double process(double p_time, bool p_seek) override; virtual String get_caption() const override; virtual Ref<AnimationNode> get_child_by_name(const StringName &p_name) override; diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 67b6205a65..5d200ebf86 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -341,7 +341,7 @@ void AnimationPlayer::_ensure_node_caches(AnimationData *p_anim, Node *p_root_ov } } -void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float p_time, float p_delta, float p_interp, bool p_is_current, bool p_seeked, bool p_started) { +void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, double p_time, double p_delta, float p_interp, bool p_is_current, bool p_seeked, bool p_started) { _ensure_node_caches(p_anim); ERR_FAIL_COND(p_anim->node_cache.size() != p_anim->animation->get_track_count()); @@ -723,7 +723,7 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float continue; } - float pos = a->track_get_key_time(i, idx); + double pos = a->track_get_key_time(i, idx); StringName anim_name = a->animation_track_get_key_animation(i, idx); if (String(anim_name) == "[stop]" || !player->has_animation(anim_name)) { @@ -732,12 +732,12 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float Ref<Animation> anim = player->get_animation(anim_name); - float at_anim_pos; + double at_anim_pos; if (anim->has_loop()) { - at_anim_pos = Math::fposmod(p_time - pos, anim->get_length()); //seek to loop + at_anim_pos = Math::fposmod(p_time - pos, (double)anim->get_length()); //seek to loop } else { - at_anim_pos = MAX(anim->get_length(), p_time - pos); //seek to end + at_anim_pos = MAX((double)anim->get_length(), p_time - pos); //seek to end } if (player->is_playing() || p_seeked) { @@ -776,11 +776,11 @@ void AnimationPlayer::_animation_process_animation(AnimationData *p_anim, float } } -void AnimationPlayer::_animation_process_data(PlaybackData &cd, float p_delta, float p_blend, bool p_seeked, bool p_started) { - float delta = p_delta * speed_scale * cd.speed_scale; - float next_pos = cd.pos + delta; +void AnimationPlayer::_animation_process_data(PlaybackData &cd, double p_delta, float p_blend, bool p_seeked, bool p_started) { + double delta = p_delta * speed_scale * cd.speed_scale; + double next_pos = cd.pos + delta; - float len = cd.from->animation->get_length(); + real_t len = cd.from->animation->get_length(); bool loop = cd.from->animation->has_loop(); if (!loop) { @@ -808,7 +808,7 @@ void AnimationPlayer::_animation_process_data(PlaybackData &cd, float p_delta, f } } else { - float looped_next_pos = Math::fposmod(next_pos, len); + double looped_next_pos = Math::fposmod(next_pos, (double)len); if (looped_next_pos == 0 && next_pos != 0) { // Loop multiples of the length to it, rather than 0 // so state at time=length is previewable in the editor @@ -823,7 +823,7 @@ void AnimationPlayer::_animation_process_data(PlaybackData &cd, float p_delta, f _animation_process_animation(cd.from, cd.pos, delta, p_blend, &cd == &playback.current, p_seeked, p_started); } -void AnimationPlayer::_animation_process2(float p_delta, bool p_started) { +void AnimationPlayer::_animation_process2(double p_delta, bool p_started) { Playback &c = playback; accum_pass++; @@ -927,7 +927,7 @@ void AnimationPlayer::_animation_update_transforms() { cache_update_bezier_size = 0; } -void AnimationPlayer::_animation_process(float p_delta) { +void AnimationPlayer::_animation_process(double p_delta) { if (playback.current.from) { end_reached = false; end_notify = false; @@ -1283,7 +1283,7 @@ float AnimationPlayer::get_playing_speed() const { return speed_scale * playback.current.speed_scale; } -void AnimationPlayer::seek(float p_time, bool p_update) { +void AnimationPlayer::seek(double p_time, bool p_update) { if (!playback.current.from) { if (playback.assigned) { ERR_FAIL_COND(!animation_set.has(playback.assigned)); @@ -1299,7 +1299,7 @@ void AnimationPlayer::seek(float p_time, bool p_update) { } } -void AnimationPlayer::seek_delta(float p_time, float p_delta) { +void AnimationPlayer::seek_delta(double p_time, float p_delta) { if (!playback.current.from) { if (playback.assigned) { ERR_FAIL_COND(!animation_set.has(playback.assigned)); diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h index 7cd9de1fa1..b693e29bdf 100644 --- a/scene/animation/animation_player.h +++ b/scene/animation/animation_player.h @@ -215,13 +215,13 @@ private: NodePath root; - void _animation_process_animation(AnimationData *p_anim, float p_time, float p_delta, float p_interp, bool p_is_current = true, bool p_seeked = false, bool p_started = false); + void _animation_process_animation(AnimationData *p_anim, double p_time, double p_delta, float p_interp, bool p_is_current = true, bool p_seeked = false, bool p_started = false); void _ensure_node_caches(AnimationData *p_anim, Node *p_root_override = nullptr); - void _animation_process_data(PlaybackData &cd, float p_delta, float p_blend, bool p_seeked, bool p_started); - void _animation_process2(float p_delta, bool p_started); + 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); void _animation_update_transforms(); - void _animation_process(float p_delta); + void _animation_process(double p_delta); void _node_removed(Node *p_node); void _stop_playing_caches(); @@ -306,8 +306,8 @@ public: void set_method_call_mode(AnimationMethodCallMode p_mode); AnimationMethodCallMode get_method_call_mode() const; - void seek(float p_time, bool p_update = false); - void seek_delta(float p_time, float p_delta); + void seek(double p_time, bool p_update = false); + void seek_delta(double p_time, float p_delta); float get_current_animation_position() const; float get_current_animation_length() const; diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index e623309888..543545b90f 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -85,7 +85,7 @@ void AnimationNode::get_child_nodes(List<ChildNode> *r_child_nodes) { } } -void AnimationNode::blend_animation(const StringName &p_animation, float p_time, float p_delta, bool p_seeked, float p_blend) { +void AnimationNode::blend_animation(const StringName &p_animation, real_t p_time, real_t p_delta, bool p_seeked, real_t p_blend) { ERR_FAIL_COND(!state); ERR_FAIL_COND(!state->player->has_animation(p_animation)); @@ -115,13 +115,13 @@ void AnimationNode::blend_animation(const StringName &p_animation, float p_time, state->animation_states.push_back(anim_state); } -float AnimationNode::_pre_process(const StringName &p_base_path, AnimationNode *p_parent, State *p_state, float p_time, bool p_seek, const Vector<StringName> &p_connections) { +real_t AnimationNode::_pre_process(const StringName &p_base_path, AnimationNode *p_parent, State *p_state, real_t p_time, bool p_seek, const Vector<StringName> &p_connections) { base_path = p_base_path; parent = p_parent; connections = p_connections; state = p_state; - float t = process(p_time, p_seek); + real_t t = process(p_time, p_seek); state = nullptr; parent = nullptr; @@ -140,7 +140,7 @@ void AnimationNode::make_invalid(const String &p_reason) { state->invalid_reasons += String::utf8("• ") + p_reason; } -float AnimationNode::blend_input(int p_input, float p_time, bool p_seek, float p_blend, FilterAction p_filter, bool p_optimize) { +real_t AnimationNode::blend_input(int p_input, real_t p_time, bool p_seek, real_t p_blend, FilterAction p_filter, bool p_optimize) { ERR_FAIL_INDEX_V(p_input, inputs.size(), 0); ERR_FAIL_COND_V(!state, 0); @@ -158,8 +158,8 @@ float AnimationNode::blend_input(int p_input, float p_time, bool p_seek, float p Ref<AnimationNode> node = blend_tree->get_node(node_name); //inputs.write[p_input].last_pass = state->last_pass; - float activity = 0.0; - float ret = _blend_node(node_name, blend_tree->get_node_connection_array(node_name), nullptr, node, p_time, p_seek, p_blend, p_filter, p_optimize, &activity); + real_t activity = 0.0; + real_t ret = _blend_node(node_name, blend_tree->get_node_connection_array(node_name), nullptr, node, p_time, p_seek, p_blend, p_filter, p_optimize, &activity); Vector<AnimationTree::Activity> *activity_ptr = state->tree->input_activity_map.getptr(base_path); @@ -170,11 +170,11 @@ float AnimationNode::blend_input(int p_input, float p_time, bool p_seek, float p return ret; } -float AnimationNode::blend_node(const StringName &p_sub_path, Ref<AnimationNode> p_node, float p_time, bool p_seek, float p_blend, FilterAction p_filter, bool p_optimize) { +real_t AnimationNode::blend_node(const StringName &p_sub_path, Ref<AnimationNode> p_node, real_t p_time, bool p_seek, real_t p_blend, FilterAction p_filter, bool p_optimize) { return _blend_node(p_sub_path, Vector<StringName>(), this, p_node, p_time, p_seek, p_blend, p_filter, p_optimize); } -float AnimationNode::_blend_node(const StringName &p_subpath, const Vector<StringName> &p_connections, AnimationNode *p_new_parent, Ref<AnimationNode> p_node, float p_time, bool p_seek, float p_blend, FilterAction p_filter, bool p_optimize, float *r_max) { +real_t AnimationNode::_blend_node(const StringName &p_subpath, const Vector<StringName> &p_connections, AnimationNode *p_new_parent, Ref<AnimationNode> p_node, real_t p_time, bool p_seek, real_t p_blend, FilterAction p_filter, bool p_optimize, real_t *r_max) { ERR_FAIL_COND_V(!p_node.is_valid(), 0); ERR_FAIL_COND_V(!state, 0); @@ -184,8 +184,8 @@ float AnimationNode::_blend_node(const StringName &p_subpath, const Vector<Strin p_node->blends.resize(blend_count); } - float *blendw = p_node->blends.ptrw(); - const float *blendr = blends.ptr(); + real_t *blendw = p_node->blends.ptrw(); + const real_t *blendr = blends.ptr(); bool any_valid = false; @@ -328,7 +328,7 @@ void AnimationNode::remove_input(int p_index) { emit_changed(); } -float AnimationNode::process(float p_time, bool p_seek) { +double AnimationNode::process(double p_time, bool p_seek) { if (get_script_instance()) { return get_script_instance()->call("_process", p_time, p_seek); } @@ -718,7 +718,7 @@ void AnimationTree::_clear_caches() { cache_valid = false; } -void AnimationTree::_process_graph(float p_delta) { +void AnimationTree::_process_graph(real_t p_delta) { _update_properties(); //if properties need updating, update them //check all tracks, see if they need modification @@ -790,7 +790,7 @@ void AnimationTree::_process_graph(float p_delta) { // root source blends root->blends.resize(state.track_count); - float *src_blendsw = root->blends.ptrw(); + real_t *src_blendsw = root->blends.ptrw(); for (int i = 0; i < state.track_count; i++) { src_blendsw[i] = 1.0; //by default all go to 1 for the root input } @@ -818,9 +818,9 @@ void AnimationTree::_process_graph(float p_delta) { for (const AnimationNode::AnimationState &as : state.animation_states) { Ref<Animation> a = as.animation; - float time = as.time; - float delta = as.delta; - float weight = as.blend; + double time = as.time; + double delta = as.delta; + real_t weight = as.blend; bool seeked = as.seeked; for (int i = 0; i < a->get_track_count(); i++) { @@ -840,7 +840,7 @@ void AnimationTree::_process_graph(float p_delta) { ERR_CONTINUE(blend_idx < 0 || blend_idx >= state.track_count); - float blend = (*as.track_blends)[blend_idx] * weight; + real_t blend = (*as.track_blends)[blend_idx] * weight; if (blend < CMP_EPSILON) { continue; //nothing to blend @@ -860,7 +860,7 @@ void AnimationTree::_process_graph(float p_delta) { t->scale = Vector3(1, 1, 1); } - float prev_time = time - delta; + real_t prev_time = time - delta; if (prev_time < 0) { if (!a->has_loop()) { prev_time = 0; @@ -928,7 +928,7 @@ void AnimationTree::_process_graph(float p_delta) { t->rot = rot; t->rot_blend_accum = blend; } else { - float rot_total = t->rot_blend_accum + blend; + real_t rot_total = t->rot_blend_accum + blend; t->rot = rot.slerp(t->rot, t->rot_blend_accum / rot_total).normalized(); t->rot_blend_accum = rot_total; } @@ -1003,7 +1003,7 @@ void AnimationTree::_process_graph(float p_delta) { case Animation::TYPE_BEZIER: { TrackCacheBezier *t = static_cast<TrackCacheBezier *>(track); - float bezier = a->bezier_track_interpolate(i, time); + real_t bezier = a->bezier_track_interpolate(i, time); if (t->process_pass != process_pass) { t->value = bezier; @@ -1029,10 +1029,10 @@ void AnimationTree::_process_graph(float p_delta) { t->playing = false; playing_caches.erase(t); } else { - float start_ofs = a->audio_track_get_key_start_offset(i, idx); + real_t start_ofs = a->audio_track_get_key_start_offset(i, idx); start_ofs += time - a->track_get_key_time(i, idx); - float end_ofs = a->audio_track_get_key_end_offset(i, idx); - float len = stream->get_length(); + real_t end_ofs = a->audio_track_get_key_end_offset(i, idx); + real_t len = stream->get_length(); if (start_ofs > len - end_ofs) { t->object->call("stop"); @@ -1068,9 +1068,9 @@ void AnimationTree::_process_graph(float p_delta) { t->playing = false; playing_caches.erase(t); } else { - float start_ofs = a->audio_track_get_key_start_offset(i, idx); - float end_ofs = a->audio_track_get_key_end_offset(i, idx); - float len = stream->get_length(); + real_t start_ofs = a->audio_track_get_key_start_offset(i, idx); + real_t end_ofs = a->audio_track_get_key_end_offset(i, idx); + real_t len = stream->get_length(); t->object->call("set_stream", stream); t->object->call("play", start_ofs); @@ -1093,7 +1093,7 @@ void AnimationTree::_process_graph(float p_delta) { 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; + real_t len = t->start > time ? (a->get_length() - t->start) + time : time - t->start; if (len > t->len) { stop = true; @@ -1109,7 +1109,7 @@ void AnimationTree::_process_graph(float p_delta) { } } - float db = Math::linear2db(MAX(blend, 0.00001)); + real_t db = Math::linear2db(MAX(blend, 0.00001)); if (t->object->has_method("set_unit_db")) { t->object->call("set_unit_db", db); } else { @@ -1132,7 +1132,7 @@ void AnimationTree::_process_graph(float p_delta) { continue; } - float pos = a->track_get_key_time(i, idx); + double pos = a->track_get_key_time(i, idx); StringName anim_name = a->animation_track_get_key_animation(i, idx); if (String(anim_name) == "[stop]" || !player2->has_animation(anim_name)) { @@ -1141,10 +1141,10 @@ void AnimationTree::_process_graph(float p_delta) { Ref<Animation> anim = player2->get_animation(anim_name); - float at_anim_pos; + real_t at_anim_pos; if (anim->has_loop()) { - at_anim_pos = Math::fposmod(time - pos, anim->get_length()); //seek to loop + at_anim_pos = Math::fposmod(time - pos, (double)anim->get_length()); //seek to loop } else { at_anim_pos = MAX(anim->get_length(), time - pos); //seek to end } @@ -1238,7 +1238,7 @@ void AnimationTree::_process_graph(float p_delta) { } } -void AnimationTree::advance(float p_time) { +void AnimationTree::advance(real_t p_time) { _process_graph(p_time); } @@ -1443,7 +1443,7 @@ void AnimationTree::rename_parameter(const String &p_base, const String &p_new_b _update_properties(); } -float AnimationTree::get_connection_activity(const StringName &p_path, int p_connection) const { +real_t AnimationTree::get_connection_activity(const StringName &p_path, int p_connection) const { if (!input_activity_map_get.has(p_path)) { return 0; } diff --git a/scene/animation/animation_tree.h b/scene/animation/animation_tree.h index 60e0c7200a..59bbc5b4da 100644 --- a/scene/animation/animation_tree.h +++ b/scene/animation/animation_tree.h @@ -57,16 +57,16 @@ public: Vector<Input> inputs; - float process_input(int p_input, float p_time, bool p_seek, float p_blend); + real_t process_input(int p_input, real_t p_time, bool p_seek, real_t p_blend); friend class AnimationTree; struct AnimationState { Ref<Animation> animation; - float time = 0.0; - float delta = 0.0; - const Vector<float> *track_blends = nullptr; - float blend = 0.0; + double time = 0.0; + double delta = 0.0; + const Vector<real_t> *track_blends = nullptr; + real_t blend = 0.0; bool seeked = false; }; @@ -81,10 +81,10 @@ public: uint64_t last_pass = 0; }; - Vector<float> blends; + Vector<real_t> blends; State *state = nullptr; - float _pre_process(const StringName &p_base_path, AnimationNode *p_parent, State *p_state, float p_time, bool p_seek, const Vector<StringName> &p_connections); + real_t _pre_process(const StringName &p_base_path, AnimationNode *p_parent, State *p_state, real_t p_time, bool p_seek, const Vector<StringName> &p_connections); void _pre_update_animations(HashMap<NodePath, int> *track_map); //all this is temporary @@ -98,12 +98,12 @@ public: Array _get_filters() const; void _set_filters(const Array &p_filters); friend class AnimationNodeBlendTree; - float _blend_node(const StringName &p_subpath, const Vector<StringName> &p_connections, AnimationNode *p_new_parent, Ref<AnimationNode> p_node, float p_time, bool p_seek, float p_blend, FilterAction p_filter = FILTER_IGNORE, bool p_optimize = true, float *r_max = nullptr); + real_t _blend_node(const StringName &p_subpath, const Vector<StringName> &p_connections, AnimationNode *p_new_parent, Ref<AnimationNode> p_node, real_t p_time, bool p_seek, real_t p_blend, FilterAction p_filter = FILTER_IGNORE, bool p_optimize = true, real_t *r_max = nullptr); protected: - void blend_animation(const StringName &p_animation, float p_time, float p_delta, bool p_seeked, float p_blend); - float blend_node(const StringName &p_sub_path, Ref<AnimationNode> p_node, float p_time, bool p_seek, float p_blend, FilterAction p_filter = FILTER_IGNORE, bool p_optimize = true); - float blend_input(int p_input, float p_time, bool p_seek, float p_blend, FilterAction p_filter = FILTER_IGNORE, bool p_optimize = true); + void blend_animation(const StringName &p_animation, real_t p_time, real_t p_delta, bool p_seeked, real_t p_blend); + real_t blend_node(const StringName &p_sub_path, Ref<AnimationNode> p_node, real_t p_time, bool p_seek, real_t p_blend, FilterAction p_filter = FILTER_IGNORE, bool p_optimize = true); + real_t blend_input(int p_input, real_t p_time, bool p_seek, real_t p_blend, FilterAction p_filter = FILTER_IGNORE, bool p_optimize = true); void make_invalid(const String &p_reason); static void _bind_methods(); @@ -126,7 +126,7 @@ public: virtual void get_child_nodes(List<ChildNode> *r_child_nodes); - virtual float process(float p_time, bool p_seek); + virtual double process(double p_time, bool p_seek); virtual String get_caption() const; int get_input_count() const; @@ -191,7 +191,7 @@ private: int bone_idx = -1; Vector3 loc; Quaternion rot; - float rot_blend_accum = 0.0; + real_t rot_blend_accum = 0.0; Vector3 scale; TrackCacheTransform() { @@ -210,7 +210,7 @@ private: }; struct TrackCacheBezier : public TrackCache { - float value = 0.0; + real_t value = 0.0; Vector<StringName> subpath; TrackCacheBezier() { type = Animation::TYPE_BEZIER; @@ -219,8 +219,8 @@ private: struct TrackCacheAudio : public TrackCache { bool playing = false; - float start = 0.0; - float len = 0.0; + real_t start = 0.0; + real_t len = 0.0; TrackCacheAudio() { type = Animation::TYPE_AUDIO; @@ -251,7 +251,7 @@ private: void _clear_caches(); bool _update_caches(AnimationPlayer *player); - void _process_graph(float p_delta); + void _process_graph(real_t p_delta); uint64_t setup_pass = 1; uint64_t process_pass = 1; @@ -271,7 +271,7 @@ private: struct Activity { uint64_t last_pass = 0; - float activity = 0.0; + real_t activity = 0.0; }; HashMap<StringName, Vector<Activity>> input_activity_map; @@ -312,8 +312,8 @@ public: Transform3D get_root_motion_transform() const; - float get_connection_activity(const StringName &p_path, int p_connection) const; - void advance(float p_time); + real_t get_connection_activity(const StringName &p_path, int p_connection) const; + void advance(real_t p_time); void rename_parameter(const String &p_base, const String &p_new_base); diff --git a/scene/animation/root_motion_view.h b/scene/animation/root_motion_view.h index 55fd2d2b73..d64c8bc675 100644 --- a/scene/animation/root_motion_view.h +++ b/scene/animation/root_motion_view.h @@ -39,8 +39,8 @@ class RootMotionView : public VisualInstance3D { public: Ref<ImmediateMesh> immediate; NodePath path; - float cell_size = 1.0; - float radius = 10.0; + real_t cell_size = 1.0; + real_t radius = 10.0; bool use_in_game = false; Color color = Color(0.5, 0.5, 1.0); bool first = true; |