Implement blending audio feature to AnimationTree
This commit is contained in:
@ -37,6 +37,7 @@
|
||||
#include "scene/3d/skeleton_3d.h"
|
||||
#include "scene/resources/animation.h"
|
||||
#include "scene/resources/animation_library.h"
|
||||
#include "scene/resources/audio_stream_polyphonic.h"
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
class AnimatedValuesBackup : public RefCounted {
|
||||
@ -147,6 +148,26 @@ private:
|
||||
|
||||
HashMap<StringName, BezierAnim> bezier_anim;
|
||||
|
||||
struct PlayingAudioStreamInfo {
|
||||
int64_t index = -1;
|
||||
double start = 0.0;
|
||||
double len = 0.0;
|
||||
};
|
||||
|
||||
struct AudioAnim {
|
||||
Ref<AudioStreamPolyphonic> audio_stream;
|
||||
Ref<AudioStreamPlaybackPolyphonic> audio_stream_playback;
|
||||
HashMap<int, PlayingAudioStreamInfo> playing_streams;
|
||||
Object *object = nullptr;
|
||||
uint64_t accum_pass = 0;
|
||||
double length = 0.0;
|
||||
double time = 0.0;
|
||||
bool loop = false;
|
||||
bool backward = false;
|
||||
};
|
||||
|
||||
HashMap<StringName, AudioAnim> audio_anim;
|
||||
|
||||
uint32_t last_setup_pass = 0;
|
||||
TrackNodeCache() {}
|
||||
};
|
||||
@ -187,7 +208,10 @@ private:
|
||||
int cache_update_prop_size = 0;
|
||||
TrackNodeCache::BezierAnim *cache_update_bezier[NODE_CACHE_UPDATE_MAX];
|
||||
int cache_update_bezier_size = 0;
|
||||
TrackNodeCache::AudioAnim *cache_update_audio[NODE_CACHE_UPDATE_MAX];
|
||||
int cache_update_audio_size = 0;
|
||||
HashSet<TrackNodeCache *> playing_caches;
|
||||
Vector<Node *> playing_audio_stream_players;
|
||||
|
||||
uint64_t accum_pass = 1;
|
||||
float speed_scale = 1.0;
|
||||
@ -263,6 +287,7 @@ private:
|
||||
bool reset_on_save = true;
|
||||
AnimationProcessCallback process_callback = ANIMATION_PROCESS_IDLE;
|
||||
AnimationMethodCallMode method_call_mode = ANIMATION_METHOD_CALL_DEFERRED;
|
||||
int audio_max_polyphony = 32;
|
||||
bool movie_quit_on_finish = false;
|
||||
bool processing = false;
|
||||
bool active = true;
|
||||
@ -278,6 +303,7 @@ private:
|
||||
void _animation_process(double p_delta);
|
||||
|
||||
void _node_removed(Node *p_node);
|
||||
void _clear_audio_streams();
|
||||
void _stop_playing_caches(bool p_reset);
|
||||
|
||||
// bind helpers
|
||||
@ -377,6 +403,9 @@ public:
|
||||
void set_method_call_mode(AnimationMethodCallMode p_mode);
|
||||
AnimationMethodCallMode get_method_call_mode() const;
|
||||
|
||||
void set_audio_max_polyphony(int p_audio_max_polyphony);
|
||||
int get_audio_max_polyphony() const;
|
||||
|
||||
void set_movie_quit_on_finish_enabled(bool p_enabled);
|
||||
bool is_movie_quit_on_finish_enabled() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user