diff options
-rw-r--r-- | editor/editor_node.cpp | 6 | ||||
-rw-r--r-- | editor/spatial_editor_gizmos.cpp | 2 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 2 | ||||
-rw-r--r-- | scene/main/scene_tree.cpp | 79 | ||||
-rw-r--r-- | scene/resources/sky_box.cpp | 63 | ||||
-rw-r--r-- | scene/resources/sky_box.h | 11 | ||||
-rw-r--r-- | scene/resources/style_box.cpp | 2 |
7 files changed, 80 insertions, 85 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 242648d4a9..a5f0478854 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -371,6 +371,7 @@ void EditorNode::_fs_changed() { if (preset->get_name() == export_defer.preset) { break; } + preset.unref(); } if (preset.is_null()) { String err = "Unknown export preset: " + export_defer.preset; @@ -385,7 +386,7 @@ void EditorNode::_fs_changed() { } } - export_defer.preset = ""; + get_tree()->quit(); } { @@ -3939,6 +3940,7 @@ void EditorNode::_dock_select_input(const Ref<InputEvent> &p_input) { splits[i]->hide(); } + _edit_current(); _save_docks(); } } @@ -3966,6 +3968,7 @@ void EditorNode::_dock_move_left() { dock_slot[dock_popup_selected]->move_child(current, prev->get_index()); dock_slot[dock_popup_selected]->set_current_tab(dock_slot[dock_popup_selected]->get_current_tab() - 1); dock_select->update(); + _edit_current(); _save_docks(); } @@ -3978,6 +3981,7 @@ void EditorNode::_dock_move_right() { dock_slot[dock_popup_selected]->move_child(next, current->get_index()); dock_slot[dock_popup_selected]->set_current_tab(dock_slot[dock_popup_selected]->get_current_tab() + 1); dock_select->update(); + _edit_current(); _save_docks(); } diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index 24be2095ce..0e6e7420e2 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -1150,7 +1150,7 @@ CameraSpatialGizmo::CameraSpatialGizmo(Camera *p_camera) { void MeshInstanceSpatialGizmo::redraw() { - Ref<ArrayMesh> m = mesh->get_mesh(); + Ref<Mesh> m = mesh->get_mesh(); if (!m.is_valid()) return; //none diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 324c0cd0d1..2b111c50a6 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -1028,6 +1028,8 @@ void TextEdit::_notification(int p_what) { if (cursor.column == j && cursor.line == line && block_caret && draw_caret && !insert_mode) { color = cache.caret_background_color; + } else if (!syntax_coloring && block_caret) { + color = cache.font_color; } if (str[j] >= 32) { diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 66eafa1070..2e67a1feaf 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -392,86 +392,11 @@ void SceneTree::input_event(const Ref<InputEvent> &p_event) { Ref<InputEvent> ev = p_event; ev->set_id(++last_id); //this should work better -#if 0 - switch(ev.type) { - - case InputEvent::MOUSE_BUTTON: { - - Matrix32 ai = root->get_final_transform().affine_inverse(); - Vector2 g = ai.xform(Vector2(ev.mouse_button.global_x,ev.mouse_button.global_y)); - Vector2 l = ai.xform(Vector2(ev->get_pos().x,ev->get_pos().y)); - ev->get_pos().x=l.x; - ev->get_pos().y=l.y; - ev.mouse_button.global_x=g.x; - ev.mouse_button.global_y=g.y; - - } break; - case InputEvent::MOUSE_MOTION: { - - Matrix32 ai = root->get_final_transform().affine_inverse(); - Vector2 g = ai.xform(Vector2(ev.mouse_motion.global_x,ev.mouse_motion.global_y)); - Vector2 l = ai.xform(Vector2(ev.mouse_motion.x,ev.mouse_motion.y)); - Vector2 r = ai.xform(Vector2(ev->get_relative().x,ev->get_relative().y)); - ev.mouse_motion.x=l.x; - ev.mouse_motion.y=l.y; - ev.mouse_motion.global_x=g.x; - ev.mouse_motion.global_y=g.y; - ev->get_relative().x=r.x; - ev->get_relative().y=r.y; - - } break; - case InputEvent::SCREEN_TOUCH: { - - Matrix32 ai = root->get_final_transform().affine_inverse(); - Vector2 t = ai.xform(Vector2(ev.screen_touch.x,ev.screen_touch.y)); - ev.screen_touch.x=t.x; - ev.screen_touch.y=t.y; - - } break; - case InputEvent::SCREEN_DRAG: { - - Matrix32 ai = root->get_final_transform().affine_inverse(); - Vector2 t = ai.xform(Vector2(ev.screen_drag.x,ev.screen_drag.y)); - Vector2 r = ai.xform(Vector2(ev.screen_drag.relative_x,ev.screen_drag.relative_y)); - Vector2 s = ai.xform(Vector2(ev.screen_drag.speed_x,ev.screen_drag.speed_y)); - ev.screen_drag.x=t.x; - ev.screen_drag.y=t.y; - ev.screen_drag.relative_x=r.x; - ev.screen_drag.relative_y=r.y; - ev.screen_drag.speed_x=s.x; - ev.screen_drag.speed_y=s.y; - } break; - } - -#endif MainLoop::input_event(ev); -#if 0 - _call_input_pause("input","_input",ev); - - call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"_gui_input","_gui_input",p_event); //special one for GUI, as controls use their own process check - - //call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"input","_input",ev); - - /* - if (ev.type==InputEvent::KEY && ev->is_pressed() && !ev->is_echo() && ev->get_scancode()==KEY_F12) { - - print_line("RAM: "+itos(Memory::get_static_mem_usage())); - print_line("DRAM: "+itos(Memory::get_dynamic_mem_usage())); - } - if (ev.type==InputEvent::KEY && ev->is_pressed() && !ev->is_echo() && ev->get_scancode()==KEY_F11) { - - Memory::dump_static_mem_to_file("memdump.txt"); - } - */ - - //transform for the rest -#else call_group_flags(GROUP_CALL_REALTIME, "_viewports", "_vp_input", ev); //special one for GUI, as controls use their own process check -#endif - if (ScriptDebugger::get_singleton() && ScriptDebugger::get_singleton()->is_remote()) { //quit from game window using F8 Ref<InputEventKey> k = ev; @@ -482,7 +407,7 @@ void SceneTree::input_event(const Ref<InputEvent> &p_event) { _flush_ugc(); root_lock--; - MessageQueue::get_singleton()->flush(); //small little hack + //MessageQueue::get_singleton()->flush(); //flushing here causes UI and other places slowness root_lock++; @@ -503,7 +428,7 @@ void SceneTree::input_event(const Ref<InputEvent> &p_event) { input_handled = true; _flush_ugc(); root_lock--; - MessageQueue::get_singleton()->flush(); //small little hack + //MessageQueue::get_singleton()->flush(); //flushing here causes UI and other places slowness } else { input_handled = true; root_lock--; diff --git a/scene/resources/sky_box.cpp b/scene/resources/sky_box.cpp index 5750960845..cc3cfe4dc0 100644 --- a/scene/resources/sky_box.cpp +++ b/scene/resources/sky_box.cpp @@ -128,7 +128,7 @@ void ProceduralSky::_radiance_changed() { VS::get_singleton()->sky_set_texture(sky, texture, size[get_radiance_size()]); } -void ProceduralSky::_update_sky() { +Ref<Image> ProceduralSky::_generate_sky() { update_queued = false; @@ -215,9 +215,7 @@ void ProceduralSky::_update_sky() { image.instance(); image->create(w, h, false, Image::FORMAT_RGBE9995, imgdata); - VS::get_singleton()->texture_allocate(texture, w, h, Image::FORMAT_RGBE9995, VS::TEXTURE_FLAG_FILTER | VS::TEXTURE_FLAG_REPEAT); - VS::get_singleton()->texture_set_data(texture, image); - _radiance_changed(); + return image; } void ProceduralSky::set_sky_top_color(const Color &p_sky_top) { @@ -385,6 +383,33 @@ RID ProceduralSky::get_rid() const { return sky; } +void ProceduralSky::_update_sky() { + + bool use_thread = true; + if (first_time) { + use_thread = false; + first_time = false; + } +#ifdef NO_THREADS + use_thread = false; +#endif + if (use_thread) { + + if (!sky_thread) { + sky_thread = Thread::create(_thread_function, this); + regen_queued = false; + } else { + regen_queued = true; + } + + } else { + Ref<Image> image = _generate_sky(); + VS::get_singleton()->texture_allocate(texture, image->get_width(), image->get_height(), Image::FORMAT_RGBE9995, VS::TEXTURE_FLAG_FILTER | VS::TEXTURE_FLAG_REPEAT); + VS::get_singleton()->texture_set_data(texture, image); + _radiance_changed(); + } +} + void ProceduralSky::_queue_update() { if (update_queued) @@ -394,6 +419,26 @@ void ProceduralSky::_queue_update() { call_deferred("_update_sky"); } +void ProceduralSky::_thread_done(const Ref<Image> &image) { + + VS::get_singleton()->texture_allocate(texture, image->get_width(), image->get_height(), Image::FORMAT_RGBE9995, VS::TEXTURE_FLAG_FILTER | VS::TEXTURE_FLAG_REPEAT); + VS::get_singleton()->texture_set_data(texture, image); + _radiance_changed(); + Thread::wait_to_finish(sky_thread); + memdelete(sky_thread); + sky_thread = NULL; + if (regen_queued) { + sky_thread = Thread::create(_thread_function, this); + regen_queued = false; + } +} + +void ProceduralSky::_thread_function(void *p_ud) { + + ProceduralSky *psky = (ProceduralSky *)p_ud; + psky->call_deferred("_thread_done", psky->_generate_sky()); +} + void ProceduralSky::_bind_methods() { ClassDB::bind_method(D_METHOD("_update_sky"), &ProceduralSky::_update_sky); @@ -446,6 +491,8 @@ void ProceduralSky::_bind_methods() { ClassDB::bind_method(D_METHOD("set_texture_size", "size"), &ProceduralSky::set_texture_size); ClassDB::bind_method(D_METHOD("get_texture_size"), &ProceduralSky::get_texture_size); + ClassDB::bind_method(D_METHOD("_thread_done", "image"), &ProceduralSky::_thread_done); + ADD_GROUP("Sky", "sky_"); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "sky_top_color"), "set_sky_top_color", "get_sky_top_color"); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "sky_horizon_color"), "set_sky_horizon_color", "get_sky_horizon_color"); @@ -503,12 +550,20 @@ ProceduralSky::ProceduralSky() { sun_energy = 16; texture_size = TEXTURE_SIZE_1024; + sky_thread = NULL; + regen_queued = false; + first_time = true; _queue_update(); } ProceduralSky::~ProceduralSky() { + if (sky_thread) { + Thread::wait_to_finish(sky_thread); + memdelete(sky_thread); + sky_thread = NULL; + } VS::get_singleton()->free(sky); VS::get_singleton()->free(texture); } diff --git a/scene/resources/sky_box.h b/scene/resources/sky_box.h index 8298d1b3c0..9bd60cddaf 100644 --- a/scene/resources/sky_box.h +++ b/scene/resources/sky_box.h @@ -30,8 +30,8 @@ #ifndef Sky_H #define Sky_H +#include "os/thread.h" #include "scene/resources/texture.h" - class Sky : public Resource { GDCLASS(Sky, Resource); @@ -97,6 +97,7 @@ public: }; private: + Thread *sky_thread; Color sky_top_color; Color sky_horizon_color; float sky_curve; @@ -121,12 +122,20 @@ private: RID texture; bool update_queued; + bool regen_queued; + + bool first_time; + + void _thread_done(const Ref<Image> &p_image); + static void _thread_function(void *p_ud); protected: static void _bind_methods(); virtual void _radiance_changed(); + Ref<Image> _generate_sky(); void _update_sky(); + void _queue_update(); public: diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp index 48efa242e9..67bc5b30ff 100644 --- a/scene/resources/style_box.cpp +++ b/scene/resources/style_box.cpp @@ -717,7 +717,7 @@ void StyleBoxFlat::_bind_methods() { ClassDB::bind_method(D_METHOD("get_bg_color"), &StyleBoxFlat::get_bg_color); ClassDB::bind_method(D_METHOD("set_border_color", "color"), &StyleBoxFlat::set_border_color_all); - ClassDB::bind_method(D_METHOD("get_border_color", "color"), &StyleBoxFlat::get_border_color_all); + ClassDB::bind_method(D_METHOD("get_border_color"), &StyleBoxFlat::get_border_color_all); ClassDB::bind_method(D_METHOD("set_border_width_all", "width"), &StyleBoxFlat::set_border_width_all); ClassDB::bind_method(D_METHOD("get_border_width_min"), &StyleBoxFlat::get_border_width_min); |