diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/3d/label_3d.cpp | 17 | ||||
-rw-r--r-- | scene/3d/label_3d.h | 14 | ||||
-rw-r--r-- | scene/3d/path_3d.cpp | 14 | ||||
-rw-r--r-- | scene/3d/path_3d.h | 2 | ||||
-rw-r--r-- | scene/gui/button.cpp | 10 | ||||
-rw-r--r-- | scene/gui/button.h | 6 | ||||
-rw-r--r-- | scene/gui/dialogs.cpp | 4 | ||||
-rw-r--r-- | scene/gui/item_list.cpp | 4 | ||||
-rw-r--r-- | scene/gui/item_list.h | 6 | ||||
-rw-r--r-- | scene/gui/label.cpp | 79 | ||||
-rw-r--r-- | scene/gui/label.h | 46 | ||||
-rw-r--r-- | scene/gui/rich_text_label.cpp | 41 | ||||
-rw-r--r-- | scene/gui/rich_text_label.h | 29 | ||||
-rw-r--r-- | scene/main/window.cpp | 13 | ||||
-rw-r--r-- | scene/resources/importer_mesh.cpp | 3 | ||||
-rw-r--r-- | scene/resources/surface_tool.cpp | 63 | ||||
-rw-r--r-- | scene/resources/surface_tool.h | 12 | ||||
-rw-r--r-- | scene/resources/text_line.cpp | 26 | ||||
-rw-r--r-- | scene/resources/text_line.h | 17 | ||||
-rw-r--r-- | scene/resources/text_paragraph.cpp | 24 | ||||
-rw-r--r-- | scene/resources/text_paragraph.h | 17 | ||||
-rw-r--r-- | scene/resources/visual_shader.cpp | 84 | ||||
-rw-r--r-- | scene/resources/visual_shader.h | 10 |
23 files changed, 163 insertions, 378 deletions
diff --git a/scene/3d/label_3d.cpp b/scene/3d/label_3d.cpp index d95cf15bfa..6ed4ce8c5b 100644 --- a/scene/3d/label_3d.cpp +++ b/scene/3d/label_3d.cpp @@ -155,11 +155,6 @@ void Label3D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "text_direction", PROPERTY_HINT_ENUM, "Auto,Left-to-Right,Right-to-Left"), "set_text_direction", "get_text_direction"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "language", PROPERTY_HINT_LOCALE_ID, ""), "set_language", "get_language"); - BIND_ENUM_CONSTANT(AUTOWRAP_OFF); - BIND_ENUM_CONSTANT(AUTOWRAP_ARBITRARY); - BIND_ENUM_CONSTANT(AUTOWRAP_WORD); - BIND_ENUM_CONSTANT(AUTOWRAP_WORD_SMART); - BIND_ENUM_CONSTANT(FLAG_SHADED); BIND_ENUM_CONSTANT(FLAG_DOUBLE_SIDED); BIND_ENUM_CONSTANT(FLAG_DISABLE_DEPTH_TEST); @@ -514,16 +509,16 @@ void Label3D::_shape() { uint16_t autowrap_flags = TextServer::BREAK_MANDATORY; switch (autowrap_mode) { - case AUTOWRAP_WORD_SMART: + case TextServer::AUTOWRAP_WORD_SMART: autowrap_flags = TextServer::BREAK_WORD_BOUND_ADAPTIVE | TextServer::BREAK_MANDATORY; break; - case AUTOWRAP_WORD: + case TextServer::AUTOWRAP_WORD: autowrap_flags = TextServer::BREAK_WORD_BOUND | TextServer::BREAK_MANDATORY; break; - case AUTOWRAP_ARBITRARY: + case TextServer::AUTOWRAP_ARBITRARY: autowrap_flags = TextServer::BREAK_GRAPHEME_BOUND | TextServer::BREAK_MANDATORY; break; - case AUTOWRAP_OFF: + case TextServer::AUTOWRAP_OFF: break; } PackedInt32Array line_breaks = TS->shaped_text_get_line_breaks(text_rid, width, 0, autowrap_flags); @@ -885,7 +880,7 @@ Color Label3D::get_outline_modulate() const { return outline_modulate; } -void Label3D::set_autowrap_mode(Label3D::AutowrapMode p_mode) { +void Label3D::set_autowrap_mode(TextServer::AutowrapMode p_mode) { if (autowrap_mode != p_mode) { autowrap_mode = p_mode; dirty_lines = true; @@ -893,7 +888,7 @@ void Label3D::set_autowrap_mode(Label3D::AutowrapMode p_mode) { } } -Label3D::AutowrapMode Label3D::get_autowrap_mode() const { +TextServer::AutowrapMode Label3D::get_autowrap_mode() const { return autowrap_mode; } diff --git a/scene/3d/label_3d.h b/scene/3d/label_3d.h index 62f4c3fe96..7766bca068 100644 --- a/scene/3d/label_3d.h +++ b/scene/3d/label_3d.h @@ -54,13 +54,6 @@ public: ALPHA_CUT_OPAQUE_PREPASS }; - enum AutowrapMode { - AUTOWRAP_OFF, - AUTOWRAP_ARBITRARY, - AUTOWRAP_WORD, - AUTOWRAP_WORD_SMART - }; - private: real_t pixel_size = 0.01; bool flags[FLAG_MAX] = {}; @@ -91,7 +84,7 @@ private: String xl_text; bool uppercase = false; - AutowrapMode autowrap_mode = AUTOWRAP_OFF; + TextServer::AutowrapMode autowrap_mode = TextServer::AUTOWRAP_OFF; float width = 500.0; int font_size = 16; @@ -200,8 +193,8 @@ public: void set_outline_modulate(const Color &p_color); Color get_outline_modulate() const; - void set_autowrap_mode(AutowrapMode p_mode); - AutowrapMode get_autowrap_mode() const; + void set_autowrap_mode(TextServer::AutowrapMode p_mode); + TextServer::AutowrapMode get_autowrap_mode() const; void set_width(float p_width); float get_width() const; @@ -234,7 +227,6 @@ public: ~Label3D(); }; -VARIANT_ENUM_CAST(Label3D::AutowrapMode); VARIANT_ENUM_CAST(Label3D::DrawFlags); VARIANT_ENUM_CAST(Label3D::AlphaCutMode); diff --git a/scene/3d/path_3d.cpp b/scene/3d/path_3d.cpp index 8c2b1c6889..e13cf6f9c8 100644 --- a/scene/3d/path_3d.cpp +++ b/scene/3d/path_3d.cpp @@ -157,10 +157,14 @@ void PathFollow3D::_update_transform(bool p_update_xyz_rot) { // for a discussion about why not Frenet frame. t.origin = pos; - - if (p_update_xyz_rot && delta_offset != 0) { // Only update rotation if some parameter has changed - i.e. not on addition to scene tree. - Vector3 t_prev = (pos - c->interpolate_baked(offset - delta_offset, cubic)).normalized(); - Vector3 t_cur = (c->interpolate_baked(offset + delta_offset, cubic) - pos).normalized(); + if (p_update_xyz_rot && prev_offset != offset) { // Only update rotation if some parameter has changed - i.e. not on addition to scene tree. + real_t sample_distance = bi * 0.01; + Vector3 t_prev_pos_a = c->interpolate_baked(prev_offset - sample_distance, cubic); + Vector3 t_prev_pos_b = c->interpolate_baked(prev_offset + sample_distance, cubic); + Vector3 t_cur_pos_a = c->interpolate_baked(offset - sample_distance, cubic); + Vector3 t_cur_pos_b = c->interpolate_baked(offset + sample_distance, cubic); + Vector3 t_prev = (t_prev_pos_a - t_prev_pos_b).normalized(); + Vector3 t_cur = (t_cur_pos_a - t_cur_pos_b).normalized(); Vector3 axis = t_prev.cross(t_cur); real_t dot = t_prev.dot(t_cur); @@ -303,7 +307,7 @@ void PathFollow3D::_bind_methods() { } void PathFollow3D::set_offset(real_t p_offset) { - delta_offset = p_offset - offset; + prev_offset = offset; offset = p_offset; if (path) { diff --git a/scene/3d/path_3d.h b/scene/3d/path_3d.h index e9ab557693..cb67a044d1 100644 --- a/scene/3d/path_3d.h +++ b/scene/3d/path_3d.h @@ -65,7 +65,7 @@ public: private: Path3D *path = nullptr; - real_t delta_offset = 0.0; // Change in offset since last _update_transform. + real_t prev_offset = 0.0; // Offset during the last _update_transform. real_t offset = 0.0; real_t h_offset = 0.0; real_t v_offset = 0.0; diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index 0d21d82896..1371c9cd57 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -35,7 +35,7 @@ Size2 Button::get_minimum_size() const { Size2 minsize = text_buf->get_size(); - if (clip_text || overrun_behavior != TextParagraph::OVERRUN_NO_TRIMMING) { + if (clip_text || overrun_behavior != TextServer::OVERRUN_NO_TRIMMING) { minsize.width = 0; } @@ -292,9 +292,9 @@ void Button::_notification(int p_what) { icon_ofs.x = 0.0; } int text_clip = size.width - style->get_minimum_size().width - icon_ofs.width; - text_buf->set_width((clip_text || overrun_behavior != TextParagraph::OVERRUN_NO_TRIMMING) ? text_clip : -1); + text_buf->set_width((clip_text || overrun_behavior != TextServer::OVERRUN_NO_TRIMMING) ? text_clip : -1); - int text_width = MAX(1, (clip_text || overrun_behavior != TextParagraph::OVERRUN_NO_TRIMMING) ? MIN(text_clip, text_buf->get_size().x) : text_buf->get_size().x); + int text_width = MAX(1, (clip_text || overrun_behavior != TextServer::OVERRUN_NO_TRIMMING) ? MIN(text_clip, text_buf->get_size().x) : text_buf->get_size().x); if (_internal_margin[SIDE_LEFT] > 0) { text_clip -= _internal_margin[SIDE_LEFT] + get_theme_constant(SNAME("h_separation")); @@ -367,7 +367,7 @@ void Button::_shape() { text_buf->set_text_overrun_behavior(overrun_behavior); } -void Button::set_text_overrun_behavior(TextParagraph::OverrunBehavior p_behavior) { +void Button::set_text_overrun_behavior(TextServer::OverrunBehavior p_behavior) { if (overrun_behavior != p_behavior) { overrun_behavior = p_behavior; _shape(); @@ -377,7 +377,7 @@ void Button::set_text_overrun_behavior(TextParagraph::OverrunBehavior p_behavior } } -TextParagraph::OverrunBehavior Button::get_text_overrun_behavior() const { +TextServer::OverrunBehavior Button::get_text_overrun_behavior() const { return overrun_behavior; } diff --git a/scene/gui/button.h b/scene/gui/button.h index 175785a35c..a1d71195cb 100644 --- a/scene/gui/button.h +++ b/scene/gui/button.h @@ -46,7 +46,7 @@ private: Dictionary opentype_features; String language; TextDirection text_direction = TEXT_DIRECTION_AUTO; - TextParagraph::OverrunBehavior overrun_behavior = TextParagraph::OVERRUN_NO_TRIMMING; + TextServer::OverrunBehavior overrun_behavior = TextServer::OVERRUN_NO_TRIMMING; Ref<Texture2D> icon; bool expand_icon = false; @@ -72,8 +72,8 @@ public: void set_text(const String &p_text); String get_text() const; - void set_text_overrun_behavior(TextParagraph::OverrunBehavior p_behavior); - TextParagraph::OverrunBehavior get_text_overrun_behavior() const; + void set_text_overrun_behavior(TextServer::OverrunBehavior p_behavior); + TextServer::OverrunBehavior get_text_overrun_behavior() const; void set_text_direction(TextDirection p_text_direction); TextDirection get_text_direction() const; diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index 0bb96a18a5..192d214262 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -154,11 +154,11 @@ bool AcceptDialog::get_close_on_escape() const { } void AcceptDialog::set_autowrap(bool p_autowrap) { - label->set_autowrap_mode(p_autowrap ? Label::AUTOWRAP_WORD : Label::AUTOWRAP_OFF); + label->set_autowrap_mode(p_autowrap ? TextServer::AUTOWRAP_WORD : TextServer::AUTOWRAP_OFF); } bool AcceptDialog::has_autowrap() { - return label->get_autowrap_mode() != Label::AUTOWRAP_OFF; + return label->get_autowrap_mode() != TextServer::AUTOWRAP_OFF; } void AcceptDialog::register_text_enter(Control *p_line_edit) { diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index 0c95dabfb5..aeb5338022 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -1550,7 +1550,7 @@ bool ItemList::has_auto_height() const { return auto_height; } -void ItemList::set_text_overrun_behavior(TextParagraph::OverrunBehavior p_behavior) { +void ItemList::set_text_overrun_behavior(TextServer::OverrunBehavior p_behavior) { if (text_overrun_behavior != p_behavior) { text_overrun_behavior = p_behavior; for (int i = 0; i < items.size(); i++) { @@ -1561,7 +1561,7 @@ void ItemList::set_text_overrun_behavior(TextParagraph::OverrunBehavior p_behavi } } -TextParagraph::OverrunBehavior ItemList::get_text_overrun_behavior() const { +TextServer::OverrunBehavior ItemList::get_text_overrun_behavior() const { return text_overrun_behavior; } diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h index ffbe7d055a..a15b090149 100644 --- a/scene/gui/item_list.h +++ b/scene/gui/item_list.h @@ -99,7 +99,7 @@ private: SelectMode select_mode = SELECT_SINGLE; IconMode icon_mode = ICON_MODE_LEFT; VScrollBar *scroll_bar = nullptr; - TextParagraph::OverrunBehavior text_overrun_behavior = TextParagraph::OVERRUN_TRIM_ELLIPSIS; + TextServer::OverrunBehavior text_overrun_behavior = TextServer::OVERRUN_TRIM_ELLIPSIS; uint64_t search_time_msec = 0; String search_string; @@ -188,8 +188,8 @@ public: void set_item_custom_fg_color(int p_idx, const Color &p_custom_fg_color); Color get_item_custom_fg_color(int p_idx) const; - void set_text_overrun_behavior(TextParagraph::OverrunBehavior p_behavior); - TextParagraph::OverrunBehavior get_text_overrun_behavior() const; + void set_text_overrun_behavior(TextServer::OverrunBehavior p_behavior); + TextServer::OverrunBehavior get_text_overrun_behavior() const; void select(int p_idx, bool p_single = true); void deselect(int p_idx); diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index eda3d40f63..82ab7c2e18 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -36,19 +36,19 @@ #include "servers/text_server.h" -void Label::set_autowrap_mode(Label::AutowrapMode p_mode) { +void Label::set_autowrap_mode(TextServer::AutowrapMode p_mode) { if (autowrap_mode != p_mode) { autowrap_mode = p_mode; lines_dirty = true; } update(); - if (clip || overrun_behavior != OVERRUN_NO_TRIMMING) { + if (clip || overrun_behavior != TextServer::OVERRUN_NO_TRIMMING) { update_minimum_size(); } } -Label::AutowrapMode Label::get_autowrap_mode() const { +TextServer::AutowrapMode Label::get_autowrap_mode() const { return autowrap_mode; } @@ -96,7 +96,7 @@ void Label::_shape() { int font_size = get_theme_font_size(SNAME("font_size")); ERR_FAIL_COND(font.is_null()); String text = (uppercase) ? TS->string_to_upper(xl_text, lang) : xl_text; - if (visible_chars >= 0 && visible_chars_behavior == VC_CHARS_BEFORE_SHAPING) { + if (visible_chars >= 0 && visible_chars_behavior == TextServer::VC_CHARS_BEFORE_SHAPING) { text = text.substr(0, visible_chars); } if (dirty) { @@ -121,16 +121,16 @@ void Label::_shape() { uint16_t autowrap_flags = TextServer::BREAK_MANDATORY; switch (autowrap_mode) { - case AUTOWRAP_WORD_SMART: + case TextServer::AUTOWRAP_WORD_SMART: autowrap_flags = TextServer::BREAK_WORD_BOUND_ADAPTIVE | TextServer::BREAK_MANDATORY; break; - case AUTOWRAP_WORD: + case TextServer::AUTOWRAP_WORD: autowrap_flags = TextServer::BREAK_WORD_BOUND | TextServer::BREAK_MANDATORY; break; - case AUTOWRAP_ARBITRARY: + case TextServer::AUTOWRAP_ARBITRARY: autowrap_flags = TextServer::BREAK_GRAPHEME_BOUND | TextServer::BREAK_MANDATORY; break; - case AUTOWRAP_OFF: + case TextServer::AUTOWRAP_OFF: break; } PackedInt32Array line_breaks = TS->shaped_text_get_line_breaks(text_rid, width, 0, autowrap_flags); @@ -146,7 +146,7 @@ void Label::_shape() { return; } - if (autowrap_mode == AUTOWRAP_OFF) { + if (autowrap_mode == TextServer::AUTOWRAP_OFF) { minsize.width = 0.0f; for (int i = 0; i < lines_rid.size(); i++) { if (minsize.width < TS->shaped_text_get_size(lines_rid[i]).x) { @@ -156,31 +156,31 @@ void Label::_shape() { } if (lines_dirty) { - uint16_t overrun_flags = TextServer::OVERRUN_NO_TRIMMING; + uint16_t overrun_flags = TextServer::OVERRUN_NO_TRIM; switch (overrun_behavior) { - case OVERRUN_TRIM_WORD_ELLIPSIS: + case TextServer::OVERRUN_TRIM_WORD_ELLIPSIS: overrun_flags |= TextServer::OVERRUN_TRIM; overrun_flags |= TextServer::OVERRUN_TRIM_WORD_ONLY; overrun_flags |= TextServer::OVERRUN_ADD_ELLIPSIS; break; - case OVERRUN_TRIM_ELLIPSIS: + case TextServer::OVERRUN_TRIM_ELLIPSIS: overrun_flags |= TextServer::OVERRUN_TRIM; overrun_flags |= TextServer::OVERRUN_ADD_ELLIPSIS; break; - case OVERRUN_TRIM_WORD: + case TextServer::OVERRUN_TRIM_WORD: overrun_flags |= TextServer::OVERRUN_TRIM; overrun_flags |= TextServer::OVERRUN_TRIM_WORD_ONLY; break; - case OVERRUN_TRIM_CHAR: + case TextServer::OVERRUN_TRIM_CHAR: overrun_flags |= TextServer::OVERRUN_TRIM; break; - case OVERRUN_NO_TRIMMING: + case TextServer::OVERRUN_NO_TRIMMING: break; } // Fill after min_size calculation. - if (autowrap_mode != AUTOWRAP_OFF) { + if (autowrap_mode != TextServer::AUTOWRAP_OFF) { int visible_lines = get_visible_line_count(); bool lines_hidden = visible_lines > 0 && visible_lines < lines_rid.size(); if (lines_hidden) { @@ -215,7 +215,7 @@ void Label::_shape() { _update_visible(); - if (autowrap_mode == AUTOWRAP_OFF || !clip || overrun_behavior == OVERRUN_NO_TRIMMING) { + if (autowrap_mode == TextServer::AUTOWRAP_OFF || !clip || overrun_behavior == TextServer::OVERRUN_NO_TRIMMING) { update_minimum_size(); } } @@ -326,9 +326,9 @@ void Label::_notification(int p_what) { } int last_line = MIN(lines_rid.size(), lines_visible + lines_skipped); - bool trim_chars = (visible_chars >= 0) && (visible_chars_behavior == VC_CHARS_AFTER_SHAPING); - bool trim_glyphs_ltr = (visible_chars >= 0) && ((visible_chars_behavior == VC_GLYPHS_LTR) || ((visible_chars_behavior == VC_GLYPHS_AUTO) && !rtl_layout)); - bool trim_glyphs_rtl = (visible_chars >= 0) && ((visible_chars_behavior == VC_GLYPHS_RTL) || ((visible_chars_behavior == VC_GLYPHS_AUTO) && rtl_layout)); + bool trim_chars = (visible_chars >= 0) && (visible_chars_behavior == TextServer::VC_CHARS_AFTER_SHAPING); + bool trim_glyphs_ltr = (visible_chars >= 0) && ((visible_chars_behavior == TextServer::VC_GLYPHS_LTR) || ((visible_chars_behavior == TextServer::VC_GLYPHS_AUTO) && !rtl_layout)); + bool trim_glyphs_rtl = (visible_chars >= 0) && ((visible_chars_behavior == TextServer::VC_GLYPHS_RTL) || ((visible_chars_behavior == TextServer::VC_GLYPHS_AUTO) && rtl_layout)); // Get real total height. int total_glyphs = 0; @@ -377,7 +377,7 @@ void Label::_notification(int p_what) { ofs.y += TS->shaped_text_get_ascent(lines_rid[i]) + font->get_spacing(TextServer::SPACING_TOP); switch (horizontal_alignment) { case HORIZONTAL_ALIGNMENT_FILL: - if (rtl && autowrap_mode != AUTOWRAP_OFF) { + if (rtl && autowrap_mode != TextServer::AUTOWRAP_OFF) { ofs.x = int(size.width - style->get_margin(SIDE_RIGHT) - line_size.width); } else { ofs.x = style->get_offset().x; @@ -554,10 +554,10 @@ Size2 Label::get_minimum_size() const { min_size.height = MAX(min_size.height, font->get_height(get_theme_font_size(SNAME("font_size"))) + font->get_spacing(TextServer::SPACING_TOP) + font->get_spacing(TextServer::SPACING_BOTTOM)); Size2 min_style = get_theme_stylebox(SNAME("normal"))->get_minimum_size(); - if (autowrap_mode != AUTOWRAP_OFF) { - return Size2(1, (clip || overrun_behavior != OVERRUN_NO_TRIMMING) ? 1 : min_size.height) + min_style; + if (autowrap_mode != TextServer::AUTOWRAP_OFF) { + return Size2(1, (clip || overrun_behavior != TextServer::OVERRUN_NO_TRIMMING) ? 1 : min_size.height) + min_style; } else { - if (clip || overrun_behavior != OVERRUN_NO_TRIMMING) { + if (clip || overrun_behavior != TextServer::OVERRUN_NO_TRIMMING) { min_size.width = 1; } return min_size + min_style; @@ -719,18 +719,18 @@ bool Label::is_clipping_text() const { return clip; } -void Label::set_text_overrun_behavior(Label::OverrunBehavior p_behavior) { +void Label::set_text_overrun_behavior(TextServer::OverrunBehavior p_behavior) { if (overrun_behavior != p_behavior) { overrun_behavior = p_behavior; lines_dirty = true; } update(); - if (clip || overrun_behavior != OVERRUN_NO_TRIMMING) { + if (clip || overrun_behavior != TextServer::OVERRUN_NO_TRIMMING) { update_minimum_size(); } } -Label::OverrunBehavior Label::get_text_overrun_behavior() const { +TextServer::OverrunBehavior Label::get_text_overrun_behavior() const { return overrun_behavior; } @@ -746,7 +746,7 @@ void Label::set_visible_characters(int p_amount) { } else { percent_visible = 1.0; } - if (visible_chars_behavior == VC_CHARS_BEFORE_SHAPING) { + if (visible_chars_behavior == TextServer::VC_CHARS_BEFORE_SHAPING) { dirty = true; } update(); @@ -766,7 +766,7 @@ void Label::set_percent_visible(float p_percent) { visible_chars = get_total_character_count() * p_percent; percent_visible = p_percent; } - if (visible_chars_behavior == VC_CHARS_BEFORE_SHAPING) { + if (visible_chars_behavior == TextServer::VC_CHARS_BEFORE_SHAPING) { dirty = true; } update(); @@ -777,11 +777,11 @@ float Label::get_percent_visible() const { return percent_visible; } -Label::VisibleCharactersBehavior Label::get_visible_characters_behavior() const { +TextServer::VisibleCharactersBehavior Label::get_visible_characters_behavior() const { return visible_chars_behavior; } -void Label::set_visible_characters_behavior(Label::VisibleCharactersBehavior p_behavior) { +void Label::set_visible_characters_behavior(TextServer::VisibleCharactersBehavior p_behavior) { if (visible_chars_behavior != p_behavior) { visible_chars_behavior = p_behavior; dirty = true; @@ -909,23 +909,6 @@ void Label::_bind_methods() { ClassDB::bind_method(D_METHOD("set_structured_text_bidi_override_options", "args"), &Label::set_structured_text_bidi_override_options); ClassDB::bind_method(D_METHOD("get_structured_text_bidi_override_options"), &Label::get_structured_text_bidi_override_options); - BIND_ENUM_CONSTANT(AUTOWRAP_OFF); - BIND_ENUM_CONSTANT(AUTOWRAP_ARBITRARY); - BIND_ENUM_CONSTANT(AUTOWRAP_WORD); - BIND_ENUM_CONSTANT(AUTOWRAP_WORD_SMART); - - BIND_ENUM_CONSTANT(OVERRUN_NO_TRIMMING); - BIND_ENUM_CONSTANT(OVERRUN_TRIM_CHAR); - BIND_ENUM_CONSTANT(OVERRUN_TRIM_WORD); - BIND_ENUM_CONSTANT(OVERRUN_TRIM_ELLIPSIS); - BIND_ENUM_CONSTANT(OVERRUN_TRIM_WORD_ELLIPSIS); - - BIND_ENUM_CONSTANT(VC_CHARS_BEFORE_SHAPING); - BIND_ENUM_CONSTANT(VC_CHARS_AFTER_SHAPING); - BIND_ENUM_CONSTANT(VC_GLYPHS_AUTO); - BIND_ENUM_CONSTANT(VC_GLYPHS_LTR); - BIND_ENUM_CONSTANT(VC_GLYPHS_RTL); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "text", PROPERTY_HINT_MULTILINE_TEXT, "", PROPERTY_USAGE_DEFAULT_INTL), "set_text", "get_text"); ADD_PROPERTY(PropertyInfo(Variant::INT, "horizontal_alignment", PROPERTY_HINT_ENUM, "Left,Center,Right,Fill"), "set_horizontal_alignment", "get_horizontal_alignment"); ADD_PROPERTY(PropertyInfo(Variant::INT, "vertical_alignment", PROPERTY_HINT_ENUM, "Top,Center,Bottom,Fill"), "set_vertical_alignment", "get_vertical_alignment"); diff --git a/scene/gui/label.h b/scene/gui/label.h index f7b725928f..fac3d75a1b 100644 --- a/scene/gui/label.h +++ b/scene/gui/label.h @@ -36,38 +36,14 @@ class Label : public Control { GDCLASS(Label, Control); -public: - enum AutowrapMode { - AUTOWRAP_OFF, - AUTOWRAP_ARBITRARY, - AUTOWRAP_WORD, - AUTOWRAP_WORD_SMART - }; - - enum OverrunBehavior { - OVERRUN_NO_TRIMMING, - OVERRUN_TRIM_CHAR, - OVERRUN_TRIM_WORD, - OVERRUN_TRIM_ELLIPSIS, - OVERRUN_TRIM_WORD_ELLIPSIS, - }; - - enum VisibleCharactersBehavior { - VC_CHARS_BEFORE_SHAPING, - VC_CHARS_AFTER_SHAPING, - VC_GLYPHS_AUTO, - VC_GLYPHS_LTR, - VC_GLYPHS_RTL, - }; - private: HorizontalAlignment horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT; VerticalAlignment vertical_alignment = VERTICAL_ALIGNMENT_TOP; String text; String xl_text; - AutowrapMode autowrap_mode = AUTOWRAP_OFF; + TextServer::AutowrapMode autowrap_mode = TextServer::AUTOWRAP_OFF; bool clip = false; - OverrunBehavior overrun_behavior = OVERRUN_NO_TRIMMING; + TextServer::OverrunBehavior overrun_behavior = TextServer::OVERRUN_NO_TRIMMING; Size2 minsize; bool uppercase = false; @@ -85,7 +61,7 @@ private: float percent_visible = 1.0; - VisibleCharactersBehavior visible_chars_behavior = VC_CHARS_BEFORE_SHAPING; + TextServer::VisibleCharactersBehavior visible_chars_behavior = TextServer::VC_CHARS_BEFORE_SHAPING; int visible_chars = -1; int lines_skipped = 0; int max_lines_visible = -1; @@ -130,14 +106,14 @@ public: void set_structured_text_bidi_override_options(Array p_args); Array get_structured_text_bidi_override_options() const; - void set_autowrap_mode(AutowrapMode p_mode); - AutowrapMode get_autowrap_mode() const; + void set_autowrap_mode(TextServer::AutowrapMode p_mode); + TextServer::AutowrapMode get_autowrap_mode() const; void set_uppercase(bool p_uppercase); bool is_uppercase() const; - VisibleCharactersBehavior get_visible_characters_behavior() const; - void set_visible_characters_behavior(VisibleCharactersBehavior p_behavior); + TextServer::VisibleCharactersBehavior get_visible_characters_behavior() const; + void set_visible_characters_behavior(TextServer::VisibleCharactersBehavior p_behavior); void set_visible_characters(int p_amount); int get_visible_characters() const; @@ -146,8 +122,8 @@ public: void set_clip_text(bool p_clip); bool is_clipping_text() const; - void set_text_overrun_behavior(OverrunBehavior p_behavior); - OverrunBehavior get_text_overrun_behavior() const; + void set_text_overrun_behavior(TextServer::OverrunBehavior p_behavior); + TextServer::OverrunBehavior get_text_overrun_behavior() const; void set_percent_visible(float p_percent); float get_percent_visible() const; @@ -166,8 +142,4 @@ public: ~Label(); }; -VARIANT_ENUM_CAST(Label::AutowrapMode); -VARIANT_ENUM_CAST(Label::OverrunBehavior); -VARIANT_ENUM_CAST(Label::VisibleCharactersBehavior); - #endif diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 4a0edd85f5..0516c8e722 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -426,16 +426,16 @@ float RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font> uint16_t autowrap_flags = TextServer::BREAK_MANDATORY; switch (autowrap_mode) { - case AUTOWRAP_WORD_SMART: + case TextServer::AUTOWRAP_WORD_SMART: autowrap_flags = TextServer::BREAK_WORD_BOUND_ADAPTIVE | TextServer::BREAK_MANDATORY; break; - case AUTOWRAP_WORD: + case TextServer::AUTOWRAP_WORD: autowrap_flags = TextServer::BREAK_WORD_BOUND | TextServer::BREAK_MANDATORY; break; - case AUTOWRAP_ARBITRARY: + case TextServer::AUTOWRAP_ARBITRARY: autowrap_flags = TextServer::BREAK_GRAPHEME_BOUND | TextServer::BREAK_MANDATORY; break; - case AUTOWRAP_OFF: + case TextServer::AUTOWRAP_OFF: break; } @@ -462,7 +462,7 @@ float RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font> Item *it_to = (p_line + 1 < (int)p_frame->lines.size()) ? p_frame->lines[p_line + 1].from : nullptr; int remaining_characters = visible_characters - l.char_offset; for (Item *it = l.from; it && it != it_to; it = _get_next_item(it)) { - if (visible_chars_behavior == VC_CHARS_BEFORE_SHAPING && visible_characters >= 0 && remaining_characters <= 0) { + if (visible_chars_behavior == TextServer::VC_CHARS_BEFORE_SHAPING && visible_characters >= 0 && remaining_characters <= 0) { break; } switch (it->type) { @@ -501,7 +501,7 @@ float RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font> Dictionary font_ftr = _find_font_features(it); String lang = _find_language(it); String tx = t->text; - if (visible_chars_behavior == VC_CHARS_BEFORE_SHAPING && visible_characters >= 0 && remaining_characters >= 0) { + if (visible_chars_behavior == TextServer::VC_CHARS_BEFORE_SHAPING && visible_characters >= 0 && remaining_characters >= 0) { tx = tx.substr(0, remaining_characters); } remaining_characters -= tx.length(); @@ -707,9 +707,9 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o bool rtl = (l.text_buf->get_direction() == TextServer::DIRECTION_RTL); bool lrtl = is_layout_rtl(); - bool trim_chars = (visible_characters >= 0) && (visible_chars_behavior == VC_CHARS_AFTER_SHAPING); - bool trim_glyphs_ltr = (visible_characters >= 0) && ((visible_chars_behavior == VC_GLYPHS_LTR) || ((visible_chars_behavior == VC_GLYPHS_AUTO) && !lrtl)); - bool trim_glyphs_rtl = (visible_characters >= 0) && ((visible_chars_behavior == VC_GLYPHS_RTL) || ((visible_chars_behavior == VC_GLYPHS_AUTO) && lrtl)); + bool trim_chars = (visible_characters >= 0) && (visible_chars_behavior == TextServer::VC_CHARS_AFTER_SHAPING); + bool trim_glyphs_ltr = (visible_characters >= 0) && ((visible_chars_behavior == TextServer::VC_GLYPHS_LTR) || ((visible_chars_behavior == TextServer::VC_GLYPHS_AUTO) && !lrtl)); + bool trim_glyphs_rtl = (visible_characters >= 0) && ((visible_chars_behavior == TextServer::VC_GLYPHS_RTL) || ((visible_chars_behavior == TextServer::VC_GLYPHS_AUTO) && lrtl)); int total_glyphs = (trim_glyphs_ltr || trim_glyphs_rtl) ? get_total_glyph_count() : 0; int visible_glyphs = total_glyphs * percent_visible; @@ -4752,7 +4752,7 @@ String RichTextLabel::get_language() const { return language; } -void RichTextLabel::set_autowrap_mode(RichTextLabel::AutowrapMode p_mode) { +void RichTextLabel::set_autowrap_mode(TextServer::AutowrapMode p_mode) { if (autowrap_mode != p_mode) { _stop_thread(); @@ -4763,7 +4763,7 @@ void RichTextLabel::set_autowrap_mode(RichTextLabel::AutowrapMode p_mode) { } } -RichTextLabel::AutowrapMode RichTextLabel::get_autowrap_mode() const { +TextServer::AutowrapMode RichTextLabel::get_autowrap_mode() const { return autowrap_mode; } @@ -4778,7 +4778,7 @@ void RichTextLabel::set_percent_visible(float p_percent) { visible_characters = get_total_character_count() * p_percent; percent_visible = p_percent; } - if (visible_chars_behavior == VC_CHARS_BEFORE_SHAPING) { + if (visible_chars_behavior == TextServer::VC_CHARS_BEFORE_SHAPING) { main->first_invalid_line.store(0); //invalidate ALL _validate_line_caches(); } @@ -5032,11 +5032,6 @@ void RichTextLabel::_bind_methods() { ADD_SIGNAL(MethodInfo("finished")); - BIND_ENUM_CONSTANT(AUTOWRAP_OFF); - BIND_ENUM_CONSTANT(AUTOWRAP_ARBITRARY); - BIND_ENUM_CONSTANT(AUTOWRAP_WORD); - BIND_ENUM_CONSTANT(AUTOWRAP_WORD_SMART); - BIND_ENUM_CONSTANT(LIST_NUMBERS); BIND_ENUM_CONSTANT(LIST_LETTERS); BIND_ENUM_CONSTANT(LIST_ROMAN); @@ -5069,19 +5064,13 @@ void RichTextLabel::_bind_methods() { BIND_ENUM_CONSTANT(ITEM_HINT); BIND_ENUM_CONSTANT(ITEM_DROPCAP); BIND_ENUM_CONSTANT(ITEM_CUSTOMFX); - - BIND_ENUM_CONSTANT(VC_CHARS_BEFORE_SHAPING); - BIND_ENUM_CONSTANT(VC_CHARS_AFTER_SHAPING); - BIND_ENUM_CONSTANT(VC_GLYPHS_AUTO); - BIND_ENUM_CONSTANT(VC_GLYPHS_LTR); - BIND_ENUM_CONSTANT(VC_GLYPHS_RTL); } -RichTextLabel::VisibleCharactersBehavior RichTextLabel::get_visible_characters_behavior() const { +TextServer::VisibleCharactersBehavior RichTextLabel::get_visible_characters_behavior() const { return visible_chars_behavior; } -void RichTextLabel::set_visible_characters_behavior(RichTextLabel::VisibleCharactersBehavior p_behavior) { +void RichTextLabel::set_visible_characters_behavior(TextServer::VisibleCharactersBehavior p_behavior) { if (visible_chars_behavior != p_behavior) { _stop_thread(); @@ -5105,7 +5094,7 @@ void RichTextLabel::set_visible_characters(int p_visible) { percent_visible = (float)p_visible / (float)total_char_count; } } - if (visible_chars_behavior == VC_CHARS_BEFORE_SHAPING) { + if (visible_chars_behavior == TextServer::VC_CHARS_BEFORE_SHAPING) { main->first_invalid_line.store(0); //invalidate ALL _validate_line_caches(); } diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h index 93e57058b0..c697320976 100644 --- a/scene/gui/rich_text_label.h +++ b/scene/gui/rich_text_label.h @@ -40,13 +40,6 @@ class RichTextLabel : public Control { GDCLASS(RichTextLabel, Control); public: - enum AutowrapMode { - AUTOWRAP_OFF, - AUTOWRAP_ARBITRARY, - AUTOWRAP_WORD, - AUTOWRAP_WORD_SMART - }; - enum ListType { LIST_NUMBERS, LIST_LETTERS, @@ -84,14 +77,6 @@ public: ITEM_CUSTOMFX }; - enum VisibleCharactersBehavior { - VC_CHARS_BEFORE_SHAPING, - VC_CHARS_AFTER_SHAPING, - VC_GLYPHS_AUTO, - VC_GLYPHS_LTR, - VC_GLYPHS_RTL, - }; - enum MenuItems { MENU_COPY, MENU_SELECT_ALL, @@ -384,7 +369,7 @@ private: VScrollBar *vscroll = nullptr; - AutowrapMode autowrap_mode = AUTOWRAP_WORD_SMART; + TextServer::AutowrapMode autowrap_mode = TextServer::AUTOWRAP_WORD_SMART; bool scroll_visible = false; bool scroll_follow = false; @@ -460,7 +445,7 @@ private: int visible_characters = -1; float percent_visible = 1.0; - VisibleCharactersBehavior visible_chars_behavior = VC_CHARS_BEFORE_SHAPING; + TextServer::VisibleCharactersBehavior visible_chars_behavior = TextServer::VC_CHARS_BEFORE_SHAPING; bool _is_click_inside_selection() const; void _find_click(ItemFrame *p_frame, const Point2i &p_click, ItemFrame **r_click_frame = nullptr, int *r_click_line = nullptr, Item **r_click_item = nullptr, int *r_click_char = nullptr, bool *r_outside = nullptr); @@ -664,8 +649,8 @@ public: void set_language(const String &p_language); String get_language() const; - void set_autowrap_mode(AutowrapMode p_mode); - AutowrapMode get_autowrap_mode() const; + void set_autowrap_mode(TextServer::AutowrapMode p_mode); + TextServer::AutowrapMode get_autowrap_mode() const; void set_structured_text_bidi_override(TextServer::StructuredTextParser p_parser); TextServer::StructuredTextParser get_structured_text_bidi_override() const; @@ -683,8 +668,8 @@ public: void set_percent_visible(float p_percent); float get_percent_visible() const; - VisibleCharactersBehavior get_visible_characters_behavior() const; - void set_visible_characters_behavior(VisibleCharactersBehavior p_behavior); + TextServer::VisibleCharactersBehavior get_visible_characters_behavior() const; + void set_visible_characters_behavior(TextServer::VisibleCharactersBehavior p_behavior); void set_effects(Array p_effects); Array get_effects(); @@ -698,9 +683,7 @@ public: ~RichTextLabel(); }; -VARIANT_ENUM_CAST(RichTextLabel::AutowrapMode); VARIANT_ENUM_CAST(RichTextLabel::ListType); VARIANT_ENUM_CAST(RichTextLabel::ItemType); -VARIANT_ENUM_CAST(RichTextLabel::VisibleCharactersBehavior); #endif // RICH_TEXT_LABEL_H diff --git a/scene/main/window.cpp b/scene/main/window.cpp index 1d697a2176..11c2a495ad 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -111,31 +111,19 @@ Size2i Window::get_real_size() const { void Window::set_max_size(const Size2i &p_max_size) { max_size = p_max_size; - if (window_id != DisplayServer::INVALID_WINDOW_ID) { - DisplayServer::get_singleton()->window_set_max_size(max_size, window_id); - } _update_window_size(); } Size2i Window::get_max_size() const { - if (window_id != DisplayServer::INVALID_WINDOW_ID) { - max_size = DisplayServer::get_singleton()->window_get_max_size(window_id); - } return max_size; } void Window::set_min_size(const Size2i &p_min_size) { min_size = p_min_size; - if (!wrap_controls && window_id != DisplayServer::INVALID_WINDOW_ID) { - DisplayServer::get_singleton()->window_set_min_size(min_size, window_id); - } _update_window_size(); } Size2i Window::get_min_size() const { - if (window_id != DisplayServer::INVALID_WINDOW_ID) { - min_size = DisplayServer::get_singleton()->window_get_min_size(window_id); - } return min_size; } @@ -621,6 +609,7 @@ void Window::_update_window_size() { } else if (window_id != DisplayServer::INVALID_WINDOW_ID) { DisplayServer::get_singleton()->window_set_size(size, window_id); DisplayServer::get_singleton()->window_set_min_size(size_limit, window_id); + DisplayServer::get_singleton()->window_set_max_size(max_size, window_id); } //update the viewport diff --git a/scene/resources/importer_mesh.cpp b/scene/resources/importer_mesh.cpp index 0fbd29b1a6..71640357b9 100644 --- a/scene/resources/importer_mesh.cpp +++ b/scene/resources/importer_mesh.cpp @@ -1185,7 +1185,7 @@ Error ImporterMesh::lightmap_unwrap_cached(const Transform3D &p_base_transform, for (unsigned int i = 0; i < surfaces_tools.size(); i++) { surfaces_tools[i]->index(); Array arrays = surfaces_tools[i]->commit_to_arrays(); - add_surface(surfaces_tools[i]->get_primitive(), arrays, Array(), Dictionary(), surfaces_tools[i]->get_material(), surfaces_tools[i]->get_meta("name")); + add_surface(surfaces_tools[i]->get_primitive_type(), arrays, Array(), Dictionary(), surfaces_tools[i]->get_material(), surfaces_tools[i]->get_meta("name")); } set_lightmap_size_hint(Size2(size_x, size_y)); @@ -1238,6 +1238,7 @@ void ImporterMesh::_bind_methods() { ClassDB::bind_method(D_METHOD("set_surface_name", "surface_idx", "name"), &ImporterMesh::set_surface_name); ClassDB::bind_method(D_METHOD("set_surface_material", "surface_idx", "material"), &ImporterMesh::set_surface_material); + ClassDB::bind_method(D_METHOD("generate_lods", "normal_merge_angle", "normal_split_angle"), &ImporterMesh::generate_lods); ClassDB::bind_method(D_METHOD("get_mesh", "base_mesh"), &ImporterMesh::get_mesh, DEFVAL(Ref<ArrayMesh>())); ClassDB::bind_method(D_METHOD("clear"), &ImporterMesh::clear); diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp index 0e41eed570..77d6e3c6f9 100644 --- a/scene/resources/surface_tool.cpp +++ b/scene/resources/surface_tool.cpp @@ -315,19 +315,17 @@ void SurfaceTool::set_uv2(const Vector2 &p_uv2) { last_uv2 = p_uv2; } -void SurfaceTool::set_custom(int p_index, const Color &p_custom) { - ERR_FAIL_INDEX(p_index, RS::ARRAY_CUSTOM_COUNT); +void SurfaceTool::set_custom(int p_channel_index, const Color &p_custom) { + ERR_FAIL_INDEX(p_channel_index, RS::ARRAY_CUSTOM_COUNT); ERR_FAIL_COND(!begun); - ERR_FAIL_COND(last_custom_format[p_index] == CUSTOM_MAX); + ERR_FAIL_COND(last_custom_format[p_channel_index] == CUSTOM_MAX); static const uint32_t mask[RS::ARRAY_CUSTOM_COUNT] = { Mesh::ARRAY_FORMAT_CUSTOM0, Mesh::ARRAY_FORMAT_CUSTOM1, Mesh::ARRAY_FORMAT_CUSTOM2, Mesh::ARRAY_FORMAT_CUSTOM3 }; - static const uint32_t shift[RS::ARRAY_CUSTOM_COUNT] = { Mesh::ARRAY_FORMAT_CUSTOM0_SHIFT, Mesh::ARRAY_FORMAT_CUSTOM1_SHIFT, Mesh::ARRAY_FORMAT_CUSTOM2_SHIFT, Mesh::ARRAY_FORMAT_CUSTOM3_SHIFT }; - ERR_FAIL_COND(!first && !(format & mask[p_index])); + ERR_FAIL_COND(!first && !(format & mask[p_channel_index])); if (first) { - format |= mask[p_index]; - format |= last_custom_format[p_index] << shift[p_index]; + format |= mask[p_channel_index]; } - last_custom[p_index] = p_custom; + last_custom[p_channel_index] = p_custom; } void SurfaceTool::set_bones(const Vector<int> &p_bones) { @@ -689,7 +687,7 @@ Array SurfaceTool::commit_to_arrays() { return a; } -Ref<ArrayMesh> SurfaceTool::commit(const Ref<ArrayMesh> &p_existing, uint32_t p_flags) { +Ref<ArrayMesh> SurfaceTool::commit(const Ref<ArrayMesh> &p_existing, uint32_t p_compress_flags) { Ref<ArrayMesh> mesh; if (p_existing.is_valid()) { mesh = p_existing; @@ -707,7 +705,15 @@ Ref<ArrayMesh> SurfaceTool::commit(const Ref<ArrayMesh> &p_existing, uint32_t p_ Array a = commit_to_arrays(); - mesh->add_surface_from_arrays(primitive, a, Array(), Dictionary(), p_flags); + uint32_t compress_flags = (p_compress_flags >> RS::ARRAY_COMPRESS_FLAGS_BASE) << RS::ARRAY_COMPRESS_FLAGS_BASE; + static const uint32_t shift[RS::ARRAY_CUSTOM_COUNT] = { Mesh::ARRAY_FORMAT_CUSTOM0_SHIFT, Mesh::ARRAY_FORMAT_CUSTOM1_SHIFT, Mesh::ARRAY_FORMAT_CUSTOM2_SHIFT, Mesh::ARRAY_FORMAT_CUSTOM3_SHIFT }; + for (int i = 0; i < RS::ARRAY_CUSTOM_COUNT; i++) { + if (last_custom_format[i] != CUSTOM_MAX) { + compress_flags |= last_custom_format[i] << shift[i]; + } + } + + mesh->add_surface_from_arrays(primitive, a, Array(), Dictionary(), compress_flags); if (material.is_valid()) { mesh->surface_set_material(surface, material); @@ -988,9 +994,6 @@ void SurfaceTool::append_from(const Ref<Mesh> &p_existing, int p_surface, const for (int j = 0; j < RS::ARRAY_CUSTOM_COUNT; j++) { if (format & custom_mask[j]) { CustomFormat new_format = (CustomFormat)((format >> custom_shift[j]) & RS::ARRAY_FORMAT_CUSTOM_MASK); - if (last_custom_format[j] != CUSTOM_MAX && last_custom_format[j] != new_format) { - WARN_PRINT(vformat("Custom %d format %d mismatch when appending format %d", j, last_custom_format[j], new_format)); - } last_custom_format[j] = new_format; } } @@ -1220,22 +1223,24 @@ SurfaceTool::SkinWeightCount SurfaceTool::get_skin_weight_count() const { return skin_weights; } -void SurfaceTool::set_custom_format(int p_index, CustomFormat p_format) { - ERR_FAIL_INDEX(p_index, RS::ARRAY_CUSTOM_COUNT); - ERR_FAIL_COND(begun); - last_custom_format[p_index] = p_format; +void SurfaceTool::set_custom_format(int p_channel_index, CustomFormat p_format) { + ERR_FAIL_INDEX(p_channel_index, RS::ARRAY_CUSTOM_COUNT); + ERR_FAIL_COND(!begun); + ERR_FAIL_INDEX(p_format, CUSTOM_MAX + 1); + last_custom_format[p_channel_index] = p_format; } -Mesh::PrimitiveType SurfaceTool::get_primitive() const { +Mesh::PrimitiveType SurfaceTool::get_primitive_type() const { return primitive; } -SurfaceTool::CustomFormat SurfaceTool::get_custom_format(int p_index) const { - ERR_FAIL_INDEX_V(p_index, RS::ARRAY_CUSTOM_COUNT, CUSTOM_MAX); - return last_custom_format[p_index]; +SurfaceTool::CustomFormat SurfaceTool::get_custom_format(int p_channel_index) const { + ERR_FAIL_INDEX_V(p_channel_index, RS::ARRAY_CUSTOM_COUNT, CUSTOM_MAX); + return last_custom_format[p_channel_index]; } void SurfaceTool::optimize_indices_for_cache() { ERR_FAIL_COND(optimize_vertex_cache_func == nullptr); ERR_FAIL_COND(index_array.size() == 0); + ERR_FAIL_COND(primitive != Mesh::PRIMITIVE_TRIANGLES); ERR_FAIL_COND(index_array.size() % 3 != 0); LocalVector old_index_array = index_array; @@ -1243,8 +1248,8 @@ void SurfaceTool::optimize_indices_for_cache() { optimize_vertex_cache_func((unsigned int *)index_array.ptr(), (unsigned int *)old_index_array.ptr(), old_index_array.size(), vertex_array.size()); } -float SurfaceTool::get_max_axis_length() const { - ERR_FAIL_COND_V(vertex_array.size() == 0, 0); +AABB SurfaceTool::get_aabb() const { + ERR_FAIL_COND_V(vertex_array.size() == 0, AABB()); AABB aabb; for (uint32_t i = 0; i < vertex_array.size(); i++) { @@ -1255,7 +1260,7 @@ float SurfaceTool::get_max_axis_length() const { } } - return aabb.get_longest_axis_size(); + return aabb; } Vector<int> SurfaceTool::generate_lod(float p_threshold, int p_target_index_count) { Vector<int> lod; @@ -1288,8 +1293,8 @@ void SurfaceTool::_bind_methods() { ClassDB::bind_method(D_METHOD("set_skin_weight_count", "count"), &SurfaceTool::set_skin_weight_count); ClassDB::bind_method(D_METHOD("get_skin_weight_count"), &SurfaceTool::get_skin_weight_count); - ClassDB::bind_method(D_METHOD("set_custom_format", "index", "format"), &SurfaceTool::set_custom_format); - ClassDB::bind_method(D_METHOD("get_custom_format", "index"), &SurfaceTool::get_custom_format); + ClassDB::bind_method(D_METHOD("set_custom_format", "channel_index", "format"), &SurfaceTool::set_custom_format); + ClassDB::bind_method(D_METHOD("get_custom_format", "channel_index"), &SurfaceTool::get_custom_format); ClassDB::bind_method(D_METHOD("begin", "primitive"), &SurfaceTool::begin); @@ -1301,7 +1306,7 @@ void SurfaceTool::_bind_methods() { ClassDB::bind_method(D_METHOD("set_uv2", "uv2"), &SurfaceTool::set_uv2); ClassDB::bind_method(D_METHOD("set_bones", "bones"), &SurfaceTool::set_bones); ClassDB::bind_method(D_METHOD("set_weights", "weights"), &SurfaceTool::set_weights); - ClassDB::bind_method(D_METHOD("set_custom", "index", "custom"), &SurfaceTool::set_custom); + ClassDB::bind_method(D_METHOD("set_custom", "channel_index", "custom_color"), &SurfaceTool::set_custom); ClassDB::bind_method(D_METHOD("set_smooth_group", "index"), &SurfaceTool::set_smooth_group); ClassDB::bind_method(D_METHOD("add_triangle_fan", "vertices", "uvs", "colors", "uv2s", "normals", "tangents"), &SurfaceTool::add_triangle_fan, DEFVAL(Vector<Vector2>()), DEFVAL(Vector<Color>()), DEFVAL(Vector<Vector2>()), DEFVAL(Vector<Vector3>()), DEFVAL(Vector<Plane>())); @@ -1315,11 +1320,11 @@ void SurfaceTool::_bind_methods() { ClassDB::bind_method(D_METHOD("optimize_indices_for_cache"), &SurfaceTool::optimize_indices_for_cache); - ClassDB::bind_method(D_METHOD("get_max_axis_length"), &SurfaceTool::get_max_axis_length); + ClassDB::bind_method(D_METHOD("get_aabb"), &SurfaceTool::get_aabb); ClassDB::bind_method(D_METHOD("generate_lod", "nd_threshold", "target_index_count"), &SurfaceTool::generate_lod, DEFVAL(3)); ClassDB::bind_method(D_METHOD("set_material", "material"), &SurfaceTool::set_material); - ClassDB::bind_method(D_METHOD("get_primitive"), &SurfaceTool::get_primitive); + ClassDB::bind_method(D_METHOD("get_primitive_type"), &SurfaceTool::get_primitive_type); ClassDB::bind_method(D_METHOD("clear"), &SurfaceTool::clear); diff --git a/scene/resources/surface_tool.h b/scene/resources/surface_tool.h index bf4332ad2a..2d399ca3bf 100644 --- a/scene/resources/surface_tool.h +++ b/scene/resources/surface_tool.h @@ -154,10 +154,10 @@ public: void set_skin_weight_count(SkinWeightCount p_weights); SkinWeightCount get_skin_weight_count() const; - void set_custom_format(int p_index, CustomFormat p_format); - CustomFormat get_custom_format(int p_index) const; + void set_custom_format(int p_channel_index, CustomFormat p_format); + CustomFormat get_custom_format(int p_channel_index) const; - Mesh::PrimitiveType get_primitive() const; + Mesh::PrimitiveType get_primitive_type() const; void begin(Mesh::PrimitiveType p_primitive); @@ -166,7 +166,7 @@ public: void set_tangent(const Plane &p_tangent); void set_uv(const Vector2 &p_uv); void set_uv2(const Vector2 &p_uv2); - void set_custom(int p_index, const Color &p_custom); + void set_custom(int p_channel_index, const Color &p_custom); void set_bones(const Vector<int> &p_bones); void set_weights(const Vector<float> &p_weights); void set_smooth_group(uint32_t p_group); @@ -183,7 +183,7 @@ public: void generate_tangents(); void optimize_indices_for_cache(); - float get_max_axis_length() const; + AABB get_aabb() const; Vector<int> generate_lod(float p_threshold, int p_target_index_count = 3); void set_material(const Ref<Material> &p_material); @@ -199,7 +199,7 @@ public: void create_from(const Ref<Mesh> &p_existing, int p_surface); void create_from_blend_shape(const Ref<Mesh> &p_existing, int p_surface, const String &p_blend_shape_name); void append_from(const Ref<Mesh> &p_existing, int p_surface, const Transform3D &p_xform); - Ref<ArrayMesh> commit(const Ref<ArrayMesh> &p_existing = Ref<ArrayMesh>(), uint32_t p_flags = 0); + Ref<ArrayMesh> commit(const Ref<ArrayMesh> &p_existing = Ref<ArrayMesh>(), uint32_t p_compress_flags = 0); SurfaceTool(); }; diff --git a/scene/resources/text_line.cpp b/scene/resources/text_line.cpp index f9390ca528..d6e7ca3478 100644 --- a/scene/resources/text_line.cpp +++ b/scene/resources/text_line.cpp @@ -98,12 +98,6 @@ void TextLine::_bind_methods() { ClassDB::bind_method(D_METHOD("draw_outline", "canvas", "pos", "outline_size", "color"), &TextLine::draw_outline, DEFVAL(1), DEFVAL(Color(1, 1, 1))); ClassDB::bind_method(D_METHOD("hit_test", "coords"), &TextLine::hit_test); - - BIND_ENUM_CONSTANT(OVERRUN_NO_TRIMMING); - BIND_ENUM_CONSTANT(OVERRUN_TRIM_CHAR); - BIND_ENUM_CONSTANT(OVERRUN_TRIM_WORD); - BIND_ENUM_CONSTANT(OVERRUN_TRIM_ELLIPSIS); - BIND_ENUM_CONSTANT(OVERRUN_TRIM_WORD_ELLIPSIS); } void TextLine::_shape() { @@ -112,26 +106,26 @@ void TextLine::_shape() { TS->shaped_text_tab_align(rid, tab_stops); } - uint16_t overrun_flags = TextServer::OVERRUN_NO_TRIMMING; - if (overrun_behavior != OVERRUN_NO_TRIMMING) { + uint16_t overrun_flags = TextServer::OVERRUN_NO_TRIM; + if (overrun_behavior != TextServer::OVERRUN_NO_TRIMMING) { switch (overrun_behavior) { - case OVERRUN_TRIM_WORD_ELLIPSIS: + case TextServer::OVERRUN_TRIM_WORD_ELLIPSIS: overrun_flags |= TextServer::OVERRUN_TRIM; overrun_flags |= TextServer::OVERRUN_TRIM_WORD_ONLY; overrun_flags |= TextServer::OVERRUN_ADD_ELLIPSIS; break; - case OVERRUN_TRIM_ELLIPSIS: + case TextServer::OVERRUN_TRIM_ELLIPSIS: overrun_flags |= TextServer::OVERRUN_TRIM; overrun_flags |= TextServer::OVERRUN_ADD_ELLIPSIS; break; - case OVERRUN_TRIM_WORD: + case TextServer::OVERRUN_TRIM_WORD: overrun_flags |= TextServer::OVERRUN_TRIM; overrun_flags |= TextServer::OVERRUN_TRIM_WORD_ONLY; break; - case OVERRUN_TRIM_CHAR: + case TextServer::OVERRUN_TRIM_CHAR: overrun_flags |= TextServer::OVERRUN_TRIM; break; - case OVERRUN_NO_TRIMMING: + case TextServer::OVERRUN_NO_TRIMMING: break; } @@ -259,20 +253,20 @@ uint16_t TextLine::get_flags() const { return flags; } -void TextLine::set_text_overrun_behavior(TextLine::OverrunBehavior p_behavior) { +void TextLine::set_text_overrun_behavior(TextServer::OverrunBehavior p_behavior) { if (overrun_behavior != p_behavior) { overrun_behavior = p_behavior; dirty = true; } } -TextLine::OverrunBehavior TextLine::get_text_overrun_behavior() const { +TextServer::OverrunBehavior TextLine::get_text_overrun_behavior() const { return overrun_behavior; } void TextLine::set_width(float p_width) { width = p_width; - if (alignment == HORIZONTAL_ALIGNMENT_FILL || overrun_behavior != OVERRUN_NO_TRIMMING) { + if (alignment == HORIZONTAL_ALIGNMENT_FILL || overrun_behavior != TextServer::OVERRUN_NO_TRIMMING) { dirty = true; } } diff --git a/scene/resources/text_line.h b/scene/resources/text_line.h index c5762db0f2..784ee8ef26 100644 --- a/scene/resources/text_line.h +++ b/scene/resources/text_line.h @@ -39,15 +39,6 @@ class TextLine : public RefCounted { GDCLASS(TextLine, RefCounted); -public: - enum OverrunBehavior { - OVERRUN_NO_TRIMMING, - OVERRUN_TRIM_CHAR, - OVERRUN_TRIM_WORD, - OVERRUN_TRIM_ELLIPSIS, - OVERRUN_TRIM_WORD_ELLIPSIS, - }; - private: RID rid; int spacing_top = 0; @@ -58,7 +49,7 @@ private: float width = -1.0; uint16_t flags = TextServer::JUSTIFICATION_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA; HorizontalAlignment alignment = HORIZONTAL_ALIGNMENT_LEFT; - OverrunBehavior overrun_behavior = OVERRUN_TRIM_ELLIPSIS; + TextServer::OverrunBehavior overrun_behavior = TextServer::OVERRUN_TRIM_ELLIPSIS; Vector<float> tab_stops; @@ -98,8 +89,8 @@ public: void set_flags(uint16_t p_flags); uint16_t get_flags() const; - void set_text_overrun_behavior(OverrunBehavior p_behavior); - OverrunBehavior get_text_overrun_behavior() const; + void set_text_overrun_behavior(TextServer::OverrunBehavior p_behavior); + TextServer::OverrunBehavior get_text_overrun_behavior() const; void set_width(float p_width); float get_width() const; @@ -125,6 +116,4 @@ public: ~TextLine(); }; -VARIANT_ENUM_CAST(TextLine::OverrunBehavior); - #endif // TEXT_LINE_H diff --git a/scene/resources/text_paragraph.cpp b/scene/resources/text_paragraph.cpp index 477b41efaa..874992ea3d 100644 --- a/scene/resources/text_paragraph.cpp +++ b/scene/resources/text_paragraph.cpp @@ -129,12 +129,6 @@ void TextParagraph::_bind_methods() { ClassDB::bind_method(D_METHOD("draw_dropcap_outline", "canvas", "pos", "outline_size", "color"), &TextParagraph::draw_dropcap_outline, DEFVAL(1), DEFVAL(Color(1, 1, 1))); ClassDB::bind_method(D_METHOD("hit_test", "coords"), &TextParagraph::hit_test); - - BIND_ENUM_CONSTANT(OVERRUN_NO_TRIMMING); - BIND_ENUM_CONSTANT(OVERRUN_TRIM_CHAR); - BIND_ENUM_CONSTANT(OVERRUN_TRIM_WORD); - BIND_ENUM_CONSTANT(OVERRUN_TRIM_ELLIPSIS); - BIND_ENUM_CONSTANT(OVERRUN_TRIM_WORD_ELLIPSIS); } void TextParagraph::_shape_lines() { @@ -190,26 +184,26 @@ void TextParagraph::_shape_lines() { lines_rid.push_back(line); } - uint16_t overrun_flags = TextServer::OVERRUN_NO_TRIMMING; - if (overrun_behavior != OVERRUN_NO_TRIMMING) { + uint16_t overrun_flags = TextServer::OVERRUN_NO_TRIM; + if (overrun_behavior != TextServer::OVERRUN_NO_TRIMMING) { switch (overrun_behavior) { - case OVERRUN_TRIM_WORD_ELLIPSIS: + case TextServer::OVERRUN_TRIM_WORD_ELLIPSIS: overrun_flags |= TextServer::OVERRUN_TRIM; overrun_flags |= TextServer::OVERRUN_TRIM_WORD_ONLY; overrun_flags |= TextServer::OVERRUN_ADD_ELLIPSIS; break; - case OVERRUN_TRIM_ELLIPSIS: + case TextServer::OVERRUN_TRIM_ELLIPSIS: overrun_flags |= TextServer::OVERRUN_TRIM; overrun_flags |= TextServer::OVERRUN_ADD_ELLIPSIS; break; - case OVERRUN_TRIM_WORD: + case TextServer::OVERRUN_TRIM_WORD: overrun_flags |= TextServer::OVERRUN_TRIM; overrun_flags |= TextServer::OVERRUN_TRIM_WORD_ONLY; break; - case OVERRUN_TRIM_CHAR: + case TextServer::OVERRUN_TRIM_CHAR: overrun_flags |= TextServer::OVERRUN_TRIM; break; - case OVERRUN_NO_TRIMMING: + case TextServer::OVERRUN_NO_TRIMMING: break; } } @@ -451,7 +445,7 @@ uint16_t TextParagraph::get_flags() const { return flags; } -void TextParagraph::set_text_overrun_behavior(TextParagraph::OverrunBehavior p_behavior) { +void TextParagraph::set_text_overrun_behavior(TextServer::OverrunBehavior p_behavior) { _THREAD_SAFE_METHOD_ if (overrun_behavior != p_behavior) { @@ -460,7 +454,7 @@ void TextParagraph::set_text_overrun_behavior(TextParagraph::OverrunBehavior p_b } } -TextParagraph::OverrunBehavior TextParagraph::get_text_overrun_behavior() const { +TextServer::OverrunBehavior TextParagraph::get_text_overrun_behavior() const { return overrun_behavior; } diff --git a/scene/resources/text_paragraph.h b/scene/resources/text_paragraph.h index 4f1aad16b5..bdcc2b5701 100644 --- a/scene/resources/text_paragraph.h +++ b/scene/resources/text_paragraph.h @@ -41,15 +41,6 @@ class TextParagraph : public RefCounted { GDCLASS(TextParagraph, RefCounted); _THREAD_SAFE_CLASS_ -public: - enum OverrunBehavior { - OVERRUN_NO_TRIMMING, - OVERRUN_TRIM_CHAR, - OVERRUN_TRIM_WORD, - OVERRUN_TRIM_ELLIPSIS, - OVERRUN_TRIM_WORD_ELLIPSIS, - }; - private: RID dropcap_rid; int dropcap_lines = 0; @@ -66,7 +57,7 @@ private: int max_lines_visible = -1; uint16_t flags = TextServer::BREAK_MANDATORY | TextServer::BREAK_WORD_BOUND | TextServer::JUSTIFICATION_WORD_BOUND | TextServer::JUSTIFICATION_KASHIDA; - OverrunBehavior overrun_behavior = OVERRUN_NO_TRIMMING; + TextServer::OverrunBehavior overrun_behavior = TextServer::OVERRUN_NO_TRIMMING; HorizontalAlignment alignment = HORIZONTAL_ALIGNMENT_LEFT; @@ -116,8 +107,8 @@ public: void set_flags(uint16_t p_flags); uint16_t get_flags() const; - void set_text_overrun_behavior(OverrunBehavior p_behavior); - OverrunBehavior get_text_overrun_behavior() const; + void set_text_overrun_behavior(TextServer::OverrunBehavior p_behavior); + TextServer::OverrunBehavior get_text_overrun_behavior() const; void set_width(float p_width); float get_width() const; @@ -165,6 +156,4 @@ public: ~TextParagraph(); }; -VARIANT_ENUM_CAST(TextParagraph::OverrunBehavior); - #endif // TEXT_PARAGRAPH_H diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp index 0ab9ef7e16..b8eac6de00 100644 --- a/scene/resources/visual_shader.cpp +++ b/scene/resources/visual_shader.cpp @@ -712,86 +712,6 @@ VisualShader::VaryingType VisualShader::get_varying_type(const String &p_name) { return varyings[p_name].type; } -void VisualShader::set_engine_version(const Dictionary &p_engine_version) { - ERR_FAIL_COND(!p_engine_version.has("major")); - ERR_FAIL_COND(!p_engine_version.has("minor")); - engine_version["major"] = p_engine_version["major"]; - engine_version["minor"] = p_engine_version["minor"]; -} - -Dictionary VisualShader::get_engine_version() const { - return engine_version; -} - -#ifndef DISABLE_DEPRECATED - -void VisualShader::update_engine_version(const Dictionary &p_new_version) { - if (engine_version.is_empty()) { // before 4.0 - for (int i = 0; i < TYPE_MAX; i++) { - for (KeyValue<int, Node> &E : graph[i].nodes) { - Ref<VisualShaderNodeInput> input = Object::cast_to<VisualShaderNodeInput>(E.value.node.ptr()); - if (input.is_valid()) { - if (input->get_input_name() == "side") { - input->set_input_name("front_facing"); - } - } - Ref<VisualShaderNodeExpression> expression = Object::cast_to<VisualShaderNodeExpression>(E.value.node.ptr()); - if (expression.is_valid()) { - for (int j = 0; j < expression->get_input_port_count(); j++) { - int type = expression->get_input_port_type(j); - if (type > 0) { // + PORT_TYPE_SCALAR_INT + PORT_TYPE_VECTOR_2D - type += 2; - } - expression->set_input_port_type(j, type); - } - for (int j = 0; j < expression->get_output_port_count(); j++) { - int type = expression->get_output_port_type(j); - if (type > 0) { // + PORT_TYPE_SCALAR_INT + PORT_TYPE_VECTOR_2D - type += 2; - } - expression->set_output_port_type(j, type); - } - } - Ref<VisualShaderNodeStep> step = Object::cast_to<VisualShaderNodeStep>(E.value.node.ptr()); - if (step.is_valid()) { - int op_type = int(step->get_op_type()); - if (int(op_type) > 0) { // + OP_TYPE_VECTOR_2D + OP_TYPE_VECTOR_2D_SCALAR - op_type += 2; - } - step->set_op_type(VisualShaderNodeStep::OpType(op_type)); - } - Ref<VisualShaderNodeSmoothStep> sstep = Object::cast_to<VisualShaderNodeSmoothStep>(E.value.node.ptr()); - if (sstep.is_valid()) { - int op_type = int(sstep->get_op_type()); - if (int(op_type) > 0) { // + OP_TYPE_VECTOR_2D + OP_TYPE_VECTOR_2D_SCALAR - op_type += 2; - } - sstep->set_op_type(VisualShaderNodeSmoothStep::OpType(op_type)); - } - Ref<VisualShaderNodeMix> mix = Object::cast_to<VisualShaderNodeMix>(E.value.node.ptr()); - if (mix.is_valid()) { - int op_type = int(mix->get_op_type()); - if (int(op_type) > 0) { // + OP_TYPE_VECTOR_2D + OP_TYPE_VECTOR_2D_SCALAR - op_type += 2; - } - mix->set_op_type(VisualShaderNodeMix::OpType(op_type)); - } - Ref<VisualShaderNodeCompare> compare = Object::cast_to<VisualShaderNodeCompare>(E.value.node.ptr()); - if (compare.is_valid()) { - int ctype = int(compare->get_comparison_type()); - if (int(ctype) > 0) { // + CTYPE_SCALAR_INT + CTYPE_VECTOR_2D - ctype += 2; - } - compare->set_comparison_type(VisualShaderNodeCompare::ComparisonType(ctype)); - } - } - } - } - set_engine_version(p_new_version); -} - -#endif /* DISABLE_DEPRECATED */ - void VisualShader::add_node(Type p_type, const Ref<VisualShaderNode> &p_node, const Vector2 &p_position, int p_id) { ERR_FAIL_COND(p_node.is_null()); ERR_FAIL_COND(p_id < 2); @@ -2628,9 +2548,6 @@ void VisualShader::_bind_methods() { ClassDB::bind_method(D_METHOD("get_node_connections", "type"), &VisualShader::_get_node_connections); - ClassDB::bind_method(D_METHOD("set_engine_version", "version"), &VisualShader::set_engine_version); - ClassDB::bind_method(D_METHOD("get_engine_version"), &VisualShader::get_engine_version); - ClassDB::bind_method(D_METHOD("set_graph_offset", "offset"), &VisualShader::set_graph_offset); ClassDB::bind_method(D_METHOD("get_graph_offset"), &VisualShader::get_graph_offset); @@ -2641,7 +2558,6 @@ void VisualShader::_bind_methods() { ClassDB::bind_method(D_METHOD("_update_shader"), &VisualShader::_update_shader); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "graph_offset", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_graph_offset", "get_graph_offset"); - ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "engine_version", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_engine_version", "get_engine_version"); ADD_PROPERTY_DEFAULT("code", ""); // Inherited from Shader, prevents showing default code as override in docs. diff --git a/scene/resources/visual_shader.h b/scene/resources/visual_shader.h index 925dff31af..afd84e49cc 100644 --- a/scene/resources/visual_shader.h +++ b/scene/resources/visual_shader.h @@ -44,8 +44,6 @@ class VisualShader : public Shader { friend class VisualShaderNodeVersionChecker; - Dictionary engine_version; - public: enum Type { TYPE_VERTEX, @@ -177,14 +175,6 @@ public: // internal methods void set_shader_type(Type p_type); Type get_shader_type() const; -public: - void set_engine_version(const Dictionary &p_version); - Dictionary get_engine_version() const; - -#ifndef DISABLE_DEPRECATED - void update_engine_version(const Dictionary &p_new_version); -#endif /* DISABLE_DEPRECATED */ - enum { NODE_ID_INVALID = -1, NODE_ID_OUTPUT = 0, |