parent
8e14f9ba21
commit
0c46068af0
@ -104,7 +104,7 @@ float AudioStreamPlaybackMP3::get_stream_sampling_rate() {
|
|||||||
return mp3_stream->sample_rate;
|
return mp3_stream->sample_rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioStreamPlaybackMP3::start(float p_from_pos) {
|
void AudioStreamPlaybackMP3::start(double p_from_pos) {
|
||||||
active = true;
|
active = true;
|
||||||
seek(p_from_pos);
|
seek(p_from_pos);
|
||||||
loops = 0;
|
loops = 0;
|
||||||
@ -123,11 +123,11 @@ int AudioStreamPlaybackMP3::get_loop_count() const {
|
|||||||
return loops;
|
return loops;
|
||||||
}
|
}
|
||||||
|
|
||||||
float AudioStreamPlaybackMP3::get_playback_position() const {
|
double AudioStreamPlaybackMP3::get_playback_position() const {
|
||||||
return float(frames_mixed) / mp3_stream->sample_rate;
|
return double(frames_mixed) / mp3_stream->sample_rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioStreamPlaybackMP3::seek(float p_time) {
|
void AudioStreamPlaybackMP3::seek(double p_time) {
|
||||||
if (!active) {
|
if (!active) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -217,15 +217,15 @@ bool AudioStreamMP3::has_loop() const {
|
|||||||
return loop;
|
return loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioStreamMP3::set_loop_offset(float p_seconds) {
|
void AudioStreamMP3::set_loop_offset(double p_seconds) {
|
||||||
loop_offset = p_seconds;
|
loop_offset = p_seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
float AudioStreamMP3::get_loop_offset() const {
|
double AudioStreamMP3::get_loop_offset() const {
|
||||||
return loop_offset;
|
return loop_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
float AudioStreamMP3::get_length() const {
|
double AudioStreamMP3::get_length() const {
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,14 +61,14 @@ protected:
|
|||||||
virtual float get_stream_sampling_rate() override;
|
virtual float get_stream_sampling_rate() override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void start(float p_from_pos = 0.0) override;
|
virtual void start(double p_from_pos = 0.0) override;
|
||||||
virtual void stop() override;
|
virtual void stop() override;
|
||||||
virtual bool is_playing() const override;
|
virtual bool is_playing() const override;
|
||||||
|
|
||||||
virtual int get_loop_count() const override; //times it looped
|
virtual int get_loop_count() const override; //times it looped
|
||||||
|
|
||||||
virtual float get_playback_position() const override;
|
virtual double get_playback_position() const override;
|
||||||
virtual void seek(float p_time) override;
|
virtual void seek(double p_time) override;
|
||||||
|
|
||||||
virtual void tag_used_streams() override;
|
virtual void tag_used_streams() override;
|
||||||
|
|
||||||
@ -104,8 +104,8 @@ public:
|
|||||||
void set_loop(bool p_enable);
|
void set_loop(bool p_enable);
|
||||||
virtual bool has_loop() const override;
|
virtual bool has_loop() const override;
|
||||||
|
|
||||||
void set_loop_offset(float p_seconds);
|
void set_loop_offset(double p_seconds);
|
||||||
float get_loop_offset() const;
|
double get_loop_offset() const;
|
||||||
|
|
||||||
void set_bpm(double p_bpm);
|
void set_bpm(double p_bpm);
|
||||||
virtual double get_bpm() const override;
|
virtual double get_bpm() const override;
|
||||||
@ -122,7 +122,7 @@ public:
|
|||||||
void set_data(const Vector<uint8_t> &p_data);
|
void set_data(const Vector<uint8_t> &p_data);
|
||||||
Vector<uint8_t> get_data() const;
|
Vector<uint8_t> get_data() const;
|
||||||
|
|
||||||
virtual float get_length() const override;
|
virtual double get_length() const override;
|
||||||
|
|
||||||
virtual bool is_monophonic() const override;
|
virtual bool is_monophonic() const override;
|
||||||
|
|
||||||
|
@ -357,7 +357,7 @@ void VideoStreamPlaybackTheora::set_file(const String &p_file) {
|
|||||||
audio_frames_wrote = 0;
|
audio_frames_wrote = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
float VideoStreamPlaybackTheora::get_time() const {
|
double VideoStreamPlaybackTheora::get_time() const {
|
||||||
// FIXME: AudioServer output latency was fixed in af9bb0e, previously it used to
|
// FIXME: AudioServer output latency was fixed in af9bb0e, previously it used to
|
||||||
// systematically return 0. Now that it gives a proper latency, it broke this
|
// systematically return 0. Now that it gives a proper latency, it broke this
|
||||||
// code where the delay compensation likely never really worked.
|
// code where the delay compensation likely never really worked.
|
||||||
@ -368,7 +368,7 @@ Ref<Texture2D> VideoStreamPlaybackTheora::get_texture() const {
|
|||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoStreamPlaybackTheora::update(float p_delta) {
|
void VideoStreamPlaybackTheora::update(double p_delta) {
|
||||||
if (file.is_null()) {
|
if (file.is_null()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -529,7 +529,7 @@ void VideoStreamPlaybackTheora::update(float p_delta) {
|
|||||||
//printf("frame at %f not ready (time %f), ready %i\n", (float)videobuf_time, get_time(), videobuf_ready);
|
//printf("frame at %f not ready (time %f), ready %i\n", (float)videobuf_time, get_time(), videobuf_ready);
|
||||||
}
|
}
|
||||||
|
|
||||||
float tdiff = videobuf_time - get_time();
|
double tdiff = videobuf_time - get_time();
|
||||||
/*If we have lots of extra time, increase the post-processing level.*/
|
/*If we have lots of extra time, increase the post-processing level.*/
|
||||||
if (tdiff > ti.fps_denominator * 0.25 / ti.fps_numerator) {
|
if (tdiff > ti.fps_denominator * 0.25 / ti.fps_numerator) {
|
||||||
pp_inc = pp_level < pp_level_max ? 1 : 0;
|
pp_inc = pp_level < pp_level_max ? 1 : 0;
|
||||||
@ -581,7 +581,7 @@ bool VideoStreamPlaybackTheora::has_loop() const {
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
float VideoStreamPlaybackTheora::get_length() const {
|
double VideoStreamPlaybackTheora::get_length() const {
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -593,11 +593,11 @@ int VideoStreamPlaybackTheora::get_loop_count() const {
|
|||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
float VideoStreamPlaybackTheora::get_playback_position() const {
|
double VideoStreamPlaybackTheora::get_playback_position() const {
|
||||||
return get_time();
|
return get_time();
|
||||||
};
|
};
|
||||||
|
|
||||||
void VideoStreamPlaybackTheora::seek(float p_time) {
|
void VideoStreamPlaybackTheora::seek(double p_time) {
|
||||||
WARN_PRINT_ONCE("Seeking in Theora videos is not implemented yet (it's only supported for GDExtension-provided video streams).");
|
WARN_PRINT_ONCE("Seeking in Theora videos is not implemented yet (it's only supported for GDExtension-provided video streams).");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ class VideoStreamPlaybackTheora : public VideoStreamPlayback {
|
|||||||
int buffer_data();
|
int buffer_data();
|
||||||
int queue_page(ogg_page *page);
|
int queue_page(ogg_page *page);
|
||||||
void video_write();
|
void video_write();
|
||||||
float get_time() const;
|
double get_time() const;
|
||||||
|
|
||||||
bool theora_eos = false;
|
bool theora_eos = false;
|
||||||
bool vorbis_eos = false;
|
bool vorbis_eos = false;
|
||||||
@ -136,19 +136,19 @@ public:
|
|||||||
virtual void set_loop(bool p_enable) override;
|
virtual void set_loop(bool p_enable) override;
|
||||||
virtual bool has_loop() const override;
|
virtual bool has_loop() const override;
|
||||||
|
|
||||||
virtual float get_length() const override;
|
virtual double get_length() const override;
|
||||||
|
|
||||||
virtual String get_stream_name() const;
|
virtual String get_stream_name() const;
|
||||||
|
|
||||||
virtual int get_loop_count() const;
|
virtual int get_loop_count() const;
|
||||||
|
|
||||||
virtual float get_playback_position() const override;
|
virtual double get_playback_position() const override;
|
||||||
virtual void seek(float p_time) override;
|
virtual void seek(double p_time) override;
|
||||||
|
|
||||||
void set_file(const String &p_file);
|
void set_file(const String &p_file);
|
||||||
|
|
||||||
virtual Ref<Texture2D> get_texture() const override;
|
virtual Ref<Texture2D> get_texture() const override;
|
||||||
virtual void update(float p_delta) override;
|
virtual void update(double p_delta) override;
|
||||||
|
|
||||||
virtual void set_mix_callback(AudioMixCallback p_callback, void *p_userdata) override;
|
virtual void set_mix_callback(AudioMixCallback p_callback, void *p_userdata) override;
|
||||||
virtual int get_channels() const override;
|
virtual int get_channels() const override;
|
||||||
|
@ -223,7 +223,7 @@ bool AudioStreamPlaybackOggVorbis::_alloc_vorbis() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioStreamPlaybackOggVorbis::start(float p_from_pos) {
|
void AudioStreamPlaybackOggVorbis::start(double p_from_pos) {
|
||||||
ERR_FAIL_COND(!ready);
|
ERR_FAIL_COND(!ready);
|
||||||
loop_fade_remaining = FADE_SIZE;
|
loop_fade_remaining = FADE_SIZE;
|
||||||
active = true;
|
active = true;
|
||||||
@ -244,15 +244,15 @@ int AudioStreamPlaybackOggVorbis::get_loop_count() const {
|
|||||||
return loops;
|
return loops;
|
||||||
}
|
}
|
||||||
|
|
||||||
float AudioStreamPlaybackOggVorbis::get_playback_position() const {
|
double AudioStreamPlaybackOggVorbis::get_playback_position() const {
|
||||||
return float(frames_mixed) / vorbis_data->get_sampling_rate();
|
return double(frames_mixed) / (double)vorbis_data->get_sampling_rate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioStreamPlaybackOggVorbis::tag_used_streams() {
|
void AudioStreamPlaybackOggVorbis::tag_used_streams() {
|
||||||
vorbis_stream->tag_used(get_playback_position());
|
vorbis_stream->tag_used(get_playback_position());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioStreamPlaybackOggVorbis::seek(float p_time) {
|
void AudioStreamPlaybackOggVorbis::seek(double p_time) {
|
||||||
ERR_FAIL_COND(!ready);
|
ERR_FAIL_COND(!ready);
|
||||||
ERR_FAIL_COND(vorbis_stream.is_null());
|
ERR_FAIL_COND(vorbis_stream.is_null());
|
||||||
if (!active) {
|
if (!active) {
|
||||||
@ -462,15 +462,15 @@ bool AudioStreamOggVorbis::has_loop() const {
|
|||||||
return loop;
|
return loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioStreamOggVorbis::set_loop_offset(float p_seconds) {
|
void AudioStreamOggVorbis::set_loop_offset(double p_seconds) {
|
||||||
loop_offset = p_seconds;
|
loop_offset = p_seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
float AudioStreamOggVorbis::get_loop_offset() const {
|
double AudioStreamOggVorbis::get_loop_offset() const {
|
||||||
return loop_offset;
|
return loop_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
float AudioStreamOggVorbis::get_length() const {
|
double AudioStreamOggVorbis::get_length() const {
|
||||||
ERR_FAIL_COND_V(packet_sequence.is_null(), 0);
|
ERR_FAIL_COND_V(packet_sequence.is_null(), 0);
|
||||||
return packet_sequence->get_length();
|
return packet_sequence->get_length();
|
||||||
}
|
}
|
||||||
|
@ -83,14 +83,14 @@ protected:
|
|||||||
virtual float get_stream_sampling_rate() override;
|
virtual float get_stream_sampling_rate() override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void start(float p_from_pos = 0.0) override;
|
virtual void start(double p_from_pos = 0.0) override;
|
||||||
virtual void stop() override;
|
virtual void stop() override;
|
||||||
virtual bool is_playing() const override;
|
virtual bool is_playing() const override;
|
||||||
|
|
||||||
virtual int get_loop_count() const override; //times it looped
|
virtual int get_loop_count() const override; //times it looped
|
||||||
|
|
||||||
virtual float get_playback_position() const override;
|
virtual double get_playback_position() const override;
|
||||||
virtual void seek(float p_time) override;
|
virtual void seek(double p_time) override;
|
||||||
|
|
||||||
virtual void tag_used_streams() override;
|
virtual void tag_used_streams() override;
|
||||||
|
|
||||||
@ -127,8 +127,8 @@ public:
|
|||||||
void set_loop(bool p_enable);
|
void set_loop(bool p_enable);
|
||||||
virtual bool has_loop() const override;
|
virtual bool has_loop() const override;
|
||||||
|
|
||||||
void set_loop_offset(float p_seconds);
|
void set_loop_offset(double p_seconds);
|
||||||
float get_loop_offset() const;
|
double get_loop_offset() const;
|
||||||
|
|
||||||
void set_bpm(double p_bpm);
|
void set_bpm(double p_bpm);
|
||||||
virtual double get_bpm() const override;
|
virtual double get_bpm() const override;
|
||||||
@ -145,7 +145,7 @@ public:
|
|||||||
void set_packet_sequence(Ref<OggPacketSequence> p_packet_sequence);
|
void set_packet_sequence(Ref<OggPacketSequence> p_packet_sequence);
|
||||||
Ref<OggPacketSequence> get_packet_sequence() const;
|
Ref<OggPacketSequence> get_packet_sequence() const;
|
||||||
|
|
||||||
virtual float get_length() const override; //if supported, otherwise return 0
|
virtual double get_length() const override; //if supported, otherwise return 0
|
||||||
|
|
||||||
virtual bool is_monophonic() const override;
|
virtual bool is_monophonic() const override;
|
||||||
|
|
||||||
|
@ -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;
|
fade_in = p_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationNodeOneShot::set_fadeout_time(float p_time) {
|
void AnimationNodeOneShot::set_fadeout_time(double p_time) {
|
||||||
fade_out = p_time;
|
fade_out = p_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
float AnimationNodeOneShot::get_fadein_time() const {
|
double AnimationNodeOneShot::get_fadein_time() const {
|
||||||
return fade_in;
|
return fade_in;
|
||||||
}
|
}
|
||||||
|
|
||||||
float AnimationNodeOneShot::get_fadeout_time() const {
|
double AnimationNodeOneShot::get_fadeout_time() const {
|
||||||
return fade_out;
|
return fade_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,11 +237,11 @@ void AnimationNodeOneShot::set_autorestart(bool p_active) {
|
|||||||
autorestart = 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;
|
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;
|
autorestart_random_delay = p_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,11 +249,11 @@ bool AnimationNodeOneShot::has_autorestart() const {
|
|||||||
return autorestart;
|
return autorestart;
|
||||||
}
|
}
|
||||||
|
|
||||||
float AnimationNodeOneShot::get_autorestart_delay() const {
|
double AnimationNodeOneShot::get_autorestart_delay() const {
|
||||||
return autorestart_delay;
|
return autorestart_delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
float AnimationNodeOneShot::get_autorestart_random_delay() const {
|
double AnimationNodeOneShot::get_autorestart_random_delay() const {
|
||||||
return autorestart_random_delay;
|
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);
|
set_parameter(this->prev_active, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
float blend;
|
real_t blend;
|
||||||
|
|
||||||
if (time < fade_in) {
|
if (time < fade_in) {
|
||||||
if (fade_in > 0) {
|
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->active, false);
|
||||||
set_parameter(this->prev_active, false);
|
set_parameter(this->prev_active, false);
|
||||||
if (autorestart) {
|
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);
|
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;
|
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;
|
xfade_time = p_fade;
|
||||||
}
|
}
|
||||||
|
|
||||||
float AnimationNodeTransition::get_xfade_time() const {
|
double AnimationNodeTransition::get_xfade_time() const {
|
||||||
return xfade_time;
|
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
|
} 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()) {
|
if (xfade_curve.is_valid()) {
|
||||||
blend = xfade_curve->sample(blend);
|
blend = xfade_curve->sample(blend);
|
||||||
}
|
}
|
||||||
|
@ -102,18 +102,18 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float fade_in = 0.0;
|
double fade_in = 0.0;
|
||||||
float fade_out = 0.0;
|
double fade_out = 0.0;
|
||||||
|
|
||||||
bool autorestart = false;
|
bool autorestart = false;
|
||||||
float autorestart_delay = 1.0;
|
double autorestart_delay = 1.0;
|
||||||
float autorestart_random_delay = 0.0;
|
double autorestart_random_delay = 0.0;
|
||||||
MixMode mix = MIX_MODE_BLEND;
|
MixMode mix = MIX_MODE_BLEND;
|
||||||
|
|
||||||
/* bool active;
|
/* bool active;
|
||||||
bool do_start;
|
bool do_start;
|
||||||
float time;
|
double time;
|
||||||
float remaining;*/
|
double remaining;*/
|
||||||
|
|
||||||
StringName active = PNAME("active");
|
StringName active = PNAME("active");
|
||||||
StringName prev_active = "prev_active";
|
StringName prev_active = "prev_active";
|
||||||
@ -130,19 +130,19 @@ public:
|
|||||||
|
|
||||||
virtual String get_caption() const override;
|
virtual String get_caption() const override;
|
||||||
|
|
||||||
void set_fadein_time(float p_time);
|
void set_fadein_time(double p_time);
|
||||||
void set_fadeout_time(float p_time);
|
void set_fadeout_time(double p_time);
|
||||||
|
|
||||||
float get_fadein_time() const;
|
double get_fadein_time() const;
|
||||||
float get_fadeout_time() const;
|
double get_fadeout_time() const;
|
||||||
|
|
||||||
void set_autorestart(bool p_active);
|
void set_autorestart(bool p_active);
|
||||||
void set_autorestart_delay(float p_time);
|
void set_autorestart_delay(double p_time);
|
||||||
void set_autorestart_random_delay(float p_time);
|
void set_autorestart_random_delay(double p_time);
|
||||||
|
|
||||||
bool has_autorestart() const;
|
bool has_autorestart() const;
|
||||||
float get_autorestart_delay() const;
|
double get_autorestart_delay() const;
|
||||||
float get_autorestart_random_delay() const;
|
double get_autorestart_random_delay() const;
|
||||||
|
|
||||||
void set_mix_mode(MixMode p_mix);
|
void set_mix_mode(MixMode p_mix);
|
||||||
MixMode get_mix_mode() const;
|
MixMode get_mix_mode() const;
|
||||||
@ -285,9 +285,9 @@ class AnimationNodeTransition : public AnimationNodeSync {
|
|||||||
int enabled_inputs = 0;
|
int enabled_inputs = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
float prev_xfading;
|
double prev_xfading;
|
||||||
int prev;
|
int prev;
|
||||||
float time;
|
double time;
|
||||||
int current;
|
int current;
|
||||||
int prev_current; */
|
int prev_current; */
|
||||||
|
|
||||||
@ -297,7 +297,7 @@ class AnimationNodeTransition : public AnimationNodeSync {
|
|||||||
StringName current = PNAME("current");
|
StringName current = PNAME("current");
|
||||||
StringName prev_current = "prev_current";
|
StringName prev_current = "prev_current";
|
||||||
|
|
||||||
float xfade_time = 0.0;
|
double xfade_time = 0.0;
|
||||||
Ref<Curve> xfade_curve;
|
Ref<Curve> xfade_curve;
|
||||||
bool from_start = true;
|
bool from_start = true;
|
||||||
|
|
||||||
@ -322,8 +322,8 @@ public:
|
|||||||
void set_input_caption(int p_input, const String &p_name);
|
void set_input_caption(int p_input, const String &p_name);
|
||||||
String get_input_caption(int p_input) const;
|
String get_input_caption(int p_input) const;
|
||||||
|
|
||||||
void set_xfade_time(float p_fade);
|
void set_xfade_time(double p_fade);
|
||||||
float get_xfade_time() const;
|
double get_xfade_time() const;
|
||||||
|
|
||||||
void set_xfade_curve(const Ref<Curve> &p_curve);
|
void set_xfade_curve(const Ref<Curve> &p_curve);
|
||||||
Ref<Curve> get_xfade_curve() const;
|
Ref<Curve> get_xfade_curve() const;
|
||||||
|
@ -156,7 +156,7 @@ bool AnimationPlayer::_get(const StringName &p_name, Variant &r_ret) const {
|
|||||||
|
|
||||||
} else if (name == "blend_times") {
|
} else if (name == "blend_times") {
|
||||||
Vector<BlendKey> keys;
|
Vector<BlendKey> keys;
|
||||||
for (const KeyValue<BlendKey, float> &E : blend_times) {
|
for (const KeyValue<BlendKey, double> &E : blend_times) {
|
||||||
keys.ordered_insert(E.key);
|
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));
|
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);
|
_animation_process(p_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1287,7 +1287,7 @@ void AnimationPlayer::_animation_removed(const StringName &p_name, const StringN
|
|||||||
|
|
||||||
// Erase blends if needed
|
// Erase blends if needed
|
||||||
List<BlendKey> to_erase;
|
List<BlendKey> to_erase;
|
||||||
for (const KeyValue<BlendKey, float> &E : blend_times) {
|
for (const KeyValue<BlendKey, double> &E : blend_times) {
|
||||||
BlendKey bk = E.key;
|
BlendKey bk = E.key;
|
||||||
if (bk.from == name || bk.to == name) {
|
if (bk.from == name || bk.to == name) {
|
||||||
to_erase.push_back(bk);
|
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) {
|
void AnimationPlayer::_rename_animation(const StringName &p_from_name, const StringName &p_to_name) {
|
||||||
// Rename autoplay or blends if needed.
|
// Rename autoplay or blends if needed.
|
||||||
List<BlendKey> to_erase;
|
List<BlendKey> to_erase;
|
||||||
HashMap<BlendKey, float, BlendKey> to_insert;
|
HashMap<BlendKey, double, BlendKey> to_insert;
|
||||||
for (const KeyValue<BlendKey, float> &E : blend_times) {
|
for (const KeyValue<BlendKey, double> &E : blend_times) {
|
||||||
BlendKey bk = E.key;
|
BlendKey bk = E.key;
|
||||||
BlendKey new_bk = bk;
|
BlendKey new_bk = bk;
|
||||||
bool erase = false;
|
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_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(!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.");
|
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;
|
BlendKey bk;
|
||||||
bk.from = p_animation1;
|
bk.from = p_animation1;
|
||||||
bk.to = p_animation2;
|
bk.to = p_animation2;
|
||||||
@ -1571,11 +1571,11 @@ void AnimationPlayer::clear_queue() {
|
|||||||
queued.clear();
|
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);
|
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;
|
StringName name = p_name;
|
||||||
|
|
||||||
if (String(name) == "") {
|
if (String(name) == "") {
|
||||||
@ -1587,7 +1587,7 @@ void AnimationPlayer::play(const StringName &p_name, float p_custom_blend, float
|
|||||||
Playback &c = playback;
|
Playback &c = playback;
|
||||||
|
|
||||||
if (c.current.from) {
|
if (c.current.from) {
|
||||||
float blend_time = 0.0;
|
double blend_time = 0.0;
|
||||||
// find if it can blend
|
// find if it can blend
|
||||||
BlendKey bk;
|
BlendKey bk;
|
||||||
bk.from = c.current.from->name;
|
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.current.from) {
|
||||||
if (playback.assigned) {
|
if (playback.assigned) {
|
||||||
ERR_FAIL_COND_MSG(!animation_set.has(playback.assigned), vformat("Animation not found: %s.", 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);
|
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");
|
ERR_FAIL_COND_V_MSG(!playback.current.from, 0, "AnimationPlayer has no current animation");
|
||||||
return playback.current.pos;
|
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");
|
ERR_FAIL_COND_V_MSG(!playback.current.from, 0, "AnimationPlayer has no current animation");
|
||||||
return playback.current.from->animation->get_length();
|
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;
|
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;
|
default_blend_time = p_default;
|
||||||
}
|
}
|
||||||
|
|
||||||
float AnimationPlayer::get_default_blend_time() const {
|
double AnimationPlayer::get_default_blend_time() const {
|
||||||
return default_blend_time;
|
return default_blend_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ private:
|
|||||||
|
|
||||||
uint64_t accum_pass = 1;
|
uint64_t accum_pass = 1;
|
||||||
float speed_scale = 1.0;
|
float speed_scale = 1.0;
|
||||||
float default_blend_time = 0.0;
|
double default_blend_time = 0.0;
|
||||||
|
|
||||||
struct AnimationData {
|
struct AnimationData {
|
||||||
String name;
|
String name;
|
||||||
@ -230,7 +230,7 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
HashMap<BlendKey, float, BlendKey> blend_times;
|
HashMap<BlendKey, double, BlendKey> blend_times;
|
||||||
|
|
||||||
struct PlaybackData {
|
struct PlaybackData {
|
||||||
AnimationData *from = nullptr;
|
AnimationData *from = nullptr;
|
||||||
@ -241,8 +241,8 @@ private:
|
|||||||
struct Blend {
|
struct Blend {
|
||||||
PlaybackData data;
|
PlaybackData data;
|
||||||
|
|
||||||
float blend_time = 0.0;
|
double blend_time = 0.0;
|
||||||
float blend_left = 0.0;
|
double blend_left = 0.0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Playback {
|
struct Playback {
|
||||||
@ -334,17 +334,17 @@ public:
|
|||||||
void get_animation_list(List<StringName> *p_animations) const;
|
void get_animation_list(List<StringName> *p_animations) const;
|
||||||
bool has_animation(const StringName &p_name) const;
|
bool has_animation(const StringName &p_name) const;
|
||||||
|
|
||||||
void set_blend_time(const StringName &p_animation1, const StringName &p_animation2, float p_time);
|
void set_blend_time(const StringName &p_animation1, const StringName &p_animation2, double p_time);
|
||||||
float get_blend_time(const StringName &p_animation1, const StringName &p_animation2) const;
|
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);
|
void animation_set_next(const StringName &p_animation, const StringName &p_next);
|
||||||
StringName animation_get_next(const StringName &p_animation) const;
|
StringName animation_get_next(const StringName &p_animation) const;
|
||||||
|
|
||||||
void set_default_blend_time(float p_default);
|
void set_default_blend_time(double p_default);
|
||||||
float get_default_blend_time() const;
|
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(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(), float p_custom_blend = -1);
|
void play_backwards(const StringName &p_name = StringName(), double p_custom_blend = -1);
|
||||||
void queue(const StringName &p_name);
|
void queue(const StringName &p_name);
|
||||||
Vector<String> get_queue();
|
Vector<String> get_queue();
|
||||||
void clear_queue();
|
void clear_queue();
|
||||||
@ -378,11 +378,11 @@ public:
|
|||||||
bool is_movie_quit_on_finish_enabled() const;
|
bool is_movie_quit_on_finish_enabled() const;
|
||||||
|
|
||||||
void seek(double p_time, bool p_update = false);
|
void seek(double p_time, bool p_update = false);
|
||||||
void seek_delta(double p_time, float p_delta);
|
void seek_delta(double p_time, double p_delta);
|
||||||
float get_current_animation_position() const;
|
double get_current_animation_position() const;
|
||||||
float get_current_animation_length() const;
|
double get_current_animation_length() const;
|
||||||
|
|
||||||
void advance(float p_time);
|
void advance(double p_time);
|
||||||
|
|
||||||
void set_root(const NodePath &p_root);
|
void set_root(const NodePath &p_root);
|
||||||
NodePath get_root() const;
|
NodePath get_root() const;
|
||||||
|
@ -1745,7 +1745,7 @@ Variant AnimationTree::_post_process_key_value(const Ref<Animation> &p_anim, int
|
|||||||
return p_value;
|
return p_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationTree::advance(real_t p_time) {
|
void AnimationTree::advance(double p_time) {
|
||||||
_process_graph(p_time);
|
_process_graph(p_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,7 +353,7 @@ public:
|
|||||||
Transform3D get_root_motion_transform() const;
|
Transform3D get_root_motion_transform() const;
|
||||||
|
|
||||||
real_t get_connection_activity(const StringName &p_path, int p_connection) 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);
|
void rename_parameter(const String &p_base, const String &p_new_base);
|
||||||
|
|
||||||
|
@ -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_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(!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.");
|
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();
|
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()) {
|
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) {
|
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) {
|
} else if (property_type == Variant::INT && p_to.get_type() == Variant::FLOAT) {
|
||||||
p_to = int(p_to);
|
p_to = int(p_to);
|
||||||
} else {
|
} else {
|
||||||
@ -93,7 +93,7 @@ Ref<PropertyTweener> Tween::tween_property(Object *p_target, NodePath p_property
|
|||||||
return tweener;
|
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(!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.");
|
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;
|
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(!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.");
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Tween::custom_step(float p_delta) {
|
bool Tween::custom_step(double p_delta) {
|
||||||
bool r = running;
|
bool r = running;
|
||||||
running = true;
|
running = true;
|
||||||
bool ret = step(p_delta);
|
bool ret = step(p_delta);
|
||||||
@ -253,7 +253,7 @@ bool Tween::custom_step(float p_delta) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Tween::step(float p_delta) {
|
bool Tween::step(double p_delta) {
|
||||||
if (dead) {
|
if (dead) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -282,22 +282,22 @@ bool Tween::step(float p_delta) {
|
|||||||
started = true;
|
started = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
float rem_delta = p_delta * speed_scale;
|
double rem_delta = p_delta * speed_scale;
|
||||||
bool step_active = false;
|
bool step_active = false;
|
||||||
total_time += rem_delta;
|
total_time += rem_delta;
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
float initial_delta = rem_delta;
|
double initial_delta = rem_delta;
|
||||||
bool potential_infinite = false;
|
bool potential_infinite = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
while (rem_delta > 0 && running) {
|
while (rem_delta > 0 && running) {
|
||||||
float step_delta = rem_delta;
|
double step_delta = rem_delta;
|
||||||
step_active = false;
|
step_active = false;
|
||||||
|
|
||||||
for (Ref<Tweener> &tweener : tweeners.write[current_step]) {
|
for (Ref<Tweener> &tweener : tweeners.write[current_step]) {
|
||||||
// Modified inside Tweener.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).
|
// Turns to true if any Tweener returns true (i.e. is still not finished).
|
||||||
step_active = tweener->step(temp_delta) || step_active;
|
step_active = tweener->step(temp_delta) || step_active;
|
||||||
step_delta = MIN(temp_delta, step_delta);
|
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;
|
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);
|
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_trans, TransitionType::TRANS_MAX, Variant());
|
||||||
ERR_FAIL_INDEX_V(p_ease, EaseType::EASE_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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<PropertyTweener> PropertyTweener::set_delay(float p_delay) {
|
Ref<PropertyTweener> PropertyTweener::set_delay(double p_delay) {
|
||||||
delay = p_delay;
|
delay = p_delay;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -506,7 +506,7 @@ void PropertyTweener::start() {
|
|||||||
delta_val = Animation::subtract_variant(final_val, initial_val);
|
delta_val = Animation::subtract_variant(final_val, initial_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PropertyTweener::step(float &r_delta) {
|
bool PropertyTweener::step(double &r_delta) {
|
||||||
if (finished) {
|
if (finished) {
|
||||||
// This is needed in case there's a parallel Tweener with longer duration.
|
// This is needed in case there's a parallel Tweener with longer duration.
|
||||||
return false;
|
return false;
|
||||||
@ -523,7 +523,7 @@ bool PropertyTweener::step(float &r_delta) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
float time = MIN(elapsed_time - delay, duration);
|
double time = MIN(elapsed_time - delay, duration);
|
||||||
if (time < duration) {
|
if (time < duration) {
|
||||||
target_instance->set_indexed(property, tween->interpolate_variant(initial_val, delta_val, time, duration, trans_type, ease_type));
|
target_instance->set_indexed(property, tween->interpolate_variant(initial_val, delta_val, time, duration, trans_type, ease_type));
|
||||||
r_delta = 0;
|
r_delta = 0;
|
||||||
@ -556,7 +556,7 @@ void PropertyTweener::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("set_delay", "delay"), &PropertyTweener::set_delay);
|
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();
|
target = p_target->get_instance_id();
|
||||||
property = p_property.get_as_property_path().get_subnames();
|
property = p_property.get_as_property_path().get_subnames();
|
||||||
initial_val = p_target->get_indexed(property);
|
initial_val = p_target->get_indexed(property);
|
||||||
@ -574,7 +574,7 @@ void IntervalTweener::start() {
|
|||||||
finished = false;
|
finished = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IntervalTweener::step(float &r_delta) {
|
bool IntervalTweener::step(double &r_delta) {
|
||||||
if (finished) {
|
if (finished) {
|
||||||
return false;
|
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;
|
duration = p_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -600,7 +600,7 @@ IntervalTweener::IntervalTweener() {
|
|||||||
ERR_FAIL_MSG("Can't create empty IntervalTweener. Use get_tree().tween_interval() instead.");
|
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;
|
delay = p_delay;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -610,7 +610,7 @@ void CallbackTweener::start() {
|
|||||||
finished = false;
|
finished = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CallbackTweener::step(float &r_delta) {
|
bool CallbackTweener::step(double &r_delta) {
|
||||||
if (finished) {
|
if (finished) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -646,7 +646,7 @@ CallbackTweener::CallbackTweener() {
|
|||||||
ERR_FAIL_MSG("Can't create empty CallbackTweener. Use get_tree().tween_callback() instead.");
|
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;
|
delay = p_delay;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -666,7 +666,7 @@ void MethodTweener::start() {
|
|||||||
finished = false;
|
finished = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MethodTweener::step(float &r_delta) {
|
bool MethodTweener::step(double &r_delta) {
|
||||||
if (finished) {
|
if (finished) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -679,7 +679,7 @@ bool MethodTweener::step(float &r_delta) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Variant current_val;
|
Variant current_val;
|
||||||
float time = MIN(elapsed_time - delay, duration);
|
double time = MIN(elapsed_time - delay, duration);
|
||||||
if (time < duration) {
|
if (time < duration) {
|
||||||
current_val = tween->interpolate_variant(initial_val, delta_val, time, duration, trans_type, ease_type);
|
current_val = tween->interpolate_variant(initial_val, delta_val, time, duration, trans_type, ease_type);
|
||||||
} else {
|
} else {
|
||||||
@ -722,7 +722,7 @@ void MethodTweener::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("set_ease", "ease"), &MethodTweener::set_ease);
|
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;
|
callback = p_callback;
|
||||||
initial_val = p_from;
|
initial_val = p_from;
|
||||||
delta_val = Animation::subtract_variant(p_to, p_from);
|
delta_val = Animation::subtract_variant(p_to, p_from);
|
||||||
|
@ -42,13 +42,13 @@ class Tweener : public RefCounted {
|
|||||||
public:
|
public:
|
||||||
virtual void set_tween(Ref<Tween> p_tween);
|
virtual void set_tween(Ref<Tween> p_tween);
|
||||||
virtual void start() = 0;
|
virtual void start() = 0;
|
||||||
virtual bool step(float &r_delta) = 0;
|
virtual bool step(double &r_delta) = 0;
|
||||||
void clear_tween();
|
void clear_tween();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
Ref<Tween> tween;
|
Ref<Tween> tween;
|
||||||
float elapsed_time = 0;
|
double elapsed_time = 0;
|
||||||
bool finished = false;
|
bool finished = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ private:
|
|||||||
ObjectID bound_node;
|
ObjectID bound_node;
|
||||||
|
|
||||||
Vector<List<Ref<Tweener>>> tweeners;
|
Vector<List<Ref<Tweener>>> tweeners;
|
||||||
float total_time = 0;
|
double total_time = 0;
|
||||||
int current_step = -1;
|
int current_step = -1;
|
||||||
int loops = 1;
|
int loops = 1;
|
||||||
int loops_done = 0;
|
int loops_done = 0;
|
||||||
@ -129,13 +129,13 @@ protected:
|
|||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Ref<PropertyTweener> tween_property(Object *p_target, NodePath p_property, Variant p_to, float p_duration);
|
Ref<PropertyTweener> tween_property(Object *p_target, NodePath p_property, Variant p_to, double p_duration);
|
||||||
Ref<IntervalTweener> tween_interval(float p_time);
|
Ref<IntervalTweener> tween_interval(double p_time);
|
||||||
Ref<CallbackTweener> tween_callback(Callable p_callback);
|
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);
|
void append(Ref<Tweener> p_tweener);
|
||||||
|
|
||||||
bool custom_step(float p_delta);
|
bool custom_step(double p_delta);
|
||||||
void stop();
|
void stop();
|
||||||
void pause();
|
void pause();
|
||||||
void play();
|
void play();
|
||||||
@ -163,12 +163,12 @@ public:
|
|||||||
Ref<Tween> chain();
|
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 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;
|
bool can_process(bool p_tree_paused) const;
|
||||||
Node *get_bound_node() const;
|
Node *get_bound_node() const;
|
||||||
float get_total_time() const;
|
double get_total_time() const;
|
||||||
|
|
||||||
Tween();
|
Tween();
|
||||||
Tween(bool p_valid);
|
Tween(bool p_valid);
|
||||||
@ -188,13 +188,13 @@ public:
|
|||||||
Ref<PropertyTweener> as_relative();
|
Ref<PropertyTweener> as_relative();
|
||||||
Ref<PropertyTweener> set_trans(Tween::TransitionType p_trans);
|
Ref<PropertyTweener> set_trans(Tween::TransitionType p_trans);
|
||||||
Ref<PropertyTweener> set_ease(Tween::EaseType p_ease);
|
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 set_tween(Ref<Tween> p_tween) override;
|
||||||
void start() 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();
|
PropertyTweener();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -208,11 +208,11 @@ private:
|
|||||||
Variant final_val;
|
Variant final_val;
|
||||||
Variant delta_val;
|
Variant delta_val;
|
||||||
|
|
||||||
float duration = 0;
|
double duration = 0;
|
||||||
Tween::TransitionType trans_type = Tween::TRANS_MAX; // This is set inside set_tween();
|
Tween::TransitionType trans_type = Tween::TRANS_MAX; // This is set inside set_tween();
|
||||||
Tween::EaseType ease_type = Tween::EASE_MAX;
|
Tween::EaseType ease_type = Tween::EASE_MAX;
|
||||||
|
|
||||||
float delay = 0;
|
double delay = 0;
|
||||||
bool do_continue = true;
|
bool do_continue = true;
|
||||||
bool relative = false;
|
bool relative = false;
|
||||||
};
|
};
|
||||||
@ -222,23 +222,23 @@ class IntervalTweener : public Tweener {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
void start() override;
|
void start() override;
|
||||||
bool step(float &r_delta) override;
|
bool step(double &r_delta) override;
|
||||||
|
|
||||||
IntervalTweener(float p_time);
|
IntervalTweener(double p_time);
|
||||||
IntervalTweener();
|
IntervalTweener();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float duration = 0;
|
double duration = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CallbackTweener : public Tweener {
|
class CallbackTweener : public Tweener {
|
||||||
GDCLASS(CallbackTweener, Tweener);
|
GDCLASS(CallbackTweener, Tweener);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Ref<CallbackTweener> set_delay(float p_delay);
|
Ref<CallbackTweener> set_delay(double p_delay);
|
||||||
|
|
||||||
void start() override;
|
void start() override;
|
||||||
bool step(float &r_delta) override;
|
bool step(double &r_delta) override;
|
||||||
|
|
||||||
CallbackTweener(Callable p_callback);
|
CallbackTweener(Callable p_callback);
|
||||||
CallbackTweener();
|
CallbackTweener();
|
||||||
@ -248,7 +248,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Callable callback;
|
Callable callback;
|
||||||
float delay = 0;
|
double delay = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MethodTweener : public Tweener {
|
class MethodTweener : public Tweener {
|
||||||
@ -257,21 +257,21 @@ class MethodTweener : public Tweener {
|
|||||||
public:
|
public:
|
||||||
Ref<MethodTweener> set_trans(Tween::TransitionType p_trans);
|
Ref<MethodTweener> set_trans(Tween::TransitionType p_trans);
|
||||||
Ref<MethodTweener> set_ease(Tween::EaseType p_ease);
|
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 set_tween(Ref<Tween> p_tween) override;
|
||||||
void start() 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();
|
MethodTweener();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float duration = 0;
|
double duration = 0;
|
||||||
float delay = 0;
|
double delay = 0;
|
||||||
Tween::TransitionType trans_type = Tween::TRANS_MAX;
|
Tween::TransitionType trans_type = Tween::TRANS_MAX;
|
||||||
Tween::EaseType ease_type = Tween::EASE_MAX;
|
Tween::EaseType ease_type = Tween::EASE_MAX;
|
||||||
|
|
||||||
|
@ -381,14 +381,14 @@ String VideoStreamPlayer::get_stream_name() const {
|
|||||||
return stream->get_name();
|
return stream->get_name();
|
||||||
}
|
}
|
||||||
|
|
||||||
float VideoStreamPlayer::get_stream_position() const {
|
double VideoStreamPlayer::get_stream_position() const {
|
||||||
if (playback.is_null()) {
|
if (playback.is_null()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return playback->get_playback_position();
|
return playback->get_playback_position();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoStreamPlayer::set_stream_position(float p_position) {
|
void VideoStreamPlayer::set_stream_position(double p_position) {
|
||||||
if (playback.is_valid()) {
|
if (playback.is_valid()) {
|
||||||
playback->seek(p_position);
|
playback->seek(p_position);
|
||||||
}
|
}
|
||||||
|
@ -105,8 +105,8 @@ public:
|
|||||||
float get_volume_db() const;
|
float get_volume_db() const;
|
||||||
|
|
||||||
String get_stream_name() const;
|
String get_stream_name() const;
|
||||||
float get_stream_position() const;
|
double get_stream_position() const;
|
||||||
void set_stream_position(float p_position);
|
void set_stream_position(double p_position);
|
||||||
|
|
||||||
void set_autoplay(bool p_enable);
|
void set_autoplay(bool p_enable);
|
||||||
bool has_autoplay() const;
|
bool has_autoplay() const;
|
||||||
|
@ -510,7 +510,7 @@ bool SceneTree::process(double p_time) {
|
|||||||
return _quit;
|
return _quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneTree::process_timers(float p_delta, bool p_physics_frame) {
|
void SceneTree::process_timers(double p_delta, bool p_physics_frame) {
|
||||||
List<Ref<SceneTreeTimer>>::Element *L = timers.back(); //last element
|
List<Ref<SceneTreeTimer>>::Element *L = timers.back(); //last element
|
||||||
|
|
||||||
for (List<Ref<SceneTreeTimer>>::Element *E = timers.front(); E;) {
|
for (List<Ref<SceneTreeTimer>>::Element *E = timers.front(); E;) {
|
||||||
@ -542,7 +542,7 @@ void SceneTree::process_timers(float p_delta, bool p_physics_frame) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneTree::process_tweens(float p_delta, bool p_physics) {
|
void SceneTree::process_tweens(double p_delta, bool p_physics) {
|
||||||
// This methods works similarly to how SceneTreeTimers are handled.
|
// This methods works similarly to how SceneTreeTimers are handled.
|
||||||
List<Ref<Tween>>::Element *L = tweens.back();
|
List<Ref<Tween>>::Element *L = tweens.back();
|
||||||
|
|
||||||
|
@ -180,8 +180,8 @@ private:
|
|||||||
void node_added(Node *p_node);
|
void node_added(Node *p_node);
|
||||||
void node_removed(Node *p_node);
|
void node_removed(Node *p_node);
|
||||||
void node_renamed(Node *p_node);
|
void node_renamed(Node *p_node);
|
||||||
void process_timers(float p_delta, bool p_physics_frame);
|
void process_timers(double p_delta, bool p_physics_frame);
|
||||||
void process_tweens(float p_delta, bool p_physics_frame);
|
void process_tweens(double p_delta, bool p_physics_frame);
|
||||||
|
|
||||||
Group *add_to_group(const StringName &p_group, Node *p_node);
|
Group *add_to_group(const StringName &p_group, Node *p_node);
|
||||||
void remove_from_group(const StringName &p_group, Node *p_node);
|
void remove_from_group(const StringName &p_group, Node *p_node);
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#include "core/io/file_access.h"
|
#include "core/io/file_access.h"
|
||||||
#include "core/io/marshalls.h"
|
#include "core/io/marshalls.h"
|
||||||
|
|
||||||
void AudioStreamPlaybackWAV::start(float p_from_pos) {
|
void AudioStreamPlaybackWAV::start(double p_from_pos) {
|
||||||
if (base->format == AudioStreamWAV::FORMAT_IMA_ADPCM) {
|
if (base->format == AudioStreamWAV::FORMAT_IMA_ADPCM) {
|
||||||
//no seeking in IMA_ADPCM
|
//no seeking in IMA_ADPCM
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
@ -67,16 +67,16 @@ int AudioStreamPlaybackWAV::get_loop_count() const {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float AudioStreamPlaybackWAV::get_playback_position() const {
|
double AudioStreamPlaybackWAV::get_playback_position() const {
|
||||||
return float(offset >> MIX_FRAC_BITS) / base->mix_rate;
|
return float(offset >> MIX_FRAC_BITS) / base->mix_rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioStreamPlaybackWAV::seek(float p_time) {
|
void AudioStreamPlaybackWAV::seek(double p_time) {
|
||||||
if (base->format == AudioStreamWAV::FORMAT_IMA_ADPCM) {
|
if (base->format == AudioStreamWAV::FORMAT_IMA_ADPCM) {
|
||||||
return; //no seeking in ima-adpcm
|
return; //no seeking in ima-adpcm
|
||||||
}
|
}
|
||||||
|
|
||||||
float max = base->get_length();
|
double max = base->get_length();
|
||||||
if (p_time < 0) {
|
if (p_time < 0) {
|
||||||
p_time = 0;
|
p_time = 0;
|
||||||
} else if (p_time >= max) {
|
} else if (p_time >= max) {
|
||||||
@ -463,7 +463,7 @@ bool AudioStreamWAV::is_stereo() const {
|
|||||||
return stereo;
|
return stereo;
|
||||||
}
|
}
|
||||||
|
|
||||||
float AudioStreamWAV::get_length() const {
|
double AudioStreamWAV::get_length() const {
|
||||||
int len = data_bytes;
|
int len = data_bytes;
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case AudioStreamWAV::FORMAT_8_BITS:
|
case AudioStreamWAV::FORMAT_8_BITS:
|
||||||
@ -481,7 +481,7 @@ float AudioStreamWAV::get_length() const {
|
|||||||
len /= 2;
|
len /= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return float(len) / mix_rate;
|
return double(len) / mix_rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AudioStreamWAV::is_monophonic() const {
|
bool AudioStreamWAV::is_monophonic() const {
|
||||||
|
@ -64,14 +64,14 @@ class AudioStreamPlaybackWAV : public AudioStreamPlayback {
|
|||||||
void do_resample(const Depth *p_src, AudioFrame *p_dst, int64_t &offset, int32_t &increment, uint32_t amount, IMA_ADPCM_State *ima_adpcm);
|
void do_resample(const Depth *p_src, AudioFrame *p_dst, int64_t &offset, int32_t &increment, uint32_t amount, IMA_ADPCM_State *ima_adpcm);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void start(float p_from_pos = 0.0) override;
|
virtual void start(double p_from_pos = 0.0) override;
|
||||||
virtual void stop() override;
|
virtual void stop() override;
|
||||||
virtual bool is_playing() const override;
|
virtual bool is_playing() const override;
|
||||||
|
|
||||||
virtual int get_loop_count() const override; //times it looped
|
virtual int get_loop_count() const override; //times it looped
|
||||||
|
|
||||||
virtual float get_playback_position() const override;
|
virtual double get_playback_position() const override;
|
||||||
virtual void seek(float p_time) override;
|
virtual void seek(double p_time) override;
|
||||||
|
|
||||||
virtual int mix(AudioFrame *p_buffer, float p_rate_scale, int p_frames) override;
|
virtual int mix(AudioFrame *p_buffer, float p_rate_scale, int p_frames) override;
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ public:
|
|||||||
void set_stereo(bool p_enable);
|
void set_stereo(bool p_enable);
|
||||||
bool is_stereo() const;
|
bool is_stereo() const;
|
||||||
|
|
||||||
virtual float get_length() const override; //if supported, otherwise return 0
|
virtual double get_length() const override; //if supported, otherwise return 0
|
||||||
|
|
||||||
virtual bool is_monophonic() const override;
|
virtual bool is_monophonic() const override;
|
||||||
|
|
||||||
|
@ -50,16 +50,16 @@ public:
|
|||||||
virtual void set_loop(bool p_enable) = 0;
|
virtual void set_loop(bool p_enable) = 0;
|
||||||
virtual bool has_loop() const = 0;
|
virtual bool has_loop() const = 0;
|
||||||
|
|
||||||
virtual float get_length() const = 0;
|
virtual double get_length() const = 0;
|
||||||
|
|
||||||
virtual float get_playback_position() const = 0;
|
virtual double get_playback_position() const = 0;
|
||||||
virtual void seek(float p_time) = 0;
|
virtual void seek(double p_time) = 0;
|
||||||
|
|
||||||
virtual void set_audio_track(int p_idx) = 0;
|
virtual void set_audio_track(int p_idx) = 0;
|
||||||
|
|
||||||
virtual Ref<Texture2D> get_texture() const = 0;
|
virtual Ref<Texture2D> get_texture() const = 0;
|
||||||
|
|
||||||
virtual void update(float p_delta) = 0;
|
virtual void update(double p_delta) = 0;
|
||||||
|
|
||||||
virtual void set_mix_callback(AudioMixCallback p_callback, void *p_userdata) = 0;
|
virtual void set_mix_callback(AudioMixCallback p_callback, void *p_userdata) = 0;
|
||||||
virtual int get_channels() const = 0;
|
virtual int get_channels() const = 0;
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#include "core/config/project_settings.h"
|
#include "core/config/project_settings.h"
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
|
|
||||||
void AudioStreamPlayback::start(float p_from_pos) {
|
void AudioStreamPlayback::start(double p_from_pos) {
|
||||||
if (GDVIRTUAL_CALL(_start, p_from_pos)) {
|
if (GDVIRTUAL_CALL(_start, p_from_pos)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -61,14 +61,14 @@ int AudioStreamPlayback::get_loop_count() const {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float AudioStreamPlayback::get_playback_position() const {
|
double AudioStreamPlayback::get_playback_position() const {
|
||||||
float ret;
|
double ret;
|
||||||
if (GDVIRTUAL_CALL(_get_playback_position, ret)) {
|
if (GDVIRTUAL_CALL(_get_playback_position, ret)) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
ERR_FAIL_V_MSG(0, "AudioStreamPlayback::get_playback_position unimplemented!");
|
ERR_FAIL_V_MSG(0, "AudioStreamPlayback::get_playback_position unimplemented!");
|
||||||
}
|
}
|
||||||
void AudioStreamPlayback::seek(float p_time) {
|
void AudioStreamPlayback::seek(double p_time) {
|
||||||
if (GDVIRTUAL_CALL(_seek, p_time)) {
|
if (GDVIRTUAL_CALL(_seek, p_time)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -207,8 +207,8 @@ String AudioStream::get_stream_name() const {
|
|||||||
return String();
|
return String();
|
||||||
}
|
}
|
||||||
|
|
||||||
float AudioStream::get_length() const {
|
double AudioStream::get_length() const {
|
||||||
float ret;
|
double ret;
|
||||||
if (GDVIRTUAL_CALL(_get_length, ret)) {
|
if (GDVIRTUAL_CALL(_get_length, ret)) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -309,7 +309,7 @@ String AudioStreamMicrophone::get_stream_name() const {
|
|||||||
return "Microphone";
|
return "Microphone";
|
||||||
}
|
}
|
||||||
|
|
||||||
float AudioStreamMicrophone::get_length() const {
|
double AudioStreamMicrophone::get_length() const {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -382,7 +382,7 @@ float AudioStreamPlaybackMicrophone::get_stream_sampling_rate() {
|
|||||||
return AudioDriver::get_singleton()->get_mix_rate();
|
return AudioDriver::get_singleton()->get_mix_rate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioStreamPlaybackMicrophone::start(float p_from_pos) {
|
void AudioStreamPlaybackMicrophone::start(double p_from_pos) {
|
||||||
if (active) {
|
if (active) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -415,11 +415,11 @@ int AudioStreamPlaybackMicrophone::get_loop_count() const {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float AudioStreamPlaybackMicrophone::get_playback_position() const {
|
double AudioStreamPlaybackMicrophone::get_playback_position() const {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioStreamPlaybackMicrophone::seek(float p_time) {
|
void AudioStreamPlaybackMicrophone::seek(double p_time) {
|
||||||
// Can't seek a microphone input
|
// Can't seek a microphone input
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -664,7 +664,7 @@ String AudioStreamRandomizer::get_stream_name() const {
|
|||||||
return "Randomizer";
|
return "Randomizer";
|
||||||
}
|
}
|
||||||
|
|
||||||
float AudioStreamRandomizer::get_length() const {
|
double AudioStreamRandomizer::get_length() const {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -769,7 +769,7 @@ void AudioStreamRandomizer::_bind_methods() {
|
|||||||
|
|
||||||
AudioStreamRandomizer::AudioStreamRandomizer() {}
|
AudioStreamRandomizer::AudioStreamRandomizer() {}
|
||||||
|
|
||||||
void AudioStreamPlaybackRandomizer::start(float p_from_pos) {
|
void AudioStreamPlaybackRandomizer::start(double p_from_pos) {
|
||||||
playing = playback;
|
playing = playback;
|
||||||
{
|
{
|
||||||
float range_from = 1.0 / randomizer->random_pitch_scale;
|
float range_from = 1.0 / randomizer->random_pitch_scale;
|
||||||
@ -812,7 +812,7 @@ int AudioStreamPlaybackRandomizer::get_loop_count() const {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float AudioStreamPlaybackRandomizer::get_playback_position() const {
|
double AudioStreamPlaybackRandomizer::get_playback_position() const {
|
||||||
if (playing.is_valid()) {
|
if (playing.is_valid()) {
|
||||||
return playing->get_playback_position();
|
return playing->get_playback_position();
|
||||||
}
|
}
|
||||||
@ -820,7 +820,7 @@ float AudioStreamPlaybackRandomizer::get_playback_position() const {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioStreamPlaybackRandomizer::seek(float p_time) {
|
void AudioStreamPlaybackRandomizer::seek(double p_time) {
|
||||||
if (playing.is_valid()) {
|
if (playing.is_valid()) {
|
||||||
playing->seek(p_time);
|
playing->seek(p_time);
|
||||||
}
|
}
|
||||||
|
@ -47,23 +47,23 @@ class AudioStreamPlayback : public RefCounted {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
GDVIRTUAL1(_start, float)
|
GDVIRTUAL1(_start, double)
|
||||||
GDVIRTUAL0(_stop)
|
GDVIRTUAL0(_stop)
|
||||||
GDVIRTUAL0RC(bool, _is_playing)
|
GDVIRTUAL0RC(bool, _is_playing)
|
||||||
GDVIRTUAL0RC(int, _get_loop_count)
|
GDVIRTUAL0RC(int, _get_loop_count)
|
||||||
GDVIRTUAL0RC(float, _get_playback_position)
|
GDVIRTUAL0RC(double, _get_playback_position)
|
||||||
GDVIRTUAL1(_seek, float)
|
GDVIRTUAL1(_seek, double)
|
||||||
GDVIRTUAL3R(int, _mix, GDNativePtr<AudioFrame>, float, int)
|
GDVIRTUAL3R(int, _mix, GDNativePtr<AudioFrame>, float, int)
|
||||||
GDVIRTUAL0(_tag_used_streams)
|
GDVIRTUAL0(_tag_used_streams)
|
||||||
public:
|
public:
|
||||||
virtual void start(float p_from_pos = 0.0);
|
virtual void start(double p_from_pos = 0.0);
|
||||||
virtual void stop();
|
virtual void stop();
|
||||||
virtual bool is_playing() const;
|
virtual bool is_playing() const;
|
||||||
|
|
||||||
virtual int get_loop_count() const; //times it looped
|
virtual int get_loop_count() const; //times it looped
|
||||||
|
|
||||||
virtual float get_playback_position() const;
|
virtual double get_playback_position() const;
|
||||||
virtual void seek(float p_time);
|
virtual void seek(double p_time);
|
||||||
|
|
||||||
virtual void tag_used_streams();
|
virtual void tag_used_streams();
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ protected:
|
|||||||
|
|
||||||
GDVIRTUAL0RC(Ref<AudioStreamPlayback>, _instantiate_playback)
|
GDVIRTUAL0RC(Ref<AudioStreamPlayback>, _instantiate_playback)
|
||||||
GDVIRTUAL0RC(String, _get_stream_name)
|
GDVIRTUAL0RC(String, _get_stream_name)
|
||||||
GDVIRTUAL0RC(float, _get_length)
|
GDVIRTUAL0RC(double, _get_length)
|
||||||
GDVIRTUAL0RC(bool, _is_monophonic)
|
GDVIRTUAL0RC(bool, _is_monophonic)
|
||||||
GDVIRTUAL0RC(double, _get_bpm)
|
GDVIRTUAL0RC(double, _get_bpm)
|
||||||
GDVIRTUAL0RC(bool, _has_loop)
|
GDVIRTUAL0RC(bool, _has_loop)
|
||||||
@ -135,7 +135,7 @@ public:
|
|||||||
virtual int get_bar_beats() const;
|
virtual int get_bar_beats() const;
|
||||||
virtual int get_beat_count() const;
|
virtual int get_beat_count() const;
|
||||||
|
|
||||||
virtual float get_length() const;
|
virtual double get_length() const;
|
||||||
virtual bool is_monophonic() const;
|
virtual bool is_monophonic() const;
|
||||||
|
|
||||||
void tag_used(float p_offset);
|
void tag_used(float p_offset);
|
||||||
@ -161,7 +161,7 @@ public:
|
|||||||
virtual Ref<AudioStreamPlayback> instantiate_playback() override;
|
virtual Ref<AudioStreamPlayback> instantiate_playback() override;
|
||||||
virtual String get_stream_name() const override;
|
virtual String get_stream_name() const override;
|
||||||
|
|
||||||
virtual float get_length() const override; //if supported, otherwise return 0
|
virtual double get_length() const override; //if supported, otherwise return 0
|
||||||
|
|
||||||
virtual bool is_monophonic() const override;
|
virtual bool is_monophonic() const override;
|
||||||
|
|
||||||
@ -180,18 +180,18 @@ class AudioStreamPlaybackMicrophone : public AudioStreamPlaybackResampled {
|
|||||||
protected:
|
protected:
|
||||||
virtual int _mix_internal(AudioFrame *p_buffer, int p_frames) override;
|
virtual int _mix_internal(AudioFrame *p_buffer, int p_frames) override;
|
||||||
virtual float get_stream_sampling_rate() override;
|
virtual float get_stream_sampling_rate() override;
|
||||||
virtual float get_playback_position() const override;
|
virtual double get_playback_position() const override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual int mix(AudioFrame *p_buffer, float p_rate_scale, int p_frames) override;
|
virtual int mix(AudioFrame *p_buffer, float p_rate_scale, int p_frames) override;
|
||||||
|
|
||||||
virtual void start(float p_from_pos = 0.0) override;
|
virtual void start(double p_from_pos = 0.0) override;
|
||||||
virtual void stop() override;
|
virtual void stop() override;
|
||||||
virtual bool is_playing() const override;
|
virtual bool is_playing() const override;
|
||||||
|
|
||||||
virtual int get_loop_count() const override; //times it looped
|
virtual int get_loop_count() const override; //times it looped
|
||||||
|
|
||||||
virtual void seek(float p_time) override;
|
virtual void seek(double p_time) override;
|
||||||
|
|
||||||
virtual void tag_used_streams() override;
|
virtual void tag_used_streams() override;
|
||||||
|
|
||||||
@ -265,7 +265,7 @@ public:
|
|||||||
virtual Ref<AudioStreamPlayback> instantiate_playback() override;
|
virtual Ref<AudioStreamPlayback> instantiate_playback() override;
|
||||||
virtual String get_stream_name() const override;
|
virtual String get_stream_name() const override;
|
||||||
|
|
||||||
virtual float get_length() const override; //if supported, otherwise return 0
|
virtual double get_length() const override; //if supported, otherwise return 0
|
||||||
virtual bool is_monophonic() const override;
|
virtual bool is_monophonic() const override;
|
||||||
|
|
||||||
AudioStreamRandomizer();
|
AudioStreamRandomizer();
|
||||||
@ -283,14 +283,14 @@ class AudioStreamPlaybackRandomizer : public AudioStreamPlayback {
|
|||||||
float volume_scale;
|
float volume_scale;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void start(float p_from_pos = 0.0) override;
|
virtual void start(double p_from_pos = 0.0) override;
|
||||||
virtual void stop() override;
|
virtual void stop() override;
|
||||||
virtual bool is_playing() const override;
|
virtual bool is_playing() const override;
|
||||||
|
|
||||||
virtual int get_loop_count() const override; //times it looped
|
virtual int get_loop_count() const override; //times it looped
|
||||||
|
|
||||||
virtual float get_playback_position() const override;
|
virtual double get_playback_position() const override;
|
||||||
virtual void seek(float p_time) override;
|
virtual void seek(double p_time) override;
|
||||||
|
|
||||||
virtual int mix(AudioFrame *p_buffer, float p_rate_scale, int p_frames) override;
|
virtual int mix(AudioFrame *p_buffer, float p_rate_scale, int p_frames) override;
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ String AudioStreamGenerator::get_stream_name() const {
|
|||||||
return "UserFeed";
|
return "UserFeed";
|
||||||
}
|
}
|
||||||
|
|
||||||
float AudioStreamGenerator::get_length() const {
|
double AudioStreamGenerator::get_length() const {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ float AudioStreamGeneratorPlayback::get_stream_sampling_rate() {
|
|||||||
return generator->get_mix_rate();
|
return generator->get_mix_rate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioStreamGeneratorPlayback::start(float p_from_pos) {
|
void AudioStreamGeneratorPlayback::start(double p_from_pos) {
|
||||||
if (mixed == 0.0) {
|
if (mixed == 0.0) {
|
||||||
begin_resample();
|
begin_resample();
|
||||||
}
|
}
|
||||||
@ -188,11 +188,11 @@ int AudioStreamGeneratorPlayback::get_loop_count() const {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float AudioStreamGeneratorPlayback::get_playback_position() const {
|
double AudioStreamGeneratorPlayback::get_playback_position() const {
|
||||||
return mixed;
|
return mixed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioStreamGeneratorPlayback::seek(float p_time) {
|
void AudioStreamGeneratorPlayback::seek(double p_time) {
|
||||||
//no seek possible
|
//no seek possible
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ public:
|
|||||||
virtual Ref<AudioStreamPlayback> instantiate_playback() override;
|
virtual Ref<AudioStreamPlayback> instantiate_playback() override;
|
||||||
virtual String get_stream_name() const override;
|
virtual String get_stream_name() const override;
|
||||||
|
|
||||||
virtual float get_length() const override;
|
virtual double get_length() const override;
|
||||||
virtual bool is_monophonic() const override;
|
virtual bool is_monophonic() const override;
|
||||||
AudioStreamGenerator();
|
AudioStreamGenerator();
|
||||||
};
|
};
|
||||||
@ -74,14 +74,14 @@ protected:
|
|||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void start(float p_from_pos = 0.0) override;
|
virtual void start(double p_from_pos = 0.0) override;
|
||||||
virtual void stop() override;
|
virtual void stop() override;
|
||||||
virtual bool is_playing() const override;
|
virtual bool is_playing() const override;
|
||||||
|
|
||||||
virtual int get_loop_count() const override; //times it looped
|
virtual int get_loop_count() const override; //times it looped
|
||||||
|
|
||||||
virtual float get_playback_position() const override;
|
virtual double get_playback_position() const override;
|
||||||
virtual void seek(float p_time) override;
|
virtual void seek(double p_time) override;
|
||||||
|
|
||||||
bool push_frame(const Vector2 &p_frame);
|
bool push_frame(const Vector2 &p_frame);
|
||||||
bool can_push_buffer(int p_frames) const;
|
bool can_push_buffer(int p_frames) const;
|
||||||
|
@ -138,7 +138,7 @@ void run_test(String file_name, AudioStreamWAV::Format data_format, bool stereo,
|
|||||||
CHECK(stream->get_data() == test_data);
|
CHECK(stream->get_data() == test_data);
|
||||||
|
|
||||||
SUBCASE("Stream length is computed properly") {
|
SUBCASE("Stream length is computed properly") {
|
||||||
CHECK(Math::is_equal_approx(stream->get_length(), wav_count / wav_rate));
|
CHECK(Math::is_equal_approx(stream->get_length(), double(wav_count / wav_rate)));
|
||||||
}
|
}
|
||||||
|
|
||||||
SUBCASE("Stream can be saved as .wav") {
|
SUBCASE("Stream can be saved as .wav") {
|
||||||
|
Loading…
Reference in New Issue
Block a user