diff options
author | Dave Palais <active.hat0408@fastmail.com> | 2022-09-22 08:54:15 -0500 |
---|---|---|
committer | Genei Shouko <date.aa2@gmail.com> | 2022-09-26 13:52:54 -0500 |
commit | 0c46068af0e9f077d3d68fe1dc647f99a55d7824 (patch) | |
tree | fce4c5b0e3ed2770386baa9468e714b71722468b /scene/animation | |
parent | 8e14f9ba21725a9445f3979742f2fc87c8a7b463 (diff) |
Change time parameters and variables to double type
Addresses #65313
Diffstat (limited to 'scene/animation')
-rw-r--r-- | scene/animation/animation_blend_tree.cpp | 26 | ||||
-rw-r--r-- | scene/animation/animation_blend_tree.h | 38 | ||||
-rw-r--r-- | scene/animation/animation_player.cpp | 30 | ||||
-rw-r--r-- | scene/animation/animation_player.h | 28 | ||||
-rw-r--r-- | scene/animation/animation_tree.cpp | 2 | ||||
-rw-r--r-- | scene/animation/animation_tree.h | 2 | ||||
-rw-r--r-- | scene/animation/tween.cpp | 50 | ||||
-rw-r--r-- | scene/animation/tween.h | 52 |
8 files changed, 114 insertions, 114 deletions
diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp index 1efbaacb3b..c063d8f1bf 100644 --- a/scene/animation/animation_blend_tree.cpp +++ b/scene/animation/animation_blend_tree.cpp @@ -217,19 +217,19 @@ Variant AnimationNodeOneShot::get_parameter_default_value(const StringName &p_pa } } -void AnimationNodeOneShot::set_fadein_time(float p_time) { +void AnimationNodeOneShot::set_fadein_time(double p_time) { fade_in = p_time; } -void AnimationNodeOneShot::set_fadeout_time(float p_time) { +void AnimationNodeOneShot::set_fadeout_time(double p_time) { fade_out = p_time; } -float AnimationNodeOneShot::get_fadein_time() const { +double AnimationNodeOneShot::get_fadein_time() const { return fade_in; } -float AnimationNodeOneShot::get_fadeout_time() const { +double AnimationNodeOneShot::get_fadeout_time() const { return fade_out; } @@ -237,11 +237,11 @@ void AnimationNodeOneShot::set_autorestart(bool p_active) { autorestart = p_active; } -void AnimationNodeOneShot::set_autorestart_delay(float p_time) { +void AnimationNodeOneShot::set_autorestart_delay(double p_time) { autorestart_delay = p_time; } -void AnimationNodeOneShot::set_autorestart_random_delay(float p_time) { +void AnimationNodeOneShot::set_autorestart_random_delay(double p_time) { autorestart_random_delay = p_time; } @@ -249,11 +249,11 @@ bool AnimationNodeOneShot::has_autorestart() const { return autorestart; } -float AnimationNodeOneShot::get_autorestart_delay() const { +double AnimationNodeOneShot::get_autorestart_delay() const { return autorestart_delay; } -float AnimationNodeOneShot::get_autorestart_random_delay() const { +double AnimationNodeOneShot::get_autorestart_random_delay() const { return autorestart_random_delay; } @@ -313,7 +313,7 @@ double AnimationNodeOneShot::process(double p_time, bool p_seek, bool p_seek_roo set_parameter(this->prev_active, true); } - float blend; + real_t blend; if (time < fade_in) { if (fade_in > 0) { @@ -351,7 +351,7 @@ double AnimationNodeOneShot::process(double p_time, bool p_seek, bool p_seek_roo set_parameter(this->active, false); set_parameter(this->prev_active, false); if (autorestart) { - float restart_sec = autorestart_delay + Math::randf() * autorestart_random_delay; + double restart_sec = autorestart_delay + Math::randd() * autorestart_random_delay; set_parameter(this->time_to_restart, restart_sec); } } @@ -676,11 +676,11 @@ String AnimationNodeTransition::get_input_caption(int p_input) const { return inputs[p_input].name; } -void AnimationNodeTransition::set_xfade_time(float p_fade) { +void AnimationNodeTransition::set_xfade_time(double p_fade) { xfade_time = p_fade; } -float AnimationNodeTransition::get_xfade_time() const { +double AnimationNodeTransition::get_xfade_time() const { return xfade_time; } @@ -748,7 +748,7 @@ double AnimationNodeTransition::process(double p_time, bool p_seek, bool p_seek_ } else { // cross-fading from prev to current - float blend = xfade_time == 0 ? 0 : (prev_xfading / xfade_time); + real_t blend = xfade_time == 0 ? 0 : (prev_xfading / xfade_time); if (xfade_curve.is_valid()) { blend = xfade_curve->sample(blend); } diff --git a/scene/animation/animation_blend_tree.h b/scene/animation/animation_blend_tree.h index 59c074cc80..1c31718259 100644 --- a/scene/animation/animation_blend_tree.h +++ b/scene/animation/animation_blend_tree.h @@ -102,18 +102,18 @@ public: }; private: - float fade_in = 0.0; - float fade_out = 0.0; + double fade_in = 0.0; + double fade_out = 0.0; bool autorestart = false; - float autorestart_delay = 1.0; - float autorestart_random_delay = 0.0; + double autorestart_delay = 1.0; + double autorestart_random_delay = 0.0; MixMode mix = MIX_MODE_BLEND; /* bool active; bool do_start; - float time; - float remaining;*/ + double time; + double remaining;*/ StringName active = PNAME("active"); StringName prev_active = "prev_active"; @@ -130,19 +130,19 @@ public: virtual String get_caption() const override; - void set_fadein_time(float p_time); - void set_fadeout_time(float p_time); + void set_fadein_time(double p_time); + void set_fadeout_time(double p_time); - float get_fadein_time() const; - float get_fadeout_time() const; + double get_fadein_time() const; + double get_fadeout_time() const; void set_autorestart(bool p_active); - void set_autorestart_delay(float p_time); - void set_autorestart_random_delay(float p_time); + void set_autorestart_delay(double p_time); + void set_autorestart_random_delay(double p_time); bool has_autorestart() const; - float get_autorestart_delay() const; - float get_autorestart_random_delay() const; + double get_autorestart_delay() const; + double get_autorestart_random_delay() const; void set_mix_mode(MixMode p_mix); MixMode get_mix_mode() const; @@ -285,9 +285,9 @@ class AnimationNodeTransition : public AnimationNodeSync { int enabled_inputs = 0; /* - float prev_xfading; + double prev_xfading; int prev; - float time; + double time; int current; int prev_current; */ @@ -297,7 +297,7 @@ class AnimationNodeTransition : public AnimationNodeSync { StringName current = PNAME("current"); StringName prev_current = "prev_current"; - float xfade_time = 0.0; + double xfade_time = 0.0; Ref<Curve> xfade_curve; bool from_start = true; @@ -322,8 +322,8 @@ public: void set_input_caption(int p_input, const String &p_name); String get_input_caption(int p_input) const; - void set_xfade_time(float p_fade); - float get_xfade_time() const; + void set_xfade_time(double p_fade); + double get_xfade_time() const; void set_xfade_curve(const Ref<Curve> &p_curve); Ref<Curve> get_xfade_curve() const; diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index ce9406883d..54b10d9d57 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -156,7 +156,7 @@ bool AnimationPlayer::_get(const StringName &p_name, Variant &r_ret) const { } else if (name == "blend_times") { Vector<BlendKey> keys; - for (const KeyValue<BlendKey, float> &E : blend_times) { + for (const KeyValue<BlendKey, double> &E : blend_times) { keys.ordered_insert(E.key); } @@ -216,7 +216,7 @@ void AnimationPlayer::_get_property_list(List<PropertyInfo> *p_list) const { p_list->push_back(PropertyInfo(Variant::ARRAY, "blend_times", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL)); } -void AnimationPlayer::advance(float p_time) { +void AnimationPlayer::advance(double p_time) { _animation_process(p_time); } @@ -1287,7 +1287,7 @@ void AnimationPlayer::_animation_removed(const StringName &p_name, const StringN // Erase blends if needed List<BlendKey> to_erase; - for (const KeyValue<BlendKey, float> &E : blend_times) { + for (const KeyValue<BlendKey, double> &E : blend_times) { BlendKey bk = E.key; if (bk.from == name || bk.to == name) { to_erase.push_back(bk); @@ -1303,8 +1303,8 @@ void AnimationPlayer::_animation_removed(const StringName &p_name, const StringN void AnimationPlayer::_rename_animation(const StringName &p_from_name, const StringName &p_to_name) { // Rename autoplay or blends if needed. List<BlendKey> to_erase; - HashMap<BlendKey, float, BlendKey> to_insert; - for (const KeyValue<BlendKey, float> &E : blend_times) { + HashMap<BlendKey, double, BlendKey> to_insert; + for (const KeyValue<BlendKey, double> &E : blend_times) { BlendKey bk = E.key; BlendKey new_bk = bk; bool erase = false; @@ -1523,7 +1523,7 @@ void AnimationPlayer::get_animation_list(List<StringName> *p_animations) const { } } -void AnimationPlayer::set_blend_time(const StringName &p_animation1, const StringName &p_animation2, float p_time) { +void AnimationPlayer::set_blend_time(const StringName &p_animation1, const StringName &p_animation2, double p_time) { ERR_FAIL_COND_MSG(!animation_set.has(p_animation1), vformat("Animation not found: %s.", p_animation1)); ERR_FAIL_COND_MSG(!animation_set.has(p_animation2), vformat("Animation not found: %s.", p_animation2)); ERR_FAIL_COND_MSG(p_time < 0, "Blend time cannot be smaller than 0."); @@ -1538,7 +1538,7 @@ void AnimationPlayer::set_blend_time(const StringName &p_animation1, const Strin } } -float AnimationPlayer::get_blend_time(const StringName &p_animation1, const StringName &p_animation2) const { +double AnimationPlayer::get_blend_time(const StringName &p_animation1, const StringName &p_animation2) const { BlendKey bk; bk.from = p_animation1; bk.to = p_animation2; @@ -1571,11 +1571,11 @@ void AnimationPlayer::clear_queue() { queued.clear(); } -void AnimationPlayer::play_backwards(const StringName &p_name, float p_custom_blend) { +void AnimationPlayer::play_backwards(const StringName &p_name, double p_custom_blend) { play(p_name, p_custom_blend, -1, true); } -void AnimationPlayer::play(const StringName &p_name, float p_custom_blend, float p_custom_scale, bool p_from_end) { +void AnimationPlayer::play(const StringName &p_name, double p_custom_blend, float p_custom_scale, bool p_from_end) { StringName name = p_name; if (String(name) == "") { @@ -1587,7 +1587,7 @@ void AnimationPlayer::play(const StringName &p_name, float p_custom_blend, float Playback &c = playback; if (c.current.from) { - float blend_time = 0.0; + double blend_time = 0.0; // find if it can blend BlendKey bk; bk.from = c.current.from->name; @@ -1741,7 +1741,7 @@ void AnimationPlayer::seek(double p_time, bool p_update) { } } -void AnimationPlayer::seek_delta(double p_time, float p_delta) { +void AnimationPlayer::seek_delta(double p_time, double p_delta) { if (!playback.current.from) { if (playback.assigned) { ERR_FAIL_COND_MSG(!animation_set.has(playback.assigned), vformat("Animation not found: %s.", playback.assigned)); @@ -1762,12 +1762,12 @@ bool AnimationPlayer::is_valid() const { return (playback.current.from); } -float AnimationPlayer::get_current_animation_position() const { +double AnimationPlayer::get_current_animation_position() const { ERR_FAIL_COND_V_MSG(!playback.current.from, 0, "AnimationPlayer has no current animation"); return playback.current.pos; } -float AnimationPlayer::get_current_animation_length() const { +double AnimationPlayer::get_current_animation_length() const { ERR_FAIL_COND_V_MSG(!playback.current.from, 0, "AnimationPlayer has no current animation"); return playback.current.from->animation->get_length(); } @@ -1933,11 +1933,11 @@ StringName AnimationPlayer::animation_get_next(const StringName &p_animation) co return animation_set[p_animation].next; } -void AnimationPlayer::set_default_blend_time(float p_default) { +void AnimationPlayer::set_default_blend_time(double p_default) { default_blend_time = p_default; } -float AnimationPlayer::get_default_blend_time() const { +double AnimationPlayer::get_default_blend_time() const { return default_blend_time; } diff --git a/scene/animation/animation_player.h b/scene/animation/animation_player.h index caf1387ff0..4f32927d25 100644 --- a/scene/animation/animation_player.h +++ b/scene/animation/animation_player.h @@ -191,7 +191,7 @@ private: uint64_t accum_pass = 1; float speed_scale = 1.0; - float default_blend_time = 0.0; + double default_blend_time = 0.0; struct AnimationData { String name; @@ -230,7 +230,7 @@ private: } }; - HashMap<BlendKey, float, BlendKey> blend_times; + HashMap<BlendKey, double, BlendKey> blend_times; struct PlaybackData { AnimationData *from = nullptr; @@ -241,8 +241,8 @@ private: struct Blend { PlaybackData data; - float blend_time = 0.0; - float blend_left = 0.0; + double blend_time = 0.0; + double blend_left = 0.0; }; struct Playback { @@ -334,17 +334,17 @@ public: void get_animation_list(List<StringName> *p_animations) const; bool has_animation(const StringName &p_name) const; - void set_blend_time(const StringName &p_animation1, const StringName &p_animation2, float p_time); - float get_blend_time(const StringName &p_animation1, const StringName &p_animation2) const; + void set_blend_time(const StringName &p_animation1, const StringName &p_animation2, double p_time); + double get_blend_time(const StringName &p_animation1, const StringName &p_animation2) const; void animation_set_next(const StringName &p_animation, const StringName &p_next); StringName animation_get_next(const StringName &p_animation) const; - void set_default_blend_time(float p_default); - float get_default_blend_time() const; + void set_default_blend_time(double p_default); + double get_default_blend_time() const; - void play(const StringName &p_name = StringName(), float p_custom_blend = -1, float p_custom_scale = 1.0, bool p_from_end = false); - void play_backwards(const StringName &p_name = StringName(), float p_custom_blend = -1); + void play(const StringName &p_name = StringName(), double p_custom_blend = -1, float p_custom_scale = 1.0, bool p_from_end = false); + void play_backwards(const StringName &p_name = StringName(), double p_custom_blend = -1); void queue(const StringName &p_name); Vector<String> get_queue(); void clear_queue(); @@ -378,11 +378,11 @@ public: bool is_movie_quit_on_finish_enabled() const; 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; + void seek_delta(double p_time, double p_delta); + double get_current_animation_position() const; + double get_current_animation_length() const; - void advance(float p_time); + void advance(double p_time); void set_root(const NodePath &p_root); NodePath get_root() const; diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index bcd52082af..05a4a2d024 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -1745,7 +1745,7 @@ Variant AnimationTree::_post_process_key_value(const Ref<Animation> &p_anim, int return p_value; } -void AnimationTree::advance(real_t p_time) { +void AnimationTree::advance(double p_time) { _process_graph(p_time); } diff --git a/scene/animation/animation_tree.h b/scene/animation/animation_tree.h index fc31c52bc6..96c1279f82 100644 --- a/scene/animation/animation_tree.h +++ b/scene/animation/animation_tree.h @@ -353,7 +353,7 @@ public: Transform3D get_root_motion_transform() const; real_t get_connection_activity(const StringName &p_path, int p_connection) const; - void advance(real_t p_time); + void advance(double p_time); void rename_parameter(const String &p_base, const String &p_new_base); diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index b02f1959b7..4a0f870406 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -71,16 +71,16 @@ void Tween::start_tweeners() { } } -Ref<PropertyTweener> Tween::tween_property(Object *p_target, NodePath p_property, Variant p_to, float p_duration) { +Ref<PropertyTweener> Tween::tween_property(Object *p_target, NodePath p_property, Variant p_to, double p_duration) { ERR_FAIL_NULL_V(p_target, nullptr); ERR_FAIL_COND_V_MSG(!valid, nullptr, "Tween invalid. Either finished or created outside scene tree."); ERR_FAIL_COND_V_MSG(started, nullptr, "Can't append to a Tween that has started. Use stop() first."); Variant::Type property_type = p_target->get_indexed(p_property.get_as_property_path().get_subnames()).get_type(); if (property_type != p_to.get_type()) { - // Cast p_to between floats and ints to avoid minor annoyances. + // Cast p_to between double and int to avoid minor annoyances. if (property_type == Variant::FLOAT && p_to.get_type() == Variant::INT) { - p_to = float(p_to); + p_to = double(p_to); } else if (property_type == Variant::INT && p_to.get_type() == Variant::FLOAT) { p_to = int(p_to); } else { @@ -93,7 +93,7 @@ Ref<PropertyTweener> Tween::tween_property(Object *p_target, NodePath p_property return tweener; } -Ref<IntervalTweener> Tween::tween_interval(float p_time) { +Ref<IntervalTweener> Tween::tween_interval(double p_time) { ERR_FAIL_COND_V_MSG(!valid, nullptr, "Tween invalid. Either finished or created outside scene tree."); ERR_FAIL_COND_V_MSG(started, nullptr, "Can't append to a Tween that has started. Use stop() first."); @@ -111,7 +111,7 @@ Ref<CallbackTweener> Tween::tween_callback(Callable p_callback) { return tweener; } -Ref<MethodTweener> Tween::tween_method(Callable p_callback, Variant p_from, Variant p_to, float p_duration) { +Ref<MethodTweener> Tween::tween_method(Callable p_callback, Variant p_from, Variant p_to, double p_duration) { ERR_FAIL_COND_V_MSG(!valid, nullptr, "Tween invalid. Either finished or created outside scene tree."); ERR_FAIL_COND_V_MSG(started, nullptr, "Can't append to a Tween that has started. Use stop() first."); @@ -245,7 +245,7 @@ Ref<Tween> Tween::chain() { return this; } -bool Tween::custom_step(float p_delta) { +bool Tween::custom_step(double p_delta) { bool r = running; running = true; bool ret = step(p_delta); @@ -253,7 +253,7 @@ bool Tween::custom_step(float p_delta) { return ret; } -bool Tween::step(float p_delta) { +bool Tween::step(double p_delta) { if (dead) { return false; } @@ -282,22 +282,22 @@ bool Tween::step(float p_delta) { started = true; } - float rem_delta = p_delta * speed_scale; + double rem_delta = p_delta * speed_scale; bool step_active = false; total_time += rem_delta; #ifdef DEBUG_ENABLED - float initial_delta = rem_delta; + double initial_delta = rem_delta; bool potential_infinite = false; #endif while (rem_delta > 0 && running) { - float step_delta = rem_delta; + double step_delta = rem_delta; step_active = false; for (Ref<Tweener> &tweener : tweeners.write[current_step]) { // Modified inside Tweener.step(). - float temp_delta = rem_delta; + double temp_delta = rem_delta; // Turns to true if any Tweener returns true (i.e. is still not finished). step_active = tweener->step(temp_delta) || step_active; step_delta = MIN(temp_delta, step_delta); @@ -359,7 +359,7 @@ Node *Tween::get_bound_node() const { } } -float Tween::get_total_time() const { +double Tween::get_total_time() const { return total_time; } @@ -373,7 +373,7 @@ real_t Tween::run_equation(TransitionType p_trans_type, EaseType p_ease_type, re return func(p_time, p_initial, p_delta, p_duration); } -Variant Tween::interpolate_variant(Variant p_initial_val, Variant p_delta_val, float p_time, float p_duration, TransitionType p_trans, EaseType p_ease) { +Variant Tween::interpolate_variant(Variant p_initial_val, Variant p_delta_val, double p_time, double p_duration, TransitionType p_trans, EaseType p_ease) { ERR_FAIL_INDEX_V(p_trans, TransitionType::TRANS_MAX, Variant()); ERR_FAIL_INDEX_V(p_ease, EaseType::EASE_MAX, Variant()); @@ -480,7 +480,7 @@ Ref<PropertyTweener> PropertyTweener::set_ease(Tween::EaseType p_ease) { return this; } -Ref<PropertyTweener> PropertyTweener::set_delay(float p_delay) { +Ref<PropertyTweener> PropertyTweener::set_delay(double p_delay) { delay = p_delay; return this; } @@ -506,7 +506,7 @@ void PropertyTweener::start() { delta_val = Animation::subtract_variant(final_val, initial_val); } -bool PropertyTweener::step(float &r_delta) { +bool PropertyTweener::step(double &r_delta) { if (finished) { // This is needed in case there's a parallel Tweener with longer duration. return false; @@ -523,7 +523,7 @@ bool PropertyTweener::step(float &r_delta) { return true; } - float time = MIN(elapsed_time - delay, duration); + double time = MIN(elapsed_time - delay, duration); if (time < duration) { target_instance->set_indexed(property, tween->interpolate_variant(initial_val, delta_val, time, duration, trans_type, ease_type)); r_delta = 0; @@ -556,7 +556,7 @@ void PropertyTweener::_bind_methods() { ClassDB::bind_method(D_METHOD("set_delay", "delay"), &PropertyTweener::set_delay); } -PropertyTweener::PropertyTweener(Object *p_target, NodePath p_property, Variant p_to, float p_duration) { +PropertyTweener::PropertyTweener(Object *p_target, NodePath p_property, Variant p_to, double p_duration) { target = p_target->get_instance_id(); property = p_property.get_as_property_path().get_subnames(); initial_val = p_target->get_indexed(property); @@ -574,7 +574,7 @@ void IntervalTweener::start() { finished = false; } -bool IntervalTweener::step(float &r_delta) { +bool IntervalTweener::step(double &r_delta) { if (finished) { return false; } @@ -592,7 +592,7 @@ bool IntervalTweener::step(float &r_delta) { } } -IntervalTweener::IntervalTweener(float p_time) { +IntervalTweener::IntervalTweener(double p_time) { duration = p_time; } @@ -600,7 +600,7 @@ IntervalTweener::IntervalTweener() { ERR_FAIL_MSG("Can't create empty IntervalTweener. Use get_tree().tween_interval() instead."); } -Ref<CallbackTweener> CallbackTweener::set_delay(float p_delay) { +Ref<CallbackTweener> CallbackTweener::set_delay(double p_delay) { delay = p_delay; return this; } @@ -610,7 +610,7 @@ void CallbackTweener::start() { finished = false; } -bool CallbackTweener::step(float &r_delta) { +bool CallbackTweener::step(double &r_delta) { if (finished) { return false; } @@ -646,7 +646,7 @@ CallbackTweener::CallbackTweener() { ERR_FAIL_MSG("Can't create empty CallbackTweener. Use get_tree().tween_callback() instead."); } -Ref<MethodTweener> MethodTweener::set_delay(float p_delay) { +Ref<MethodTweener> MethodTweener::set_delay(double p_delay) { delay = p_delay; return this; } @@ -666,7 +666,7 @@ void MethodTweener::start() { finished = false; } -bool MethodTweener::step(float &r_delta) { +bool MethodTweener::step(double &r_delta) { if (finished) { return false; } @@ -679,7 +679,7 @@ bool MethodTweener::step(float &r_delta) { } Variant current_val; - float time = MIN(elapsed_time - delay, duration); + double time = MIN(elapsed_time - delay, duration); if (time < duration) { current_val = tween->interpolate_variant(initial_val, delta_val, time, duration, trans_type, ease_type); } else { @@ -722,7 +722,7 @@ void MethodTweener::_bind_methods() { ClassDB::bind_method(D_METHOD("set_ease", "ease"), &MethodTweener::set_ease); } -MethodTweener::MethodTweener(Callable p_callback, Variant p_from, Variant p_to, float p_duration) { +MethodTweener::MethodTweener(Callable p_callback, Variant p_from, Variant p_to, double p_duration) { callback = p_callback; initial_val = p_from; delta_val = Animation::subtract_variant(p_to, p_from); diff --git a/scene/animation/tween.h b/scene/animation/tween.h index da7a8b5d71..345974ecc5 100644 --- a/scene/animation/tween.h +++ b/scene/animation/tween.h @@ -42,13 +42,13 @@ class Tweener : public RefCounted { public: virtual void set_tween(Ref<Tween> p_tween); virtual void start() = 0; - virtual bool step(float &r_delta) = 0; + virtual bool step(double &r_delta) = 0; void clear_tween(); protected: static void _bind_methods(); Ref<Tween> tween; - float elapsed_time = 0; + double elapsed_time = 0; bool finished = false; }; @@ -103,7 +103,7 @@ private: ObjectID bound_node; Vector<List<Ref<Tweener>>> tweeners; - float total_time = 0; + double total_time = 0; int current_step = -1; int loops = 1; int loops_done = 0; @@ -129,13 +129,13 @@ protected: static void _bind_methods(); public: - Ref<PropertyTweener> tween_property(Object *p_target, NodePath p_property, Variant p_to, float p_duration); - Ref<IntervalTweener> tween_interval(float p_time); + Ref<PropertyTweener> tween_property(Object *p_target, NodePath p_property, Variant p_to, double p_duration); + Ref<IntervalTweener> tween_interval(double p_time); Ref<CallbackTweener> tween_callback(Callable p_callback); - Ref<MethodTweener> tween_method(Callable p_callback, Variant p_from, Variant p_to, float p_duration); + Ref<MethodTweener> tween_method(Callable p_callback, Variant p_from, Variant p_to, double p_duration); void append(Ref<Tweener> p_tweener); - bool custom_step(float p_delta); + bool custom_step(double p_delta); void stop(); void pause(); void play(); @@ -163,12 +163,12 @@ public: Ref<Tween> chain(); static real_t run_equation(TransitionType p_trans_type, EaseType p_ease_type, real_t t, real_t b, real_t c, real_t d); - static Variant interpolate_variant(Variant p_initial_val, Variant p_delta_val, float p_time, float p_duration, Tween::TransitionType p_trans, Tween::EaseType p_ease); + static Variant interpolate_variant(Variant p_initial_val, Variant p_delta_val, double p_time, double p_duration, Tween::TransitionType p_trans, Tween::EaseType p_ease); - bool step(float p_delta); + bool step(double p_delta); bool can_process(bool p_tree_paused) const; Node *get_bound_node() const; - float get_total_time() const; + double get_total_time() const; Tween(); Tween(bool p_valid); @@ -188,13 +188,13 @@ public: Ref<PropertyTweener> as_relative(); Ref<PropertyTweener> set_trans(Tween::TransitionType p_trans); Ref<PropertyTweener> set_ease(Tween::EaseType p_ease); - Ref<PropertyTweener> set_delay(float p_delay); + Ref<PropertyTweener> set_delay(double p_delay); void set_tween(Ref<Tween> p_tween) override; void start() override; - bool step(float &r_delta) override; + bool step(double &r_delta) override; - PropertyTweener(Object *p_target, NodePath p_property, Variant p_to, float p_duration); + PropertyTweener(Object *p_target, NodePath p_property, Variant p_to, double p_duration); PropertyTweener(); protected: @@ -208,11 +208,11 @@ private: Variant final_val; Variant delta_val; - float duration = 0; + double duration = 0; Tween::TransitionType trans_type = Tween::TRANS_MAX; // This is set inside set_tween(); Tween::EaseType ease_type = Tween::EASE_MAX; - float delay = 0; + double delay = 0; bool do_continue = true; bool relative = false; }; @@ -222,23 +222,23 @@ class IntervalTweener : public Tweener { public: void start() override; - bool step(float &r_delta) override; + bool step(double &r_delta) override; - IntervalTweener(float p_time); + IntervalTweener(double p_time); IntervalTweener(); private: - float duration = 0; + double duration = 0; }; class CallbackTweener : public Tweener { GDCLASS(CallbackTweener, Tweener); public: - Ref<CallbackTweener> set_delay(float p_delay); + Ref<CallbackTweener> set_delay(double p_delay); void start() override; - bool step(float &r_delta) override; + bool step(double &r_delta) override; CallbackTweener(Callable p_callback); CallbackTweener(); @@ -248,7 +248,7 @@ protected: private: Callable callback; - float delay = 0; + double delay = 0; }; class MethodTweener : public Tweener { @@ -257,21 +257,21 @@ class MethodTweener : public Tweener { public: Ref<MethodTweener> set_trans(Tween::TransitionType p_trans); Ref<MethodTweener> set_ease(Tween::EaseType p_ease); - Ref<MethodTweener> set_delay(float p_delay); + Ref<MethodTweener> set_delay(double p_delay); void set_tween(Ref<Tween> p_tween) override; void start() override; - bool step(float &r_delta) override; + bool step(double &r_delta) override; - MethodTweener(Callable p_callback, Variant p_from, Variant p_to, float p_duration); + MethodTweener(Callable p_callback, Variant p_from, Variant p_to, double p_duration); MethodTweener(); protected: static void _bind_methods(); private: - float duration = 0; - float delay = 0; + double duration = 0; + double delay = 0; Tween::TransitionType trans_type = Tween::TRANS_MAX; Tween::EaseType ease_type = Tween::EASE_MAX; |