Skip to content

Commit

Permalink
Merge branch 'master' into tremble
Browse files Browse the repository at this point in the history
# Conflicts:
#	servers/rendering/renderer_rd/storage_rd/light_storage.cpp
  • Loading branch information
jitspoe committed Dec 6, 2024
2 parents f4a985b + eb51030 commit 753fe6d
Show file tree
Hide file tree
Showing 159 changed files with 4,748 additions and 2,991 deletions.
5 changes: 5 additions & 0 deletions COPYRIGHT.txt
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ Comment: Noto Sans font
Copyright: 2012, Google Inc.
License: OFL-1.1

Files: ./thirdparty/fonts/Vazirmatn*.woff2
Comment: Vazirmatn font
Copyright: 2015, The Vazirmatn Project Authors.
License: OFL-1.1

Files: ./thirdparty/freetype/
Comment: The FreeType Project
Copyright: 1996-2023, David Turner, Robert Wilhelm, and Werner Lemberg.
Expand Down
3 changes: 3 additions & 0 deletions core/config/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ String Engine::get_architecture_name() const {
return "ppc";
#endif

#elif defined(__loongarch64)
return "loongarch64";

#elif defined(__wasm__)
#if defined(__wasm64__)
return "wasm64";
Expand Down
4 changes: 4 additions & 0 deletions core/crypto/crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ class ResourceFormatLoaderCrypto : public ResourceFormatLoader {
virtual void get_recognized_extensions(List<String> *p_extensions) const override;
virtual bool handles_type(const String &p_type) const override;
virtual String get_resource_type(const String &p_path) const override;

// Treat certificates as text files, do not generate a `*.{crt,key,pub}.uid` file.
virtual ResourceUID::ID get_resource_uid(const String &p_path) const override { return ResourceUID::INVALID_ID; }
virtual bool has_custom_uid_support() const override { return true; }
};

class ResourceFormatSaverCrypto : public ResourceFormatSaver {
Expand Down
4 changes: 4 additions & 0 deletions core/io/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ class ResourceFormatLoaderJSON : public ResourceFormatLoader {
virtual void get_recognized_extensions(List<String> *p_extensions) const override;
virtual bool handles_type(const String &p_type) const override;
virtual String get_resource_type(const String &p_path) const override;

// Treat JSON as a text file, do not generate a `*.json.uid` file.
virtual ResourceUID::ID get_resource_uid(const String &p_path) const override { return ResourceUID::INVALID_ID; }
virtual bool has_custom_uid_support() const override { return true; }
};

class ResourceFormatSaverJSON : public ResourceFormatSaver {
Expand Down
7 changes: 6 additions & 1 deletion core/io/resource_uid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,12 @@ String ResourceUID::uid_to_path(const String &p_uid) {
}

String ResourceUID::path_to_uid(const String &p_path) {
return singleton->id_to_text(ResourceLoader::get_resource_uid(p_path));
const ID id = ResourceLoader::get_resource_uid(p_path);
if (id == INVALID_ID) {
return p_path;
} else {
return singleton->id_to_text(id);
}
}

String ResourceUID::ensure_path(const String &p_uid_or_path) {
Expand Down
4 changes: 4 additions & 0 deletions core/io/translation_loader_po.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ class TranslationLoaderPO : public ResourceFormatLoader {
virtual bool handles_type(const String &p_type) const override;
virtual String get_resource_type(const String &p_path) const override;

// Treat translations as text/binary files, do not generate a `*.{po,mo}.uid` file.
virtual ResourceUID::ID get_resource_uid(const String &p_path) const override { return ResourceUID::INVALID_ID; }
virtual bool has_custom_uid_support() const override { return true; }

TranslationLoaderPO() {}
};

Expand Down
4 changes: 4 additions & 0 deletions core/os/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,10 @@ bool OS::has_feature(const String &p_feature) {
if (p_feature == "wasm") {
return true;
}
#elif defined(__loongarch64)
if (p_feature == "loongarch64") {
return true;
}
#endif

#if defined(IOS_SIMULATOR)
Expand Down
63 changes: 32 additions & 31 deletions core/string/ustring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ const char16_t Char16String::_null = 0;
const char32_t String::_null = 0;
const char32_t String::_replacement_char = 0xfffd;

// strlen equivalent function for char32_t * arguments.
_FORCE_INLINE_ size_t strlen(const char32_t *p_str) {
const char32_t *ptr = p_str;
while (*ptr != 0) {
++ptr;
}
return ptr - p_str;
}

bool select_word(const String &p_s, int p_col, int &r_beg, int &r_end) {
const String &s = p_s;
int beg = CLAMP(p_col, 0, s.length());
Expand Down Expand Up @@ -424,11 +433,7 @@ void String::copy_from(const char32_t *p_cstr) {
return;
}

int len = 0;
const char32_t *ptr = p_cstr;
while (*(ptr++) != 0) {
len++;
}
const int len = strlen(p_cstr);

if (len == 0) {
resize(0);
Expand Down Expand Up @@ -629,12 +634,7 @@ String &String::operator+=(char32_t p_char) {

bool String::operator==(const char *p_str) const {
// compare Latin-1 encoded c-string
int len = 0;
const char *aux = p_str;

while (*(aux++) != 0) {
len++;
}
int len = strlen(p_str);

if (length() != len) {
return false;
Expand Down Expand Up @@ -668,12 +668,7 @@ bool String::operator==(const wchar_t *p_str) const {
}

bool String::operator==(const char32_t *p_str) const {
int len = 0;
const char32_t *aux = p_str;

while (*(aux++) != 0) {
len++;
}
const int len = strlen(p_str);

if (length() != len) {
return false;
Expand Down Expand Up @@ -1109,17 +1104,21 @@ String String::_camelcase_to_underscore() const {
String new_string;
int start_index = 0;

for (int i = 1; i < size(); i++) {
bool is_prev_upper = is_unicode_upper_case(cstr[i - 1]);
bool is_prev_lower = is_unicode_lower_case(cstr[i - 1]);
bool is_prev_digit = is_digit(cstr[i - 1]);
if (length() == 0) {
return *this;
}

bool is_curr_upper = is_unicode_upper_case(cstr[i]);
bool is_curr_lower = is_unicode_lower_case(cstr[i]);
bool is_curr_digit = is_digit(cstr[i]);
bool is_prev_upper = is_unicode_upper_case(cstr[0]);
bool is_prev_lower = is_unicode_lower_case(cstr[0]);
bool is_prev_digit = is_digit(cstr[0]);

for (int i = 1; i < length(); i++) {
const bool is_curr_upper = is_unicode_upper_case(cstr[i]);
const bool is_curr_lower = is_unicode_lower_case(cstr[i]);
const bool is_curr_digit = is_digit(cstr[i]);

bool is_next_lower = false;
if (i + 1 < size()) {
if (i + 1 < length()) {
is_next_lower = is_unicode_lower_case(cstr[i + 1]);
}

Expand All @@ -1132,6 +1131,10 @@ String String::_camelcase_to_underscore() const {
new_string += substr(start_index, i - start_index) + "_";
start_index = i;
}

is_prev_upper = is_curr_upper;
is_prev_lower = is_curr_lower;
is_prev_digit = is_curr_digit;
}

new_string += substr(start_index, size() - start_index);
Expand Down Expand Up @@ -5286,7 +5289,7 @@ bool String::is_valid_html_color() const {
}

// Changes made to the set of invalid filename characters must also be reflected in the String documentation for is_valid_filename.
static const char *invalid_filename_characters = ": / \\ ? * \" | % < >";
static const char *invalid_filename_characters[] = { ":", "/", "\\", "?", "*", "\"", "|", "%", "<", ">" };

bool String::is_valid_filename() const {
String stripped = strip_edges();
Expand All @@ -5298,8 +5301,7 @@ bool String::is_valid_filename() const {
return false;
}

Vector<String> chars = String(invalid_filename_characters).split(" ");
for (const String &ch : chars) {
for (const char *ch : invalid_filename_characters) {
if (contains(ch)) {
return false;
}
Expand All @@ -5308,10 +5310,9 @@ bool String::is_valid_filename() const {
}

String String::validate_filename() const {
Vector<String> chars = String(invalid_filename_characters).split(" ");
String name = strip_edges();
for (int i = 0; i < chars.size(); i++) {
name = name.replace(chars[i], "_");
for (const char *ch : invalid_filename_characters) {
name = name.replace(ch, "_");
}
return name;
}
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/PackedFloat32Array.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
<method name="to_byte_array" qualifiers="const">
<return type="PackedByteArray" />
<description>
Returns a copy of the data converted to a [PackedByteArray], where each element have been encoded as 4 bytes.
Returns a copy of the data converted to a [PackedByteArray], where each element has been encoded as 4 bytes.
The size of the new array will be [code]float32_array.size() * 4[/code].
</description>
</method>
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/PackedFloat64Array.xml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
<method name="to_byte_array" qualifiers="const">
<return type="PackedByteArray" />
<description>
Returns a copy of the data converted to a [PackedByteArray], where each element have been encoded as 8 bytes.
Returns a copy of the data converted to a [PackedByteArray], where each element has been encoded as 8 bytes.
The size of the new array will be [code]float64_array.size() * 8[/code].
</description>
</method>
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/PackedInt32Array.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
<method name="to_byte_array" qualifiers="const">
<return type="PackedByteArray" />
<description>
Returns a copy of the data converted to a [PackedByteArray], where each element have been encoded as 4 bytes.
Returns a copy of the data converted to a [PackedByteArray], where each element has been encoded as 4 bytes.
The size of the new array will be [code]int32_array.size() * 4[/code].
</description>
</method>
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/PackedInt64Array.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
<method name="to_byte_array" qualifiers="const">
<return type="PackedByteArray" />
<description>
Returns a copy of the data converted to a [PackedByteArray], where each element have been encoded as 8 bytes.
Returns a copy of the data converted to a [PackedByteArray], where each element has been encoded as 8 bytes.
The size of the new array will be [code]int64_array.size() * 8[/code].
</description>
</method>
Expand Down
33 changes: 33 additions & 0 deletions doc/classes/ShaderIncludeDB.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="ShaderIncludeDB" inherits="Object" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
Internal database of built in shader include files.
</brief_description>
<description>
This object contains shader fragments from Godot's internal shaders. These can be used when access to internal uniform buffers and/or internal functions is required for instance when composing compositor effects or compute shaders. Only fragments for the current rendering device are loaded.
</description>
<tutorials>
</tutorials>
<methods>
<method name="get_built_in_include_file" qualifiers="static">
<return type="String" />
<param index="0" name="filename" type="String" />
<description>
Returns the code for the built-in shader fragment. You can also access this in your shader code through [code]#include "filename"[/code].
</description>
</method>
<method name="has_built_in_include_file" qualifiers="static">
<return type="bool" />
<param index="0" name="filename" type="String" />
<description>
Returns [code]true[/code] if an include file with this name exists.
</description>
</method>
<method name="list_built_in_include_files" qualifiers="static">
<return type="PackedStringArray" />
<description>
Returns a list of built-in include files that are currently registered.
</description>
</method>
</methods>
</class>
2 changes: 1 addition & 1 deletion doc/classes/SurfaceTool.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
<method name="generate_tangents">
<return type="void" />
<description>
Generates a tangent vector for each vertex. Requires that each vertex have UVs and normals set already (see [method generate_normals]).
Generates a tangent vector for each vertex. Requires that each vertex already has UVs and normals set (see [method generate_normals]).
</description>
</method>
<method name="get_aabb" qualifiers="const">
Expand Down
10 changes: 10 additions & 0 deletions drivers/d3d12/rendering_device_driver_d3d12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6144,6 +6144,16 @@ uint64_t RenderingDeviceDriverD3D12::limit_get(Limit p_limit) {
switch (p_limit) {
case LIMIT_MAX_BOUND_UNIFORM_SETS:
return safe_unbounded;
case LIMIT_MAX_TEXTURE_ARRAY_LAYERS:
return D3D12_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION;
case LIMIT_MAX_TEXTURE_SIZE_1D:
return D3D12_REQ_TEXTURE1D_U_DIMENSION;
case LIMIT_MAX_TEXTURE_SIZE_2D:
return D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION;
case LIMIT_MAX_TEXTURE_SIZE_3D:
return D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION;
case LIMIT_MAX_TEXTURE_SIZE_CUBE:
return D3D12_REQ_TEXTURECUBE_DIMENSION;
case LIMIT_MAX_TEXTURES_PER_SHADER_STAGE:
return device_limits.max_srvs_per_shader_stage;
case LIMIT_MAX_UNIFORM_BUFFER_SIZE:
Expand Down
2 changes: 1 addition & 1 deletion drivers/gles3/storage/light_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@ bool LightStorage::shadow_atlas_update_light(RID p_atlas, RID p_light_instance,
old_shadow = old_key & SHADOW_INDEX_MASK;

// Only re-allocate if a better option is available, and enough time has passed.
should_realloc = shadow_atlas->quadrants[old_quadrant].subdivision != (uint32_t)best_subdiv && (shadow_atlas->quadrants[old_quadrant].shadows[old_shadow].alloc_tick - tick > shadow_atlas_realloc_tolerance_msec);
should_realloc = shadow_atlas->quadrants[old_quadrant].subdivision != (uint32_t)best_subdiv && (tick - shadow_atlas->quadrants[old_quadrant].shadows[old_shadow].alloc_tick > shadow_atlas_realloc_tolerance_msec);
should_redraw = shadow_atlas->quadrants[old_quadrant].shadows[old_shadow].version != p_light_version;

if (!should_realloc) {
Expand Down
2 changes: 1 addition & 1 deletion editor/connections_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ ConnectDialog::~ConnectDialog() {

Control *ConnectionsDockTree::make_custom_tooltip(const String &p_text) const {
// If it's not a doc tooltip, fallback to the default one.
if (p_text.contains("::")) {
if (p_text.is_empty() || p_text.contains("::")) {
return nullptr;
}

Expand Down
6 changes: 6 additions & 0 deletions editor/editor_inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ bool EditorInspector::_property_path_matches(const String &p_property_path, cons
return false;
}

String EditorProperty::get_tooltip_string(const String &p_string) const {
// Trim to 100 characters to prevent the tooltip from being too long.
constexpr int TOOLTIP_MAX_LENGTH = 100;
return p_string.left(TOOLTIP_MAX_LENGTH).strip_edges() + String((p_string.length() > TOOLTIP_MAX_LENGTH) ? "..." : "");
}

Size2 EditorProperty::get_minimum_size() const {
Size2 ms;
Ref<Font> font = get_theme_font(SceneStringName(font), SNAME("Tree"));
Expand Down
2 changes: 2 additions & 0 deletions editor/editor_inspector.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ class EditorProperty : public Container {
public:
void emit_changed(const StringName &p_property, const Variant &p_value, const StringName &p_field = StringName(), bool p_changing = false);

String get_tooltip_string(const String &p_string) const;

virtual Size2 get_minimum_size() const override;

void set_label(const String &p_label);
Expand Down
16 changes: 7 additions & 9 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1427,7 +1427,7 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String
if (p_resource->get_path().is_resource_file()) {
file->set_current_file(p_resource->get_path().get_file());
} else {
if (extensions.size()) {
if (!preferred.is_empty()) {
String resource_name_snake_case = p_resource->get_class().to_snake_case();
file->set_current_file("new_" + resource_name_snake_case + "." + preferred.front()->get().to_lower());
} else {
Expand All @@ -1436,18 +1436,15 @@ void EditorNode::save_resource_as(const Ref<Resource> &p_resource, const String
}
} else if (!p_resource->get_path().is_empty()) {
file->set_current_path(p_resource->get_path());
if (extensions.size()) {
String ext = p_resource->get_path().get_extension().to_lower();
if (!extensions.is_empty()) {
const String ext = p_resource->get_path().get_extension().to_lower();
if (extensions.find(ext) == nullptr) {
file->set_current_path(p_resource->get_path().replacen("." + ext, "." + extensions.front()->get()));
}
}
} else if (preferred.size()) {
String existing;
if (extensions.size()) {
String resource_name_snake_case = p_resource->get_class().to_snake_case();
existing = "new_" + resource_name_snake_case + "." + preferred.front()->get().to_lower();
}
} else if (!preferred.is_empty()) {
const String resource_name_snake_case = p_resource->get_class().to_snake_case();
const String existing = "new_" + resource_name_snake_case + "." + preferred.front()->get().to_lower();
file->set_current_path(existing);
}
file->set_title(TTR("Save Resource As..."));
Expand Down Expand Up @@ -7173,6 +7170,7 @@ EditorNode::EditorNode() {
main_menu = memnew(MenuBar);
main_menu->set_mouse_filter(Control::MOUSE_FILTER_STOP);
title_bar->add_child(main_menu);
main_menu->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
main_menu->set_theme_type_variation("MainMenuBar");
main_menu->set_start_index(0); // Main menu, add to the start of global menu.
main_menu->set_prefer_global_menu(global_menu);
Expand Down
Loading

0 comments on commit 753fe6d

Please sign in to comment.