diff --git a/scene/audio/stream_player.cpp b/scene/audio/stream_player.cpp index 4cfca0492a9..004c20bc359 100644 --- a/scene/audio/stream_player.cpp +++ b/scene/audio/stream_player.cpp @@ -67,7 +67,7 @@ bool StreamPlayer::sp_mix(int32_t *p_buffer,int p_frames) { void StreamPlayer::sp_update() { - //_THREAD_SAFE_METHOD_ + _THREAD_SAFE_METHOD_ if (!paused && resampler.is_ready() && playback.is_valid()) { if (!playback->is_playing()) { @@ -143,8 +143,6 @@ void StreamPlayer::play(float p_from_offset) { return; //if (is_playing()) stop(); - - //_THREAD_SAFE_METHOD_ playback->play(p_from_offset); //feed the ringbuffer as long as no update callback is going on sp_update(); @@ -162,8 +160,8 @@ void StreamPlayer::stop() { if (playback.is_null()) return; - //_THREAD_SAFE_METHOD_ AudioServer::get_singleton()->stream_set_active(stream_rid,false); + _THREAD_SAFE_METHOD_ playback->stop(); resampler.flush(); diff --git a/scene/audio/stream_player.h b/scene/audio/stream_player.h index be090f50e14..b5aa943067c 100644 --- a/scene/audio/stream_player.h +++ b/scene/audio/stream_player.h @@ -37,7 +37,7 @@ class StreamPlayer : public Node { OBJ_TYPE(StreamPlayer,Node); - //_THREAD_SAFE_CLASS_ + _THREAD_SAFE_CLASS_ struct InternalStream : public AudioServer::AudioStream { StreamPlayer *player; diff --git a/tools/editor/editor_import_export.cpp b/tools/editor/editor_import_export.cpp index b6c68d05be5..35f9375035f 100644 --- a/tools/editor/editor_import_export.cpp +++ b/tools/editor/editor_import_export.cpp @@ -1064,7 +1064,7 @@ Error EditorExportPlatform::save_pack_file(void *p_userdata,const String& p_path MD5Final(&ctx); pd->f->store_buffer(ctx.digest,16); } - pd->ep->step("Storing File: "+p_path,2+p_file*100/p_total); + pd->ep->step("Storing File: "+p_path,2+p_file*100/p_total,false); pd->count++; pd->ftmp->store_buffer(p_data.ptr(),p_data.size()); if (pd->alignment > 1) { @@ -1102,7 +1102,7 @@ Error EditorExportPlatform::save_zip_file(void *p_userdata,const String& p_path, zipWriteInFileInZip(zip,p_data.ptr(),p_data.size()); zipCloseFileInZip(zip); - zd->ep->step("Storing File: "+p_path,2+p_file*100/p_total); + zd->ep->step("Storing File: "+p_path,2+p_file*100/p_total,false); zd->count++; return OK; diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 6352a235f70..b30c875866f 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -4040,9 +4040,9 @@ void EditorNode::progress_add_task(const String& p_task,const String& p_label, i singleton->progress_dialog->add_task(p_task,p_label,p_steps); } -void EditorNode::progress_task_step(const String& p_task, const String& p_state, int p_step) { +void EditorNode::progress_task_step(const String& p_task, const String& p_state, int p_step,bool p_force_redraw) { - singleton->progress_dialog->task_step(p_task,p_state,p_step); + singleton->progress_dialog->task_step(p_task,p_state,p_step,p_force_redraw); } diff --git a/tools/editor/editor_node.h b/tools/editor/editor_node.h index 113d897eee1..0a087eb1eda 100644 --- a/tools/editor/editor_node.h +++ b/tools/editor/editor_node.h @@ -647,7 +647,7 @@ public: static void add_io_error(const String& p_error); static void progress_add_task(const String& p_task,const String& p_label, int p_steps); - static void progress_task_step(const String& p_task,const String& p_state, int p_step=-1); + static void progress_task_step(const String& p_task,const String& p_state, int p_step=-1,bool p_force_refresh=true); static void progress_end_task(const String& p_task); static void progress_add_task_bg(const String& p_task,const String& p_label, int p_steps); @@ -674,7 +674,7 @@ public: struct EditorProgress { String task; - void step(const String& p_state, int p_step=-1) { EditorNode::progress_task_step(task,p_state,p_step); } + void step(const String& p_state, int p_step=-1,bool p_force_refresh=true) { EditorNode::progress_task_step(task,p_state,p_step,p_force_refresh); } EditorProgress(const String& p_task,const String& p_label,int p_amount) { EditorNode::progress_add_task(p_task,p_label,p_amount); task=p_task; } ~EditorProgress() { EditorNode::progress_end_task(task); } }; diff --git a/tools/editor/io_plugins/editor_import_collada.cpp b/tools/editor/io_plugins/editor_import_collada.cpp index d57cff850e7..ffc2d057e35 100644 --- a/tools/editor/io_plugins/editor_import_collada.cpp +++ b/tools/editor/io_plugins/editor_import_collada.cpp @@ -68,6 +68,7 @@ struct ColladaImport { Map node_map; //map from collada node to engine node + Map node_name_map; //map from collada node to engine node Map > mesh_cache; Map > curve_cache; Map > material_cache; @@ -124,6 +125,7 @@ Error ColladaImport::_populate_skeleton(Skeleton *p_skeleton,Collada::Node *p_no nm.node=p_skeleton; nm.bone = r_bone; node_map[p_node->id]=nm; + node_name_map[p_node->name]=p_node->id; skeleton_bone_map[p_skeleton][joint->sid]=r_bone; @@ -345,6 +347,7 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) { NodeMap nm; nm.node=node; node_map[p_node->id]=nm; + node_name_map[p_node->name]=p_node->id; Transform xf = p_node->default_transform; xf = collada.fix_transform( xf ) * p_node->post_transform; @@ -1906,9 +1909,20 @@ void ColladaImport::create_animations(bool p_make_tracks_in_all_bones) { Collada::AnimationTrack &at = collada.state.animation_tracks[i]; //print_line("CHANNEL: "+at.target+" PARAM: "+at.param); + + String node; + if (!node_map.has(at.target)) { - print_line("Coudlnt find node: "+at.target); - continue; + + if (node_name_map.has(at.target)) { + + node=node_name_map[at.target]; + } else { + print_line("Coudlnt find node: "+at.target); + continue; + } + } else { + node=at.target; } @@ -1917,8 +1931,9 @@ void ColladaImport::create_animations(bool p_make_tracks_in_all_bones) { valid_animated_properties.push_back(i); } else { - node_map[at.target].anim_tracks.push_back(i); - valid_animated_nodes.insert(at.target); + + node_map[node].anim_tracks.push_back(i); + valid_animated_nodes.insert(node); } } @@ -1934,6 +1949,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones Ref animation = Ref( memnew( Animation )); + if (p_clip==-1) { //print_line("default"); @@ -2007,10 +2023,12 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones while(f=anim_length) { base_snapshots.push_back(anim_length); + } } @@ -2019,11 +2037,17 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones bool tracks_found=false; + + for(Set::Element* E=valid_animated_nodes.front();E;E=E->next()) { // take snapshots - if (!collada.state.scene_map.has(E->get())) + + + if (!collada.state.scene_map.has(E->get())) { + continue; + } NodeMap &nm = node_map[E->get()]; String path = scene->get_path_to(nm.node); @@ -2039,7 +2063,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones Collada::Node *cn = collada.state.scene_map[E->get()]; if (cn->ignore_anim) { - //print_line("warning, ignoring animation on node: "+path); + continue; } @@ -2058,20 +2082,23 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones for(int i=0;i::Element *ET=nm.anim_tracks.front();ET;ET=ET->next()) { //apply tracks + if (p_clip==-1) { - if (track_filter.has(ET->get())) + if (track_filter.has(ET->get())) { + continue; + } } else { if (!track_filter.has(ET->get())) diff --git a/tools/editor/progress_dialog.cpp b/tools/editor/progress_dialog.cpp index c8b87486c02..90398767ea7 100644 --- a/tools/editor/progress_dialog.cpp +++ b/tools/editor/progress_dialog.cpp @@ -29,7 +29,7 @@ #include "progress_dialog.h" #include "main/main.h" #include "message_queue.h" - +#include "os/os.h" void BackgroundProgress::_add_task(const String& p_task,const String& p_label, int p_steps) { @@ -191,10 +191,16 @@ void ProgressDialog::add_task(const String& p_task,const String& p_label,int p_s } -void ProgressDialog::task_step(const String& p_task, const String& p_state, int p_step){ +void ProgressDialog::task_step(const String& p_task, const String& p_state, int p_step,bool p_force_redraw){ ERR_FAIL_COND(!tasks.has(p_task)); + if (!p_force_redraw) { + uint64_t tus = OS::get_singleton()->get_ticks_usec(); + if (tus-last_progress_tick < 50000) //50ms + return; + } + Task &t=tasks[p_task]; if (p_step<0) t.progress->set_val(t.progress->get_val()+1); @@ -202,6 +208,7 @@ void ProgressDialog::task_step(const String& p_task, const String& p_state, int t.progress->set_val(p_step); t.state->set_text(p_state); + last_progress_tick=OS::get_singleton()->get_ticks_usec(); Main::iteration(); // this will not work on a lot of platforms, so it's only meant for the editor } @@ -229,4 +236,5 @@ ProgressDialog::ProgressDialog() { add_child(main); main->set_area_as_parent_rect(); set_exclusive(true); + last_progress_tick=0; } diff --git a/tools/editor/progress_dialog.h b/tools/editor/progress_dialog.h index 7f1cc4cb2d0..8c75948fda0 100644 --- a/tools/editor/progress_dialog.h +++ b/tools/editor/progress_dialog.h @@ -84,6 +84,7 @@ class ProgressDialog : public Popup { Map tasks; VBoxContainer *main; + uint64_t last_progress_tick; void _popup(); protected: @@ -92,7 +93,7 @@ protected: public: void add_task(const String& p_task,const String& p_label, int p_steps); - void task_step(const String& p_task,const String& p_state, int p_step=-1); + void task_step(const String& p_task, const String& p_state, int p_step=-1, bool p_force_redraw=true); void end_task(const String& p_task);