summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/doc_data.h8
-rw-r--r--core/io/resource.cpp15
-rw-r--r--core/math/a_star_grid_2d.cpp12
-rw-r--r--core/os/os.h10
-rw-r--r--core/os/time.cpp55
-rw-r--r--doc/Makefile2
-rw-r--r--doc/classes/AnimatedSprite3D.xml6
-rw-r--r--doc/classes/Area2D.xml16
-rw-r--r--doc/classes/Area3D.xml16
-rw-r--r--doc/classes/ImporterMesh.xml2
-rw-r--r--doc/classes/ProjectSettings.xml12
-rw-r--r--doc/classes/TextServer.xml1
-rw-r--r--doc/classes/Time.xml4
-rw-r--r--doc/classes/Tween.xml9
-rwxr-xr-xdoc/tools/make_rst.py2
-rw-r--r--drivers/gles3/rasterizer_gles3.cpp8
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.cpp1
-rw-r--r--drivers/gles3/shaders/scene.glsl7
-rw-r--r--drivers/gles3/shaders/sky.glsl13
-rw-r--r--drivers/gles3/storage/material_storage.cpp1
-rw-r--r--drivers/gles3/storage/mesh_storage.cpp15
-rw-r--r--drivers/gles3/storage/texture_storage.cpp2
-rw-r--r--drivers/unix/os_unix.cpp21
-rw-r--r--drivers/unix/os_unix.h3
-rw-r--r--editor/create_dialog.cpp9
-rw-r--r--editor/debugger/editor_profiler.cpp22
-rw-r--r--editor/debugger/editor_profiler.h3
-rw-r--r--editor/debugger/script_editor_debugger.cpp9
-rw-r--r--editor/doc_tools.cpp88
-rw-r--r--editor/editor_fonts.cpp10
-rw-r--r--editor/editor_help.cpp94
-rw-r--r--editor/editor_help_search.cpp39
-rw-r--r--editor/editor_help_search.h2
-rw-r--r--editor/editor_inspector.cpp16
-rw-r--r--editor/editor_inspector.h3
-rw-r--r--editor/editor_node.cpp17
-rw-r--r--editor/editor_node.h2
-rw-r--r--editor/editor_properties_array_dict.cpp26
-rw-r--r--editor/editor_resource_picker.cpp2
-rw-r--r--editor/editor_themes.cpp22
-rw-r--r--editor/editor_undo_redo_manager.cpp7
-rw-r--r--editor/export/editor_export_platform.cpp13
-rw-r--r--editor/export/project_export.cpp15
-rw-r--r--editor/icons/GuiResizerTopLeft.svg1
-rw-r--r--editor/icons/PreviewEnvironment.svg1
-rw-r--r--editor/icons/PreviewSun.svg1
-rw-r--r--editor/import/resource_importer_scene.cpp36
-rw-r--r--editor/import/resource_importer_scene.h2
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.cpp4
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp24
-rw-r--r--editor/plugins/shader_editor_plugin.h4
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.cpp31
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.h2
-rw-r--r--editor/plugins/tiles/tile_map_editor.cpp1
-rw-r--r--editor/plugins/version_control_editor_plugin.cpp10
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp6
-rw-r--r--editor/project_manager.cpp62
-rw-r--r--editor/project_manager.h3
-rw-r--r--modules/gdscript/doc_classes/@GDScript.xml4
-rw-r--r--modules/gdscript/gdscript.cpp6
-rw-r--r--modules/gdscript/gdscript_cache.cpp4
-rw-r--r--modules/gltf/gltf_document.cpp2
-rw-r--r--modules/gltf/register_types.cpp5
-rw-r--r--modules/mono/editor/GodotTools/GodotTools/Build/DotNetFinder.cs18
-rw-r--r--modules/multiplayer/multiplayer_spawner.cpp13
-rw-r--r--modules/navigation/navigation_mesh_generator.cpp3
-rw-r--r--modules/webrtc/doc_classes/WebRTCPeerConnection.xml39
-rw-r--r--modules/webrtc/doc_classes/WebRTCPeerConnectionExtension.xml10
-rw-r--r--modules/webrtc/library_godot_webrtc.js196
-rw-r--r--modules/webrtc/webrtc_peer_connection.cpp13
-rw-r--r--modules/webrtc/webrtc_peer_connection.h19
-rw-r--r--modules/webrtc/webrtc_peer_connection_extension.cpp2
-rw-r--r--modules/webrtc/webrtc_peer_connection_extension.h2
-rw-r--r--modules/webrtc/webrtc_peer_connection_js.cpp23
-rw-r--r--modules/webrtc/webrtc_peer_connection_js.h14
-rw-r--r--platform/android/export/export.cpp2
-rw-r--r--platform/android/export/export_plugin.cpp15
-rw-r--r--platform/android/java/app/config.gradle26
-rw-r--r--platform/android/java/editor/build.gradle23
-rw-r--r--platform/android/java/editor/src/main/AndroidManifest.xml2
-rw-r--r--platform/ios/detect.py4
-rw-r--r--platform/linuxbsd/gl_manager_x11.cpp24
-rw-r--r--platform/linuxbsd/os_linuxbsd.cpp7
-rw-r--r--platform/macos/display_server_macos.mm1
-rw-r--r--platform/macos/export/export.cpp2
-rw-r--r--platform/macos/export/export_plugin.cpp30
-rw-r--r--platform/macos/gl_manager_macos_legacy.mm5
-rw-r--r--platform/macos/godot_content_view.h10
-rw-r--r--platform/macos/godot_content_view.mm41
-rw-r--r--platform/macos/os_macos.mm5
-rw-r--r--platform/uwp/os_uwp.cpp37
-rw-r--r--platform/uwp/os_uwp.h3
-rw-r--r--platform/web/display_server_web.cpp2
-rw-r--r--platform/web/export/export.cpp2
-rw-r--r--platform/windows/display_server_windows.cpp146
-rw-r--r--platform/windows/display_server_windows.h4
-rw-r--r--platform/windows/export/export.cpp2
-rw-r--r--platform/windows/gl_manager_windows.cpp7
-rw-r--r--platform/windows/os_windows.cpp34
-rw-r--r--platform/windows/os_windows.h3
-rw-r--r--scene/2d/animated_sprite_2d.cpp66
-rw-r--r--scene/2d/area_2d.cpp13
-rw-r--r--scene/2d/area_2d.h3
-rw-r--r--scene/3d/area_3d.cpp13
-rw-r--r--scene/3d/area_3d.h3
-rw-r--r--scene/3d/sprite_3d.cpp188
-rw-r--r--scene/3d/sprite_3d.h11
-rw-r--r--scene/gui/graph_edit.cpp8
-rw-r--r--scene/gui/graph_edit.h2
-rw-r--r--scene/gui/rich_text_label.cpp34
-rw-r--r--scene/main/node.h4
-rw-r--r--scene/resources/font.cpp6
-rw-r--r--scene/resources/importer_mesh.cpp41
-rw-r--r--scene/resources/importer_mesh.h2
-rw-r--r--scene/resources/sky_material.cpp86
-rw-r--r--scene/resources/sky_material.h4
-rw-r--r--servers/rendering/renderer_rd/effects/ss_effects.cpp12
-rw-r--r--servers/rendering/renderer_rd/effects/ss_effects.h7
-rw-r--r--servers/rendering/renderer_rd/environment/sky.cpp2
-rw-r--r--servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp20
-rw-r--r--servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h5
-rw-r--r--servers/rendering/renderer_rd/renderer_scene_render_rd.cpp4
-rw-r--r--servers/rendering/renderer_rd/renderer_scene_render_rd.h2
-rw-r--r--servers/rendering/renderer_rd/shaders/effects/screen_space_reflection.glsl21
-rw-r--r--servers/rendering/renderer_rd/shaders/environment/sky.glsl13
-rw-r--r--servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl10
-rw-r--r--servers/rendering/renderer_rd/shaders/scene_forward_clustered_inc.glsl4
-rw-r--r--servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl7
-rw-r--r--servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp209
-rw-r--r--servers/rendering/renderer_rd/storage_rd/mesh_storage.h11
-rw-r--r--servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.cpp9
-rw-r--r--servers/rendering/renderer_viewport.cpp26
-rw-r--r--servers/rendering/rendering_server_default.cpp5
-rw-r--r--servers/rendering/shader_language.cpp48
-rw-r--r--servers/rendering/shader_language.h4
-rw-r--r--servers/rendering/shader_types.cpp1
-rw-r--r--thirdparty/README.md2
-rw-r--r--thirdparty/openxr/include/openxr/openxr.h135
-rw-r--r--thirdparty/openxr/include/openxr/openxr_platform.h2
-rw-r--r--thirdparty/openxr/include/openxr/openxr_reflection.h63
-rw-r--r--thirdparty/openxr/src/common/unique_asset.h33
-rw-r--r--thirdparty/openxr/src/loader/android_utilities.cpp2
-rw-r--r--thirdparty/openxr/src/loader/api_layer_interface.cpp1
-rw-r--r--thirdparty/openxr/src/loader/loader_core.cpp6
-rw-r--r--thirdparty/openxr/src/loader/manifest_file.cpp120
-rw-r--r--thirdparty/openxr/src/loader/manifest_file.hpp14
-rw-r--r--thirdparty/openxr/src/loader/runtime_interface.cpp37
-rw-r--r--thirdparty/openxr/src/loader/runtime_interface.hpp2
148 files changed, 2192 insertions, 767 deletions
diff --git a/core/doc_data.h b/core/doc_data.h
index 1d8d2483e0..3b7bf149b4 100644
--- a/core/doc_data.h
+++ b/core/doc_data.h
@@ -66,6 +66,8 @@ public:
String return_enum;
String qualifiers;
String description;
+ bool is_deprecated = false;
+ bool is_experimental = false;
Vector<ArgumentDoc> arguments;
Vector<int> errors_returned;
bool operator<(const MethodDoc &p_method) const {
@@ -105,6 +107,8 @@ public:
String enumeration;
bool is_bitfield = false;
String description;
+ bool is_deprecated = false;
+ bool is_experimental = false;
bool operator<(const ConstantDoc &p_const) const {
return name < p_const.name;
}
@@ -126,6 +130,8 @@ public:
String default_value;
bool overridden = false;
String overrides;
+ bool is_deprecated = false;
+ bool is_experimental = false;
bool operator<(const PropertyDoc &p_prop) const {
return name < p_prop.name;
}
@@ -167,6 +173,8 @@ public:
Vector<PropertyDoc> properties;
Vector<MethodDoc> annotations;
Vector<ThemeItemDoc> theme_properties;
+ bool is_deprecated = false;
+ bool is_experimental = false;
bool is_script_doc = false;
String script_path;
bool operator<(const ClassDoc &p_class) const {
diff --git a/core/io/resource.cpp b/core/io/resource.cpp
index d117f86f39..553698f8a6 100644
--- a/core/io/resource.cpp
+++ b/core/io/resource.cpp
@@ -93,15 +93,14 @@ String Resource::get_path() const {
String Resource::generate_scene_unique_id() {
// Generate a unique enough hash, but still user-readable.
// If it's not unique it does not matter because the saver will try again.
- OS::Date date = OS::get_singleton()->get_date();
- OS::Time time = OS::get_singleton()->get_time();
+ OS::DateTime dt = OS::get_singleton()->get_datetime();
uint32_t hash = hash_murmur3_one_32(OS::get_singleton()->get_ticks_usec());
- hash = hash_murmur3_one_32(date.year, hash);
- hash = hash_murmur3_one_32(date.month, hash);
- hash = hash_murmur3_one_32(date.day, hash);
- hash = hash_murmur3_one_32(time.hour, hash);
- hash = hash_murmur3_one_32(time.minute, hash);
- hash = hash_murmur3_one_32(time.second, hash);
+ hash = hash_murmur3_one_32(dt.year, hash);
+ hash = hash_murmur3_one_32(dt.month, hash);
+ hash = hash_murmur3_one_32(dt.day, hash);
+ hash = hash_murmur3_one_32(dt.hour, hash);
+ hash = hash_murmur3_one_32(dt.minute, hash);
+ hash = hash_murmur3_one_32(dt.second, hash);
hash = hash_murmur3_one_32(Math::rand(), hash);
static constexpr uint32_t characters = 5;
diff --git a/core/math/a_star_grid_2d.cpp b/core/math/a_star_grid_2d.cpp
index 23d7e379ee..ad67cfa852 100644
--- a/core/math/a_star_grid_2d.cpp
+++ b/core/math/a_star_grid_2d.cpp
@@ -30,16 +30,16 @@
#include "a_star_grid_2d.h"
-static real_t heuristic_manhattan(const Vector2i &p_from, const Vector2i &p_to) {
+static real_t heuristic_euclidian(const Vector2i &p_from, const Vector2i &p_to) {
real_t dx = (real_t)ABS(p_to.x - p_from.x);
real_t dy = (real_t)ABS(p_to.y - p_from.y);
- return dx + dy;
+ return (real_t)Math::sqrt(dx * dx + dy * dy);
}
-static real_t heuristic_euclidian(const Vector2i &p_from, const Vector2i &p_to) {
+static real_t heuristic_manhattan(const Vector2i &p_from, const Vector2i &p_to) {
real_t dx = (real_t)ABS(p_to.x - p_from.x);
real_t dy = (real_t)ABS(p_to.y - p_from.y);
- return (real_t)Math::sqrt(dx * dx + dy * dy);
+ return dx + dy;
}
static real_t heuristic_octile(const Vector2i &p_from, const Vector2i &p_to) {
@@ -55,7 +55,7 @@ static real_t heuristic_chebyshev(const Vector2i &p_from, const Vector2i &p_to)
return MAX(dx, dy);
}
-static real_t (*heuristics[AStarGrid2D::HEURISTIC_MAX])(const Vector2i &, const Vector2i &) = { heuristic_manhattan, heuristic_euclidian, heuristic_octile, heuristic_chebyshev };
+static real_t (*heuristics[AStarGrid2D::HEURISTIC_MAX])(const Vector2i &, const Vector2i &) = { heuristic_euclidian, heuristic_manhattan, heuristic_octile, heuristic_chebyshev };
void AStarGrid2D::set_size(const Size2i &p_size) {
ERR_FAIL_COND(p_size.x < 0 || p_size.y < 0);
@@ -572,7 +572,7 @@ void AStarGrid2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "cell_size"), "set_cell_size", "get_cell_size");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "jumping_enabled"), "set_jumping_enabled", "is_jumping_enabled");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "default_heuristic", PROPERTY_HINT_ENUM, "Manhattan,Euclidean,Octile,Chebyshev,Max"), "set_default_heuristic", "get_default_heuristic");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "default_heuristic", PROPERTY_HINT_ENUM, "Euclidean,Manhattan,Octile,Chebyshev,Max"), "set_default_heuristic", "get_default_heuristic");
ADD_PROPERTY(PropertyInfo(Variant::INT, "diagonal_mode", PROPERTY_HINT_ENUM, "Never,Always,At Least One Walkable,Only If No Obstacles,Max"), "set_diagonal_mode", "get_diagonal_mode");
BIND_ENUM_CONSTANT(HEURISTIC_EUCLIDEAN);
diff --git a/core/os/os.h b/core/os/os.h
index 0e8a2d0398..363697ea30 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -202,18 +202,15 @@ public:
MONTH_DECEMBER,
};
- struct Date {
+ struct DateTime {
int64_t year;
Month month;
uint8_t day;
Weekday weekday;
- bool dst;
- };
-
- struct Time {
uint8_t hour;
uint8_t minute;
uint8_t second;
+ bool dst;
};
struct TimeZoneInfo {
@@ -221,8 +218,7 @@ public:
String name;
};
- virtual Date get_date(bool p_utc = false) const = 0;
- virtual Time get_time(bool p_utc = false) const = 0;
+ virtual DateTime get_datetime(bool utc = false) const = 0;
virtual TimeZoneInfo get_time_zone_info() const = 0;
virtual double get_unix_time() const;
diff --git a/core/os/time.cpp b/core/os/time.cpp
index a30e2a906b..a3c2c99b4c 100644
--- a/core/os/time.cpp
+++ b/core/os/time.cpp
@@ -324,63 +324,60 @@ String Time::get_offset_string_from_offset_minutes(int64_t p_offset_minutes) con
}
Dictionary Time::get_datetime_dict_from_system(bool p_utc) const {
- OS::Date date = OS::get_singleton()->get_date(p_utc);
- OS::Time time = OS::get_singleton()->get_time(p_utc);
+ OS::DateTime dt = OS::get_singleton()->get_datetime(p_utc);
Dictionary datetime;
- datetime[YEAR_KEY] = date.year;
- datetime[MONTH_KEY] = (uint8_t)date.month;
- datetime[DAY_KEY] = date.day;
- datetime[WEEKDAY_KEY] = (uint8_t)date.weekday;
- datetime[DST_KEY] = date.dst;
- datetime[HOUR_KEY] = time.hour;
- datetime[MINUTE_KEY] = time.minute;
- datetime[SECOND_KEY] = time.second;
+ datetime[YEAR_KEY] = dt.year;
+ datetime[MONTH_KEY] = (uint8_t)dt.month;
+ datetime[DAY_KEY] = dt.day;
+ datetime[WEEKDAY_KEY] = (uint8_t)dt.weekday;
+ datetime[HOUR_KEY] = dt.hour;
+ datetime[MINUTE_KEY] = dt.minute;
+ datetime[SECOND_KEY] = dt.second;
+ datetime[DST_KEY] = dt.dst;
return datetime;
}
Dictionary Time::get_date_dict_from_system(bool p_utc) const {
- OS::Date date = OS::get_singleton()->get_date(p_utc);
+ OS::DateTime dt = OS::get_singleton()->get_datetime(p_utc);
Dictionary date_dictionary;
- date_dictionary[YEAR_KEY] = date.year;
- date_dictionary[MONTH_KEY] = (uint8_t)date.month;
- date_dictionary[DAY_KEY] = date.day;
- date_dictionary[WEEKDAY_KEY] = (uint8_t)date.weekday;
- date_dictionary[DST_KEY] = date.dst;
+ date_dictionary[YEAR_KEY] = dt.year;
+ date_dictionary[MONTH_KEY] = (uint8_t)dt.month;
+ date_dictionary[DAY_KEY] = dt.day;
+ date_dictionary[WEEKDAY_KEY] = (uint8_t)dt.weekday;
return date_dictionary;
}
Dictionary Time::get_time_dict_from_system(bool p_utc) const {
- OS::Time time = OS::get_singleton()->get_time(p_utc);
+ OS::DateTime dt = OS::get_singleton()->get_datetime(p_utc);
Dictionary time_dictionary;
- time_dictionary[HOUR_KEY] = time.hour;
- time_dictionary[MINUTE_KEY] = time.minute;
- time_dictionary[SECOND_KEY] = time.second;
+ time_dictionary[HOUR_KEY] = dt.hour;
+ time_dictionary[MINUTE_KEY] = dt.minute;
+ time_dictionary[SECOND_KEY] = dt.second;
return time_dictionary;
}
String Time::get_datetime_string_from_system(bool p_utc, bool p_use_space) const {
- OS::Date date = OS::get_singleton()->get_date(p_utc);
- OS::Time time = OS::get_singleton()->get_time(p_utc);
+ OS::DateTime dt = OS::get_singleton()->get_datetime(p_utc);
// vformat only supports up to 6 arguments, so we need to split this up into 2 parts.
- String timestamp = vformat("%04d-%02d-%02d", date.year, (uint8_t)date.month, date.day);
+ String timestamp = vformat("%04d-%02d-%02d", dt.year, (uint8_t)dt.month, dt.day);
if (p_use_space) {
- timestamp = vformat("%s %02d:%02d:%02d", timestamp, time.hour, time.minute, time.second);
+ timestamp = vformat("%s %02d:%02d:%02d", timestamp, dt.hour, dt.minute, dt.second);
} else {
- timestamp = vformat("%sT%02d:%02d:%02d", timestamp, time.hour, time.minute, time.second);
+ timestamp = vformat("%sT%02d:%02d:%02d", timestamp, dt.hour, dt.minute, dt.second);
}
return timestamp;
}
String Time::get_date_string_from_system(bool p_utc) const {
- OS::Date date = OS::get_singleton()->get_date(p_utc);
+ OS::DateTime dt = OS::get_singleton()->get_datetime(p_utc);
// Android is picky about the types passed to make Variant, so we need a cast.
- return vformat("%04d-%02d-%02d", date.year, (uint8_t)date.month, date.day);
+ return vformat("%04d-%02d-%02d", dt.year, (uint8_t)dt.month, dt.day);
}
String Time::get_time_string_from_system(bool p_utc) const {
- OS::Time time = OS::get_singleton()->get_time(p_utc);
- return vformat("%02d:%02d:%02d", time.hour, time.minute, time.second);
+ OS::DateTime dt = OS::get_singleton()->get_datetime(p_utc);
+ return vformat("%02d:%02d:%02d", dt.hour, dt.minute, dt.second);
}
Dictionary Time::get_time_zone_from_system() const {
diff --git a/doc/Makefile b/doc/Makefile
index ecc5e51dd6..c8bf32d6e2 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -1,4 +1,4 @@
-BASEDIR = $(CURDIR)
+BASEDIR = .
CLASSES = $(BASEDIR)/classes/ $(BASEDIR)/../modules/
OUTPUTDIR = $(BASEDIR)/_build
TOOLSDIR = $(BASEDIR)/tools
diff --git a/doc/classes/AnimatedSprite3D.xml b/doc/classes/AnimatedSprite3D.xml
index 0bc5484e3a..58d3ca6ad3 100644
--- a/doc/classes/AnimatedSprite3D.xml
+++ b/doc/classes/AnimatedSprite3D.xml
@@ -13,8 +13,9 @@
<method name="play">
<return type="void" />
<param index="0" name="anim" type="StringName" default="&amp;&quot;&quot;" />
+ <param index="1" name="backwards" type="bool" default="false" />
<description>
- Plays the animation named [param anim]. If no [param anim] is provided, the current animation is played.
+ Plays the animation named [param anim]. If no [param anim] is provided, the current animation is played. If [param backwards] is [code]true[/code], the animation will be played in reverse.
</description>
</method>
<method name="stop">
@@ -37,6 +38,9 @@
<member name="playing" type="bool" setter="set_playing" getter="is_playing" default="false">
If [code]true[/code], the [member animation] is currently playing.
</member>
+ <member name="speed_scale" type="float" setter="set_speed_scale" getter="get_speed_scale" default="1.0">
+ The animation speed is multiplied by this value.
+ </member>
</members>
<signals>
<signal name="animation_finished">
diff --git a/doc/classes/Area2D.xml b/doc/classes/Area2D.xml
index f1e40d4979..29592f133d 100644
--- a/doc/classes/Area2D.xml
+++ b/doc/classes/Area2D.xml
@@ -25,10 +25,24 @@
<method name="get_overlapping_bodies" qualifiers="const">
<return type="Node2D[]" />
<description>
- Returns a list of intersecting [PhysicsBody2D]s. The overlapping body's [member CollisionObject2D.collision_layer] must be part of this area's [member CollisionObject2D.collision_mask] in order to be detected.
+ Returns a list of intersecting [PhysicsBody2D]s and [TileMap]s. The overlapping body's [member CollisionObject2D.collision_layer] must be part of this area's [member CollisionObject2D.collision_mask] in order to be detected.
For performance reasons (collisions are all processed at the same time) this list is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
</description>
</method>
+ <method name="has_overlapping_areas" qualifiers="const">
+ <return type="bool" />
+ <description>
+ Returns [code]true[/code] if intersecting any [Area2D]s, otherwise returns [code]false[/code]. The overlapping area's [member CollisionObject2D.collision_layer] must be part of this area's [member CollisionObject2D.collision_mask] in order to be detected.
+ For performance reasons (collisions are all processed at the same time) the list of overlapping areas is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
+ </description>
+ </method>
+ <method name="has_overlapping_bodies" qualifiers="const">
+ <return type="bool" />
+ <description>
+ Returns [code]true[/code] if intersecting any [PhysicsBody2D]s or [TileMap]s, otherwise returns [code]false[/code]. The overlapping body's [member CollisionObject2D.collision_layer] must be part of this area's [member CollisionObject2D.collision_mask] in order to be detected.
+ For performance reasons (collisions are all processed at the same time) the list of overlapping bodies is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
+ </description>
+ </method>
<method name="overlaps_area" qualifiers="const">
<return type="bool" />
<param index="0" name="area" type="Node" />
diff --git a/doc/classes/Area3D.xml b/doc/classes/Area3D.xml
index 14081918cf..ce49be9bc1 100644
--- a/doc/classes/Area3D.xml
+++ b/doc/classes/Area3D.xml
@@ -23,10 +23,24 @@
<method name="get_overlapping_bodies" qualifiers="const">
<return type="Node3D[]" />
<description>
- Returns a list of intersecting [PhysicsBody3D]s. The overlapping body's [member CollisionObject3D.collision_layer] must be part of this area's [member CollisionObject3D.collision_mask] in order to be detected.
+ Returns a list of intersecting [PhysicsBody3D]s and [GridMap]s. The overlapping body's [member CollisionObject3D.collision_layer] must be part of this area's [member CollisionObject3D.collision_mask] in order to be detected.
For performance reasons (collisions are all processed at the same time) this list is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
</description>
</method>
+ <method name="has_overlapping_areas" qualifiers="const">
+ <return type="bool" />
+ <description>
+ Returns [code]true[/code] if intersecting any [Area3D]s, otherwise returns [code]false[/code]. The overlapping area's [member CollisionObject3D.collision_layer] must be part of this area's [member CollisionObject3D.collision_mask] in order to be detected.
+ For performance reasons (collisions are all processed at the same time) the list of overlapping areas is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
+ </description>
+ </method>
+ <method name="has_overlapping_bodies" qualifiers="const">
+ <return type="bool" />
+ <description>
+ Returns [code]true[/code] if intersecting any [PhysicsBody3D]s or [GridMap]s, otherwise returns [code]false[/code]. The overlapping body's [member CollisionObject3D.collision_layer] must be part of this area's [member CollisionObject3D.collision_mask] in order to be detected.
+ For performance reasons (collisions are all processed at the same time) the list of overlapping bodies is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
+ </description>
+ </method>
<method name="overlaps_area" qualifiers="const">
<return type="bool" />
<param index="0" name="area" type="Node" />
diff --git a/doc/classes/ImporterMesh.xml b/doc/classes/ImporterMesh.xml
index 3c3dbe4d87..1c9655c266 100644
--- a/doc/classes/ImporterMesh.xml
+++ b/doc/classes/ImporterMesh.xml
@@ -43,10 +43,12 @@
<return type="void" />
<param index="0" name="normal_merge_angle" type="float" />
<param index="1" name="normal_split_angle" type="float" />
+ <param index="2" name="bone_transform_array" type="Array" />
<description>
Generates all lods for this ImporterMesh.
[param normal_merge_angle] and [param normal_split_angle] are in degrees and used in the same way as the importer settings in [code]lods[/code]. As a good default, use 25 and 60 respectively.
The number of generated lods can be accessed using [method get_surface_lod_count], and each LOD is available in [method get_surface_lod_size] and [method get_surface_lod_indices].
+ [param bone_transform_array] is an [Array] which can be either empty or contain [Transform3D]s which, for each of the mesh's bone IDs, will apply mesh skinning when generating the LOD mesh variations. This is usually used to account for discrepancies in scale between the mesh itself and its skinning data.
</description>
</method>
<method name="get_blend_shape_count" qualifiers="const">
diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml
index 3dbf7c75e5..1f07a13c94 100644
--- a/doc/classes/ProjectSettings.xml
+++ b/doc/classes/ProjectSettings.xml
@@ -640,10 +640,22 @@
If [code]true[/code], Blender 3D scene files with the [code].blend[/code] extension will be imported by converting them to glTF 2.0.
This requires configuring a path to a Blender executable in the editor settings at [code]filesystem/import/blender/blender3_path[/code]. Blender 3.0 or later is required.
</member>
+ <member name="filesystem/import/blender/enabled.android" type="bool" setter="" getter="" default="false">
+ Override for [member filesystem/import/blender/enabled] on Android where Blender can't easily be accessed from Godot.
+ </member>
+ <member name="filesystem/import/blender/enabled.web" type="bool" setter="" getter="" default="false">
+ Override for [member filesystem/import/blender/enabled] on the Web where Blender can't easily be accessed from Godot.
+ </member>
<member name="filesystem/import/fbx/enabled" type="bool" setter="" getter="" default="true">
If [code]true[/code], Autodesk FBX 3D scene files with the [code].fbx[/code] extension will be imported by converting them to glTF 2.0.
This requires configuring a path to a FBX2glTF executable in the editor settings at [code]filesystem/import/fbx/fbx2gltf_path[/code].
</member>
+ <member name="filesystem/import/fbx/enabled.android" type="bool" setter="" getter="" default="false">
+ Override for [member filesystem/import/fbx/enabled] on Android where FBX2glTF can't easily be accessed from Godot.
+ </member>
+ <member name="filesystem/import/fbx/enabled.web" type="bool" setter="" getter="" default="false">
+ Override for [member filesystem/import/fbx/enabled] on the Web where FBX2glTF can't easily be accessed from Godot.
+ </member>
<member name="gui/common/default_scroll_deadzone" type="int" setter="" getter="" default="0">
Default value for [member ScrollContainer.scroll_deadzone], which will be used for all [ScrollContainer]s unless overridden.
</member>
diff --git a/doc/classes/TextServer.xml b/doc/classes/TextServer.xml
index 0db16b491d..2e67c61e54 100644
--- a/doc/classes/TextServer.xml
+++ b/doc/classes/TextServer.xml
@@ -1720,6 +1720,7 @@
</constant>
<constant name="HINTING_NORMAL" value="2" enum="Hinting">
Use the default font hinting mode (crisper but less smooth).
+ [b]Note:[/b] This hinting mode changes both horizontal and vertical glyph metrics. If applied to monospace font, some glyphs might have different width.
</constant>
<constant name="SUBPIXEL_POSITIONING_DISABLED" value="0" enum="SubpixelPositioning">
Glyph horizontal position is rounded to the whole pixel size, each glyph is rasterized once.
diff --git a/doc/classes/Time.xml b/doc/classes/Time.xml
index cdbe30c444..1abe017a4d 100644
--- a/doc/classes/Time.xml
+++ b/doc/classes/Time.xml
@@ -17,7 +17,7 @@
<return type="Dictionary" />
<param index="0" name="utc" type="bool" default="false" />
<description>
- Returns the current date as a dictionary of keys: [code]year[/code], [code]month[/code], [code]day[/code], [code]weekday[/code], and [code]dst[/code] (Daylight Savings Time).
+ Returns the current date as a dictionary of keys: [code]year[/code], [code]month[/code], [code]day[/code], and [code]weekday[/code].
The returned values are in the system's local time when [param utc] is [code]false[/code], otherwise they are in UTC.
</description>
</method>
@@ -57,7 +57,7 @@
<return type="Dictionary" />
<param index="0" name="utc" type="bool" default="false" />
<description>
- Returns the current date as a dictionary of keys: [code]year[/code], [code]month[/code], [code]day[/code], [code]weekday[/code], [code]hour[/code], [code]minute[/code], and [code]second[/code].
+ Returns the current date as a dictionary of keys: [code]year[/code], [code]month[/code], [code]day[/code], [code]weekday[/code], [code]hour[/code], [code]minute[/code], [code]second[/code], and [code]dst[/code] (Daylight Savings Time).
</description>
</method>
<method name="get_datetime_dict_from_unix_time" qualifiers="const">
diff --git a/doc/classes/Tween.xml b/doc/classes/Tween.xml
index c7fc78c1d3..5186972477 100644
--- a/doc/classes/Tween.xml
+++ b/doc/classes/Tween.xml
@@ -36,9 +36,18 @@
tween.tween_property(sprite, "position", Vector2(0, 0), 1)
[/codeblock]
In the example above, all children of a node are moved one after another to position (0, 0).
+ You should avoid using more than one [Tween] per object's property. If two or more tweens animate one property at the same time, the last one created will take priority and assign the final value. If you want to interrupt and restart an animation, consider assigning the [Tween] to a variable:
+ [codeblock]
+ var tween
+ func animate():
+ if tween:
+ tween.kill() # Abort the previous animation.
+ tween = create_tween()
+ [/codeblock]
Some [Tweener]s use transitions and eases. The first accepts a [enum TransitionType] constant, and refers to the way the timing of the animation is handled (see [url=https://easings.net/]easings.net[/url] for some examples). The second accepts an [enum EaseType] constant, and controls where the [code]trans_type[/code] is applied to the interpolation (in the beginning, the end, or both). If you don't know which transition and easing to pick, you can try different [enum TransitionType] constants with [constant EASE_IN_OUT], and use the one that looks best.
[url=https://raw.githubusercontent.com/godotengine/godot-docs/master/img/tween_cheatsheet.png]Tween easing and transition types cheatsheet[/url]
[b]Note:[/b] All [Tween]s will automatically start by default. To prevent a [Tween] from autostarting, you can call [method stop] immediately after it is created.
+ [b]Note:[/b] [Tween]s are processing after all of nodes in the current frame, i.e. after [method Node._process] or [method Node._physics_process] (depending on [enum TweenProcessMode]).
</description>
<tutorials>
</tutorials>
diff --git a/doc/tools/make_rst.py b/doc/tools/make_rst.py
index cd7de085d8..a8569413ec 100755
--- a/doc/tools/make_rst.py
+++ b/doc/tools/make_rst.py
@@ -1480,6 +1480,8 @@ def format_text_block(
)
tag_text = f"``{link_target}``"
+ escape_pre = True
+ escape_post = True
# Formatting directives.
diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp
index cc96294ca5..3575837794 100644
--- a/drivers/gles3/rasterizer_gles3.cpp
+++ b/drivers/gles3/rasterizer_gles3.cpp
@@ -280,11 +280,6 @@ void RasterizerGLES3::_blit_render_target_to_screen(RID p_render_target, Display
GLES3::RenderTarget *rt = texture_storage->get_render_target(p_render_target);
ERR_FAIL_COND(!rt);
- // TODO: do we need a keep 3d linear option?
-
- // Make sure we are drawing to the right context.
- DisplayServer::get_singleton()->gl_window_make_current(p_screen);
-
if (rt->external.fbo != 0) {
glBindFramebuffer(GL_READ_FRAMEBUFFER, rt->external.fbo);
} else {
@@ -298,9 +293,6 @@ void RasterizerGLES3::_blit_render_target_to_screen(RID p_render_target, Display
// is this p_screen useless in a multi window environment?
void RasterizerGLES3::blit_render_targets_to_screen(DisplayServer::WindowID p_screen, const BlitToScreen *p_render_targets, int p_amount) {
- // All blits are going to the system framebuffer, so just bind once.
- glBindFramebuffer(GL_FRAMEBUFFER, GLES3::TextureStorage::system_fbo);
-
for (int i = 0; i < p_amount; i++) {
const BlitToScreen &blit = p_render_targets[i];
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp
index dae26b1e5f..1952efff0e 100644
--- a/drivers/gles3/rasterizer_scene_gles3.cpp
+++ b/drivers/gles3/rasterizer_scene_gles3.cpp
@@ -683,6 +683,7 @@ void RasterizerSceneGLES3::_setup_sky(const RenderDataGLES3 *p_render_data, cons
light_data_dirty = true;
for (uint32_t i = sky_globals.directional_light_count; i < sky_globals.max_directional_lights; i++) {
sky_globals.directional_lights[i].enabled = false;
+ sky_globals.last_frame_directional_lights[i].enabled = false;
}
}
diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl
index c7fdd6ebd8..efd6036ba9 100644
--- a/drivers/gles3/shaders/scene.glsl
+++ b/drivers/gles3/shaders/scene.glsl
@@ -629,11 +629,12 @@ void light_compute(vec3 N, vec3 L, vec3 V, float A, vec3 light_color, float atte
float diffuse_brdf_NL; // BRDF times N.L for calculating diffuse radiance
#if defined(DIFFUSE_LAMBERT_WRAP)
- // energy conserving lambert wrap shader
- diffuse_brdf_NL = max(0.0, (NdotL + roughness) / ((1.0 + roughness) * (1.0 + roughness)));
+ // Energy conserving lambert wrap shader.
+ // https://web.archive.org/web/20210228210901/http://blog.stevemcauley.com/2011/12/03/energy-conserving-wrapped-diffuse/
+ diffuse_brdf_NL = max(0.0, (NdotL + roughness) / ((1.0 + roughness) * (1.0 + roughness))) * (1.0 / M_PI);
#elif defined(DIFFUSE_TOON)
- diffuse_brdf_NL = smoothstep(-roughness, max(roughness, 0.01), NdotL);
+ diffuse_brdf_NL = smoothstep(-roughness, max(roughness, 0.01), NdotL) * (1.0 / M_PI);
#elif defined(DIFFUSE_BURLEY)
diff --git a/drivers/gles3/shaders/sky.glsl b/drivers/gles3/shaders/sky.glsl
index 21f01d2a8f..4c0fe47f6b 100644
--- a/drivers/gles3/shaders/sky.glsl
+++ b/drivers/gles3/shaders/sky.glsl
@@ -104,6 +104,15 @@ uniform uint directional_light_count;
layout(location = 0) out vec4 frag_color;
+#ifdef USE_DEBANDING
+// https://www.iryoku.com/next-generation-post-processing-in-call-of-duty-advanced-warfare
+vec3 interleaved_gradient_noise(vec2 pos) {
+ const vec3 magic = vec3(0.06711056f, 0.00583715f, 52.9829189f);
+ float res = fract(magic.z * fract(dot(pos, magic.xy))) * 2.0 - 1.0;
+ return vec3(res, -res, res) / 255.0;
+}
+#endif
+
void main() {
vec3 cube_normal;
cube_normal.z = -1.0;
@@ -168,4 +177,8 @@ void main() {
frag_color.rgb = color;
frag_color.a = alpha;
+
+#ifdef USE_DEBANDING
+ frag_color.rgb += interleaved_gradient_noise(gl_FragCoord.xy);
+#endif
}
diff --git a/drivers/gles3/storage/material_storage.cpp b/drivers/gles3/storage/material_storage.cpp
index 3dbc75392c..523c9dd8e6 100644
--- a/drivers/gles3/storage/material_storage.cpp
+++ b/drivers/gles3/storage/material_storage.cpp
@@ -1715,6 +1715,7 @@ ShaderCompiler::DefaultIdentifierActions actions;
actions.usage_defines["HALF_RES_COLOR"] = "\n#define USES_HALF_RES_COLOR\n";
actions.usage_defines["QUARTER_RES_COLOR"] = "\n#define USES_QUARTER_RES_COLOR\n";
actions.render_mode_defines["disable_fog"] = "#define DISABLE_FOG\n";
+ actions.render_mode_defines["use_debanding"] = "#define USE_DEBANDING\n";
actions.default_filter = ShaderLanguage::FILTER_LINEAR_MIPMAP;
actions.default_repeat = ShaderLanguage::REPEAT_ENABLE;
diff --git a/drivers/gles3/storage/mesh_storage.cpp b/drivers/gles3/storage/mesh_storage.cpp
index e54ecd51c4..22d84eba93 100644
--- a/drivers/gles3/storage/mesh_storage.cpp
+++ b/drivers/gles3/storage/mesh_storage.cpp
@@ -554,6 +554,21 @@ void MeshStorage::mesh_clear(RID p_mesh) {
glDeleteBuffers(1, &s.index_buffer);
s.index_buffer = 0;
}
+
+ if (s.versions) {
+ memfree(s.versions); //reallocs, so free with memfree.
+ }
+
+ if (s.lod_count) {
+ for (uint32_t j = 0; j < s.lod_count; j++) {
+ if (s.lods[j].index_buffer != 0) {
+ glDeleteBuffers(1, &s.lods[j].index_buffer);
+ s.lods[j].index_buffer = 0;
+ }
+ }
+ memdelete_arr(s.lods);
+ }
+
memdelete(mesh->surfaces[i]);
}
if (mesh->surfaces) {
diff --git a/drivers/gles3/storage/texture_storage.cpp b/drivers/gles3/storage/texture_storage.cpp
index b8ab4d6839..a801b3285a 100644
--- a/drivers/gles3/storage/texture_storage.cpp
+++ b/drivers/gles3/storage/texture_storage.cpp
@@ -1199,7 +1199,7 @@ void TextureStorage::_update_render_target(RenderTarget *rt) {
rt->color_internal_format = rt->is_transparent ? GL_RGBA8 : GL_RGB10_A2;
rt->color_format = GL_RGBA;
- rt->color_type = rt->is_transparent ? GL_BYTE : GL_UNSIGNED_INT_2_10_10_10_REV;
+ rt->color_type = rt->is_transparent ? GL_UNSIGNED_BYTE : GL_UNSIGNED_INT_2_10_10_10_REV;
rt->image_format = Image::FORMAT_RGBA8;
glDisable(GL_SCISSOR_TEST);
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp
index 384f46c8df..beb2812999 100644
--- a/drivers/unix/os_unix.cpp
+++ b/drivers/unix/os_unix.cpp
@@ -200,7 +200,7 @@ double OS_Unix::get_unix_time() const {
return (double)tv_now.tv_sec + double(tv_now.tv_usec) / 1000000;
}
-OS::Date OS_Unix::get_date(bool p_utc) const {
+OS::DateTime OS_Unix::get_datetime(bool p_utc) const {
time_t t = time(nullptr);
struct tm lt;
if (p_utc) {
@@ -208,7 +208,7 @@ OS::Date OS_Unix::get_date(bool p_utc) const {
} else {
localtime_r(&t, &lt);
}
- Date ret;
+ DateTime ret;
ret.year = 1900 + lt.tm_year;
// Index starting at 1 to match OS_Unix::get_date
// and Windows SYSTEMTIME and tm_mon follows the typical structure
@@ -216,24 +216,11 @@ OS::Date OS_Unix::get_date(bool p_utc) const {
ret.month = (Month)(lt.tm_mon + 1);
ret.day = lt.tm_mday;
ret.weekday = (Weekday)lt.tm_wday;
- ret.dst = lt.tm_isdst;
-
- return ret;
-}
-
-OS::Time OS_Unix::get_time(bool p_utc) const {
- time_t t = time(nullptr);
- struct tm lt;
- if (p_utc) {
- gmtime_r(&t, &lt);
- } else {
- localtime_r(&t, &lt);
- }
- Time ret;
ret.hour = lt.tm_hour;
ret.minute = lt.tm_min;
ret.second = lt.tm_sec;
- get_time_zone_info();
+ ret.dst = lt.tm_isdst;
+
return ret;
}
diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h
index f4609a565b..b4c844bfef 100644
--- a/drivers/unix/os_unix.h
+++ b/drivers/unix/os_unix.h
@@ -63,8 +63,7 @@ public:
virtual String get_name() const override;
- virtual Date get_date(bool p_utc) const override;
- virtual Time get_time(bool p_utc) const override;
+ virtual DateTime get_datetime(bool p_utc) const override;
virtual TimeZoneInfo get_time_zone_info() const override;
virtual double get_unix_time() const override;
diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp
index 4ac32d7317..3e72c6211d 100644
--- a/editor/create_dialog.cpp
+++ b/editor/create_dialog.cpp
@@ -296,6 +296,15 @@ void CreateDialog::_configure_search_option_item(TreeItem *r_item, const String
r_item->set_icon(0, EditorNode::get_singleton()->get_class_icon(p_type, icon_fallback));
}
+ bool is_deprecated = EditorHelp::get_doc_data()->class_list[p_type].is_deprecated;
+ bool is_experimental = EditorHelp::get_doc_data()->class_list[p_type].is_experimental;
+
+ if (is_deprecated) {
+ r_item->add_button(0, get_theme_icon("StatusError", SNAME("EditorIcons")), 0, false, TTR("This class is marked as deprecated."));
+ } else if (is_experimental) {
+ r_item->add_button(0, get_theme_icon("NodeWarning", SNAME("EditorIcons")), 0, false, TTR("This class is marked as experimental."));
+ }
+
if (!search_box->get_text().is_empty()) {
r_item->set_collapsed(false);
} else {
diff --git a/editor/debugger/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp
index cf48366bd3..a882275375 100644
--- a/editor/debugger/editor_profiler.cpp
+++ b/editor/debugger/editor_profiler.cpp
@@ -104,6 +104,10 @@ void EditorProfiler::clear() {
updating_frame = false;
hover_metric = -1;
seeking = false;
+
+ // Ensure button text (start, stop) is correct
+ _set_button_text();
+ emit_signal(SNAME("enable_profiling"), activate->is_pressed());
}
static String _get_percent_txt(float p_value, float p_total) {
@@ -374,15 +378,23 @@ void EditorProfiler::_update_frame() {
updating_frame = false;
}
-void EditorProfiler::_activate_pressed() {
+void EditorProfiler::_set_button_text() {
if (activate->is_pressed()) {
activate->set_icon(get_theme_icon(SNAME("Stop"), SNAME("EditorIcons")));
activate->set_text(TTR("Stop"));
- _clear_pressed();
} else {
activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons")));
activate->set_text(TTR("Start"));
}
+}
+
+void EditorProfiler::_activate_pressed() {
+ _set_button_text();
+
+ if (activate->is_pressed()) {
+ _clear_pressed();
+ }
+
emit_signal(SNAME("enable_profiling"), activate->is_pressed());
}
@@ -499,8 +511,12 @@ void EditorProfiler::_bind_methods() {
ADD_SIGNAL(MethodInfo("break_request"));
}
-void EditorProfiler::set_enabled(bool p_enable) {
+void EditorProfiler::set_enabled(bool p_enable, bool p_clear) {
+ activate->set_pressed(false);
activate->set_disabled(!p_enable);
+ if (p_clear) {
+ clear();
+ }
}
bool EditorProfiler::is_profiling() {
diff --git a/editor/debugger/editor_profiler.h b/editor/debugger/editor_profiler.h
index df92125258..e9ecc285ed 100644
--- a/editor/debugger/editor_profiler.h
+++ b/editor/debugger/editor_profiler.h
@@ -122,6 +122,7 @@ private:
Timer *frame_delay = nullptr;
Timer *plot_delay = nullptr;
+ void _set_button_text();
void _update_frame();
void _activate_pressed();
@@ -153,7 +154,7 @@ protected:
public:
void add_frame_metric(const Metric &p_metric, bool p_final = false);
- void set_enabled(bool p_enable);
+ void set_enabled(bool p_enable, bool p_clear = true);
bool is_profiling();
bool is_seeking() { return seeking; }
void disable_seeking();
diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp
index 5baa9970af..6bc1536cb9 100644
--- a/editor/debugger/script_editor_debugger.cpp
+++ b/editor/debugger/script_editor_debugger.cpp
@@ -52,7 +52,6 @@
#include "editor/plugins/node_3d_editor_plugin.h"
#include "main/performance.h"
#include "scene/3d/camera_3d.h"
-#include "scene/debugger/scene_debugger.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/label.h"
#include "scene/gui/line_edit.h"
@@ -317,7 +316,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
if (!error.is_empty()) {
tabs->set_current_tab(0);
}
- profiler->set_enabled(false);
+ profiler->set_enabled(false, false);
inspector->clear_cache(); // Take a chance to force remote objects update.
} else if (p_msg == "debug_exit") {
@@ -327,7 +326,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
_update_buttons_state();
_set_reason_text(TTR("Execution resumed."), MESSAGE_SUCCESS);
emit_signal(SNAME("breaked"), false, false, "", false);
- profiler->set_enabled(true);
+ profiler->set_enabled(true, false);
profiler->disable_seeking();
} else if (p_msg == "set_pid") {
ERR_FAIL_COND(p_data.size() < 1);
@@ -916,6 +915,8 @@ void ScriptEditorDebugger::start(Ref<RemoteDebuggerPeer> p_peer) {
_clear_errors_list();
stop();
+ profiler->set_enabled(true, true);
+
peer = p_peer;
ERR_FAIL_COND(p_peer.is_null());
@@ -971,6 +972,8 @@ void ScriptEditorDebugger::stop() {
res_path_cache.clear();
profiler_signature.clear();
+ profiler->set_enabled(true, false);
+
inspector->edit(nullptr);
_update_buttons_state();
}
diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp
index ec9a744e57..9f655ab00a 100644
--- a/editor/doc_tools.cpp
+++ b/editor/doc_tools.cpp
@@ -85,6 +85,9 @@ void DocTools::merge_from(const DocTools &p_data) {
const DocData::ClassDoc &cf = p_data.class_list[c.name];
+ c.is_deprecated = cf.is_deprecated;
+ c.is_experimental = cf.is_experimental;
+
c.description = cf.description;
c.brief_description = cf.brief_description;
c.tutorials = cf.tutorials;
@@ -133,6 +136,8 @@ void DocTools::merge_from(const DocTools &p_data) {
const DocData::MethodDoc &mf = cf.constructors[j];
m.description = mf.description;
+ m.is_deprecated = mf.is_deprecated;
+ m.is_experimental = mf.is_experimental;
break;
}
}
@@ -148,6 +153,8 @@ void DocTools::merge_from(const DocTools &p_data) {
const DocData::MethodDoc &mf = cf.methods[j];
m.description = mf.description;
+ m.is_deprecated = mf.is_deprecated;
+ m.is_experimental = mf.is_experimental;
break;
}
}
@@ -162,6 +169,8 @@ void DocTools::merge_from(const DocTools &p_data) {
const DocData::MethodDoc &mf = cf.signals[j];
m.description = mf.description;
+ m.is_deprecated = mf.is_deprecated;
+ m.is_experimental = mf.is_experimental;
break;
}
}
@@ -176,6 +185,8 @@ void DocTools::merge_from(const DocTools &p_data) {
const DocData::ConstantDoc &mf = cf.constants[j];
m.description = mf.description;
+ m.is_deprecated = mf.is_deprecated;
+ m.is_experimental = mf.is_experimental;
break;
}
}
@@ -190,6 +201,8 @@ void DocTools::merge_from(const DocTools &p_data) {
const DocData::MethodDoc &mf = cf.annotations[j];
m.description = mf.description;
+ m.is_deprecated = mf.is_deprecated;
+ m.is_experimental = mf.is_experimental;
break;
}
}
@@ -204,6 +217,8 @@ void DocTools::merge_from(const DocTools &p_data) {
const DocData::PropertyDoc &pf = cf.properties[j];
p.description = pf.description;
+ p.is_deprecated = pf.is_deprecated;
+ p.is_experimental = pf.is_experimental;
break;
}
}
@@ -266,6 +281,8 @@ void DocTools::merge_from(const DocTools &p_data) {
const DocData::MethodDoc &mf = cf.operators[j];
m.description = mf.description;
+ m.is_deprecated = mf.is_deprecated;
+ m.is_experimental = mf.is_experimental;
break;
}
}
@@ -1007,6 +1024,12 @@ static Error _parse_methods(Ref<XMLParser> &parser, Vector<DocData::MethodDoc> &
if (parser->has_attribute("qualifiers")) {
method.qualifiers = parser->get_attribute_value("qualifiers");
}
+ if (parser->has_attribute("is_deprecated")) {
+ method.is_deprecated = parser->get_attribute_value("is_deprecated").to_lower() == "true";
+ }
+ if (parser->has_attribute("is_experimental")) {
+ method.is_experimental = parser->get_attribute_value("is_experimental").to_lower() == "true";
+ }
while (parser->read() == OK) {
if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
@@ -1138,6 +1161,16 @@ Error DocTools::_load(Ref<XMLParser> parser) {
c.inherits = parser->get_attribute_value("inherits");
}
+ if (parser->has_attribute("is_deprecated")) {
+ String result = parser->get_attribute_value("is_deprecated");
+ c.is_deprecated = (result == "true" || result == "True" || result == "TRUE" || result == "1");
+ }
+
+ if (parser->has_attribute("is_experimental")) {
+ String result = parser->get_attribute_value("is_experimental");
+ c.is_experimental = (result == "true" || result == "True" || result == "TRUE" || result == "1");
+ }
+
while (parser->read() == OK) {
if (parser->get_node_type() == XMLParser::NODE_ELEMENT) {
String name2 = parser->get_node_name();
@@ -1211,6 +1244,12 @@ Error DocTools::_load(Ref<XMLParser> parser) {
if (parser->has_attribute("enum")) {
prop2.enumeration = parser->get_attribute_value("enum");
}
+ if (parser->has_attribute("is_deprecated")) {
+ prop2.is_deprecated = parser->get_attribute_value("is_deprecated").to_lower() == "true";
+ }
+ if (parser->has_attribute("is_experimental")) {
+ prop2.is_experimental = parser->get_attribute_value("is_experimental").to_lower() == "true";
+ }
if (!parser->is_empty()) {
parser->read();
if (parser->get_node_type() == XMLParser::NODE_TEXT) {
@@ -1275,6 +1314,14 @@ Error DocTools::_load(Ref<XMLParser> parser) {
if (parser->has_attribute("is_bitfield")) {
constant2.is_bitfield = parser->get_attribute_value("is_bitfield").to_lower() == "true";
}
+ if (parser->has_attribute("is_deprecated")) {
+ String result = parser->get_attribute_value("is_deprecated");
+ constant2.is_deprecated = (result == "true" || result == "True" || result == "TRUE" || result == "1");
+ }
+ if (parser->has_attribute("is_experimental")) {
+ String result = parser->get_attribute_value("is_experimental");
+ constant2.is_experimental = (result == "true" || result == "True" || result == "TRUE" || result == "1");
+ }
if (!parser->is_empty()) {
parser->read();
if (parser->get_node_type() == XMLParser::NODE_TEXT) {
@@ -1327,7 +1374,15 @@ static void _write_method_doc(Ref<FileAccess> f, const String &p_name, Vector<Do
qualifiers += " qualifiers=\"" + m.qualifiers.xml_escape() + "\"";
}
- _write_string(f, 2, "<" + p_name + " name=\"" + m.name.xml_escape() + "\"" + qualifiers + ">");
+ String additional_attributes;
+ if (m.is_deprecated) {
+ additional_attributes += " is_deprecated=\"True\"";
+ }
+ if (m.is_experimental) {
+ additional_attributes += " is_experimental=\"True\"";
+ }
+
+ _write_string(f, 2, "<" + p_name + " name=\"" + m.name.xml_escape() + "\"" + qualifiers + additional_attributes + ">");
if (!m.return_type.is_empty()) {
String enum_text;
@@ -1390,6 +1445,12 @@ Error DocTools::save_classes(const String &p_default_path, const HashMap<String,
String header = "<class name=\"" + c.name + "\"";
if (!c.inherits.is_empty()) {
header += " inherits=\"" + c.inherits + "\"";
+ if (c.is_deprecated) {
+ header += " is_deprecated=\"True\"";
+ }
+ if (c.is_experimental) {
+ header += " is_experimental=\"True\"";
+ }
}
header += String(" version=\"") + VERSION_BRANCH + "\"";
// Reference the XML schema so editors can provide error checking.
@@ -1433,6 +1494,12 @@ Error DocTools::save_classes(const String &p_default_path, const HashMap<String,
if (!c.properties[i].default_value.is_empty()) {
additional_attributes += " default=\"" + c.properties[i].default_value.xml_escape(true) + "\"";
}
+ if (c.properties[i].is_deprecated) {
+ additional_attributes += " is_deprecated=\"True\"";
+ }
+ if (c.properties[i].is_experimental) {
+ additional_attributes += " is_experimental=\"True\"";
+ }
const DocData::PropertyDoc &p = c.properties[i];
@@ -1453,21 +1520,30 @@ Error DocTools::save_classes(const String &p_default_path, const HashMap<String,
_write_string(f, 1, "<constants>");
for (int i = 0; i < c.constants.size(); i++) {
const DocData::ConstantDoc &k = c.constants[i];
+
+ String additional_attributes;
+ if (c.constants[i].is_deprecated) {
+ additional_attributes += " is_deprecated=\"True\"";
+ }
+ if (c.constants[i].is_experimental) {
+ additional_attributes += " is_experimental=\"True\"";
+ }
+
if (k.is_value_valid) {
if (!k.enumeration.is_empty()) {
if (k.is_bitfield) {
- _write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"" + k.value + "\" enum=\"" + k.enumeration + "\" is_bitfield=\"true\">");
+ _write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"" + k.value + "\" enum=\"" + k.enumeration + "\" is_bitfield=\"true\"" + additional_attributes + ">");
} else {
- _write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"" + k.value + "\" enum=\"" + k.enumeration + "\">");
+ _write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"" + k.value + "\" enum=\"" + k.enumeration + "\"" + additional_attributes + ">");
}
} else {
- _write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"" + k.value + "\">");
+ _write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"" + k.value + "\"" + additional_attributes + ">");
}
} else {
if (!k.enumeration.is_empty()) {
- _write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"platform-dependent\" enum=\"" + k.enumeration + "\">");
+ _write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"platform-dependent\" enum=\"" + k.enumeration + "\"" + additional_attributes + ">");
} else {
- _write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"platform-dependent\">");
+ _write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"platform-dependent\"" + additional_attributes + ">");
}
}
_write_string(f, 3, _translate_doc_string(k.description).strip_edges().xml_escape());
diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp
index fffe77f1c4..c31d13d122 100644
--- a/editor/editor_fonts.cpp
+++ b/editor/editor_fonts.cpp
@@ -96,6 +96,7 @@ void editor_register_fonts(Ref<Theme> p_theme) {
TextServer::SubpixelPositioning font_subpixel_positioning = (TextServer::SubpixelPositioning)(int)EditorSettings::get_singleton()->get("interface/editor/font_subpixel_positioning");
TextServer::Hinting font_hinting;
+ TextServer::Hinting font_mono_hinting;
switch (font_hinting_setting) {
case 0:
// The "Auto" setting uses the setting that best matches the OS' font rendering:
@@ -104,18 +105,23 @@ void editor_register_fonts(Ref<Theme> p_theme) {
// - Linux has configurable font hinting, but most distributions including Ubuntu default to "Light".
#ifdef MACOS_ENABLED
font_hinting = TextServer::HINTING_NONE;
+ font_mono_hinting = TextServer::HINTING_NONE;
#else
font_hinting = TextServer::HINTING_LIGHT;
+ font_mono_hinting = TextServer::HINTING_LIGHT;
#endif
break;
case 1:
font_hinting = TextServer::HINTING_NONE;
+ font_mono_hinting = TextServer::HINTING_NONE;
break;
case 2:
font_hinting = TextServer::HINTING_LIGHT;
+ font_mono_hinting = TextServer::HINTING_LIGHT;
break;
default:
font_hinting = TextServer::HINTING_NORMAL;
+ font_mono_hinting = TextServer::HINTING_LIGHT;
break;
}
@@ -163,7 +169,7 @@ void editor_register_fonts(Ref<Theme> p_theme) {
default_font_bold->set_fallbacks(fallbacks_bold);
default_font_bold_msdf->set_fallbacks(fallbacks_bold);
- Ref<FontFile> default_font_mono = load_internal_font(_font_JetBrainsMono_Regular, _font_JetBrainsMono_Regular_size, font_hinting, font_antialiasing, true, font_subpixel_positioning);
+ Ref<FontFile> default_font_mono = load_internal_font(_font_JetBrainsMono_Regular, _font_JetBrainsMono_Regular_size, font_mono_hinting, font_antialiasing, true, font_subpixel_positioning);
default_font_mono->set_fallbacks(fallbacks);
// Init base font configs and load custom fonts.
@@ -260,7 +266,7 @@ void editor_register_fonts(Ref<Theme> p_theme) {
Ref<FontVariation> mono_fc;
mono_fc.instantiate();
if (custom_font_path_source.length() > 0 && dir->file_exists(custom_font_path_source)) {
- Ref<FontFile> custom_font = load_external_font(custom_font_path_source, font_hinting, font_antialiasing, true, font_subpixel_positioning);
+ Ref<FontFile> custom_font = load_external_font(custom_font_path_source, font_mono_hinting, font_antialiasing, true, font_subpixel_positioning);
{
TypedArray<Font> fallback_custom;
fallback_custom.push_back(default_font_mono);
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index b8f115e82e..745dcdd04c 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -276,6 +276,23 @@ String EditorHelp::_fix_constant(const String &p_constant) const {
return p_constant;
}
+// Macros for assigning the deprecation/experimental information to class members
+#define DEPRECATED_DOC_TAG \
+ class_desc->push_color(get_theme_color(SNAME("error_color"), SNAME("Editor"))); \
+ Ref<Texture2D> error_icon = get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons")); \
+ class_desc->add_text(" "); \
+ class_desc->add_image(error_icon, error_icon->get_width(), error_icon->get_height()); \
+ class_desc->add_text(" (" + TTR("Deprecated") + ")"); \
+ class_desc->pop();
+
+#define EXPERIMENTAL_DOC_TAG \
+ class_desc->push_color(get_theme_color(SNAME("warning_color"), SNAME("Editor"))); \
+ Ref<Texture2D> warning_icon = get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons")); \
+ class_desc->add_text(" "); \
+ class_desc->add_image(warning_icon, warning_icon->get_width(), warning_icon->get_height()); \
+ class_desc->add_text(" (" + TTR("Experimental") + ")"); \
+ class_desc->pop();
+
void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview) {
method_line[p_method.name] = class_desc->get_paragraph_count() - 2; //gets overridden if description
@@ -356,6 +373,14 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview
class_desc->pop();
}
+ if (p_method.is_deprecated) {
+ DEPRECATED_DOC_TAG;
+ }
+
+ if (p_method.is_experimental) {
+ EXPERIMENTAL_DOC_TAG;
+ }
+
if (p_overview) {
class_desc->pop(); //cell
}
@@ -565,6 +590,17 @@ void EditorHelp::_update_doc() {
class_desc->pop(); // color
class_desc->pop(); // font size
class_desc->pop(); // font
+
+ if (cd.is_deprecated) {
+ class_desc->add_text(" ");
+ Ref<Texture2D> error_icon = get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons"));
+ class_desc->add_image(error_icon, error_icon->get_width(), error_icon->get_height());
+ }
+ if (cd.is_experimental) {
+ class_desc->add_text(" ");
+ Ref<Texture2D> warning_icon = get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons"));
+ class_desc->add_image(warning_icon, warning_icon->get_width(), warning_icon->get_height());
+ }
class_desc->add_newline();
const String non_breaking_space = String::chr(160);
@@ -627,6 +663,26 @@ void EditorHelp::_update_doc() {
}
}
+ // Note if deprecated.
+ if (cd.is_deprecated) {
+ Ref<Texture2D> error_icon = get_theme_icon(SNAME("StatusError"), SNAME("EditorIcons"));
+ class_desc->push_color(get_theme_color(SNAME("error_color"), SNAME("Editor")));
+ class_desc->add_image(error_icon, error_icon->get_width(), error_icon->get_height());
+ class_desc->add_text(String(" ") + TTR("This class is marked as deprecated. It will be removed in future versions."));
+ class_desc->pop();
+ class_desc->add_newline();
+ }
+
+ // Note if experimental.
+ if (cd.is_experimental) {
+ Ref<Texture2D> warning_icon = get_theme_icon(SNAME("NodeWarning"), SNAME("EditorIcons"));
+ class_desc->push_color(get_theme_color(SNAME("warning_color"), SNAME("Editor")));
+ class_desc->add_image(warning_icon, warning_icon->get_width(), warning_icon->get_height());
+ class_desc->add_text(String(" ") + TTR("This class is marked as experimental. It is subject to likely change or possible removal in future versions. Use at your own discretion."));
+ class_desc->pop();
+ class_desc->add_newline();
+ }
+
class_desc->add_newline();
class_desc->add_newline();
@@ -817,6 +873,13 @@ void EditorHelp::_update_doc() {
class_desc->pop();
}
+ if (cd.properties[i].is_deprecated) {
+ DEPRECATED_DOC_TAG;
+ }
+ if (cd.properties[i].is_experimental) {
+ EXPERIMENTAL_DOC_TAG;
+ }
+
class_desc->pop();
class_desc->pop(); // cell
@@ -1066,6 +1129,14 @@ void EditorHelp::_update_doc() {
class_desc->push_color(symbol_color);
class_desc->add_text(")");
+
+ if (cd.signals[i].is_deprecated) {
+ DEPRECATED_DOC_TAG;
+ }
+ if (cd.signals[i].is_experimental) {
+ EXPERIMENTAL_DOC_TAG;
+ }
+
class_desc->pop();
class_desc->pop(); // end monofont
if (!cd.signals[i].description.strip_edges().is_empty()) {
@@ -1187,6 +1258,14 @@ void EditorHelp::_update_doc() {
class_desc->pop();
class_desc->pop();
+ if (enum_list[i].is_deprecated) {
+ DEPRECATED_DOC_TAG;
+ }
+
+ if (enum_list[i].is_experimental) {
+ EXPERIMENTAL_DOC_TAG;
+ }
+
class_desc->add_newline();
if (!enum_list[i].description.strip_edges().is_empty()) {
@@ -1258,6 +1337,14 @@ void EditorHelp::_update_doc() {
class_desc->pop();
+ if (constants[i].is_deprecated) {
+ DEPRECATED_DOC_TAG;
+ }
+
+ if (constants[i].is_experimental) {
+ EXPERIMENTAL_DOC_TAG;
+ }
+
class_desc->add_newline();
if (!constants[i].description.strip_edges().is_empty()) {
@@ -1438,6 +1525,13 @@ void EditorHelp::_update_doc() {
class_desc->pop(); // color
}
+ if (cd.properties[i].is_deprecated) {
+ DEPRECATED_DOC_TAG;
+ }
+ if (cd.properties[i].is_experimental) {
+ EXPERIMENTAL_DOC_TAG;
+ }
+
if (cd.is_script_doc && (!cd.properties[i].setter.is_empty() || !cd.properties[i].getter.is_empty())) {
class_desc->push_color(symbol_color);
class_desc->add_text(" [" + TTR("property:") + " ");
diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp
index af0cff9ad6..7e7d7ca418 100644
--- a/editor/editor_help_search.cpp
+++ b/editor/editor_help_search.cpp
@@ -326,6 +326,7 @@ bool EditorHelpSearch::Runner::_phase_match_classes_init() {
bool EditorHelpSearch::Runner::_phase_match_classes() {
DocData::ClassDoc &class_doc = iterator_doc->value;
if (class_doc.name.is_empty()) {
+ ++iterator_doc;
return false;
}
if (!_is_class_disabled_by_feature_profile(class_doc.name)) {
@@ -432,7 +433,7 @@ bool EditorHelpSearch::Runner::_phase_class_items_init() {
bool EditorHelpSearch::Runner::_phase_class_items() {
if (!iterator_match) {
- return false;
+ return true;
}
ClassMatch &match = iterator_match->value;
@@ -459,10 +460,8 @@ bool EditorHelpSearch::Runner::_phase_member_items_init() {
bool EditorHelpSearch::Runner::_phase_member_items() {
ClassMatch &match = iterator_match->value;
- if (!match.doc) {
- return false;
- }
- if (match.doc->name.is_empty()) {
+ if (!match.doc || match.doc->name.is_empty()) {
+ ++iterator_match;
return false;
}
@@ -599,6 +598,14 @@ TreeItem *EditorHelpSearch::Runner::_create_class_item(TreeItem *p_parent, const
item->set_custom_color(1, disabled_color);
}
+ if (p_doc->is_deprecated) {
+ Ref<Texture2D> error_icon = ui_service->get_theme_icon("StatusError", SNAME("EditorIcons"));
+ item->add_button(0, error_icon, 0, false, TTR("This class is marked as deprecated."));
+ } else if (p_doc->is_experimental) {
+ Ref<Texture2D> warning_icon = ui_service->get_theme_icon("NodeWarning", SNAME("EditorIcons"));
+ item->add_button(0, warning_icon, 0, false, TTR("This class is marked as experimental."));
+ }
+
_match_item(item, p_doc->name);
return item;
@@ -606,37 +613,37 @@ TreeItem *EditorHelpSearch::Runner::_create_class_item(TreeItem *p_parent, const
TreeItem *EditorHelpSearch::Runner::_create_method_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const String &p_text, const DocData::MethodDoc *p_doc) {
String tooltip = _build_method_tooltip(p_class_doc, p_doc);
- return _create_member_item(p_parent, p_class_doc->name, "MemberMethod", p_doc->name, p_text, TTRC("Method"), "method", tooltip);
+ return _create_member_item(p_parent, p_class_doc->name, "MemberMethod", p_doc->name, p_text, TTRC("Method"), "method", tooltip, p_doc->is_deprecated, p_doc->is_experimental);
}
TreeItem *EditorHelpSearch::Runner::_create_signal_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::MethodDoc *p_doc) {
String tooltip = _build_method_tooltip(p_class_doc, p_doc);
- return _create_member_item(p_parent, p_class_doc->name, "MemberSignal", p_doc->name, p_doc->name, TTRC("Signal"), "signal", tooltip);
+ return _create_member_item(p_parent, p_class_doc->name, "MemberSignal", p_doc->name, p_doc->name, TTRC("Signal"), "signal", tooltip, p_doc->is_deprecated, p_doc->is_experimental);
}
TreeItem *EditorHelpSearch::Runner::_create_annotation_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const String &p_text, const DocData::MethodDoc *p_doc) {
String tooltip = _build_method_tooltip(p_class_doc, p_doc);
- return _create_member_item(p_parent, p_class_doc->name, "MemberAnnotation", p_doc->name, p_text, TTRC("Annotation"), "annotation", tooltip);
+ return _create_member_item(p_parent, p_class_doc->name, "MemberAnnotation", p_doc->name, p_text, TTRC("Annotation"), "annotation", tooltip, p_doc->is_deprecated, p_doc->is_experimental);
}
TreeItem *EditorHelpSearch::Runner::_create_constant_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::ConstantDoc *p_doc) {
String tooltip = p_class_doc->name + "." + p_doc->name;
- return _create_member_item(p_parent, p_class_doc->name, "MemberConstant", p_doc->name, p_doc->name, TTRC("Constant"), "constant", tooltip);
+ return _create_member_item(p_parent, p_class_doc->name, "MemberConstant", p_doc->name, p_doc->name, TTRC("Constant"), "constant", tooltip, p_doc->is_deprecated, p_doc->is_experimental);
}
TreeItem *EditorHelpSearch::Runner::_create_property_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::PropertyDoc *p_doc) {
String tooltip = p_doc->type + " " + p_class_doc->name + "." + p_doc->name;
tooltip += "\n " + p_class_doc->name + "." + p_doc->setter + "(value) setter";
tooltip += "\n " + p_class_doc->name + "." + p_doc->getter + "() getter";
- return _create_member_item(p_parent, p_class_doc->name, "MemberProperty", p_doc->name, p_doc->name, TTRC("Property"), "property", tooltip);
+ return _create_member_item(p_parent, p_class_doc->name, "MemberProperty", p_doc->name, p_doc->name, TTRC("Property"), "property", tooltip, p_doc->is_deprecated, p_doc->is_experimental);
}
TreeItem *EditorHelpSearch::Runner::_create_theme_property_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::ThemeItemDoc *p_doc) {
String tooltip = p_doc->type + " " + p_class_doc->name + "." + p_doc->name;
- return _create_member_item(p_parent, p_class_doc->name, "MemberTheme", p_doc->name, p_doc->name, TTRC("Theme Property"), "theme_item", tooltip);
+ return _create_member_item(p_parent, p_class_doc->name, "MemberTheme", p_doc->name, p_doc->name, TTRC("Theme Property"), "theme_item", tooltip, false, false);
}
-TreeItem *EditorHelpSearch::Runner::_create_member_item(TreeItem *p_parent, const String &p_class_name, const String &p_icon, const String &p_name, const String &p_text, const String &p_type, const String &p_metatype, const String &p_tooltip) {
+TreeItem *EditorHelpSearch::Runner::_create_member_item(TreeItem *p_parent, const String &p_class_name, const String &p_icon, const String &p_name, const String &p_text, const String &p_type, const String &p_metatype, const String &p_tooltip, bool is_deprecated, bool is_experimental) {
Ref<Texture2D> icon;
String text;
if (search_flags & SEARCH_SHOW_HIERARCHY) {
@@ -655,6 +662,14 @@ TreeItem *EditorHelpSearch::Runner::_create_member_item(TreeItem *p_parent, cons
item->set_tooltip_text(1, p_tooltip);
item->set_metadata(0, "class_" + p_metatype + ":" + p_class_name + ":" + p_name);
+ if (is_deprecated) {
+ Ref<Texture2D> error_icon = ui_service->get_theme_icon("StatusError", SNAME("EditorIcons"));
+ item->add_button(0, error_icon, 0, false, TTR("This member is marked as deprecated."));
+ } else if (is_experimental) {
+ Ref<Texture2D> warning_icon = ui_service->get_theme_icon("NodeWarning", SNAME("EditorIcons"));
+ item->add_button(0, warning_icon, 0, false, TTR("This member is marked as experimental."));
+ }
+
_match_item(item, p_name);
return item;
diff --git a/editor/editor_help_search.h b/editor/editor_help_search.h
index 26abaec6e6..efd8645cd7 100644
--- a/editor/editor_help_search.h
+++ b/editor/editor_help_search.h
@@ -155,7 +155,7 @@ class EditorHelpSearch::Runner : public RefCounted {
TreeItem *_create_constant_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::ConstantDoc *p_doc);
TreeItem *_create_property_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::PropertyDoc *p_doc);
TreeItem *_create_theme_property_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::ThemeItemDoc *p_doc);
- TreeItem *_create_member_item(TreeItem *p_parent, const String &p_class_name, const String &p_icon, const String &p_name, const String &p_text, const String &p_type, const String &p_metatype, const String &p_tooltip);
+ TreeItem *_create_member_item(TreeItem *p_parent, const String &p_class_name, const String &p_icon, const String &p_name, const String &p_text, const String &p_type, const String &p_metatype, const String &p_tooltip, bool is_deprecated, bool is_experimental);
public:
bool work(uint64_t slot = 100000);
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index f001887ef9..9e7314bf50 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -1651,6 +1651,10 @@ void EditorInspectorArray::_panel_draw(int p_index) {
void EditorInspectorArray::_panel_gui_input(Ref<InputEvent> p_event, int p_index) {
ERR_FAIL_INDEX(p_index, (int)array_elements.size());
+ if (read_only) {
+ return;
+ }
+
Ref<InputEventKey> key_ref = p_event;
if (key_ref.is_valid()) {
const InputEventKey &key = **key_ref;
@@ -2151,7 +2155,7 @@ void EditorInspectorArray::drop_data_fw(const Point2 &p_point, const Variant &p_
}
bool EditorInspectorArray::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
- if (!movable) {
+ if (!movable || read_only) {
return false;
}
// First, update drawing.
@@ -2271,7 +2275,9 @@ VBoxContainer *EditorInspectorArray::get_vbox(int p_index) {
}
}
-EditorInspectorArray::EditorInspectorArray() {
+EditorInspectorArray::EditorInspectorArray(bool p_read_only) {
+ read_only = p_read_only;
+
set_mouse_filter(Control::MOUSE_FILTER_STOP);
odd_style.instantiate();
@@ -2297,6 +2303,7 @@ EditorInspectorArray::EditorInspectorArray() {
add_button = EditorInspector::create_inspector_action_button(TTR("Add Element"));
add_button->connect("pressed", callable_mp(this, &EditorInspectorArray::_add_button_pressed));
+ add_button->set_disabled(read_only);
vbox->add_child(add_button);
control_dropping = memnew(Control);
@@ -2317,6 +2324,7 @@ EditorInspectorArray::EditorInspectorArray() {
new_size_spin_box->set_max(16384);
new_size_spin_box->connect("value_changed", callable_mp(this, &EditorInspectorArray::_new_size_spin_box_value_changed));
new_size_spin_box->get_line_edit()->connect("text_submitted", callable_mp(this, &EditorInspectorArray::_new_size_spin_box_text_submitted));
+ new_size_spin_box->set_editable(!read_only);
resize_dialog_vbox->add_margin_child(TTRC("New Size:"), new_size_spin_box);
vbox->connect("visibility_changed", callable_mp(this, &EditorInspectorArray::_vbox_visibility_changed));
@@ -3051,7 +3059,7 @@ void EditorInspector::update_tree() {
if (p.type == Variant::NIL) {
// Setup the array to use a method to create/move/delete elements.
array_element_prefix = class_name_components[0];
- editor_inspector_array = memnew(EditorInspectorArray);
+ editor_inspector_array = memnew(EditorInspectorArray(all_read_only));
String array_label = path.contains("/") ? path.substr(path.rfind("/") + 1) : path;
array_label = EditorPropertyNameProcessor::get_singleton()->process_name(property_label_string, property_name_style);
@@ -3063,7 +3071,7 @@ void EditorInspector::update_tree() {
// Setup the array to use the count property and built-in functions to create/move/delete elements.
if (class_name_components.size() >= 2) {
array_element_prefix = class_name_components[1];
- editor_inspector_array = memnew(EditorInspectorArray);
+ editor_inspector_array = memnew(EditorInspectorArray(all_read_only));
int page = per_array_page.has(array_element_prefix) ? per_array_page[array_element_prefix] : 0;
editor_inspector_array->setup_with_count_property(object, class_name_components[0], p.name, array_element_prefix, page, c, foldable, movable, numbered, page_size, add_button_text, swap_method);
diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h
index d634eae23f..70378d8cf2 100644
--- a/editor/editor_inspector.h
+++ b/editor/editor_inspector.h
@@ -333,6 +333,7 @@ class EditorInspectorArray : public EditorInspectorSection {
int begin_array_index = 0;
int end_array_index = 0;
+ bool read_only = false;
bool movable = true;
bool numbered = false;
@@ -404,7 +405,7 @@ public:
void setup_with_count_property(Object *p_object, String p_label, const StringName &p_count_property, const StringName &p_array_element_prefix, int p_page, const Color &p_bg_color, bool p_foldable, bool p_movable = true, bool p_numbered = false, int p_page_length = 5, const String &p_add_item_text = "", const String &p_swap_method = "");
VBoxContainer *get_vbox(int p_index);
- EditorInspectorArray();
+ EditorInspectorArray(bool p_read_only);
};
class EditorPaginator : public HBoxContainer {
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 9dc4c2c953..8eaddcb7e1 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -3932,7 +3932,7 @@ void EditorNode::edit_foreign_resource(Ref<Resource> p_resource) {
InspectorDock::get_singleton()->call_deferred("edit_resource", p_resource);
}
-bool EditorNode::is_resource_read_only(Ref<Resource> p_resource) {
+bool EditorNode::is_resource_read_only(Ref<Resource> p_resource, bool p_foreign_resources_are_writable) {
ERR_FAIL_COND_V(p_resource.is_null(), false);
String path = p_resource->get_path();
@@ -3944,7 +3944,11 @@ bool EditorNode::is_resource_read_only(Ref<Resource> p_resource) {
// If the base resource is a packed scene, we treat it as read-only if it is not the currently edited scene.
if (ResourceLoader::get_resource_type(base) == "PackedScene") {
if (!get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->get_scene_file_path() != base) {
- return true;
+ // If we have not flagged foreign resources as writable or the base scene the resource is
+ // part was imported, it can be considered read-only.
+ if (!p_foreign_resources_are_writable || FileAccess::exists(base + ".import")) {
+ return true;
+ }
}
} else {
// If a corresponding .import file exists for the base file, we assume it to be imported and should therefore treated as read-only.
@@ -6750,8 +6754,10 @@ EditorNode::EditorNode() {
project_menu->add_separator();
project_menu->add_shortcut(ED_SHORTCUT_AND_COMMAND("editor/export", TTR("Export..."), Key::NONE, TTR("Export")), FILE_EXPORT_PROJECT);
+#ifndef ANDROID_ENABLED
project_menu->add_item(TTR("Install Android Build Template..."), FILE_INSTALL_ANDROID_SOURCE);
project_menu->add_item(TTR("Open User Data Folder"), RUN_USER_DATA_FOLDER);
+#endif
project_menu->add_separator();
project_menu->add_item(TTR("Customize Engine Build Configuration..."), TOOLS_BUILD_PROFILE_MANAGER);
@@ -6814,12 +6820,14 @@ EditorNode::EditorNode() {
settings_menu->set_item_tooltip(-1, TTR("Screenshots are stored in the Editor Data/Settings Folder."));
+#ifndef ANDROID_ENABLED
ED_SHORTCUT_AND_COMMAND("editor/fullscreen_mode", TTR("Toggle Fullscreen"), KeyModifierMask::SHIFT | Key::F11);
ED_SHORTCUT_OVERRIDE("editor/fullscreen_mode", "macos", KeyModifierMask::META | KeyModifierMask::CTRL | Key::F);
settings_menu->add_shortcut(ED_GET_SHORTCUT("editor/fullscreen_mode"), SETTINGS_TOGGLE_FULLSCREEN);
-
+#endif
settings_menu->add_separator();
+#ifndef ANDROID_ENABLED
if (OS::get_singleton()->get_data_path() == OS::get_singleton()->get_config_path()) {
// Configuration and data folders are located in the same place (Windows/MacOS).
settings_menu->add_item(TTR("Open Editor Data/Settings Folder"), SETTINGS_EDITOR_DATA_FOLDER);
@@ -6829,9 +6837,12 @@ EditorNode::EditorNode() {
settings_menu->add_item(TTR("Open Editor Settings Folder"), SETTINGS_EDITOR_CONFIG_FOLDER);
}
settings_menu->add_separator();
+#endif
settings_menu->add_item(TTR("Manage Editor Features..."), SETTINGS_MANAGE_FEATURE_PROFILES);
+#ifndef ANDROID_ENABLED
settings_menu->add_item(TTR("Manage Export Templates..."), SETTINGS_MANAGE_EXPORT_TEMPLATES);
+#endif
help_menu = memnew(PopupMenu);
help_menu->set_name(TTR("Help"));
diff --git a/editor/editor_node.h b/editor/editor_node.h
index df3d2ae0f8..200d68908c 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -784,7 +784,7 @@ public:
void open_request(const String &p_path);
void edit_foreign_resource(Ref<Resource> p_resource);
- bool is_resource_read_only(Ref<Resource> p_resource);
+ bool is_resource_read_only(Ref<Resource> p_resource, bool p_foreign_resources_are_writable = false);
bool is_changing_scene() const;
diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp
index ad84b30689..728a3b0f80 100644
--- a/editor/editor_properties_array_dict.cpp
+++ b/editor/editor_properties_array_dict.cpp
@@ -268,6 +268,7 @@ void EditorPropertyArray::update_property() {
size_slider->set_step(1);
size_slider->set_max(1000000);
size_slider->set_h_size_flags(SIZE_EXPAND_FILL);
+ size_slider->set_read_only(is_read_only());
size_slider->connect("value_changed", callable_mp(this, &EditorPropertyArray::_length_changed));
hbox->add_child(size_slider);
@@ -278,6 +279,7 @@ void EditorPropertyArray::update_property() {
button_add_item = EditorInspector::create_inspector_action_button(TTR("Add Element"));
button_add_item->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
button_add_item->connect(SNAME("pressed"), callable_mp(this, &EditorPropertyArray::_add_element));
+ button_add_item->set_disabled(is_read_only());
vbox->add_child(button_add_item);
paginator = memnew(EditorPaginator);
@@ -328,6 +330,7 @@ void EditorPropertyArray::update_property() {
Button *reorder_button = memnew(Button);
reorder_button->set_icon(get_theme_icon(SNAME("TripleBar"), SNAME("EditorIcons")));
reorder_button->set_default_cursor_shape(Control::CURSOR_MOVE);
+ reorder_button->set_disabled(is_read_only());
reorder_button->connect("gui_input", callable_mp(this, &EditorPropertyArray::_reorder_button_gui_input));
reorder_button->connect("button_down", callable_mp(this, &EditorPropertyArray::_reorder_button_down).bind(i + offset));
reorder_button->connect("button_up", callable_mp(this, &EditorPropertyArray::_reorder_button_up));
@@ -358,6 +361,7 @@ void EditorPropertyArray::update_property() {
prop->connect("property_changed", callable_mp(this, &EditorPropertyArray::_property_changed));
prop->connect("object_id_selected", callable_mp(this, &EditorPropertyArray::_object_id_selected));
prop->set_h_size_flags(SIZE_EXPAND_FILL);
+ prop->set_read_only(is_read_only());
hbox->add_child(prop);
bool is_untyped_array = array.get_type() == Variant::ARRAY && subtype == Variant::NIL;
@@ -366,10 +370,12 @@ void EditorPropertyArray::update_property() {
Button *edit = memnew(Button);
edit->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")));
hbox->add_child(edit);
+ edit->set_disabled(is_read_only());
edit->connect("pressed", callable_mp(this, &EditorPropertyArray::_change_type).bind(edit, i + offset));
} else {
Button *remove = memnew(Button);
remove->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
+ remove->set_disabled(is_read_only());
remove->connect("pressed", callable_mp(this, &EditorPropertyArray::_remove_pressed).bind(i + offset));
hbox->add_child(remove);
}
@@ -409,6 +415,10 @@ void EditorPropertyArray::_button_draw() {
}
bool EditorPropertyArray::_is_drop_valid(const Dictionary &p_drag_data) const {
+ if (is_read_only()) {
+ return false;
+ }
+
String allowed_type = Variant::get_type_name(subtype);
// When the subtype is of type Object, an additional subtype may be specified in the hint string
@@ -609,7 +619,7 @@ void EditorPropertyArray::setup(Variant::Type p_array_type, const String &p_hint
}
void EditorPropertyArray::_reorder_button_gui_input(const Ref<InputEvent> &p_event) {
- if (reorder_from_index < 0) {
+ if (reorder_from_index < 0 || is_read_only()) {
return;
}
@@ -646,6 +656,10 @@ void EditorPropertyArray::_reorder_button_gui_input(const Ref<InputEvent> &p_eve
}
void EditorPropertyArray::_reorder_button_down(int p_index) {
+ if (is_read_only()) {
+ return;
+ }
+
reorder_from_index = p_index;
reorder_to_index = p_index;
reorder_selected_element_hbox = Object::cast_to<HBoxContainer>(property_vbox->get_child(p_index % page_length));
@@ -656,6 +670,10 @@ void EditorPropertyArray::_reorder_button_down(int p_index) {
}
void EditorPropertyArray::_reorder_button_up() {
+ if (is_read_only()) {
+ return;
+ }
+
if (reorder_from_index != reorder_to_index) {
// Move the element.
Variant array = object->get_array();
@@ -1097,6 +1115,10 @@ void EditorPropertyDictionary::update_property() {
}
}
+ ERR_FAIL_COND(!prop);
+
+ prop->set_read_only(is_read_only());
+
if (i == amount) {
PanelContainer *pc = memnew(PanelContainer);
property_vbox->add_child(pc);
@@ -1135,6 +1157,7 @@ void EditorPropertyDictionary::update_property() {
prop->set_h_size_flags(SIZE_EXPAND_FILL);
Button *edit = memnew(Button);
edit->set_icon(get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")));
+ edit->set_disabled(is_read_only());
hbox->add_child(edit);
edit->connect("pressed", callable_mp(this, &EditorPropertyDictionary::_change_type).bind(edit, change_index));
@@ -1143,6 +1166,7 @@ void EditorPropertyDictionary::update_property() {
if (i == amount + 1) {
button_add_item = EditorInspector::create_inspector_action_button(TTR("Add Key/Value Pair"));
button_add_item->set_icon(get_theme_icon(SNAME("Add"), SNAME("EditorIcons")));
+ button_add_item->set_disabled(is_read_only());
button_add_item->connect("pressed", callable_mp(this, &EditorPropertyDictionary::_add_key_value));
add_vbox->add_child(button_add_item);
}
diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp
index 5346052f4d..84cb085551 100644
--- a/editor/editor_resource_picker.cpp
+++ b/editor/editor_resource_picker.cpp
@@ -186,7 +186,7 @@ void EditorResourcePicker::_update_menu_items() {
// Add options for changing existing value of the resource.
if (edited_resource.is_valid()) {
// Determine if the edited resource is part of another scene (foreign) which was imported
- bool is_edited_resource_foreign_import = EditorNode::get_singleton()->is_resource_read_only(edited_resource);
+ bool is_edited_resource_foreign_import = EditorNode::get_singleton()->is_resource_read_only(edited_resource, true);
// If the resource is determined to be foreign and imported, change the menu entry's description to 'inspect' rather than 'edit'
// since will only be able to view its properties in read-only mode.
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index 64ddecc588..edbd2dd62f 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -191,25 +191,6 @@ static Ref<StyleBoxLine> make_line_stylebox(Color p_color, int p_thickness = 1,
return style;
}
-static Ref<Texture2D> flip_icon(Ref<Texture2D> p_texture, bool p_flip_y = false, bool p_flip_x = false) {
- if (!p_flip_y && !p_flip_x) {
- return p_texture;
- }
-
- Ref<Image> img = p_texture->get_image();
- ERR_FAIL_NULL_V(img, Ref<Texture2D>());
- img = img->duplicate();
-
- if (p_flip_y) {
- img->flip_y();
- }
- if (p_flip_x) {
- img->flip_x();
- }
-
- return ImageTexture::create_from_image(img);
-}
-
#ifdef MODULE_SVG_ENABLED
// See also `generate_icon()` in `scene/resources/default_theme.cpp`.
static Ref<ImageTexture> editor_generate_icon(int p_index, float p_scale, float p_saturation, const HashMap<Color, Color> &p_convert_colors = HashMap<Color, Color>()) {
@@ -1567,14 +1548,13 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_stylebox("camera", "GraphEditMinimap", style_minimap_camera);
theme->set_stylebox("node", "GraphEditMinimap", style_minimap_node);
- Ref<Texture2D> minimap_resizer_icon = theme->get_icon(SNAME("GuiResizer"), SNAME("EditorIcons"));
Color minimap_resizer_color;
if (dark_theme) {
minimap_resizer_color = Color(1, 1, 1, 0.65);
} else {
minimap_resizer_color = Color(0, 0, 0, 0.65);
}
- theme->set_icon("resizer", "GraphEditMinimap", flip_icon(minimap_resizer_icon, true, true));
+ theme->set_icon("resizer", "GraphEditMinimap", theme->get_icon(SNAME("GuiResizerTopLeft"), SNAME("EditorIcons")));
theme->set_color("resizer_color", "GraphEditMinimap", minimap_resizer_color);
// GraphNode
diff --git a/editor/editor_undo_redo_manager.cpp b/editor/editor_undo_redo_manager.cpp
index eca2b3143b..8c04a4d595 100644
--- a/editor/editor_undo_redo_manager.cpp
+++ b/editor/editor_undo_redo_manager.cpp
@@ -124,7 +124,7 @@ void EditorUndoRedoManager::create_action(const String &p_name, UndoRedo::MergeM
create_action_for_history(p_name, INVALID_HISTORY, p_mode);
if (p_custom_context) {
- // This assigns context to pending action.
+ // This assigns history to pending action.
get_history_for_object(p_custom_context);
}
}
@@ -218,7 +218,10 @@ void EditorUndoRedoManager::add_undo_reference(Object *p_object) {
}
void EditorUndoRedoManager::commit_action(bool p_execute) {
- ERR_FAIL_COND(pending_action.history_id == INVALID_HISTORY);
+ if (pending_action.history_id == INVALID_HISTORY) {
+ return; // Empty action, do nothing.
+ }
+
is_committing = true;
History &history = get_or_create_history(pending_action.history_id);
diff --git a/editor/export/editor_export_platform.cpp b/editor/export/editor_export_platform.cpp
index 2a444bb04f..bcc85570ed 100644
--- a/editor/export/editor_export_platform.cpp
+++ b/editor/export/editor_export_platform.cpp
@@ -1619,21 +1619,24 @@ void EditorExportPlatform::gen_export_flags(Vector<String> &r_flags, int p_flags
}
bool EditorExportPlatform::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
+ bool valid = true;
+#ifndef ANDROID_ENABLED
String templates_error;
- bool valid_export_configuration = has_valid_export_configuration(p_preset, templates_error, r_missing_templates);
-
- String project_configuration_error;
- bool valid_project_configuration = has_valid_project_configuration(p_preset, project_configuration_error);
+ valid = valid && has_valid_export_configuration(p_preset, templates_error, r_missing_templates);
if (!templates_error.is_empty()) {
r_error += templates_error;
}
+#endif
+
+ String project_configuration_error;
+ valid = valid && has_valid_project_configuration(p_preset, project_configuration_error);
if (!project_configuration_error.is_empty()) {
r_error += project_configuration_error;
}
- return valid_export_configuration && valid_project_configuration;
+ return valid;
}
EditorExportPlatform::EditorExportPlatform() {
diff --git a/editor/export/project_export.cpp b/editor/export/project_export.cpp
index 00a0e08d3a..8c67885971 100644
--- a/editor/export/project_export.cpp
+++ b/editor/export/project_export.cpp
@@ -932,8 +932,10 @@ void ProjectExportDialog::_export_project_to_path(const String &p_path) {
}
void ProjectExportDialog::_export_all_dialog() {
+#ifndef ANDROID_ENABLED
export_all_dialog->show();
export_all_dialog->popup_centered(Size2(300, 80));
+#endif
}
void ProjectExportDialog::_export_all_dialog_action(const String &p_str) {
@@ -1194,11 +1196,16 @@ ProjectExportDialog::ProjectExportDialog() {
set_cancel_button_text(TTR("Close"));
set_ok_button_text(TTR("Export PCK/ZIP..."));
+ get_ok_button()->set_disabled(true);
+#ifdef ANDROID_ENABLED
+ export_button = memnew(Button);
+ export_button->hide();
+#else
export_button = add_button(TTR("Export Project..."), !DisplayServer::get_singleton()->get_swap_cancel_ok(), "export");
+#endif
export_button->connect("pressed", callable_mp(this, &ProjectExportDialog::_export_project));
// Disable initially before we select a valid preset
export_button->set_disabled(true);
- get_ok_button()->set_disabled(true);
export_all_dialog = memnew(ConfirmationDialog);
add_child(export_all_dialog);
@@ -1208,8 +1215,14 @@ ProjectExportDialog::ProjectExportDialog() {
export_all_dialog->add_button(TTR("Debug"), true, "debug");
export_all_dialog->add_button(TTR("Release"), true, "release");
export_all_dialog->connect("custom_action", callable_mp(this, &ProjectExportDialog::_export_all_dialog_action));
+#ifdef ANDROID_ENABLED
+ export_all_dialog->hide();
+ export_all_button = memnew(Button);
+ export_all_button->hide();
+#else
export_all_button = add_button(TTR("Export All..."), !DisplayServer::get_singleton()->get_swap_cancel_ok(), "export");
+#endif
export_all_button->connect("pressed", callable_mp(this, &ProjectExportDialog::_export_all_dialog));
export_all_button->set_disabled(true);
diff --git a/editor/icons/GuiResizerTopLeft.svg b/editor/icons/GuiResizerTopLeft.svg
new file mode 100644
index 0000000000..a67c2c0722
--- /dev/null
+++ b/editor/icons/GuiResizerTopLeft.svg
@@ -0,0 +1 @@
+<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m4 12c.55228 0 1-.44772 1-1v-6h6c.55228 0 1-.44772 1-1s-.44772-1-1-1h-7c-.55226.000055-.99994.44774-1 1v7c0 .55228.44772 1 1 1z" fill="#fff" fill-opacity=".58824"/></svg>
diff --git a/editor/icons/PreviewEnvironment.svg b/editor/icons/PreviewEnvironment.svg
new file mode 100644
index 0000000000..e0b0257daf
--- /dev/null
+++ b/editor/icons/PreviewEnvironment.svg
@@ -0,0 +1 @@
+<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><g fill="#e0e0e0" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="m8 1a7 7 0 0 0 -7 7 7 7 0 0 0 7 7 7 7 0 0 0 7-7 7 7 0 0 0 -7-7zm-1.7305 2.3125c-.83125 1.5372-1.2685 3.1037-1.2695 4.6816-.64057-.11251-1.3005-.27158-1.9766-.47266a5 5 0 0 1 3.2461-4.209zm3.4629.00391a5 5 0 0 1 3.2383 4.1875c-.65187.17448-1.3077.32867-1.9727.44922-.0084-1.5627-.44294-3.1141-1.2656-4.6367zm-1.7324.0078088c1.0126 1.593 1.5 3.1425 1.5 4.6758 0 .054042-.00662.10803-.00781.16211-.96392.096801-1.9566.1103-2.9844.027344-.00163-.063192-.00781-.12632-.00781-.18945 0-1.5333.48744-3.0828 1.5-4.6758zm4.8789 5.7578a5 5 0 0 1 -3.1484 3.6055002c.57106-1.0564.95277-2.1268 1.1367-3.2051002.68204-.10905 1.3556-.23789 2.0117-.40039zm-9.7461.033203c.68377.18153 1.3555.33345 2.0098.43164.18781 1.0551002.56647 2.1026002 1.125 3.1367002a5 5 0 0 1 -3.1348-3.5684002zm6.168.55469c-.22615.9886602-.65424 1.9884002-1.3008 3.0059002-.63811-1.0042-1.0645-1.9908-1.293-2.9668002.89027.054126 1.7517.029377 2.5938-.039062z"/><path d="m8 1v2.3242c1.0126 1.593 1.5 3.1425 1.5 4.6758 0 .054042-.00662.10803-.00781.16211-.4894.049148-.98713.077552-1.4922.082031v1.4922c.43915-.0076.87287-.031628 1.3008-.066406-.22615.98866-.65424 1.9884-1.3008 3.0059v2.3242a7 7 0 0 0 7.000001-7 7 7 0 0 0 -7.000001-7zm1.7324 2.3164a5 5 0 0 1 3.2383 4.1875c-.65187.17448-1.3077.32867-1.9727.44922-.00845-1.5627-.44294-3.1141-1.2656-4.6367zm3.1465 5.7656a5 5 0 0 1 -3.1484 3.6055c.57106-1.0564.95277-2.1268 1.1367-3.2051.68204-.10905 1.3556-.23789 2.0117-.40039z"/></g></svg>
diff --git a/editor/icons/PreviewSun.svg b/editor/icons/PreviewSun.svg
new file mode 100644
index 0000000000..a8c652be65
--- /dev/null
+++ b/editor/icons/PreviewSun.svg
@@ -0,0 +1 @@
+<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m7 1v3h2v-3zm-2.5352 2.0508-1.4141 1.4141 1.4141 1.4141 1.4141-1.4141zm7.0703 0-1.4141 1.4141 1.4141 1.4141 1.4141-1.4141zm-3.5352 1.9492c-1.6569 0-3 1.3432-3 3s1.3431 3 3 3 3-1.3432 3-3-1.3431-3-3-3zm-7 2v2h3v-2zm11 0v2h3v-2zm-7.5352 3.1211-1.4141 1.4141 1.4141 1.4141 1.4141-1.4141zm7.0703 0-1.4141 1.4141 1.4141 1.4141 1.4141-1.4141zm-4.5352 1.8789v3h2v-3z" fill="#e0e0e0"/></svg>
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index 41061c3fc3..b5798a5784 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -1891,6 +1891,39 @@ void ResourceImporterScene::_replace_owner(Node *p_node, Node *p_scene, Node *p_
}
}
+Array ResourceImporterScene::_get_skinned_pose_transforms(ImporterMeshInstance3D *p_src_mesh_node) {
+ Array skin_pose_transform_array;
+
+ const Ref<Skin> skin = p_src_mesh_node->get_skin();
+ if (skin.is_valid()) {
+ NodePath skeleton_path = p_src_mesh_node->get_skeleton_path();
+ const Node *node = p_src_mesh_node->get_node_or_null(skeleton_path);
+ const Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(node);
+ if (skeleton) {
+ int bind_count = skin->get_bind_count();
+
+ for (int i = 0; i < bind_count; i++) {
+ Transform3D bind_pose = skin->get_bind_pose(i);
+ String bind_name = skin->get_bind_name(i);
+
+ int bone_idx = bind_name.is_empty() ? skin->get_bind_bone(i) : skeleton->find_bone(bind_name);
+ ERR_FAIL_COND_V(bone_idx >= skeleton->get_bone_count(), Array());
+
+ Transform3D bp_global_rest;
+ if (bone_idx >= 0) {
+ bp_global_rest = skeleton->get_bone_global_pose(bone_idx);
+ } else {
+ bp_global_rest = skeleton->get_bone_global_pose(i);
+ }
+
+ skin_pose_transform_array.push_back(bp_global_rest * bind_pose);
+ }
+ }
+ }
+
+ return skin_pose_transform_array;
+}
+
void ResourceImporterScene::_generate_meshes(Node *p_node, const Dictionary &p_mesh_data, bool p_generate_lods, bool p_create_shadow_meshes, LightBakeMode p_light_bake_mode, float p_lightmap_texel_size, const Vector<uint8_t> &p_src_lightmap_cache, Vector<Vector<uint8_t>> &r_lightmap_caches) {
ImporterMeshInstance3D *src_mesh_node = Object::cast_to<ImporterMeshInstance3D>(p_node);
if (src_mesh_node) {
@@ -2007,7 +2040,8 @@ void ResourceImporterScene::_generate_meshes(Node *p_node, const Dictionary &p_m
}
if (generate_lods) {
- src_mesh_node->get_mesh()->generate_lods(merge_angle, split_angle);
+ Array skin_pose_transform_array = _get_skinned_pose_transforms(src_mesh_node);
+ src_mesh_node->get_mesh()->generate_lods(merge_angle, split_angle, skin_pose_transform_array);
}
if (create_shadow_meshes) {
diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h
index da37893cc5..77bc06533c 100644
--- a/editor/import/resource_importer_scene.h
+++ b/editor/import/resource_importer_scene.h
@@ -34,6 +34,7 @@
#include "core/error/error_macros.h"
#include "core/io/resource_importer.h"
#include "core/variant/dictionary.h"
+#include "scene/3d/importer_mesh_instance_3d.h"
#include "scene/3d/node_3d.h"
#include "scene/resources/animation.h"
#include "scene/resources/mesh.h"
@@ -208,6 +209,7 @@ class ResourceImporterScene : public ResourceImporter {
SHAPE_TYPE_CAPSULE,
};
+ Array _get_skinned_pose_transforms(ImporterMeshInstance3D *p_src_mesh_node);
void _replace_owner(Node *p_node, Node *p_scene, Node *p_new_owner);
void _generate_meshes(Node *p_node, const Dictionary &p_mesh_data, bool p_generate_lods, bool p_create_shadow_meshes, LightBakeMode p_light_bake_mode, float p_lightmap_texel_size, const Vector<uint8_t> &p_src_lightmap_cache, Vector<Vector<uint8_t>> &r_lightmap_caches);
void _add_shapes(Node *p_node, const Vector<Ref<Shape3D>> &p_shapes);
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp
index f1e6c70549..f4b8646e18 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp
@@ -907,6 +907,10 @@ void AnimationNodeBlendTreeEditor::_bind_methods() {
AnimationNodeBlendTreeEditor *AnimationNodeBlendTreeEditor::singleton = nullptr;
void AnimationNodeBlendTreeEditor::_node_renamed(const String &p_text, Ref<AnimationNode> p_node) {
+ if (blend_tree.is_null()) {
+ return;
+ }
+
String prev_name = blend_tree->get_node_name(p_node);
ERR_FAIL_COND(prev_name.is_empty());
GraphNode *gn = Object::cast_to<GraphNode>(graph->get_node(prev_name));
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index 34d2cc3cd4..c8b49678d2 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -5516,8 +5516,8 @@ Dictionary Node3DEditor::get_state() const {
pd["sun_color"] = sun_color->get_pick_color();
pd["sun_energy"] = sun_energy->get_value();
- pd["sun_disabled"] = sun_button->is_pressed();
- pd["environ_disabled"] = environ_button->is_pressed();
+ pd["sun_enabled"] = sun_button->is_pressed();
+ pd["environ_enabled"] = environ_button->is_pressed();
d["preview_sun_env"] = pd;
}
@@ -5648,8 +5648,8 @@ void Node3DEditor::set_state(const Dictionary &p_state) {
sun_color->set_pick_color(pd["sun_color"]);
sun_energy->set_value(pd["sun_energy"]);
- sun_button->set_pressed(pd["sun_disabled"]);
- environ_button->set_pressed(pd["environ_disabled"]);
+ sun_button->set_pressed(pd["sun_enabled"]);
+ environ_button->set_pressed(pd["environ_enabled"]);
sun_environ_updating = false;
@@ -5657,8 +5657,8 @@ void Node3DEditor::set_state(const Dictionary &p_state) {
_update_preview_environment();
} else {
_load_default_preview_settings();
- sun_button->set_pressed(false);
- environ_button->set_pressed(false);
+ sun_button->set_pressed(true);
+ environ_button->set_pressed(true);
_preview_settings_changed();
_update_preview_environment();
}
@@ -7159,8 +7159,8 @@ void Node3DEditor::_update_theme() {
view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_3_VIEWPORTS_ALT), get_theme_icon(SNAME("Panels3Alt"), SNAME("EditorIcons")));
view_menu->get_popup()->set_item_icon(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_4_VIEWPORTS), get_theme_icon(SNAME("Panels4"), SNAME("EditorIcons")));
- sun_button->set_icon(get_theme_icon(SNAME("DirectionalLight3D"), SNAME("EditorIcons")));
- environ_button->set_icon(get_theme_icon(SNAME("WorldEnvironment"), SNAME("EditorIcons")));
+ sun_button->set_icon(get_theme_icon(SNAME("PreviewSun"), SNAME("EditorIcons")));
+ environ_button->set_icon(get_theme_icon(SNAME("PreviewEnvironment"), SNAME("EditorIcons")));
sun_environ_settings->set_icon(get_theme_icon(SNAME("GuiTabMenuHl"), SNAME("EditorIcons")));
sun_title->add_theme_font_override("font", get_theme_font(SNAME("title_font"), SNAME("Window")));
@@ -7636,7 +7636,7 @@ void Node3DEditor::_load_default_preview_settings() {
}
void Node3DEditor::_update_preview_environment() {
- bool disable_light = directional_light_count > 0 || sun_button->is_pressed();
+ bool disable_light = directional_light_count > 0 || !sun_button->is_pressed();
sun_button->set_disabled(directional_light_count > 0);
@@ -7664,7 +7664,7 @@ void Node3DEditor::_update_preview_environment() {
sun_angle_altitude->set_value(-Math::rad_to_deg(sun_rotation.x));
sun_angle_azimuth->set_value(180.0 - Math::rad_to_deg(sun_rotation.y));
- bool disable_env = world_env_count > 0 || environ_button->is_pressed();
+ bool disable_env = world_env_count > 0 || !environ_button->is_pressed();
environ_button->set_disabled(world_env_count > 0);
@@ -7855,6 +7855,8 @@ Node3DEditor::Node3DEditor() {
sun_button->set_flat(true);
sun_button->connect("pressed", callable_mp(this, &Node3DEditor::_update_preview_environment), CONNECT_DEFERRED);
sun_button->set_disabled(true);
+ // Preview is enabled by default - ensure this applies on editor startup when there is no state yet.
+ sun_button->set_pressed(true);
main_menu_hbox->add_child(sun_button);
@@ -7864,6 +7866,8 @@ Node3DEditor::Node3DEditor() {
environ_button->set_flat(true);
environ_button->connect("pressed", callable_mp(this, &Node3DEditor::_update_preview_environment), CONNECT_DEFERRED);
environ_button->set_disabled(true);
+ // Preview is enabled by default - ensure this applies on editor startup when there is no state yet.
+ environ_button->set_pressed(true);
main_menu_hbox->add_child(environ_button);
diff --git a/editor/plugins/shader_editor_plugin.h b/editor/plugins/shader_editor_plugin.h
index afd38ef71a..f48b2fc70e 100644
--- a/editor/plugins/shader_editor_plugin.h
+++ b/editor/plugins/shader_editor_plugin.h
@@ -115,8 +115,8 @@ public:
ShaderTextEditor();
};
-class ShaderEditor : public PanelContainer {
- GDCLASS(ShaderEditor, PanelContainer);
+class ShaderEditor : public MarginContainer {
+ GDCLASS(ShaderEditor, MarginContainer);
enum {
EDIT_UNDO,
diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp
index ae21aad337..d0a1ddafa1 100644
--- a/editor/plugins/sprite_frames_editor_plugin.cpp
+++ b/editor/plugins/sprite_frames_editor_plugin.cpp
@@ -984,11 +984,17 @@ void SpriteFramesEditor::_update_library(bool p_skip_selector) {
}
void SpriteFramesEditor::edit(SpriteFrames *p_frames) {
- if (frames == p_frames) {
+ bool new_read_only_state = false;
+ if (p_frames) {
+ new_read_only_state = EditorNode::get_singleton()->is_resource_read_only(p_frames);
+ }
+
+ if (frames == p_frames && new_read_only_state == read_only) {
return;
}
frames = p_frames;
+ read_only = new_read_only_state;
if (p_frames) {
if (!p_frames->has_animation(edited_anim)) {
@@ -1009,6 +1015,20 @@ void SpriteFramesEditor::edit(SpriteFrames *p_frames) {
} else {
hide();
}
+
+ new_anim->set_disabled(read_only);
+ remove_anim->set_disabled(read_only);
+ anim_speed->set_editable(!read_only);
+ anim_loop->set_disabled(read_only);
+ load->set_disabled(read_only);
+ load_sheet->set_disabled(read_only);
+ copy->set_disabled(read_only);
+ paste->set_disabled(read_only);
+ empty->set_disabled(read_only);
+ empty2->set_disabled(read_only);
+ move_up->set_disabled(read_only);
+ move_down->set_disabled(read_only);
+ _delete->set_disabled(read_only);
}
void SpriteFramesEditor::set_undo_redo(Ref<EditorUndoRedoManager> p_undo_redo) {
@@ -1016,6 +1036,10 @@ void SpriteFramesEditor::set_undo_redo(Ref<EditorUndoRedoManager> p_undo_redo) {
}
Variant SpriteFramesEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
+ if (read_only) {
+ return false;
+ }
+
if (!frames->has_animation(edited_anim)) {
return false;
}
@@ -1038,6 +1062,10 @@ Variant SpriteFramesEditor::get_drag_data_fw(const Point2 &p_point, Control *p_f
}
bool SpriteFramesEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
+ if (read_only) {
+ return false;
+ }
+
Dictionary d = p_data;
if (!d.has("type")) {
@@ -1169,6 +1197,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
remove_anim->set_flat(true);
remove_anim->set_tooltip_text(TTR("Remove Animation"));
hbc_animlist->add_child(remove_anim);
+ remove_anim->set_disabled(true);
remove_anim->connect("pressed", callable_mp(this, &SpriteFramesEditor::_animation_remove));
anim_search_box = memnew(LineEdit);
diff --git a/editor/plugins/sprite_frames_editor_plugin.h b/editor/plugins/sprite_frames_editor_plugin.h
index f2530b732f..092f556c63 100644
--- a/editor/plugins/sprite_frames_editor_plugin.h
+++ b/editor/plugins/sprite_frames_editor_plugin.h
@@ -57,6 +57,8 @@ class SpriteFramesEditor : public HSplitContainer {
};
int dominant_param = PARAM_FRAME_COUNT;
+ bool read_only = false;
+
Button *load = nullptr;
Button *load_sheet = nullptr;
Button *_delete = nullptr;
diff --git a/editor/plugins/tiles/tile_map_editor.cpp b/editor/plugins/tiles/tile_map_editor.cpp
index a91f22ccd0..79230891f1 100644
--- a/editor/plugins/tiles/tile_map_editor.cpp
+++ b/editor/plugins/tiles/tile_map_editor.cpp
@@ -3677,6 +3677,7 @@ void TileMapEditor::_update_layers_selection() {
tile_map_layer = -1;
}
tile_map->set_selected_layer(toggle_highlight_selected_layer_button->is_pressed() ? tile_map_layer : -1);
+ tileset_changed_needs_update = false; // Update is not needed here and actually causes problems.
layers_selection_button->clear();
if (tile_map->get_layers_count() > 0) {
diff --git a/editor/plugins/version_control_editor_plugin.cpp b/editor/plugins/version_control_editor_plugin.cpp
index 761140b2d5..336ce9e4c8 100644
--- a/editor/plugins/version_control_editor_plugin.cpp
+++ b/editor/plugins/version_control_editor_plugin.cpp
@@ -1124,6 +1124,8 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() {
set_up_password->connect(SNAME("text_changed"), callable_mp(this, &VersionControlEditorPlugin::_update_set_up_warning));
set_up_password_input->add_child(set_up_password);
+ const String home_dir = OS::get_singleton()->has_environment("HOME") ? OS::get_singleton()->get_environment("HOME") : OS::get_singleton()->get_system_dir(OS::SYSTEM_DIR_DOCUMENTS);
+
HBoxContainer *set_up_ssh_public_key_input = memnew(HBoxContainer);
set_up_ssh_public_key_input->set_h_size_flags(Control::SIZE_EXPAND_FILL);
set_up_settings_vbc->add_child(set_up_ssh_public_key_input);
@@ -1147,10 +1149,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() {
set_up_ssh_public_key_file_dialog->set_access(FileDialog::ACCESS_FILESYSTEM);
set_up_ssh_public_key_file_dialog->set_file_mode(FileDialog::FILE_MODE_OPEN_FILE);
set_up_ssh_public_key_file_dialog->set_show_hidden_files(true);
- // TODO: Make this start at the user's home folder
- Ref<DirAccess> d = DirAccess::open(OS::get_singleton()->get_system_dir(OS::SYSTEM_DIR_DOCUMENTS));
- d->change_dir("../");
- set_up_ssh_public_key_file_dialog->set_current_dir(d->get_current_dir());
+ set_up_ssh_public_key_file_dialog->set_current_dir(home_dir);
set_up_ssh_public_key_file_dialog->connect(SNAME("file_selected"), callable_mp(this, &VersionControlEditorPlugin::_ssh_public_key_selected));
set_up_ssh_public_key_input_hbc->add_child(set_up_ssh_public_key_file_dialog);
@@ -1183,8 +1182,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() {
set_up_ssh_private_key_file_dialog->set_access(FileDialog::ACCESS_FILESYSTEM);
set_up_ssh_private_key_file_dialog->set_file_mode(FileDialog::FILE_MODE_OPEN_FILE);
set_up_ssh_private_key_file_dialog->set_show_hidden_files(true);
- // TODO: Make this start at the user's home folder
- set_up_ssh_private_key_file_dialog->set_current_dir(d->get_current_dir());
+ set_up_ssh_private_key_file_dialog->set_current_dir(home_dir);
set_up_ssh_private_key_file_dialog->connect("file_selected", callable_mp(this, &VersionControlEditorPlugin::_ssh_private_key_selected));
set_up_ssh_private_key_input_hbc->add_child(set_up_ssh_private_key_file_dialog);
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index 2af8da02a3..ee8148f00a 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -5198,9 +5198,9 @@ VisualShaderEditor::VisualShaderEditor() {
add_options.push_back(AddOption("Tangent", "Input/Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "tangent", "TANGENT"), { "tangent" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
add_options.push_back(AddOption("Vertex", "Input/Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "vertex", "VERTEX"), { "vertex" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
add_options.push_back(AddOption("View", "Input/Fragment", "VisualShaderNodeInput", vformat(input_param_for_fragment_and_light_shader_modes, "view", "VIEW"), { "view" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("ViewIndex", "Input/Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "view_index", "VIEW_INDEX"), { "view_index" }, VisualShaderNode::PORT_TYPE_SCALAR_INT, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("ViewMonoLeft", "Input/Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "view_mono_left", "VIEW_MONO_LEFT"), { "view_mono_left" }, VisualShaderNode::PORT_TYPE_SCALAR_INT, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
- add_options.push_back(AddOption("ViewRight", "Input/Vertex", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "view_right", "VIEW_RIGHT"), { "view_right" }, VisualShaderNode::PORT_TYPE_SCALAR_INT, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("ViewIndex", "Input/Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "view_index", "VIEW_INDEX"), { "view_index" }, VisualShaderNode::PORT_TYPE_SCALAR_INT, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("ViewMonoLeft", "Input/Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "view_mono_left", "VIEW_MONO_LEFT"), { "view_mono_left" }, VisualShaderNode::PORT_TYPE_SCALAR_INT, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
+ add_options.push_back(AddOption("ViewRight", "Input/Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "view_right", "VIEW_RIGHT"), { "view_right" }, VisualShaderNode::PORT_TYPE_SCALAR_INT, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
add_options.push_back(AddOption("NodePositionWorld", "Input/Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "node_position_world", "NODE_POSITION_WORLD"), { "node_position_world" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
add_options.push_back(AddOption("CameraPositionWorld", "Input/Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "camera_position_world", "CAMERA_POSITION_WORLD"), { "camera_position_world" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
add_options.push_back(AddOption("CameraDirectionWorld", "Input/Fragment", "VisualShaderNodeInput", vformat(input_param_for_vertex_and_fragment_shader_modes, "camera_direction_world", "CAMERA_DIRECTION_WORLD"), { "camera_direction_world" }, VisualShaderNode::PORT_TYPE_VECTOR_3D, TYPE_FLAGS_FRAGMENT, Shader::MODE_SPATIAL));
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 270e04050e..f11874a994 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -59,6 +59,8 @@
#include "servers/navigation_server_3d.h"
#include "servers/physics_server_2d.h"
+constexpr int GODOT4_CONFIG_VERSION = 5;
+
class ProjectDialog : public ConfirmationDialog {
GDCLASS(ProjectDialog, ConfirmationDialog);
@@ -1065,6 +1067,7 @@ public:
int refresh_project(const String &dir_path);
void add_project(const String &dir_path, bool favorite);
void save_config();
+ void set_project_version(const String &p_project_path, int version);
private:
static void _bind_methods();
@@ -1673,6 +1676,15 @@ void ProjectList::save_config() {
_config.save(_config_path);
}
+void ProjectList::set_project_version(const String &p_project_path, int p_version) {
+ for (ProjectList::Item &E : _projects) {
+ if (E.path == p_project_path) {
+ E.version = p_version;
+ break;
+ }
+ }
+}
+
int ProjectList::get_project_count() const {
return _projects.size();
}
@@ -2170,6 +2182,9 @@ void ProjectManager::_open_selected_projects_ask() {
Label *ask_update_label = ask_update_settings->get_label();
ask_update_label->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_LEFT); // Reset in case of previous center align.
+ full_convert_button->hide();
+
+ ask_update_settings->get_ok_button()->set_text("OK");
// Check if the config_version property was empty or 0
if (config_version == 0) {
@@ -2179,7 +2194,11 @@ void ProjectManager::_open_selected_projects_ask() {
}
// Check if we need to convert project settings from an earlier engine version
if (config_version < ProjectSettings::CONFIG_VERSION) {
- ask_update_settings->set_text(vformat(TTR("The following project settings file was generated by an older engine version, and needs to be converted for this version:\n\n%s\n\nDo you want to convert it?\nWarning: You won't be able to open the project with previous versions of the engine anymore."), conf));
+ if (config_version == GODOT4_CONFIG_VERSION - 1 && ProjectSettings::CONFIG_VERSION == GODOT4_CONFIG_VERSION) { // Conversion from Godot 3 to 4.
+ full_convert_button->show();
+ }
+ ask_update_settings->set_text(vformat(TTR("The following project settings file was generated by an older engine version, and needs to be converted for this version:\n\n%s\n\nDo you want to convert it? You can also convert the entire project (recommended if you are upgrading).\nWarning: You won't be able to open the project with previous versions of the engine anymore."), conf));
+ ask_update_settings->get_ok_button()->set_text(TTR("Convert project.godot"));
ask_update_settings->popup_centered();
return;
}
@@ -2223,6 +2242,32 @@ void ProjectManager::_open_selected_projects_ask() {
_open_selected_projects();
}
+void ProjectManager::_perform_full_project_conversion() {
+ Vector<ProjectList::Item> selected_list = _project_list->get_selected_projects();
+ if (selected_list.is_empty()) {
+ return;
+ }
+
+ const String &path = selected_list[0].path;
+
+ print_line("Converting project: " + path);
+
+ Ref<ConfigFile> cf;
+ cf.instantiate();
+ cf->load(path.path_join("project.godot"));
+ cf->set_value("", "config_version", GODOT4_CONFIG_VERSION);
+ cf->save(path.path_join("project.godot"));
+ _project_list->set_project_version(path, GODOT4_CONFIG_VERSION);
+
+ List<String> args;
+ args.push_back("--path");
+ args.push_back(path);
+ args.push_back("--convert-3to4");
+
+ Error err = OS::get_singleton()->create_instance(args);
+ ERR_FAIL_COND(err);
+}
+
void ProjectManager::_run_project_confirm() {
Vector<ProjectList::Item> selected_list = _project_list->get_selected_projects();
@@ -2724,9 +2769,10 @@ ProjectManager::ProjectManager() {
settings_hb->add_child(h_spacer);
language_btn = memnew(OptionButton);
- language_btn->set_flat(true);
language_btn->set_icon(get_theme_icon(SNAME("Environment"), SNAME("EditorIcons")));
language_btn->set_focus_mode(Control::FOCUS_NONE);
+ language_btn->set_fit_to_longest_item(false);
+ language_btn->set_flat(true);
language_btn->connect("item_selected", callable_mp(this, &ProjectManager::_language_selected));
#ifdef ANDROID_ENABLED
// The language selection dropdown doesn't work on Android (as the setting isn't saved), see GH-60353.
@@ -2824,8 +2870,20 @@ ProjectManager::ProjectManager() {
ask_update_settings = memnew(ConfirmationDialog);
ask_update_settings->get_ok_button()->connect("pressed", callable_mp(this, &ProjectManager::_confirm_update_settings));
+ full_convert_button = ask_update_settings->add_button("Perform Full Project Conversion", false);
add_child(ask_update_settings);
+ ask_full_convert_dialog = memnew(ConfirmationDialog);
+ ask_full_convert_dialog->set_autowrap(true);
+ ask_full_convert_dialog->set_text(TTR(R"(This option will perform full project conversion, updating scenes and scripts from Godot 3.x to work in Godot 4.0. Note that this is a best-effort conversion, i.e. it makes upgrading the project easier, but it will not open out-of-the-box and will still require manual adjustments.
+
+IMPORTANT: Make sure to backup your project before converting, as this operation makes it impossible to open in older versions of Godot.)"));
+ ask_full_convert_dialog->connect("confirmed", callable_mp(this, &ProjectManager::_perform_full_project_conversion));
+ add_child(ask_full_convert_dialog);
+
+ full_convert_button->connect("pressed", callable_mp((Window *)ask_update_settings, &ConfirmationDialog::hide));
+ full_convert_button->connect("pressed", callable_mp((Window *)ask_full_convert_dialog, &ConfirmationDialog::popup_centered_ratio).bind(0.2));
+
npdialog = memnew(ProjectDialog);
npdialog->connect("projects_updated", callable_mp(this, &ProjectManager::_on_projects_updated));
npdialog->connect("project_created", callable_mp(this, &ProjectManager::_on_project_created));
diff --git a/editor/project_manager.h b/editor/project_manager.h
index 10bf25c048..0831a63e68 100644
--- a/editor/project_manager.h
+++ b/editor/project_manager.h
@@ -87,6 +87,7 @@ class ProjectManager : public Control {
ConfirmationDialog *multi_open_ask = nullptr;
ConfirmationDialog *multi_run_ask = nullptr;
ConfirmationDialog *multi_scan_ask = nullptr;
+ ConfirmationDialog *ask_full_convert_dialog = nullptr;
ConfirmationDialog *ask_update_settings = nullptr;
ConfirmationDialog *open_templates = nullptr;
EditorAbout *about = nullptr;
@@ -97,6 +98,7 @@ class ProjectManager : public Control {
AcceptDialog *dialog_error = nullptr;
ProjectDialog *npdialog = nullptr;
+ Button *full_convert_button = nullptr;
OptionButton *language_btn = nullptr;
LinkButton *version_btn = nullptr;
@@ -106,6 +108,7 @@ class ProjectManager : public Control {
void _run_project_confirm();
void _open_selected_projects();
void _open_selected_projects_ask();
+ void _perform_full_project_conversion();
void _import_project();
void _new_project();
void _rename_project();
diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml
index 4a38caea52..4f325fcf52 100644
--- a/modules/gdscript/doc_classes/@GDScript.xml
+++ b/modules/gdscript/doc_classes/@GDScript.xml
@@ -35,14 +35,14 @@
<description>
Asserts that the [code]condition[/code] is [code]true[/code]. If the [code]condition[/code] is [code]false[/code], an error is generated. When running from the editor, the running project will also be paused until you resume it. This can be used as a stronger form of [method @GlobalScope.push_error] for reporting errors to project developers or add-on users.
[b]Note:[/b] For performance reasons, the code inside [method assert] is only executed in debug builds or when running the project from the editor. Don't include code that has side effects in an [method assert] call. Otherwise, the project will behave differently when exported in release mode.
- The optional [code]message[/code] argument, if given, is shown in addition to the generic "Assertion failed" message. You can use this to provide additional details about why the assertion failed.
+ The optional [code]message[/code] argument, if given, is shown in addition to the generic "Assertion failed" message. It must be a static string, so format strings can't be used. You can use this to provide additional details about why the assertion failed.
[codeblock]
# Imagine we always want speed to be between 0 and 20.
var speed = -10
assert(speed &lt; 20) # True, the program will continue
assert(speed &gt;= 0) # False, the program will stop
assert(speed &gt;= 0 and speed &lt; 20) # You can also combine the two conditional statements in one check
- assert(speed &lt; 20, "speed = %f, but the speed limit is 20" % speed) # Show a message with clarifying details
+ assert(speed &lt; 20, "the speed limit is 20") # Show a message
[/codeblock]
</description>
</method>
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp
index 10babad378..1cff2181af 100644
--- a/modules/gdscript/gdscript.cpp
+++ b/modules/gdscript/gdscript.cpp
@@ -1077,10 +1077,12 @@ Error GDScript::load_source_code(const String &p_path) {
}
source = s;
+ path = p_path;
#ifdef TOOLS_ENABLED
source_changed_cache = true;
-#endif
- path = p_path;
+ set_edited(false);
+ set_last_modified_time(FileAccess::get_modified_time(path));
+#endif // TOOLS_ENABLED
return OK;
}
diff --git a/modules/gdscript/gdscript_cache.cpp b/modules/gdscript/gdscript_cache.cpp
index 48d5fbc569..c25f5b58d5 100644
--- a/modules/gdscript/gdscript_cache.cpp
+++ b/modules/gdscript/gdscript_cache.cpp
@@ -146,9 +146,7 @@ String GDScriptCache::get_source_code(const String &p_path) {
Vector<uint8_t> source_file;
Error err;
Ref<FileAccess> f = FileAccess::open(p_path, FileAccess::READ, &err);
- if (err) {
- ERR_FAIL_COND_V(err, "");
- }
+ ERR_FAIL_COND_V(err, "");
uint64_t len = f->get_length();
source_file.resize(len + 1);
diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp
index 6cb398b5f8..f5730e7137 100644
--- a/modules/gltf/gltf_document.cpp
+++ b/modules/gltf/gltf_document.cpp
@@ -2673,7 +2673,7 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> state) {
} else if (a.has("JOINTS_0") && a.has("JOINTS_1")) {
PackedInt32Array joints_0 = _decode_accessor_as_ints(state, a["JOINTS_0"], true);
PackedInt32Array joints_1 = _decode_accessor_as_ints(state, a["JOINTS_1"], true);
- ERR_FAIL_COND_V(joints_0.size() != joints_0.size(), ERR_INVALID_DATA);
+ ERR_FAIL_COND_V(joints_0.size() != joints_1.size(), ERR_INVALID_DATA);
int32_t weight_8_count = JOINT_GROUP_SIZE * 2;
Vector<int> joints;
joints.resize(vertex_num * weight_8_count);
diff --git a/modules/gltf/register_types.cpp b/modules/gltf/register_types.cpp
index dbbccc9bcc..6e7f7d6fed 100644
--- a/modules/gltf/register_types.cpp
+++ b/modules/gltf/register_types.cpp
@@ -142,6 +142,11 @@ void initialize_gltf_module(ModuleInitializationLevel p_level) {
GLOBAL_DEF_RST("filesystem/import/fbx/enabled", true);
GDREGISTER_CLASS(EditorSceneFormatImporterBlend);
GDREGISTER_CLASS(EditorSceneFormatImporterFBX);
+ // Can't (a priori) run external app on these platforms.
+ GLOBAL_DEF_RST("filesystem/import/blender/enabled.android", false);
+ GLOBAL_DEF_RST("filesystem/import/blender/enabled.web", false);
+ GLOBAL_DEF_RST("filesystem/import/fbx/enabled.android", false);
+ GLOBAL_DEF_RST("filesystem/import/fbx/enabled.web", false);
ClassDB::set_current_api(prev_api);
EditorNode::add_init_callback(_editor_init);
diff --git a/modules/mono/editor/GodotTools/GodotTools/Build/DotNetFinder.cs b/modules/mono/editor/GodotTools/GodotTools/Build/DotNetFinder.cs
index 7bce53308c..b437c7e742 100644
--- a/modules/mono/editor/GodotTools/GodotTools/Build/DotNetFinder.cs
+++ b/modules/mono/editor/GodotTools/GodotTools/Build/DotNetFinder.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
+using System.Runtime.InteropServices;
using JetBrains.Annotations;
using OS = GodotTools.Utils.OS;
@@ -16,6 +17,23 @@ namespace GodotTools.Build
// In the future, this method may do more than just search in PATH. We could look in
// known locations or use Godot's linked nethost to search from the hostfxr location.
+ if (OS.IsMacOS)
+ {
+ if (RuntimeInformation.OSArchitecture == Architecture.X64)
+ {
+ string dotnet_x64 = "/usr/local/share/dotnet/x64/dotnet"; // Look for x64 version, when running under Rosetta 2.
+ if (File.Exists(dotnet_x64))
+ {
+ return dotnet_x64;
+ }
+ }
+ string dotnet = "/usr/local/share/dotnet/dotnet"; // Look for native version.
+ if (File.Exists(dotnet))
+ {
+ return dotnet;
+ }
+ }
+
return OS.PathWhich("dotnet");
}
diff --git a/modules/multiplayer/multiplayer_spawner.cpp b/modules/multiplayer/multiplayer_spawner.cpp
index 6f60318b3b..d46972ffb6 100644
--- a/modules/multiplayer/multiplayer_spawner.cpp
+++ b/modules/multiplayer/multiplayer_spawner.cpp
@@ -91,9 +91,6 @@ void MultiplayerSpawner::add_spawnable_scene(const String &p_path) {
sc.path = p_path;
if (Engine::get_singleton()->is_editor_hint()) {
ERR_FAIL_COND(!FileAccess::exists(p_path));
- } else {
- sc.cache = ResourceLoader::load(p_path);
- ERR_FAIL_COND_MSG(sc.cache.is_null(), "Invalid spawnable scene: " + p_path);
}
spawnable_scenes.push_back(sc);
}
@@ -101,6 +98,7 @@ int MultiplayerSpawner::get_spawnable_scene_count() const {
return spawnable_scenes.size();
}
String MultiplayerSpawner::get_spawnable_scene(int p_idx) const {
+ ERR_FAIL_INDEX_V(p_idx, (int)spawnable_scenes.size(), "");
return spawnable_scenes[p_idx].path;
}
void MultiplayerSpawner::clear_spawnable_scenes() {
@@ -270,9 +268,12 @@ const Variant MultiplayerSpawner::get_spawn_argument(const ObjectID &p_id) const
Node *MultiplayerSpawner::instantiate_scene(int p_id) {
ERR_FAIL_COND_V_MSG(spawn_limit && spawn_limit <= tracked_nodes.size(), nullptr, "Spawn limit reached!");
ERR_FAIL_UNSIGNED_INDEX_V((uint32_t)p_id, spawnable_scenes.size(), nullptr);
- Ref<PackedScene> scene = spawnable_scenes[p_id].cache;
- ERR_FAIL_COND_V(scene.is_null(), nullptr);
- return scene->instantiate();
+ SpawnableScene &sc = spawnable_scenes[p_id];
+ if (sc.cache.is_null()) {
+ sc.cache = ResourceLoader::load(sc.path);
+ }
+ ERR_FAIL_COND_V_MSG(sc.cache.is_null(), nullptr, "Invalid spawnable scene: " + sc.path);
+ return sc.cache->instantiate();
}
Node *MultiplayerSpawner::instantiate_custom(const Variant &p_data) {
diff --git a/modules/navigation/navigation_mesh_generator.cpp b/modules/navigation/navigation_mesh_generator.cpp
index cfb8e0cd42..f989fc45a5 100644
--- a/modules/navigation/navigation_mesh_generator.cpp
+++ b/modules/navigation/navigation_mesh_generator.cpp
@@ -209,6 +209,9 @@ void NavigationMeshGenerator::_parse_geometry(const Transform3D &p_navmesh_trans
for (uint32_t shape_owner : shape_owners) {
const int shape_count = static_body->shape_owner_get_shape_count(shape_owner);
for (int i = 0; i < shape_count; i++) {
+ if (static_body->is_shape_owner_disabled(i)) {
+ continue;
+ }
Ref<Shape3D> s = static_body->shape_owner_get_shape(shape_owner, i);
if (s.is_null()) {
continue;
diff --git a/modules/webrtc/doc_classes/WebRTCPeerConnection.xml b/modules/webrtc/doc_classes/WebRTCPeerConnection.xml
index e99aeb4f51..4ecc71ddbb 100644
--- a/modules/webrtc/doc_classes/WebRTCPeerConnection.xml
+++ b/modules/webrtc/doc_classes/WebRTCPeerConnection.xml
@@ -67,6 +67,18 @@
Returns the connection state. See [enum ConnectionState].
</description>
</method>
+ <method name="get_gathering_state" qualifiers="const">
+ <return type="int" enum="WebRTCPeerConnection.GatheringState" />
+ <description>
+ Returns the ICE [enum GatheringState] of the connection. This lets you detect, for example, when collection of ICE candidates has finished.
+ </description>
+ </method>
+ <method name="get_signaling_state" qualifiers="const">
+ <return type="int" enum="WebRTCPeerConnection.SignalingState" />
+ <description>
+ Returns the [enum SignalingState] on the local end of the connection while connecting or reconnecting to another peer.
+ </description>
+ </method>
<method name="initialize">
<return type="int" enum="Error" />
<param index="0" name="configuration" type="Dictionary" default="{}" />
@@ -165,5 +177,32 @@
<constant name="STATE_CLOSED" value="5" enum="ConnectionState">
The peer connection is closed (after calling [method close] for example).
</constant>
+ <constant name="GATHERING_STATE_NEW" value="0" enum="GatheringState">
+ The peer connection was just created and hasn't done any networking yet.
+ </constant>
+ <constant name="GATHERING_STATE_GATHERING" value="1" enum="GatheringState">
+ The ICE agent is in the process of gathering candidates for the connection.
+ </constant>
+ <constant name="GATHERING_STATE_COMPLETE" value="2" enum="GatheringState">
+ The ICE agent has finished gathering candidates. If something happens that requires collecting new candidates, such as a new interface being added or the addition of a new ICE server, the state will revert to gathering to gather those candidates.
+ </constant>
+ <constant name="SIGNALING_STATE_STABLE" value="0" enum="SignalingState">
+ There is no ongoing exchange of offer and answer underway. This may mean that the [WebRTCPeerConnection] is new ([constant STATE_NEW]) or that negotiation is complete and a connection has been established ([constant STATE_CONNECTED]).
+ </constant>
+ <constant name="SIGNALING_STATE_HAVE_LOCAL_OFFER" value="1" enum="SignalingState">
+ The local peer has called [method set_local_description], passing in SDP representing an offer (usually created by calling [method create_offer]), and the offer has been applied successfully.
+ </constant>
+ <constant name="SIGNALING_STATE_HAVE_REMOTE_OFFER" value="2" enum="SignalingState">
+ The remote peer has created an offer and used the signaling server to deliver it to the local peer, which has set the offer as the remote description by calling [method set_remote_description].
+ </constant>
+ <constant name="SIGNALING_STATE_HAVE_LOCAL_PRANSWER" value="3" enum="SignalingState">
+ The offer sent by the remote peer has been applied and an answer has been created and applied by calling [method set_local_description]. This provisional answer describes the supported media formats and so forth, but may not have a complete set of ICE candidates included. Further candidates will be delivered separately later.
+ </constant>
+ <constant name="SIGNALING_STATE_HAVE_REMOTE_PRANSWER" value="4" enum="SignalingState">
+ A provisional answer has been received and successfully applied in response to an offer previously sent and established by calling [method set_local_description].
+ </constant>
+ <constant name="SIGNALING_STATE_CLOSED" value="5" enum="SignalingState">
+ The [WebRTCPeerConnection] has been closed.
+ </constant>
</constants>
</class>
diff --git a/modules/webrtc/doc_classes/WebRTCPeerConnectionExtension.xml b/modules/webrtc/doc_classes/WebRTCPeerConnectionExtension.xml
index 3c4bf18a76..474d2f6a89 100644
--- a/modules/webrtc/doc_classes/WebRTCPeerConnectionExtension.xml
+++ b/modules/webrtc/doc_classes/WebRTCPeerConnectionExtension.xml
@@ -37,6 +37,16 @@
<description>
</description>
</method>
+ <method name="_get_gathering_state" qualifiers="virtual const">
+ <return type="int" enum="WebRTCPeerConnection.GatheringState" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_signaling_state" qualifiers="virtual const">
+ <return type="int" enum="WebRTCPeerConnection.SignalingState" />
+ <description>
+ </description>
+ </method>
<method name="_initialize" qualifiers="virtual">
<return type="int" enum="Error" />
<param index="0" name="p_config" type="Dictionary" />
diff --git a/modules/webrtc/library_godot_webrtc.js b/modules/webrtc/library_godot_webrtc.js
index e57e4299e0..e6604eecd7 100644
--- a/modules/webrtc/library_godot_webrtc.js
+++ b/modules/webrtc/library_godot_webrtc.js
@@ -220,64 +220,123 @@ mergeInto(LibraryManager.library, GodotRTCDataChannel);
const GodotRTCPeerConnection = {
$GodotRTCPeerConnection__deps: ['$IDHandler', '$GodotRuntime', '$GodotRTCDataChannel'],
$GodotRTCPeerConnection: {
- onstatechange: function (p_id, p_conn, callback, event) {
- const ref = IDHandler.get(p_id);
- if (!ref) {
- return;
- }
- let state;
- switch (p_conn.iceConnectionState) {
- case 'new':
- state = 0;
- break;
- case 'checking':
- state = 1;
- break;
- case 'connected':
- case 'completed':
- state = 2;
- break;
- case 'disconnected':
- state = 3;
- break;
- case 'failed':
- state = 4;
- break;
- case 'closed':
- default:
- state = 5;
- break;
- }
- callback(state);
+ // Enums
+ ConnectionState: {
+ 'new': 0,
+ 'connecting': 1,
+ 'connected': 2,
+ 'disconnected': 3,
+ 'failed': 4,
+ 'closed': 5,
},
- onicecandidate: function (p_id, callback, event) {
- const ref = IDHandler.get(p_id);
- if (!ref || !event.candidate) {
- return;
+ ConnectionStateCompat: {
+ // Using values from IceConnectionState for browsers that do not support ConnectionState (notably Firefox).
+ 'new': 0,
+ 'checking': 1,
+ 'connected': 2,
+ 'completed': 2,
+ 'disconnected': 3,
+ 'failed': 4,
+ 'closed': 5,
+ },
+
+ IceGatheringState: {
+ 'new': 0,
+ 'gathering': 1,
+ 'complete': 2,
+ },
+
+ SignalingState: {
+ 'stable': 0,
+ 'have-local-offer': 1,
+ 'have-remote-offer': 2,
+ 'have-local-pranswer': 3,
+ 'have-remote-pranswer': 4,
+ 'closed': 5,
+ },
+
+ // Callbacks
+ create: function (config, onConnectionChange, onSignalingChange, onIceGatheringChange, onIceCandidate, onDataChannel) {
+ let conn = null;
+ try {
+ conn = new RTCPeerConnection(config);
+ } catch (e) {
+ GodotRuntime.error(e);
+ return 0;
}
- const c = event.candidate;
- const candidate_str = GodotRuntime.allocString(c.candidate);
- const mid_str = GodotRuntime.allocString(c.sdpMid);
- callback(mid_str, c.sdpMLineIndex, candidate_str);
- GodotRuntime.free(candidate_str);
- GodotRuntime.free(mid_str);
+ const id = IDHandler.add(conn);
+
+ if ('connectionState' in conn && conn['connectionState'] !== undefined) {
+ // Use "connectionState" if supported
+ conn.onconnectionstatechange = function (event) {
+ if (!IDHandler.get(id)) {
+ return;
+ }
+ onConnectionChange(GodotRTCPeerConnection.ConnectionState[conn.connectionState] || 0);
+ };
+ } else {
+ // Fall back to using "iceConnectionState" when "connectionState" is not supported (notably Firefox).
+ conn.oniceconnectionstatechange = function (event) {
+ if (!IDHandler.get(id)) {
+ return;
+ }
+ onConnectionChange(GodotRTCPeerConnection.ConnectionStateCompat[conn.iceConnectionState] || 0);
+ };
+ }
+ conn.onicegatheringstatechange = function (event) {
+ if (!IDHandler.get(id)) {
+ return;
+ }
+ onIceGatheringChange(GodotRTCPeerConnection.IceGatheringState[conn.iceGatheringState] || 0);
+ };
+ conn.onsignalingstatechange = function (event) {
+ if (!IDHandler.get(id)) {
+ return;
+ }
+ onSignalingChange(GodotRTCPeerConnection.SignalingState[conn.signalingState] || 0);
+ };
+ conn.onicecandidate = function (event) {
+ if (!IDHandler.get(id)) {
+ return;
+ }
+ const c = event.candidate;
+ if (!c || !c.candidate) {
+ return;
+ }
+ const candidate_str = GodotRuntime.allocString(c.candidate);
+ const mid_str = GodotRuntime.allocString(c.sdpMid);
+ onIceCandidate(mid_str, c.sdpMLineIndex, candidate_str);
+ GodotRuntime.free(candidate_str);
+ GodotRuntime.free(mid_str);
+ };
+ conn.ondatachannel = function (event) {
+ if (!IDHandler.get(id)) {
+ return;
+ }
+ const cid = IDHandler.add(event.channel);
+ onDataChannel(cid);
+ };
+ return id;
},
- ondatachannel: function (p_id, callback, event) {
- const ref = IDHandler.get(p_id);
- if (!ref) {
+ destroy: function (p_id) {
+ const conn = IDHandler.get(p_id);
+ if (!conn) {
return;
}
-
- const cid = IDHandler.add(event.channel);
- callback(cid);
+ conn.onconnectionstatechange = null;
+ conn.oniceconnectionstatechange = null;
+ conn.onicegatheringstatechange = null;
+ conn.onsignalingstatechange = null;
+ conn.onicecandidate = null;
+ conn.ondatachannel = null;
+ IDHandler.remove(p_id);
},
onsession: function (p_id, callback, session) {
- const ref = IDHandler.get(p_id);
- if (!ref) {
+ if (!IDHandler.get(p_id)) {
return;
}
const type_str = GodotRuntime.allocString(session.type);
@@ -297,27 +356,19 @@ const GodotRTCPeerConnection = {
},
},
- godot_js_rtc_pc_create__sig: 'iiiiii',
- godot_js_rtc_pc_create: function (p_config, p_ref, p_on_state_change, p_on_candidate, p_on_datachannel) {
- const onstatechange = GodotRuntime.get_func(p_on_state_change).bind(null, p_ref);
- const oncandidate = GodotRuntime.get_func(p_on_candidate).bind(null, p_ref);
- const ondatachannel = GodotRuntime.get_func(p_on_datachannel).bind(null, p_ref);
-
- const config = JSON.parse(GodotRuntime.parseString(p_config));
- let conn = null;
- try {
- conn = new RTCPeerConnection(config);
- } catch (e) {
- GodotRuntime.error(e);
- return 0;
- }
-
- const base = GodotRTCPeerConnection;
- const id = IDHandler.add(conn);
- conn.oniceconnectionstatechange = base.onstatechange.bind(null, id, conn, onstatechange);
- conn.onicecandidate = base.onicecandidate.bind(null, id, oncandidate);
- conn.ondatachannel = base.ondatachannel.bind(null, id, ondatachannel);
- return id;
+ godot_js_rtc_pc_create__sig: 'iiiiiiii',
+ godot_js_rtc_pc_create: function (p_config, p_ref, p_on_connection_state_change, p_on_ice_gathering_state_change, p_on_signaling_state_change, p_on_ice_candidate, p_on_datachannel) {
+ const wrap = function (p_func) {
+ return GodotRuntime.get_func(p_func).bind(null, p_ref);
+ };
+ return GodotRTCPeerConnection.create(
+ JSON.parse(GodotRuntime.parseString(p_config)),
+ wrap(p_on_connection_state_change),
+ wrap(p_on_signaling_state_change),
+ wrap(p_on_ice_gathering_state_change),
+ wrap(p_on_ice_candidate),
+ wrap(p_on_datachannel)
+ );
},
godot_js_rtc_pc_close__sig: 'vi',
@@ -331,14 +382,7 @@ const GodotRTCPeerConnection = {
godot_js_rtc_pc_destroy__sig: 'vi',
godot_js_rtc_pc_destroy: function (p_id) {
- const ref = IDHandler.get(p_id);
- if (!ref) {
- return;
- }
- ref.oniceconnectionstatechange = null;
- ref.onicecandidate = null;
- ref.ondatachannel = null;
- IDHandler.remove(p_id);
+ GodotRTCPeerConnection.destroy(p_id);
},
godot_js_rtc_pc_offer_create__sig: 'viiii',
diff --git a/modules/webrtc/webrtc_peer_connection.cpp b/modules/webrtc/webrtc_peer_connection.cpp
index d885b9262b..5aa891d35c 100644
--- a/modules/webrtc/webrtc_peer_connection.cpp
+++ b/modules/webrtc/webrtc_peer_connection.cpp
@@ -69,6 +69,8 @@ void WebRTCPeerConnection::_bind_methods() {
ClassDB::bind_method(D_METHOD("close"), &WebRTCPeerConnection::close);
ClassDB::bind_method(D_METHOD("get_connection_state"), &WebRTCPeerConnection::get_connection_state);
+ ClassDB::bind_method(D_METHOD("get_gathering_state"), &WebRTCPeerConnection::get_gathering_state);
+ ClassDB::bind_method(D_METHOD("get_signaling_state"), &WebRTCPeerConnection::get_signaling_state);
ADD_SIGNAL(MethodInfo("session_description_created", PropertyInfo(Variant::STRING, "type"), PropertyInfo(Variant::STRING, "sdp")));
ADD_SIGNAL(MethodInfo("ice_candidate_created", PropertyInfo(Variant::STRING, "media"), PropertyInfo(Variant::INT, "index"), PropertyInfo(Variant::STRING, "name")));
@@ -80,6 +82,17 @@ void WebRTCPeerConnection::_bind_methods() {
BIND_ENUM_CONSTANT(STATE_DISCONNECTED);
BIND_ENUM_CONSTANT(STATE_FAILED);
BIND_ENUM_CONSTANT(STATE_CLOSED);
+
+ BIND_ENUM_CONSTANT(GATHERING_STATE_NEW);
+ BIND_ENUM_CONSTANT(GATHERING_STATE_GATHERING);
+ BIND_ENUM_CONSTANT(GATHERING_STATE_COMPLETE);
+
+ BIND_ENUM_CONSTANT(SIGNALING_STATE_STABLE);
+ BIND_ENUM_CONSTANT(SIGNALING_STATE_HAVE_LOCAL_OFFER);
+ BIND_ENUM_CONSTANT(SIGNALING_STATE_HAVE_REMOTE_OFFER);
+ BIND_ENUM_CONSTANT(SIGNALING_STATE_HAVE_LOCAL_PRANSWER);
+ BIND_ENUM_CONSTANT(SIGNALING_STATE_HAVE_REMOTE_PRANSWER);
+ BIND_ENUM_CONSTANT(SIGNALING_STATE_CLOSED);
}
WebRTCPeerConnection::WebRTCPeerConnection() {
diff --git a/modules/webrtc/webrtc_peer_connection.h b/modules/webrtc/webrtc_peer_connection.h
index 122ea3d00f..76f29f9d68 100644
--- a/modules/webrtc/webrtc_peer_connection.h
+++ b/modules/webrtc/webrtc_peer_connection.h
@@ -47,6 +47,21 @@ public:
STATE_CLOSED
};
+ enum GatheringState {
+ GATHERING_STATE_NEW,
+ GATHERING_STATE_GATHERING,
+ GATHERING_STATE_COMPLETE,
+ };
+
+ enum SignalingState {
+ SIGNALING_STATE_STABLE,
+ SIGNALING_STATE_HAVE_LOCAL_OFFER,
+ SIGNALING_STATE_HAVE_REMOTE_OFFER,
+ SIGNALING_STATE_HAVE_LOCAL_PRANSWER,
+ SIGNALING_STATE_HAVE_REMOTE_PRANSWER,
+ SIGNALING_STATE_CLOSED,
+ };
+
private:
static StringName default_extension;
@@ -57,6 +72,8 @@ public:
static void set_default_extension(const StringName &p_name);
virtual ConnectionState get_connection_state() const = 0;
+ virtual GatheringState get_gathering_state() const = 0;
+ virtual SignalingState get_signaling_state() const = 0;
virtual Error initialize(Dictionary p_config = Dictionary()) = 0;
virtual Ref<WebRTCDataChannel> create_data_channel(String p_label, Dictionary p_options = Dictionary()) = 0;
@@ -74,5 +91,7 @@ public:
};
VARIANT_ENUM_CAST(WebRTCPeerConnection::ConnectionState);
+VARIANT_ENUM_CAST(WebRTCPeerConnection::GatheringState);
+VARIANT_ENUM_CAST(WebRTCPeerConnection::SignalingState);
#endif // WEBRTC_PEER_CONNECTION_H
diff --git a/modules/webrtc/webrtc_peer_connection_extension.cpp b/modules/webrtc/webrtc_peer_connection_extension.cpp
index 54143e4b79..592a1f8a97 100644
--- a/modules/webrtc/webrtc_peer_connection_extension.cpp
+++ b/modules/webrtc/webrtc_peer_connection_extension.cpp
@@ -32,6 +32,8 @@
void WebRTCPeerConnectionExtension::_bind_methods() {
GDVIRTUAL_BIND(_get_connection_state);
+ GDVIRTUAL_BIND(_get_gathering_state);
+ GDVIRTUAL_BIND(_get_signaling_state);
GDVIRTUAL_BIND(_initialize, "p_config");
GDVIRTUAL_BIND(_create_data_channel, "p_label", "p_config");
GDVIRTUAL_BIND(_create_offer);
diff --git a/modules/webrtc/webrtc_peer_connection_extension.h b/modules/webrtc/webrtc_peer_connection_extension.h
index 0c324ca45f..085069debb 100644
--- a/modules/webrtc/webrtc_peer_connection_extension.h
+++ b/modules/webrtc/webrtc_peer_connection_extension.h
@@ -53,6 +53,8 @@ public:
/** GDExtension **/
EXBIND0RC(ConnectionState, get_connection_state);
+ EXBIND0RC(GatheringState, get_gathering_state);
+ EXBIND0RC(SignalingState, get_signaling_state);
EXBIND1R(Error, initialize, Dictionary);
EXBIND0R(Error, create_offer);
EXBIND2R(Error, set_remote_description, String, String);
diff --git a/modules/webrtc/webrtc_peer_connection_js.cpp b/modules/webrtc/webrtc_peer_connection_js.cpp
index f48705253b..a371312ae9 100644
--- a/modules/webrtc/webrtc_peer_connection_js.cpp
+++ b/modules/webrtc/webrtc_peer_connection_js.cpp
@@ -51,6 +51,16 @@ void WebRTCPeerConnectionJS::_on_connection_state_changed(void *p_obj, int p_sta
peer->_conn_state = (ConnectionState)p_state;
}
+void WebRTCPeerConnectionJS::_on_gathering_state_changed(void *p_obj, int p_state) {
+ WebRTCPeerConnectionJS *peer = static_cast<WebRTCPeerConnectionJS *>(p_obj);
+ peer->_gathering_state = (GatheringState)p_state;
+}
+
+void WebRTCPeerConnectionJS::_on_signaling_state_changed(void *p_obj, int p_state) {
+ WebRTCPeerConnectionJS *peer = static_cast<WebRTCPeerConnectionJS *>(p_obj);
+ peer->_signaling_state = (SignalingState)p_state;
+}
+
void WebRTCPeerConnectionJS::_on_error(void *p_obj) {
ERR_PRINT("RTCPeerConnection error!");
}
@@ -100,7 +110,7 @@ Error WebRTCPeerConnectionJS::initialize(Dictionary p_config) {
_conn_state = STATE_NEW;
String config = Variant(p_config).to_json_string();
- _js_id = godot_js_rtc_pc_create(config.utf8().get_data(), this, &_on_connection_state_changed, &_on_ice_candidate, &_on_data_channel);
+ _js_id = godot_js_rtc_pc_create(config.utf8().get_data(), this, &_on_connection_state_changed, &_on_gathering_state_changed, &_on_signaling_state_changed, &_on_ice_candidate, &_on_data_channel);
return _js_id ? OK : FAILED;
}
@@ -117,14 +127,19 @@ Error WebRTCPeerConnectionJS::poll() {
return OK;
}
+WebRTCPeerConnection::GatheringState WebRTCPeerConnectionJS::get_gathering_state() const {
+ return _gathering_state;
+}
+
+WebRTCPeerConnection::SignalingState WebRTCPeerConnectionJS::get_signaling_state() const {
+ return _signaling_state;
+}
+
WebRTCPeerConnection::ConnectionState WebRTCPeerConnectionJS::get_connection_state() const {
return _conn_state;
}
WebRTCPeerConnectionJS::WebRTCPeerConnectionJS() {
- _conn_state = STATE_NEW;
- _js_id = 0;
-
Dictionary config;
initialize(config);
}
diff --git a/modules/webrtc/webrtc_peer_connection_js.h b/modules/webrtc/webrtc_peer_connection_js.h
index 50266129e4..e62ad6af28 100644
--- a/modules/webrtc/webrtc_peer_connection_js.h
+++ b/modules/webrtc/webrtc_peer_connection_js.h
@@ -37,11 +37,13 @@
extern "C" {
typedef void (*RTCOnIceConnectionStateChange)(void *p_obj, int p_state);
+typedef void (*RTCOnIceGatheringStateChange)(void *p_obj, int p_state);
+typedef void (*RTCOnSignalingStateChange)(void *p_obj, int p_state);
typedef void (*RTCOnIceCandidate)(void *p_obj, const char *p_mid, int p_mline_idx, const char *p_candidate);
typedef void (*RTCOnDataChannel)(void *p_obj, int p_id);
typedef void (*RTCOnSession)(void *p_obj, const char *p_type, const char *p_sdp);
typedef void (*RTCOnError)(void *p_obj);
-extern int godot_js_rtc_pc_create(const char *p_config, void *p_obj, RTCOnIceConnectionStateChange p_on_state_change, RTCOnIceCandidate p_on_candidate, RTCOnDataChannel p_on_datachannel);
+extern int godot_js_rtc_pc_create(const char *p_config, void *p_obj, RTCOnIceConnectionStateChange p_on_connection_state_change, RTCOnIceGatheringStateChange p_on_gathering_state_change, RTCOnSignalingStateChange p_on_signaling_state_change, RTCOnIceCandidate p_on_candidate, RTCOnDataChannel p_on_datachannel);
extern void godot_js_rtc_pc_close(int p_id);
extern void godot_js_rtc_pc_destroy(int p_id);
extern void godot_js_rtc_pc_offer_create(int p_id, void *p_obj, RTCOnSession p_on_session, RTCOnError p_on_error);
@@ -55,10 +57,14 @@ class WebRTCPeerConnectionJS : public WebRTCPeerConnection {
GDCLASS(WebRTCPeerConnectionJS, WebRTCPeerConnection);
private:
- int _js_id;
- ConnectionState _conn_state;
+ int _js_id = 0;
+ ConnectionState _conn_state = STATE_NEW;
+ GatheringState _gathering_state = GATHERING_STATE_NEW;
+ SignalingState _signaling_state = SIGNALING_STATE_STABLE;
static void _on_connection_state_changed(void *p_obj, int p_state);
+ static void _on_gathering_state_changed(void *p_obj, int p_state);
+ static void _on_signaling_state_changed(void *p_obj, int p_state);
static void _on_ice_candidate(void *p_obj, const char *p_mid_name, int p_mline_idx, const char *p_candidate);
static void _on_data_channel(void *p_obj, int p_channel);
static void _on_session_created(void *p_obj, const char *p_type, const char *p_session);
@@ -66,6 +72,8 @@ private:
public:
virtual ConnectionState get_connection_state() const override;
+ virtual GatheringState get_gathering_state() const override;
+ virtual SignalingState get_signaling_state() const override;
virtual Error initialize(Dictionary configuration = Dictionary()) override;
virtual Ref<WebRTCDataChannel> create_data_channel(String p_channel_name, Dictionary p_channel_config = Dictionary()) override;
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp
index 5bbe0ffab6..f4c4e985fe 100644
--- a/platform/android/export/export.cpp
+++ b/platform/android/export/export.cpp
@@ -36,6 +36,7 @@
#include "export_plugin.h"
void register_android_exporter() {
+#ifndef ANDROID_ENABLED
EDITOR_DEF("export/android/android_sdk_path", "");
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/android/android_sdk_path", PROPERTY_HINT_GLOBAL_DIR));
EDITOR_DEF("export/android/debug_keystore", "");
@@ -47,6 +48,7 @@ void register_android_exporter() {
EDITOR_DEF("export/android/shutdown_adb_on_exit", true);
EDITOR_DEF("export/android/one_click_deploy_clear_previous_install", false);
+#endif
Ref<EditorExportPlatformAndroid> exporter = Ref<EditorExportPlatformAndroid>(memnew(EditorExportPlatformAndroid));
EditorExport::get_singleton()->add_export_platform(exporter);
diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp
index 0f8ef3f7d6..e5656bd00b 100644
--- a/platform/android/export/export_plugin.cpp
+++ b/platform/android/export/export_plugin.cpp
@@ -569,16 +569,15 @@ bool EditorExportPlatformAndroid::_should_compress_asset(const String &p_path, c
}
zip_fileinfo EditorExportPlatformAndroid::get_zip_fileinfo() {
- OS::Time time = OS::get_singleton()->get_time();
- OS::Date date = OS::get_singleton()->get_date();
+ OS::DateTime dt = OS::get_singleton()->get_datetime();
zip_fileinfo zipfi;
- zipfi.tmz_date.tm_hour = time.hour;
- zipfi.tmz_date.tm_mday = date.day;
- zipfi.tmz_date.tm_min = time.minute;
- zipfi.tmz_date.tm_mon = date.month - 1; // tm_mon is zero indexed
- zipfi.tmz_date.tm_sec = time.second;
- zipfi.tmz_date.tm_year = date.year;
+ zipfi.tmz_date.tm_year = dt.year;
+ zipfi.tmz_date.tm_mon = dt.month - 1; // tm_mon is zero indexed
+ zipfi.tmz_date.tm_mday = dt.day;
+ zipfi.tmz_date.tm_hour = dt.hour;
+ zipfi.tmz_date.tm_min = dt.minute;
+ zipfi.tmz_date.tm_sec = dt.second;
zipfi.dosDate = 0;
zipfi.external_fa = 0;
zipfi.internal_fa = 0;
diff --git a/platform/android/java/app/config.gradle b/platform/android/java/app/config.gradle
index fbd97fae0b..0346625e4b 100644
--- a/platform/android/java/app/config.gradle
+++ b/platform/android/java/app/config.gradle
@@ -127,16 +127,36 @@ ext.generateGodotLibraryVersion = { List<String> requiredKeys ->
if (requiredKeys.empty) {
libraryVersionName = map.values().join(".")
try {
+ if (map.containsKey("status")) {
+ int statusCode = 0
+ String statusValue = map["status"]
+ if (statusValue == null) {
+ statusCode = 0
+ } else if (statusValue.startsWith("alpha")) {
+ statusCode = 1
+ } else if (statusValue.startsWith("beta")) {
+ statusCode = 2
+ } else if (statusValue.startsWith("rc")) {
+ statusCode = 3
+ } else if (statusValue.startsWith("stable")) {
+ statusCode = 4
+ } else {
+ statusCode = 0
+ }
+
+ libraryVersionCode = statusCode
+ }
+
if (map.containsKey("patch")) {
- libraryVersionCode = Integer.parseInt(map["patch"])
+ libraryVersionCode += Integer.parseInt(map["patch"]) * 10
}
if (map.containsKey("minor")) {
- libraryVersionCode += (Integer.parseInt(map["minor"]) * 100)
+ libraryVersionCode += (Integer.parseInt(map["minor"]) * 1000)
}
if (map.containsKey("major")) {
- libraryVersionCode += (Integer.parseInt(map["major"]) * 10000)
+ libraryVersionCode += (Integer.parseInt(map["major"]) * 100000)
}
} catch (NumberFormatException ignore) {
libraryVersionCode = 1
diff --git a/platform/android/java/editor/build.gradle b/platform/android/java/editor/build.gradle
index 729966ee69..9152492e9d 100644
--- a/platform/android/java/editor/build.gradle
+++ b/platform/android/java/editor/build.gradle
@@ -12,6 +12,25 @@ dependencies {
implementation "androidx.window:window:1.0.0"
}
+ext {
+ // Build number added as a suffix to the version code, and incremented for each build/upload to
+ // the Google Play store.
+ // This should be reset on each stable release of Godot.
+ editorBuildNumber = 0
+ // Value by which the Godot version code should be offset by to make room for the build number
+ editorBuildNumberOffset = 100
+}
+
+def generateVersionCode() {
+ int libraryVersionCode = getGodotLibraryVersionCode()
+ return (libraryVersionCode * editorBuildNumberOffset) + editorBuildNumber
+}
+
+def generateVersionName() {
+ String libraryVersionName = getGodotLibraryVersionName()
+ return libraryVersionName + ".$editorBuildNumber"
+}
+
android {
compileSdkVersion versions.compileSdk
buildToolsVersion versions.buildTools
@@ -20,8 +39,8 @@ android {
defaultConfig {
// The 'applicationId' suffix allows to install Godot 3.x(v3) and 4.x(v4) on the same device
applicationId "org.godotengine.editor.v4"
- versionCode getGodotLibraryVersionCode()
- versionName getGodotLibraryVersionName()
+ versionCode generateVersionCode()
+ versionName generateVersionName()
minSdkVersion versions.minSdk
targetSdkVersion versions.targetSdk
diff --git a/platform/android/java/editor/src/main/AndroidManifest.xml b/platform/android/java/editor/src/main/AndroidManifest.xml
index abf506a83c..6aa5f06f31 100644
--- a/platform/android/java/editor/src/main/AndroidManifest.xml
+++ b/platform/android/java/editor/src/main/AndroidManifest.xml
@@ -7,7 +7,7 @@
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
- android:smallScreens="true"
+ android:smallScreens="false"
android:xlargeScreens="true" />
<uses-feature
diff --git a/platform/ios/detect.py b/platform/ios/detect.py
index 3cfb25cf61..ed7e714c4e 100644
--- a/platform/ios/detect.py
+++ b/platform/ios/detect.py
@@ -120,6 +120,10 @@ def configure(env):
env.Append(CCFLAGS=["-miphoneos-version-min=11.0"])
if env["arch"] == "x86_64":
+ if not env["ios_simulator"]:
+ print("ERROR: Building for iOS with 'arch=x86_64' requires 'ios_simulator=yes'.")
+ sys.exit(255)
+
env["ENV"]["MACOSX_DEPLOYMENT_TARGET"] = "10.9"
env.Append(
CCFLAGS=(
diff --git a/platform/linuxbsd/gl_manager_x11.cpp b/platform/linuxbsd/gl_manager_x11.cpp
index 04c1df71fb..838be2c042 100644
--- a/platform/linuxbsd/gl_manager_x11.cpp
+++ b/platform/linuxbsd/gl_manager_x11.cpp
@@ -256,7 +256,11 @@ void GLManager_X11::release_current() {
if (!_current_window) {
return;
}
- glXMakeCurrent(_x_windisp.x11_display, None, nullptr);
+
+ if (!glXMakeCurrent(_x_windisp.x11_display, None, nullptr)) {
+ ERR_PRINT("glXMakeCurrent failed");
+ }
+ _current_window = nullptr;
}
void GLManager_X11::window_make_current(DisplayServer::WindowID p_window_id) {
@@ -276,7 +280,9 @@ void GLManager_X11::window_make_current(DisplayServer::WindowID p_window_id) {
const GLDisplay &disp = get_display(win.gldisplay_id);
- glXMakeCurrent(disp.x11_display, win.x11_window, disp.context->glx_context);
+ if (!glXMakeCurrent(disp.x11_display, win.x11_window, disp.context->glx_context)) {
+ ERR_PRINT("glXMakeCurrent failed");
+ }
_internal_set_current_window(&win);
}
@@ -290,13 +296,12 @@ void GLManager_X11::make_current() {
return;
}
const GLDisplay &disp = get_current_display();
- glXMakeCurrent(_x_windisp.x11_display, _x_windisp.x11_window, disp.context->glx_context);
+ if (!glXMakeCurrent(_x_windisp.x11_display, _x_windisp.x11_window, disp.context->glx_context)) {
+ ERR_PRINT("glXMakeCurrent failed");
+ }
}
void GLManager_X11::swap_buffers() {
- // NO NEED TO CALL SWAP BUFFERS for each window...
- // see https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glXSwapBuffers.xml
-
if (!_current_window) {
return;
}
@@ -315,13 +320,6 @@ void GLManager_X11::swap_buffers() {
}
}
- // print_line("\tswap_buffers");
-
- // only for debugging without drawing anything
- // glClearColor(Math::randf(), 0, 1, 1);
- //glClear(GL_COLOR_BUFFER_BIT);
-
- //const GLDisplay &disp = get_current_display();
glXSwapBuffers(_x_windisp.x11_display, _x_windisp.x11_window);
}
diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp
index 61faf3061c..f0d7b6ede5 100644
--- a/platform/linuxbsd/os_linuxbsd.cpp
+++ b/platform/linuxbsd/os_linuxbsd.cpp
@@ -686,10 +686,9 @@ Error OS_LinuxBSD::move_to_trash(const String &p_path) {
String renamed_path = path.get_base_dir() + "/" + file_name;
// Generates the .trashinfo file
- OS::Date date = OS::get_singleton()->get_date(false);
- OS::Time time = OS::get_singleton()->get_time(false);
- String timestamp = vformat("%04d-%02d-%02dT%02d:%02d:", date.year, (int)date.month, date.day, time.hour, time.minute);
- timestamp = vformat("%s%02d", timestamp, time.second); // vformat only supports up to 6 arguments.
+ OS::DateTime dt = OS::get_singleton()->get_datetime(false);
+ String timestamp = vformat("%04d-%02d-%02dT%02d:%02d:", dt.year, (int)dt.month, dt.day, dt.hour, dt.minute);
+ timestamp = vformat("%s%02d", timestamp, dt.second); // vformat only supports up to 6 arguments.
String trash_info = "[Trash Info]\nPath=" + path.uri_encode() + "\nDeletionDate=" + timestamp + "\n";
{
Error err;
diff --git a/platform/macos/display_server_macos.mm b/platform/macos/display_server_macos.mm
index b009007d73..91c6da5d13 100644
--- a/platform/macos/display_server_macos.mm
+++ b/platform/macos/display_server_macos.mm
@@ -166,6 +166,7 @@ DisplayServerMacOS::WindowID DisplayServerMacOS::_create_window(WindowMode p_mod
ERR_FAIL_COND_V_MSG(err != OK, INVALID_WINDOW_ID, "Can't create an OpenGL context");
}
#endif
+ [wd.window_view updateLayerDelegate];
id = window_id_counter++;
windows[id] = wd;
}
diff --git a/platform/macos/export/export.cpp b/platform/macos/export/export.cpp
index f219616df4..5f9cf22ccf 100644
--- a/platform/macos/export/export.cpp
+++ b/platform/macos/export/export.cpp
@@ -33,12 +33,14 @@
#include "export_plugin.h"
void register_macos_exporter() {
+#ifndef ANDROID_ENABLED
EDITOR_DEF("export/macos/rcodesign", "");
#ifdef WINDOWS_ENABLED
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/macos/rcodesign", PROPERTY_HINT_GLOBAL_FILE, "*.exe"));
#else
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/macos/rcodesign", PROPERTY_HINT_GLOBAL_FILE));
#endif
+#endif
Ref<EditorExportPlatformMacOS> platform;
platform.instantiate();
diff --git a/platform/macos/export/export_plugin.cpp b/platform/macos/export/export_plugin.cpp
index 50104aced5..070830c486 100644
--- a/platform/macos/export/export_plugin.cpp
+++ b/platform/macos/export/export_plugin.cpp
@@ -1641,16 +1641,15 @@ void EditorExportPlatformMacOS::_zip_folder_recursive(zipFile &p_zip, const Stri
continue;
}
if (da->is_link(f)) {
- OS::Time time = OS::get_singleton()->get_time();
- OS::Date date = OS::get_singleton()->get_date();
+ OS::DateTime dt = OS::get_singleton()->get_datetime();
zip_fileinfo zipfi;
- zipfi.tmz_date.tm_hour = time.hour;
- zipfi.tmz_date.tm_mday = date.day;
- zipfi.tmz_date.tm_min = time.minute;
- zipfi.tmz_date.tm_mon = date.month - 1; // Note: "tm" month range - 0..11, Godot month range - 1..12, https://www.cplusplus.com/reference/ctime/tm/
- zipfi.tmz_date.tm_sec = time.second;
- zipfi.tmz_date.tm_year = date.year;
+ zipfi.tmz_date.tm_year = dt.year;
+ zipfi.tmz_date.tm_mon = dt.month - 1; // Note: "tm" month range - 0..11, Godot month range - 1..12, https://www.cplusplus.com/reference/ctime/tm/
+ zipfi.tmz_date.tm_mday = dt.day;
+ zipfi.tmz_date.tm_hour = dt.hour;
+ zipfi.tmz_date.tm_min = dt.minute;
+ zipfi.tmz_date.tm_sec = dt.second;
zipfi.dosDate = 0;
// 0120000: symbolic link type
// 0000755: permissions rwxr-xr-x
@@ -1686,16 +1685,15 @@ void EditorExportPlatformMacOS::_zip_folder_recursive(zipFile &p_zip, const Stri
} else {
bool is_executable = (p_folder.ends_with("MacOS") && (f == p_pkg_name)) || p_folder.ends_with("Helpers") || f.ends_with(".command");
- OS::Time time = OS::get_singleton()->get_time();
- OS::Date date = OS::get_singleton()->get_date();
+ OS::DateTime dt = OS::get_singleton()->get_datetime();
zip_fileinfo zipfi;
- zipfi.tmz_date.tm_hour = time.hour;
- zipfi.tmz_date.tm_mday = date.day;
- zipfi.tmz_date.tm_min = time.minute;
- zipfi.tmz_date.tm_mon = date.month - 1; // Note: "tm" month range - 0..11, Godot month range - 1..12, https://www.cplusplus.com/reference/ctime/tm/
- zipfi.tmz_date.tm_sec = time.second;
- zipfi.tmz_date.tm_year = date.year;
+ zipfi.tmz_date.tm_year = dt.year;
+ zipfi.tmz_date.tm_mon = dt.month - 1; // Note: "tm" month range - 0..11, Godot month range - 1..12, https://www.cplusplus.com/reference/ctime/tm/
+ zipfi.tmz_date.tm_mday = dt.day;
+ zipfi.tmz_date.tm_hour = dt.hour;
+ zipfi.tmz_date.tm_min = dt.minute;
+ zipfi.tmz_date.tm_sec = dt.second;
zipfi.dosDate = 0;
// 0100000: regular file type
// 0000755: permissions rwxr-xr-x
diff --git a/platform/macos/gl_manager_macos_legacy.mm b/platform/macos/gl_manager_macos_legacy.mm
index e6bb7aaa85..dec4821b86 100644
--- a/platform/macos/gl_manager_macos_legacy.mm
+++ b/platform/macos/gl_manager_macos_legacy.mm
@@ -167,9 +167,8 @@ void GLManager_MacOS::make_current() {
}
void GLManager_MacOS::swap_buffers() {
- for (const KeyValue<DisplayServer::WindowID, GLWindow> &E : windows) {
- [E.value.context flushBuffer];
- }
+ GLWindow &win = windows[current_window];
+ [win.context flushBuffer];
}
void GLManager_MacOS::window_update(DisplayServer::WindowID p_window_id) {
diff --git a/platform/macos/godot_content_view.h b/platform/macos/godot_content_view.h
index 353305aec1..a6318ab903 100644
--- a/platform/macos/godot_content_view.h
+++ b/platform/macos/godot_content_view.h
@@ -45,6 +45,14 @@
#import <QuartzCore/CAMetalLayer.h>
+@interface GodotContentLayerDelegate : NSObject <CALayerDelegate> {
+ DisplayServer::WindowID window_id;
+}
+
+- (void)setWindowID:(DisplayServer::WindowID)wid;
+
+@end
+
@interface GodotContentView : RootView <NSTextInputClient> {
DisplayServer::WindowID window_id;
NSTrackingArea *tracking_area;
@@ -53,12 +61,14 @@
bool mouse_down_control;
bool ignore_momentum_scroll;
bool last_pen_inverted;
+ id layer_delegate;
}
- (void)processScrollEvent:(NSEvent *)event button:(MouseButton)button factor:(double)factor;
- (void)processPanEvent:(NSEvent *)event dx:(double)dx dy:(double)dy;
- (void)processMouseEvent:(NSEvent *)event index:(MouseButton)index mask:(MouseButton)mask pressed:(bool)pressed;
- (void)setWindowID:(DisplayServer::WindowID)wid;
+- (void)updateLayerDelegate;
- (void)cancelComposition;
@end
diff --git a/platform/macos/godot_content_view.mm b/platform/macos/godot_content_view.mm
index dbed969901..f93ef48f6c 100644
--- a/platform/macos/godot_content_view.mm
+++ b/platform/macos/godot_content_view.mm
@@ -32,11 +32,48 @@
#include "display_server_macos.h"
#include "key_mapping_macos.h"
+#include "main/main.h"
+
+@implementation GodotContentLayerDelegate
+
+- (id)init {
+ self = [super init];
+ window_id = DisplayServer::INVALID_WINDOW_ID;
+ return self;
+}
+
+- (void)setWindowID:(DisplayServerMacOS::WindowID)wid {
+ window_id = wid;
+}
+
+- (void)displayLayer:(CALayer *)layer {
+ DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton();
+ if (OS::get_singleton()->get_main_loop() && ds->get_is_resizing()) {
+ Main::force_redraw();
+ if (!Main::is_iterating()) { // Avoid cyclic loop.
+ Main::iteration();
+ }
+ }
+}
+
+@end
@implementation GodotContentView
+- (void)setFrameSize:(NSSize)newSize {
+ [super setFrameSize:newSize];
+ [self.layer setNeedsDisplay]; // Force "drawRect" call.
+}
+
+- (void)updateLayerDelegate {
+ self.layer.delegate = layer_delegate;
+ self.layer.autoresizingMask = kCALayerHeightSizable | kCALayerWidthSizable;
+ self.layer.needsDisplayOnBoundsChange = YES;
+}
+
- (id)init {
self = [super init];
+ layer_delegate = [[GodotContentLayerDelegate alloc] init];
window_id = DisplayServer::INVALID_WINDOW_ID;
tracking_area = nil;
ime_input_event_in_progress = false;
@@ -45,6 +82,9 @@
last_pen_inverted = false;
[self updateTrackingAreas];
+ self.layerContentsRedrawPolicy = NSViewLayerContentsRedrawDuringViewResize;
+ self.layerContentsPlacement = NSViewLayerContentsPlacementTopLeft;
+
if (@available(macOS 10.13, *)) {
[self registerForDraggedTypes:[NSArray arrayWithObject:NSPasteboardTypeFileURL]];
#if !defined(__aarch64__) // Do not build deprectead 10.13 code on ARM.
@@ -58,6 +98,7 @@
- (void)setWindowID:(DisplayServerMacOS::WindowID)wid {
window_id = wid;
+ [layer_delegate setWindowID:window_id];
}
// MARK: Backing Layer
diff --git a/platform/macos/os_macos.mm b/platform/macos/os_macos.mm
index 35c4e4b03d..c250a9d71a 100644
--- a/platform/macos/os_macos.mm
+++ b/platform/macos/os_macos.mm
@@ -56,10 +56,11 @@ _FORCE_INLINE_ String OS_MacOS::get_framework_executable(const String &p_path) {
}
void OS_MacOS::pre_wait_observer_cb(CFRunLoopObserverRef p_observer, CFRunLoopActivity p_activiy, void *p_context) {
- // Prevent main loop from sleeping and redraw window during resize / modal popups.
+ // Prevent main loop from sleeping and redraw window during modal popup display.
+ // Do not redraw when rendering is done from the separate thread, it will conflict with the OpenGL context updates.
DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton();
- if (get_singleton()->get_main_loop() && ds && (get_singleton()->get_render_thread_mode() != RENDER_SEPARATE_THREAD || !ds->get_is_resizing())) {
+ if (get_singleton()->get_main_loop() && ds && (get_singleton()->get_render_thread_mode() != RENDER_SEPARATE_THREAD) && !ds->get_is_resizing()) {
Main::force_redraw();
if (!Main::is_iterating()) { // Avoid cyclic loop.
Main::iteration();
diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp
index 494f5ec4b9..791328964b 100644
--- a/platform/uwp/os_uwp.cpp
+++ b/platform/uwp/os_uwp.cpp
@@ -444,7 +444,7 @@ String OS_UWP::get_name() const {
return "UWP";
}
-OS::Date OS_UWP::get_date(bool p_utc) const {
+OS::DateTime OS_UWP::get_datetime(bool p_utc) const {
SYSTEMTIME systemtime;
if (p_utc) {
GetSystemTime(&systemtime);
@@ -452,28 +452,23 @@ OS::Date OS_UWP::get_date(bool p_utc) const {
GetLocalTime(&systemtime);
}
- Date date;
- date.day = systemtime.wDay;
- date.month = Month(systemtime.wMonth);
- date.weekday = Weekday(systemtime.wDayOfWeek);
- date.year = systemtime.wYear;
- date.dst = false;
- return date;
-}
-
-OS::Time OS_UWP::get_time(bool p_utc) const {
- SYSTEMTIME systemtime;
- if (p_utc) {
- GetSystemTime(&systemtime);
- } else {
- GetLocalTime(&systemtime);
+ //Get DST information from Windows, but only if p_utc is false.
+ TIME_ZONE_INFORMATION info;
+ bool daylight = false;
+ if (!p_utc && GetTimeZoneInformation(&info) == TIME_ZONE_ID_DAYLIGHT) {
+ daylight = true;
}
- Time time;
- time.hour = systemtime.wHour;
- time.min = systemtime.wMinute;
- time.sec = systemtime.wSecond;
- return time;
+ DateTime dt;
+ dt.year = systemtime.wYear;
+ dt.month = Month(systemtime.wMonth);
+ dt.day = systemtime.wDay;
+ dt.weekday = Weekday(systemtime.wDayOfWeek);
+ dt.hour = systemtime.wHour;
+ dt.minute = systemtime.wMinute;
+ dt.second = systemtime.wSecond;
+ dt.dst = daylight;
+ return dt;
}
OS::TimeZoneInfo OS_UWP::get_time_zone_info() const {
diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h
index 5a58486ee7..7d4224cf74 100644
--- a/platform/uwp/os_uwp.h
+++ b/platform/uwp/os_uwp.h
@@ -184,8 +184,7 @@ public:
virtual String get_name() const;
- virtual Date get_date(bool p_utc) const;
- virtual Time get_time(bool p_utc) const;
+ virtual DateTime get_datetime(bool p_utc) const;
virtual TimeZoneInfo get_time_zone_info() const;
virtual uint64_t get_unix_time() const;
diff --git a/platform/web/display_server_web.cpp b/platform/web/display_server_web.cpp
index 38ac6b23f4..f6a61b18e4 100644
--- a/platform/web/display_server_web.cpp
+++ b/platform/web/display_server_web.cpp
@@ -997,7 +997,7 @@ void DisplayServerWeb::window_set_mode(WindowMode p_mode, WindowID p_window) {
} break;
case WINDOW_MODE_MAXIMIZED:
case WINDOW_MODE_MINIMIZED:
- WARN_PRINT("WindowMode MAXIMIZED and MINIMIZED are not supported in Web platform.");
+ // WindowMode MAXIMIZED and MINIMIZED are not supported in Web platform.
break;
default:
break;
diff --git a/platform/web/export/export.cpp b/platform/web/export/export.cpp
index 7193bc6ac4..4b4e8b2705 100644
--- a/platform/web/export/export.cpp
+++ b/platform/web/export/export.cpp
@@ -34,6 +34,7 @@
#include "export_plugin.h"
void register_web_exporter() {
+#ifndef ANDROID_ENABLED
EDITOR_DEF("export/web/http_host", "localhost");
EDITOR_DEF("export/web/http_port", 8060);
EDITOR_DEF("export/web/use_tls", false);
@@ -42,6 +43,7 @@ void register_web_exporter() {
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "export/web/http_port", PROPERTY_HINT_RANGE, "1,65535,1"));
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/web/tls_key", PROPERTY_HINT_GLOBAL_FILE, "*.key"));
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/web/tls_certificate", PROPERTY_HINT_GLOBAL_FILE, "*.crt,*.pem"));
+#endif
Ref<EditorExportPlatformWeb> platform;
platform.instantiate();
diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp
index b4949de3f7..237215c198 100644
--- a/platform/windows/display_server_windows.cpp
+++ b/platform/windows/display_server_windows.cpp
@@ -1496,7 +1496,7 @@ void DisplayServerWindows::cursor_set_shape(CursorShape p_shape) {
IDC_HELP
};
- if (cursors[p_shape] != nullptr) {
+ if (cursors_cache.has(p_shape)) {
SetCursor(cursors[p_shape]);
} else {
SetCursor(LoadCursor(hInstance, win_cursors[p_shape]));
@@ -1509,55 +1509,6 @@ DisplayServer::CursorShape DisplayServerWindows::cursor_get_shape() const {
return cursor_shape;
}
-void DisplayServerWindows::GetMaskBitmaps(HBITMAP hSourceBitmap, COLORREF clrTransparent, OUT HBITMAP &hAndMaskBitmap, OUT HBITMAP &hXorMaskBitmap) {
- // Get the system display DC.
- HDC hDC = GetDC(nullptr);
-
- // Create helper DC.
- HDC hMainDC = CreateCompatibleDC(hDC);
- HDC hAndMaskDC = CreateCompatibleDC(hDC);
- HDC hXorMaskDC = CreateCompatibleDC(hDC);
-
- // Get the dimensions of the source bitmap.
- BITMAP bm;
- GetObject(hSourceBitmap, sizeof(BITMAP), &bm);
-
- // Create the mask bitmaps.
- hAndMaskBitmap = CreateCompatibleBitmap(hDC, bm.bmWidth, bm.bmHeight); // Color.
- hXorMaskBitmap = CreateCompatibleBitmap(hDC, bm.bmWidth, bm.bmHeight); // Color.
-
- // Release the system display DC.
- ReleaseDC(nullptr, hDC);
-
- // Select the bitmaps to helper DC.
- HBITMAP hOldMainBitmap = (HBITMAP)SelectObject(hMainDC, hSourceBitmap);
- HBITMAP hOldAndMaskBitmap = (HBITMAP)SelectObject(hAndMaskDC, hAndMaskBitmap);
- HBITMAP hOldXorMaskBitmap = (HBITMAP)SelectObject(hXorMaskDC, hXorMaskBitmap);
-
- // Assign the monochrome AND mask bitmap pixels so that the pixels of the source bitmap
- // with 'clrTransparent' will be white pixels of the monochrome bitmap.
- SetBkColor(hMainDC, clrTransparent);
- BitBlt(hAndMaskDC, 0, 0, bm.bmWidth, bm.bmHeight, hMainDC, 0, 0, SRCCOPY);
-
- // Assign the color XOR mask bitmap pixels so that the pixels of the source bitmap
- // with 'clrTransparent' will be black and rest the pixels same as corresponding
- // pixels of the source bitmap.
- SetBkColor(hXorMaskDC, RGB(0, 0, 0));
- SetTextColor(hXorMaskDC, RGB(255, 255, 255));
- BitBlt(hXorMaskDC, 0, 0, bm.bmWidth, bm.bmHeight, hAndMaskDC, 0, 0, SRCCOPY);
- BitBlt(hXorMaskDC, 0, 0, bm.bmWidth, bm.bmHeight, hMainDC, 0, 0, SRCAND);
-
- // Deselect bitmaps from the helper DC.
- SelectObject(hMainDC, hOldMainBitmap);
- SelectObject(hAndMaskDC, hOldAndMaskBitmap);
- SelectObject(hXorMaskDC, hOldXorMaskBitmap);
-
- // Delete the helper DC.
- DeleteDC(hXorMaskDC);
- DeleteDC(hAndMaskDC);
- DeleteDC(hMainDC);
-}
-
void DisplayServerWindows::cursor_set_custom_image(const Ref<Resource> &p_cursor, CursorShape p_shape, const Vector2 &p_hotspot) {
_THREAD_SAFE_METHOD_
@@ -1610,8 +1561,26 @@ void DisplayServerWindows::cursor_set_custom_image(const Ref<Resource> &p_cursor
UINT image_size = texture_size.width * texture_size.height;
// Create the BITMAP with alpha channel.
- COLORREF *buffer = (COLORREF *)memalloc(sizeof(COLORREF) * image_size);
-
+ COLORREF *buffer = nullptr;
+
+ BITMAPV5HEADER bi;
+ ZeroMemory(&bi, sizeof(bi));
+ bi.bV5Size = sizeof(bi);
+ bi.bV5Width = texture_size.width;
+ bi.bV5Height = -texture_size.height;
+ bi.bV5Planes = 1;
+ bi.bV5BitCount = 32;
+ bi.bV5Compression = BI_BITFIELDS;
+ bi.bV5RedMask = 0x00ff0000;
+ bi.bV5GreenMask = 0x0000ff00;
+ bi.bV5BlueMask = 0x000000ff;
+ bi.bV5AlphaMask = 0xff000000;
+
+ HDC dc = GetDC(nullptr);
+ HBITMAP bitmap = CreateDIBSection(dc, reinterpret_cast<BITMAPINFO *>(&bi), DIB_RGB_COLORS, reinterpret_cast<void **>(&buffer), nullptr, 0);
+ HBITMAP mask = CreateBitmap(texture_size.width, texture_size.height, 1, 1, nullptr);
+
+ bool fully_transparent = true;
for (UINT index = 0; index < image_size; index++) {
int row_index = floor(index / texture_size.width) + atlas_rect.position.y;
int column_index = (index % int(texture_size.width)) + atlas_rect.position.x;
@@ -1620,39 +1589,28 @@ void DisplayServerWindows::cursor_set_custom_image(const Ref<Resource> &p_cursor
column_index = MIN(column_index, atlas_rect.size.width - 1);
row_index = MIN(row_index, atlas_rect.size.height - 1);
}
+ const Color &c = image->get_pixel(column_index, row_index);
+ fully_transparent = fully_transparent && (c.a == 0.f);
- *(buffer + index) = image->get_pixel(column_index, row_index).to_argb32();
- }
-
- // Using 4 channels, so 4 * 8 bits.
- HBITMAP bitmap = CreateBitmap(texture_size.width, texture_size.height, 1, 4 * 8, buffer);
- COLORREF clrTransparent = -1;
-
- // Create the AND and XOR masks for the bitmap.
- HBITMAP hAndMask = nullptr;
- HBITMAP hXorMask = nullptr;
-
- GetMaskBitmaps(bitmap, clrTransparent, hAndMask, hXorMask);
-
- if (nullptr == hAndMask || nullptr == hXorMask) {
- memfree(buffer);
- DeleteObject(bitmap);
- return;
+ *(buffer + index) = c.to_argb32();
}
// Finally, create the icon.
- ICONINFO iconinfo;
- iconinfo.fIcon = FALSE;
- iconinfo.xHotspot = p_hotspot.x;
- iconinfo.yHotspot = p_hotspot.y;
- iconinfo.hbmMask = hAndMask;
- iconinfo.hbmColor = hXorMask;
-
if (cursors[p_shape]) {
DestroyIcon(cursors[p_shape]);
}
- cursors[p_shape] = CreateIconIndirect(&iconinfo);
+ if (fully_transparent) {
+ cursors[p_shape] = nullptr;
+ } else {
+ ICONINFO iconinfo;
+ iconinfo.fIcon = FALSE;
+ iconinfo.xHotspot = p_hotspot.x;
+ iconinfo.yHotspot = p_hotspot.y;
+ iconinfo.hbmMask = mask;
+ iconinfo.hbmColor = bitmap;
+ cursors[p_shape] = CreateIconIndirect(&iconinfo);
+ }
Vector<Variant> params;
params.push_back(p_cursor);
@@ -1665,17 +1623,15 @@ void DisplayServerWindows::cursor_set_custom_image(const Ref<Resource> &p_cursor
}
}
- DeleteObject(hAndMask);
- DeleteObject(hXorMask);
-
- memfree(buffer);
+ DeleteObject(mask);
DeleteObject(bitmap);
+ ReleaseDC(nullptr, dc);
} else {
// Reset to default system cursor.
if (cursors[p_shape]) {
DestroyIcon(cursors[p_shape]);
- cursors[p_shape] = nullptr;
}
+ cursors[p_shape] = nullptr;
CursorShape c = cursor_shape;
cursor_shape = CURSOR_MAX;
@@ -2419,14 +2375,14 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
} break;
case WM_SETTINGCHANGE: {
if (lParam && CompareStringOrdinal(reinterpret_cast<LPCWCH>(lParam), -1, L"ImmersiveColorSet", -1, true) == CSTR_EQUAL) {
- if (is_dark_mode_supported()) {
+ if (is_dark_mode_supported() && dark_title_available) {
BOOL value = is_dark_mode();
::DwmSetWindowAttribute(windows[window_id].hWnd, DWMWA_USE_IMMERSIVE_DARK_MODE, &value, sizeof(value));
}
}
} break;
case WM_THEMECHANGED: {
- if (is_dark_mode_supported()) {
+ if (is_dark_mode_supported() && dark_title_available) {
BOOL value = is_dark_mode();
::DwmSetWindowAttribute(windows[window_id].hWnd, DWMWA_USE_IMMERSIVE_DARK_MODE, &value, sizeof(value));
}
@@ -3541,7 +3497,7 @@ DisplayServer::WindowID DisplayServerWindows::_create_window(WindowMode p_mode,
wd.pre_fs_valid = true;
}
- if (is_dark_mode_supported()) {
+ if (is_dark_mode_supported() && dark_title_available) {
BOOL value = is_dark_mode();
::DwmSetWindowAttribute(wd.hWnd, DWMWA_USE_IMMERSIVE_DARK_MODE, &value, sizeof(value));
}
@@ -3633,6 +3589,7 @@ WTPacketPtr DisplayServerWindows::wintab_WTPacket = nullptr;
WTEnablePtr DisplayServerWindows::wintab_WTEnable = nullptr;
// UXTheme API.
+bool DisplayServerWindows::dark_title_available = false;
bool DisplayServerWindows::ux_theme_available = false;
IsDarkModeAllowedForAppPtr DisplayServerWindows::IsDarkModeAllowedForApp = nullptr;
ShouldAppsUseDarkModePtr DisplayServerWindows::ShouldAppsUseDarkMode = nullptr;
@@ -3725,7 +3682,21 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
// Enforce default keep screen on value.
screen_set_keep_on(GLOBAL_GET("display/window/energy_saving/keep_screen_on"));
- // Load UXTheme
+ // Load Windows version info.
+ OSVERSIONINFOW os_ver;
+ ZeroMemory(&os_ver, sizeof(OSVERSIONINFOW));
+ os_ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
+
+ HMODULE nt_lib = LoadLibraryW(L"ntdll.dll");
+ if (nt_lib) {
+ RtlGetVersionPtr RtlGetVersion = (RtlGetVersionPtr)GetProcAddress(nt_lib, "RtlGetVersion");
+ if (RtlGetVersion) {
+ RtlGetVersion(&os_ver);
+ }
+ FreeLibrary(nt_lib);
+ }
+
+ // Load UXTheme.
HMODULE ux_theme_lib = LoadLibraryW(L"uxtheme.dll");
if (ux_theme_lib) {
IsDarkModeAllowedForApp = (IsDarkModeAllowedForAppPtr)GetProcAddress(ux_theme_lib, MAKEINTRESOURCEA(136));
@@ -3735,6 +3706,9 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
GetImmersiveUserColorSetPreference = (GetImmersiveUserColorSetPreferencePtr)GetProcAddress(ux_theme_lib, MAKEINTRESOURCEA(98));
ux_theme_available = IsDarkModeAllowedForApp && ShouldAppsUseDarkMode && GetImmersiveColorFromColorSetEx && GetImmersiveColorTypeFromName && GetImmersiveUserColorSetPreference;
+ if (os_ver.dwBuildNumber >= 22000) {
+ dark_title_available = true;
+ }
}
// Note: Wacom WinTab driver API for pen input, for devices incompatible with Windows Ink.
diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h
index dbc9821970..fd64a02020 100644
--- a/platform/windows/display_server_windows.h
+++ b/platform/windows/display_server_windows.h
@@ -157,6 +157,7 @@ typedef bool(WINAPI *ShouldAppsUseDarkModePtr)();
typedef DWORD(WINAPI *GetImmersiveColorFromColorSetExPtr)(UINT dwImmersiveColorSet, UINT dwImmersiveColorType, bool bIgnoreHighContrast, UINT dwHighContrastCacheMode);
typedef int(WINAPI *GetImmersiveColorTypeFromNamePtr)(const WCHAR *name);
typedef int(WINAPI *GetImmersiveUserColorSetPreferencePtr)(bool bForceCheckRegistry, bool bSkipCheckOnFail);
+typedef HRESULT(WINAPI *RtlGetVersionPtr)(OSVERSIONINFOW *lpVersionInformation);
// Windows Ink API
#ifndef POINTER_STRUCTURES
@@ -285,6 +286,7 @@ class DisplayServerWindows : public DisplayServer {
_THREAD_SAFE_CLASS_
// UXTheme API
+ static bool dark_title_available;
static bool ux_theme_available;
static IsDarkModeAllowedForAppPtr IsDarkModeAllowedForApp;
static ShouldAppsUseDarkModePtr ShouldAppsUseDarkMode;
@@ -309,8 +311,6 @@ class DisplayServerWindows : public DisplayServer {
String tablet_driver;
Vector<String> tablet_drivers;
- void GetMaskBitmaps(HBITMAP hSourceBitmap, COLORREF clrTransparent, OUT HBITMAP &hAndMaskBitmap, OUT HBITMAP &hXorMaskBitmap);
-
enum {
KEY_EVENT_BUFFER_SIZE = 512
};
diff --git a/platform/windows/export/export.cpp b/platform/windows/export/export.cpp
index 20320470b8..8f91756c02 100644
--- a/platform/windows/export/export.cpp
+++ b/platform/windows/export/export.cpp
@@ -34,6 +34,7 @@
#include "export_plugin.h"
void register_windows_exporter() {
+#ifndef ANDROID_ENABLED
EDITOR_DEF("export/windows/rcedit", "");
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/windows/rcedit", PROPERTY_HINT_GLOBAL_FILE, "*.exe"));
#ifdef WINDOWS_ENABLED
@@ -46,6 +47,7 @@ void register_windows_exporter() {
EDITOR_DEF("export/windows/wine", "");
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/windows/wine", PROPERTY_HINT_GLOBAL_FILE));
#endif
+#endif
Ref<EditorExportPlatformWindows> platform;
platform.instantiate();
diff --git a/platform/windows/gl_manager_windows.cpp b/platform/windows/gl_manager_windows.cpp
index d509ff8c51..7689751f1b 100644
--- a/platform/windows/gl_manager_windows.cpp
+++ b/platform/windows/gl_manager_windows.cpp
@@ -289,12 +289,7 @@ void GLManager_Windows::make_current() {
}
void GLManager_Windows::swap_buffers() {
- // on other platforms, OpenGL swaps buffers for all windows (on all displays, really?)
- // Windows swaps buffers on a per-window basis
- // REVISIT: this could be structurally bad, should we have "dirty" flags then?
- for (KeyValue<DisplayServer::WindowID, GLWindow> &entry : _windows) {
- SwapBuffers(entry.value.hDC);
- }
+ SwapBuffers(_current_window->hDC);
}
Error GLManager_Windows::initialize() {
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index b7794bbbf8..2c268ff3d5 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -290,7 +290,7 @@ String OS_Windows::get_name() const {
return "Windows";
}
-OS::Date OS_Windows::get_date(bool p_utc) const {
+OS::DateTime OS_Windows::get_datetime(bool p_utc) const {
SYSTEMTIME systemtime;
if (p_utc) {
GetSystemTime(&systemtime);
@@ -305,28 +305,16 @@ OS::Date OS_Windows::get_date(bool p_utc) const {
daylight = true;
}
- Date date;
- date.day = systemtime.wDay;
- date.month = Month(systemtime.wMonth);
- date.weekday = Weekday(systemtime.wDayOfWeek);
- date.year = systemtime.wYear;
- date.dst = daylight;
- return date;
-}
-
-OS::Time OS_Windows::get_time(bool p_utc) const {
- SYSTEMTIME systemtime;
- if (p_utc) {
- GetSystemTime(&systemtime);
- } else {
- GetLocalTime(&systemtime);
- }
-
- Time time;
- time.hour = systemtime.wHour;
- time.minute = systemtime.wMinute;
- time.second = systemtime.wSecond;
- return time;
+ DateTime dt;
+ dt.year = systemtime.wYear;
+ dt.month = Month(systemtime.wMonth);
+ dt.day = systemtime.wDay;
+ dt.weekday = Weekday(systemtime.wDayOfWeek);
+ dt.hour = systemtime.wHour;
+ dt.minute = systemtime.wMinute;
+ dt.second = systemtime.wSecond;
+ dt.dst = daylight;
+ return dt;
}
OS::TimeZoneInfo OS_Windows::get_time_zone_info() const {
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index 3e054c068c..53451b780e 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -146,8 +146,7 @@ public:
virtual void initialize_joypads() override {}
- virtual Date get_date(bool p_utc) const override;
- virtual Time get_time(bool p_utc) const override;
+ virtual DateTime get_datetime(bool p_utc) const override;
virtual TimeZoneInfo get_time_zone_info() const override;
virtual double get_unix_time() const override;
diff --git a/scene/2d/animated_sprite_2d.cpp b/scene/2d/animated_sprite_2d.cpp
index b1b1cb23ed..7fe464d2f4 100644
--- a/scene/2d/animated_sprite_2d.cpp
+++ b/scene/2d/animated_sprite_2d.cpp
@@ -108,6 +108,7 @@ void AnimatedSprite2D::_validate_property(PropertyInfo &p_property) const {
if (!frames.is_valid()) {
return;
}
+
if (p_property.name == "animation") {
p_property.hint = PROPERTY_HINT_ENUM;
List<StringName> names;
@@ -137,9 +138,15 @@ void AnimatedSprite2D::_validate_property(PropertyInfo &p_property) const {
p_property.hint_string = String(animation) + "," + p_property.hint_string;
}
}
+ return;
}
if (p_property.name == "frame") {
+ if (playing) {
+ p_property.usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_READ_ONLY;
+ return;
+ }
+
p_property.hint = PROPERTY_HINT_RANGE;
if (frames->has_animation(animation) && frames->get_frame_count(animation) > 0) {
p_property.hint_string = "0," + itos(frames->get_frame_count(animation) - 1) + ",1";
@@ -175,33 +182,38 @@ void AnimatedSprite2D::_notification(int p_what) {
if (timeout <= 0) {
timeout = _get_frame_duration();
- int fc = frames->get_frame_count(animation);
- if ((!backwards && frame >= fc - 1) || (backwards && frame <= 0)) {
- if (frames->get_animation_loop(animation)) {
- if (backwards) {
- frame = fc - 1;
- } else {
- frame = 0;
- }
-
- emit_signal(SceneStringNames::get_singleton()->animation_finished);
- } else {
- if (backwards) {
+ int last_frame = frames->get_frame_count(animation) - 1;
+ if (!backwards) {
+ // Forward.
+ if (frame >= last_frame) {
+ if (frames->get_animation_loop(animation)) {
frame = 0;
- } else {
- frame = fc - 1;
- }
-
- if (!is_over) {
- is_over = true;
emit_signal(SceneStringNames::get_singleton()->animation_finished);
+ } else {
+ frame = last_frame;
+ if (!is_over) {
+ is_over = true;
+ emit_signal(SceneStringNames::get_singleton()->animation_finished);
+ }
}
+ } else {
+ frame++;
}
} else {
- if (backwards) {
- frame--;
+ // Reversed.
+ if (frame <= 0) {
+ if (frames->get_animation_loop(animation)) {
+ frame = last_frame;
+ emit_signal(SceneStringNames::get_singleton()->animation_finished);
+ } else {
+ frame = 0;
+ if (!is_over) {
+ is_over = true;
+ emit_signal(SceneStringNames::get_singleton()->animation_finished);
+ }
+ }
} else {
- frame++;
+ frame--;
}
}
@@ -259,14 +271,15 @@ void AnimatedSprite2D::_notification(int p_what) {
void AnimatedSprite2D::set_sprite_frames(const Ref<SpriteFrames> &p_frames) {
if (frames.is_valid()) {
- frames->disconnect("changed", callable_mp(this, &AnimatedSprite2D::_res_changed));
+ frames->disconnect(SceneStringNames::get_singleton()->changed, callable_mp(this, &AnimatedSprite2D::_res_changed));
}
+
frames = p_frames;
if (frames.is_valid()) {
- frames->connect("changed", callable_mp(this, &AnimatedSprite2D::_res_changed));
+ frames->connect(SceneStringNames::get_singleton()->changed, callable_mp(this, &AnimatedSprite2D::_res_changed));
}
- if (!frames.is_valid()) {
+ if (frames.is_null()) {
frame = 0;
} else {
set_frame(frame);
@@ -283,7 +296,7 @@ Ref<SpriteFrames> AnimatedSprite2D::get_sprite_frames() const {
}
void AnimatedSprite2D::set_frame(int p_frame) {
- if (!frames.is_valid()) {
+ if (frames.is_null()) {
return;
}
@@ -318,7 +331,7 @@ void AnimatedSprite2D::set_speed_scale(double p_speed_scale) {
speed_scale = MAX(p_speed_scale, 0.0f);
- // We adapt the timeout so that the animation speed adapts as soon as the speed scale is changed
+ // We adapt the timeout so that the animation speed adapts as soon as the speed scale is changed.
_reset_timeout();
timeout -= elapsed;
}
@@ -378,6 +391,7 @@ void AnimatedSprite2D::set_playing(bool p_playing) {
playing = p_playing;
_reset_timeout();
set_process_internal(playing);
+ notify_property_list_changed();
}
bool AnimatedSprite2D::is_playing() const {
diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp
index 3def41eaa5..b3f80b5e43 100644
--- a/scene/2d/area_2d.cpp
+++ b/scene/2d/area_2d.cpp
@@ -459,6 +459,16 @@ TypedArray<Area2D> Area2D::get_overlapping_areas() const {
return ret;
}
+bool Area2D::has_overlapping_bodies() const {
+ ERR_FAIL_COND_V_MSG(!monitoring, false, "Can't find overlapping bodies when monitoring is off.");
+ return !body_map.is_empty();
+}
+
+bool Area2D::has_overlapping_areas() const {
+ ERR_FAIL_COND_V_MSG(!monitoring, false, "Can't find overlapping areas when monitoring is off.");
+ return !area_map.is_empty();
+}
+
bool Area2D::overlaps_area(Node *p_area) const {
ERR_FAIL_NULL_V(p_area, false);
HashMap<ObjectID, AreaState>::ConstIterator E = area_map.find(p_area->get_instance_id());
@@ -578,6 +588,9 @@ void Area2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_overlapping_bodies"), &Area2D::get_overlapping_bodies);
ClassDB::bind_method(D_METHOD("get_overlapping_areas"), &Area2D::get_overlapping_areas);
+ ClassDB::bind_method(D_METHOD("has_overlapping_bodies"), &Area2D::has_overlapping_bodies);
+ ClassDB::bind_method(D_METHOD("has_overlapping_areas"), &Area2D::has_overlapping_areas);
+
ClassDB::bind_method(D_METHOD("overlaps_body", "body"), &Area2D::overlaps_body);
ClassDB::bind_method(D_METHOD("overlaps_area", "area"), &Area2D::overlaps_area);
diff --git a/scene/2d/area_2d.h b/scene/2d/area_2d.h
index 3d8d77eabb..f70f1dfc3d 100644
--- a/scene/2d/area_2d.h
+++ b/scene/2d/area_2d.h
@@ -180,6 +180,9 @@ public:
TypedArray<Node2D> get_overlapping_bodies() const; //function for script
TypedArray<Area2D> get_overlapping_areas() const; //function for script
+ bool has_overlapping_bodies() const;
+ bool has_overlapping_areas() const;
+
bool overlaps_area(Node *p_area) const;
bool overlaps_body(Node *p_body) const;
diff --git a/scene/3d/area_3d.cpp b/scene/3d/area_3d.cpp
index f118080009..cefa9eceff 100644
--- a/scene/3d/area_3d.cpp
+++ b/scene/3d/area_3d.cpp
@@ -489,6 +489,11 @@ TypedArray<Node3D> Area3D::get_overlapping_bodies() const {
return ret;
}
+bool Area3D::has_overlapping_bodies() const {
+ ERR_FAIL_COND_V_MSG(!monitoring, false, "Can't find overlapping bodies when monitoring is off.");
+ return !body_map.is_empty();
+}
+
void Area3D::set_monitorable(bool p_enable) {
ERR_FAIL_COND_MSG(locked || (is_inside_tree() && PhysicsServer3D::get_singleton()->is_flushing_queries()), "Function blocked during in/out signal. Use set_deferred(\"monitorable\", true/false).");
@@ -521,6 +526,11 @@ TypedArray<Area3D> Area3D::get_overlapping_areas() const {
return ret;
}
+bool Area3D::has_overlapping_areas() const {
+ ERR_FAIL_COND_V_MSG(!monitoring, false, "Can't find overlapping areas when monitoring is off.");
+ return !area_map.is_empty();
+}
+
bool Area3D::overlaps_area(Node *p_area) const {
ERR_FAIL_NULL_V(p_area, false);
HashMap<ObjectID, AreaState>::ConstIterator E = area_map.find(p_area->get_instance_id());
@@ -686,6 +696,9 @@ void Area3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_overlapping_bodies"), &Area3D::get_overlapping_bodies);
ClassDB::bind_method(D_METHOD("get_overlapping_areas"), &Area3D::get_overlapping_areas);
+ ClassDB::bind_method(D_METHOD("has_overlapping_bodies"), &Area3D::has_overlapping_bodies);
+ ClassDB::bind_method(D_METHOD("has_overlapping_areas"), &Area3D::has_overlapping_areas);
+
ClassDB::bind_method(D_METHOD("overlaps_body", "body"), &Area3D::overlaps_body);
ClassDB::bind_method(D_METHOD("overlaps_area", "area"), &Area3D::overlaps_area);
diff --git a/scene/3d/area_3d.h b/scene/3d/area_3d.h
index 48364739b7..0f0bcc7ce0 100644
--- a/scene/3d/area_3d.h
+++ b/scene/3d/area_3d.h
@@ -201,6 +201,9 @@ public:
TypedArray<Node3D> get_overlapping_bodies() const;
TypedArray<Area3D> get_overlapping_areas() const; //function for script
+ bool has_overlapping_bodies() const;
+ bool has_overlapping_areas() const;
+
bool overlaps_area(Node *p_area) const;
bool overlaps_body(Node *p_body) const;
diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp
index 4515277dc3..7a89bf81bb 100644
--- a/scene/3d/sprite_3d.cpp
+++ b/scene/3d/sprite_3d.cpp
@@ -30,7 +30,6 @@
#include "sprite_3d.h"
-#include "core/core_string_names.h"
#include "scene/scene_string_names.h"
Color SpriteBase3D::_get_color_accum() {
@@ -58,7 +57,7 @@ void SpriteBase3D::_propagate_color_changed() {
}
color_dirty = true;
- _queue_update();
+ _queue_redraw();
for (SpriteBase3D *&E : children) {
E->_propagate_color_changed();
@@ -90,7 +89,7 @@ void SpriteBase3D::_notification(int p_what) {
void SpriteBase3D::set_centered(bool p_center) {
centered = p_center;
- _queue_update();
+ _queue_redraw();
}
bool SpriteBase3D::is_centered() const {
@@ -99,7 +98,7 @@ bool SpriteBase3D::is_centered() const {
void SpriteBase3D::set_offset(const Point2 &p_offset) {
offset = p_offset;
- _queue_update();
+ _queue_redraw();
}
Point2 SpriteBase3D::get_offset() const {
@@ -108,7 +107,7 @@ Point2 SpriteBase3D::get_offset() const {
void SpriteBase3D::set_flip_h(bool p_flip) {
hflip = p_flip;
- _queue_update();
+ _queue_redraw();
}
bool SpriteBase3D::is_flipped_h() const {
@@ -117,7 +116,7 @@ bool SpriteBase3D::is_flipped_h() const {
void SpriteBase3D::set_flip_v(bool p_flip) {
vflip = p_flip;
- _queue_update();
+ _queue_redraw();
}
bool SpriteBase3D::is_flipped_v() const {
@@ -127,7 +126,7 @@ bool SpriteBase3D::is_flipped_v() const {
void SpriteBase3D::set_modulate(const Color &p_color) {
modulate = p_color;
_propagate_color_changed();
- _queue_update();
+ _queue_redraw();
}
Color SpriteBase3D::get_modulate() const {
@@ -137,7 +136,7 @@ Color SpriteBase3D::get_modulate() const {
void SpriteBase3D::set_render_priority(int p_priority) {
ERR_FAIL_COND(p_priority < RS::MATERIAL_RENDER_PRIORITY_MIN || p_priority > RS::MATERIAL_RENDER_PRIORITY_MAX);
render_priority = p_priority;
- _queue_update();
+ _queue_redraw();
}
int SpriteBase3D::get_render_priority() const {
@@ -146,7 +145,7 @@ int SpriteBase3D::get_render_priority() const {
void SpriteBase3D::set_pixel_size(real_t p_amount) {
pixel_size = p_amount;
- _queue_update();
+ _queue_redraw();
}
real_t SpriteBase3D::get_pixel_size() const {
@@ -156,7 +155,7 @@ real_t SpriteBase3D::get_pixel_size() const {
void SpriteBase3D::set_axis(Vector3::Axis p_axis) {
ERR_FAIL_INDEX(p_axis, 3);
axis = p_axis;
- _queue_update();
+ _queue_redraw();
}
Vector3::Axis SpriteBase3D::get_axis() const {
@@ -171,7 +170,8 @@ void SpriteBase3D::_im_update() {
//texture->draw_rect_region(ci,dst_rect,src_rect,modulate);
}
-void SpriteBase3D::_queue_update() {
+void SpriteBase3D::_queue_redraw() {
+ // The 3D equivalent of CanvasItem.queue_redraw().
if (pending_update) {
return;
}
@@ -250,7 +250,7 @@ Ref<TriangleMesh> SpriteBase3D::generate_triangle_mesh() const {
void SpriteBase3D::set_draw_flag(DrawFlags p_flag, bool p_enable) {
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
flags[p_flag] = p_enable;
- _queue_update();
+ _queue_redraw();
}
bool SpriteBase3D::get_draw_flag(DrawFlags p_flag) const {
@@ -261,7 +261,7 @@ bool SpriteBase3D::get_draw_flag(DrawFlags p_flag) const {
void SpriteBase3D::set_alpha_cut_mode(AlphaCutMode p_mode) {
ERR_FAIL_INDEX(p_mode, 3);
alpha_cut = p_mode;
- _queue_update();
+ _queue_redraw();
}
SpriteBase3D::AlphaCutMode SpriteBase3D::get_alpha_cut_mode() const {
@@ -269,9 +269,9 @@ SpriteBase3D::AlphaCutMode SpriteBase3D::get_alpha_cut_mode() const {
}
void SpriteBase3D::set_billboard_mode(StandardMaterial3D::BillboardMode p_mode) {
- ERR_FAIL_INDEX(p_mode, 3);
+ ERR_FAIL_INDEX(p_mode, 3); // Cannot use BILLBOARD_PARTICLES.
billboard_mode = p_mode;
- _queue_update();
+ _queue_redraw();
}
StandardMaterial3D::BillboardMode SpriteBase3D::get_billboard_mode() const {
@@ -281,7 +281,7 @@ StandardMaterial3D::BillboardMode SpriteBase3D::get_billboard_mode() const {
void SpriteBase3D::set_texture_filter(StandardMaterial3D::TextureFilter p_filter) {
if (texture_filter != p_filter) {
texture_filter = p_filter;
- _queue_update();
+ _queue_redraw();
}
}
@@ -329,7 +329,6 @@ void SpriteBase3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_item_rect"), &SpriteBase3D::get_item_rect);
ClassDB::bind_method(D_METHOD("generate_triangle_mesh"), &SpriteBase3D::generate_triangle_mesh);
- ClassDB::bind_method(D_METHOD("_queue_update"), &SpriteBase3D::_queue_update);
ClassDB::bind_method(D_METHOD("_im_update"), &SpriteBase3D::_im_update);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "centered"), "set_centered", "is_centered");
@@ -368,7 +367,7 @@ SpriteBase3D::SpriteBase3D() {
}
material = RenderingServer::get_singleton()->material_create();
- // Set defaults for material, names need to match up those in StandardMaterial3D
+ // Set defaults for material, names need to match up those in StandardMaterial3D.
RS::get_singleton()->material_set_param(material, "albedo", Color(1, 1, 1, 1));
RS::get_singleton()->material_set_param(material, "specular", 0.5);
RS::get_singleton()->material_set_param(material, "metallic", 0.0);
@@ -394,7 +393,7 @@ SpriteBase3D::SpriteBase3D() {
mesh_colors.resize(4);
mesh_uvs.resize(4);
- // create basic mesh and store format information
+ // Create basic mesh and store format information.
for (int i = 0; i < 4; i++) {
mesh_normals.write[i] = Vector3(0.0, 0.0, 0.0);
mesh_tangents.write[i * 4 + 0] = 0.0;
@@ -554,7 +553,7 @@ void Sprite3D::_draw() {
AABB aabb;
- // Everything except position and UV is compressed
+ // Everything except position and UV is compressed.
uint8_t *vertex_write_buffer = vertex_buffer.ptrw();
uint8_t *attribute_write_buffer = attribute_buffer.ptrw();
@@ -637,13 +636,14 @@ void Sprite3D::set_texture(const Ref<Texture2D> &p_texture) {
return;
}
if (texture.is_valid()) {
- texture->disconnect(CoreStringNames::get_singleton()->changed, Callable(this, "_queue_update"));
+ texture->disconnect(SceneStringNames::get_singleton()->changed, callable_mp((SpriteBase3D *)this, &Sprite3D::_queue_redraw));
}
texture = p_texture;
if (texture.is_valid()) {
- texture->connect(CoreStringNames::get_singleton()->changed, Callable(this, "_queue_update"));
+ texture->connect(SceneStringNames::get_singleton()->changed, callable_mp((SpriteBase3D *)this, &Sprite3D::_queue_redraw));
}
- _queue_update();
+
+ _queue_redraw();
emit_signal(SceneStringNames::get_singleton()->texture_changed);
}
@@ -657,7 +657,7 @@ void Sprite3D::set_region_enabled(bool p_region) {
}
region = p_region;
- _queue_update();
+ _queue_redraw();
}
bool Sprite3D::is_region_enabled() const {
@@ -668,7 +668,7 @@ void Sprite3D::set_region_rect(const Rect2 &p_region_rect) {
bool changed = region_rect != p_region_rect;
region_rect = p_region_rect;
if (region && changed) {
- _queue_update();
+ _queue_redraw();
}
}
@@ -681,7 +681,7 @@ void Sprite3D::set_frame(int p_frame) {
frame = p_frame;
- _queue_update();
+ _queue_redraw();
emit_signal(SceneStringNames::get_singleton()->frame_changed);
}
@@ -704,7 +704,7 @@ Vector2i Sprite3D::get_frame_coords() const {
void Sprite3D::set_vframes(int p_amount) {
ERR_FAIL_COND(p_amount < 1);
vframes = p_amount;
- _queue_update();
+ _queue_redraw();
notify_property_list_changed();
}
@@ -715,7 +715,7 @@ int Sprite3D::get_vframes() const {
void Sprite3D::set_hframes(int p_amount) {
ERR_FAIL_COND(p_amount < 1);
hframes = p_amount;
- _queue_update();
+ _queue_redraw();
notify_property_list_changed();
}
@@ -820,9 +820,9 @@ void AnimatedSprite3D::_draw() {
}
Ref<Texture2D> texture = frames->get_frame(animation, frame);
- if (!texture.is_valid()) {
+ if (texture.is_null()) {
set_base(RID());
- return; //no texuture no life
+ return;
}
Size2 tsize = texture->get_size();
if (tsize.x == 0 || tsize.y == 0) {
@@ -917,7 +917,7 @@ void AnimatedSprite3D::_draw() {
AABB aabb;
- // Everything except position and UV is compressed
+ // Everything except position and UV is compressed.
uint8_t *vertex_write_buffer = vertex_buffer.ptrw();
uint8_t *attribute_write_buffer = attribute_buffer.ptrw();
@@ -997,6 +997,7 @@ void AnimatedSprite3D::_validate_property(PropertyInfo &p_property) const {
if (!frames.is_valid()) {
return;
}
+
if (p_property.name == "animation") {
p_property.hint = PROPERTY_HINT_ENUM;
List<StringName> names;
@@ -1026,9 +1027,15 @@ void AnimatedSprite3D::_validate_property(PropertyInfo &p_property) const {
p_property.hint_string = String(animation) + "," + p_property.hint_string;
}
}
+ return;
}
if (p_property.name == "frame") {
+ if (playing) {
+ p_property.usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_READ_ONLY;
+ return;
+ }
+
p_property.hint = PROPERTY_HINT_RANGE;
if (frames->has_animation(animation) && frames->get_frame_count(animation) > 0) {
p_property.hint_string = "0," + itos(frames->get_frame_count(animation) - 1) + ",1";
@@ -1056,27 +1063,51 @@ void AnimatedSprite3D::_notification(int p_what) {
double remaining = get_process_delta_time();
while (remaining) {
- double speed = frames->get_animation_speed(animation);
+ double speed = frames->get_animation_speed(animation) * speed_scale;
if (speed == 0) {
return; // Do nothing.
}
if (timeout <= 0) {
- timeout = 1.0 / speed;
-
- int fc = frames->get_frame_count(animation);
- if (frame >= fc - 1) {
- if (frames->get_animation_loop(animation)) {
- frame = 0;
+ timeout = _get_frame_duration();
+
+ int last_frame = frames->get_frame_count(animation) - 1;
+ if (!backwards) {
+ // Forward.
+ if (frame >= last_frame) {
+ if (frames->get_animation_loop(animation)) {
+ frame = 0;
+ emit_signal(SceneStringNames::get_singleton()->animation_finished);
+ } else {
+ frame = last_frame;
+ if (!is_over) {
+ is_over = true;
+ emit_signal(SceneStringNames::get_singleton()->animation_finished);
+ }
+ }
} else {
- frame = fc - 1;
+ frame++;
}
- emit_signal(SceneStringNames::get_singleton()->animation_finished);
} else {
- frame++;
+ // Reversed.
+ if (frame <= 0) {
+ if (frames->get_animation_loop(animation)) {
+ frame = last_frame;
+ emit_signal(SceneStringNames::get_singleton()->animation_finished);
+ } else {
+ frame = 0;
+ if (!is_over) {
+ is_over = true;
+ emit_signal(SceneStringNames::get_singleton()->animation_finished);
+ }
+ }
+ } else {
+ frame--;
+ }
}
- _queue_update();
+ _queue_redraw();
+
emit_signal(SceneStringNames::get_singleton()->frame_changed);
}
@@ -1090,14 +1121,15 @@ void AnimatedSprite3D::_notification(int p_what) {
void AnimatedSprite3D::set_sprite_frames(const Ref<SpriteFrames> &p_frames) {
if (frames.is_valid()) {
- frames->disconnect("changed", Callable(this, "_res_changed"));
+ frames->disconnect(SceneStringNames::get_singleton()->changed, callable_mp(this, &AnimatedSprite3D::_res_changed));
}
+
frames = p_frames;
if (frames.is_valid()) {
- frames->connect("changed", Callable(this, "_res_changed"));
+ frames->connect(SceneStringNames::get_singleton()->changed, callable_mp(this, &AnimatedSprite3D::_res_changed));
}
- if (!frames.is_valid()) {
+ if (frames.is_null()) {
frame = 0;
} else {
set_frame(frame);
@@ -1105,7 +1137,7 @@ void AnimatedSprite3D::set_sprite_frames(const Ref<SpriteFrames> &p_frames) {
notify_property_list_changed();
_reset_timeout();
- _queue_update();
+ _queue_redraw();
update_configuration_warnings();
}
@@ -1114,7 +1146,7 @@ Ref<SpriteFrames> AnimatedSprite3D::get_sprite_frames() const {
}
void AnimatedSprite3D::set_frame(int p_frame) {
- if (!frames.is_valid()) {
+ if (frames.is_null()) {
return;
}
@@ -1135,7 +1167,8 @@ void AnimatedSprite3D::set_frame(int p_frame) {
frame = p_frame;
_reset_timeout();
- _queue_update();
+ _queue_redraw();
+
emit_signal(SceneStringNames::get_singleton()->frame_changed);
}
@@ -1143,6 +1176,20 @@ int AnimatedSprite3D::get_frame() const {
return frame;
}
+void AnimatedSprite3D::set_speed_scale(double p_speed_scale) {
+ double elapsed = _get_frame_duration() - timeout;
+
+ speed_scale = MAX(p_speed_scale, 0.0f);
+
+ // We adapt the timeout so that the animation speed adapts as soon as the speed scale is changed.
+ _reset_timeout();
+ timeout -= elapsed;
+}
+
+double AnimatedSprite3D::get_speed_scale() const {
+ return speed_scale;
+}
+
Rect2 AnimatedSprite3D::get_item_rect() const {
if (!frames.is_valid() || !frames->has_animation(animation) || frame < 0 || frame >= frames->get_frame_count(animation)) {
return Rect2(0, 0, 1, 1);
@@ -1171,7 +1218,8 @@ Rect2 AnimatedSprite3D::get_item_rect() const {
void AnimatedSprite3D::_res_changed() {
set_frame(frame);
- _queue_update();
+
+ _queue_redraw();
}
void AnimatedSprite3D::set_playing(bool p_playing) {
@@ -1181,16 +1229,24 @@ void AnimatedSprite3D::set_playing(bool p_playing) {
playing = p_playing;
_reset_timeout();
set_process_internal(playing);
+ notify_property_list_changed();
}
bool AnimatedSprite3D::is_playing() const {
return playing;
}
-void AnimatedSprite3D::play(const StringName &p_animation) {
+void AnimatedSprite3D::play(const StringName &p_animation, const bool p_backwards) {
+ backwards = p_backwards;
+
if (p_animation) {
set_animation(p_animation);
+ if (frames.is_valid() && backwards && get_frame() == 0) {
+ set_frame(frames->get_frame_count(p_animation) - 1);
+ }
}
+
+ is_over = false;
set_playing(true);
}
@@ -1198,24 +1254,28 @@ void AnimatedSprite3D::stop() {
set_playing(false);
}
+double AnimatedSprite3D::_get_frame_duration() {
+ if (frames.is_valid() && frames->has_animation(animation)) {
+ double speed = frames->get_animation_speed(animation) * speed_scale;
+ if (speed > 0) {
+ return 1.0 / speed;
+ }
+ }
+ return 0.0;
+}
+
void AnimatedSprite3D::_reset_timeout() {
if (!playing) {
return;
}
- if (frames.is_valid() && frames->has_animation(animation)) {
- float speed = frames->get_animation_speed(animation);
- if (speed > 0) {
- timeout = 1.0 / speed;
- } else {
- timeout = 0;
- }
- } else {
- timeout = 0;
- }
+ timeout = _get_frame_duration();
+ is_over = false;
}
void AnimatedSprite3D::set_animation(const StringName &p_animation) {
+ ERR_FAIL_COND_MSG(frames == nullptr, vformat("There is no animation with name '%s'.", p_animation));
+ ERR_FAIL_COND_MSG(!frames->get_animation_names().has(p_animation), vformat("There is no animation with name '%s'.", p_animation));
if (animation == p_animation) {
return;
}
@@ -1224,7 +1284,7 @@ void AnimatedSprite3D::set_animation(const StringName &p_animation) {
_reset_timeout();
set_frame(0);
notify_property_list_changed();
- _queue_update();
+ _queue_redraw();
}
StringName AnimatedSprite3D::get_animation() const {
@@ -1261,12 +1321,15 @@ void AnimatedSprite3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_playing", "playing"), &AnimatedSprite3D::set_playing);
ClassDB::bind_method(D_METHOD("is_playing"), &AnimatedSprite3D::is_playing);
- ClassDB::bind_method(D_METHOD("play", "anim"), &AnimatedSprite3D::play, DEFVAL(StringName()));
+ ClassDB::bind_method(D_METHOD("play", "anim", "backwards"), &AnimatedSprite3D::play, DEFVAL(StringName()), DEFVAL(false));
ClassDB::bind_method(D_METHOD("stop"), &AnimatedSprite3D::stop);
ClassDB::bind_method(D_METHOD("set_frame", "frame"), &AnimatedSprite3D::set_frame);
ClassDB::bind_method(D_METHOD("get_frame"), &AnimatedSprite3D::get_frame);
+ ClassDB::bind_method(D_METHOD("set_speed_scale", "speed_scale"), &AnimatedSprite3D::set_speed_scale);
+ ClassDB::bind_method(D_METHOD("get_speed_scale"), &AnimatedSprite3D::get_speed_scale);
+
ClassDB::bind_method(D_METHOD("_res_changed"), &AnimatedSprite3D::_res_changed);
ADD_SIGNAL(MethodInfo("frame_changed"));
@@ -1275,6 +1338,7 @@ void AnimatedSprite3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "frames", PROPERTY_HINT_RESOURCE_TYPE, "SpriteFrames"), "set_sprite_frames", "get_sprite_frames");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "animation"), "set_animation", "get_animation");
ADD_PROPERTY(PropertyInfo(Variant::INT, "frame"), "set_frame", "get_frame");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "speed_scale"), "set_speed_scale", "get_speed_scale");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playing"), "set_playing", "is_playing");
}
diff --git a/scene/3d/sprite_3d.h b/scene/3d/sprite_3d.h
index 84244a2476..e6a546a76d 100644
--- a/scene/3d/sprite_3d.h
+++ b/scene/3d/sprite_3d.h
@@ -106,7 +106,7 @@ protected:
uint32_t skin_stride = 0;
uint32_t mesh_surface_format = 0;
- void _queue_update();
+ void _queue_redraw();
public:
void set_centered(bool p_center);
@@ -209,15 +209,19 @@ class AnimatedSprite3D : public SpriteBase3D {
Ref<SpriteFrames> frames;
bool playing = false;
+ bool backwards = false;
StringName animation = "default";
int frame = 0;
+ float speed_scale = 1.0f;
bool centered = false;
+ bool is_over = false;
double timeout = 0.0;
void _res_changed();
+ double _get_frame_duration();
void _reset_timeout();
RID last_shader;
@@ -233,7 +237,7 @@ public:
void set_sprite_frames(const Ref<SpriteFrames> &p_frames);
Ref<SpriteFrames> get_sprite_frames() const;
- void play(const StringName &p_animation = StringName());
+ void play(const StringName &p_animation = StringName(), const bool p_backwards = false);
void stop();
void set_playing(bool p_playing);
@@ -245,6 +249,9 @@ public:
void set_frame(int p_frame);
int get_frame() const;
+ void set_speed_scale(double p_speed_scale);
+ double get_speed_scale() const;
+
virtual Rect2 get_item_rect() const override;
virtual TypedArray<String> get_configuration_warnings() const override;
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 69512903b4..5a0236268b 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -190,6 +190,14 @@ void GraphEditMinimap::_adjust_graph_scroll(const Vector2 &p_offset) {
ge->set_scroll_ofs(p_offset + graph_offset - camera_size / 2);
}
+TypedArray<String> GraphEdit::get_configuration_warnings() const {
+ TypedArray<String> warnings = Control::get_configuration_warnings();
+
+ warnings.push_back(RTR("Please be aware that GraphEdit and GraphNode will undergo extensive refactoring in a future beta version involving compatibility-breaking API changes."));
+
+ return warnings;
+}
+
Error GraphEdit::connect_node(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port) {
if (is_node_connected(p_from, p_from_port, p_to, p_to_port)) {
return OK;
diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h
index 9371ed3df4..0fe9e7c555 100644
--- a/scene/gui/graph_edit.h
+++ b/scene/gui/graph_edit.h
@@ -287,6 +287,8 @@ protected:
GDVIRTUAL4R(bool, _is_node_hover_valid, StringName, int, StringName, int);
public:
+ TypedArray<String> get_configuration_warnings() const override;
+
Error connect_node(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port);
bool is_node_connected(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port);
void disconnect_node(const StringName &p_from, int p_from_port, const StringName &p_to, int p_to_port);
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index c936fe9738..64a0402149 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -1664,7 +1664,7 @@ int RichTextLabel::_find_first_line(int p_from, int p_to, int p_vofs) const {
r = m;
}
}
- return l;
+ return MIN(l, (int)main->lines.size() - 1);
}
_FORCE_INLINE_ float RichTextLabel::_calculate_line_vertical_offset(const RichTextLabel::Line &line) const {
@@ -4364,6 +4364,8 @@ int RichTextLabel::get_visible_paragraph_count() const {
if (!is_visible()) {
return 0;
}
+
+ const_cast<RichTextLabel *>(this)->_validate_line_caches();
return visible_paragraph_count;
}
@@ -4392,6 +4394,8 @@ void RichTextLabel::scroll_to_line(int p_line) {
}
float RichTextLabel::get_line_offset(int p_line) {
+ _validate_line_caches();
+
int line_count = 0;
int to_line = main->first_invalid_line.load();
for (int i = 0; i < to_line; i++) {
@@ -4409,6 +4413,8 @@ float RichTextLabel::get_line_offset(int p_line) {
}
float RichTextLabel::get_paragraph_offset(int p_paragraph) {
+ _validate_line_caches();
+
int to_line = main->first_invalid_line.load();
if (0 <= p_paragraph && p_paragraph < to_line) {
return main->lines[p_paragraph].offset.y;
@@ -4417,6 +4423,8 @@ float RichTextLabel::get_paragraph_offset(int p_paragraph) {
}
int RichTextLabel::get_line_count() const {
+ const_cast<RichTextLabel *>(this)->_validate_line_caches();
+
int line_count = 0;
int to_line = main->first_invalid_line.load();
for (int i = 0; i < to_line; i++) {
@@ -4430,6 +4438,8 @@ int RichTextLabel::get_visible_line_count() const {
if (!is_visible()) {
return 0;
}
+ const_cast<RichTextLabel *>(this)->_validate_line_caches();
+
return visible_line_count;
}
@@ -4844,7 +4854,14 @@ void RichTextLabel::set_use_bbcode(bool p_enable) {
}
use_bbcode = p_enable;
notify_property_list_changed();
- set_text(text);
+
+ const String current_text = text;
+ if (use_bbcode) {
+ parse_bbcode(current_text);
+ } else { // raw text
+ clear();
+ add_text(current_text);
+ }
}
bool RichTextLabel::is_using_bbcode() const {
@@ -5005,7 +5022,12 @@ int RichTextLabel::get_content_height() const {
int to_line = main->first_invalid_line.load();
if (to_line) {
MutexLock lock(main->lines[to_line - 1].text_buf->get_mutex());
- total_height = main->lines[to_line - 1].offset.y + main->lines[to_line - 1].text_buf->get_size().y + main->lines[to_line - 1].text_buf->get_line_count() * theme_cache.line_separation;
+ if (theme_cache.line_separation < 0) {
+ // Do not apply to the last line to avoid cutting text.
+ total_height = main->lines[to_line - 1].offset.y + main->lines[to_line - 1].text_buf->get_size().y + (main->lines[to_line - 1].text_buf->get_line_count() - 1) * theme_cache.line_separation;
+ } else {
+ total_height = main->lines[to_line - 1].offset.y + main->lines[to_line - 1].text_buf->get_size().y + main->lines[to_line - 1].text_buf->get_line_count() * theme_cache.line_separation;
+ }
}
return total_height;
}
@@ -5298,6 +5320,8 @@ int RichTextLabel::get_visible_characters() const {
}
int RichTextLabel::get_character_line(int p_char) {
+ _validate_line_caches();
+
int line_count = 0;
int to_line = main->first_invalid_line.load();
for (int i = 0; i < to_line; i++) {
@@ -5318,6 +5342,8 @@ int RichTextLabel::get_character_line(int p_char) {
}
int RichTextLabel::get_character_paragraph(int p_char) {
+ _validate_line_caches();
+
int para_count = 0;
int to_line = main->first_invalid_line.load();
for (int i = 0; i < to_line; i++) {
@@ -5349,6 +5375,8 @@ int RichTextLabel::get_total_character_count() const {
}
int RichTextLabel::get_total_glyph_count() const {
+ const_cast<RichTextLabel *>(this)->_validate_line_caches();
+
int tg = 0;
Item *it = main;
while (it) {
diff --git a/scene/main/node.h b/scene/main/node.h
index 39225b1358..13a938ef97 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -529,4 +529,8 @@ Error Node::rpc_id(int p_peer_id, const StringName &p_method, VarArgs... p_args)
return rpcp(p_peer_id, p_method, sizeof...(p_args) == 0 ? nullptr : (const Variant **)argptrs, sizeof...(p_args));
}
+// Add these macro to your class's 'get_configuration_warnings' function to have warnings show up in the scene tree inspector.
+#define DEPRECATED_NODE_WARNING warnings.push_back(RTR("This node is marked as deprecated and will be removed in future versions.\nPlease check the Godot documentation for information about migration."));
+#define EXPERIMENTAL_NODE_WARNING warnings.push_back(RTR("This node is marked as experimental and may be subject to removal or major changes in future versions."));
+
#endif // NODE_H
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp
index 189d8d5502..3d9e4e4a63 100644
--- a/scene/resources/font.cpp
+++ b/scene/resources/font.cpp
@@ -554,7 +554,6 @@ Font::Font() {
}
Font::~Font() {
- reset_state();
}
/*************************************************************************/
@@ -2433,11 +2432,10 @@ int32_t FontFile::get_glyph_index(int p_size, char32_t p_char, char32_t p_variat
}
FontFile::FontFile() {
- /* NOP */
}
FontFile::~FontFile() {
- reset_state();
+ _clear_cache();
}
/*************************************************************************/
@@ -2688,7 +2686,6 @@ FontVariation::FontVariation() {
}
FontVariation::~FontVariation() {
- reset_state();
}
/*************************************************************************/
@@ -3081,5 +3078,4 @@ SystemFont::SystemFont() {
}
SystemFont::~SystemFont() {
- reset_state();
}
diff --git a/scene/resources/importer_mesh.cpp b/scene/resources/importer_mesh.cpp
index 0afca95de0..de3d502102 100644
--- a/scene/resources/importer_mesh.cpp
+++ b/scene/resources/importer_mesh.cpp
@@ -254,7 +254,20 @@ void ImporterMesh::set_surface_material(int p_surface, const Ref<Material> &p_ma
mesh.unref();
}
-void ImporterMesh::generate_lods(float p_normal_merge_angle, float p_normal_split_angle) {
+#define VERTEX_SKIN_FUNC(bone_count, vert_idx, read_array, write_array, transform_array, bone_array, weight_array) \
+ Vector3 transformed_vert = Vector3(); \
+ for (unsigned int weight_idx = 0; weight_idx < bone_count; weight_idx++) { \
+ int bone_idx = bone_array[vert_idx * bone_count + weight_idx]; \
+ float w = weight_array[vert_idx * bone_count + weight_idx]; \
+ if (w < FLT_EPSILON) { \
+ continue; \
+ } \
+ ERR_FAIL_INDEX(bone_idx, static_cast<int>(transform_array.size())); \
+ transformed_vert += transform_array[bone_idx].xform(read_array[vert_idx]) * w; \
+ } \
+ write_array[vert_idx] = transformed_vert;
+
+void ImporterMesh::generate_lods(float p_normal_merge_angle, float p_normal_split_angle, Array p_bone_transform_array) {
if (!SurfaceTool::simplify_scale_func) {
return;
}
@@ -265,6 +278,12 @@ void ImporterMesh::generate_lods(float p_normal_merge_angle, float p_normal_spli
return;
}
+ LocalVector<Transform3D> bone_transform_vector;
+ for (int i = 0; i < p_bone_transform_array.size(); i++) {
+ ERR_FAIL_COND(p_bone_transform_array[i].get_type() != Variant::TRANSFORM3D);
+ bone_transform_vector.push_back(p_bone_transform_array[i]);
+ }
+
for (int i = 0; i < surfaces.size(); i++) {
if (surfaces[i].primitive != Mesh::PRIMITIVE_TRIANGLES) {
continue;
@@ -276,6 +295,8 @@ void ImporterMesh::generate_lods(float p_normal_merge_angle, float p_normal_spli
Vector<Vector3> normals = surfaces[i].arrays[RS::ARRAY_NORMAL];
Vector<Vector2> uvs = surfaces[i].arrays[RS::ARRAY_TEX_UV];
Vector<Vector2> uv2s = surfaces[i].arrays[RS::ARRAY_TEX_UV2];
+ Vector<int> bones = surfaces[i].arrays[RS::ARRAY_BONES];
+ Vector<float> weights = surfaces[i].arrays[RS::ARRAY_WEIGHTS];
unsigned int index_count = indices.size();
unsigned int vertex_count = vertices.size();
@@ -301,6 +322,22 @@ void ImporterMesh::generate_lods(float p_normal_merge_angle, float p_normal_spli
}
}
+ if (bones.size() > 0 && weights.size() && bone_transform_vector.size() > 0) {
+ Vector3 *vertices_ptrw = vertices.ptrw();
+
+ // Apply bone transforms to regular surface.
+ unsigned int bone_weight_length = surfaces[i].flags & Mesh::ARRAY_FLAG_USE_8_BONE_WEIGHTS ? 8 : 4;
+
+ const int *bo = bones.ptr();
+ const float *we = weights.ptr();
+
+ for (unsigned int j = 0; j < vertex_count; j++) {
+ VERTEX_SKIN_FUNC(bone_weight_length, j, vertices_ptr, vertices_ptrw, bone_transform_vector, bo, we)
+ }
+
+ vertices_ptr = vertices.ptr();
+ }
+
float normal_merge_threshold = Math::cos(Math::deg_to_rad(p_normal_merge_angle));
float normal_pre_split_threshold = Math::cos(Math::deg_to_rad(MIN(180.0f, p_normal_split_angle * 2.0f)));
float normal_split_threshold = Math::cos(Math::deg_to_rad(p_normal_split_angle));
@@ -1246,7 +1283,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("generate_lods", "normal_merge_angle", "normal_split_angle", "bone_transform_array"), &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/importer_mesh.h b/scene/resources/importer_mesh.h
index dce2638c19..088a77edd1 100644
--- a/scene/resources/importer_mesh.h
+++ b/scene/resources/importer_mesh.h
@@ -112,7 +112,7 @@ public:
void set_surface_material(int p_surface, const Ref<Material> &p_material);
- void generate_lods(float p_normal_merge_angle, float p_normal_split_angle);
+ void generate_lods(float p_normal_merge_angle, float p_normal_split_angle, Array p_skin_pose_transform_array);
void create_shadow_mesh();
Ref<ImporterMesh> get_shadow_mesh() const;
diff --git a/scene/resources/sky_material.cpp b/scene/resources/sky_material.cpp
index fc999d5fcb..d21f04fab8 100644
--- a/scene/resources/sky_material.cpp
+++ b/scene/resources/sky_material.cpp
@@ -34,7 +34,7 @@
#include "core/version.h"
Mutex ProceduralSkyMaterial::shader_mutex;
-RID ProceduralSkyMaterial::shader;
+RID ProceduralSkyMaterial::shader_cache[2];
void ProceduralSkyMaterial::set_sky_top_color(const Color &p_sky_top) {
sky_top_color = p_sky_top;
@@ -147,7 +147,11 @@ float ProceduralSkyMaterial::get_sun_curve() const {
void ProceduralSkyMaterial::set_use_debanding(bool p_use_debanding) {
use_debanding = p_use_debanding;
- RS::get_singleton()->material_set_param(_get_material(), "use_debanding", use_debanding);
+ _update_shader();
+ // Only set if shader already compiled
+ if (shader_set) {
+ RS::get_singleton()->material_set_shader(_get_material(), shader_cache[int(use_debanding)]);
+ }
}
bool ProceduralSkyMaterial::get_use_debanding() const {
@@ -161,7 +165,8 @@ Shader::Mode ProceduralSkyMaterial::get_shader_mode() const {
RID ProceduralSkyMaterial::get_rid() const {
_update_shader();
if (!shader_set) {
- RS::get_singleton()->material_set_shader(_get_material(), shader);
+ RS::get_singleton()->material_set_shader(_get_material(), shader_cache[1 - int(use_debanding)]);
+ RS::get_singleton()->material_set_shader(_get_material(), shader_cache[int(use_debanding)]);
shader_set = true;
}
return _get_material();
@@ -169,7 +174,7 @@ RID ProceduralSkyMaterial::get_rid() const {
RID ProceduralSkyMaterial::get_shader_rid() const {
_update_shader();
- return shader;
+ return shader_cache[int(use_debanding)];
}
void ProceduralSkyMaterial::_validate_property(PropertyInfo &p_property) const {
@@ -241,21 +246,24 @@ void ProceduralSkyMaterial::_bind_methods() {
}
void ProceduralSkyMaterial::cleanup_shader() {
- if (shader.is_valid()) {
- RS::get_singleton()->free(shader);
+ if (shader_cache[0].is_valid()) {
+ RS::get_singleton()->free(shader_cache[0]);
+ RS::get_singleton()->free(shader_cache[1]);
}
}
void ProceduralSkyMaterial::_update_shader() {
shader_mutex.lock();
- if (shader.is_null()) {
- shader = RS::get_singleton()->shader_create();
+ if (shader_cache[0].is_null()) {
+ for (int i = 0; i < 2; i++) {
+ shader_cache[i] = RS::get_singleton()->shader_create();
- // Add a comment to describe the shader origin (useful when converting to ShaderMaterial).
- RS::get_singleton()->shader_set_code(shader, R"(
+ // Add a comment to describe the shader origin (useful when converting to ShaderMaterial).
+ RS::get_singleton()->shader_set_code(shader_cache[i], vformat(R"(
// NOTE: Shader automatically converted from )" VERSION_NAME " " VERSION_FULL_CONFIG R"('s ProceduralSkyMaterial.
shader_type sky;
+%s
uniform vec4 sky_top_color : source_color = vec4(0.385, 0.454, 0.55, 1.0);
uniform vec4 sky_horizon_color : source_color = vec4(0.646, 0.656, 0.67, 1.0);
@@ -269,14 +277,6 @@ uniform float ground_curve : hint_range(0, 1) = 0.02;
uniform float ground_energy = 1.0;
uniform float sun_angle_max = 30.0;
uniform float sun_curve : hint_range(0, 1) = 0.15;
-uniform bool use_debanding = true;
-
-// https://www.iryoku.com/next-generation-post-processing-in-call-of-duty-advanced-warfare
-vec3 interleaved_gradient_noise(vec2 pos) {
- const vec3 magic = vec3(0.06711056f, 0.00583715f, 52.9829189f);
- float res = fract(magic.z * fract(dot(pos, magic.xy))) * 2.0 - 1.0;
- return vec3(res, -res, res) / 255.0;
-}
void sky() {
float v_angle = acos(clamp(EYEDIR.y, -1.0, 1.0));
@@ -332,11 +332,10 @@ void sky() {
ground *= ground_energy;
COLOR = mix(ground, sky, step(0.0, EYEDIR.y));
- if (use_debanding) {
- COLOR += interleaved_gradient_noise(FRAGCOORD.xy);
- }
}
-)");
+)",
+ i ? "render_mode use_debanding;" : ""));
+ }
}
shader_mutex.unlock();
}
@@ -546,7 +545,11 @@ float PhysicalSkyMaterial::get_energy_multiplier() const {
void PhysicalSkyMaterial::set_use_debanding(bool p_use_debanding) {
use_debanding = p_use_debanding;
- RS::get_singleton()->material_set_param(_get_material(), "use_debanding", use_debanding);
+ _update_shader();
+ // Only set if shader already compiled
+ if (shader_set) {
+ RS::get_singleton()->material_set_shader(_get_material(), shader_cache[int(use_debanding)]);
+ }
}
bool PhysicalSkyMaterial::get_use_debanding() const {
@@ -570,7 +573,8 @@ Shader::Mode PhysicalSkyMaterial::get_shader_mode() const {
RID PhysicalSkyMaterial::get_rid() const {
_update_shader();
if (!shader_set) {
- RS::get_singleton()->material_set_shader(_get_material(), shader);
+ RS::get_singleton()->material_set_shader(_get_material(), shader_cache[1 - int(use_debanding)]);
+ RS::get_singleton()->material_set_shader(_get_material(), shader_cache[int(use_debanding)]);
shader_set = true;
}
return _get_material();
@@ -578,7 +582,7 @@ RID PhysicalSkyMaterial::get_rid() const {
RID PhysicalSkyMaterial::get_shader_rid() const {
_update_shader();
- return shader;
+ return shader_cache[int(use_debanding)];
}
void PhysicalSkyMaterial::_validate_property(PropertyInfo &p_property) const {
@@ -588,7 +592,7 @@ void PhysicalSkyMaterial::_validate_property(PropertyInfo &p_property) const {
}
Mutex PhysicalSkyMaterial::shader_mutex;
-RID PhysicalSkyMaterial::shader;
+RID PhysicalSkyMaterial::shader_cache[2];
void PhysicalSkyMaterial::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_rayleigh_coefficient", "rayleigh"), &PhysicalSkyMaterial::set_rayleigh_coefficient);
@@ -642,21 +646,24 @@ void PhysicalSkyMaterial::_bind_methods() {
}
void PhysicalSkyMaterial::cleanup_shader() {
- if (shader.is_valid()) {
- RS::get_singleton()->free(shader);
+ if (shader_cache[0].is_valid()) {
+ RS::get_singleton()->free(shader_cache[0]);
+ RS::get_singleton()->free(shader_cache[1]);
}
}
void PhysicalSkyMaterial::_update_shader() {
shader_mutex.lock();
- if (shader.is_null()) {
- shader = RS::get_singleton()->shader_create();
+ if (shader_cache[0].is_null()) {
+ for (int i = 0; i < 2; i++) {
+ shader_cache[i] = RS::get_singleton()->shader_create();
- // Add a comment to describe the shader origin (useful when converting to ShaderMaterial).
- RS::get_singleton()->shader_set_code(shader, R"(
+ // Add a comment to describe the shader origin (useful when converting to ShaderMaterial).
+ RS::get_singleton()->shader_set_code(shader_cache[i], vformat(R"(
// NOTE: Shader automatically converted from )" VERSION_NAME " " VERSION_FULL_CONFIG R"('s PhysicalSkyMaterial.
shader_type sky;
+%s
uniform float rayleigh : hint_range(0, 64) = 2.0;
uniform vec4 rayleigh_color : source_color = vec4(0.3, 0.405, 0.6, 1.0);
@@ -668,7 +675,6 @@ uniform float turbidity : hint_range(0, 1000) = 10.0;
uniform float sun_disk_scale : hint_range(0, 360) = 1.0;
uniform vec4 ground_color : source_color = vec4(0.1, 0.07, 0.034, 1.0);
uniform float exposure : hint_range(0, 128) = 1.0;
-uniform bool use_debanding = true;
uniform sampler2D night_sky : source_color, hint_default_black;
@@ -683,13 +689,6 @@ float henyey_greenstein(float cos_theta, float g) {
return k * (1.0 - g * g) / (pow(1.0 + g * g - 2.0 * g * cos_theta, 1.5));
}
-// https://www.iryoku.com/next-generation-post-processing-in-call-of-duty-advanced-warfare
-vec3 interleaved_gradient_noise(vec2 pos) {
- const vec3 magic = vec3(0.06711056f, 0.00583715f, 52.9829189f);
- float res = fract(magic.z * fract(dot(pos, magic.xy))) * 2.0 - 1.0;
- return vec3(res, -res, res) / 255.0;
-}
-
void sky() {
if (LIGHT0_ENABLED) {
float zenith_angle = clamp( dot(UP, normalize(LIGHT0_DIRECTION)), -1.0, 1.0 );
@@ -737,16 +736,15 @@ void sky() {
vec3 color = Lin + L0;
COLOR = pow(color, vec3(1.0 / (1.2 + (1.2 * sun_fade))));
COLOR *= exposure;
- if (use_debanding) {
- COLOR += interleaved_gradient_noise(FRAGCOORD.xy);
- }
} else {
// There is no sun, so display night_sky and nothing else.
COLOR = texture(night_sky, SKY_COORDS).xyz;
COLOR *= exposure;
}
}
-)");
+)",
+ i ? "render_mode use_debanding;" : ""));
+ }
}
shader_mutex.unlock();
diff --git a/scene/resources/sky_material.h b/scene/resources/sky_material.h
index b517fd806b..fbb202d8d8 100644
--- a/scene/resources/sky_material.h
+++ b/scene/resources/sky_material.h
@@ -55,7 +55,7 @@ private:
bool use_debanding = true;
static Mutex shader_mutex;
- static RID shader;
+ static RID shader_cache[2];
static void _update_shader();
mutable bool shader_set = false;
@@ -160,7 +160,7 @@ class PhysicalSkyMaterial : public Material {
private:
static Mutex shader_mutex;
- static RID shader;
+ static RID shader_cache[2];
float rayleigh = 0.0f;
Color rayleigh_color;
diff --git a/servers/rendering/renderer_rd/effects/ss_effects.cpp b/servers/rendering/renderer_rd/effects/ss_effects.cpp
index 315bea2e67..582c5abbdd 100644
--- a/servers/rendering/renderer_rd/effects/ss_effects.cpp
+++ b/servers/rendering/renderer_rd/effects/ss_effects.cpp
@@ -443,6 +443,11 @@ void SSEffects::downsample_depth(RID p_depth_buffer, const Vector<RID> &p_depth_
RD::get_singleton()->draw_command_begin_label("Downsample Depth");
if (p_invalidate_uniform_set || use_full_mips != ss_effects.used_full_mips_last_frame || use_half_size != ss_effects.used_half_size_last_frame || use_mips != ss_effects.used_mips_last_frame) {
+ if (ss_effects.downsample_uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(ss_effects.downsample_uniform_set)) {
+ RD::get_singleton()->free(ss_effects.downsample_uniform_set);
+ ss_effects.downsample_uniform_set = RID();
+ }
+
Vector<RD::Uniform> uniforms;
{
RD::Uniform u;
@@ -516,6 +521,7 @@ void SSEffects::downsample_depth(RID p_depth_buffer, const Vector<RID> &p_depth_
ss_effects.used_full_mips_last_frame = use_full_mips;
ss_effects.used_half_size_last_frame = use_half_size;
+ ss_effects.used_mips_last_frame = use_mips;
}
/* SSIL */
@@ -1484,7 +1490,7 @@ void SSEffects::ssr_allocate_buffers(SSRRenderBuffers &p_ssr_buffers, const Rend
}
}
-void SSEffects::screen_space_reflection(SSRRenderBuffers &p_ssr_buffers, const RID *p_diffuse_slices, const RID *p_normal_roughness_slices, RenderingServer::EnvironmentSSRRoughnessQuality p_roughness_quality, const RID *p_metallic_slices, const Color &p_metallic_mask, const RID *p_depth_slices, const Size2i &p_screen_size, int p_max_steps, float p_fade_in, float p_fade_out, float p_tolerance, const uint32_t p_view_count, const Projection *p_projections, const Vector3 *p_eye_offsets) {
+void SSEffects::screen_space_reflection(SSRRenderBuffers &p_ssr_buffers, const RID *p_diffuse_slices, const RID *p_normal_roughness_slices, RenderingServer::EnvironmentSSRRoughnessQuality p_roughness_quality, const RID *p_metallic_slices, const RID *p_depth_slices, const Size2i &p_screen_size, int p_max_steps, float p_fade_in, float p_fade_out, float p_tolerance, const uint32_t p_view_count, const Projection *p_projections, const Vector3 *p_eye_offsets) {
UniformSetCacheRD *uniform_set_cache = UniformSetCacheRD::get_singleton();
ERR_FAIL_NULL(uniform_set_cache);
MaterialStorage *material_storage = MaterialStorage::get_singleton();
@@ -1579,10 +1585,6 @@ void SSEffects::screen_space_reflection(SSRRenderBuffers &p_ssr_buffers, const R
push_constant.proj_info[1] = -2.0f / (p_screen_size.height * p_projections[v].matrix[1][1]);
push_constant.proj_info[2] = (1.0f - p_projections[v].matrix[0][2]) / p_projections[v].matrix[0][0];
push_constant.proj_info[3] = (1.0f + p_projections[v].matrix[1][2]) / p_projections[v].matrix[1][1];
- push_constant.metallic_mask[0] = CLAMP(p_metallic_mask.r * 255.0, 0, 255);
- push_constant.metallic_mask[1] = CLAMP(p_metallic_mask.g * 255.0, 0, 255);
- push_constant.metallic_mask[2] = CLAMP(p_metallic_mask.b * 255.0, 0, 255);
- push_constant.metallic_mask[3] = CLAMP(p_metallic_mask.a * 255.0, 0, 255);
ScreenSpaceReflectionMode mode = (p_roughness_quality != RS::ENV_SSR_ROUGHNESS_QUALITY_DISABLED) ? SCREEN_SPACE_REFLECTION_ROUGH : SCREEN_SPACE_REFLECTION_NORMAL;
RID shader = ssr.shader.version_get_shader(ssr.shader_version, mode);
diff --git a/servers/rendering/renderer_rd/effects/ss_effects.h b/servers/rendering/renderer_rd/effects/ss_effects.h
index a60f3a48ab..d50319c46f 100644
--- a/servers/rendering/renderer_rd/effects/ss_effects.h
+++ b/servers/rendering/renderer_rd/effects/ss_effects.h
@@ -168,7 +168,7 @@ public:
};
void ssr_allocate_buffers(SSRRenderBuffers &p_ssr_buffers, const RenderingDevice::DataFormat p_color_format, RenderingServer::EnvironmentSSRRoughnessQuality p_roughness_quality, const Size2i &p_screen_size, const uint32_t p_view_count);
- void screen_space_reflection(SSRRenderBuffers &p_ssr_buffers, const RID *p_diffuse_slices, const RID *p_normal_roughness_slices, RS::EnvironmentSSRRoughnessQuality p_roughness_quality, const RID *p_metallic_slices, const Color &p_metallic_mask, const RID *p_depth_slices, const Size2i &p_screen_size, int p_max_steps, float p_fade_in, float p_fade_out, float p_tolerance, const uint32_t p_view_count, const Projection *p_projections, const Vector3 *p_eye_offsets);
+ void screen_space_reflection(SSRRenderBuffers &p_ssr_buffers, const RID *p_diffuse_slices, const RID *p_normal_roughness_slices, RS::EnvironmentSSRRoughnessQuality p_roughness_quality, const RID *p_metallic_slices, const RID *p_depth_slices, const Size2i &p_screen_size, int p_max_steps, float p_fade_in, float p_fade_out, float p_tolerance, const uint32_t p_view_count, const Projection *p_projections, const Vector3 *p_eye_offsets);
void ssr_free(SSRRenderBuffers &p_ssr_buffers);
/* subsurface scattering */
@@ -465,10 +465,7 @@ private:
uint32_t orthogonal; // 4 - 52
float filter_mipmap_levels; // 4 - 56
uint32_t use_half_res; // 4 - 60
- uint8_t metallic_mask[4]; // 4 - 64
-
- uint32_t view_index; // 4 - 68
- uint32_t pad[3]; // 12 - 80
+ uint32_t view_index; // 4 - 64
// float projection[16]; // this is in our ScreenSpaceReflectionSceneData now
};
diff --git a/servers/rendering/renderer_rd/environment/sky.cpp b/servers/rendering/renderer_rd/environment/sky.cpp
index 65d1d9e705..307af99e91 100644
--- a/servers/rendering/renderer_rd/environment/sky.cpp
+++ b/servers/rendering/renderer_rd/environment/sky.cpp
@@ -907,6 +907,7 @@ void SkyRD::init() {
actions.usage_defines["HALF_RES_COLOR"] = "\n#define USES_HALF_RES_COLOR\n";
actions.usage_defines["QUARTER_RES_COLOR"] = "\n#define USES_QUARTER_RES_COLOR\n";
actions.render_mode_defines["disable_fog"] = "#define DISABLE_FOG\n";
+ actions.render_mode_defines["use_debanding"] = "#define USE_DEBANDING\n";
actions.sampler_array_name = "material_samplers";
actions.base_texture_binding_index = 1;
@@ -1260,6 +1261,7 @@ void SkyRD::setup(RID p_env, Ref<RenderSceneBuffersRD> p_render_buffers, const P
light_data_dirty = true;
for (uint32_t i = sky_scene_state.ubo.directional_light_count; i < sky_scene_state.max_directional_lights; i++) {
sky_scene_state.directional_lights[i].enabled = false;
+ sky_scene_state.last_frame_directional_lights[i].enabled = false;
}
}
diff --git a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
index a0f6e69fd5..33d7ddd6e8 100644
--- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
+++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
@@ -124,7 +124,7 @@ void RenderForwardClustered::RenderBufferDataForwardClustered::configure(RenderS
render_buffers = p_render_buffers;
ERR_FAIL_NULL(render_buffers);
- bool msaa_3d = render_buffers->get_msaa_3d();
+ RS::ViewportMSAA msaa_3d = render_buffers->get_msaa_3d();
if (msaa_3d != RS::VIEWPORT_MSAA_DISABLED) {
RD::DataFormat format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT;
@@ -477,6 +477,10 @@ void RenderForwardClustered::_render_list_template(RenderingDevice::DrawListID p
prev_material_uniform_set = material_uniform_set;
}
+ if (surf->owner->base_flags & INSTANCE_DATA_FLAG_MULTIMESH) {
+ mesh_storage->_multimesh_get_motion_vectors_offsets(surf->owner->data->base, push_constant.multimesh_motion_vectors_current_offset, push_constant.multimesh_motion_vectors_previous_offset);
+ }
+
RD::get_singleton()->draw_list_set_push_constant(draw_list, &push_constant, sizeof(SceneState::PushConstant));
uint32_t instance_count = surf->owner->instance_count > 1 ? surf->owner->instance_count : element_info.repeat;
@@ -924,7 +928,7 @@ _FORCE_INLINE_ static uint32_t _indices_to_primitives(RS::PrimitiveType p_primit
static const uint32_t subtractor[RS::PRIMITIVE_MAX] = { 0, 0, 1, 0, 1 };
return (p_indices - subtractor[p_primitive]) / divisor[p_primitive];
}
-void RenderForwardClustered::_fill_render_list(RenderListType p_render_list, const RenderDataRD *p_render_data, PassMode p_pass_mode, bool p_using_sdfgi, bool p_using_opaque_gi, bool p_append) {
+void RenderForwardClustered::_fill_render_list(RenderListType p_render_list, const RenderDataRD *p_render_data, PassMode p_pass_mode, uint32_t p_color_pass_flags = 0, bool p_using_sdfgi, bool p_using_opaque_gi, bool p_append) {
RendererRD::MeshStorage *mesh_storage = RendererRD::MeshStorage::get_singleton();
if (p_render_list == RENDER_LIST_OPAQUE) {
@@ -1149,6 +1153,12 @@ void RenderForwardClustered::_fill_render_list(RenderListType p_render_list, con
scene_state.used_depth_texture = true;
}
+ if (p_color_pass_flags & COLOR_PASS_FLAG_MOTION_VECTORS && flags & INSTANCE_DATA_FLAG_MULTIMESH) {
+ if (RendererRD::MeshStorage::get_singleton()->_multimesh_enable_motion_vectors(inst->data->base)) {
+ inst->transforms_uniform_set = mesh_storage->multimesh_get_3d_uniform_set(inst->data->base, scene_shader.default_shader_rd, TRANSFORMS_UNIFORM_SET);
+ }
+ }
+
} else if (p_pass_mode == PASS_MODE_SHADOW || p_pass_mode == PASS_MODE_SHADOW_DP) {
if (surf->flags & GeometryInstanceSurfaceDataCache::FLAG_PASS_SHADOW) {
rl->add_element(surf);
@@ -1322,7 +1332,7 @@ void RenderForwardClustered::_render_scene(RenderDataRD *p_render_data, const Co
_update_render_base_uniform_set(); //may have changed due to the above (light buffer enlarged, as an example)
- _fill_render_list(RENDER_LIST_OPAQUE, p_render_data, PASS_MODE_COLOR, using_sdfgi, using_sdfgi || using_voxelgi);
+ _fill_render_list(RENDER_LIST_OPAQUE, p_render_data, PASS_MODE_COLOR, color_pass_flags, using_sdfgi, using_sdfgi || using_voxelgi);
render_list[RENDER_LIST_OPAQUE].sort_by_key();
render_list[RENDER_LIST_ALPHA].sort_by_reverse_depth_and_priority();
_fill_instance_data(RENDER_LIST_OPAQUE, p_render_data->render_info ? p_render_data->render_info->info[RS::VIEWPORT_RENDER_INFO_TYPE_VISIBLE] : (int *)nullptr);
@@ -1609,7 +1619,7 @@ void RenderForwardClustered::_render_scene(RenderDataRD *p_render_data, const Co
for (uint32_t v = 0; v < p_render_data->view_count; v++) {
specular_views[v] = rb_data->get_specular(v);
}
- _process_ssr(rb, color_only_framebuffer, normal_roughness_views, rb_data->get_specular(), specular_views, Color(0, 0, 0, 1), p_render_data->environment, p_render_data->view_projection, p_render_data->view_eye_offset, rb->get_msaa_3d() == RS::VIEWPORT_MSAA_DISABLED);
+ _process_ssr(rb, color_only_framebuffer, normal_roughness_views, rb_data->get_specular(), specular_views, p_render_data->environment, p_render_data->view_projection, p_render_data->view_eye_offset, rb->get_msaa_3d() == RS::VIEWPORT_MSAA_DISABLED);
RD::get_singleton()->draw_command_end_label();
} else {
//just mix specular back
@@ -1723,7 +1733,7 @@ void RenderForwardClustered::_render_shadow_append(RID p_framebuffer, const Page
PassMode pass_mode = p_use_dp ? PASS_MODE_SHADOW_DP : PASS_MODE_SHADOW;
uint32_t render_list_from = render_list[RENDER_LIST_SECONDARY].elements.size();
- _fill_render_list(RENDER_LIST_SECONDARY, &render_data, pass_mode, false, false, true);
+ _fill_render_list(RENDER_LIST_SECONDARY, &render_data, pass_mode, 0, false, false, true);
uint32_t render_list_size = render_list[RENDER_LIST_SECONDARY].elements.size() - render_list_from;
render_list[RENDER_LIST_SECONDARY].sort_by_key_range(render_list_from, render_list_size);
_fill_instance_data(RENDER_LIST_SECONDARY, p_render_info ? p_render_info->info[RS::VIEWPORT_RENDER_INFO_TYPE_SHADOW] : (int *)nullptr, render_list_from, render_list_size, false);
diff --git a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h
index 35379cd69b..9e2586542a 100644
--- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h
+++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.h
@@ -337,7 +337,8 @@ class RenderForwardClustered : public RendererSceneRenderRD {
struct PushConstant {
uint32_t base_index; //
uint32_t uv_offset; //packed
- uint32_t pad[2];
+ uint32_t multimesh_motion_vectors_current_offset;
+ uint32_t multimesh_motion_vectors_previous_offset;
};
struct InstanceData {
@@ -429,7 +430,7 @@ class RenderForwardClustered : public RendererSceneRenderRD {
void _update_instance_data_buffer(RenderListType p_render_list);
void _fill_instance_data(RenderListType p_render_list, int *p_render_info = nullptr, uint32_t p_offset = 0, int32_t p_max_elements = -1, bool p_update_buffer = true);
- void _fill_render_list(RenderListType p_render_list, const RenderDataRD *p_render_data, PassMode p_pass_mode, bool p_using_sdfgi = false, bool p_using_opaque_gi = false, bool p_append = false);
+ void _fill_render_list(RenderListType p_render_list, const RenderDataRD *p_render_data, PassMode p_pass_mode, uint32_t p_color_pass_flags, bool p_using_sdfgi = false, bool p_using_opaque_gi = false, bool p_append = false);
HashMap<Size2i, RID> sdfgi_framebuffer_size_cache;
diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
index 78c83d1fb4..e2b06bc92f 100644
--- a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp
@@ -1328,7 +1328,7 @@ void RendererSceneRenderRD::_process_sss(Ref<RenderSceneBuffersRD> p_render_buff
}
}
-void RendererSceneRenderRD::_process_ssr(Ref<RenderSceneBuffersRD> p_render_buffers, RID p_dest_framebuffer, const RID *p_normal_slices, RID p_specular_buffer, const RID *p_metallic_slices, const Color &p_metallic_mask, RID p_environment, const Projection *p_projections, const Vector3 *p_eye_offsets, bool p_use_additive) {
+void RendererSceneRenderRD::_process_ssr(Ref<RenderSceneBuffersRD> p_render_buffers, RID p_dest_framebuffer, const RID *p_normal_slices, RID p_specular_buffer, const RID *p_metallic_slices, RID p_environment, const Projection *p_projections, const Vector3 *p_eye_offsets, bool p_use_additive) {
ERR_FAIL_NULL(ss_effects);
ERR_FAIL_COND(p_render_buffers.is_null());
@@ -1355,7 +1355,7 @@ void RendererSceneRenderRD::_process_ssr(Ref<RenderSceneBuffersRD> p_render_buff
texture_slices[v] = p_render_buffers->get_internal_texture(v);
depth_slices[v] = p_render_buffers->get_depth_texture(v);
}
- ss_effects->screen_space_reflection(p_render_buffers->ssr, texture_slices, p_normal_slices, ssr_roughness_quality, p_metallic_slices, p_metallic_mask, depth_slices, half_size, environment_get_ssr_max_steps(p_environment), environment_get_ssr_fade_in(p_environment), environment_get_ssr_fade_out(p_environment), environment_get_ssr_depth_tolerance(p_environment), view_count, p_projections, p_eye_offsets);
+ ss_effects->screen_space_reflection(p_render_buffers->ssr, texture_slices, p_normal_slices, ssr_roughness_quality, p_metallic_slices, depth_slices, half_size, environment_get_ssr_max_steps(p_environment), environment_get_ssr_fade_in(p_environment), environment_get_ssr_fade_out(p_environment), environment_get_ssr_depth_tolerance(p_environment), view_count, p_projections, p_eye_offsets);
copy_effects->merge_specular(p_dest_framebuffer, p_specular_buffer, p_use_additive ? RID() : p_render_buffers->get_internal_texture(), p_render_buffers->ssr.output, view_count);
}
diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.h b/servers/rendering/renderer_rd/renderer_scene_render_rd.h
index 76d2bc68fe..d47394989f 100644
--- a/servers/rendering/renderer_rd/renderer_scene_render_rd.h
+++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.h
@@ -138,7 +138,7 @@ protected:
virtual RID _render_buffers_get_velocity_texture(Ref<RenderSceneBuffersRD> p_render_buffers) = 0;
void _process_ssao(Ref<RenderSceneBuffersRD> p_render_buffers, RID p_environment, RID p_normal_buffer, const Projection &p_projection);
- void _process_ssr(Ref<RenderSceneBuffersRD> p_render_buffers, RID p_dest_framebuffer, const RID *p_normal_buffer_slices, RID p_specular_buffer, const RID *p_metallic_slices, const Color &p_metallic_mask, RID p_environment, const Projection *p_projections, const Vector3 *p_eye_offsets, bool p_use_additive);
+ void _process_ssr(Ref<RenderSceneBuffersRD> p_render_buffers, RID p_dest_framebuffer, const RID *p_normal_buffer_slices, RID p_specular_buffer, const RID *p_metallic_slices, RID p_environment, const Projection *p_projections, const Vector3 *p_eye_offsets, bool p_use_additive);
void _process_sss(Ref<RenderSceneBuffersRD> p_render_buffers, const Projection &p_camera);
void _process_ssil(Ref<RenderSceneBuffersRD> p_render_buffers, RID p_environment, RID p_normal_buffer, const Projection &p_projection, const Transform3D &p_transform);
diff --git a/servers/rendering/renderer_rd/shaders/effects/screen_space_reflection.glsl b/servers/rendering/renderer_rd/shaders/effects/screen_space_reflection.glsl
index 246ef81cb2..9f86643e52 100644
--- a/servers/rendering/renderer_rd/shaders/effects/screen_space_reflection.glsl
+++ b/servers/rendering/renderer_rd/shaders/effects/screen_space_reflection.glsl
@@ -30,12 +30,7 @@ layout(push_constant, std430) uniform Params {
bool orthogonal;
float filter_mipmap_levels;
bool use_half_res;
- uint metallic_mask;
-
uint view_index;
- uint pad1;
- uint pad2;
- uint pad3;
}
params;
@@ -167,7 +162,7 @@ void main() {
if (depth > z_to) {
// if depth was surpassed
- if (depth <= max(z_to, z_from) + params.depth_tolerance && -depth < params.camera_z_far) {
+ if (depth <= max(z_to, z_from) + params.depth_tolerance && -depth < params.camera_z_far * 0.95) {
// check the depth tolerance and far clip
// check that normal is valid
found = true;
@@ -231,18 +226,20 @@ void main() {
}
}
- // Isn't this going to be overwritten after our endif?
- final_color = imageLoad(source_diffuse, ivec2((final_pos - 0.5) * pixel_size));
-
imageStore(blur_radius_image, ssC, vec4(blur_radius / 255.0)); //stored in r8
#endif // MODE_ROUGH
final_color = vec4(imageLoad(source_diffuse, ivec2(final_pos - 0.5)).rgb, fade * margin_blend);
- //change blend by metallic
- vec4 metallic_mask = unpackUnorm4x8(params.metallic_mask);
- final_color.a *= dot(metallic_mask, texelFetch(source_metallic, ssC << 1, 0));
+ // Schlick term.
+ float metallic = texelFetch(source_metallic, ssC << 1, 0).w;
+ float f0 = mix(0.04, 1.0, metallic); // Assume a "specular" amount of 0.5
+ normal.y = -normal.y;
+ float m = clamp(1.0 - dot(normalize(normal), -view_dir), 0.0, 1.0);
+ float m2 = m * m;
+ m = m2 * m2 * m; // pow(m,5)
+ final_color.a *= f0 + (1.0 - f0) * m; // Fresnel Schlick term.
imageStore(ssr_image, ssC, final_color);
diff --git a/servers/rendering/renderer_rd/shaders/environment/sky.glsl b/servers/rendering/renderer_rd/shaders/environment/sky.glsl
index 0eb0f5f8fd..d523461600 100644
--- a/servers/rendering/renderer_rd/shaders/environment/sky.glsl
+++ b/servers/rendering/renderer_rd/shaders/environment/sky.glsl
@@ -153,6 +153,15 @@ layout(set = 3, binding = 0) uniform texture3D volumetric_fog_texture;
layout(location = 0) out vec4 frag_color;
+#ifdef USE_DEBANDING
+// https://www.iryoku.com/next-generation-post-processing-in-call-of-duty-advanced-warfare
+vec3 interleaved_gradient_noise(vec2 pos) {
+ const vec3 magic = vec3(0.06711056f, 0.00583715f, 52.9829189f);
+ float res = fract(magic.z * fract(dot(pos, magic.xy))) * 2.0 - 1.0;
+ return vec3(res, -res, res) / 255.0;
+}
+#endif
+
vec4 volumetric_fog_process(vec2 screen_uv) {
vec3 fog_pos = vec3(screen_uv, 1.0);
@@ -252,4 +261,8 @@ void main() {
// For mobile renderer we're multiplying by 0.5 as we're using a UNORM buffer.
// For both mobile and clustered, we also bake in the exposure value for the environment and camera.
frag_color.rgb = frag_color.rgb * params.luminance_multiplier;
+
+#ifdef USE_DEBANDING
+ frag_color.rgb += interleaved_gradient_noise(gl_FragCoord.xy);
+#endif
}
diff --git a/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl b/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl
index 26b96b358f..8e8ec6883a 100644
--- a/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl
+++ b/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl
@@ -129,7 +129,7 @@ invariant gl_Position;
#GLOBALS
-void vertex_shader(in uint instance_index, in bool is_multimesh, in SceneData scene_data, in mat4 model_matrix, out vec4 screen_pos) {
+void vertex_shader(in uint instance_index, in bool is_multimesh, in uint multimesh_offset, in SceneData scene_data, in mat4 model_matrix, out vec4 screen_pos) {
vec4 instance_custom = vec4(0.0);
#if defined(COLOR_USED)
color_interp = color_attrib;
@@ -208,7 +208,7 @@ void vertex_shader(in uint instance_index, in bool is_multimesh, in SceneData sc
}
}
- uint offset = stride * gl_InstanceIndex;
+ uint offset = stride * (gl_InstanceIndex + multimesh_offset);
if (bool(instances.data[instance_index].flags & INSTANCE_FLAGS_MULTIMESH_FORMAT_2D)) {
matrix = mat4(transforms.data[offset + 0], transforms.data[offset + 1], vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0));
@@ -397,13 +397,13 @@ void main() {
mat4 model_matrix = instances.data[instance_index].transform;
#if defined(MOTION_VECTORS)
global_time = scene_data_block.prev_data.time;
- vertex_shader(instance_index, is_multimesh, scene_data_block.prev_data, instances.data[instance_index].prev_transform, prev_screen_position);
+ vertex_shader(instance_index, is_multimesh, draw_call.multimesh_motion_vectors_previous_offset, scene_data_block.prev_data, instances.data[instance_index].prev_transform, prev_screen_position);
global_time = scene_data_block.data.time;
- vertex_shader(instance_index, is_multimesh, scene_data_block.data, model_matrix, screen_position);
+ vertex_shader(instance_index, is_multimesh, draw_call.multimesh_motion_vectors_current_offset, scene_data_block.data, model_matrix, screen_position);
#else
global_time = scene_data_block.data.time;
vec4 screen_position;
- vertex_shader(instance_index, is_multimesh, scene_data_block.data, model_matrix, screen_position);
+ vertex_shader(instance_index, is_multimesh, draw_call.multimesh_motion_vectors_current_offset, scene_data_block.data, model_matrix, screen_position);
#endif
}
diff --git a/servers/rendering/renderer_rd/shaders/scene_forward_clustered_inc.glsl b/servers/rendering/renderer_rd/shaders/scene_forward_clustered_inc.glsl
index 45484b8c47..d97da0c571 100644
--- a/servers/rendering/renderer_rd/shaders/scene_forward_clustered_inc.glsl
+++ b/servers/rendering/renderer_rd/shaders/scene_forward_clustered_inc.glsl
@@ -29,8 +29,8 @@
layout(push_constant, std430) uniform DrawCall {
uint instance_index;
uint uv_offset;
- uint pad0;
- uint pad1;
+ uint multimesh_motion_vectors_current_offset;
+ uint multimesh_motion_vectors_previous_offset;
}
draw_call;
diff --git a/servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl b/servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl
index 4e6e29b315..2fba1351f7 100644
--- a/servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl
+++ b/servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl
@@ -97,11 +97,12 @@ void light_compute(vec3 N, vec3 L, vec3 V, float A, vec3 light_color, float atte
float diffuse_brdf_NL; // BRDF times N.L for calculating diffuse radiance
#if defined(DIFFUSE_LAMBERT_WRAP)
- // energy conserving lambert wrap shader
- diffuse_brdf_NL = max(0.0, (NdotL + roughness) / ((1.0 + roughness) * (1.0 + roughness)));
+ // Energy conserving lambert wrap shader.
+ // https://web.archive.org/web/20210228210901/http://blog.stevemcauley.com/2011/12/03/energy-conserving-wrapped-diffuse/
+ diffuse_brdf_NL = max(0.0, (NdotL + roughness) / ((1.0 + roughness) * (1.0 + roughness))) * (1.0 / M_PI);
#elif defined(DIFFUSE_TOON)
- diffuse_brdf_NL = smoothstep(-roughness, max(roughness, 0.01), NdotL);
+ diffuse_brdf_NL = smoothstep(-roughness, max(roughness, 0.01), NdotL) * (1.0 / M_PI);
#elif defined(DIFFUSE_BURLEY)
diff --git a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp
index 49e3543ba5..1827b73507 100644
--- a/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp
+++ b/servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "mesh_storage.h"
+#include "../../rendering_server_globals.h"
using namespace RendererRD;
@@ -1211,7 +1212,13 @@ void MeshStorage::multimesh_allocate_data(RID p_multimesh, int p_instances, RS::
if (multimesh->data_cache_dirty_regions) {
memdelete_arr(multimesh->data_cache_dirty_regions);
multimesh->data_cache_dirty_regions = nullptr;
- multimesh->data_cache_used_dirty_regions = 0;
+ multimesh->data_cache_dirty_region_count = 0;
+ }
+
+ if (multimesh->previous_data_cache_dirty_regions) {
+ memdelete_arr(multimesh->previous_data_cache_dirty_regions);
+ multimesh->previous_data_cache_dirty_regions = nullptr;
+ multimesh->previous_data_cache_dirty_region_count = 0;
}
multimesh->instances = p_instances;
@@ -1228,14 +1235,67 @@ void MeshStorage::multimesh_allocate_data(RID p_multimesh, int p_instances, RS::
multimesh->aabb = AABB();
multimesh->aabb_dirty = false;
multimesh->visible_instances = MIN(multimesh->visible_instances, multimesh->instances);
+ multimesh->motion_vectors_current_offset = 0;
+ multimesh->motion_vectors_previous_offset = 0;
+ multimesh->motion_vectors_last_change = -1;
if (multimesh->instances) {
- multimesh->buffer = RD::get_singleton()->storage_buffer_create(multimesh->instances * multimesh->stride_cache * 4);
+ uint32_t buffer_size = multimesh->instances * multimesh->stride_cache * sizeof(float);
+ if (multimesh->motion_vectors_enabled) {
+ buffer_size *= 2;
+ }
+ multimesh->buffer = RD::get_singleton()->storage_buffer_create(buffer_size);
}
multimesh->dependency.changed_notify(Dependency::DEPENDENCY_CHANGED_MULTIMESH);
}
+bool MeshStorage::_multimesh_enable_motion_vectors(RID p_multimesh) {
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
+ ERR_FAIL_COND_V(!multimesh, false);
+
+ if (multimesh->motion_vectors_enabled) {
+ return false;
+ }
+
+ multimesh->motion_vectors_enabled = true;
+
+ multimesh->motion_vectors_current_offset = 0;
+ multimesh->motion_vectors_previous_offset = 0;
+ multimesh->motion_vectors_last_change = -1;
+
+ if (!multimesh->data_cache.is_empty()) {
+ multimesh->data_cache.append_array(multimesh->data_cache);
+ }
+
+ if (multimesh->buffer_set) {
+ RD::get_singleton()->barrier();
+ Vector<uint8_t> buffer_data = RD::get_singleton()->buffer_get_data(multimesh->buffer);
+ if (!multimesh->data_cache.is_empty()) {
+ memcpy(buffer_data.ptrw(), multimesh->data_cache.ptr(), buffer_data.size());
+ }
+
+ RD::get_singleton()->free(multimesh->buffer);
+ uint32_t buffer_size = multimesh->instances * multimesh->stride_cache * sizeof(float) * 2;
+ multimesh->buffer = RD::get_singleton()->storage_buffer_create(buffer_size);
+ RD::get_singleton()->buffer_update(multimesh->buffer, 0, buffer_data.size(), buffer_data.ptr(), RD::BARRIER_MASK_NO_BARRIER);
+ RD::get_singleton()->buffer_update(multimesh->buffer, buffer_data.size(), buffer_data.size(), buffer_data.ptr());
+ multimesh->uniform_set_3d = RID(); // Cleared by dependency
+ return true;
+ }
+ return false; // Update the transforms uniform set cache
+}
+
+void MeshStorage::_multimesh_get_motion_vectors_offsets(RID p_multimesh, uint32_t &r_current_offset, uint32_t &r_prev_offset) {
+ MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
+ ERR_FAIL_COND(!multimesh);
+ r_current_offset = multimesh->motion_vectors_current_offset;
+ if (RSG::rasterizer->get_frame_number() - multimesh->motion_vectors_last_change >= 2) {
+ multimesh->motion_vectors_previous_offset = multimesh->motion_vectors_current_offset;
+ }
+ r_prev_offset = multimesh->motion_vectors_previous_offset;
+}
+
int MeshStorage::multimesh_get_instance_count(RID p_multimesh) const {
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
ERR_FAIL_COND_V(!multimesh, 0);
@@ -1261,7 +1321,7 @@ void MeshStorage::multimesh_set_mesh(RID p_multimesh, RID p_mesh) {
//need to re-create AABB unfortunately, calling this has a penalty
if (multimesh->buffer_set) {
Vector<uint8_t> buffer = RD::get_singleton()->buffer_get_data(multimesh->buffer);
- const uint8_t *r = buffer.ptr();
+ const uint8_t *r = buffer.ptr() + multimesh->motion_vectors_current_offset * multimesh->stride_cache * sizeof(float);
const float *data = reinterpret_cast<const float *>(r);
_multimesh_re_create_aabb(multimesh, data, multimesh->instances);
}
@@ -1276,10 +1336,14 @@ void MeshStorage::_multimesh_make_local(MultiMesh *multimesh) const {
if (multimesh->data_cache.size() > 0) {
return; //already local
}
- ERR_FAIL_COND(multimesh->data_cache.size() > 0);
+
// this means that the user wants to load/save individual elements,
// for this, the data must reside on CPU, so just copy it there.
- multimesh->data_cache.resize(multimesh->instances * multimesh->stride_cache);
+ uint32_t buffer_size = multimesh->instances * multimesh->stride_cache;
+ if (multimesh->motion_vectors_enabled) {
+ buffer_size *= 2;
+ }
+ multimesh->data_cache.resize(buffer_size);
{
float *w = multimesh->data_cache.ptrw();
@@ -1290,15 +1354,48 @@ void MeshStorage::_multimesh_make_local(MultiMesh *multimesh) const {
memcpy(w, r, buffer.size());
}
} else {
- memset(w, 0, (size_t)multimesh->instances * multimesh->stride_cache * sizeof(float));
+ memset(w, 0, buffer_size * sizeof(float));
}
}
uint32_t data_cache_dirty_region_count = (multimesh->instances - 1) / MULTIMESH_DIRTY_REGION_SIZE + 1;
multimesh->data_cache_dirty_regions = memnew_arr(bool, data_cache_dirty_region_count);
- for (uint32_t i = 0; i < data_cache_dirty_region_count; i++) {
- multimesh->data_cache_dirty_regions[i] = false;
+ memset(multimesh->data_cache_dirty_regions, 0, data_cache_dirty_region_count * sizeof(bool));
+ multimesh->data_cache_dirty_region_count = 0;
+
+ multimesh->previous_data_cache_dirty_regions = memnew_arr(bool, data_cache_dirty_region_count);
+ memset(multimesh->previous_data_cache_dirty_regions, 0, data_cache_dirty_region_count * sizeof(bool));
+ multimesh->previous_data_cache_dirty_region_count = 0;
+}
+
+void MeshStorage::_multimesh_update_motion_vectors_data_cache(MultiMesh *multimesh) {
+ ERR_FAIL_COND(multimesh->data_cache.is_empty());
+
+ if (!multimesh->motion_vectors_enabled) {
+ return;
+ }
+
+ uint32_t frame = RSG::rasterizer->get_frame_number();
+ if (multimesh->motion_vectors_last_change != frame) {
+ multimesh->motion_vectors_previous_offset = multimesh->motion_vectors_current_offset;
+ multimesh->motion_vectors_current_offset = multimesh->instances - multimesh->motion_vectors_current_offset;
+ multimesh->motion_vectors_last_change = frame;
+
+ if (multimesh->previous_data_cache_dirty_region_count > 0) {
+ uint8_t *data = (uint8_t *)multimesh->data_cache.ptrw();
+ uint32_t current_ofs = multimesh->motion_vectors_current_offset * multimesh->stride_cache * sizeof(float);
+ uint32_t previous_ofs = multimesh->motion_vectors_previous_offset * multimesh->stride_cache * sizeof(float);
+ uint32_t visible_instances = multimesh->visible_instances >= 0 ? multimesh->visible_instances : multimesh->instances;
+ uint32_t visible_region_count = visible_instances == 0 ? 0 : (visible_instances - 1) / MULTIMESH_DIRTY_REGION_SIZE + 1;
+ uint32_t region_size = multimesh->stride_cache * MULTIMESH_DIRTY_REGION_SIZE * sizeof(float);
+ uint32_t size = multimesh->stride_cache * (uint32_t)multimesh->instances * (uint32_t)sizeof(float);
+ for (uint32_t i = 0; i < visible_region_count; i++) {
+ if (multimesh->previous_data_cache_dirty_regions[i]) {
+ uint32_t offset = i * region_size;
+ memcpy(data + current_ofs + offset, data + previous_ofs + offset, MIN(region_size, size - offset));
+ }
+ }
+ }
}
- multimesh->data_cache_used_dirty_regions = 0;
}
void MeshStorage::_multimesh_mark_dirty(MultiMesh *multimesh, int p_index, bool p_aabb) {
@@ -1309,7 +1406,7 @@ void MeshStorage::_multimesh_mark_dirty(MultiMesh *multimesh, int p_index, bool
#endif
if (!multimesh->data_cache_dirty_regions[region_index]) {
multimesh->data_cache_dirty_regions[region_index] = true;
- multimesh->data_cache_used_dirty_regions++;
+ multimesh->data_cache_dirty_region_count++;
}
if (p_aabb) {
@@ -1330,7 +1427,7 @@ void MeshStorage::_multimesh_mark_all_dirty(MultiMesh *multimesh, bool p_data, b
for (uint32_t i = 0; i < data_cache_dirty_region_count; i++) {
if (!multimesh->data_cache_dirty_regions[i]) {
multimesh->data_cache_dirty_regions[i] = true;
- multimesh->data_cache_used_dirty_regions++;
+ multimesh->data_cache_dirty_region_count++;
}
}
}
@@ -1395,11 +1492,12 @@ void MeshStorage::multimesh_instance_set_transform(RID p_multimesh, int p_index,
ERR_FAIL_COND(multimesh->xform_format != RS::MULTIMESH_TRANSFORM_3D);
_multimesh_make_local(multimesh);
+ _multimesh_update_motion_vectors_data_cache(multimesh);
{
float *w = multimesh->data_cache.ptrw();
- float *dataptr = w + p_index * multimesh->stride_cache;
+ float *dataptr = w + (multimesh->motion_vectors_current_offset + p_index) * multimesh->stride_cache;
dataptr[0] = p_transform.basis.rows[0][0];
dataptr[1] = p_transform.basis.rows[0][1];
@@ -1425,11 +1523,12 @@ void MeshStorage::multimesh_instance_set_transform_2d(RID p_multimesh, int p_ind
ERR_FAIL_COND(multimesh->xform_format != RS::MULTIMESH_TRANSFORM_2D);
_multimesh_make_local(multimesh);
+ _multimesh_update_motion_vectors_data_cache(multimesh);
{
float *w = multimesh->data_cache.ptrw();
- float *dataptr = w + p_index * multimesh->stride_cache;
+ float *dataptr = w + (multimesh->motion_vectors_current_offset + p_index) * multimesh->stride_cache;
dataptr[0] = p_transform.columns[0][0];
dataptr[1] = p_transform.columns[1][0];
@@ -1451,11 +1550,12 @@ void MeshStorage::multimesh_instance_set_color(RID p_multimesh, int p_index, con
ERR_FAIL_COND(!multimesh->uses_colors);
_multimesh_make_local(multimesh);
+ _multimesh_update_motion_vectors_data_cache(multimesh);
{
float *w = multimesh->data_cache.ptrw();
- float *dataptr = w + p_index * multimesh->stride_cache + multimesh->color_offset_cache;
+ float *dataptr = w + (multimesh->motion_vectors_current_offset + p_index) * multimesh->stride_cache + multimesh->color_offset_cache;
dataptr[0] = p_color.r;
dataptr[1] = p_color.g;
@@ -1473,11 +1573,12 @@ void MeshStorage::multimesh_instance_set_custom_data(RID p_multimesh, int p_inde
ERR_FAIL_COND(!multimesh->uses_custom_data);
_multimesh_make_local(multimesh);
+ _multimesh_update_motion_vectors_data_cache(multimesh);
{
float *w = multimesh->data_cache.ptrw();
- float *dataptr = w + p_index * multimesh->stride_cache + multimesh->custom_data_offset_cache;
+ float *dataptr = w + (multimesh->motion_vectors_current_offset + p_index) * multimesh->stride_cache + multimesh->custom_data_offset_cache;
dataptr[0] = p_color.r;
dataptr[1] = p_color.g;
@@ -1514,7 +1615,7 @@ Transform3D MeshStorage::multimesh_instance_get_transform(RID p_multimesh, int p
{
const float *r = multimesh->data_cache.ptr();
- const float *dataptr = r + p_index * multimesh->stride_cache;
+ const float *dataptr = r + (multimesh->motion_vectors_current_offset + p_index) * multimesh->stride_cache;
t.basis.rows[0][0] = dataptr[0];
t.basis.rows[0][1] = dataptr[1];
@@ -1545,7 +1646,7 @@ Transform2D MeshStorage::multimesh_instance_get_transform_2d(RID p_multimesh, in
{
const float *r = multimesh->data_cache.ptr();
- const float *dataptr = r + p_index * multimesh->stride_cache;
+ const float *dataptr = r + (multimesh->motion_vectors_current_offset + p_index) * multimesh->stride_cache;
t.columns[0][0] = dataptr[0];
t.columns[1][0] = dataptr[1];
@@ -1570,7 +1671,7 @@ Color MeshStorage::multimesh_instance_get_color(RID p_multimesh, int p_index) co
{
const float *r = multimesh->data_cache.ptr();
- const float *dataptr = r + p_index * multimesh->stride_cache + multimesh->color_offset_cache;
+ const float *dataptr = r + (multimesh->motion_vectors_current_offset + p_index) * multimesh->stride_cache + multimesh->color_offset_cache;
c.r = dataptr[0];
c.g = dataptr[1];
@@ -1593,7 +1694,7 @@ Color MeshStorage::multimesh_instance_get_custom_data(RID p_multimesh, int p_ind
{
const float *r = multimesh->data_cache.ptr();
- const float *dataptr = r + p_index * multimesh->stride_cache + multimesh->custom_data_offset_cache;
+ const float *dataptr = r + (multimesh->motion_vectors_current_offset + p_index) * multimesh->stride_cache + multimesh->custom_data_offset_cache;
c.r = dataptr[0];
c.g = dataptr[1];
@@ -1609,25 +1710,26 @@ void MeshStorage::multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_b
ERR_FAIL_COND(!multimesh);
ERR_FAIL_COND(p_buffer.size() != (multimesh->instances * (int)multimesh->stride_cache));
+ if (multimesh->motion_vectors_enabled) {
+ uint32_t frame = RSG::rasterizer->get_frame_number();
+
+ if (multimesh->motion_vectors_last_change != frame) {
+ multimesh->motion_vectors_previous_offset = multimesh->motion_vectors_current_offset;
+ multimesh->motion_vectors_current_offset = multimesh->instances - multimesh->motion_vectors_current_offset;
+ multimesh->motion_vectors_last_change = frame;
+ }
+ }
+
{
const float *r = p_buffer.ptr();
- RD::get_singleton()->buffer_update(multimesh->buffer, 0, p_buffer.size() * sizeof(float), r);
+ RD::get_singleton()->buffer_update(multimesh->buffer, multimesh->motion_vectors_current_offset * multimesh->stride_cache * sizeof(float), p_buffer.size() * sizeof(float), r);
multimesh->buffer_set = true;
}
if (multimesh->data_cache.size()) {
- //if we have a data cache, just update it
- multimesh->data_cache = p_buffer;
- {
- //clear dirty since nothing will be dirty anymore
- uint32_t data_cache_dirty_region_count = (multimesh->instances - 1) / MULTIMESH_DIRTY_REGION_SIZE + 1;
- for (uint32_t i = 0; i < data_cache_dirty_region_count; i++) {
- multimesh->data_cache_dirty_regions[i] = false;
- }
- multimesh->data_cache_used_dirty_regions = 0;
- }
-
- _multimesh_mark_all_dirty(multimesh, false, true); //update AABB
+ float *cache_data = multimesh->data_cache.ptrw();
+ memcpy(cache_data + (multimesh->motion_vectors_current_offset * multimesh->stride_cache), p_buffer.ptr(), p_buffer.size() * sizeof(float));
+ _multimesh_mark_all_dirty(multimesh, true, true); //update AABB
} else if (multimesh->mesh.is_valid()) {
//if we have a mesh set, we need to re-generate the AABB from the new data
const float *data = p_buffer.ptr();
@@ -1642,20 +1744,19 @@ Vector<float> MeshStorage::multimesh_get_buffer(RID p_multimesh) const {
ERR_FAIL_COND_V(!multimesh, Vector<float>());
if (multimesh->buffer.is_null()) {
return Vector<float>();
- } else if (multimesh->data_cache.size()) {
- return multimesh->data_cache;
} else {
- //get from memory
-
- Vector<uint8_t> buffer = RD::get_singleton()->buffer_get_data(multimesh->buffer);
Vector<float> ret;
ret.resize(multimesh->instances * multimesh->stride_cache);
- {
- float *w = ret.ptrw();
- const uint8_t *r = buffer.ptr();
- memcpy(w, r, buffer.size());
- }
+ float *w = ret.ptrw();
+ if (multimesh->data_cache.size()) {
+ const uint8_t *r = (uint8_t *)multimesh->data_cache.ptr() + multimesh->motion_vectors_current_offset * multimesh->stride_cache * sizeof(float);
+ memcpy(w, r, ret.size() * sizeof(float));
+ } else {
+ Vector<uint8_t> buffer = RD::get_singleton()->buffer_get_data(multimesh->buffer);
+ const uint8_t *r = buffer.ptr() + multimesh->motion_vectors_current_offset * multimesh->stride_cache * sizeof(float);
+ memcpy(w, r, ret.size() * sizeof(float));
+ }
return ret;
}
}
@@ -1698,36 +1799,38 @@ void MeshStorage::_update_dirty_multimeshes() {
MultiMesh *multimesh = multimesh_dirty_list;
if (multimesh->data_cache.size()) { //may have been cleared, so only process if it exists
- const float *data = multimesh->data_cache.ptr();
uint32_t visible_instances = multimesh->visible_instances >= 0 ? multimesh->visible_instances : multimesh->instances;
+ uint32_t buffer_offset = multimesh->motion_vectors_current_offset * multimesh->stride_cache;
+ const float *data = multimesh->data_cache.ptr() + buffer_offset;
- if (multimesh->data_cache_used_dirty_regions) {
+ uint32_t total_dirty_regions = multimesh->data_cache_dirty_region_count + multimesh->previous_data_cache_dirty_region_count;
+ if (total_dirty_regions != 0) {
uint32_t data_cache_dirty_region_count = (multimesh->instances - 1) / MULTIMESH_DIRTY_REGION_SIZE + 1;
uint32_t visible_region_count = visible_instances == 0 ? 0 : (visible_instances - 1) / MULTIMESH_DIRTY_REGION_SIZE + 1;
uint32_t region_size = multimesh->stride_cache * MULTIMESH_DIRTY_REGION_SIZE * sizeof(float);
-
- if (multimesh->data_cache_used_dirty_regions > 32 || multimesh->data_cache_used_dirty_regions > visible_region_count / 2) {
+ if (total_dirty_regions > 32 || total_dirty_regions > visible_region_count / 2) {
//if there too many dirty regions, or represent the majority of regions, just copy all, else transfer cost piles up too much
- RD::get_singleton()->buffer_update(multimesh->buffer, 0, MIN(visible_region_count * region_size, multimesh->instances * (uint32_t)multimesh->stride_cache * (uint32_t)sizeof(float)), data);
+ RD::get_singleton()->buffer_update(multimesh->buffer, buffer_offset * sizeof(float), MIN(visible_region_count * region_size, multimesh->instances * (uint32_t)multimesh->stride_cache * (uint32_t)sizeof(float)), data);
} else {
//not that many regions? update them all
for (uint32_t i = 0; i < visible_region_count; i++) {
- if (multimesh->data_cache_dirty_regions[i]) {
+ if (multimesh->data_cache_dirty_regions[i] || multimesh->previous_data_cache_dirty_regions[i]) {
uint32_t offset = i * region_size;
uint32_t size = multimesh->stride_cache * (uint32_t)multimesh->instances * (uint32_t)sizeof(float);
uint32_t region_start_index = multimesh->stride_cache * MULTIMESH_DIRTY_REGION_SIZE * i;
- RD::get_singleton()->buffer_update(multimesh->buffer, offset, MIN(region_size, size - offset), &data[region_start_index]);
+ RD::get_singleton()->buffer_update(multimesh->buffer, buffer_offset * sizeof(float) + offset, MIN(region_size, size - offset), &data[region_start_index], RD::BARRIER_MASK_NO_BARRIER);
}
}
+ RD::get_singleton()->barrier(RD::BARRIER_MASK_NO_BARRIER, RD::BARRIER_MASK_ALL);
}
- for (uint32_t i = 0; i < data_cache_dirty_region_count; i++) {
- multimesh->data_cache_dirty_regions[i] = false;
- }
+ memcpy(multimesh->previous_data_cache_dirty_regions, multimesh->data_cache_dirty_regions, data_cache_dirty_region_count * sizeof(bool));
+ memset(multimesh->data_cache_dirty_regions, 0, data_cache_dirty_region_count * sizeof(bool));
- multimesh->data_cache_used_dirty_regions = 0;
+ multimesh->previous_data_cache_dirty_region_count = multimesh->data_cache_dirty_region_count;
+ multimesh->data_cache_dirty_region_count = 0;
}
if (multimesh->aabb_dirty) {
diff --git a/servers/rendering/renderer_rd/storage_rd/mesh_storage.h b/servers/rendering/renderer_rd/storage_rd/mesh_storage.h
index 5c0d019c15..622f3911c7 100644
--- a/servers/rendering/renderer_rd/storage_rd/mesh_storage.h
+++ b/servers/rendering/renderer_rd/storage_rd/mesh_storage.h
@@ -205,13 +205,19 @@ private:
AABB aabb;
bool aabb_dirty = false;
bool buffer_set = false;
+ bool motion_vectors_enabled = false;
+ uint32_t motion_vectors_current_offset = 0;
+ uint32_t motion_vectors_previous_offset = 0;
+ uint64_t motion_vectors_last_change = -1;
uint32_t stride_cache = 0;
uint32_t color_offset_cache = 0;
uint32_t custom_data_offset_cache = 0;
Vector<float> data_cache; //used if individual setting is used
bool *data_cache_dirty_regions = nullptr;
- uint32_t data_cache_used_dirty_regions = 0;
+ uint32_t data_cache_dirty_region_count = 0;
+ bool *previous_data_cache_dirty_regions = nullptr;
+ uint32_t previous_data_cache_dirty_region_count = 0;
RID buffer; //storage buffer
RID uniform_set_3d;
@@ -228,6 +234,7 @@ private:
MultiMesh *multimesh_dirty_list = nullptr;
_FORCE_INLINE_ void _multimesh_make_local(MultiMesh *multimesh) const;
+ _FORCE_INLINE_ void _multimesh_update_motion_vectors_data_cache(MultiMesh *multimesh);
_FORCE_INLINE_ void _multimesh_mark_dirty(MultiMesh *multimesh, int p_index, bool p_aabb);
_FORCE_INLINE_ void _multimesh_mark_all_dirty(MultiMesh *multimesh, bool p_data, bool p_aabb);
_FORCE_INLINE_ void _multimesh_re_create_aabb(MultiMesh *multimesh, const float *p_data, int p_instances);
@@ -579,6 +586,8 @@ public:
virtual AABB multimesh_get_aabb(RID p_multimesh) const override;
void _update_dirty_multimeshes();
+ bool _multimesh_enable_motion_vectors(RID p_multimesh);
+ void _multimesh_get_motion_vectors_offsets(RID p_multimesh, uint32_t &r_current_offset, uint32_t &r_prev_offset);
_FORCE_INLINE_ RS::MultimeshTransformFormat multimesh_get_transform_format(RID p_multimesh) const {
MultiMesh *multimesh = multimesh_owner.get_or_null(p_multimesh);
diff --git a/servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.cpp b/servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.cpp
index 576ec81124..16fdbc07f5 100644
--- a/servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.cpp
+++ b/servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.cpp
@@ -128,6 +128,11 @@ void RenderSceneBuffersRD::cleanup() {
ss_effects.linear_depth_slices.clear();
}
+ if (ss_effects.downsample_uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(ss_effects.downsample_uniform_set)) {
+ RD::get_singleton()->free(ss_effects.downsample_uniform_set);
+ ss_effects.downsample_uniform_set = RID();
+ }
+
sse->ssao_free(ss_effects.ssao);
sse->ssil_free(ss_effects.ssil);
sse->ssr_free(ssr);
@@ -535,7 +540,9 @@ void RenderSceneBuffersRD::ensure_velocity() {
RD::TEXTURE_SAMPLES_8,
};
- create_texture(RB_SCOPE_BUFFERS, RB_TEX_VELOCITY_MSAA, RD::DATA_FORMAT_R16G16_SFLOAT, msaa_usage_bits, ts[msaa_3d]);
+ RD::TextureSamples texture_samples = ts[msaa_3d];
+
+ create_texture(RB_SCOPE_BUFFERS, RB_TEX_VELOCITY_MSAA, RD::DATA_FORMAT_R16G16_SFLOAT, msaa_usage_bits, texture_samples);
}
create_texture(RB_SCOPE_BUFFERS, RB_TEX_VELOCITY, RD::DATA_FORMAT_R16G16_SFLOAT, usage_bits);
diff --git a/servers/rendering/renderer_viewport.cpp b/servers/rendering/renderer_viewport.cpp
index d466f90e79..eacd9bbbc2 100644
--- a/servers/rendering/renderer_viewport.cpp
+++ b/servers/rendering/renderer_viewport.cpp
@@ -73,33 +73,36 @@ static Transform2D _canvas_get_transform(RendererViewport::Viewport *p_viewport,
}
Vector<RendererViewport::Viewport *> RendererViewport::_sort_active_viewports() {
- // We need to sort the viewports in a "topological order",
- // children first and parents last, we use the Kahn's algorithm to achieve that.
+ // We need to sort the viewports in a "topological order", children first and
+ // parents last. We also need to keep sibling viewports in the original order
+ // from top to bottom.
Vector<Viewport *> result;
List<Viewport *> nodes;
- for (Viewport *viewport : active_viewports) {
+ for (int i = active_viewports.size() - 1; i >= 0; --i) {
+ Viewport *viewport = active_viewports[i];
if (viewport->parent.is_valid()) {
continue;
}
nodes.push_back(viewport);
+ result.insert(0, viewport);
}
while (!nodes.is_empty()) {
- Viewport *node = nodes[0];
+ const Viewport *node = nodes[0];
nodes.pop_front();
- result.insert(0, node);
-
- for (Viewport *child : active_viewports) {
+ for (int i = active_viewports.size() - 1; i >= 0; --i) {
+ Viewport *child = active_viewports[i];
if (child->parent != node->self) {
continue;
}
if (!nodes.find(child)) {
nodes.push_back(child);
+ result.insert(0, child);
}
}
}
@@ -714,7 +717,14 @@ void RendererViewport::draw_viewports() {
blit_to_screen_list[vp->viewport_to_screen] = Vector<BlitToScreen>();
}
- blit_to_screen_list[vp->viewport_to_screen].push_back(blit);
+ if (OS::get_singleton()->get_current_rendering_driver_name() == "opengl3") {
+ Vector<BlitToScreen> blit_to_screen_vec;
+ blit_to_screen_vec.push_back(blit);
+ RSG::rasterizer->blit_render_targets_to_screen(vp->viewport_to_screen, blit_to_screen_vec.ptr(), 1);
+ RSG::rasterizer->end_frame(true);
+ } else {
+ blit_to_screen_list[vp->viewport_to_screen].push_back(blit);
+ }
}
}
diff --git a/servers/rendering/rendering_server_default.cpp b/servers/rendering/rendering_server_default.cpp
index 1f686069bd..9103b0cf56 100644
--- a/servers/rendering/rendering_server_default.cpp
+++ b/servers/rendering/rendering_server_default.cpp
@@ -91,7 +91,10 @@ void RenderingServerDefault::_draw(bool p_swap_buffers, double frame_step) {
RSG::viewport->draw_viewports();
RSG::canvas_render->update();
- RSG::rasterizer->end_frame(p_swap_buffers);
+ if (OS::get_singleton()->get_current_rendering_driver_name() != "opengl3") {
+ // Already called for gl_compatibility renderer.
+ RSG::rasterizer->end_frame(p_swap_buffers);
+ }
XRServer *xr_server = XRServer::get_singleton();
if (xr_server != nullptr) {
diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp
index e2519ba8d1..6754d84cd4 100644
--- a/servers/rendering/shader_language.cpp
+++ b/servers/rendering/shader_language.cpp
@@ -1069,7 +1069,7 @@ String ShaderLanguage::get_uniform_hint_name(ShaderNode::Uniform::Hint p_hint) {
result = "hint_range";
} break;
case ShaderNode::Uniform::HINT_SOURCE_COLOR: {
- result = "hint_color";
+ result = "source_color";
} break;
case ShaderNode::Uniform::HINT_NORMAL: {
result = "hint_normal";
@@ -1171,6 +1171,10 @@ void ShaderLanguage::clear() {
last_type = IDENTIFIER_MAX;
current_uniform_group_name = "";
current_uniform_subgroup_name = "";
+ current_uniform_hint = ShaderNode::Uniform::HINT_NONE;
+ current_uniform_filter = FILTER_DEFAULT;
+ current_uniform_repeat = REPEAT_DEFAULT;
+ current_uniform_instance_index_defined = false;
completion_type = COMPLETION_NONE;
completion_block = nullptr;
@@ -8617,6 +8621,7 @@ Error ShaderLanguage::_parse_shader(const HashMap<StringName, FunctionInfo> &p_f
}
custom_instance_index = tk.constant;
+ current_uniform_instance_index_defined = true;
if (custom_instance_index >= MAX_INSTANCE_UNIFORM_INDICES) {
_set_error(vformat(RTR("Allowed instance uniform indices must be within [0..%d] range."), MAX_INSTANCE_UNIFORM_INDICES - 1));
@@ -8682,6 +8687,7 @@ Error ShaderLanguage::_parse_shader(const HashMap<StringName, FunctionInfo> &p_f
return ERR_PARSE_ERROR;
} else {
uniform.hint = new_hint;
+ current_uniform_hint = new_hint;
}
}
@@ -8695,6 +8701,7 @@ Error ShaderLanguage::_parse_shader(const HashMap<StringName, FunctionInfo> &p_f
return ERR_PARSE_ERROR;
} else {
uniform.filter = new_filter;
+ current_uniform_filter = new_filter;
}
}
@@ -8708,6 +8715,7 @@ Error ShaderLanguage::_parse_shader(const HashMap<StringName, FunctionInfo> &p_f
return ERR_PARSE_ERROR;
} else {
uniform.repeat = new_repeat;
+ current_uniform_repeat = new_repeat;
}
}
@@ -8775,6 +8783,11 @@ Error ShaderLanguage::_parse_shader(const HashMap<StringName, FunctionInfo> &p_f
keyword_completion_context = CF_GLOBAL_SPACE;
#endif // DEBUG_ENABLED
completion_type = COMPLETION_NONE;
+
+ current_uniform_hint = ShaderNode::Uniform::HINT_NONE;
+ current_uniform_filter = FILTER_DEFAULT;
+ current_uniform_repeat = REPEAT_DEFAULT;
+ current_uniform_instance_index_defined = false;
} else { // varying
ShaderNode::Varying varying;
varying.type = type;
@@ -10311,28 +10324,33 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_
} break;
case COMPLETION_HINT: {
if (completion_base == DataType::TYPE_VEC3 || completion_base == DataType::TYPE_VEC4) {
- ScriptLanguage::CodeCompletionOption option("source_color", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT);
- r_options->push_back(option);
+ if (current_uniform_hint == ShaderNode::Uniform::HINT_NONE) {
+ ScriptLanguage::CodeCompletionOption option("source_color", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT);
+ r_options->push_back(option);
+ }
} else if ((completion_base == DataType::TYPE_INT || completion_base == DataType::TYPE_FLOAT) && !completion_base_array) {
- ScriptLanguage::CodeCompletionOption option("hint_range", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT);
+ if (current_uniform_hint == ShaderNode::Uniform::HINT_NONE) {
+ ScriptLanguage::CodeCompletionOption option("hint_range", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT);
- if (completion_base == DataType::TYPE_INT) {
- option.insert_text = "hint_range(0, 100, 1)";
- } else {
- option.insert_text = "hint_range(0.0, 1.0, 0.1)";
- }
+ if (completion_base == DataType::TYPE_INT) {
+ option.insert_text = "hint_range(0, 100, 1)";
+ } else {
+ option.insert_text = "hint_range(0.0, 1.0, 0.1)";
+ }
- r_options->push_back(option);
+ r_options->push_back(option);
+ }
} else if ((int(completion_base) > int(TYPE_MAT4) && int(completion_base) < int(TYPE_STRUCT)) && !completion_base_array) {
- static Vector<String> options;
-
- if (options.is_empty()) {
+ Vector<String> options;
+ if (current_uniform_filter == FILTER_DEFAULT) {
options.push_back("filter_linear");
options.push_back("filter_linear_mipmap");
options.push_back("filter_linear_mipmap_anisotropic");
options.push_back("filter_nearest");
options.push_back("filter_nearest_mipmap");
options.push_back("filter_nearest_mipmap_anisotropic");
+ }
+ if (current_uniform_hint == ShaderNode::Uniform::HINT_NONE) {
options.push_back("hint_anisotropy");
options.push_back("hint_default_black");
options.push_back("hint_default_white");
@@ -10348,6 +10366,8 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_
options.push_back("hint_normal_roughness_texture");
options.push_back("hint_depth_texture");
options.push_back("source_color");
+ }
+ if (current_uniform_repeat == REPEAT_DEFAULT) {
options.push_back("repeat_enable");
options.push_back("repeat_disable");
}
@@ -10357,7 +10377,7 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_
r_options->push_back(option);
}
}
- if (!completion_base_array) {
+ if (!completion_base_array && !current_uniform_instance_index_defined) {
ScriptLanguage::CodeCompletionOption option("instance_index", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT);
option.insert_text = "instance_index(0)";
r_options->push_back(option);
diff --git a/servers/rendering/shader_language.h b/servers/rendering/shader_language.h
index 75b713d167..e9f8c3b289 100644
--- a/servers/rendering/shader_language.h
+++ b/servers/rendering/shader_language.h
@@ -1050,6 +1050,10 @@ private:
};
CompletionType completion_type;
+ ShaderNode::Uniform::Hint current_uniform_hint = ShaderNode::Uniform::HINT_NONE;
+ TextureFilter current_uniform_filter = FILTER_DEFAULT;
+ TextureRepeat current_uniform_repeat = REPEAT_DEFAULT;
+ bool current_uniform_instance_index_defined = false;
int completion_line = 0;
BlockNode *completion_block = nullptr;
DataType completion_base;
diff --git a/servers/rendering/shader_types.cpp b/servers/rendering/shader_types.cpp
index a12701c6aa..cd063f91ac 100644
--- a/servers/rendering/shader_types.cpp
+++ b/servers/rendering/shader_types.cpp
@@ -450,6 +450,7 @@ ShaderTypes::ShaderTypes() {
shader_modes[RS::SHADER_SKY].modes.push_back({ PNAME("use_half_res_pass") });
shader_modes[RS::SHADER_SKY].modes.push_back({ PNAME("use_quarter_res_pass") });
shader_modes[RS::SHADER_SKY].modes.push_back({ PNAME("disable_fog") });
+ shader_modes[RS::SHADER_SKY].modes.push_back({ PNAME("use_debanding") });
}
/************ FOG **************************/
diff --git a/thirdparty/README.md b/thirdparty/README.md
index ffc8137819..df54f8cf36 100644
--- a/thirdparty/README.md
+++ b/thirdparty/README.md
@@ -535,7 +535,7 @@ Patch files are provided in `oidn/patches/`.
## openxr
- Upstream: https://github.com/KhronosGroup/OpenXR-SDK
-- Version: 1.0.23 (885a90f8934d84121344ba8e4aa5159d5b496e08, 2022)
+- Version: 1.0.25 (c16a18c99740ea5dd251e3af117e0e5aea4ceaa9, 2022)
- License: Apache 2.0
Files extracted from upstream source:
diff --git a/thirdparty/openxr/include/openxr/openxr.h b/thirdparty/openxr/include/openxr/openxr.h
index 6c6a52d27e..6f9b71aa68 100644
--- a/thirdparty/openxr/include/openxr/openxr.h
+++ b/thirdparty/openxr/include/openxr/openxr.h
@@ -2,7 +2,7 @@
#define OPENXR_H_ 1
/*
-** Copyright (c) 2017-2022, The Khronos Group Inc.
+** Copyright 2017-2022 The Khronos Group Inc.
**
** SPDX-License-Identifier: Apache-2.0 OR MIT
*/
@@ -25,7 +25,7 @@ extern "C" {
((((major) & 0xffffULL) << 48) | (((minor) & 0xffffULL) << 32) | ((patch) & 0xffffffffULL))
// OpenXR current version number.
-#define XR_CURRENT_API_VERSION XR_MAKE_VERSION(1, 0, 23)
+#define XR_CURRENT_API_VERSION XR_MAKE_VERSION(1, 0, 25)
#define XR_VERSION_MAJOR(version) (uint16_t)(((uint64_t)(version) >> 48)& 0xffffULL)
#define XR_VERSION_MINOR(version) (uint16_t)(((uint64_t)(version) >> 32) & 0xffffULL)
@@ -401,6 +401,7 @@ typedef enum XrStructureType {
XR_TYPE_COMPOSITION_LAYER_PASSTHROUGH_FB = 1000118003,
XR_TYPE_GEOMETRY_INSTANCE_CREATE_INFO_FB = 1000118004,
XR_TYPE_GEOMETRY_INSTANCE_TRANSFORM_FB = 1000118005,
+ XR_TYPE_SYSTEM_PASSTHROUGH_PROPERTIES2_FB = 1000118006,
XR_TYPE_PASSTHROUGH_STYLE_FB = 1000118020,
XR_TYPE_PASSTHROUGH_COLOR_MAP_MONO_TO_RGBA_FB = 1000118021,
XR_TYPE_PASSTHROUGH_COLOR_MAP_MONO_TO_MONO_FB = 1000118022,
@@ -439,6 +440,9 @@ typedef enum XrStructureType {
XR_TYPE_SWAPCHAIN_STATE_SAMPLER_VULKAN_FB = 1000163000,
XR_TYPE_COMPOSITION_LAYER_SPACE_WARP_INFO_FB = 1000171000,
XR_TYPE_SYSTEM_SPACE_WARP_PROPERTIES_FB = 1000171001,
+ XR_TYPE_SEMANTIC_LABELS_FB = 1000175000,
+ XR_TYPE_ROOM_LAYOUT_FB = 1000175001,
+ XR_TYPE_BOUNDARY_2D_FB = 1000175002,
XR_TYPE_DIGITAL_LENS_CONTROL_ALMALENCE = 1000196000,
XR_TYPE_SPACE_CONTAINER_FB = 1000199000,
XR_TYPE_PASSTHROUGH_KEYBOARD_HANDS_INTENSITY_FB = 1000203002,
@@ -2603,7 +2607,7 @@ typedef struct XrHandJointsMotionRangeInfoEXT {
XR_DEFINE_HANDLE(XrSceneMSFT)
-#define XR_MSFT_scene_understanding_SPEC_VERSION 1
+#define XR_MSFT_scene_understanding_SPEC_VERSION 2
#define XR_MSFT_SCENE_UNDERSTANDING_EXTENSION_NAME "XR_MSFT_scene_understanding"
typedef enum XrSceneComputeFeatureMSFT {
@@ -2925,7 +2929,7 @@ XRAPI_ATTR XrResult XRAPI_CALL xrGetSceneMeshBuffersMSFT(
#define XR_MSFT_scene_understanding_serialization 1
-#define XR_MSFT_scene_understanding_serialization_SPEC_VERSION 1
+#define XR_MSFT_scene_understanding_serialization_SPEC_VERSION 2
#define XR_MSFT_SCENE_UNDERSTANDING_SERIALIZATION_EXTENSION_NAME "XR_MSFT_scene_understanding_serialization"
typedef struct XrSerializedSceneFragmentDataGetInfoMSFT {
XrStructureType type;
@@ -3166,7 +3170,7 @@ XRAPI_ATTR XrResult XRAPI_CALL xrGetFacialExpressionsHTC(
#define XR_FB_color_space 1
-#define XR_FB_color_space_SPEC_VERSION 2
+#define XR_FB_color_space_SPEC_VERSION 3
#define XR_FB_COLOR_SPACE_EXTENSION_NAME "XR_FB_color_space"
typedef enum XrColorSpaceFB {
@@ -3206,7 +3210,7 @@ XRAPI_ATTR XrResult XRAPI_CALL xrSetColorSpaceFB(
#define XR_FB_hand_tracking_mesh 1
-#define XR_FB_hand_tracking_mesh_SPEC_VERSION 2
+#define XR_FB_hand_tracking_mesh_SPEC_VERSION 3
#define XR_FB_HAND_TRACKING_MESH_EXTENSION_NAME "XR_FB_hand_tracking_mesh"
typedef struct XrVector4sFB {
int16_t x;
@@ -3317,6 +3321,10 @@ XR_DEFINE_ATOM(XrAsyncRequestIdFB)
typedef enum XrSpaceComponentTypeFB {
XR_SPACE_COMPONENT_TYPE_LOCATABLE_FB = 0,
XR_SPACE_COMPONENT_TYPE_STORABLE_FB = 1,
+ XR_SPACE_COMPONENT_TYPE_BOUNDED_2D_FB = 3,
+ XR_SPACE_COMPONENT_TYPE_BOUNDED_3D_FB = 4,
+ XR_SPACE_COMPONENT_TYPE_SEMANTIC_LABELS_FB = 5,
+ XR_SPACE_COMPONENT_TYPE_ROOM_LAYOUT_FB = 6,
XR_SPACE_COMPONENT_TYPE_SPACE_CONTAINER_FB = 7,
XR_SPACE_COMPONENT_TYPE_MAX_ENUM_FB = 0x7FFFFFFF
} XrSpaceComponentTypeFB;
@@ -3625,7 +3633,7 @@ XRAPI_ATTR XrResult XRAPI_CALL xrTriangleMeshEndVertexBufferUpdateFB(
XR_DEFINE_HANDLE(XrPassthroughFB)
XR_DEFINE_HANDLE(XrPassthroughLayerFB)
XR_DEFINE_HANDLE(XrGeometryInstanceFB)
-#define XR_FB_passthrough_SPEC_VERSION 2
+#define XR_FB_passthrough_SPEC_VERSION 3
#define XR_FB_PASSTHROUGH_EXTENSION_NAME "XR_FB_passthrough"
#define XR_PASSTHROUGH_COLOR_MAP_MONO_SIZE_FB 256
@@ -3636,10 +3644,18 @@ typedef enum XrPassthroughLayerPurposeFB {
XR_PASSTHROUGH_LAYER_PURPOSE_TRACKED_KEYBOARD_MASKED_HANDS_FB = 1000203002,
XR_PASSTHROUGH_LAYER_PURPOSE_MAX_ENUM_FB = 0x7FFFFFFF
} XrPassthroughLayerPurposeFB;
+typedef XrFlags64 XrPassthroughCapabilityFlagsFB;
+
+// Flag bits for XrPassthroughCapabilityFlagsFB
+static const XrPassthroughCapabilityFlagsFB XR_PASSTHROUGH_CAPABILITY_BIT_FB = 0x00000001;
+static const XrPassthroughCapabilityFlagsFB XR_PASSTHROUGH_CAPABILITY_COLOR_BIT_FB = 0x00000002;
+static const XrPassthroughCapabilityFlagsFB XR_PASSTHROUGH_CAPABILITY_LAYER_DEPTH_BIT_FB = 0x00000004;
+
typedef XrFlags64 XrPassthroughFlagsFB;
// Flag bits for XrPassthroughFlagsFB
static const XrPassthroughFlagsFB XR_PASSTHROUGH_IS_RUNNING_AT_CREATION_BIT_FB = 0x00000001;
+static const XrPassthroughFlagsFB XR_PASSTHROUGH_LAYER_DEPTH_BIT_FB = 0x00000002;
typedef XrFlags64 XrPassthroughStateChangedFlagsFB;
@@ -3656,6 +3672,13 @@ typedef struct XrSystemPassthroughPropertiesFB {
XrBool32 supportsPassthrough;
} XrSystemPassthroughPropertiesFB;
+// XrSystemPassthroughProperties2FB extends XrSystemProperties
+typedef struct XrSystemPassthroughProperties2FB {
+ XrStructureType type;
+ const void* XR_MAY_ALIAS next;
+ XrPassthroughCapabilityFlagsFB capabilities;
+} XrSystemPassthroughProperties2FB;
+
typedef struct XrPassthroughCreateInfoFB {
XrStructureType type;
const void* XR_MAY_ALIAS next;
@@ -3801,7 +3824,7 @@ XRAPI_ATTR XrResult XRAPI_CALL xrGeometryInstanceSetTransformFB(
#define XR_NULL_RENDER_MODEL_KEY_FB 0
XR_DEFINE_ATOM(XrRenderModelKeyFB)
-#define XR_FB_render_model_SPEC_VERSION 2
+#define XR_FB_render_model_SPEC_VERSION 3
#define XR_FB_RENDER_MODEL_EXTENSION_NAME "XR_FB_render_model"
#define XR_MAX_RENDER_MODEL_NAME_SIZE_FB 64
typedef XrFlags64 XrRenderModelFlagsFB;
@@ -4007,6 +4030,11 @@ XRAPI_ATTR XrResult XRAPI_CALL xrSetViewOffsetVARJO(
#endif /* !XR_NO_PROTOTYPES */
+#define XR_ML_ml2_controller_interaction 1
+#define XR_ML_ml2_controller_interaction_SPEC_VERSION 1
+#define XR_ML_ML2_CONTROLLER_INTERACTION_EXTENSION_NAME "XR_ML_ml2_controller_interaction"
+
+
#define XR_MSFT_spatial_anchor_persistence 1
XR_DEFINE_HANDLE(XrSpatialAnchorStoreConnectionMSFT)
#define XR_MAX_SPATIAL_ANCHOR_NAME_SIZE_MSFT 256
@@ -4303,6 +4331,93 @@ typedef struct XrSystemSpaceWarpPropertiesFB {
+#define XR_FB_scene 1
+#define XR_FB_scene_SPEC_VERSION 1
+#define XR_FB_SCENE_EXTENSION_NAME "XR_FB_scene"
+typedef struct XrExtent3DfFB {
+ float width;
+ float height;
+ float depth;
+} XrExtent3DfFB;
+
+typedef struct XrOffset3DfFB {
+ float x;
+ float y;
+ float z;
+} XrOffset3DfFB;
+
+typedef struct XrRect3DfFB {
+ XrOffset3DfFB offset;
+ XrExtent3DfFB extent;
+} XrRect3DfFB;
+
+typedef struct XrSemanticLabelsFB {
+ XrStructureType type;
+ const void* XR_MAY_ALIAS next;
+ uint32_t bufferCapacityInput;
+ uint32_t bufferCountOutput;
+ char* buffer;
+} XrSemanticLabelsFB;
+
+typedef struct XrRoomLayoutFB {
+ XrStructureType type;
+ const void* XR_MAY_ALIAS next;
+ XrUuidEXT floorUuid;
+ XrUuidEXT ceilingUuid;
+ uint32_t wallUuidCapacityInput;
+ uint32_t wallUuidCountOutput;
+ XrUuidEXT* wallUuids;
+} XrRoomLayoutFB;
+
+typedef struct XrBoundary2DFB {
+ XrStructureType type;
+ const void* XR_MAY_ALIAS next;
+ uint32_t vertexCapacityInput;
+ uint32_t vertexCountOutput;
+ XrVector2f* vertices;
+} XrBoundary2DFB;
+
+typedef XrResult (XRAPI_PTR *PFN_xrGetSpaceBoundingBox2DFB)(XrSession session, XrSpace space, XrRect2Df* boundingBox2DOutput);
+typedef XrResult (XRAPI_PTR *PFN_xrGetSpaceBoundingBox3DFB)(XrSession session, XrSpace space, XrRect3DfFB* boundingBox3DOutput);
+typedef XrResult (XRAPI_PTR *PFN_xrGetSpaceSemanticLabelsFB)(XrSession session, XrSpace space, XrSemanticLabelsFB* semanticLabelsOutput);
+typedef XrResult (XRAPI_PTR *PFN_xrGetSpaceBoundary2DFB)(XrSession session, XrSpace space, XrBoundary2DFB* boundary2DOutput);
+typedef XrResult (XRAPI_PTR *PFN_xrGetSpaceRoomLayoutFB)(XrSession session, XrSpace space, XrRoomLayoutFB* roomLayoutOutput);
+
+#ifndef XR_NO_PROTOTYPES
+#ifdef XR_EXTENSION_PROTOTYPES
+XRAPI_ATTR XrResult XRAPI_CALL xrGetSpaceBoundingBox2DFB(
+ XrSession session,
+ XrSpace space,
+ XrRect2Df* boundingBox2DOutput);
+
+XRAPI_ATTR XrResult XRAPI_CALL xrGetSpaceBoundingBox3DFB(
+ XrSession session,
+ XrSpace space,
+ XrRect3DfFB* boundingBox3DOutput);
+
+XRAPI_ATTR XrResult XRAPI_CALL xrGetSpaceSemanticLabelsFB(
+ XrSession session,
+ XrSpace space,
+ XrSemanticLabelsFB* semanticLabelsOutput);
+
+XRAPI_ATTR XrResult XRAPI_CALL xrGetSpaceBoundary2DFB(
+ XrSession session,
+ XrSpace space,
+ XrBoundary2DFB* boundary2DOutput);
+
+XRAPI_ATTR XrResult XRAPI_CALL xrGetSpaceRoomLayoutFB(
+ XrSession session,
+ XrSpace space,
+ XrRoomLayoutFB* roomLayoutOutput);
+#endif /* XR_EXTENSION_PROTOTYPES */
+#endif /* !XR_NO_PROTOTYPES */
+
+
+#define XR_EXT_palm_pose 1
+#define XR_EXT_palm_pose_SPEC_VERSION 2
+#define XR_EXT_PALM_POSE_EXTENSION_NAME "XR_EXT_palm_pose"
+
+
#define XR_ALMALENCE_digital_lens_control 1
#define XR_ALMALENCE_digital_lens_control_SPEC_VERSION 1
#define XR_ALMALENCE_DIGITAL_LENS_CONTROL_EXTENSION_NAME "XR_ALMALENCE_digital_lens_control"
@@ -4329,13 +4444,13 @@ XRAPI_ATTR XrResult XRAPI_CALL xrSetDigitalLensControlALMALENCE(
#define XR_FB_spatial_entity_container 1
-#define XR_FB_spatial_entity_container_SPEC_VERSION 1
+#define XR_FB_spatial_entity_container_SPEC_VERSION 2
#define XR_FB_SPATIAL_ENTITY_CONTAINER_EXTENSION_NAME "XR_FB_spatial_entity_container"
typedef struct XrSpaceContainerFB {
XrStructureType type;
const void* XR_MAY_ALIAS next;
uint32_t uuidCapacityInput;
- uint32_t* uuidCountOutput;
+ uint32_t uuidCountOutput;
XrUuidEXT* uuids;
} XrSpaceContainerFB;
diff --git a/thirdparty/openxr/include/openxr/openxr_platform.h b/thirdparty/openxr/include/openxr/openxr_platform.h
index f0fbf6955a..b3aabb23c5 100644
--- a/thirdparty/openxr/include/openxr/openxr_platform.h
+++ b/thirdparty/openxr/include/openxr/openxr_platform.h
@@ -2,7 +2,7 @@
#define OPENXR_PLATFORM_H_ 1
/*
-** Copyright (c) 2017-2022, The Khronos Group Inc.
+** Copyright 2017-2022 The Khronos Group Inc.
**
** SPDX-License-Identifier: Apache-2.0 OR MIT
*/
diff --git a/thirdparty/openxr/include/openxr/openxr_reflection.h b/thirdparty/openxr/include/openxr/openxr_reflection.h
index 163b54e4e4..ac6f452377 100644
--- a/thirdparty/openxr/include/openxr/openxr_reflection.h
+++ b/thirdparty/openxr/include/openxr/openxr_reflection.h
@@ -302,6 +302,7 @@ XR_ENUM_STR(XrResult);
_(XR_TYPE_COMPOSITION_LAYER_PASSTHROUGH_FB, 1000118003) \
_(XR_TYPE_GEOMETRY_INSTANCE_CREATE_INFO_FB, 1000118004) \
_(XR_TYPE_GEOMETRY_INSTANCE_TRANSFORM_FB, 1000118005) \
+ _(XR_TYPE_SYSTEM_PASSTHROUGH_PROPERTIES2_FB, 1000118006) \
_(XR_TYPE_PASSTHROUGH_STYLE_FB, 1000118020) \
_(XR_TYPE_PASSTHROUGH_COLOR_MAP_MONO_TO_RGBA_FB, 1000118021) \
_(XR_TYPE_PASSTHROUGH_COLOR_MAP_MONO_TO_MONO_FB, 1000118022) \
@@ -340,6 +341,9 @@ XR_ENUM_STR(XrResult);
_(XR_TYPE_SWAPCHAIN_STATE_SAMPLER_VULKAN_FB, 1000163000) \
_(XR_TYPE_COMPOSITION_LAYER_SPACE_WARP_INFO_FB, 1000171000) \
_(XR_TYPE_SYSTEM_SPACE_WARP_PROPERTIES_FB, 1000171001) \
+ _(XR_TYPE_SEMANTIC_LABELS_FB, 1000175000) \
+ _(XR_TYPE_ROOM_LAYOUT_FB, 1000175001) \
+ _(XR_TYPE_BOUNDARY_2D_FB, 1000175002) \
_(XR_TYPE_DIGITAL_LENS_CONTROL_ALMALENCE, 1000196000) \
_(XR_TYPE_SPACE_CONTAINER_FB, 1000199000) \
_(XR_TYPE_PASSTHROUGH_KEYBOARD_HANDS_INTENSITY_FB, 1000203002) \
@@ -660,6 +664,10 @@ XR_ENUM_STR(XrResult);
#define XR_LIST_ENUM_XrSpaceComponentTypeFB(_) \
_(XR_SPACE_COMPONENT_TYPE_LOCATABLE_FB, 0) \
_(XR_SPACE_COMPONENT_TYPE_STORABLE_FB, 1) \
+ _(XR_SPACE_COMPONENT_TYPE_BOUNDED_2D_FB, 3) \
+ _(XR_SPACE_COMPONENT_TYPE_BOUNDED_3D_FB, 4) \
+ _(XR_SPACE_COMPONENT_TYPE_SEMANTIC_LABELS_FB, 5) \
+ _(XR_SPACE_COMPONENT_TYPE_ROOM_LAYOUT_FB, 6) \
_(XR_SPACE_COMPONENT_TYPE_SPACE_CONTAINER_FB, 7) \
_(XR_SPACE_COMPONENT_TYPE_MAX_ENUM_FB, 0x7FFFFFFF)
@@ -847,8 +855,14 @@ XR_ENUM_STR(XrResult);
#define XR_LIST_BITS_XrTriangleMeshFlagsFB(_) \
_(XR_TRIANGLE_MESH_MUTABLE_BIT_FB, 0x00000001) \
+#define XR_LIST_BITS_XrPassthroughCapabilityFlagsFB(_) \
+ _(XR_PASSTHROUGH_CAPABILITY_BIT_FB, 0x00000001) \
+ _(XR_PASSTHROUGH_CAPABILITY_COLOR_BIT_FB, 0x00000002) \
+ _(XR_PASSTHROUGH_CAPABILITY_LAYER_DEPTH_BIT_FB, 0x00000004) \
+
#define XR_LIST_BITS_XrPassthroughFlagsFB(_) \
_(XR_PASSTHROUGH_IS_RUNNING_AT_CREATION_BIT_FB, 0x00000001) \
+ _(XR_PASSTHROUGH_LAYER_DEPTH_BIT_FB, 0x00000002) \
#define XR_LIST_BITS_XrPassthroughStateChangedFlagsFB(_) \
_(XR_PASSTHROUGH_STATE_CHANGED_REINIT_REQUIRED_BIT_FB, 0x00000001) \
@@ -2288,6 +2302,11 @@ XR_ENUM_STR(XrResult);
_(next) \
_(supportsPassthrough) \
+#define XR_LIST_STRUCT_XrSystemPassthroughProperties2FB(_) \
+ _(type) \
+ _(next) \
+ _(capabilities) \
+
#define XR_LIST_STRUCT_XrPassthroughCreateInfoFB(_) \
_(type) \
_(next) \
@@ -2589,6 +2608,43 @@ XR_ENUM_STR(XrResult);
_(recommendedMotionVectorImageRectWidth) \
_(recommendedMotionVectorImageRectHeight) \
+#define XR_LIST_STRUCT_XrExtent3DfFB(_) \
+ _(width) \
+ _(height) \
+ _(depth) \
+
+#define XR_LIST_STRUCT_XrOffset3DfFB(_) \
+ _(x) \
+ _(y) \
+ _(z) \
+
+#define XR_LIST_STRUCT_XrRect3DfFB(_) \
+ _(offset) \
+ _(extent) \
+
+#define XR_LIST_STRUCT_XrSemanticLabelsFB(_) \
+ _(type) \
+ _(next) \
+ _(bufferCapacityInput) \
+ _(bufferCountOutput) \
+ _(buffer) \
+
+#define XR_LIST_STRUCT_XrRoomLayoutFB(_) \
+ _(type) \
+ _(next) \
+ _(floorUuid) \
+ _(ceilingUuid) \
+ _(wallUuidCapacityInput) \
+ _(wallUuidCountOutput) \
+ _(wallUuids) \
+
+#define XR_LIST_STRUCT_XrBoundary2DFB(_) \
+ _(type) \
+ _(next) \
+ _(vertexCapacityInput) \
+ _(vertexCountOutput) \
+ _(vertices) \
+
#define XR_LIST_STRUCT_XrDigitalLensControlALMALENCE(_) \
_(type) \
_(next) \
@@ -2785,6 +2841,7 @@ XR_ENUM_STR(XrResult);
_(XrKeyboardTrackingQueryFB, XR_TYPE_KEYBOARD_TRACKING_QUERY_FB) \
_(XrTriangleMeshCreateInfoFB, XR_TYPE_TRIANGLE_MESH_CREATE_INFO_FB) \
_(XrSystemPassthroughPropertiesFB, XR_TYPE_SYSTEM_PASSTHROUGH_PROPERTIES_FB) \
+ _(XrSystemPassthroughProperties2FB, XR_TYPE_SYSTEM_PASSTHROUGH_PROPERTIES2_FB) \
_(XrPassthroughCreateInfoFB, XR_TYPE_PASSTHROUGH_CREATE_INFO_FB) \
_(XrPassthroughLayerCreateInfoFB, XR_TYPE_PASSTHROUGH_LAYER_CREATE_INFO_FB) \
_(XrCompositionLayerPassthroughFB, XR_TYPE_COMPOSITION_LAYER_PASSTHROUGH_FB) \
@@ -2823,6 +2880,9 @@ XR_ENUM_STR(XrResult);
_(XrEventDataSpaceEraseCompleteFB, XR_TYPE_EVENT_DATA_SPACE_ERASE_COMPLETE_FB) \
_(XrCompositionLayerSpaceWarpInfoFB, XR_TYPE_COMPOSITION_LAYER_SPACE_WARP_INFO_FB) \
_(XrSystemSpaceWarpPropertiesFB, XR_TYPE_SYSTEM_SPACE_WARP_PROPERTIES_FB) \
+ _(XrSemanticLabelsFB, XR_TYPE_SEMANTIC_LABELS_FB) \
+ _(XrRoomLayoutFB, XR_TYPE_ROOM_LAYOUT_FB) \
+ _(XrBoundary2DFB, XR_TYPE_BOUNDARY_2D_FB) \
_(XrDigitalLensControlALMALENCE, XR_TYPE_DIGITAL_LENS_CONTROL_ALMALENCE) \
_(XrSpaceContainerFB, XR_TYPE_SPACE_CONTAINER_FB) \
_(XrPassthroughKeyboardHandsIntensityFB, XR_TYPE_PASSTHROUGH_KEYBOARD_HANDS_INTENSITY_FB) \
@@ -3071,6 +3131,7 @@ XR_ENUM_STR(XrResult);
_(XR_VARJO_environment_depth_estimation, 124) \
_(XR_VARJO_marker_tracking, 125) \
_(XR_VARJO_view_offset, 126) \
+ _(XR_ML_ml2_controller_interaction, 135) \
_(XR_MSFT_spatial_anchor_persistence, 143) \
_(XR_ULTRALEAP_hand_tracking_forearm, 150) \
_(XR_FB_spatial_entity_query, 157) \
@@ -3082,6 +3143,8 @@ XR_ENUM_STR(XrResult);
_(XR_FB_swapchain_update_state_vulkan, 164) \
_(XR_KHR_swapchain_usage_input_attachment_bit, 166) \
_(XR_FB_space_warp, 172) \
+ _(XR_FB_scene, 176) \
+ _(XR_EXT_palm_pose, 177) \
_(XR_ALMALENCE_digital_lens_control, 197) \
_(XR_FB_spatial_entity_container, 200) \
_(XR_FB_passthrough_keyboard_hands, 204) \
diff --git a/thirdparty/openxr/src/common/unique_asset.h b/thirdparty/openxr/src/common/unique_asset.h
new file mode 100644
index 0000000000..4929039a03
--- /dev/null
+++ b/thirdparty/openxr/src/common/unique_asset.h
@@ -0,0 +1,33 @@
+// Copyright (c) 2017-2022, The Khronos Group Inc.
+//
+// SPDX-License-Identifier: Apache-2.0 OR MIT
+#pragma once
+
+#ifdef XR_USE_PLATFORM_ANDROID
+
+#include <memory>
+#include <android/asset_manager.h>
+
+namespace deleters {
+struct AAssetDeleter {
+ void operator()(AAsset* asset) const noexcept {
+ if (asset != nullptr) {
+ AAsset_close(asset);
+ }
+ }
+};
+
+struct AAssetDirDeleter {
+ void operator()(AAssetDir* dir) const noexcept {
+ if (dir != nullptr) {
+ AAssetDir_close(dir);
+ }
+ }
+};
+
+} // namespace deleters
+
+using UniqueAsset = std::unique_ptr<AAsset, deleters::AAssetDeleter>;
+using UniqueAssetDir = std::unique_ptr<AAssetDir, deleters::AAssetDirDeleter>;
+
+#endif
diff --git a/thirdparty/openxr/src/loader/android_utilities.cpp b/thirdparty/openxr/src/loader/android_utilities.cpp
index 807a775820..59d9a99b74 100644
--- a/thirdparty/openxr/src/loader/android_utilities.cpp
+++ b/thirdparty/openxr/src/loader/android_utilities.cpp
@@ -299,7 +299,7 @@ int getActiveRuntimeVirtualManifest(wrap::android::content::Context const &conte
auto hasFunctions = cursor.getInt(cursor.getColumnIndex(active_runtime::Columns::HAS_FUNCTIONS)) == 1;
__android_log_print(ANDROID_LOG_INFO, TAG, "Got runtime: package: %s, so filename: %s, native lib dir: %s, has functions: %s",
- packageName.c_str(), libDir.c_str(), filename.c_str(), (hasFunctions ? "yes" : "no"));
+ packageName.c_str(), filename.c_str(), libDir.c_str(), (hasFunctions ? "yes" : "no"));
auto lib_path = libDir + "/" + filename;
cursor.close();
diff --git a/thirdparty/openxr/src/loader/api_layer_interface.cpp b/thirdparty/openxr/src/loader/api_layer_interface.cpp
index c3fd5bb7f1..b946e09402 100644
--- a/thirdparty/openxr/src/loader/api_layer_interface.cpp
+++ b/thirdparty/openxr/src/loader/api_layer_interface.cpp
@@ -53,7 +53,6 @@ XrResult ApiLayerInterface::GetApiLayerProperties(const std::string& openxr_comm
uint32_t* outgoing_count, XrApiLayerProperties* api_layer_properties) {
std::vector<std::unique_ptr<ApiLayerManifestFile>> manifest_files;
uint32_t manifest_count = 0;
-
// Validate props struct before proceeding
if (0 < incoming_count && nullptr != api_layer_properties) {
for (uint32_t i = 0; i < incoming_count; i++) {
diff --git a/thirdparty/openxr/src/loader/loader_core.cpp b/thirdparty/openxr/src/loader/loader_core.cpp
index 375f1c93ba..a8bbfb4de2 100644
--- a/thirdparty/openxr/src/loader/loader_core.cpp
+++ b/thirdparty/openxr/src/loader/loader_core.cpp
@@ -711,9 +711,6 @@ XRLOADER_ABI_CATCH_FALLBACK
XRAPI_ATTR XrResult XRAPI_CALL LoaderXrGetInstanceProcAddr(XrInstance instance, const char *name,
PFN_xrVoidFunction *function) XRLOADER_ABI_TRY {
- // Initialize the function to nullptr in case it does not get caught in a known case
- *function = nullptr;
-
if (nullptr == function) {
LoaderLogger::LogValidationErrorMessage("VUID-xrGetInstanceProcAddr-function-parameter", "xrGetInstanceProcAddr",
"Invalid Function pointer");
@@ -726,6 +723,9 @@ XRAPI_ATTR XrResult XRAPI_CALL LoaderXrGetInstanceProcAddr(XrInstance instance,
return XR_ERROR_VALIDATION_FAILURE;
}
+ // Initialize the function to nullptr in case it does not get caught in a known case
+ *function = nullptr;
+
LoaderInstance *loader_instance = nullptr;
if (instance == XR_NULL_HANDLE) {
// Null instance is allowed for a few specific API entry points, otherwise return error
diff --git a/thirdparty/openxr/src/loader/manifest_file.cpp b/thirdparty/openxr/src/loader/manifest_file.cpp
index e4eab3949e..df99d51f8f 100644
--- a/thirdparty/openxr/src/loader/manifest_file.cpp
+++ b/thirdparty/openxr/src/loader/manifest_file.cpp
@@ -21,6 +21,7 @@
#include "loader_platform.hpp"
#include "platform_utils.hpp"
#include "loader_logger.hpp"
+#include "unique_asset.h"
#include <json/json.h>
#include <openxr/openxr.h>
@@ -50,6 +51,10 @@
#define SYSCONFDIR "/etc"
#endif // !SYSCONFDIR
+#ifdef XR_USE_PLATFORM_ANDROID
+#include <android/asset_manager.h>
+#endif
+
#ifdef XRLOADER_DISABLE_EXCEPTION_HANDLING
#if JSON_USE_EXCEPTIONS
#error \
@@ -656,17 +661,68 @@ ApiLayerManifestFile::ApiLayerManifestFile(ManifestFileType type, const std::str
_description(description),
_implementation_version(implementation_version) {}
-void ApiLayerManifestFile::CreateIfValid(ManifestFileType type, const std::string &filename,
- std::vector<std::unique_ptr<ApiLayerManifestFile>> &manifest_files) {
- std::ifstream json_stream(filename, std::ifstream::in);
+#ifdef XR_USE_PLATFORM_ANDROID
+void ApiLayerManifestFile::AddManifestFilesAndroid(ManifestFileType type,
+ std::vector<std::unique_ptr<ApiLayerManifestFile>> &manifest_files) {
+ AAssetManager *assetManager = (AAssetManager *)Android_Get_Asset_Manager();
+ std::vector<std::string> filenames;
+ {
+ std::string search_path = "";
+ switch (type) {
+ case MANIFEST_TYPE_IMPLICIT_API_LAYER:
+ search_path = "openxr/1/api_layers/implicit.d/";
+ break;
+ case MANIFEST_TYPE_EXPLICIT_API_LAYER:
+ search_path = "openxr/1/api_layers/explicit.d/";
+ break;
+ default:
+ return;
+ }
- std::ostringstream error_ss("ApiLayerManifestFile::CreateIfValid ");
- if (!json_stream.is_open()) {
- error_ss << "failed to open " << filename << ". Does it exist?";
- LoaderLogger::LogErrorMessage("", error_ss.str());
- return;
+ UniqueAssetDir dir{AAssetManager_openDir(assetManager, search_path.c_str())};
+ if (!dir) {
+ return;
+ }
+ const std::string json = ".json";
+ const char *fn = nullptr;
+ while ((fn = AAssetDir_getNextFileName(dir.get())) != nullptr) {
+ const std::string filename = search_path + fn;
+ if (filename.size() < json.size()) {
+ continue;
+ }
+ if (filename.compare(filename.size() - json.size(), json.size(), json) == 0) {
+ filenames.push_back(filename);
+ }
+ }
}
+ for (const auto &filename : filenames) {
+ UniqueAsset asset{AAssetManager_open(assetManager, filename.c_str(), AASSET_MODE_BUFFER)};
+ if (!asset) {
+ LoaderLogger::LogWarningMessage(
+ "", "ApiLayerManifestFile::AddManifestFilesAndroid unable to open asset " + filename + ", skipping");
+
+ continue;
+ }
+ size_t length = AAsset_getLength(asset.get());
+ const char *buf = reinterpret_cast<const char *>(AAsset_getBuffer(asset.get()));
+ if (!buf) {
+ LoaderLogger::LogWarningMessage(
+ "", "ApiLayerManifestFile::AddManifestFilesAndroid unable to access asset" + filename + ", skipping");
+ continue;
+ }
+ std::istringstream json_stream(std::string{buf, length});
+
+ CreateIfValid(ManifestFileType::MANIFEST_TYPE_EXPLICIT_API_LAYER, filename, json_stream,
+ &ApiLayerManifestFile::LocateLibraryInAssets, manifest_files);
+ }
+}
+#endif // XR_USE_PLATFORM_ANDROID
+
+void ApiLayerManifestFile::CreateIfValid(ManifestFileType type, const std::string &filename, std::istream &json_stream,
+ LibraryLocator locate_library,
+ std::vector<std::unique_ptr<ApiLayerManifestFile>> &manifest_files) {
+ std::ostringstream error_ss("ApiLayerManifestFile::CreateIfValid ");
Json::CharReaderBuilder builder;
std::string errors;
Json::Value root_node = Json::nullValue;
@@ -757,9 +813,7 @@ void ApiLayerManifestFile::CreateIfValid(ManifestFileType type, const std::strin
} else {
// Otherwise, treat the library path as a relative path based on the JSON file.
std::string combined_path;
- std::string file_parent;
- if (!FileSysUtilsGetParentPath(filename, file_parent) ||
- !FileSysUtilsCombinePaths(file_parent, library_path, combined_path) || !FileSysUtilsPathExists(combined_path)) {
+ if (!locate_library(filename, library_path, combined_path)) {
error_ss << filename << " library " << combined_path << " does not appear to exist";
LoaderLogger::LogErrorMessage("", error_ss.str());
return;
@@ -781,6 +835,46 @@ void ApiLayerManifestFile::CreateIfValid(ManifestFileType type, const std::strin
manifest_files.back()->ParseCommon(layer_root_node);
}
+void ApiLayerManifestFile::CreateIfValid(ManifestFileType type, const std::string &filename,
+ std::vector<std::unique_ptr<ApiLayerManifestFile>> &manifest_files) {
+ std::ifstream json_stream(filename, std::ifstream::in);
+ if (!json_stream.is_open()) {
+ std::ostringstream error_ss("ApiLayerManifestFile::CreateIfValid ");
+ error_ss << "failed to open " << filename << ". Does it exist?";
+ LoaderLogger::LogErrorMessage("", error_ss.str());
+ return;
+ }
+ CreateIfValid(type, filename, json_stream, &ApiLayerManifestFile::LocateLibraryRelativeToJson, manifest_files);
+}
+
+bool ApiLayerManifestFile::LocateLibraryRelativeToJson(
+ const std::string &json_filename, const std::string &library_path,
+ std::string &out_combined_path) { // Otherwise, treat the library path as a relative path based on the JSON file.
+ std::string combined_path;
+ std::string file_parent;
+ if (!FileSysUtilsGetParentPath(json_filename, file_parent) ||
+ !FileSysUtilsCombinePaths(file_parent, library_path, combined_path) || !FileSysUtilsPathExists(combined_path)) {
+ out_combined_path = combined_path;
+ return false;
+ }
+ out_combined_path = combined_path;
+ return true;
+}
+
+#ifdef XR_USE_PLATFORM_ANDROID
+bool ApiLayerManifestFile::LocateLibraryInAssets(const std::string & /* json_filename */, const std::string &library_path,
+ std::string &out_combined_path) {
+ std::string combined_path;
+ std::string file_parent = GetAndroidNativeLibraryDir();
+ if (!FileSysUtilsCombinePaths(file_parent, library_path, combined_path) || !FileSysUtilsPathExists(combined_path)) {
+ out_combined_path = combined_path;
+ return false;
+ }
+ out_combined_path = combined_path;
+ return true;
+}
+#endif
+
void ApiLayerManifestFile::PopulateApiLayerProperties(XrApiLayerProperties &props) const {
props.layerVersion = _implementation_version;
props.specVersion = XR_MAKE_VERSION(_api_version.major, _api_version.minor, _api_version.patch);
@@ -841,5 +935,9 @@ XrResult ApiLayerManifestFile::FindManifestFiles(ManifestFileType type,
ApiLayerManifestFile::CreateIfValid(type, cur_file, manifest_files);
}
+#ifdef XR_USE_PLATFORM_ANDROID
+ ApiLayerManifestFile::AddManifestFilesAndroid(type, manifest_files);
+#endif // XR_USE_PLATFORM_ANDROID
+
return XR_SUCCESS;
}
diff --git a/thirdparty/openxr/src/loader/manifest_file.hpp b/thirdparty/openxr/src/loader/manifest_file.hpp
index 0d04886d84..de0aab65c2 100644
--- a/thirdparty/openxr/src/loader/manifest_file.hpp
+++ b/thirdparty/openxr/src/loader/manifest_file.hpp
@@ -14,6 +14,7 @@
#include <memory>
#include <string>
#include <vector>
+#include <iosfwd>
#include <unordered_map>
namespace Json {
@@ -79,6 +80,8 @@ class RuntimeManifestFile : public ManifestFile {
std::vector<std::unique_ptr<RuntimeManifestFile>> &manifest_files);
};
+using LibraryLocator = bool (*)(const std::string &json_filename, const std::string &library_path, std::string &out_combined_path);
+
// ApiLayerManifestFile class -
// Responsible for finding and parsing API Layer-specific manifest files.
class ApiLayerManifestFile : public ManifestFile {
@@ -93,8 +96,19 @@ class ApiLayerManifestFile : public ManifestFile {
ApiLayerManifestFile(ManifestFileType type, const std::string &filename, const std::string &layer_name,
const std::string &description, const JsonVersion &api_version, const uint32_t &implementation_version,
const std::string &library_path);
+
+ static void CreateIfValid(ManifestFileType type, const std::string &filename, std::istream &json_stream,
+ LibraryLocator locate_library, std::vector<std::unique_ptr<ApiLayerManifestFile>> &manifest_files);
static void CreateIfValid(ManifestFileType type, const std::string &filename,
std::vector<std::unique_ptr<ApiLayerManifestFile>> &manifest_files);
+ /// @return false if we could not find the library.
+ static bool LocateLibraryRelativeToJson(const std::string &json_filename, const std::string &library_path,
+ std::string &out_combined_path);
+#ifdef XR_USE_PLATFORM_ANDROID
+ static bool LocateLibraryInAssets(const std::string &json_filename, const std::string &library_path,
+ std::string &out_combined_path);
+ static void AddManifestFilesAndroid(ManifestFileType type, std::vector<std::unique_ptr<ApiLayerManifestFile>> &manifest_files);
+#endif
JsonVersion _api_version;
std::string _layer_name;
diff --git a/thirdparty/openxr/src/loader/runtime_interface.cpp b/thirdparty/openxr/src/loader/runtime_interface.cpp
index 1a35ba013a..0f081ff9b2 100644
--- a/thirdparty/openxr/src/loader/runtime_interface.cpp
+++ b/thirdparty/openxr/src/loader/runtime_interface.cpp
@@ -27,6 +27,7 @@
#ifdef XR_USE_PLATFORM_ANDROID
#include "android_utilities.h"
+#include <android/asset_manager_jni.h>
#include <json/value.h>
#endif // XR_USE_PLATFORM_ANDROID
@@ -50,6 +51,14 @@ class LoaderInitData {
* Type alias for the platform-specific structure type.
*/
using StructType = XrLoaderInitInfoAndroidKHR;
+ /*!
+ * Native library path.
+ */
+ std::string _native_library_path;
+ /*!
+ * Android asset manager.
+ */
+ AAssetManager* _android_asset_manager;
#endif
/*!
@@ -99,6 +108,30 @@ XrResult LoaderInitData::initialize(const XrLoaderInitInfoBaseHeaderKHR* info) {
_data = *cast_info;
jni::init((jni::JavaVM*)_data.applicationVM);
_data.next = nullptr;
+ JNIEnv* Env;
+ ((jni::JavaVM*)(cast_info->applicationVM))->AttachCurrentThread(&Env, nullptr);
+ const jclass contextClass = Env->GetObjectClass((jobject)_data.applicationContext);
+
+ const jmethodID getAssetsMethod = Env->GetMethodID(contextClass, "getAssets", "()Landroid/content/res/AssetManager;");
+ const jobject AssetManagerObject = Env->CallObjectMethod((jobject)_data.applicationContext, getAssetsMethod);
+ _android_asset_manager = AAssetManager_fromJava(Env, AssetManagerObject);
+
+ const jmethodID getApplicationContextMethod =
+ Env->GetMethodID(contextClass, "getApplicationContext", "()Landroid/content/Context;");
+ const jobject contextObject = Env->CallObjectMethod((jobject)_data.applicationContext, getApplicationContextMethod);
+ const jmethodID getApplicationInfoMethod =
+ Env->GetMethodID(contextClass, "getApplicationInfo", "()Landroid/content/pm/ApplicationInfo;");
+ const jobject applicationInfoObject = Env->CallObjectMethod(contextObject, getApplicationInfoMethod);
+ const jfieldID nativeLibraryDirField =
+ Env->GetFieldID(Env->GetObjectClass(applicationInfoObject), "nativeLibraryDir", "Ljava/lang/String;");
+ const jobject nativeLibraryDirObject = Env->GetObjectField(applicationInfoObject, nativeLibraryDirField);
+ const jmethodID getBytesMethod =
+ Env->GetMethodID(Env->GetObjectClass(nativeLibraryDirObject), "getBytes", "(Ljava/lang/String;)[B");
+ const auto bytesObject =
+ static_cast<jbyteArray>(Env->CallObjectMethod(nativeLibraryDirObject, getBytesMethod, Env->NewStringUTF("UTF-8")));
+ const size_t length = Env->GetArrayLength(bytesObject);
+ const jbyte* const bytes = Env->GetByteArrayElements(bytesObject, nullptr);
+ _native_library_path = std::string(reinterpret_cast<const char*>(bytes), length);
_initialized = true;
return XR_SUCCESS;
}
@@ -109,6 +142,10 @@ XrResult InitializeLoader(const XrLoaderInitInfoBaseHeaderKHR* loaderInitInfo) {
return LoaderInitData::instance().initialize(loaderInitInfo);
}
+std::string GetAndroidNativeLibraryDir() { return LoaderInitData::instance()._native_library_path; }
+
+void* Android_Get_Asset_Manager() { return LoaderInitData::instance()._android_asset_manager; }
+
#endif // XR_KHR_LOADER_INIT_SUPPORT
#ifdef XR_USE_PLATFORM_ANDROID
diff --git a/thirdparty/openxr/src/loader/runtime_interface.hpp b/thirdparty/openxr/src/loader/runtime_interface.hpp
index 5f49b28abe..fa53ee03f2 100644
--- a/thirdparty/openxr/src/loader/runtime_interface.hpp
+++ b/thirdparty/openxr/src/loader/runtime_interface.hpp
@@ -31,6 +31,8 @@ class Value;
//! Initialize loader, where required.
XrResult InitializeLoader(const XrLoaderInitInfoBaseHeaderKHR* loaderInitInfo);
XrResult GetPlatformRuntimeVirtualManifest(Json::Value& out_manifest);
+std::string GetAndroidNativeLibraryDir();
+void* Android_Get_Asset_Manager();
#endif
class RuntimeManifestFile;