diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/2d/animated_sprite_2d.cpp | 5 | ||||
-rw-r--r-- | scene/2d/physics_body_2d.cpp | 9 | ||||
-rw-r--r-- | scene/2d/physics_body_2d.h | 1 | ||||
-rw-r--r-- | scene/3d/physics_body_3d.cpp | 7 | ||||
-rw-r--r-- | scene/3d/physics_body_3d.h | 1 | ||||
-rw-r--r-- | scene/3d/sprite_3d.cpp | 14 | ||||
-rw-r--r-- | scene/gui/code_edit.cpp | 9 | ||||
-rw-r--r-- | scene/gui/code_edit.h | 1 | ||||
-rw-r--r-- | scene/gui/container.cpp | 6 | ||||
-rw-r--r-- | scene/gui/container.h | 3 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 4 | ||||
-rw-r--r-- | scene/gui/text_edit.h | 2 | ||||
-rw-r--r-- | scene/main/viewport.cpp | 10 | ||||
-rw-r--r-- | scene/resources/canvas_item_material.cpp | 2 | ||||
-rw-r--r-- | scene/resources/material.cpp | 2 | ||||
-rw-r--r-- | scene/resources/packed_scene.cpp | 2 | ||||
-rw-r--r-- | scene/resources/theme.cpp | 8 | ||||
-rw-r--r-- | scene/scene_string_names.cpp | 1 | ||||
-rw-r--r-- | scene/scene_string_names.h | 1 |
19 files changed, 58 insertions, 30 deletions
diff --git a/scene/2d/animated_sprite_2d.cpp b/scene/2d/animated_sprite_2d.cpp index 96a3134691..fad4784d51 100644 --- a/scene/2d/animated_sprite_2d.cpp +++ b/scene/2d/animated_sprite_2d.cpp @@ -94,7 +94,7 @@ Rect2 AnimatedSprite2D::_get_rect() const { Point2 ofs = offset; if (centered) { - ofs -= Size2(s) / 2; + ofs -= s / 2; } if (s == Size2(0, 0)) { @@ -228,8 +228,7 @@ void AnimatedSprite2D::_notification(int p_what) { RID ci = get_canvas_item(); - Size2i s; - s = texture->get_size(); + Size2 s = texture->get_size(); Point2 ofs = offset; if (centered) { ofs -= s / 2; diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index 9a10255acc..f493d97ceb 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -1089,6 +1089,9 @@ bool CharacterBody2D::move_and_slide() { if (!current_platform_velocity.is_equal_approx(Vector2())) { PhysicsServer2D::MotionParameters parameters(get_global_transform(), current_platform_velocity * delta, margin); parameters.exclude_bodies.insert(platform_rid); + if (platform_object_id.is_valid()) { + parameters.exclude_objects.insert(platform_object_id); + } PhysicsServer2D::MotionResult floor_result; if (move_and_collide(parameters, floor_result, false, false)) { @@ -1125,9 +1128,11 @@ void CharacterBody2D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo Vector2 prev_floor_normal = floor_normal; RID prev_platform_rid = platform_rid; + ObjectID prev_platform_object_id = platform_object_id; int prev_platform_layer = platform_layer; platform_rid = RID(); + platform_object_id = ObjectID(); floor_normal = Vector2(); platform_velocity = Vector2(); @@ -1199,6 +1204,7 @@ void CharacterBody2D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo } on_floor = true; platform_rid = prev_platform_rid; + platform_object_id = prev_platform_object_id; platform_layer = prev_platform_layer; platform_velocity = p_prev_platform_velocity; floor_normal = prev_floor_normal; @@ -1285,6 +1291,7 @@ void CharacterBody2D::_move_and_slide_free(double p_delta) { Vector2 motion = motion_velocity * p_delta; platform_rid = RID(); + platform_object_id = ObjectID(); floor_normal = Vector2(); platform_velocity = Vector2(); @@ -1402,6 +1409,7 @@ void CharacterBody2D::_set_collision_direction(const PhysicsServer2D::MotionResu void CharacterBody2D::_set_platform_data(const PhysicsServer2D::MotionResult &p_result) { platform_rid = p_result.collider; + platform_object_id = p_result.collider_id; platform_velocity = p_result.collider_velocity; platform_layer = PhysicsServer2D::get_singleton()->body_get_collision_layer(platform_rid); } @@ -1620,6 +1628,7 @@ void CharacterBody2D::_notification(int p_what) { // Reset move_and_slide() data. on_floor = false; platform_rid = RID(); + platform_object_id = ObjectID(); on_ceiling = false; on_wall = false; motion_results.clear(); diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h index fd8bb66158..d1f52b33f2 100644 --- a/scene/2d/physics_body_2d.h +++ b/scene/2d/physics_body_2d.h @@ -368,6 +368,7 @@ private: Vector2 real_velocity; RID platform_rid; + ObjectID platform_object_id; bool on_floor = false; bool on_ceiling = false; bool on_wall = false; diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp index b7c808398c..976bff4fbc 100644 --- a/scene/3d/physics_body_3d.cpp +++ b/scene/3d/physics_body_3d.cpp @@ -1131,6 +1131,9 @@ bool CharacterBody3D::move_and_slide() { if (!current_platform_velocity.is_equal_approx(Vector3())) { PhysicsServer3D::MotionParameters parameters(get_global_transform(), current_platform_velocity * delta, margin); parameters.exclude_bodies.insert(platform_rid); + if (platform_object_id.is_valid()) { + parameters.exclude_objects.insert(platform_object_id); + } PhysicsServer3D::MotionResult floor_result; if (move_and_collide(parameters, floor_result, false, false)) { @@ -1169,6 +1172,7 @@ void CharacterBody3D::_move_and_slide_grounded(double p_delta, bool p_was_on_flo Vector3 prev_floor_normal = floor_normal; platform_rid = RID(); + platform_object_id = ObjectID(); platform_velocity = Vector3(); platform_ceiling_velocity = Vector3(); floor_normal = Vector3(); @@ -1416,6 +1420,7 @@ void CharacterBody3D::_move_and_slide_free(double p_delta) { Vector3 motion = motion_velocity * p_delta; platform_rid = RID(); + platform_object_id = ObjectID(); floor_normal = Vector3(); platform_velocity = Vector3(); @@ -1611,6 +1616,7 @@ void CharacterBody3D::_set_collision_direction(const PhysicsServer3D::MotionResu void CharacterBody3D::_set_platform_data(const PhysicsServer3D::MotionCollision &p_collision) { platform_rid = p_collision.collider; + platform_object_id = p_collision.collider_id; platform_velocity = p_collision.collider_velocity; platform_layer = PhysicsServer3D::get_singleton()->body_get_collision_layer(platform_rid); } @@ -1833,6 +1839,7 @@ void CharacterBody3D::_notification(int p_what) { // Reset move_and_slide() data. collision_state.state = 0; platform_rid = RID(); + platform_object_id = ObjectID(); motion_results.clear(); platform_velocity = Vector3(); } break; diff --git a/scene/3d/physics_body_3d.h b/scene/3d/physics_body_3d.h index d2754e7726..5677df730c 100644 --- a/scene/3d/physics_body_3d.h +++ b/scene/3d/physics_body_3d.h @@ -383,6 +383,7 @@ private: int max_slides = 6; int platform_layer = 0; RID platform_rid; + ObjectID platform_object_id; uint32_t moving_platform_floor_layers = UINT32_MAX; uint32_t moving_platform_wall_layers = 0; real_t floor_snap_length = 0.1; diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index b9a2736918..349a534680 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -712,7 +712,7 @@ Rect2 Sprite3D::get_item_rect() const { return CanvasItem::get_item_rect(); */ - Size2i s; + Size2 s; if (region) { s = region_rect.size; @@ -807,22 +807,20 @@ void AnimatedSprite3D::_draw() { set_base(RID()); return; //no texuture no life } - Vector2 tsize = texture->get_size(); + Size2 tsize = texture->get_size(); if (tsize.x == 0 || tsize.y == 0) { return; } - Size2i s = tsize; Rect2 src_rect; - - src_rect.size = s; + src_rect.size = tsize; Point2 ofs = get_offset(); if (is_centered()) { - ofs -= s / 2; + ofs -= tsize / 2; } - Rect2 dst_rect(ofs, s); + Rect2 dst_rect(ofs, tsize); Rect2 final_rect; Rect2 final_src_rect; @@ -1133,7 +1131,7 @@ Rect2 AnimatedSprite3D::get_item_rect() const { if (t.is_null()) { return Rect2(0, 0, 1, 1); } - Size2i s = t->get_size(); + Size2 s = t->get_size(); Point2 ofs = get_offset(); if (centered) { diff --git a/scene/gui/code_edit.cpp b/scene/gui/code_edit.cpp index b816f12bc3..da54903871 100644 --- a/scene/gui/code_edit.cpp +++ b/scene/gui/code_edit.cpp @@ -433,7 +433,7 @@ void CodeEdit::gui_input(const Ref<InputEvent> &p_gui_input) { return; } if (k->is_action("ui_end", true)) { - code_completion_current_selected = MIN(code_completion_options.size() - 1, code_completion_current_selected + code_completion_max_lines); + code_completion_current_selected = code_completion_options.size() - 1; update(); accept_event(); return; @@ -2937,6 +2937,7 @@ void CodeEdit::_lines_edited_from(int p_from_line, int p_to_line) { return; } + lines_edited_changed += p_to_line - p_from_line; lines_edited_from = (lines_edited_from == -1) ? MIN(p_from_line, p_to_line) : MIN(lines_edited_from, MIN(p_from_line, p_to_line)); lines_edited_to = (lines_edited_to == -1) ? MAX(p_from_line, p_to_line) : MAX(lines_edited_from, MAX(p_from_line, p_to_line)); } @@ -2963,7 +2964,6 @@ void CodeEdit::_text_changed() { } lc = get_line_count(); - int line_change_size = (lines_edited_to - lines_edited_from); List<int> breakpoints; breakpointed_lines.get_key_list(&breakpoints); for (const int &line : breakpoints) { @@ -2974,8 +2974,8 @@ void CodeEdit::_text_changed() { breakpointed_lines.erase(line); emit_signal(SNAME("breakpoint_toggled"), line); - int next_line = line + line_change_size; - if (next_line < lc && is_line_breakpointed(next_line)) { + int next_line = line + lines_edited_changed; + if (next_line > -1 && next_line < lc && is_line_breakpointed(next_line)) { emit_signal(SNAME("breakpoint_toggled"), next_line); breakpointed_lines[next_line] = true; continue; @@ -2984,6 +2984,7 @@ void CodeEdit::_text_changed() { lines_edited_from = -1; lines_edited_to = -1; + lines_edited_changed = 0; } CodeEdit::CodeEdit() { diff --git a/scene/gui/code_edit.h b/scene/gui/code_edit.h index d8eccb7d32..f0d971dd35 100644 --- a/scene/gui/code_edit.h +++ b/scene/gui/code_edit.h @@ -240,6 +240,7 @@ private: int line_spacing = 1; /* Callbacks */ + int lines_edited_changed = 0; int lines_edited_from = -1; int lines_edited_to = -1; diff --git a/scene/gui/container.cpp b/scene/gui/container.cpp index 11941529cd..a1bd82f6f7 100644 --- a/scene/gui/container.cpp +++ b/scene/gui/container.cpp @@ -87,6 +87,9 @@ void Container::_sort_children() { return; } + notification(NOTIFICATION_PRE_SORT_CHILDREN); + emit_signal(SceneStringNames::get_singleton()->pre_sort_children); + notification(NOTIFICATION_SORT_CHILDREN); emit_signal(SceneStringNames::get_singleton()->sort_children); pending_sort = false; @@ -174,7 +177,10 @@ void Container::_bind_methods() { ClassDB::bind_method(D_METHOD("queue_sort"), &Container::queue_sort); ClassDB::bind_method(D_METHOD("fit_child_in_rect", "child", "rect"), &Container::fit_child_in_rect); + BIND_CONSTANT(NOTIFICATION_PRE_SORT_CHILDREN); BIND_CONSTANT(NOTIFICATION_SORT_CHILDREN); + + ADD_SIGNAL(MethodInfo("pre_sort_children")); ADD_SIGNAL(MethodInfo("sort_children")); } diff --git a/scene/gui/container.h b/scene/gui/container.h index bce3085f0c..f3ae948556 100644 --- a/scene/gui/container.h +++ b/scene/gui/container.h @@ -51,7 +51,8 @@ protected: public: enum { - NOTIFICATION_SORT_CHILDREN = 50 + NOTIFICATION_PRE_SORT_CHILDREN = 50, + NOTIFICATION_SORT_CHILDREN = 51, }; void fit_child_in_rect(Control *p_child, const Rect2 &p_rect); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 57bcbb7c2d..6370ea9c95 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -2399,6 +2399,7 @@ Control::CursorShape TextEdit::get_cursor_shape(const Point2 &p_pos) const { } String TextEdit::get_tooltip(const Point2 &p_pos) const { + Object *tooltip_obj = ObjectDB::get_instance(tooltip_obj_id); if (!tooltip_obj) { return Control::get_tooltip(p_pos); } @@ -2421,7 +2422,8 @@ String TextEdit::get_tooltip(const Point2 &p_pos) const { } void TextEdit::set_tooltip_request_func(Object *p_obj, const StringName &p_function, const Variant &p_udata) { - tooltip_obj = p_obj; + ERR_FAIL_NULL(p_obj); + tooltip_obj_id = p_obj->get_instance_id(); tooltip_func = p_function; tooltip_ud = p_udata; } diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 07e585847a..3230de776f 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -330,7 +330,7 @@ private: int _get_column_pos_of_word(const String &p_key, const String &p_search, uint32_t p_search_flags, int p_from_column) const; /* Tooltip. */ - Object *tooltip_obj = nullptr; + ObjectID tooltip_obj_id; StringName tooltip_func; Variant tooltip_ud; diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index b3b743370b..e88bb3b952 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -57,17 +57,17 @@ #include "servers/audio_server.h" void ViewportTexture::setup_local_to_scene() { + Node *local_scene = get_local_scene(); + if (!local_scene) { + return; + } + if (vp) { vp->viewport_textures.erase(this); } vp = nullptr; - Node *local_scene = get_local_scene(); - if (!local_scene) { - return; - } - Node *vpn = local_scene->get_node(path); ERR_FAIL_COND_MSG(!vpn, "ViewportTexture: Path to node is invalid."); diff --git a/scene/resources/canvas_item_material.cpp b/scene/resources/canvas_item_material.cpp index fa95ab0e79..b291724c4c 100644 --- a/scene/resources/canvas_item_material.cpp +++ b/scene/resources/canvas_item_material.cpp @@ -135,7 +135,7 @@ void CanvasItemMaterial::_update_shader() { code += " particle_frame = mod(particle_frame, particle_total_frames);\n"; code += " }"; code += " UV /= vec2(h_frames, v_frames);\n"; - code += " UV += vec2(mod(particle_frame, h_frames) / h_frames, floor(particle_frame / h_frames) / v_frames);\n"; + code += " UV += vec2(mod(particle_frame, h_frames) / h_frames, floor((particle_frame + 0.5) / h_frames) / v_frames);\n"; code += "}\n"; } diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 66f04f0292..abb3381c4e 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -811,7 +811,7 @@ void BaseMaterial3D::_update_shader() { code += " particle_frame = mod(particle_frame, particle_total_frames);\n"; code += " }"; code += " UV /= vec2(h_frames, v_frames);\n"; - code += " UV += vec2(mod(particle_frame, h_frames) / h_frames, floor(particle_frame / h_frames) / v_frames);\n"; + code += " UV += vec2(mod(particle_frame, h_frames) / h_frames, floor((particle_frame + 0.5) / h_frames) / v_frames);\n"; } break; case BILLBOARD_MAX: break; // Internal value, skip. diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index c8d3ea5e37..60cda637ca 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -388,7 +388,7 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Map editable_instances.push_back(p_owner->get_path_to(p_node)); // Node is the root of an editable instance. is_editable_instance = true; - } else if (p_node->get_owner() && p_node->get_owner() != p_owner && p_owner->is_editable_instance(p_node->get_owner())) { + } else if (p_node->get_owner() && p_owner->is_ancestor_of(p_node->get_owner()) && p_owner->is_editable_instance(p_node->get_owner())) { // Node is part of an editable instance. is_editable_instance = true; } diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp index 1486b433f0..65cdc1e24e 100644 --- a/scene/resources/theme.cpp +++ b/scene/resources/theme.cpp @@ -271,7 +271,7 @@ void Theme::set_default_theme_font(const Ref<Font> &p_default_font) { default_theme_font = p_default_font; if (default_theme_font.is_valid()) { - default_theme_font->connect("changed", callable_mp(this, &Theme::_emit_theme_changed), varray(), CONNECT_REFERENCE_COUNTED); + default_theme_font->connect("changed", callable_mp(this, &Theme::_emit_theme_changed), varray(false), CONNECT_REFERENCE_COUNTED); } _emit_theme_changed(); @@ -314,7 +314,7 @@ void Theme::set_icon(const StringName &p_name, const StringName &p_theme_type, c icon_map[p_theme_type][p_name] = p_icon; if (p_icon.is_valid()) { - icon_map[p_theme_type][p_name]->connect("changed", callable_mp(this, &Theme::_emit_theme_changed), varray(), CONNECT_REFERENCE_COUNTED); + icon_map[p_theme_type][p_name]->connect("changed", callable_mp(this, &Theme::_emit_theme_changed), varray(false), CONNECT_REFERENCE_COUNTED); } _emit_theme_changed(!existing); @@ -401,7 +401,7 @@ void Theme::set_stylebox(const StringName &p_name, const StringName &p_theme_typ style_map[p_theme_type][p_name] = p_style; if (p_style.is_valid()) { - style_map[p_theme_type][p_name]->connect("changed", callable_mp(this, &Theme::_emit_theme_changed), varray(), CONNECT_REFERENCE_COUNTED); + style_map[p_theme_type][p_name]->connect("changed", callable_mp(this, &Theme::_emit_theme_changed), varray(false), CONNECT_REFERENCE_COUNTED); } _emit_theme_changed(!existing); @@ -488,7 +488,7 @@ void Theme::set_font(const StringName &p_name, const StringName &p_theme_type, c font_map[p_theme_type][p_name] = p_font; if (p_font.is_valid()) { - font_map[p_theme_type][p_name]->connect("changed", callable_mp(this, &Theme::_emit_theme_changed), varray(), CONNECT_REFERENCE_COUNTED); + font_map[p_theme_type][p_name]->connect("changed", callable_mp(this, &Theme::_emit_theme_changed), varray(false), CONNECT_REFERENCE_COUNTED); } _emit_theme_changed(!existing); diff --git a/scene/scene_string_names.cpp b/scene/scene_string_names.cpp index b283749ffa..29e5dd6056 100644 --- a/scene/scene_string_names.cpp +++ b/scene/scene_string_names.cpp @@ -73,6 +73,7 @@ SceneStringNames::SceneStringNames() { focus_entered = StaticCString::create("focus_entered"); focus_exited = StaticCString::create("focus_exited"); + pre_sort_children = StaticCString::create("pre_sort_children"); sort_children = StaticCString::create("sort_children"); body_shape_entered = StaticCString::create("body_shape_entered"); diff --git a/scene/scene_string_names.h b/scene/scene_string_names.h index 2923351eab..5e3195952e 100644 --- a/scene/scene_string_names.h +++ b/scene/scene_string_names.h @@ -89,6 +89,7 @@ public: StringName focus_entered; StringName focus_exited; + StringName pre_sort_children; StringName sort_children; StringName finished; |