diff options
-rw-r--r-- | core/math/random_number_generator.h | 5 | ||||
-rw-r--r-- | doc/classes/ArrayMesh.xml | 5 | ||||
-rw-r--r-- | doc/classes/Color.xml | 2 | ||||
-rw-r--r-- | doc/classes/MeshInstance.xml | 1 | ||||
-rw-r--r-- | doc/classes/MeshInstance2D.xml | 5 | ||||
-rw-r--r-- | doc/classes/PrimitiveMesh.xml | 5 | ||||
-rw-r--r-- | doc/classes/QuadMesh.xml | 1 | ||||
-rw-r--r-- | doc/classes/TriangleMesh.xml | 2 | ||||
-rw-r--r-- | editor/create_dialog.cpp | 9 | ||||
-rw-r--r-- | editor/plugins/shader_editor_plugin.cpp | 85 | ||||
-rw-r--r-- | editor/plugins/shader_editor_plugin.h | 8 | ||||
-rw-r--r-- | editor/scene_tree_editor.cpp | 4 | ||||
-rw-r--r-- | platform/windows/export/export.cpp | 4 | ||||
-rw-r--r-- | scene/gui/base_button.cpp | 12 |
14 files changed, 119 insertions, 29 deletions
diff --git a/core/math/random_number_generator.h b/core/math/random_number_generator.h index 6b6bcdd2cd..a6182a4b33 100644 --- a/core/math/random_number_generator.h +++ b/core/math/random_number_generator.h @@ -59,7 +59,10 @@ public: _FORCE_INLINE_ int randi_range(int from, int to) { unsigned int ret = randbase.rand(); - return ret % (to - from + 1) + from; + if (to < from) + return ret % (from - to + 1) + to; + else + return ret % (to - from + 1) + from; } RandomNumberGenerator(); diff --git a/doc/classes/ArrayMesh.xml b/doc/classes/ArrayMesh.xml index 745d803a30..d44e3c54c9 100644 --- a/doc/classes/ArrayMesh.xml +++ b/doc/classes/ArrayMesh.xml @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="ArrayMesh" inherits="Mesh" category="Core" version="3.2"> <brief_description> + [Mesh] type that provides utility for constructing a surface from arrays. </brief_description> <description> The [ArrayMesh] is used to construct a [Mesh] by specifying the attributes as arrays. The most basic example is the creation of a single triangle @@ -30,6 +31,7 @@ <argument index="0" name="name" type="String"> </argument> <description> + Add name for a blend shape that will be added with [method add_surface_from_arrays]. Must be called before surface is added. </description> </method> <method name="add_surface_from_arrays"> @@ -176,6 +178,7 @@ <argument index="2" name="data" type="PoolByteArray"> </argument> <description> + Updates a specified region of mesh arrays on GPU. Warning: only use if you know what you are doing. You can easily cause crashes by calling this function with improper arguments. </description> </method> </methods> @@ -183,7 +186,7 @@ <member name="blend_shape_mode" type="int" setter="set_blend_shape_mode" getter="get_blend_shape_mode" enum="Mesh.BlendShapeMode"> </member> <member name="custom_aabb" type="AABB" setter="set_custom_aabb" getter="get_custom_aabb"> - An overriding bounding box for this mesh. + Overrides the [AABB] with one defined by user for use with frustum culling. Especially useful to avoid unnexpected culling when using a shader to offset vertices. </member> </members> <constants> diff --git a/doc/classes/Color.xml b/doc/classes/Color.xml index ab5d7a0a5d..30e80fa512 100644 --- a/doc/classes/Color.xml +++ b/doc/classes/Color.xml @@ -144,7 +144,7 @@ <return type="Color"> </return> <description> - Returns the inverted color [code](1 - r, 1 - g, 1 - b, 1 - a)[/code]. + Returns the inverted color [code](1 - r, 1 - g, 1 - b, a)[/code]. [codeblock] var c = Color(0.3, 0.4, 0.9) var inverted_color = c.inverted() # a color of an RGBA(178, 153, 26, 255) diff --git a/doc/classes/MeshInstance.xml b/doc/classes/MeshInstance.xml index c5c15e0ddc..f5868f51cb 100644 --- a/doc/classes/MeshInstance.xml +++ b/doc/classes/MeshInstance.xml @@ -43,6 +43,7 @@ <return type="int"> </return> <description> + Returns the number of surface materials. </description> </method> <method name="set_surface_material"> diff --git a/doc/classes/MeshInstance2D.xml b/doc/classes/MeshInstance2D.xml index d18ba96a95..39a733fdb3 100644 --- a/doc/classes/MeshInstance2D.xml +++ b/doc/classes/MeshInstance2D.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="MeshInstance2D" inherits="Node2D" category="Core" version="3.2"> <brief_description> + Node used for displaying a [Mesh] in 2D. </brief_description> <description> + Node used for displaying a [Mesh] in 2D. Can be constructed from an existing [Sprite] use tool in Toolbar. Select "Sprite" then "Convert to Mesh2D", select settings in popup and press "Create Mesh2D". </description> <tutorials> <link>http://docs.godotengine.org/en/latest/tutorials/2d/2d_meshes.html</link> @@ -11,10 +13,13 @@ </methods> <members> <member name="mesh" type="Mesh" setter="set_mesh" getter="get_mesh"> + The [Mesh] that will be drawn by the [MeshInstance2D]. </member> <member name="normal_map" type="Texture" setter="set_normal_map" getter="get_normal_map"> + The normal map that will be used if using the default [CanvasItemMaterial]. </member> <member name="texture" type="Texture" setter="set_texture" getter="get_texture"> + The [Texture] that will be used if using the default [CanvasItemMaterial]. Can be accessed as [code]TEXTURE[/code] in CanvasItem shader. </member> </members> <constants> diff --git a/doc/classes/PrimitiveMesh.xml b/doc/classes/PrimitiveMesh.xml index c9c3643edb..2214357308 100644 --- a/doc/classes/PrimitiveMesh.xml +++ b/doc/classes/PrimitiveMesh.xml @@ -4,7 +4,7 @@ Base class for all primitive meshes. Handles applying a [Material] to a primitive mesh. </brief_description> <description> - Base class for all primitive meshes. Handles applying a [Material] to a primitive mesh. + Base class for all primitive meshes. Handles applying a [Material] to a primitive mesh. Examples include [CapsuleMesh], [CubeMesh], [CylinderMesh], [PlaneMesh], [PrismMesh], [QuadMesh], and [SphereMesh]. </description> <tutorials> </tutorials> @@ -13,13 +13,16 @@ <return type="Array"> </return> <description> + Returns mesh arrays used to constitute surface of [Mesh]. Mesh array can be used with [ArrayMesh] to create new surface. </description> </method> </methods> <members> <member name="custom_aabb" type="AABB" setter="set_custom_aabb" getter="get_custom_aabb"> + Overrides the [AABB] with one defined by user for use with frustum culling. Especially useful to avoid unnexpected culling when using a shader to offset vertices. </member> <member name="flip_faces" type="bool" setter="set_flip_faces" getter="get_flip_faces"> + If set, the order of the vertices in each triangle are reversed resulting in the backside of the mesh being drawn. Result is the same as using *CULL_BACK* in [SpatialMaterial]. Default is false. </member> <member name="material" type="Material" setter="set_material" getter="get_material"> The current [Material] of the primitive mesh. diff --git a/doc/classes/QuadMesh.xml b/doc/classes/QuadMesh.xml index 779ce11180..cf7e56f895 100644 --- a/doc/classes/QuadMesh.xml +++ b/doc/classes/QuadMesh.xml @@ -12,6 +12,7 @@ </methods> <members> <member name="size" type="Vector2" setter="set_size" getter="get_size"> + Size in the X and Y axes. Default is [code]Vector2(1, 1)[/code]. </member> </members> <constants> diff --git a/doc/classes/TriangleMesh.xml b/doc/classes/TriangleMesh.xml index 9600a1d196..2125aa5e17 100644 --- a/doc/classes/TriangleMesh.xml +++ b/doc/classes/TriangleMesh.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="TriangleMesh" inherits="Reference" category="Core" version="3.2"> <brief_description> + Internal mesh type. </brief_description> <description> + Mesh type used internally for collision calculations. </description> <tutorials> </tutorials> diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 604a050fcd..e84602b29f 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -246,13 +246,14 @@ bool CreateDialog::_is_class_disabled_by_feature_profile(const StringName &p_cla if (profile->is_class_disabled(class_name)) { return true; } - class_name = ClassDB::get_parent_class(class_name); + class_name = ClassDB::get_parent_class_nocheck(class_name); } return false; } void CreateDialog::select_type(const String &p_type) { + TreeItem *to_select; if (search_options_types.has(p_type)) { to_select = search_options_types[p_type]; @@ -279,10 +280,6 @@ void CreateDialog::_update_search() { favorite->set_disabled(true); help_bit->set_text(""); - /* - TreeItem *root = search_options->create_item(); - _parse_fs(EditorFileSystem::get_singleton()->get_filesystem()); -*/ search_options_types.clear(); @@ -733,6 +730,7 @@ CreateDialog::CreateDialog() { fav_vb->add_margin_child(TTR("Favorites:"), favorites, true); favorites->set_hide_root(true); favorites->set_hide_folding(true); + favorites->set_allow_reselect(true); favorites->connect("cell_selected", this, "_favorite_selected"); favorites->connect("item_activated", this, "_favorite_activated"); favorites->set_drag_forwarding(this); @@ -747,6 +745,7 @@ CreateDialog::CreateDialog() { rec_vb->add_margin_child(TTR("Recent:"), recent, true); recent->set_hide_root(true); recent->set_hide_folding(true); + recent->set_allow_reselect(true); recent->connect("cell_selected", this, "_history_selected"); recent->connect("item_activated", this, "_history_activated"); recent->add_constant_override("draw_guides", 1); diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index a795405dfc..f9ca38b919 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -60,6 +60,26 @@ void ShaderTextEditor::set_edited_shader(const Ref<Shader> &p_shader) { _line_col_changed(); } +void ShaderTextEditor::reload_text() { + ERR_FAIL_COND(shader.is_null()); + + TextEdit *te = get_text_edit(); + int column = te->cursor_get_column(); + int row = te->cursor_get_line(); + int h = te->get_h_scroll(); + int v = te->get_v_scroll(); + + te->set_text(shader->get_code()); + te->cursor_set_line(row); + te->cursor_set_column(column); + te->set_h_scroll(h); + te->set_v_scroll(v); + + te->tag_saved_version(); + + update_line_and_column(); +} + void ShaderTextEditor::_load_theme_settings() { get_text_edit()->clear_colors(); @@ -330,9 +350,8 @@ void ShaderEditor::_menu_option(int p_option) { void ShaderEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { - //if (is_visible_in_tree()) - // shader_editor->get_text_edit()->grab_focus(); + if (p_what == MainLoop::NOTIFICATION_WM_FOCUS_IN) { + _check_for_external_edit(); } } @@ -363,12 +382,14 @@ void ShaderEditor::_editor_settings_changed() { void ShaderEditor::_bind_methods() { + ClassDB::bind_method("_reload_shader_from_disk", &ShaderEditor::_reload_shader_from_disk); ClassDB::bind_method("_editor_settings_changed", &ShaderEditor::_editor_settings_changed); ClassDB::bind_method("_text_edit_gui_input", &ShaderEditor::_text_edit_gui_input); ClassDB::bind_method("_menu_option", &ShaderEditor::_menu_option); ClassDB::bind_method("_params_changed", &ShaderEditor::_params_changed); ClassDB::bind_method("apply_shaders", &ShaderEditor::apply_shaders); + ClassDB::bind_method("save_external_data", &ShaderEditor::save_external_data); } void ShaderEditor::ensure_select_current() { @@ -389,6 +410,37 @@ void ShaderEditor::goto_line_selection(int p_line, int p_begin, int p_end) { shader_editor->goto_line_selection(p_line, p_begin, p_end); } +void ShaderEditor::_check_for_external_edit() { + + if (shader.is_null() || !shader.is_valid()) { + return; + } + + // internal shader. + if (shader->get_path() == "" || shader->get_path().find("local://") != -1 || shader->get_path().find("::") != -1) { + return; + } + + bool use_autoreload = bool(EDITOR_DEF("text_editor/files/auto_reload_scripts_on_external_change", false)); + if (shader->get_last_modified_time() != FileAccess::get_modified_time(shader->get_path())) { + if (use_autoreload) { + _reload_shader_from_disk(); + } else { + disk_changed->call_deferred("popup_centered"); + } + } +} + +void ShaderEditor::_reload_shader_from_disk() { + + Ref<Shader> rel_shader = ResourceLoader::load(shader->get_path(), shader->get_class(), true); + ERR_FAIL_COND(!rel_shader.is_valid()); + + shader->set_code(rel_shader->get_code()); + shader->set_last_modified_time(rel_shader->get_last_modified_time()); + shader_editor->reload_text(); +} + void ShaderEditor::edit(const Ref<Shader> &p_shader) { if (p_shader.is_null() || !p_shader->is_text_shader()) @@ -405,16 +457,20 @@ void ShaderEditor::edit(const Ref<Shader> &p_shader) { // see if already has it } -void ShaderEditor::save_external_data() { +void ShaderEditor::save_external_data(const String &p_str) { - if (shader.is_null()) + if (shader.is_null()) { + disk_changed->hide(); return; - apply_shaders(); + } + apply_shaders(); if (shader->get_path() != "" && shader->get_path().find("local://") == -1 && shader->get_path().find("::") == -1) { //external shader, save it ResourceSaver::save(shader->get_path(), shader); } + + disk_changed->hide(); } void ShaderEditor::apply_shaders() { @@ -573,6 +629,23 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) { goto_line_dialog = memnew(GotoLineDialog); add_child(goto_line_dialog); + disk_changed = memnew(ConfirmationDialog); + + VBoxContainer *vbc = memnew(VBoxContainer); + disk_changed->add_child(vbc); + + Label *dl = memnew(Label); + dl->set_text(TTR("This shader has been modified on on disk.\nWhat action should be taken?")); + vbc->add_child(dl); + + disk_changed->connect("confirmed", this, "_reload_shader_from_disk"); + disk_changed->get_ok()->set_text(TTR("Reload")); + + disk_changed->add_button(TTR("Resave"), !OS::get_singleton()->get_swap_ok_cancel(), "resave"); + disk_changed->connect("custom_action", this, "save_external_data"); + + add_child(disk_changed); + _editor_settings_changed(); } diff --git a/editor/plugins/shader_editor_plugin.h b/editor/plugins/shader_editor_plugin.h index 28ac9faaa5..b56c1451ad 100644 --- a/editor/plugins/shader_editor_plugin.h +++ b/editor/plugins/shader_editor_plugin.h @@ -58,6 +58,8 @@ protected: public: virtual void _validate_script(); + void reload_text(); + Ref<Shader> get_edited_shader() const; void set_edited_shader(const Ref<Shader> &p_shader); ShaderTextEditor(); @@ -103,6 +105,7 @@ class ShaderEditor : public PanelContainer { GotoLineDialog *goto_line_dialog; ConfirmationDialog *erase_tab_confirm; + ConfirmationDialog *disk_changed; ShaderTextEditor *shader_editor; @@ -112,6 +115,9 @@ class ShaderEditor : public PanelContainer { void _editor_settings_changed(); + void _check_for_external_edit(); + void _reload_shader_from_disk(); + protected: void _notification(int p_what); static void _bind_methods(); @@ -127,7 +133,7 @@ public: void goto_line_selection(int p_line, int p_begin, int p_end); virtual Size2 get_minimum_size() const { return Size2(0, 200); } - void save_external_data(); + void save_external_data(const String &p_str = ""); ShaderEditor(EditorNode *p_node); }; diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index 064bf0077a..d6c8e6b452 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -291,8 +291,8 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { p_node->connect("script_changed", this, "_node_script_changed", varray(p_node)); if (!p_node->get_script().is_null()) { - - item->add_button(0, get_icon("Script", "EditorIcons"), BUTTON_SCRIPT, false, TTR("Open Script")); + Ref<Script> script = p_node->get_script(); + item->add_button(0, get_icon("Script", "EditorIcons"), BUTTON_SCRIPT, false, TTR("Open Script:") + " " + script->get_path()); } if (p_node->is_class("CanvasItem")) { diff --git a/platform/windows/export/export.cpp b/platform/windows/export/export.cpp index 141ab96370..4a72d07adc 100644 --- a/platform/windows/export/export.cpp +++ b/platform/windows/export/export.cpp @@ -138,8 +138,8 @@ void EditorExportPlatformWindows::get_export_options(List<ExportOption> *r_optio EditorExportPlatformPC::get_export_options(r_options); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/icon", PROPERTY_HINT_FILE, "*.ico"), "")); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/file_version"), "")); - r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/product_version"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/file_version", PROPERTY_HINT_PLACEHOLDER_TEXT, "1.0.0"), "")); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/product_version", PROPERTY_HINT_PLACEHOLDER_TEXT, "1.0.0"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/company_name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Company Name"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/product_name", PROPERTY_HINT_PLACEHOLDER_TEXT, "Game Name"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "application/file_description"), "")); diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index 5ef2557383..fadf5e432c 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -216,9 +216,7 @@ void BaseButton::set_pressed(bool p_pressed) { if (p_pressed) { _unpress_group(); } - if (toggle_mode) { - _toggled(status.pressed); - } + _toggled(status.pressed); update(); } @@ -337,9 +335,6 @@ bool BaseButton::is_keep_pressed_outside() const { void BaseButton::set_shortcut(const Ref<ShortCut> &p_shortcut) { - if (shortcut.is_null() == p_shortcut.is_null()) - return; - shortcut = p_shortcut; set_process_unhandled_input(shortcut.is_valid()); } @@ -356,11 +351,10 @@ void BaseButton::_unhandled_input(Ref<InputEvent> p_event) { return; //ignore because of modal window if (is_toggle_mode()) { - set_pressed(!is_pressed()); - emit_signal("toggled", is_pressed()); + set_pressed(!is_pressed()); // Also calls _toggled() internally. } - emit_signal("pressed"); + _pressed(); } } |