From c8d64e8580da5bf53ccbb5790389b310d3d68e2d Mon Sep 17 00:00:00 2001 From: kobewi Date: Sun, 7 May 2023 02:32:20 +0200 Subject: Fix another collision shape editor crash (cherry picked from commit 01c32dffafddd52e65b8413034b2f5283523da92) --- editor/plugins/collision_shape_2d_editor_plugin.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/editor/plugins/collision_shape_2d_editor_plugin.cpp b/editor/plugins/collision_shape_2d_editor_plugin.cpp index 0aef364c2d..204d783df1 100644 --- a/editor/plugins/collision_shape_2d_editor_plugin.cpp +++ b/editor/plugins/collision_shape_2d_editor_plugin.cpp @@ -436,7 +436,7 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla switch (shape_type) { case CAPSULE_SHAPE: { - Ref shape = node->get_shape(); + Ref shape = current_shape; handles.resize(2); float radius = shape->get_radius(); @@ -451,7 +451,7 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla } break; case CIRCLE_SHAPE: { - Ref shape = node->get_shape(); + Ref shape = current_shape; handles.resize(1); handles.write[0] = Point2(shape->get_radius(), 0); @@ -467,7 +467,7 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla } break; case WORLD_BOUNDARY_SHAPE: { - Ref shape = node->get_shape(); + Ref shape = current_shape; handles.resize(2); handles.write[0] = shape->get_normal() * shape->get_distance(); @@ -479,7 +479,7 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla } break; case SEPARATION_RAY_SHAPE: { - Ref shape = node->get_shape(); + Ref shape = current_shape; handles.resize(1); handles.write[0] = Point2(0, shape->get_length()); @@ -489,7 +489,7 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla } break; case RECTANGLE_SHAPE: { - Ref shape = node->get_shape(); + Ref shape = current_shape; handles.resize(8); Vector2 ext = shape->get_size() / 2; @@ -501,7 +501,7 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla } break; case SEGMENT_SHAPE: { - Ref shape = node->get_shape(); + Ref shape = current_shape; handles.resize(2); handles.write[0] = shape->get_a(); -- cgit v1.2.3 From 0c312c7a08cfc807de809ba281553927209b9a79 Mon Sep 17 00:00:00 2001 From: "K. S. Ernest (iFire) Lee" Date: Mon, 13 Mar 2023 07:13:25 -0700 Subject: Fix CSG edge case causing intersection line to hit on common edge of 2 triangles. The previous implementation assumed that the intersection entered or exited a shape when it hit right on the common edge of 2 triangles. However, there is also a case where it just "skirts" the other shape on the outside. To fix this, we added code to check the intersection distance and if the normals of the faces are pointed in the same direction as the intersection or not (e.g. inner product > 0). This handles the case where the intersection line hits the common edge of 2 triangles and skirts the other shape on the outside. Extended code to cover a third case. Fixes #58637. Co-authored-by: OldBelge (cherry picked from commit eaa84bc682dfb7f1f97970c7f4dfd4c6e63ba681) --- modules/csg/csg.cpp | 80 ++++++++++++++++++++++++++++------ modules/csg/csg.h | 13 +++++- modules/csg/csg_shape.cpp | 2 +- modules/csg/doc_classes/CSGShape3D.xml | 2 +- 4 files changed, 80 insertions(+), 17 deletions(-) diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp index dee95d1ac5..a8ae4cfa5e 100644 --- a/modules/csg/csg.cpp +++ b/modules/csg/csg.cpp @@ -526,17 +526,19 @@ int CSGBrushOperation::MeshMerge::_create_bvh(FaceBVH *facebvhptr, FaceBVH **fac return index; } -void CSGBrushOperation::MeshMerge::_add_distance(List &r_intersectionsA, List &r_intersectionsB, bool p_from_B, real_t p_distance) const { - List &intersections = p_from_B ? r_intersectionsB : r_intersectionsA; +void CSGBrushOperation::MeshMerge::_add_distance(List &r_intersectionsA, List &r_intersectionsB, bool p_from_B, real_t p_distance_squared, bool p_is_conormal) const { + List &intersections = p_from_B ? r_intersectionsB : r_intersectionsA; // Check if distance exists. - for (const real_t E : intersections) { - if (Math::is_equal_approx(E, p_distance)) { + for (const IntersectionDistance E : intersections) { + if (E.is_conormal == p_is_conormal && Math::is_equal_approx(E.distance_squared, p_distance_squared)) { return; } } - - intersections.push_back(p_distance); + IntersectionDistance IntersectionDistance; + IntersectionDistance.is_conormal = p_is_conormal; + IntersectionDistance.distance_squared = p_distance_squared; + intersections.push_back(IntersectionDistance); } bool CSGBrushOperation::MeshMerge::_bvh_inside(FaceBVH *facebvhptr, int p_max_depth, int p_bvh_first, int p_face_idx) const { @@ -561,8 +563,11 @@ bool CSGBrushOperation::MeshMerge::_bvh_inside(FaceBVH *facebvhptr, int p_max_de VISITED_BIT_MASK = ~NODE_IDX_MASK }; - List intersectionsA; - List intersectionsB; + List intersectionsA; + List intersectionsB; + + Intersection closest_intersection; + closest_intersection.found = false; int level = 0; int pos = p_bvh_first; @@ -587,17 +592,61 @@ bool CSGBrushOperation::MeshMerge::_bvh_inside(FaceBVH *facebvhptr, int p_max_de }; Vector3 current_normal = Plane(current_points[0], current_points[1], current_points[2]).normal; Vector3 intersection_point; - // Check if faces are co-planar. if (current_normal.is_equal_approx(face_normal) && is_point_in_triangle(face_center, current_points)) { // Only add an intersection if not a B face. if (!face.from_b) { - _add_distance(intersectionsA, intersectionsB, current_face.from_b, 0); + _add_distance(intersectionsA, intersectionsB, current_face.from_b, 0, true); } } else if (ray_intersects_triangle(face_center, face_normal, current_points, CMP_EPSILON, intersection_point)) { - real_t distance = face_center.distance_to(intersection_point); - _add_distance(intersectionsA, intersectionsB, current_face.from_b, distance); + real_t distance_squared = face_center.distance_squared_to(intersection_point); + real_t inner = current_normal.dot(face_normal); + // If the faces are perpendicular, ignore this face. + // The triangles on the side should be intersected and result in the correct behavior. + if (!Math::is_zero_approx(inner)) { + _add_distance(intersectionsA, intersectionsB, current_face.from_b, distance_squared, inner > 0.0f); + } + } + + if (face.from_b != current_face.from_b) { + if (current_normal.is_equal_approx(face_normal) && + is_point_in_triangle(face_center, current_points)) { + // Only add an intersection if not a B face. + if (!face.from_b) { + closest_intersection.found = true; + closest_intersection.conormal = 1.0f; + closest_intersection.distance_squared = 0.0f; + closest_intersection.origin_angle = -FLT_MAX; + } + } else if (ray_intersects_triangle(face_center, face_normal, current_points, CMP_EPSILON, intersection_point)) { + Intersection potential_intersection; + potential_intersection.found = true; + potential_intersection.conormal = face_normal.dot(current_normal); + potential_intersection.distance_squared = face_center.distance_squared_to(intersection_point); + potential_intersection.origin_angle = Math::abs(potential_intersection.conormal); + real_t intersection_dist_from_face = face_normal.dot(intersection_point - face_center); + for (int i = 0; i < 3; i++) { + real_t point_dist_from_face = face_normal.dot(current_points[i] - face_center); + if (!Math::is_equal_approx(point_dist_from_face, intersection_dist_from_face) && + point_dist_from_face < intersection_dist_from_face) { + potential_intersection.origin_angle = -potential_intersection.origin_angle; + break; + } + } + if (potential_intersection.conormal != 0.0f) { + if (!closest_intersection.found) { + closest_intersection = potential_intersection; + } else if (!Math::is_equal_approx(potential_intersection.distance_squared, closest_intersection.distance_squared) && + potential_intersection.distance_squared < closest_intersection.distance_squared) { + closest_intersection = potential_intersection; + } else if (Math::is_equal_approx(potential_intersection.distance_squared, closest_intersection.distance_squared)) { + if (potential_intersection.origin_angle < closest_intersection.origin_angle) { + closest_intersection = potential_intersection; + } + } + } + } } } @@ -652,8 +701,11 @@ bool CSGBrushOperation::MeshMerge::_bvh_inside(FaceBVH *facebvhptr, int p_max_de } } - // Inside if face normal intersects other faces an odd number of times. - return (intersectionsA.size() + intersectionsB.size()) & 1; + if (!closest_intersection.found) { + return false; + } else { + return closest_intersection.conormal > 0.0f; + } } void CSGBrushOperation::MeshMerge::mark_inside_faces() { diff --git a/modules/csg/csg.h b/modules/csg/csg.h index 1513a01f9e..473a23e39f 100644 --- a/modules/csg/csg.h +++ b/modules/csg/csg.h @@ -135,6 +135,17 @@ struct CSGBrushOperation { return h; } }; + struct Intersection { + bool found = false; + real_t conormal = FLT_MAX; + real_t distance_squared = FLT_MAX; + real_t origin_angle = FLT_MAX; + }; + + struct IntersectionDistance { + bool is_conormal; + real_t distance_squared; + }; Vector points; Vector faces; @@ -143,7 +154,7 @@ struct CSGBrushOperation { OAHashMap snap_cache; float vertex_snap = 0.0; - inline void _add_distance(List &r_intersectionsA, List &r_intersectionsB, bool p_from_B, real_t p_distance) const; + inline void _add_distance(List &r_intersectionsA, List &r_intersectionsB, bool p_from_B, real_t p_distance, bool p_is_conormal) const; inline bool _bvh_inside(FaceBVH *facebvhptr, int p_max_depth, int p_bvh_first, int p_face_idx) const; inline int _create_bvh(FaceBVH *facebvhptr, FaceBVH **facebvhptrptr, int p_from, int p_size, int p_depth, int &r_max_depth, int &r_max_alloc); diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index afb8e62eea..ba0d49c993 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -653,7 +653,7 @@ void CSGShape3D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_meshes"), &CSGShape3D::get_meshes); ADD_PROPERTY(PropertyInfo(Variant::INT, "operation", PROPERTY_HINT_ENUM, "Union,Intersection,Subtraction"), "set_operation", "get_operation"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "snap", PROPERTY_HINT_RANGE, "0.0001,1,0.001,suffix:m"), "set_snap", "get_snap"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "snap", PROPERTY_HINT_RANGE, "0.000001,1,0.000001,suffix:m"), "set_snap", "get_snap"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "calculate_tangents"), "set_calculate_tangents", "is_calculating_tangents"); ADD_GROUP("Collision", "collision_"); diff --git a/modules/csg/doc_classes/CSGShape3D.xml b/modules/csg/doc_classes/CSGShape3D.xml index 06f8f5a403..c29c3c789e 100644 --- a/modules/csg/doc_classes/CSGShape3D.xml +++ b/modules/csg/doc_classes/CSGShape3D.xml @@ -73,7 +73,7 @@ The operation that is performed on this shape. This is ignored for the first CSG child node as the operation is between this node and the previous child of this nodes parent. - Snap makes the mesh snap to a given distance so that the faces of two meshes can be perfectly aligned. A lower value results in greater precision but may be harder to adjust. + Snap makes the mesh vertices snap to a given distance so that the faces of two meshes can be perfectly aligned. A lower value results in greater precision but may be harder to adjust. Adds a collision shape to the physics engine for our CSG shape. This will always act like a static body. Note that the collision shape is still active even if the CSG shape itself is hidden. See also [member collision_mask] and [member collision_priority]. -- cgit v1.2.3 From 268b60ddd6843dc5468a7951b3910084cd435ae3 Mon Sep 17 00:00:00 2001 From: Justin Wash Date: Thu, 27 Apr 2023 17:16:42 -0500 Subject: Fix infinite loop in Build2DFaces::_find_edge_intersections (cherry picked from commit 1ac2c537da86bd9a9234954dd4ba67e32c1b0d3a) --- modules/csg/csg.cpp | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp index a8ae4cfa5e..0bd8e5d9ad 100644 --- a/modules/csg/csg.cpp +++ b/modules/csg/csg.cpp @@ -1068,6 +1068,8 @@ void CSGBrushOperation::Build2DFaces::_merge_faces(const Vector &p_segment_ } void CSGBrushOperation::Build2DFaces::_find_edge_intersections(const Vector2 p_segment_points[2], Vector &r_segment_indices) { + LocalVector> processed_edges; + // For each face. for (int face_idx = 0; face_idx < faces.size(); ++face_idx) { Face2D face = faces[face_idx]; @@ -1079,17 +1081,32 @@ void CSGBrushOperation::Build2DFaces::_find_edge_intersections(const Vector2 p_s // Check each edge. for (int face_edge_idx = 0; face_edge_idx < 3; ++face_edge_idx) { - Vector2 edge_points[2] = { + Vector edge_points_and_uvs = { face_vertices[face_edge_idx].point, - face_vertices[(face_edge_idx + 1) % 3].point - }; - Vector2 edge_uvs[2] = { + face_vertices[(face_edge_idx + 1) % 3].point, face_vertices[face_edge_idx].uv, face_vertices[(face_edge_idx + 1) % 3].uv }; - Vector2 intersection_point; + + Vector2 edge_points[2] = { + edge_points_and_uvs[0], + edge_points_and_uvs[1], + }; + Vector2 edge_uvs[2] = { + edge_points_and_uvs[2], + edge_points_and_uvs[3], + }; + + // Check if edge has already been processed. + if (processed_edges.find(edge_points_and_uvs) != -1) { + continue; + } + + processed_edges.push_back(edge_points_and_uvs); // First check if the ends of the segment are on the edge. + Vector2 intersection_point; + bool on_edge = false; for (int edge_point_idx = 0; edge_point_idx < 2; ++edge_point_idx) { intersection_point = Geometry2D::get_closest_point_to_segment(p_segment_points[edge_point_idx], edge_points); -- cgit v1.2.3 From ebaf3cc9abb66bb4060c1b90311e237b82bedc74 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Thu, 27 Apr 2023 19:04:12 +0300 Subject: [iOS] Fix loading of GDExtension dylibs auto converted to framework. (cherry picked from commit ad4d565ee7c16652d1c391e339f16fd6966fd21b) --- platform/ios/os_ios.mm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/platform/ios/os_ios.mm b/platform/ios/os_ios.mm index 4d2dd3c52c..ac2d40c607 100644 --- a/platform/ios/os_ios.mm +++ b/platform/ios/os_ios.mm @@ -239,11 +239,21 @@ Error OS_IOS::open_dynamic_library(const String p_path, void *&p_library_handle, path = get_framework_executable(get_executable_path().get_base_dir().path_join(p_path.get_file())); } + if (!FileAccess::exists(path)) { + // Load .dylib converted to framework from within the executable path. + path = get_framework_executable(get_executable_path().get_base_dir().path_join(p_path.get_file().get_basename() + ".framework")); + } + if (!FileAccess::exists(path)) { // Load .dylib or framework from a standard iOS location. path = get_framework_executable(get_executable_path().get_base_dir().path_join("Frameworks").path_join(p_path.get_file())); } + if (!FileAccess::exists(path)) { + // Load .dylib converted to framework from a standard iOS location. + path = get_framework_executable(get_executable_path().get_base_dir().path_join("Frameworks").path_join(p_path.get_file().get_basename() + ".framework")); + } + p_library_handle = dlopen(path.utf8().get_data(), RTLD_NOW); ERR_FAIL_COND_V_MSG(!p_library_handle, ERR_CANT_OPEN, "Can't open dynamic library: " + p_path + ", error: " + dlerror() + "."); -- cgit v1.2.3 From 2a0597d0cbe1f3e98803a431d28a58d0590d74ae Mon Sep 17 00:00:00 2001 From: Lyuma Date: Thu, 27 Apr 2023 01:41:28 -0700 Subject: import: Fix Silhouette used incorrect index. Fixes bind pose mistake from using i (mesh skin index) instead of bone_idx (skeleton bone index). Fixes #76448 (cherry picked from commit d33a734ac51f57043586fda058314075271527be) --- editor/import/post_import_plugin_skeleton_rest_fixer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/import/post_import_plugin_skeleton_rest_fixer.cpp b/editor/import/post_import_plugin_skeleton_rest_fixer.cpp index e105135c11..6214a2b70d 100644 --- a/editor/import/post_import_plugin_skeleton_rest_fixer.cpp +++ b/editor/import/post_import_plugin_skeleton_rest_fixer.cpp @@ -669,7 +669,7 @@ void PostImportPluginSkeletonRestFixer::internal_process(InternalImportCategory StringName bn = skin->get_bind_name(i); int bone_idx = src_skeleton->find_bone(bn); if (bone_idx >= 0) { - Transform3D new_rest = silhouette_diff[i] * src_skeleton->get_bone_global_rest(bone_idx); + Transform3D new_rest = silhouette_diff[bone_idx] * src_skeleton->get_bone_global_rest(bone_idx); skin->set_bind_pose(i, new_rest.inverse() * ibm_diff[bone_idx]); } } -- cgit v1.2.3 From 9d257f10c0b6d180c88dc43aa76db2fe83e2ca29 Mon Sep 17 00:00:00 2001 From: clayjohn Date: Thu, 27 Apr 2023 10:54:25 -0700 Subject: Use DXT1 when compressing PNGs with RGB format This results in much smaller file sizes with the same quality (cherry picked from commit f84c6df8d1aec35fe53521f241b26fc5312d26e3) --- modules/etcpak/image_compress_etcpak.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/etcpak/image_compress_etcpak.cpp b/modules/etcpak/image_compress_etcpak.cpp index 16a59d3880..14cce2686c 100644 --- a/modules/etcpak/image_compress_etcpak.cpp +++ b/modules/etcpak/image_compress_etcpak.cpp @@ -66,7 +66,7 @@ EtcpakType _determine_dxt_type(Image::UsedChannels p_channels) { case Image::USED_CHANNELS_RG: return EtcpakType::ETCPAK_TYPE_DXT5_RA_AS_RG; case Image::USED_CHANNELS_RGB: - return EtcpakType::ETCPAK_TYPE_DXT5; + return EtcpakType::ETCPAK_TYPE_DXT1; case Image::USED_CHANNELS_RGBA: return EtcpakType::ETCPAK_TYPE_DXT5; default: -- cgit v1.2.3 From e58001bd0d2eee1b174a0d8bd21ea18f97f25778 Mon Sep 17 00:00:00 2001 From: Tefatika <692720+Tefatika@users.noreply.github.com> Date: Fri, 28 Apr 2023 02:03:35 +0200 Subject: Command Palette search now also uses original English command names Both localized and non localized names will be used while filtering The highest score between the two will be picked when determining the entries order (cherry picked from commit 09460cfaaf6524143b482c3082566f05ef227389) --- editor/editor_command_palette.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/editor/editor_command_palette.cpp b/editor/editor_command_palette.cpp index 1c598277dd..eb35eddeb1 100644 --- a/editor/editor_command_palette.cpp +++ b/editor/editor_command_palette.cpp @@ -75,9 +75,15 @@ void EditorCommandPalette::_update_command_search(const String &search_text) { r.shortcut_text = E.value.shortcut; r.last_used = E.value.last_used; - if (search_text.is_subsequence_ofn(r.display_name)) { + bool is_subsequence_of_key_name = search_text.is_subsequence_ofn(r.key_name); + bool is_subsequence_of_display_name = search_text.is_subsequence_ofn(r.display_name); + + if (is_subsequence_of_key_name || is_subsequence_of_display_name) { if (!search_text.is_empty()) { - r.score = _score_path(search_text, r.display_name.to_lower()); + float key_name_score = is_subsequence_of_key_name ? _score_path(search_text, r.key_name.to_lower()) : .0f; + float display_name_score = is_subsequence_of_display_name ? _score_path(search_text, r.display_name.to_lower()) : .0f; + + r.score = MAX(key_name_score, display_name_score); } entries.push_back(r); -- cgit v1.2.3 From b532dd7626be320a83148de8e6c4469ee24391ca Mon Sep 17 00:00:00 2001 From: Tefatika <692720+Tefatika@users.noreply.github.com> Date: Sun, 30 Apr 2023 00:11:58 +0200 Subject: Fixed error messages when setting all_tab_in_front of TabContainer Some signal handlers weren't unregistered when removing the wrapped child TabBar, which resulted in errors printed when the TabBar was removed and added again when the flag was updated (cherry picked from commit abd894daf794828986b9450cf7d0ef50d37dab06) --- scene/gui/tab_container.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index 208cb29772..c5f7500380 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -547,12 +547,12 @@ void TabContainer::add_child_notify(Node *p_child) { } void TabContainer::move_child_notify(Node *p_child) { + Container::move_child_notify(p_child); + if (p_child == tab_bar) { return; } - Container::move_child_notify(p_child); - Control *c = Object::cast_to(p_child); if (c && !c->is_set_as_top_level()) { int old_idx = -1; @@ -571,12 +571,12 @@ void TabContainer::move_child_notify(Node *p_child) { } void TabContainer::remove_child_notify(Node *p_child) { + Container::remove_child_notify(p_child); + if (p_child == tab_bar) { return; } - Container::remove_child_notify(p_child); - Control *c = Object::cast_to(p_child); if (!c || c->is_set_as_top_level()) { return; -- cgit v1.2.3 From 70f7fcd208213d052720ce5b80a4249f4c051592 Mon Sep 17 00:00:00 2001 From: VolTer Date: Sat, 29 Oct 2022 22:15:27 +0200 Subject: Light3D show scaling warning immediately (cherry picked from commit 818d57b5b4f01ffc05968a3a1a2d210683c56d0a) --- scene/2d/physics_body_2d.cpp | 4 +--- scene/3d/collision_object_3d.cpp | 6 +----- scene/3d/collision_polygon_3d.cpp | 6 +----- scene/3d/collision_shape_3d.cpp | 6 +----- scene/3d/light_3d.cpp | 3 +++ scene/3d/physics_body_3d.cpp | 4 +--- 6 files changed, 8 insertions(+), 21 deletions(-) diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index ba361c2656..4c1f6499ab 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -907,9 +907,7 @@ void RigidBody2D::_notification(int p_what) { } break; case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: { - if (Engine::get_singleton()->is_editor_hint()) { - update_configuration_warnings(); - } + update_configuration_warnings(); } break; } #endif diff --git a/scene/3d/collision_object_3d.cpp b/scene/3d/collision_object_3d.cpp index 19d1b83cab..6d8d60dcaa 100644 --- a/scene/3d/collision_object_3d.cpp +++ b/scene/3d/collision_object_3d.cpp @@ -83,13 +83,9 @@ void CollisionObject3D::_notification(int p_what) { _update_pickable(); } break; -#ifdef TOOLS_ENABLED case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: { - if (Engine::get_singleton()->is_editor_hint()) { - update_configuration_warnings(); - } + update_configuration_warnings(); } break; -#endif case NOTIFICATION_TRANSFORM_CHANGED: { if (only_update_transform_changes) { diff --git a/scene/3d/collision_polygon_3d.cpp b/scene/3d/collision_polygon_3d.cpp index 53a61c1368..9a2ed00274 100644 --- a/scene/3d/collision_polygon_3d.cpp +++ b/scene/3d/collision_polygon_3d.cpp @@ -104,11 +104,7 @@ void CollisionPolygon3D::_notification(int p_what) { if (parent) { _update_in_shape_owner(true); } -#ifdef TOOLS_ENABLED - if (Engine::get_singleton()->is_editor_hint()) { - update_configuration_warnings(); - } -#endif + update_configuration_warnings(); } break; case NOTIFICATION_UNPARENTED: { diff --git a/scene/3d/collision_shape_3d.cpp b/scene/3d/collision_shape_3d.cpp index f1d918ad9b..b7f3b12c25 100644 --- a/scene/3d/collision_shape_3d.cpp +++ b/scene/3d/collision_shape_3d.cpp @@ -99,11 +99,7 @@ void CollisionShape3D::_notification(int p_what) { if (parent) { _update_in_shape_owner(true); } -#ifdef TOOLS_ENABLED - if (Engine::get_singleton()->is_editor_hint()) { - update_configuration_warnings(); - } -#endif + update_configuration_warnings(); } break; case NOTIFICATION_UNPARENTED: { diff --git a/scene/3d/light_3d.cpp b/scene/3d/light_3d.cpp index 16c82bf6d2..18198b566e 100644 --- a/scene/3d/light_3d.cpp +++ b/scene/3d/light_3d.cpp @@ -284,6 +284,9 @@ void Light3D::_update_visibility() { void Light3D::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_TRANSFORM_CHANGED: { + update_configuration_warnings(); + } break; case NOTIFICATION_VISIBILITY_CHANGED: case NOTIFICATION_ENTER_TREE: { _update_visibility(); diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp index 89bb1b5c65..9de9444fb6 100644 --- a/scene/3d/physics_body_3d.cpp +++ b/scene/3d/physics_body_3d.cpp @@ -599,9 +599,7 @@ void RigidBody3D::_notification(int p_what) { } break; case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: { - if (Engine::get_singleton()->is_editor_hint()) { - update_configuration_warnings(); - } + update_configuration_warnings(); } break; } #endif -- cgit v1.2.3 From a07ad181ab71e374082fa37cea6b399bd4c8092d Mon Sep 17 00:00:00 2001 From: HolonProduction Date: Sun, 30 Apr 2023 13:33:43 +0200 Subject: Preserve scene unique names when saving branch as scene. (cherry picked from commit 7814dedc91a9df70a6c873d0ad30f444c401b0ec) --- editor/scene_tree_dock.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index d8f1d92e44..f1e1136c83 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -275,6 +275,8 @@ void SceneTreeDock::_replace_with_branch_scene(const String &p_file, Node *base) return; } + instantiated_scene->set_unique_name_in_owner(base->is_unique_name_in_owner()); + EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); undo_redo->create_action(TTR("Replace with Branch Scene")); -- cgit v1.2.3 From e68e2fad25eaba112bee37234be89d1bb5829869 Mon Sep 17 00:00:00 2001 From: Tetane Date: Fri, 28 Apr 2023 20:10:04 +0200 Subject: Use a SubViewport for CanvasItem inspector preview (cherry picked from commit d3792a237331f56efdb36b1753f171ddc99629db) --- editor/plugins/material_editor_plugin.cpp | 12 +++++++++++- editor/plugins/material_editor_plugin.h | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index 36c143ca8d..32d237e411 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -157,9 +157,19 @@ void MaterialEditor::_button_pressed(Node *p_button) { MaterialEditor::MaterialEditor() { // canvas item + vc_2d = memnew(SubViewportContainer); + vc_2d->set_stretch(true); + add_child(vc_2d); + vc_2d->set_anchors_and_offsets_preset(PRESET_FULL_RECT); + + viewport_2d = memnew(SubViewport); + vc_2d->add_child(viewport_2d); + viewport_2d->set_disable_input(true); + viewport_2d->set_transparent_background(true); + layout_2d = memnew(HBoxContainer); layout_2d->set_alignment(BoxContainer::ALIGNMENT_CENTER); - add_child(layout_2d); + viewport_2d->add_child(layout_2d); layout_2d->set_anchors_and_offsets_preset(PRESET_FULL_RECT); rect_instance = memnew(ColorRect); diff --git a/editor/plugins/material_editor_plugin.h b/editor/plugins/material_editor_plugin.h index 63ee053b1d..7a610d860c 100644 --- a/editor/plugins/material_editor_plugin.h +++ b/editor/plugins/material_editor_plugin.h @@ -50,6 +50,8 @@ class MaterialEditor : public Control { Vector2 rot; + SubViewportContainer *vc_2d = nullptr; + SubViewport *viewport_2d = nullptr; HBoxContainer *layout_2d = nullptr; ColorRect *rect_instance = nullptr; -- cgit v1.2.3 From 2435c9426d3b5aba64f2aafffe1d5fc8fa06d5a7 Mon Sep 17 00:00:00 2001 From: clayjohn Date: Wed, 3 May 2023 01:06:34 -0700 Subject: Use proper UV in cubemap downsampler raster This removes bias in cubemap downsampling shader that resulted in the bottom of cubemaps being over represented (cherry picked from commit fb77021559c42d5512f12baa07dcf94c47b7ab15) --- .../effects/cubemap_downsampler_raster.glsl | 204 ++++++++++----------- 1 file changed, 101 insertions(+), 103 deletions(-) diff --git a/servers/rendering/renderer_rd/shaders/effects/cubemap_downsampler_raster.glsl b/servers/rendering/renderer_rd/shaders/effects/cubemap_downsampler_raster.glsl index 0828ffd921..b8c64d09f4 100644 --- a/servers/rendering/renderer_rd/shaders/effects/cubemap_downsampler_raster.glsl +++ b/servers/rendering/renderer_rd/shaders/effects/cubemap_downsampler_raster.glsl @@ -55,109 +55,107 @@ void main() { // Converted from compute shader which uses absolute coordinates. // Could possibly simplify this float face_size = float(params.face_size); + float inv_face_size = 1.0 / face_size; + vec2 id = floor(uv_interp); - if (uv_interp.x < face_size && uv_interp.y < face_size) { - float inv_face_size = 1.0 / face_size; - - float u0 = (uv_interp.x * 2.0 + 1.0 - 0.75) * inv_face_size - 1.0; - float u1 = (uv_interp.x * 2.0 + 1.0 + 0.75) * inv_face_size - 1.0; - - float v0 = (uv_interp.y * 2.0 + 1.0 - 0.75) * -inv_face_size + 1.0; - float v1 = (uv_interp.y * 2.0 + 1.0 + 0.75) * -inv_face_size + 1.0; - - float weights[4]; - weights[0] = calcWeight(u0, v0); - weights[1] = calcWeight(u1, v0); - weights[2] = calcWeight(u0, v1); - weights[3] = calcWeight(u1, v1); - - const float wsum = 0.5 / (weights[0] + weights[1] + weights[2] + weights[3]); - for (int i = 0; i < 4; i++) { - weights[i] = weights[i] * wsum + .125; - } - - vec3 dir; - vec4 color; - switch (params.face_id) { - case 0: - get_dir_0(dir, u0, v0); - color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0]; - - get_dir_0(dir, u1, v0); - color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1]; - - get_dir_0(dir, u0, v1); - color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2]; - - get_dir_0(dir, u1, v1); - color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3]; - break; - case 1: - get_dir_1(dir, u0, v0); - color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0]; - - get_dir_1(dir, u1, v0); - color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1]; - - get_dir_1(dir, u0, v1); - color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2]; - - get_dir_1(dir, u1, v1); - color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3]; - break; - case 2: - get_dir_2(dir, u0, v0); - color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0]; - - get_dir_2(dir, u1, v0); - color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1]; - - get_dir_2(dir, u0, v1); - color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2]; - - get_dir_2(dir, u1, v1); - color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3]; - break; - case 3: - get_dir_3(dir, u0, v0); - color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0]; - - get_dir_3(dir, u1, v0); - color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1]; - - get_dir_3(dir, u0, v1); - color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2]; - - get_dir_3(dir, u1, v1); - color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3]; - break; - case 4: - get_dir_4(dir, u0, v0); - color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0]; - - get_dir_4(dir, u1, v0); - color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1]; - - get_dir_4(dir, u0, v1); - color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2]; - - get_dir_4(dir, u1, v1); - color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3]; - break; - default: - get_dir_5(dir, u0, v0); - color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0]; - - get_dir_5(dir, u1, v0); - color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1]; - - get_dir_5(dir, u0, v1); - color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2]; - - get_dir_5(dir, u1, v1); - color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3]; - break; - } - frag_color = color; + float u1 = (id.x * 2.0 + 1.0 + 0.75) * inv_face_size - 1.0; + float u0 = (id.x * 2.0 + 1.0 - 0.75) * inv_face_size - 1.0; + + float v0 = (id.y * 2.0 + 1.0 - 0.75) * -inv_face_size + 1.0; + float v1 = (id.y * 2.0 + 1.0 + 0.75) * -inv_face_size + 1.0; + + float weights[4]; + weights[0] = calcWeight(u0, v0); + weights[1] = calcWeight(u1, v0); + weights[2] = calcWeight(u0, v1); + weights[3] = calcWeight(u1, v1); + + const float wsum = 0.5 / (weights[0] + weights[1] + weights[2] + weights[3]); + for (int i = 0; i < 4; i++) { + weights[i] = weights[i] * wsum + .125; + } + + vec3 dir; + vec4 color; + switch (params.face_id) { + case 0: + get_dir_0(dir, u0, v0); + color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0]; + + get_dir_0(dir, u1, v0); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1]; + + get_dir_0(dir, u0, v1); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2]; + + get_dir_0(dir, u1, v1); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3]; + break; + case 1: + get_dir_1(dir, u0, v0); + color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0]; + + get_dir_1(dir, u1, v0); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1]; + + get_dir_1(dir, u0, v1); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2]; + + get_dir_1(dir, u1, v1); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3]; + break; + case 2: + get_dir_2(dir, u0, v0); + color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0]; + + get_dir_2(dir, u1, v0); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1]; + + get_dir_2(dir, u0, v1); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2]; + + get_dir_2(dir, u1, v1); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3]; + break; + case 3: + get_dir_3(dir, u0, v0); + color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0]; + + get_dir_3(dir, u1, v0); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1]; + + get_dir_3(dir, u0, v1); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2]; + + get_dir_3(dir, u1, v1); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3]; + break; + case 4: + get_dir_4(dir, u0, v0); + color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0]; + + get_dir_4(dir, u1, v0); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1]; + + get_dir_4(dir, u0, v1); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2]; + + get_dir_4(dir, u1, v1); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3]; + break; + default: + get_dir_5(dir, u0, v0); + color = textureLod(source_cubemap, normalize(dir), 0.0) * weights[0]; + + get_dir_5(dir, u1, v0); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[1]; + + get_dir_5(dir, u0, v1); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[2]; + + get_dir_5(dir, u1, v1); + color += textureLod(source_cubemap, normalize(dir), 0.0) * weights[3]; + break; } + frag_color = color; } -- cgit v1.2.3 From 907b10fb96cacc5817330f7f3f92f0f8e3f97c01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Fri, 28 Apr 2023 12:49:11 +0200 Subject: Fix additional cases of breakage of rendering effects (cherry picked from commit c58e50adccf5476dbc661cb2d0f807e419a9e586) --- servers/rendering/renderer_rd/environment/fog.cpp | 50 ++++++++++++++-------- servers/rendering/renderer_rd/environment/fog.h | 13 +----- servers/rendering/renderer_rd/environment/gi.cpp | 14 ------ .../renderer_rd/storage_rd/light_storage.h | 10 ++--- 4 files changed, 40 insertions(+), 47 deletions(-) diff --git a/servers/rendering/renderer_rd/environment/fog.cpp b/servers/rendering/renderer_rd/environment/fog.cpp index 57da55db4d..78b785153f 100644 --- a/servers/rendering/renderer_rd/environment/fog.cpp +++ b/servers/rendering/renderer_rd/environment/fog.cpp @@ -388,6 +388,37 @@ Fog::FogShaderData::~FogShaderData() { //////////////////////////////////////////////////////////////////////////////// // Volumetric Fog +bool Fog::VolumetricFog::sync_gi_dependent_sets_validity(bool p_ensure_freed) { + bool null = gi_dependent_sets.copy_uniform_set.is_null(); + bool valid = !null && RD::get_singleton()->uniform_set_is_valid(gi_dependent_sets.copy_uniform_set); + +#ifdef DEV_ENABLED + // It's all-or-nothing, or something else has changed that requires dev attention. + DEV_ASSERT(null == gi_dependent_sets.process_uniform_set_density.is_null()); + DEV_ASSERT(null == gi_dependent_sets.process_uniform_set.is_null()); + DEV_ASSERT(null == gi_dependent_sets.process_uniform_set2.is_null()); + DEV_ASSERT(valid == RD::get_singleton()->uniform_set_is_valid(gi_dependent_sets.process_uniform_set_density)); + DEV_ASSERT(valid == RD::get_singleton()->uniform_set_is_valid(gi_dependent_sets.process_uniform_set)); + DEV_ASSERT(valid == RD::get_singleton()->uniform_set_is_valid(gi_dependent_sets.process_uniform_set2)); +#endif + + if (valid) { + if (p_ensure_freed) { + RD::get_singleton()->free(gi_dependent_sets.copy_uniform_set); + RD::get_singleton()->free(gi_dependent_sets.process_uniform_set_density); + RD::get_singleton()->free(gi_dependent_sets.process_uniform_set); + RD::get_singleton()->free(gi_dependent_sets.process_uniform_set2); + valid = false; + } + } + + if (!valid && !null) { + gi_dependent_sets = {}; + } + + return valid; +} + void Fog::VolumetricFog::init(const Vector3i &fog_size, RID p_sky_shader) { width = fog_size.x; height = fog_size.y; @@ -464,17 +495,7 @@ Fog::VolumetricFog::~VolumetricFog() { RD::get_singleton()->free(fog_uniform_set); } - // At this point, due to cascade deletions, the sets may no longer be valid, but still they must work as a group. - gi_dependent_sets.valid = RD::get_singleton()->uniform_set_is_valid(gi_dependent_sets.process_uniform_set_density); -#ifdef DEV_ENABLED - gi_dependent_sets.assert_actual_validity(); -#endif - if (gi_dependent_sets.valid) { - RD::get_singleton()->free(gi_dependent_sets.copy_uniform_set); - RD::get_singleton()->free(gi_dependent_sets.process_uniform_set_density); - RD::get_singleton()->free(gi_dependent_sets.process_uniform_set); - RD::get_singleton()->free(gi_dependent_sets.process_uniform_set2); - } + sync_gi_dependent_sets_validity(true); if (sdfgi_uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(sdfgi_uniform_set)) { RD::get_singleton()->free(sdfgi_uniform_set); @@ -717,10 +738,7 @@ void Fog::volumetric_fog_update(const VolumetricFogSettings &p_settings, const P RD::get_singleton()->compute_list_end(); } -#ifdef DEV_ENABLED - fog->gi_dependent_sets.assert_actual_validity(); -#endif - if (!fog->gi_dependent_sets.valid) { + if (!fog->sync_gi_dependent_sets_validity()) { //re create uniform set if needed Vector uniforms; Vector copy_uniforms; @@ -932,8 +950,6 @@ void Fog::volumetric_fog_update(const VolumetricFogSettings &p_settings, const P uniforms.remove_at(8); uniforms.write[7].set_id(0, aux7); fog->gi_dependent_sets.process_uniform_set_density = RD::get_singleton()->uniform_set_create(uniforms, volumetric_fog.process_shader.version_get_shader(volumetric_fog.process_shader_version, VolumetricFogShader::VOLUMETRIC_FOG_PROCESS_SHADER_DENSITY), 0); - - fog->gi_dependent_sets.valid = true; } bool using_sdfgi = RendererSceneRenderRD::get_singleton()->environment_get_volumetric_fog_gi_inject(p_settings.env) > 0.0001 && RendererSceneRenderRD::get_singleton()->environment_get_sdfgi_enabled(p_settings.env) && (p_settings.sdfgi.is_valid()); diff --git a/servers/rendering/renderer_rd/environment/fog.h b/servers/rendering/renderer_rd/environment/fog.h index 926da4026c..277389c596 100644 --- a/servers/rendering/renderer_rd/environment/fog.h +++ b/servers/rendering/renderer_rd/environment/fog.h @@ -303,21 +303,10 @@ public: RID fog_uniform_set; struct { - bool valid = false; RID copy_uniform_set; RID process_uniform_set_density; RID process_uniform_set; RID process_uniform_set2; - -#ifdef DEV_ENABLED - void assert_actual_validity() { - // It's all-or-nothing, or something else has changed that requires dev attention. - DEV_ASSERT(valid == RD::get_singleton()->uniform_set_is_valid(copy_uniform_set)); - DEV_ASSERT(valid == RD::get_singleton()->uniform_set_is_valid(process_uniform_set_density)); - DEV_ASSERT(valid == RD::get_singleton()->uniform_set_is_valid(process_uniform_set)); - DEV_ASSERT(valid == RD::get_singleton()->uniform_set_is_valid(process_uniform_set2)); - } -#endif } gi_dependent_sets; RID sdfgi_uniform_set; @@ -328,6 +317,8 @@ public: virtual void configure(RenderSceneBuffersRD *p_render_buffers) override{}; virtual void free_data() override{}; + bool sync_gi_dependent_sets_validity(bool p_ensure_freed = false); + void init(const Vector3i &fog_size, RID p_sky_shader); ~VolumetricFog(); }; diff --git a/servers/rendering/renderer_rd/environment/gi.cpp b/servers/rendering/renderer_rd/environment/gi.cpp index 52f09e1ccb..c2a018c7c6 100644 --- a/servers/rendering/renderer_rd/environment/gi.cpp +++ b/servers/rendering/renderer_rd/environment/gi.cpp @@ -3695,20 +3695,6 @@ void GI::setup_voxel_gi_instances(RenderDataRD *p_render_data, Refuniform_set[v] = RID(); } - if (p_render_buffers->has_custom_data(RB_SCOPE_FOG)) { - Ref fog = p_render_buffers->get_custom_data(RB_SCOPE_FOG); - -#ifdef DEV_ENABLED - fog->gi_dependent_sets.assert_actual_validity(); -#endif - if (fog->gi_dependent_sets.valid) { - RD::get_singleton()->free(fog->gi_dependent_sets.copy_uniform_set); - RD::get_singleton()->free(fog->gi_dependent_sets.process_uniform_set_density); - RD::get_singleton()->free(fog->gi_dependent_sets.process_uniform_set); - RD::get_singleton()->free(fog->gi_dependent_sets.process_uniform_set2); - fog->gi_dependent_sets.valid = false; - } - } } if (p_voxel_gi_instances.size() > 0) { diff --git a/servers/rendering/renderer_rd/storage_rd/light_storage.h b/servers/rendering/renderer_rd/storage_rd/light_storage.h index c36d1ef503..3360358169 100644 --- a/servers/rendering/renderer_rd/storage_rd/light_storage.h +++ b/servers/rendering/renderer_rd/storage_rd/light_storage.h @@ -93,11 +93,11 @@ private: struct ShadowTransform { Projection camera; Transform3D transform; - float farplane; - float split; - float bias_scale; - float shadow_texel_size; - float range_begin; + float farplane = 0.0; + float split = 0.0; + float bias_scale = 0.0; + float shadow_texel_size = 0.0; + float range_begin = 0.0; Rect2 atlas_rect; Vector2 uv_scale; }; -- cgit v1.2.3 From 0277f57b6fdeafb18478bd404b8c2610bedc60d1 Mon Sep 17 00:00:00 2001 From: kobewi Date: Mon, 1 May 2023 13:50:34 +0200 Subject: Some clarifications on screen-space coordinates (cherry picked from commit 33b9be27d39503897933726d1c5560e4ec271222) --- doc/classes/CanvasItem.xml | 1 + doc/classes/DisplayServer.xml | 2 +- doc/classes/Window.xml | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/classes/CanvasItem.xml b/doc/classes/CanvasItem.xml index 572963b406..d410dcb25a 100644 --- a/doc/classes/CanvasItem.xml +++ b/doc/classes/CanvasItem.xml @@ -423,6 +423,7 @@ Returns the mouse's position in the [CanvasLayer] that this [CanvasItem] is in using the coordinate system of the [CanvasLayer]. + [b]Note:[/b] For screen-space coordinates (e.g. when using a non-embedded [Popup]), you can use [method DisplayServer.mouse_get_position]. diff --git a/doc/classes/DisplayServer.xml b/doc/classes/DisplayServer.xml index 5e898de976..775bddcbe2 100644 --- a/doc/classes/DisplayServer.xml +++ b/doc/classes/DisplayServer.xml @@ -815,7 +815,7 @@ - Returns the mouse cursor's current position. + Returns the mouse cursor's current position in screen coordinates. diff --git a/doc/classes/Window.xml b/doc/classes/Window.xml index deef703e0d..fe025ff598 100644 --- a/doc/classes/Window.xml +++ b/doc/classes/Window.xml @@ -567,6 +567,7 @@ The window's position in pixels. + If [member ProjectSettings.display/window/subwindows/embed_subwindows] is [code]false[/code], the position is in absolute screen coordinates. This typically applies to editor plugins. If the setting is [code]false[/code], the window's position is in the coordinates of its parent [Viewport]. The window's size in pixels. -- cgit v1.2.3 From a5cb7a5eb5134957ccc9bff5b6a2f78aa54078d6 Mon Sep 17 00:00:00 2001 From: Bastiaan Olij Date: Fri, 31 Mar 2023 11:28:53 +1100 Subject: Expose viewports render targer RID (cherry picked from commit ab60d3b65ce990a44fe595ec0860c0ae9ce9358d) --- doc/classes/RenderingServer.xml | 7 +++++++ servers/rendering/renderer_viewport.cpp | 7 +++++++ servers/rendering/renderer_viewport.h | 1 + servers/rendering/rendering_server_default.h | 1 + servers/rendering_server.cpp | 1 + servers/rendering_server.h | 1 + 6 files changed, 18 insertions(+) diff --git a/doc/classes/RenderingServer.xml b/doc/classes/RenderingServer.xml index 08c1cc4bd3..05ac18c7fe 100644 --- a/doc/classes/RenderingServer.xml +++ b/doc/classes/RenderingServer.xml @@ -3215,6 +3215,13 @@ + + + + + Returns the render target for the viewport. + + diff --git a/servers/rendering/renderer_viewport.cpp b/servers/rendering/renderer_viewport.cpp index f609fa6023..8813c2e651 100644 --- a/servers/rendering/renderer_viewport.cpp +++ b/servers/rendering/renderer_viewport.cpp @@ -962,6 +962,13 @@ void RendererViewport::viewport_set_update_mode(RID p_viewport, RS::ViewportUpda viewport->update_mode = p_mode; } +RID RendererViewport::viewport_get_render_target(RID p_viewport) const { + const Viewport *viewport = viewport_owner.get_or_null(p_viewport); + ERR_FAIL_COND_V(!viewport, RID()); + + return viewport->render_target; +} + RID RendererViewport::viewport_get_texture(RID p_viewport) const { const Viewport *viewport = viewport_owner.get_or_null(p_viewport); ERR_FAIL_COND_V(!viewport, RID()); diff --git a/servers/rendering/renderer_viewport.h b/servers/rendering/renderer_viewport.h index c24275de6e..2f9537a47c 100644 --- a/servers/rendering/renderer_viewport.h +++ b/servers/rendering/renderer_viewport.h @@ -231,6 +231,7 @@ public: void viewport_set_clear_mode(RID p_viewport, RS::ViewportClearMode p_clear_mode); + RID viewport_get_render_target(RID p_viewport) const; RID viewport_get_texture(RID p_viewport) const; RID viewport_get_occluder_debug_texture(RID p_viewport) const; diff --git a/servers/rendering/rendering_server_default.h b/servers/rendering/rendering_server_default.h index a3bdf7d146..3e30ae0313 100644 --- a/servers/rendering/rendering_server_default.h +++ b/servers/rendering/rendering_server_default.h @@ -606,6 +606,7 @@ public: FUNC2(viewport_set_update_mode, RID, ViewportUpdateMode) + FUNC1RC(RID, viewport_get_render_target, RID) FUNC1RC(RID, viewport_get_texture, RID) FUNC2(viewport_set_disable_2d, RID, bool) diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index 8380558e1c..12f4a199b6 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -2198,6 +2198,7 @@ void RenderingServer::_bind_methods() { ClassDB::bind_method(D_METHOD("viewport_set_texture_mipmap_bias", "viewport", "mipmap_bias"), &RenderingServer::viewport_set_texture_mipmap_bias); ClassDB::bind_method(D_METHOD("viewport_set_update_mode", "viewport", "update_mode"), &RenderingServer::viewport_set_update_mode); ClassDB::bind_method(D_METHOD("viewport_set_clear_mode", "viewport", "clear_mode"), &RenderingServer::viewport_set_clear_mode); + ClassDB::bind_method(D_METHOD("viewport_get_render_target", "viewport"), &RenderingServer::viewport_get_render_target); ClassDB::bind_method(D_METHOD("viewport_get_texture", "viewport"), &RenderingServer::viewport_get_texture); ClassDB::bind_method(D_METHOD("viewport_set_disable_3d", "viewport", "disable"), &RenderingServer::viewport_set_disable_3d); ClassDB::bind_method(D_METHOD("viewport_set_disable_2d", "viewport", "disable"), &RenderingServer::viewport_set_disable_2d); diff --git a/servers/rendering_server.h b/servers/rendering_server.h index b53b7d2ff9..6b18914d38 100644 --- a/servers/rendering_server.h +++ b/servers/rendering_server.h @@ -837,6 +837,7 @@ public: virtual void viewport_set_clear_mode(RID p_viewport, ViewportClearMode p_clear_mode) = 0; + virtual RID viewport_get_render_target(RID p_viewport) const = 0; virtual RID viewport_get_texture(RID p_viewport) const = 0; enum ViewportEnvironmentMode { -- cgit v1.2.3 From 19b998396c5caefe3beda9cb81337c5c7159519c Mon Sep 17 00:00:00 2001 From: kobewi Date: Sun, 9 Apr 2023 20:43:55 +0200 Subject: Close built-in shaders when closing scene (cherry picked from commit aaf02ec04a8ef053a359bc2f4cc3f1747448a4a3) --- editor/editor_data.cpp | 2 +- editor/editor_node.cpp | 1 + editor/plugins/script_editor_plugin.cpp | 7 +++++-- editor/plugins/script_editor_plugin.h | 3 +-- editor/plugins/shader_editor_plugin.cpp | 28 ++++++++++++++++++++++++++++ editor/plugins/shader_editor_plugin.h | 4 ++++ 6 files changed, 40 insertions(+), 5 deletions(-) diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index 9bdd39f684..7eb539333b 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -595,7 +595,7 @@ void EditorData::remove_scene(int p_idx) { } if (!edited_scene[p_idx].path.is_empty()) { - ScriptEditor::get_singleton()->close_builtin_scripts_from_scene(edited_scene[p_idx].path); + EditorNode::get_singleton()->emit_signal("scene_closed", edited_scene[p_idx].path); } undo_redo_manager->discard_history(edited_scene[p_idx].history_id); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 87ca642be5..54494b63df 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -6617,6 +6617,7 @@ void EditorNode::_bind_methods() { ADD_SIGNAL(MethodInfo("scene_saved", PropertyInfo(Variant::STRING, "path"))); ADD_SIGNAL(MethodInfo("project_settings_changed")); ADD_SIGNAL(MethodInfo("scene_changed")); + ADD_SIGNAL(MethodInfo("scene_closed", PropertyInfo(Variant::STRING, "path"))); } static Node *_resource_get_edited_scene() { diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 46218869b3..ef86fd2a4c 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1643,6 +1643,7 @@ void ScriptEditor::_notification(int p_what) { get_tree()->connect("tree_changed", callable_mp(this, &ScriptEditor::_tree_changed)); InspectorDock::get_singleton()->connect("request_help", callable_mp(this, &ScriptEditor::_help_class_open)); EditorNode::get_singleton()->connect("request_help_search", callable_mp(this, &ScriptEditor::_help_search)); + EditorNode::get_singleton()->connect("scene_closed", callable_mp(this, &ScriptEditor::_close_builtin_scripts_from_scene)); } break; case NOTIFICATION_EXIT_TREE: { @@ -1677,7 +1678,7 @@ bool ScriptEditor::can_take_away_focus() const { } } -void ScriptEditor::close_builtin_scripts_from_scene(const String &p_scene) { +void ScriptEditor::_close_builtin_scripts_from_scene(const String &p_scene) { for (int i = 0; i < tab_container->get_tab_count(); i++) { ScriptEditorBase *se = Object::cast_to(tab_container->get_tab_control(i)); @@ -1687,7 +1688,7 @@ void ScriptEditor::close_builtin_scripts_from_scene(const String &p_scene) { continue; } - if (scr->is_built_in() && scr->get_path().begins_with(p_scene)) { //is an internal script and belongs to scene being closed + if (scr->is_built_in() && scr->get_path().begins_with(p_scene)) { // Is an internal script and belongs to scene being closed. _close_tab(i, false); i--; } @@ -4089,6 +4090,8 @@ ScriptEditor::ScriptEditor() { Ref json_syntax_highlighter; json_syntax_highlighter.instantiate(); register_syntax_highlighter(json_syntax_highlighter); + + EditorNode::get_singleton()->connect("scene_closed", callable_mp(this, &ScriptEditor::_close_builtin_scripts_from_scene)); } ScriptEditor::~ScriptEditor() { diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index 7d2f5ad22a..10dfe0f199 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -482,6 +482,7 @@ class ScriptEditor : public PanelContainer { void _on_find_in_files_modified_files(PackedStringArray paths); static void _open_script_request(const String &p_path); + void _close_builtin_scripts_from_scene(const String &p_scene); static ScriptEditor *script_editor; @@ -523,8 +524,6 @@ public: void notify_script_close(const Ref