Use doubles for time in animation code

This commit is contained in:
Aaron Franke 2021-05-21 02:42:37 -04:00
parent 9d9161c719
commit 78d33a6e24
No known key found for this signature in database
GPG key ID: 40A1750B977E56BF
14 changed files with 149 additions and 149 deletions

View file

@ -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) { if (blend_points_used == 0) {
return 0.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); 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] = {}; float weights[MAX_BLEND_POINTS] = {};

View file

@ -93,7 +93,7 @@ public:
void set_value_label(const String &p_label); void set_value_label(const String &p_label);
String get_value_label() const; 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; String get_caption() const override;
Ref<AnimationNode> get_child_by_name(const StringName &p_name) override; Ref<AnimationNode> get_child_by_name(const StringName &p_name) override;

View file

@ -431,12 +431,12 @@ void AnimationNodeBlendSpace2D::_blend_triangle(const Vector2 &p_pos, const Vect
r_weights[2] = w; r_weights[2] = w;
} }
float AnimationNodeBlendSpace2D::process(float p_time, bool p_seek) { double AnimationNodeBlendSpace2D::process(double p_time, bool p_seek) {
_update_triangles(); _update_triangles();
Vector2 blend_pos = get_parameter(blend_position); Vector2 blend_pos = get_parameter(blend_position);
int closest = get_parameter(this->closest); 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 float mind = 0.0; //time of min distance point
if (blend_mode == BLEND_MODE_INTERPOLATED) { if (blend_mode == BLEND_MODE_INTERPOLATED) {

View file

@ -126,7 +126,7 @@ public:
void set_y_label(const String &p_label); void set_y_label(const String &p_label);
String get_y_label() const; 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; virtual String get_caption() const override;
Vector2 get_closest_point(const Vector2 &p_point); Vector2 get_closest_point(const Vector2 &p_point);

View file

@ -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; AnimationPlayer *ap = state->player;
ERR_FAIL_COND_V(!ap, 0); ERR_FAIL_COND_V(!ap, 0);
float time = get_parameter(this->time); double time = get_parameter(this->time);
if (!ap->has_animation(animation)) { if (!ap->has_animation(animation)) {
AnimationNodeBlendTree *tree = Object::cast_to<AnimationNodeBlendTree>(parent); 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); Ref<Animation> anim = ap->get_animation(animation);
float step; double step;
if (p_seek) { if (p_seek) {
time = p_time; time = p_time;
@ -94,7 +94,7 @@ float AnimationNodeAnimation::process(float p_time, bool p_seek) {
step = p_time; step = p_time;
} }
float anim_size = anim->get_length(); double anim_size = anim->get_length();
if (anim->has_loop()) { if (anim->has_loop()) {
if (anim_size) { if (anim_size) {
@ -202,12 +202,12 @@ bool AnimationNodeOneShot::has_filter() const {
return true; 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 active = get_parameter(this->active);
bool prev_active = get_parameter(this->prev_active); bool prev_active = get_parameter(this->prev_active);
float time = get_parameter(this->time); double time = get_parameter(this->time);
float remaining = get_parameter(this->remaining); double remaining = get_parameter(this->remaining);
float time_to_restart = get_parameter(this->time_to_restart); double time_to_restart = get_parameter(this->time_to_restart);
if (!active) { if (!active) {
//make it as if this node doesn't exist, pass input 0 by. //make it as if this node doesn't exist, pass input 0 by.
@ -370,9 +370,9 @@ bool AnimationNodeAdd2::has_filter() const {
return true; return true;
} }
float AnimationNodeAdd2::process(float p_time, bool p_seek) { double AnimationNodeAdd2::process(double p_time, bool p_seek) {
float amount = get_parameter(add_amount); double amount = get_parameter(add_amount);
float rem0 = blend_input(0, p_time, p_seek, 1.0, FILTER_IGNORE, !sync); 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); blend_input(1, p_time, p_seek, amount, FILTER_PASS, !sync);
return rem0; return rem0;
@ -416,10 +416,10 @@ bool AnimationNodeAdd3::has_filter() const {
return true; return true;
} }
float AnimationNodeAdd3::process(float p_time, bool p_seek) { double AnimationNodeAdd3::process(double p_time, bool p_seek) {
float amount = get_parameter(add_amount); double amount = get_parameter(add_amount);
blend_input(0, p_time, p_seek, MAX(0, -amount), FILTER_PASS, !sync); 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); blend_input(2, p_time, p_seek, MAX(0, amount), FILTER_PASS, !sync);
return rem0; return rem0;
@ -452,11 +452,11 @@ String AnimationNodeBlend2::get_caption() const {
return "Blend2"; return "Blend2";
} }
float AnimationNodeBlend2::process(float p_time, bool p_seek) { double AnimationNodeBlend2::process(double p_time, bool p_seek) {
float amount = get_parameter(blend_amount); double amount = get_parameter(blend_amount);
float rem0 = blend_input(0, p_time, p_seek, 1.0 - amount, FILTER_BLEND, !sync); double 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 rem1 = blend_input(1, p_time, p_seek, amount, FILTER_PASS, !sync);
return amount > 0.5 ? rem1 : rem0; //hacky but good enough return amount > 0.5 ? rem1 : rem0; //hacky but good enough
} }
@ -507,11 +507,11 @@ bool AnimationNodeBlend3::is_using_sync() const {
return sync; return sync;
} }
float AnimationNodeBlend3::process(float p_time, bool p_seek) { double AnimationNodeBlend3::process(double p_time, bool p_seek) {
float amount = get_parameter(blend_amount); double amount = get_parameter(blend_amount);
float rem0 = blend_input(0, p_time, p_seek, MAX(0, -amount), FILTER_IGNORE, !sync); double 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); double 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 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 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"; return "TimeScale";
} }
float AnimationNodeTimeScale::process(float p_time, bool p_seek) { double AnimationNodeTimeScale::process(double p_time, bool p_seek) {
float scale = get_parameter(this->scale); double scale = get_parameter(this->scale);
if (p_seek) { if (p_seek) {
return blend_input(0, p_time, true, 1.0, FILTER_IGNORE, false); return blend_input(0, p_time, true, 1.0, FILTER_IGNORE, false);
} else { } else {
@ -575,12 +575,12 @@ String AnimationNodeTimeSeek::get_caption() const {
return "Seek"; return "Seek";
} }
float AnimationNodeTimeSeek::process(float p_time, bool p_seek) { double AnimationNodeTimeSeek::process(double p_time, bool p_seek) {
float seek_pos = get_parameter(this->seek_pos); double seek_pos = get_parameter(this->seek_pos);
if (p_seek) { if (p_seek) {
return blend_input(0, p_time, true, 1.0, FILTER_IGNORE, false); return blend_input(0, p_time, true, 1.0, FILTER_IGNORE, false);
} else if (seek_pos >= 0) { } 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 set_parameter(this->seek_pos, -1.0); //reset
return ret; return ret;
} else { } else {
@ -676,13 +676,13 @@ float AnimationNodeTransition::get_cross_fade_time() const {
return xfade; 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 current = get_parameter(this->current);
int prev = get_parameter(this->prev); int prev = get_parameter(this->prev);
int prev_current = get_parameter(this->prev_current); int prev_current = get_parameter(this->prev_current);
float time = get_parameter(this->time); double time = get_parameter(this->time);
float prev_xfading = get_parameter(this->prev_xfading); double prev_xfading = get_parameter(this->prev_xfading);
bool switched = current != prev_current; bool switched = current != prev_current;
@ -794,7 +794,7 @@ String AnimationNodeOutput::get_caption() const {
return "Output"; 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); return blend_input(0, p_time, p_seek, 1.0);
} }
@ -1007,7 +1007,7 @@ String AnimationNodeBlendTree::get_caption() const {
return "BlendTree"; 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; 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); return _blend_node("output", nodes[SceneStringNames::get_singleton()->output].connections, this, output, p_time, p_seek, 1.0);
} }

View file

@ -53,7 +53,7 @@ public:
static Vector<String> (*get_editable_animation_list)(); static Vector<String> (*get_editable_animation_list)();
virtual String get_caption() 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_animation(const StringName &p_name); void set_animation(const StringName &p_name);
StringName get_animation() const; StringName get_animation() const;
@ -122,7 +122,7 @@ public:
bool is_using_sync() const; bool is_using_sync() const;
virtual bool has_filter() const override; 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(); AnimationNodeOneShot();
}; };
@ -148,7 +148,7 @@ public:
bool is_using_sync() const; bool is_using_sync() const;
virtual bool has_filter() const override; 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(); AnimationNodeAdd2();
}; };
@ -172,7 +172,7 @@ public:
bool is_using_sync() const; bool is_using_sync() const;
virtual bool has_filter() const override; 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(); AnimationNodeAdd3();
}; };
@ -191,7 +191,7 @@ public:
virtual Variant get_parameter_default_value(const StringName &p_parameter) const override; virtual Variant get_parameter_default_value(const StringName &p_parameter) const override;
virtual String get_caption() 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); void set_use_sync(bool p_sync);
bool is_using_sync() const; bool is_using_sync() const;
@ -218,7 +218,7 @@ public:
void set_use_sync(bool p_sync); void set_use_sync(bool p_sync);
bool is_using_sync() const; bool is_using_sync() const;
float process(float p_time, bool p_seek) override; double process(double p_time, bool p_seek) override;
AnimationNodeBlend3(); AnimationNodeBlend3();
}; };
@ -236,7 +236,7 @@ public:
virtual String get_caption() const override; 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(); AnimationNodeTimeScale();
}; };
@ -255,7 +255,7 @@ public:
virtual String get_caption() const override; 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(); AnimationNodeTimeSeek();
}; };
@ -313,7 +313,7 @@ public:
void set_cross_fade_time(float p_fade); void set_cross_fade_time(float p_fade);
float get_cross_fade_time() const; 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(); AnimationNodeTransition();
}; };
@ -323,7 +323,7 @@ class AnimationNodeOutput : public AnimationNode {
public: public:
virtual String get_caption() 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;
AnimationNodeOutput(); AnimationNodeOutput();
}; };
@ -390,7 +390,7 @@ public:
void get_node_connections(List<NodeConnection> *r_connections) const; void get_node_connections(List<NodeConnection> *r_connections) const;
virtual String get_caption() 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 get_node_list(List<StringName> *r_list); void get_node_list(List<StringName> *r_list);

View file

@ -286,7 +286,7 @@ bool AnimationNodeStateMachinePlayback::_travel(AnimationNodeStateMachine *p_sta
return true; 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 not playing and it can restart, then restart
if (!playing && start_request == StringName()) { if (!playing && start_request == StringName()) {
if (!stop_request && p_state_machine->start_node) { if (!stop_request && p_state_machine->start_node) {
@ -790,7 +790,7 @@ Vector2 AnimationNodeStateMachine::get_graph_offset() const {
return graph_offset; 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); Ref<AnimationNodeStateMachinePlayback> playback = get_parameter(this->playback);
ERR_FAIL_COND_V(playback.is_null(), 0.0); ERR_FAIL_COND_V(playback.is_null(), 0.0);

View file

@ -114,7 +114,7 @@ class AnimationNodeStateMachinePlayback : public Resource {
bool _travel(AnimationNodeStateMachine *p_state_machine, const StringName &p_travel); 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: protected:
static void _bind_methods(); static void _bind_methods();
@ -210,7 +210,7 @@ public:
void set_graph_offset(const Vector2 &p_offset); void set_graph_offset(const Vector2 &p_offset);
Vector2 get_graph_offset() const; 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 String get_caption() const override;
virtual Ref<AnimationNode> get_child_by_name(const StringName &p_name) override; virtual Ref<AnimationNode> get_child_by_name(const StringName &p_name) override;

View file

@ -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); _ensure_node_caches(p_anim);
ERR_FAIL_COND(p_anim->node_cache.size() != p_anim->animation->get_track_count()); 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; 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); StringName anim_name = a->animation_track_get_key_animation(i, idx);
if (String(anim_name) == "[stop]" || !player->has_animation(anim_name)) { 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); Ref<Animation> anim = player->get_animation(anim_name);
float at_anim_pos; double at_anim_pos;
if (anim->has_loop()) { 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 { } 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) { if (player->is_playing() || p_seeked) {
@ -776,9 +776,9 @@ 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) { void AnimationPlayer::_animation_process_data(PlaybackData &cd, double p_delta, float p_blend, bool p_seeked, bool p_started) {
float delta = p_delta * speed_scale * cd.speed_scale; double delta = p_delta * speed_scale * cd.speed_scale;
float next_pos = cd.pos + delta; double next_pos = cd.pos + delta;
float len = cd.from->animation->get_length(); float len = cd.from->animation->get_length();
bool loop = cd.from->animation->has_loop(); bool loop = cd.from->animation->has_loop();
@ -808,7 +808,7 @@ void AnimationPlayer::_animation_process_data(PlaybackData &cd, float p_delta, f
} }
} else { } 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) { if (looped_next_pos == 0 && next_pos != 0) {
// Loop multiples of the length to it, rather than 0 // Loop multiples of the length to it, rather than 0
// so state at time=length is previewable in the editor // 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); _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; Playback &c = playback;
accum_pass++; accum_pass++;
@ -927,7 +927,7 @@ void AnimationPlayer::_animation_update_transforms() {
cache_update_bezier_size = 0; cache_update_bezier_size = 0;
} }
void AnimationPlayer::_animation_process(float p_delta) { void AnimationPlayer::_animation_process(double p_delta) {
if (playback.current.from) { if (playback.current.from) {
end_reached = false; end_reached = false;
end_notify = false; end_notify = false;
@ -1283,7 +1283,7 @@ float AnimationPlayer::get_playing_speed() const {
return speed_scale * playback.current.speed_scale; 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.current.from) {
if (playback.assigned) { if (playback.assigned) {
ERR_FAIL_COND(!animation_set.has(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.current.from) {
if (playback.assigned) { if (playback.assigned) {
ERR_FAIL_COND(!animation_set.has(playback.assigned)); ERR_FAIL_COND(!animation_set.has(playback.assigned));

View file

@ -215,13 +215,13 @@ private:
NodePath root; 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 _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_process_data(PlaybackData &cd, double p_delta, float p_blend, bool p_seeked, bool p_started);
void _animation_process2(float p_delta, bool p_started); void _animation_process2(double p_delta, bool p_started);
void _animation_update_transforms(); void _animation_update_transforms();
void _animation_process(float p_delta); void _animation_process(double p_delta);
void _node_removed(Node *p_node); void _node_removed(Node *p_node);
void _stop_playing_caches(); void _stop_playing_caches();
@ -306,8 +306,8 @@ public:
void set_method_call_mode(AnimationMethodCallMode p_mode); void set_method_call_mode(AnimationMethodCallMode p_mode);
AnimationMethodCallMode get_method_call_mode() const; AnimationMethodCallMode get_method_call_mode() const;
void seek(float p_time, bool p_update = false); void seek(double p_time, bool p_update = false);
void seek_delta(float p_time, float p_delta); void seek_delta(double p_time, float p_delta);
float get_current_animation_position() const; float get_current_animation_position() const;
float get_current_animation_length() const; float get_current_animation_length() const;

View file

@ -328,7 +328,7 @@ void AnimationNode::remove_input(int p_index) {
emit_changed(); emit_changed();
} }
float AnimationNode::process(float p_time, bool p_seek) { double AnimationNode::process(double p_time, bool p_seek) {
if (get_script_instance()) { if (get_script_instance()) {
return get_script_instance()->call("_process", p_time, p_seek); return get_script_instance()->call("_process", p_time, p_seek);
} }
@ -818,8 +818,8 @@ void AnimationTree::_process_graph(float p_delta) {
for (const AnimationNode::AnimationState &as : state.animation_states) { for (const AnimationNode::AnimationState &as : state.animation_states) {
Ref<Animation> a = as.animation; Ref<Animation> a = as.animation;
float time = as.time; double time = as.time;
float delta = as.delta; double delta = as.delta;
float weight = as.blend; float weight = as.blend;
bool seeked = as.seeked; bool seeked = as.seeked;
@ -1132,7 +1132,7 @@ void AnimationTree::_process_graph(float p_delta) {
continue; 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); StringName anim_name = a->animation_track_get_key_animation(i, idx);
if (String(anim_name) == "[stop]" || !player2->has_animation(anim_name)) { if (String(anim_name) == "[stop]" || !player2->has_animation(anim_name)) {
@ -1144,7 +1144,7 @@ void AnimationTree::_process_graph(float p_delta) {
float at_anim_pos; float at_anim_pos;
if (anim->has_loop()) { 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 { } else {
at_anim_pos = MAX(anim->get_length(), time - pos); //seek to end at_anim_pos = MAX(anim->get_length(), time - pos); //seek to end
} }

View file

@ -63,8 +63,8 @@ public:
struct AnimationState { struct AnimationState {
Ref<Animation> animation; Ref<Animation> animation;
float time = 0.0; double time = 0.0;
float delta = 0.0; double delta = 0.0;
const Vector<float> *track_blends = nullptr; const Vector<float> *track_blends = nullptr;
float blend = 0.0; float blend = 0.0;
bool seeked = false; bool seeked = false;
@ -126,7 +126,7 @@ public:
virtual void get_child_nodes(List<ChildNode> *r_child_nodes); 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; virtual String get_caption() const;
int get_input_count() const; int get_input_count() const;

View file

@ -722,7 +722,7 @@ bool Animation::track_get_interpolation_loop_wrap(int p_track) const {
// transform // transform
/* /*
template<class T> template<class T>
int Animation::_insert_pos(float p_time, T& p_keys) { int Animation::_insert_pos(double p_time, T& p_keys) {
// simple, linear time inset that should be fast enough in reality. // simple, linear time inset that should be fast enough in reality.
int idx=p_keys.size(); int idx=p_keys.size();
@ -745,12 +745,12 @@ int Animation::_insert_pos(float p_time, T& p_keys) {
*/ */
template <class T, class V> template <class T, class V>
int Animation::_insert(float p_time, T &p_keys, const V &p_value) { int Animation::_insert(double p_time, T &p_keys, const V &p_value) {
int idx = p_keys.size(); int idx = p_keys.size();
while (true) { while (true) {
// Condition for replacement. // Condition for replacement.
if (idx > 0 && Math::is_equal_approx(p_keys[idx - 1].time, p_time)) { if (idx > 0 && Math::is_equal_approx((double)p_keys[idx - 1].time, p_time)) {
float transition = p_keys[idx - 1].transition; float transition = p_keys[idx - 1].transition;
p_keys.write[idx - 1] = p_value; p_keys.write[idx - 1] = p_value;
p_keys.write[idx - 1].transition = transition; p_keys.write[idx - 1].transition = transition;
@ -794,7 +794,7 @@ Error Animation::transform_track_get_key(int p_track, int p_key, Vector3 *r_loc,
return OK; return OK;
} }
int Animation::transform_track_insert_key(int p_track, float p_time, const Vector3 &p_loc, const Quaternion &p_rot, const Vector3 &p_scale) { int Animation::transform_track_insert_key(int p_track, double p_time, const Vector3 &p_loc, const Quaternion &p_rot, const Vector3 &p_scale) {
ERR_FAIL_INDEX_V(p_track, tracks.size(), -1); ERR_FAIL_INDEX_V(p_track, tracks.size(), -1);
Track *t = tracks[p_track]; Track *t = tracks[p_track];
ERR_FAIL_COND_V(t->type != TYPE_TRANSFORM3D, -1); ERR_FAIL_COND_V(t->type != TYPE_TRANSFORM3D, -1);
@ -812,7 +812,7 @@ int Animation::transform_track_insert_key(int p_track, float p_time, const Vecto
return ret; return ret;
} }
void Animation::track_remove_key_at_time(int p_track, float p_time) { void Animation::track_remove_key_at_time(int p_track, double p_time) {
int idx = track_find_key(p_track, p_time, true); int idx = track_find_key(p_track, p_time, true);
ERR_FAIL_COND(idx < 0); ERR_FAIL_COND(idx < 0);
track_remove_key(p_track, idx); track_remove_key(p_track, idx);
@ -864,7 +864,7 @@ void Animation::track_remove_key(int p_track, int p_idx) {
emit_changed(); emit_changed();
} }
int Animation::track_find_key(int p_track, float p_time, bool p_exact) const { int Animation::track_find_key(int p_track, double p_time, bool p_exact) const {
ERR_FAIL_INDEX_V(p_track, tracks.size(), -1); ERR_FAIL_INDEX_V(p_track, tracks.size(), -1);
Track *t = tracks[p_track]; Track *t = tracks[p_track];
@ -946,7 +946,7 @@ int Animation::track_find_key(int p_track, float p_time, bool p_exact) const {
return -1; return -1;
} }
void Animation::track_insert_key(int p_track, float p_time, const Variant &p_key, float p_transition) { void Animation::track_insert_key(int p_track, double p_time, const Variant &p_key, float p_transition) {
ERR_FAIL_INDEX(p_track, tracks.size()); ERR_FAIL_INDEX(p_track, tracks.size());
Track *t = tracks[p_track]; Track *t = tracks[p_track];
@ -1151,7 +1151,7 @@ Variant Animation::track_get_key_value(int p_track, int p_key_idx) const {
ERR_FAIL_V(Variant()); ERR_FAIL_V(Variant());
} }
float Animation::track_get_key_time(int p_track, int p_key_idx) const { double Animation::track_get_key_time(int p_track, int p_key_idx) const {
ERR_FAIL_INDEX_V(p_track, tracks.size(), -1); ERR_FAIL_INDEX_V(p_track, tracks.size(), -1);
Track *t = tracks[p_track]; Track *t = tracks[p_track];
@ -1196,7 +1196,7 @@ float Animation::track_get_key_time(int p_track, int p_key_idx) const {
ERR_FAIL_V(-1); ERR_FAIL_V(-1);
} }
void Animation::track_set_key_time(int p_track, int p_key_idx, float p_time) { void Animation::track_set_key_time(int p_track, int p_key_idx, double p_time) {
ERR_FAIL_INDEX(p_track, tracks.size()); ERR_FAIL_INDEX(p_track, tracks.size());
Track *t = tracks[p_track]; Track *t = tracks[p_track];
@ -1412,7 +1412,7 @@ void Animation::track_set_key_transition(int p_track, int p_key_idx, float p_tra
} }
template <class K> template <class K>
int Animation::_find(const Vector<K> &p_keys, float p_time) const { int Animation::_find(const Vector<K> &p_keys, double p_time) const {
int len = p_keys.size(); int len = p_keys.size();
if (len == 0) { if (len == 0) {
return -2; return -2;
@ -1433,7 +1433,7 @@ int Animation::_find(const Vector<K> &p_keys, float p_time) const {
while (low <= high) { while (low <= high) {
middle = (low + high) / 2; middle = (low + high) / 2;
if (Math::is_equal_approx(p_time, keys[middle].time)) { //match if (Math::is_equal_approx(p_time, (double)keys[middle].time)) { //match
return middle; return middle;
} else if (p_time < keys[middle].time) { } else if (p_time < keys[middle].time) {
high = middle - 1; //search low end of array high = middle - 1; //search low end of array
@ -1584,7 +1584,7 @@ float Animation::_cubic_interpolate(const float &p_pre_a, const float &p_a, cons
} }
template <class T> template <class T>
T Animation::_interpolate(const Vector<TKey<T>> &p_keys, float p_time, InterpolationType p_interp, bool p_loop_wrap, bool *p_ok) const { T Animation::_interpolate(const Vector<TKey<T>> &p_keys, double p_time, InterpolationType p_interp, bool p_loop_wrap, bool *p_ok) const {
int len = _find(p_keys, length) + 1; // try to find last key (there may be more past the end) int len = _find(p_keys, length) + 1; // try to find last key (there may be more past the end)
if (len <= 0) { if (len <= 0) {
@ -1728,7 +1728,7 @@ T Animation::_interpolate(const Vector<TKey<T>> &p_keys, float p_time, Interpola
// do a barrel roll // do a barrel roll
} }
Error Animation::transform_track_interpolate(int p_track, float p_time, Vector3 *r_loc, Quaternion *r_rot, Vector3 *r_scale) const { Error Animation::transform_track_interpolate(int p_track, double p_time, Vector3 *r_loc, Quaternion *r_rot, Vector3 *r_scale) const {
ERR_FAIL_INDEX_V(p_track, tracks.size(), ERR_INVALID_PARAMETER); ERR_FAIL_INDEX_V(p_track, tracks.size(), ERR_INVALID_PARAMETER);
Track *t = tracks[p_track]; Track *t = tracks[p_track];
ERR_FAIL_COND_V(t->type != TYPE_TRANSFORM3D, ERR_INVALID_PARAMETER); ERR_FAIL_COND_V(t->type != TYPE_TRANSFORM3D, ERR_INVALID_PARAMETER);
@ -1758,7 +1758,7 @@ Error Animation::transform_track_interpolate(int p_track, float p_time, Vector3
return OK; return OK;
} }
Variant Animation::value_track_interpolate(int p_track, float p_time) const { Variant Animation::value_track_interpolate(int p_track, double p_time) const {
ERR_FAIL_INDEX_V(p_track, tracks.size(), 0); ERR_FAIL_INDEX_V(p_track, tracks.size(), 0);
Track *t = tracks[p_track]; Track *t = tracks[p_track];
ERR_FAIL_COND_V(t->type != TYPE_VALUE, Variant()); ERR_FAIL_COND_V(t->type != TYPE_VALUE, Variant());
@ -1775,7 +1775,7 @@ Variant Animation::value_track_interpolate(int p_track, float p_time) const {
return Variant(); return Variant();
} }
void Animation::_value_track_get_key_indices_in_range(const ValueTrack *vt, float from_time, float to_time, List<int> *p_indices) const { void Animation::_value_track_get_key_indices_in_range(const ValueTrack *vt, double from_time, double to_time, List<int> *p_indices) const {
if (from_time != length && to_time == length) { if (from_time != length && to_time == length) {
to_time = length * 1.001; //include a little more if at the end to_time = length * 1.001; //include a little more if at the end
} }
@ -1812,15 +1812,15 @@ void Animation::_value_track_get_key_indices_in_range(const ValueTrack *vt, floa
} }
} }
void Animation::value_track_get_key_indices(int p_track, float p_time, float p_delta, List<int> *p_indices) const { void Animation::value_track_get_key_indices(int p_track, double p_time, double p_delta, List<int> *p_indices) const {
ERR_FAIL_INDEX(p_track, tracks.size()); ERR_FAIL_INDEX(p_track, tracks.size());
Track *t = tracks[p_track]; Track *t = tracks[p_track];
ERR_FAIL_COND(t->type != TYPE_VALUE); ERR_FAIL_COND(t->type != TYPE_VALUE);
ValueTrack *vt = static_cast<ValueTrack *>(t); ValueTrack *vt = static_cast<ValueTrack *>(t);
float from_time = p_time - p_delta; double from_time = p_time - p_delta;
float to_time = p_time; double to_time = p_time;
if (from_time > to_time) { if (from_time > to_time) {
SWAP(from_time, to_time); SWAP(from_time, to_time);
@ -1875,7 +1875,7 @@ Animation::UpdateMode Animation::value_track_get_update_mode(int p_track) const
} }
template <class T> template <class T>
void Animation::_track_get_key_indices_in_range(const Vector<T> &p_array, float from_time, float to_time, List<int> *p_indices) const { void Animation::_track_get_key_indices_in_range(const Vector<T> &p_array, double from_time, double to_time, List<int> *p_indices) const {
if (from_time != length && to_time == length) { if (from_time != length && to_time == length) {
to_time = length * 1.01; //include a little more if at the end to_time = length * 1.01; //include a little more if at the end
} }
@ -1908,12 +1908,12 @@ void Animation::_track_get_key_indices_in_range(const Vector<T> &p_array, float
} }
} }
void Animation::track_get_key_indices_in_range(int p_track, float p_time, float p_delta, List<int> *p_indices) const { void Animation::track_get_key_indices_in_range(int p_track, double p_time, double p_delta, List<int> *p_indices) const {
ERR_FAIL_INDEX(p_track, tracks.size()); ERR_FAIL_INDEX(p_track, tracks.size());
const Track *t = tracks[p_track]; const Track *t = tracks[p_track];
float from_time = p_time - p_delta; double from_time = p_time - p_delta;
float to_time = p_time; double to_time = p_time;
if (from_time > to_time) { if (from_time > to_time) {
SWAP(from_time, to_time); SWAP(from_time, to_time);
@ -2021,7 +2021,7 @@ void Animation::track_get_key_indices_in_range(int p_track, float p_time, float
} }
} }
void Animation::_method_track_get_key_indices_in_range(const MethodTrack *mt, float from_time, float to_time, List<int> *p_indices) const { void Animation::_method_track_get_key_indices_in_range(const MethodTrack *mt, double from_time, double to_time, List<int> *p_indices) const {
if (from_time != length && to_time == length) { if (from_time != length && to_time == length) {
to_time = length * 1.01; //include a little more if at the end to_time = length * 1.01; //include a little more if at the end
} }
@ -2054,15 +2054,15 @@ void Animation::_method_track_get_key_indices_in_range(const MethodTrack *mt, fl
} }
} }
void Animation::method_track_get_key_indices(int p_track, float p_time, float p_delta, List<int> *p_indices) const { void Animation::method_track_get_key_indices(int p_track, double p_time, double p_delta, List<int> *p_indices) const {
ERR_FAIL_INDEX(p_track, tracks.size()); ERR_FAIL_INDEX(p_track, tracks.size());
Track *t = tracks[p_track]; Track *t = tracks[p_track];
ERR_FAIL_COND(t->type != TYPE_METHOD); ERR_FAIL_COND(t->type != TYPE_METHOD);
MethodTrack *mt = static_cast<MethodTrack *>(t); MethodTrack *mt = static_cast<MethodTrack *>(t);
float from_time = p_time - p_delta; double from_time = p_time - p_delta;
float to_time = p_time; double to_time = p_time;
if (from_time > to_time) { if (from_time > to_time) {
SWAP(from_time, to_time); SWAP(from_time, to_time);
@ -2128,7 +2128,7 @@ StringName Animation::method_track_get_name(int p_track, int p_key_idx) const {
return pm->methods[p_key_idx].method; return pm->methods[p_key_idx].method;
} }
int Animation::bezier_track_insert_key(int p_track, float p_time, float p_value, const Vector2 &p_in_handle, const Vector2 &p_out_handle) { int Animation::bezier_track_insert_key(int p_track, double p_time, float p_value, const Vector2 &p_in_handle, const Vector2 &p_out_handle) {
ERR_FAIL_INDEX_V(p_track, tracks.size(), -1); ERR_FAIL_INDEX_V(p_track, tracks.size(), -1);
Track *t = tracks[p_track]; Track *t = tracks[p_track];
ERR_FAIL_COND_V(t->type != TYPE_BEZIER, -1); ERR_FAIL_COND_V(t->type != TYPE_BEZIER, -1);
@ -2246,7 +2246,7 @@ static _FORCE_INLINE_ Vector2 _bezier_interp(real_t t, const Vector2 &start, con
return start * omt3 + control_1 * omt2 * t * 3.0 + control_2 * omt * t2 * 3.0 + end * t3; return start * omt3 + control_1 * omt2 * t * 3.0 + control_2 * omt * t2 * 3.0 + end * t3;
} }
float Animation::bezier_track_interpolate(int p_track, float p_time) const { float Animation::bezier_track_interpolate(int p_track, double p_time) const {
//this uses a different interpolation scheme //this uses a different interpolation scheme
ERR_FAIL_INDEX_V(p_track, tracks.size(), 0); ERR_FAIL_INDEX_V(p_track, tracks.size(), 0);
Track *track = tracks[p_track]; Track *track = tracks[p_track];
@ -2277,14 +2277,14 @@ float Animation::bezier_track_interpolate(int p_track, float p_time) const {
return bt->values[bt->values.size() - 1].value.value; return bt->values[bt->values.size() - 1].value.value;
} }
float t = p_time - bt->values[idx].time; double t = p_time - bt->values[idx].time;
int iterations = 10; int iterations = 10;
float duration = bt->values[idx + 1].time - bt->values[idx].time; // time duration between our two keyframes real_t duration = bt->values[idx + 1].time - bt->values[idx].time; // time duration between our two keyframes
float low = 0.0; // 0% of the current animation segment real_t low = 0.0; // 0% of the current animation segment
float high = 1.0; // 100% of the current animation segment real_t high = 1.0; // 100% of the current animation segment
float middle; real_t middle;
Vector2 start(0, bt->values[idx].value.value); Vector2 start(0, bt->values[idx].value.value);
Vector2 start_out = start + bt->values[idx].value.out_handle; Vector2 start_out = start + bt->values[idx].value.out_handle;
@ -2307,12 +2307,12 @@ float Animation::bezier_track_interpolate(int p_track, float p_time) const {
//interpolate the result: //interpolate the result:
Vector2 low_pos = _bezier_interp(low, start, start_out, end_in, end); Vector2 low_pos = _bezier_interp(low, start, start_out, end_in, end);
Vector2 high_pos = _bezier_interp(high, start, start_out, end_in, end); Vector2 high_pos = _bezier_interp(high, start, start_out, end_in, end);
float c = (t - low_pos.x) / (high_pos.x - low_pos.x); real_t c = (t - low_pos.x) / (high_pos.x - low_pos.x);
return low_pos.lerp(high_pos, c).y; return low_pos.lerp(high_pos, c).y;
} }
int Animation::audio_track_insert_key(int p_track, float p_time, const RES &p_stream, float p_start_offset, float p_end_offset) { int Animation::audio_track_insert_key(int p_track, double p_time, const RES &p_stream, float p_start_offset, float p_end_offset) {
ERR_FAIL_INDEX_V(p_track, tracks.size(), -1); ERR_FAIL_INDEX_V(p_track, tracks.size(), -1);
Track *t = tracks[p_track]; Track *t = tracks[p_track];
ERR_FAIL_COND_V(t->type != TYPE_AUDIO, -1); ERR_FAIL_COND_V(t->type != TYPE_AUDIO, -1);
@ -2426,7 +2426,7 @@ float Animation::audio_track_get_key_end_offset(int p_track, int p_key) const {
// //
int Animation::animation_track_insert_key(int p_track, float p_time, const StringName &p_animation) { int Animation::animation_track_insert_key(int p_track, double p_time, const StringName &p_animation) {
ERR_FAIL_INDEX_V(p_track, tracks.size(), -1); ERR_FAIL_INDEX_V(p_track, tracks.size(), -1);
Track *t = tracks[p_track]; Track *t = tracks[p_track];
ERR_FAIL_COND_V(t->type != TYPE_ANIMATION, -1); ERR_FAIL_COND_V(t->type != TYPE_ANIMATION, -1);
@ -2727,9 +2727,9 @@ bool Animation::_transform_track_optimize_key(const TKey<TransformKey> &t0, cons
} else { } else {
Vector3 pd = (v2 - v0); Vector3 pd = (v2 - v0);
float d0 = pd.dot(v0); real_t d0 = pd.dot(v0);
float d1 = pd.dot(v1); real_t d1 = pd.dot(v1);
float d2 = pd.dot(v2); real_t d2 = pd.dot(v2);
if (d1 < d0 || d1 > d2) { if (d1 < d0 || d1 > d2) {
return false; return false;
} }
@ -2817,9 +2817,9 @@ bool Animation::_transform_track_optimize_key(const TKey<TransformKey> &t0, cons
} else { } else {
Vector3 pd = (v2 - v0); Vector3 pd = (v2 - v0);
float d0 = pd.dot(v0); real_t d0 = pd.dot(v0);
float d1 = pd.dot(v1); real_t d1 = pd.dot(v1);
float d2 = pd.dot(v2); real_t d2 = pd.dot(v2);
if (d1 < d0 || d1 > d2) { if (d1 < d0 || d1 > d2) {
return false; //beyond segment range return false; //beyond segment range
} }

View file

@ -172,16 +172,16 @@ private:
/* /*
template<class T> template<class T>
int _insert_pos(float p_time, T& p_keys);*/ int _insert_pos(double p_time, T& p_keys);*/
template <class T> template <class T>
void _clear(T &p_keys); void _clear(T &p_keys);
template <class T, class V> template <class T, class V>
int _insert(float p_time, T &p_keys, const V &p_value); int _insert(double p_time, T &p_keys, const V &p_value);
template <class K> template <class K>
inline int _find(const Vector<K> &p_keys, float p_time) const; inline int _find(const Vector<K> &p_keys, double p_time) const;
_FORCE_INLINE_ Animation::TransformKey _interpolate(const Animation::TransformKey &p_a, const Animation::TransformKey &p_b, float p_c) const; _FORCE_INLINE_ Animation::TransformKey _interpolate(const Animation::TransformKey &p_a, const Animation::TransformKey &p_b, float p_c) const;
@ -197,21 +197,21 @@ private:
_FORCE_INLINE_ float _cubic_interpolate(const float &p_pre_a, const float &p_a, const float &p_b, const float &p_post_b, float p_c) const; _FORCE_INLINE_ float _cubic_interpolate(const float &p_pre_a, const float &p_a, const float &p_b, const float &p_post_b, float p_c) const;
template <class T> template <class T>
_FORCE_INLINE_ T _interpolate(const Vector<TKey<T>> &p_keys, float p_time, InterpolationType p_interp, bool p_loop_wrap, bool *p_ok) const; _FORCE_INLINE_ T _interpolate(const Vector<TKey<T>> &p_keys, double p_time, InterpolationType p_interp, bool p_loop_wrap, bool *p_ok) const;
template <class T> template <class T>
_FORCE_INLINE_ void _track_get_key_indices_in_range(const Vector<T> &p_array, float from_time, float to_time, List<int> *p_indices) const; _FORCE_INLINE_ void _track_get_key_indices_in_range(const Vector<T> &p_array, double from_time, double to_time, List<int> *p_indices) const;
_FORCE_INLINE_ void _value_track_get_key_indices_in_range(const ValueTrack *vt, float from_time, float to_time, List<int> *p_indices) const; _FORCE_INLINE_ void _value_track_get_key_indices_in_range(const ValueTrack *vt, double from_time, double to_time, List<int> *p_indices) const;
_FORCE_INLINE_ void _method_track_get_key_indices_in_range(const MethodTrack *mt, float from_time, float to_time, List<int> *p_indices) const; _FORCE_INLINE_ void _method_track_get_key_indices_in_range(const MethodTrack *mt, double from_time, double to_time, List<int> *p_indices) const;
float length = 1.0; double length = 1.0;
float step = 0.1; float step = 0.1;
bool loop = false; bool loop = false;
// bind helpers // bind helpers
private: private:
Array _transform_track_interpolate(int p_track, float p_time) const { Array _transform_track_interpolate(int p_track, double p_time) const {
Vector3 loc; Vector3 loc;
Quaternion rot; Quaternion rot;
Vector3 scale; Vector3 scale;
@ -223,7 +223,7 @@ private:
return ret; return ret;
} }
Vector<int> _value_track_get_key_indices(int p_track, float p_time, float p_delta) const { Vector<int> _value_track_get_key_indices(int p_track, double p_time, double p_delta) const {
List<int> idxs; List<int> idxs;
value_track_get_key_indices(p_track, p_time, p_delta, &idxs); value_track_get_key_indices(p_track, p_time, p_delta, &idxs);
Vector<int> idxr; Vector<int> idxr;
@ -233,7 +233,7 @@ private:
} }
return idxr; return idxr;
} }
Vector<int> _method_track_get_key_indices(int p_track, float p_time, float p_delta) const { Vector<int> _method_track_get_key_indices(int p_track, double p_time, double p_delta) const {
List<int> idxs; List<int> idxs;
method_track_get_key_indices(p_track, p_time, p_delta, &idxs); method_track_get_key_indices(p_track, p_time, p_delta, &idxs);
Vector<int> idxr; Vector<int> idxr;
@ -279,24 +279,24 @@ public:
void track_set_enabled(int p_track, bool p_enabled); void track_set_enabled(int p_track, bool p_enabled);
bool track_is_enabled(int p_track) const; bool track_is_enabled(int p_track) const;
void track_insert_key(int p_track, float p_time, const Variant &p_key, float p_transition = 1); void track_insert_key(int p_track, double p_time, const Variant &p_key, float p_transition = 1);
void track_set_key_transition(int p_track, int p_key_idx, float p_transition); void track_set_key_transition(int p_track, int p_key_idx, float p_transition);
void track_set_key_value(int p_track, int p_key_idx, const Variant &p_value); void track_set_key_value(int p_track, int p_key_idx, const Variant &p_value);
void track_set_key_time(int p_track, int p_key_idx, float p_time); void track_set_key_time(int p_track, int p_key_idx, double p_time);
int track_find_key(int p_track, float p_time, bool p_exact = false) const; int track_find_key(int p_track, double p_time, bool p_exact = false) const;
void track_remove_key(int p_track, int p_idx); void track_remove_key(int p_track, int p_idx);
void track_remove_key_at_time(int p_track, float p_time); void track_remove_key_at_time(int p_track, double p_time);
int track_get_key_count(int p_track) const; int track_get_key_count(int p_track) const;
Variant track_get_key_value(int p_track, int p_key_idx) const; Variant track_get_key_value(int p_track, int p_key_idx) const;
float track_get_key_time(int p_track, int p_key_idx) const; double track_get_key_time(int p_track, int p_key_idx) const;
float track_get_key_transition(int p_track, int p_key_idx) const; float track_get_key_transition(int p_track, int p_key_idx) const;
int transform_track_insert_key(int p_track, float p_time, const Vector3 &p_loc, const Quaternion &p_rot = Quaternion(), const Vector3 &p_scale = Vector3()); int transform_track_insert_key(int p_track, double p_time, const Vector3 &p_loc, const Quaternion &p_rot = Quaternion(), const Vector3 &p_scale = Vector3());
Error transform_track_get_key(int p_track, int p_key, Vector3 *r_loc, Quaternion *r_rot, Vector3 *r_scale) const; Error transform_track_get_key(int p_track, int p_key, Vector3 *r_loc, Quaternion *r_rot, Vector3 *r_scale) const;
void track_set_interpolation_type(int p_track, InterpolationType p_interp); void track_set_interpolation_type(int p_track, InterpolationType p_interp);
InterpolationType track_get_interpolation_type(int p_track) const; InterpolationType track_get_interpolation_type(int p_track) const;
int bezier_track_insert_key(int p_track, float p_time, float p_value, const Vector2 &p_in_handle, const Vector2 &p_out_handle); int bezier_track_insert_key(int p_track, double p_time, float p_value, const Vector2 &p_in_handle, const Vector2 &p_out_handle);
void bezier_track_set_key_value(int p_track, int p_index, float p_value); void bezier_track_set_key_value(int p_track, int p_index, float p_value);
void bezier_track_set_key_in_handle(int p_track, int p_index, const Vector2 &p_handle); void bezier_track_set_key_in_handle(int p_track, int p_index, const Vector2 &p_handle);
void bezier_track_set_key_out_handle(int p_track, int p_index, const Vector2 &p_handle); void bezier_track_set_key_out_handle(int p_track, int p_index, const Vector2 &p_handle);
@ -304,9 +304,9 @@ public:
Vector2 bezier_track_get_key_in_handle(int p_track, int p_index) const; Vector2 bezier_track_get_key_in_handle(int p_track, int p_index) const;
Vector2 bezier_track_get_key_out_handle(int p_track, int p_index) const; Vector2 bezier_track_get_key_out_handle(int p_track, int p_index) const;
float bezier_track_interpolate(int p_track, float p_time) const; float bezier_track_interpolate(int p_track, double p_time) const;
int audio_track_insert_key(int p_track, float p_time, const RES &p_stream, float p_start_offset = 0, float p_end_offset = 0); int audio_track_insert_key(int p_track, double p_time, const RES &p_stream, float p_start_offset = 0, float p_end_offset = 0);
void audio_track_set_key_stream(int p_track, int p_key, const RES &p_stream); void audio_track_set_key_stream(int p_track, int p_key, const RES &p_stream);
void audio_track_set_key_start_offset(int p_track, int p_key, float p_offset); void audio_track_set_key_start_offset(int p_track, int p_key, float p_offset);
void audio_track_set_key_end_offset(int p_track, int p_key, float p_offset); void audio_track_set_key_end_offset(int p_track, int p_key, float p_offset);
@ -314,27 +314,27 @@ public:
float audio_track_get_key_start_offset(int p_track, int p_key) const; float audio_track_get_key_start_offset(int p_track, int p_key) const;
float audio_track_get_key_end_offset(int p_track, int p_key) const; float audio_track_get_key_end_offset(int p_track, int p_key) const;
int animation_track_insert_key(int p_track, float p_time, const StringName &p_animation); int animation_track_insert_key(int p_track, double p_time, const StringName &p_animation);
void animation_track_set_key_animation(int p_track, int p_key, const StringName &p_animation); void animation_track_set_key_animation(int p_track, int p_key, const StringName &p_animation);
StringName animation_track_get_key_animation(int p_track, int p_key) const; StringName animation_track_get_key_animation(int p_track, int p_key) const;
void track_set_interpolation_loop_wrap(int p_track, bool p_enable); void track_set_interpolation_loop_wrap(int p_track, bool p_enable);
bool track_get_interpolation_loop_wrap(int p_track) const; bool track_get_interpolation_loop_wrap(int p_track) const;
Error transform_track_interpolate(int p_track, float p_time, Vector3 *r_loc, Quaternion *r_rot, Vector3 *r_scale) const; Error transform_track_interpolate(int p_track, double p_time, Vector3 *r_loc, Quaternion *r_rot, Vector3 *r_scale) const;
Variant value_track_interpolate(int p_track, float p_time) const; Variant value_track_interpolate(int p_track, double p_time) const;
void value_track_get_key_indices(int p_track, float p_time, float p_delta, List<int> *p_indices) const; void value_track_get_key_indices(int p_track, double p_time, double p_delta, List<int> *p_indices) const;
void value_track_set_update_mode(int p_track, UpdateMode p_mode); void value_track_set_update_mode(int p_track, UpdateMode p_mode);
UpdateMode value_track_get_update_mode(int p_track) const; UpdateMode value_track_get_update_mode(int p_track) const;
void method_track_get_key_indices(int p_track, float p_time, float p_delta, List<int> *p_indices) const; void method_track_get_key_indices(int p_track, double p_time, double p_delta, List<int> *p_indices) const;
Vector<Variant> method_track_get_params(int p_track, int p_key_idx) const; Vector<Variant> method_track_get_params(int p_track, int p_key_idx) const;
StringName method_track_get_name(int p_track, int p_key_idx) const; StringName method_track_get_name(int p_track, int p_key_idx) const;
void copy_track(int p_track, Ref<Animation> p_to_animation); void copy_track(int p_track, Ref<Animation> p_to_animation);
void track_get_key_indices_in_range(int p_track, float p_time, float p_delta, List<int> *p_indices) const; void track_get_key_indices_in_range(int p_track, double p_time, double p_delta, List<int> *p_indices) const;
void set_length(float p_length); void set_length(float p_length);
float get_length() const; float get_length() const;