diff --git a/core/command_queue_mt.h b/core/command_queue_mt.h index 0985f3cfe72..113199869bc 100644 --- a/core/command_queue_mt.h +++ b/core/command_queue_mt.h @@ -34,6 +34,7 @@ #include "os/mutex.h" #include "os/memory.h" #include "simple_type.h" +#include "print_string.h" /** @author Juan Linietsky */ @@ -174,7 +175,7 @@ class CommandQueueMT { R* ret; SyncSemaphore *sync; - virtual void call() { *ret = (instance->*method)(p1); sync->sem->post(); sync->in_use=false; ; } + virtual void call() { *ret = (instance->*method)(p1); sync->sem->post(); print_line("post"); sync->in_use=false; ; } }; template @@ -675,6 +676,7 @@ public: if (sync) sync->post(); ss->sem->wait(); + print_line("wait"); } template diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 03b6c9759b3..22d89840ae5 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -214,6 +214,7 @@ RES ResourceLoader::load(const String &p_path,const String& p_type_hint,bool p_n Ref ResourceLoader::load_import_metadata(const String &p_path) { + String local_path; if (p_path.is_rel_path()) local_path="res://"+p_path; diff --git a/core/message_queue.cpp b/core/message_queue.cpp index cfbdb37b888..489939ee658 100644 --- a/core/message_queue.cpp +++ b/core/message_queue.cpp @@ -324,6 +324,7 @@ int MessageQueue::get_max_buffer_usage() const { void MessageQueue::flush() { + if (buffer_max_usedtype!=TYPE_NOTIFICATION) - read_pos+=sizeof(Variant)*message->args; + advance+=sizeof(Variant)*message->args; message->~Message(); - _THREAD_SAFE_UNLOCK_ + _THREAD_SAFE_LOCK_ + read_pos+=advance; } - _THREAD_SAFE_LOCK_ + buffer_end=0; // reset buffer _THREAD_SAFE_UNLOCK_ diff --git a/core/vector.h b/core/vector.h index 04018b9f788..b93d9a0deab 100644 --- a/core/vector.h +++ b/core/vector.h @@ -104,7 +104,7 @@ public: template - int find(T_val& p_val) const; + int find(const T_val& p_val) const; void set(int p_index,T p_elem); T get(int p_index) const; @@ -221,7 +221,7 @@ void Vector::_copy_on_write() { } template template -int Vector::find(T_val& p_val) const { +int Vector::find(const T_val &p_val) const { int ret = -1; if (size() == 0) diff --git a/main/main.cpp b/main/main.cpp index 2d5039b6586..a00538a6ae0 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1380,6 +1380,8 @@ bool Main::iteration() { SpatialSound2DServer::get_singleton()->update( step*time_scale ); + VisualServer::get_singleton()->sync(); //sync if still drawing from previous frames. + if (OS::get_singleton()->can_draw()) { if ((!force_redraw_requested) && OS::get_singleton()->is_in_low_processor_usage_mode()) { @@ -1392,8 +1394,6 @@ bool Main::iteration() { OS::get_singleton()->frames_drawn++; force_redraw_requested = false; } - } else { - VisualServer::get_singleton()->flush(); // flush visual commands } if (AudioServer::get_singleton()) diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 0c15f99509f..c497bc5363f 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -3601,6 +3601,10 @@ TextEdit::TextEdit() { set_focus_mode(FOCUS_ALL); _update_caches(); cache.size=Size2(1,1); + cache.row_height=1; + cache.line_spacing=1; + cache.line_number_w=1; + tab_size=4; text.set_tab_size(tab_size); text.clear(); diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp index 862669ecd8e..90598ee789e 100644 --- a/scene/resources/shader.cpp +++ b/scene/resources/shader.cpp @@ -36,7 +36,7 @@ Shader::Mode Shader::get_mode() const { - return (Mode)VisualServer::get_singleton()->shader_get_mode(shader); + return mode; } void Shader::set_code( const String& p_vertex, const String& p_fragment, const String& p_light,int p_fragment_ofs,int p_light_ofs) { @@ -203,6 +203,7 @@ void Shader::_bind_methods() { Shader::Shader(Mode p_mode) { + mode=p_mode; shader = VisualServer::get_singleton()->shader_create(VS::ShaderMode(p_mode)); params_cache_dirty=true; } diff --git a/scene/resources/shader.h b/scene/resources/shader.h index c5ef3777f7d..b805cbec96f 100644 --- a/scene/resources/shader.h +++ b/scene/resources/shader.h @@ -37,8 +37,18 @@ class Shader : public Resource { OBJ_TYPE(Shader,Resource); OBJ_SAVE_TYPE( Shader ); RES_BASE_EXTENSION("shd"); - RID shader; +public: + enum Mode { + + MODE_MATERIAL, + MODE_CANVAS_ITEM, + MODE_POST_PROCESS, + MODE_MAX + }; +private: + RID shader; + Mode mode; Dictionary _get_code(); void _set_code(const Dictionary& p_string); @@ -55,15 +65,10 @@ class Shader : public Resource { protected: + static void _bind_methods(); public: - enum Mode { - MODE_MATERIAL, - MODE_CANVAS_ITEM, - MODE_POST_PROCESS, - MODE_MAX - }; //void set_mode(Mode p_mode); Mode get_mode() const; diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp index a547da9b61b..52e5c21272f 100644 --- a/servers/visual/visual_server_raster.cpp +++ b/servers/visual/visual_server_raster.cpp @@ -7358,7 +7358,7 @@ void VisualServerRaster::_draw_cursors_and_margins() { rasterizer->canvas_end_rect(); }; -void VisualServerRaster::flush() { +void VisualServerRaster::sync() { //do none } diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index f3b94b73df8..e2940c216be 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -1237,7 +1237,7 @@ public: /* EVENT QUEUING */ virtual void draw(); - virtual void flush(); + virtual void sync(); virtual void init(); virtual void finish(); diff --git a/servers/visual/visual_server_wrap_mt.cpp b/servers/visual/visual_server_wrap_mt.cpp index 44a41a93da5..19dff3d36c7 100644 --- a/servers/visual/visual_server_wrap_mt.cpp +++ b/servers/visual/visual_server_wrap_mt.cpp @@ -96,16 +96,19 @@ void VisualServerWrapMT::thread_loop() { /* EVENT QUEUING */ -void VisualServerWrapMT::flush() { +void VisualServerWrapMT::sync() { if (create_thread) { + /* TODO: sync with the thread */ + + /* ERR_FAIL_COND(!draw_mutex); draw_mutex->lock(); draw_pending++; //cambiar por un saferefcount draw_mutex->unlock(); - - command_queue.push( this, &VisualServerWrapMT::thread_flush); + */ + //command_queue.push( this, &VisualServerWrapMT::thread_flush); } else { command_queue.flush_all(); //flush all pending from other threads @@ -118,15 +121,16 @@ void VisualServerWrapMT::draw() { if (create_thread) { + /* TODO: Make it draw ERR_FAIL_COND(!draw_mutex); draw_mutex->lock(); draw_pending++; //cambiar por un saferefcount draw_mutex->unlock(); command_queue.push( this, &VisualServerWrapMT::thread_draw); + */ } else { - command_queue.flush_all(); //flush all pending from other threads visual_server->draw(); } } diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index d07e1940d7f..6719342a6a6 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -681,7 +681,7 @@ public: virtual void init(); virtual void finish(); virtual void draw(); - virtual void flush(); + virtual void sync(); FUNC0RC(bool,has_changed); /* RENDER INFO */ diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index 78320f277e1..25e6a68469c 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -554,7 +554,7 @@ void VisualServer::_bind_methods() { ObjectTypeDB::bind_method(_MD("mesh_add_surface_from_planes"),&VisualServer::mesh_add_surface_from_planes); ObjectTypeDB::bind_method(_MD("draw"),&VisualServer::draw); - ObjectTypeDB::bind_method(_MD("flush"),&VisualServer::flush); + ObjectTypeDB::bind_method(_MD("sync"),&VisualServer::sync); ObjectTypeDB::bind_method(_MD("free"),&VisualServer::free); ObjectTypeDB::bind_method(_MD("set_default_clear_color"),&VisualServer::set_default_clear_color); diff --git a/servers/visual_server.h b/servers/visual_server.h index c1c2ef4fd3c..ef63907e345 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -1097,7 +1097,7 @@ public: /* EVENT QUEUING */ virtual void draw()=0; - virtual void flush()=0; + virtual void sync()=0; virtual bool has_changed() const=0; virtual void init()=0; virtual void finish()=0; diff --git a/tools/editor/editor_file_dialog.cpp b/tools/editor/editor_file_dialog.cpp index e3508e4493b..b1bbd71f7b3 100644 --- a/tools/editor/editor_file_dialog.cpp +++ b/tools/editor/editor_file_dialog.cpp @@ -348,7 +348,6 @@ void EditorFileDialog::_push_history() { } } - void EditorFileDialog::_item_dc_selected(int p_item) { @@ -672,7 +671,7 @@ void EditorFileDialog::set_current_dir(const String& p_dir) { dir_access->change_dir(p_dir); update_dir(); invalidate(); - _push_history(); + //_push_history(); } @@ -852,8 +851,8 @@ void EditorFileDialog::_favorite_move_up(){ if (current>0 && currentget_item_count()) { Vector favorited = EditorSettings::get_singleton()->get_favorite_dirs(); - int a_idx=favorited.find(favorites->get_item_metadata(current-1)); - int b_idx=favorited.find(favorites->get_item_metadata(current)); + int a_idx=favorited.find(String(favorites->get_item_metadata(current-1))); + int b_idx=favorited.find(String(favorites->get_item_metadata(current))); if (a_idx==-1 || b_idx==-1) return; @@ -873,8 +872,8 @@ void EditorFileDialog::_favorite_move_down(){ if (current>=0 && currentget_item_count()-1) { Vector favorited = EditorSettings::get_singleton()->get_favorite_dirs(); - int a_idx=favorited.find(favorites->get_item_metadata(current+1)); - int b_idx=favorited.find(favorites->get_item_metadata(current)); + int a_idx=favorited.find(String(favorites->get_item_metadata(current+1))); + int b_idx=favorited.find(String(favorites->get_item_metadata(current))); if (a_idx==-1 || b_idx==-1) return; @@ -1143,6 +1142,7 @@ EditorFileDialog::EditorFileDialog() { show_hidden_files=true; display_mode=DISPLAY_THUMBNAILS; + local_history_pos=0; VBoxContainer *vbc = memnew( VBoxContainer ); add_child(vbc); diff --git a/tools/editor/editor_resource_preview.cpp b/tools/editor/editor_resource_preview.cpp index 86f6661e8a8..f684b49a2cc 100644 --- a/tools/editor/editor_resource_preview.cpp +++ b/tools/editor/editor_resource_preview.cpp @@ -98,7 +98,7 @@ void EditorResourcePreview::_thread() { if (queue.size()) { - //print_line("pop from queue"); + QueueItem item = queue.front()->get(); queue.pop_front(); @@ -106,6 +106,7 @@ void EditorResourcePreview::_thread() { Ref texture; + //print_line("pop from queue "+item.path); uint64_t modtime = FileAccess::get_modified_time(item.path); int thumbnail_size = EditorSettings::get_singleton()->get("file_dialog/thumbnail_size"); @@ -206,7 +207,7 @@ void EditorResourcePreview::queue_resource_preview(const String& p_path, Object* } - //print_line("send to thread"); + //print_line("send to thread "+p_path); QueueItem item; item.function=p_receiver_func; item.id=p_receiver->get_instance_ID(); diff --git a/tools/editor/io_plugins/editor_texture_import_plugin.cpp b/tools/editor/io_plugins/editor_texture_import_plugin.cpp index a44eae4d3f7..4f7ec1839ab 100644 --- a/tools/editor/io_plugins/editor_texture_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_texture_import_plugin.cpp @@ -600,9 +600,9 @@ EditorTextureImportDialog::EditorTextureImportDialog(EditorTextureImportPlugin* file_select->set_access(EditorFileDialog::ACCESS_FILESYSTEM); add_child(file_select); if (!large) - file_select->set_mode(FileDialog::MODE_OPEN_FILES); + file_select->set_mode(EditorFileDialog::MODE_OPEN_FILES); else - file_select->set_mode(FileDialog::MODE_OPEN_FILE); + file_select->set_mode(EditorFileDialog::MODE_OPEN_FILE); file_select->connect("files_selected", this,"_choose_files"); file_select->connect("file_selected", this,"_choose_file"); diff --git a/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp b/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp index a533c6aa1e9..8eea7231269 100644 --- a/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp +++ b/tools/editor/plugins/collision_polygon_2d_editor_plugin.cpp @@ -380,6 +380,7 @@ void CollisionPolygon2DEditor::_bind_methods() { CollisionPolygon2DEditor::CollisionPolygon2DEditor(EditorNode *p_editor) { + node=NULL; canvas_item_editor=NULL; editor=p_editor; undo_redo = editor->get_undo_redo(); diff --git a/tools/editor/plugins/collision_polygon_editor_plugin.cpp b/tools/editor/plugins/collision_polygon_editor_plugin.cpp index de40727f1b0..381cfd74aba 100644 --- a/tools/editor/plugins/collision_polygon_editor_plugin.cpp +++ b/tools/editor/plugins/collision_polygon_editor_plugin.cpp @@ -533,6 +533,7 @@ void CollisionPolygonEditor::_bind_methods() { CollisionPolygonEditor::CollisionPolygonEditor(EditorNode *p_editor) { + node=NULL; editor=p_editor; undo_redo = editor->get_undo_redo(); diff --git a/tools/editor/plugins/editor_preview_plugins.cpp b/tools/editor/plugins/editor_preview_plugins.cpp index 9532c6b9e93..a77ba9a605d 100644 --- a/tools/editor/plugins/editor_preview_plugins.cpp +++ b/tools/editor/plugins/editor_preview_plugins.cpp @@ -63,14 +63,15 @@ EditorTexturePreviewPlugin::EditorTexturePreviewPlugin() { Ref EditorPackedScenePreviewPlugin::_gen_from_imd(Ref p_imd) { - if (p_imd.is_null()) + if (p_imd.is_null()) { return Ref(); + } if (!p_imd->has_option("thumbnail")) return Ref(); Variant tn = p_imd->get_option("thumbnail"); - print_line(Variant::get_type_name(tn.get_type())); + //print_line(Variant::get_type_name(tn.get_type())); DVector thumbnail = tn; int len = thumbnail.size(); diff --git a/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp b/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp index bf882857d9d..757b5327dd9 100644 --- a/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp +++ b/tools/editor/plugins/light_occluder_2d_editor_plugin.cpp @@ -411,6 +411,7 @@ void LightOccluder2DEditor::_bind_methods() { LightOccluder2DEditor::LightOccluder2DEditor(EditorNode *p_editor) { + node=NULL; canvas_item_editor=NULL; editor=p_editor; undo_redo = editor->get_undo_redo(); diff --git a/tools/editor/plugins/navigation_polygon_editor_plugin.cpp b/tools/editor/plugins/navigation_polygon_editor_plugin.cpp index bc15741d0f7..fa1f6144136 100644 --- a/tools/editor/plugins/navigation_polygon_editor_plugin.cpp +++ b/tools/editor/plugins/navigation_polygon_editor_plugin.cpp @@ -459,7 +459,7 @@ void NavigationPolygonEditor::_bind_methods() { } NavigationPolygonEditor::NavigationPolygonEditor(EditorNode *p_editor) { - + node=NULL; canvas_item_editor=NULL; editor=p_editor; undo_redo = editor->get_undo_redo(); diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index 0b3f3e0626b..77663f39c09 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -2216,6 +2216,14 @@ void SpatialEditorViewport::reset() { SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, EditorNode *p_editor, int p_index) { + _edit.mode=TRANSFORM_NONE; + _edit.plane=TRANSFORM_VIEW; + _edit.edited_gizmo=0; + _edit.snap=1; + _edit.gizmo_handle=0; + + + index=p_index; editor=p_editor; editor_selection=editor->get_editor_selection();; @@ -3615,6 +3623,8 @@ void SpatialEditor::_default_light_angle_input(const InputEvent& p_event) { SpatialEditor::SpatialEditor(EditorNode *p_editor) { + gizmo.visible=true; + gizmo.scale=1.0; viewport_environment = Ref( memnew( Environment ) ); undo_redo=p_editor->get_undo_redo();