diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/basis_universal/image_compress_basisu.cpp | 6 | ||||
-rw-r--r-- | modules/multiplayer/multiplayer_synchronizer.cpp | 2 | ||||
-rw-r--r-- | modules/navigation/2d/nav_mesh_generator_2d.cpp | 12 | ||||
-rw-r--r-- | modules/text_server_adv/text_server_adv.cpp | 154 | ||||
-rw-r--r-- | modules/text_server_fb/text_server_fb.cpp | 132 |
5 files changed, 189 insertions, 117 deletions
diff --git a/modules/basis_universal/image_compress_basisu.cpp b/modules/basis_universal/image_compress_basisu.cpp index d8ef1c0414..216fa6c9a2 100644 --- a/modules/basis_universal/image_compress_basisu.cpp +++ b/modules/basis_universal/image_compress_basisu.cpp @@ -65,6 +65,12 @@ Vector<uint8_t> basis_universal_packer(const Ref<Image> &p_image, Image::UsedCha params.m_multithreading = true; params.m_check_for_alpha = false; + if (!OS::get_singleton()->is_stdout_verbose()) { + params.m_print_stats = false; + params.m_compute_stats = false; + params.m_status_output = false; + } + basisu::job_pool job_pool(OS::get_singleton()->get_processor_count()); params.m_pJob_pool = &job_pool; diff --git a/modules/multiplayer/multiplayer_synchronizer.cpp b/modules/multiplayer/multiplayer_synchronizer.cpp index ca3fa43207..852975b8eb 100644 --- a/modules/multiplayer/multiplayer_synchronizer.cpp +++ b/modules/multiplayer/multiplayer_synchronizer.cpp @@ -270,7 +270,7 @@ void MultiplayerSynchronizer::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "root_path"), "set_root_path", "get_root_path"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "replication_interval", PROPERTY_HINT_RANGE, "0,5,0.001,suffix:s"), "set_replication_interval", "get_replication_interval"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "delta_interval", PROPERTY_HINT_RANGE, "0,5,0.001,suffix:s"), "set_delta_interval", "get_delta_interval"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "replication_config", PROPERTY_HINT_RESOURCE_TYPE, "SceneReplicationConfig", PROPERTY_USAGE_NO_EDITOR), "set_replication_config", "get_replication_config"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "replication_config", PROPERTY_HINT_RESOURCE_TYPE, "SceneReplicationConfig", PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT), "set_replication_config", "get_replication_config"); ADD_PROPERTY(PropertyInfo(Variant::INT, "visibility_update_mode", PROPERTY_HINT_ENUM, "Idle,Physics,None"), "set_visibility_update_mode", "get_visibility_update_mode"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "public_visibility"), "set_visibility_public", "is_visibility_public"); diff --git a/modules/navigation/2d/nav_mesh_generator_2d.cpp b/modules/navigation/2d/nav_mesh_generator_2d.cpp index aa4c797723..8c2fb42463 100644 --- a/modules/navigation/2d/nav_mesh_generator_2d.cpp +++ b/modules/navigation/2d/nav_mesh_generator_2d.cpp @@ -1010,8 +1010,7 @@ void NavMeshGenerator2D::generator_bake_from_source_geometry_data(Ref<Navigation } if (new_baked_outlines.size() == 0) { - p_navigation_mesh->set_vertices(Vector<Vector2>()); - p_navigation_mesh->clear_polygons(); + p_navigation_mesh->clear(); return; } @@ -1045,8 +1044,7 @@ void NavMeshGenerator2D::generator_bake_from_source_geometry_data(Ref<Navigation TPPLPartition tpart; if (tpart.ConvexPartition_HM(&tppl_in_polygon, &tppl_out_polygon) == 0) { //failed! ERR_PRINT("NavigationPolygon Convex partition failed. Unable to create a valid NavigationMesh from defined polygon outline paths."); - p_navigation_mesh->set_vertices(Vector<Vector2>()); - p_navigation_mesh->clear_polygons(); + p_navigation_mesh->clear(); return; } @@ -1071,11 +1069,7 @@ void NavMeshGenerator2D::generator_bake_from_source_geometry_data(Ref<Navigation new_polygons.push_back(new_polygon); } - p_navigation_mesh->set_vertices(new_vertices); - p_navigation_mesh->clear_polygons(); - for (int i = 0; i < new_polygons.size(); i++) { - p_navigation_mesh->add_polygon(new_polygons[i]); - } + p_navigation_mesh->set_data(new_vertices, new_polygons); } #endif // CLIPPER2_ENABLED diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp index 33ba2da761..0c87199635 100644 --- a/modules/text_server_adv/text_server_adv.cpp +++ b/modules/text_server_adv/text_server_adv.cpp @@ -7048,10 +7048,10 @@ PackedInt32Array TextServerAdvanced::_string_get_word_breaks(const String &p_str HashSet<int> breaks; UErrorCode err = U_ZERO_ERROR; - UBreakIterator *bi = ubrk_open(UBRK_LINE, lang.ascii().get_data(), (const UChar *)utf16.get_data(), utf16.length(), &err); + UBreakIterator *bi = ubrk_open(UBRK_WORD, lang.ascii().get_data(), (const UChar *)utf16.get_data(), utf16.length(), &err); if (U_SUCCESS(err)) { while (ubrk_next(bi) != UBRK_DONE) { - int pos = _convert_pos(p_string, utf16, ubrk_current(bi)) - 1; + int pos = _convert_pos(p_string, utf16, ubrk_current(bi)); if (pos != p_string.length() - 1) { breaks.insert(pos); } @@ -7061,79 +7061,111 @@ PackedInt32Array TextServerAdvanced::_string_get_word_breaks(const String &p_str PackedInt32Array ret; - int line_start = 0; - int line_end = 0; // End of last word on current line. - int word_start = 0; // -1 if no word encountered. Leading spaces are part of a word. - int word_length = 0; + if (p_chars_per_line > 0) { + int line_start = 0; + int last_break = -1; + int line_length = 0; - for (int i = 0; i < p_string.length(); i++) { - const char32_t c = p_string[i]; + for (int i = 0; i < p_string.length(); i++) { + const char32_t c = p_string[i]; - if (is_linebreak(c)) { - // Force newline. - ret.push_back(line_start); - ret.push_back(i); - line_start = i + 1; - line_end = line_start; - word_start = line_start; - word_length = 0; - } else if (c == 0xfffc) { - continue; - } else if ((u_ispunct(c) && c != 0x005F) || is_underscore(c) || c == '\t' || is_whitespace(c)) { - // A whitespace ends current word. - if (word_length > 0) { - line_end = i - 1; - word_start = -1; - word_length = 0; - } - } else if (breaks.has(i)) { - // End current word, no space. - if (word_length > 0) { - line_end = i; - word_start = i + 1; - word_length = 0; - } - if (p_chars_per_line <= 0) { - ret.push_back(line_start); - ret.push_back(line_end + 1); - line_start = word_start; - line_end = line_start; - } - } else { - if (word_start == -1) { - word_start = i; - if (p_chars_per_line <= 0) { + bool is_lb = is_linebreak(c); + bool is_ws = is_whitespace(c); + bool is_p = (u_ispunct(c) && c != 0x005F) || is_underscore(c) || c == '\t' || c == 0xfffc; + + if (is_lb) { + if (line_length > 0) { ret.push_back(line_start); - ret.push_back(line_end + 1); - line_start = word_start; - line_end = line_start; + ret.push_back(i); } + line_start = i; + line_length = 0; + last_break = -1; + continue; + } else if (breaks.has(i) || is_ws || is_p) { + last_break = i; } - word_length += 1; - if (p_chars_per_line > 0) { - if (word_length > p_chars_per_line) { - // Word too long: wrap before current character. + if (line_length == p_chars_per_line) { + if (last_break != -1) { + int last_break_w_spaces = last_break; + while (last_break > line_start && is_whitespace(p_string[last_break - 1])) { + last_break--; + } + if (line_start != last_break) { + ret.push_back(line_start); + ret.push_back(last_break); + } + while (last_break_w_spaces < p_string.length() && is_whitespace(p_string[last_break_w_spaces])) { + last_break_w_spaces++; + } + line_start = last_break_w_spaces; + if (last_break_w_spaces < i) { + line_length = i - last_break_w_spaces; + } else { + i = last_break_w_spaces; + line_length = 0; + } + } else { ret.push_back(line_start); ret.push_back(i); line_start = i; - line_end = i; + line_length = 0; + } + last_break = -1; + } + line_length++; + } + if (line_length > 0) { + ret.push_back(line_start); + ret.push_back(p_string.length()); + } + } else { + int word_start = 0; // -1 if no word encountered. Leading spaces are part of a word. + int word_length = 0; + + for (int i = 0; i < p_string.length(); i++) { + const char32_t c = p_string[i]; + + bool is_lb = is_linebreak(c); + bool is_ws = is_whitespace(c); + bool is_p = (u_ispunct(c) && c != 0x005F) || is_underscore(c) || c == '\t' || c == 0xfffc; + + if (word_start == -1) { + if (!is_lb && !is_ws && !is_p) { word_start = i; - word_length = 1; - } else if (i - line_start + 1 > p_chars_per_line) { - // Line too long: wrap after the last word. - ret.push_back(line_start); - ret.push_back(line_end + 1); - line_start = word_start; - line_end = line_start; } + continue; + } + + if (is_lb) { + if (word_start != -1 && word_length > 0) { + ret.push_back(word_start); + ret.push_back(i); + } + word_start = -1; + word_length = 0; + } else if (breaks.has(i) || is_ws || is_p) { + if (word_start != -1 && word_length > 0) { + ret.push_back(word_start); + ret.push_back(i); + } + if (is_ws || is_p) { + word_start = -1; + } else { + word_start = i; + } + word_length = 0; } + + word_length++; + } + if (word_start != -1 && word_length > 0) { + ret.push_back(word_start); + ret.push_back(p_string.length()); } } - if (line_start < p_string.length()) { - ret.push_back(line_start); - ret.push_back(p_string.length()); - } + return ret; } diff --git a/modules/text_server_fb/text_server_fb.cpp b/modules/text_server_fb/text_server_fb.cpp index 697c3366c5..6cf6b236ed 100644 --- a/modules/text_server_fb/text_server_fb.cpp +++ b/modules/text_server_fb/text_server_fb.cpp @@ -4492,65 +4492,105 @@ String TextServerFallback::_string_to_title(const String &p_string, const String PackedInt32Array TextServerFallback::_string_get_word_breaks(const String &p_string, const String &p_language, int64_t p_chars_per_line) const { PackedInt32Array ret; - int line_start = 0; - int line_end = 0; // End of last word on current line. - int word_start = 0; // -1 if no word encountered. Leading spaces are part of a word. - int word_length = 0; + if (p_chars_per_line > 0) { + int line_start = 0; + int last_break = -1; + int line_length = 0; - for (int i = 0; i < p_string.length(); i++) { - const char32_t c = p_string[i]; + for (int i = 0; i < p_string.length(); i++) { + const char32_t c = p_string[i]; - if (is_linebreak(c)) { - // Force newline. - ret.push_back(line_start); - ret.push_back(i); - line_start = i + 1; - line_end = line_start; - word_start = line_start; - word_length = 0; - } else if (c == 0xfffc) { - continue; - } else if ((is_punct(c) && c != 0x005F) || is_underscore(c) || c == '\t' || is_whitespace(c)) { - // A whitespace ends current word. - if (word_length > 0) { - line_end = i - 1; - word_start = -1; - word_length = 0; - } - } else { - if (word_start == -1) { - word_start = i; - if (p_chars_per_line <= 0) { + bool is_lb = is_linebreak(c); + bool is_ws = is_whitespace(c); + bool is_p = (is_punct(c) && c != 0x005F) || is_underscore(c) || c == '\t' || c == 0xfffc; + + if (is_lb) { + if (line_length > 0) { ret.push_back(line_start); - ret.push_back(line_end + 1); - line_start = word_start; - line_end = line_start; + ret.push_back(i); } + line_start = i; + line_length = 0; + last_break = -1; + continue; + } else if (is_ws || is_p) { + last_break = i; } - word_length += 1; - if (p_chars_per_line > 0) { - if (word_length > p_chars_per_line) { - // Word too long: wrap before current character. + if (line_length == p_chars_per_line) { + if (last_break != -1) { + int last_break_w_spaces = last_break; + while (last_break > line_start && is_whitespace(p_string[last_break - 1])) { + last_break--; + } + if (line_start != last_break) { + ret.push_back(line_start); + ret.push_back(last_break); + } + while (last_break_w_spaces < p_string.length() && is_whitespace(p_string[last_break_w_spaces])) { + last_break_w_spaces++; + } + line_start = last_break_w_spaces; + if (last_break_w_spaces < i) { + line_length = i - last_break_w_spaces; + } else { + i = last_break_w_spaces; + line_length = 0; + } + } else { ret.push_back(line_start); ret.push_back(i); line_start = i; - line_end = i; + line_length = 0; + } + last_break = -1; + } + line_length++; + } + if (line_length > 0) { + ret.push_back(line_start); + ret.push_back(p_string.length()); + } + } else { + int word_start = 0; // -1 if no word encountered. Leading spaces are part of a word. + int word_length = 0; + + for (int i = 0; i < p_string.length(); i++) { + const char32_t c = p_string[i]; + + bool is_lb = is_linebreak(c); + bool is_ws = is_whitespace(c); + bool is_p = (is_punct(c) && c != 0x005F) || is_underscore(c) || c == '\t' || c == 0xfffc; + + if (word_start == -1) { + if (!is_lb && !is_ws && !is_p) { word_start = i; - word_length = 1; - } else if (i - line_start + 1 > p_chars_per_line) { - // Line too long: wrap after the last word. - ret.push_back(line_start); - ret.push_back(line_end + 1); - line_start = word_start; - line_end = line_start; } + continue; } + + if (is_lb) { + if (word_start != -1 && word_length > 0) { + ret.push_back(word_start); + ret.push_back(i); + } + word_start = -1; + word_length = 0; + } else if (is_ws || is_p) { + if (word_start != -1 && word_length > 0) { + ret.push_back(word_start); + ret.push_back(i); + } + word_start = -1; + word_length = 0; + } + + word_length++; + } + if (word_start != -1 && word_length > 0) { + ret.push_back(word_start); + ret.push_back(p_string.length()); } - } - if (line_start < p_string.length()) { - ret.push_back(line_start); - ret.push_back(p_string.length()); } return ret; } |