diff options
-rw-r--r-- | drivers/gles2/shader_compiler_gles2.cpp | 2 | ||||
-rw-r--r-- | drivers/gles2/shaders/stdlib.glsl | 75 | ||||
-rw-r--r-- | editor/plugins/asset_library_editor_plugin.cpp | 44 | ||||
-rw-r--r-- | editor/plugins/asset_library_editor_plugin.h | 2 | ||||
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 22 | ||||
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.h | 1 | ||||
-rw-r--r-- | editor/plugins/visual_shader_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | main/main.cpp | 8 |
8 files changed, 124 insertions, 32 deletions
diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp index afc63cc416..ab0ee7c24f 100644 --- a/drivers/gles2/shader_compiler_gles2.cpp +++ b/drivers/gles2/shader_compiler_gles2.cpp @@ -966,6 +966,7 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() { actions[VS::SHADER_CANVAS_ITEM].usage_defines["outerProduct"] = "#define OUTER_PRODUCT_USED\n"; actions[VS::SHADER_CANVAS_ITEM].usage_defines["round"] = "#define ROUND_USED\n"; actions[VS::SHADER_CANVAS_ITEM].usage_defines["roundEven"] = "#define ROUND_EVEN_USED\n"; + actions[VS::SHADER_CANVAS_ITEM].usage_defines["inverse"] = "#define INVERSE_USED\n"; actions[VS::SHADER_CANVAS_ITEM].usage_defines["isinf"] = "#define IS_INF_USED\n"; actions[VS::SHADER_CANVAS_ITEM].usage_defines["isnan"] = "#define IS_NAN_USED\n"; actions[VS::SHADER_CANVAS_ITEM].usage_defines["trunc"] = "#define TRUNC_USED\n"; @@ -1075,6 +1076,7 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() { actions[VS::SHADER_SPATIAL].usage_defines["outerProduct"] = "#define OUTER_PRODUCT_USED\n"; actions[VS::SHADER_SPATIAL].usage_defines["round"] = "#define ROUND_USED\n"; actions[VS::SHADER_SPATIAL].usage_defines["roundEven"] = "#define ROUND_EVEN_USED\n"; + actions[VS::SHADER_SPATIAL].usage_defines["inverse"] = "#define INVERSE_USED\n"; actions[VS::SHADER_SPATIAL].usage_defines["isinf"] = "#define IS_INF_USED\n"; actions[VS::SHADER_SPATIAL].usage_defines["isnan"] = "#define IS_NAN_USED\n"; actions[VS::SHADER_SPATIAL].usage_defines["trunc"] = "#define TRUNC_USED\n"; diff --git a/drivers/gles2/shaders/stdlib.glsl b/drivers/gles2/shaders/stdlib.glsl index 96421fcb4a..9c74418743 100644 --- a/drivers/gles2/shaders/stdlib.glsl +++ b/drivers/gles2/shaders/stdlib.glsl @@ -299,6 +299,81 @@ highp float determinant(highp mat4 m) { #endif +#if defined(INVERSE_USED) + +highp mat2 inverse(highp mat2 m) { + highp float d = 1.0 / (m[0].x * m[1].y - m[1].x * m[0].y); + return mat2( + vec2(m[1].y * d, -m[0].y * d), + vec2(-m[1].x * d, m[0].x * d)); +} + +highp mat3 inverse(highp mat3 m) { + highp float d = 1.0 / (m[0].x * (m[1].y * m[2].z - m[2].y * m[1].z) - m[1].x * (m[0].y * m[2].z - m[2].y * m[0].z) + m[2].x * (m[0].y * m[1].z - m[1].y * m[0].z)); + return mat3( + vec3((m[1].y * m[2].z - m[2].y * m[1].z), -(m[1].x * m[2].z - m[2].x * m[1].z), (m[1].x * m[2].y - m[2].x * m[1].y)) * d, + vec3(-(m[0].y * m[2].z - m[2].y * m[0].z), (m[0].x * m[2].z - m[2].x * m[0].z), -(m[0].x * m[2].y - m[2].x * m[0].y)) * d, + vec3((m[0].y * m[1].z - m[1].y * m[0].z), -(m[0].x * m[1].z - m[1].x * m[0].z), (m[0].x * m[1].y - m[1].x * m[0].y)) * d); +} + +highp mat4 inverse(highp mat4 m) { + highp float c00 = m[2].z * m[3].w - m[3].z * m[2].w; + highp float c02 = m[1].z * m[3].w - m[3].z * m[1].w; + highp float c03 = m[1].z * m[2].w - m[2].z * m[1].w; + + highp float c04 = m[2].y * m[3].w - m[3].y * m[2].w; + highp float c06 = m[1].y * m[3].w - m[3].y * m[1].w; + highp float c07 = m[1].y * m[2].w - m[2].y * m[1].w; + + highp float c08 = m[2].y * m[3].z - m[3].y * m[2].z; + highp float c10 = m[1].y * m[3].z - m[3].y * m[1].z; + highp float c11 = m[1].y * m[2].z - m[2].y * m[1].z; + + highp float c12 = m[2].x * m[3].w - m[3].x * m[2].w; + highp float c14 = m[1].x * m[3].w - m[3].x * m[1].w; + highp float c15 = m[1].x * m[2].w - m[2].x * m[1].w; + + highp float c16 = m[2].x * m[3].z - m[3].x * m[2].z; + highp float c18 = m[1].x * m[3].z - m[3].x * m[1].z; + highp float c19 = m[1].x * m[2].z - m[2].x * m[1].z; + + highp float c20 = m[2].x * m[3].y - m[3].x * m[2].y; + highp float c22 = m[1].x * m[3].y - m[3].x * m[1].y; + highp float c23 = m[1].x * m[2].y - m[2].x * m[1].y; + + vec4 f0 = vec4(c00, c00, c02, c03); + vec4 f1 = vec4(c04, c04, c06, c07); + vec4 f2 = vec4(c08, c08, c10, c11); + vec4 f3 = vec4(c12, c12, c14, c15); + vec4 f4 = vec4(c16, c16, c18, c19); + vec4 f5 = vec4(c20, c20, c22, c23); + + vec4 v0 = vec4(m[1].x, m[0].x, m[0].x, m[0].x); + vec4 v1 = vec4(m[1].y, m[0].y, m[0].y, m[0].y); + vec4 v2 = vec4(m[1].z, m[0].z, m[0].z, m[0].z); + vec4 v3 = vec4(m[1].w, m[0].w, m[0].w, m[0].w); + + vec4 inv0 = vec4(v1 * f0 - v2 * f1 + v3 * f2); + vec4 inv1 = vec4(v0 * f0 - v2 * f3 + v3 * f4); + vec4 inv2 = vec4(v0 * f1 - v1 * f3 + v3 * f5); + vec4 inv3 = vec4(v0 * f2 - v1 * f4 + v2 * f5); + + vec4 sa = vec4(+1, -1, +1, -1); + vec4 sb = vec4(-1, +1, -1, +1); + + mat4 inv = mat4(inv0 * sa, inv1 * sb, inv2 * sa, inv3 * sb); + + vec4 r0 = vec4(inv[0].x, inv[1].x, inv[2].x, inv[3].x); + vec4 d0 = vec4(m[0] * r0); + + highp float d1 = (d0.x + d0.y) + (d0.z + d0.w); + highp float d = 1.0 / d1; + + return inv * d; +} + +#endif + #ifndef USE_GLES_OVER_GL #if defined(TRANSPOSE_USED) diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 132bf3973e..3eea888950 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -600,33 +600,15 @@ void EditorAssetLibrary::_notification(int p_what) { case NOTIFICATION_PROCESS: { HTTPClient::Status s = request->get_http_client_status(); - bool visible = s != HTTPClient::STATUS_DISCONNECTED; + const bool loading = s != HTTPClient::STATUS_DISCONNECTED; - if (visible != load_status->is_visible()) { - load_status->set_visible(visible); - } - - if (visible) { - switch (s) { - - case HTTPClient::STATUS_RESOLVING: { - load_status->set_value(0.1); - } break; - case HTTPClient::STATUS_CONNECTING: { - load_status->set_value(0.2); - } break; - case HTTPClient::STATUS_REQUESTING: { - load_status->set_value(0.3); - } break; - case HTTPClient::STATUS_BODY: { - load_status->set_value(0.4); - } break; - default: { - } - } + if (loading) { + library_scroll->set_modulate(Color(1, 1, 1, 0.5)); + } else { + library_scroll->set_modulate(Color(1, 1, 1, 1)); } - bool no_downloads = downloads_hb->get_child_count() == 0; + const bool no_downloads = downloads_hb->get_child_count() == 0; if (no_downloads == downloads_scroll->is_visible()) { downloads_scroll->set_visible(!no_downloads); } @@ -1157,6 +1139,10 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const _search(); } break; case REQUESTING_SEARCH: { + + // The loading text only needs to be displayed before the first page is loaded + library_loading->hide(); + if (asset_items) { memdelete(asset_items); } @@ -1472,6 +1458,10 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { library_vb_border->add_child(library_vb); + library_loading = memnew(Label(TTR("Loading..."))); + library_loading->set_align(Label::ALIGN_CENTER); + library_vb->add_child(library_loading); + asset_top_page = memnew(HBoxContainer); library_vb->add_child(asset_top_page); @@ -1494,12 +1484,6 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { library_vb->add_constant_override("separation", 20 * EDSCALE); - load_status = memnew(ProgressBar); - load_status->set_min(0); - load_status->set_max(1); - load_status->set_step(0.001); - library_main->add_child(load_status); - error_hb = memnew(HBoxContainer); library_main->add_child(error_hb); error_label = memnew(Label); diff --git a/editor/plugins/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h index 81288ae831..d81606c284 100644 --- a/editor/plugins/asset_library_editor_plugin.h +++ b/editor/plugins/asset_library_editor_plugin.h @@ -186,13 +186,13 @@ class EditorAssetLibrary : public PanelContainer { PanelContainer *library_scroll_bg; ScrollContainer *library_scroll; VBoxContainer *library_vb; + Label *library_loading; LineEdit *filter; OptionButton *categories; OptionButton *repository; OptionButton *sort; ToolButton *reverse; Button *search; - ProgressBar *load_status; HBoxContainer *error_hb; TextureRect *error_tr; Label *error_label; diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 785a1c107a..2daee70474 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -4429,6 +4429,27 @@ void CanvasItemEditor::_popup_callback(int p_op) { } } break; + case CLEAR_GUIDES: { + + if (EditorNode::get_singleton()->get_edited_scene()->has_meta("_edit_horizontal_guides_") || EditorNode::get_singleton()->get_edited_scene()->has_meta("_edit_vertical_guides_")) { + undo_redo->create_action(TTR("Clear Guides")); + if (EditorNode::get_singleton()->get_edited_scene()->has_meta("_edit_horizontal_guides_")) { + Array hguides = EditorNode::get_singleton()->get_edited_scene()->get_meta("_edit_horizontal_guides_"); + + undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_horizontal_guides_", Array()); + undo_redo->add_undo_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_horizontal_guides_", hguides); + } + if (EditorNode::get_singleton()->get_edited_scene()->has_meta("_edit_vertical_guides_")) { + Array vguides = EditorNode::get_singleton()->get_edited_scene()->get_meta("_edit_vertical_guides_"); + + undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_vertical_guides_", Array()); + undo_redo->add_undo_method(EditorNode::get_singleton()->get_edited_scene(), "set_meta", "_edit_vertical_guides_", vguides); + } + undo_redo->add_undo_method(viewport, "update"); + undo_redo->commit_action(); + } + + } break; case VIEW_CENTER_TO_SELECTION: case VIEW_FRAME_TO_SELECTION: { @@ -5159,6 +5180,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { p->add_separator(); p->add_shortcut(ED_SHORTCUT("canvas_item_editor/center_selection", TTR("Center Selection"), KEY_F), VIEW_CENTER_TO_SELECTION); p->add_shortcut(ED_SHORTCUT("canvas_item_editor/frame_selection", TTR("Frame Selection"), KEY_MASK_SHIFT | KEY_F), VIEW_FRAME_TO_SELECTION); + p->add_shortcut(ED_SHORTCUT("canvas_item_editor/clear_guides", TTR("Clear Guides")), CLEAR_GUIDES); p->add_separator(); p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/preview_canvas_scale", TTR("Preview Canvas Scale"), KEY_MASK_SHIFT | KEY_MASK_CMD | KEY_P), PREVIEW_CANVAS_SCALE); diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index a16d07599a..ac7d612292 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -178,6 +178,7 @@ private: ANIM_COPY_POSE, ANIM_PASTE_POSE, ANIM_CLEAR_POSE, + CLEAR_GUIDES, VIEW_CENTER_TO_SELECTION, VIEW_FRAME_TO_SELECTION, PREVIEW_CANVAS_SCALE, diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index c036a31ab5..66fbc32b1c 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -2569,7 +2569,7 @@ VisualShaderEditor::VisualShaderEditor() { add_options.push_back(AddOption("TransformDecompose", "Transform", "Composition", "VisualShaderNodeTransformDecompose", TTR("Decomposes transform to four vectors."))); add_options.push_back(AddOption("Determinant", "Transform", "Functions", "VisualShaderNodeDeterminant", TTR("Calculates the determinant of a transform."), -1, VisualShaderNode::PORT_TYPE_SCALAR)); - add_options.push_back(AddOption("Inverse", "Transform", "Functions", "VisualShaderNodeTransformFunc", TTR("Calculates the inverse of a transform."), VisualShaderNodeTransformFunc::FUNC_INVERSE, VisualShaderNode::PORT_TYPE_TRANSFORM, -1, -1, -1, true)); + add_options.push_back(AddOption("Inverse", "Transform", "Functions", "VisualShaderNodeTransformFunc", TTR("Calculates the inverse of a transform."), VisualShaderNodeTransformFunc::FUNC_INVERSE, VisualShaderNode::PORT_TYPE_TRANSFORM)); add_options.push_back(AddOption("Transpose", "Transform", "Functions", "VisualShaderNodeTransformFunc", TTR("Calculates the transpose of a transform."), VisualShaderNodeTransformFunc::FUNC_TRANSPOSE, VisualShaderNode::PORT_TYPE_TRANSFORM)); add_options.push_back(AddOption("TransformMult", "Transform", "Operators", "VisualShaderNodeTransformMult", TTR("Multiplies transform by transform."), -1, VisualShaderNode::PORT_TYPE_TRANSFORM)); diff --git a/main/main.cpp b/main/main.cpp index 582df4e866..8def4bd1ec 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -598,6 +598,14 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph auto_build_solutions = true; editor = true; +#ifdef DEBUG_METHODS_ENABLED + } else if (I->get() == "--gdnative-generate-json-api") { + // Register as an editor instance to use the GLES2 fallback automatically on hardware that doesn't support the GLES3 backend + editor = true; + + // We still pass it to the main arguments since the argument handling itself is not done in this function + main_args.push_back(I->get()); +#endif } else if (I->get() == "--export" || I->get() == "--export-debug") { // Export project editor = true; |