diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/3d/navigation_3d.cpp | 2 | ||||
-rw-r--r-- | scene/3d/physics_body_3d.cpp | 7 | ||||
-rw-r--r-- | scene/3d/physics_body_3d.h | 3 | ||||
-rw-r--r-- | scene/animation/tween.cpp | 14 | ||||
-rw-r--r-- | scene/gui/box_container.cpp | 2 | ||||
-rw-r--r-- | scene/gui/line_edit.cpp | 57 | ||||
-rw-r--r-- | scene/gui/line_edit.h | 9 | ||||
-rw-r--r-- | scene/gui/rich_text_label.cpp | 3 | ||||
-rw-r--r-- | scene/gui/tree.cpp | 8 | ||||
-rw-r--r-- | scene/resources/animation.cpp | 2 | ||||
-rw-r--r-- | scene/resources/dynamic_font.cpp | 36 | ||||
-rw-r--r-- | scene/resources/dynamic_font.h | 2 | ||||
-rw-r--r-- | scene/resources/texture.cpp | 2 |
13 files changed, 122 insertions, 25 deletions
diff --git a/scene/3d/navigation_3d.cpp b/scene/3d/navigation_3d.cpp index 07a4824c28..851966db2b 100644 --- a/scene/3d/navigation_3d.cpp +++ b/scene/3d/navigation_3d.cpp @@ -109,7 +109,7 @@ Navigation3D::Navigation3D() { map = NavigationServer3D::get_singleton()->map_create(); set_cell_size(0.3); - set_edge_connection_margin(5.0); // Five meters, depends alot on the agents radius + set_edge_connection_margin(5.0); // Five meters, depends a lot on the agent's radius up = Vector3(0, 1, 0); } diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp index 72ae75b236..fc021e5532 100644 --- a/scene/3d/physics_body_3d.cpp +++ b/scene/3d/physics_body_3d.cpp @@ -358,6 +358,7 @@ void RigidBody3D::_direct_state_changed(Object *p_state) { set_global_transform(state->get_transform()); linear_velocity = state->get_linear_velocity(); angular_velocity = state->get_angular_velocity(); + inverse_inertia_tensor = state->get_inverse_inertia_tensor(); if (sleeping != state->is_sleeping()) { sleeping = state->is_sleeping(); emit_signal(SceneStringNames::get_singleton()->sleeping_state_changed); @@ -594,6 +595,10 @@ Vector3 RigidBody3D::get_angular_velocity() const { return angular_velocity; } +Basis RigidBody3D::get_inverse_inertia_tensor() { + return inverse_inertia_tensor; +} + void RigidBody3D::set_use_custom_integrator(bool p_enable) { if (custom_integrator == p_enable) { return; @@ -760,6 +765,8 @@ void RigidBody3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_angular_velocity", "angular_velocity"), &RigidBody3D::set_angular_velocity); ClassDB::bind_method(D_METHOD("get_angular_velocity"), &RigidBody3D::get_angular_velocity); + ClassDB::bind_method(D_METHOD("get_inverse_inertia_tensor"), &RigidBody3D::get_inverse_inertia_tensor); + ClassDB::bind_method(D_METHOD("set_gravity_scale", "gravity_scale"), &RigidBody3D::set_gravity_scale); ClassDB::bind_method(D_METHOD("get_gravity_scale"), &RigidBody3D::get_gravity_scale); diff --git a/scene/3d/physics_body_3d.h b/scene/3d/physics_body_3d.h index 413b587fc4..9830a55183 100644 --- a/scene/3d/physics_body_3d.h +++ b/scene/3d/physics_body_3d.h @@ -123,6 +123,7 @@ protected: Vector3 linear_velocity; Vector3 angular_velocity; + Basis inverse_inertia_tensor; real_t gravity_scale; real_t linear_damp; real_t angular_damp; @@ -201,6 +202,8 @@ public: void set_angular_velocity(const Vector3 &p_velocity); Vector3 get_angular_velocity() const override; + Basis get_inverse_inertia_tensor(); + void set_gravity_scale(real_t p_gravity_scale); real_t get_gravity_scale() const; diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 854db5fee2..bd4396d680 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -701,21 +701,21 @@ void Tween::_tween_process(float p_delta) { } // Are all of the tweens complete? - bool all_finished = true; + int any_unfinished = 0; // For each tween we wish to interpolate... for (List<InterpolateData>::Element *E = interpolates.front(); E; E = E->next()) { // Get the data from it InterpolateData &data = E->get(); - // Track if we hit one that isn't finished yet - all_finished = all_finished && data.finish; - // Is the data not active or already finished? No need to go any further if (!data.active || data.finish) { continue; } + // Track if we hit one that isn't finished yet + any_unfinished++; + // Get the target object for this interpolation Object *object = ObjectDB::get_instance(data.id); if (object == nullptr) { @@ -802,17 +802,15 @@ void Tween::_tween_process(float p_delta) { // If we are not repeating the tween, remove it if (!repeat) { call_deferred("_remove_by_uid", data.uid); + any_unfinished--; } - } else if (!repeat) { - // Check whether all tweens are finished - all_finished = all_finished && data.finish; } } // One less update left to go pending_update--; // If all tweens are completed, we no longer need to be active - if (all_finished) { + if (any_unfinished == 0) { set_active(false); emit_signal("tween_all_completed"); } diff --git a/scene/gui/box_container.cpp b/scene/gui/box_container.cpp index d198ae90d1..f130726837 100644 --- a/scene/gui/box_container.cpp +++ b/scene/gui/box_container.cpp @@ -96,7 +96,7 @@ void BoxContainer::_resort() { } stretch_avail += stretch_diff; //available stretch space. - /** Second, pass sucessively to discard elements that can't be stretched, this will run while stretchable + /** Second, pass successively to discard elements that can't be stretched, this will run while stretchable elements exist */ bool has_stretched = false; diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 27c2c70708..646f9f6095 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -118,7 +118,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { selection.creating = false; selection.doubleclick = false; - if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD)) { + if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD) && virtual_keyboard_enabled) { if (selection.enabled) { DisplayServer::get_singleton()->virtual_keyboard_show(text, get_global_rect(), max_length, selection.begin, selection.end); } else { @@ -309,7 +309,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { case KEY_KP_ENTER: case KEY_ENTER: { emit_signal("text_entered", text); - if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD)) { + if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD) && virtual_keyboard_enabled) { DisplayServer::get_singleton()->virtual_keyboard_hide(); } @@ -699,7 +699,7 @@ void LineEdit::_notification(int p_what) { update(); } break; case NOTIFICATION_DRAW: { - if ((!has_focus() && !menu->has_focus()) || !window_has_focus) { + if ((!has_focus() && !menu->has_focus() && !caret_force_displayed) || !window_has_focus) { draw_caret = false; } @@ -925,10 +925,14 @@ void LineEdit::_notification(int p_what) { } } break; case NOTIFICATION_FOCUS_ENTER: { - if (caret_blink_enabled) { - caret_blink_timer->start(); - } else { - draw_caret = true; + if (!caret_force_displayed) { + if (caret_blink_enabled) { + if (caret_blink_timer->is_stopped()) { + caret_blink_timer->start(); + } + } else { + draw_caret = true; + } } if (get_viewport()->get_window_id() != DisplayServer::INVALID_WINDOW_ID) { @@ -937,7 +941,7 @@ void LineEdit::_notification(int p_what) { DisplayServer::get_singleton()->window_set_ime_position(get_global_position() + cursor_pos, get_viewport()->get_window_id()); } - if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD)) { + if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD) && virtual_keyboard_enabled) { if (selection.enabled) { DisplayServer::get_singleton()->virtual_keyboard_show(text, get_global_rect(), max_length, selection.begin, selection.end); } else { @@ -947,7 +951,7 @@ void LineEdit::_notification(int p_what) { } break; case NOTIFICATION_FOCUS_EXIT: { - if (caret_blink_enabled) { + if (caret_blink_enabled && !caret_force_displayed) { caret_blink_timer->stop(); } @@ -958,7 +962,7 @@ void LineEdit::_notification(int p_what) { ime_text = ""; ime_selection = Point2(); - if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD)) { + if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_VIRTUAL_KEYBOARD) && virtual_keyboard_enabled) { DisplayServer::get_singleton()->virtual_keyboard_hide(); } @@ -1167,9 +1171,11 @@ bool LineEdit::cursor_get_blink_enabled() const { void LineEdit::cursor_set_blink_enabled(const bool p_enabled) { caret_blink_enabled = p_enabled; - if (has_focus()) { + if (has_focus() || caret_force_displayed) { if (p_enabled) { - caret_blink_timer->start(); + if (caret_blink_timer->is_stopped()) { + caret_blink_timer->start(); + } } else { caret_blink_timer->stop(); } @@ -1178,6 +1184,16 @@ void LineEdit::cursor_set_blink_enabled(const bool p_enabled) { draw_caret = true; } +bool LineEdit::cursor_get_force_displayed() const { + return caret_force_displayed; +} + +void LineEdit::cursor_set_force_displayed(const bool p_enabled) { + caret_force_displayed = p_enabled; + cursor_set_blink_enabled(caret_blink_enabled); + update(); +} + float LineEdit::cursor_get_blink_speed() const { return caret_blink_timer->get_wait_time(); } @@ -1200,7 +1216,7 @@ void LineEdit::_reset_caret_blink_timer() { void LineEdit::_toggle_draw_caret() { draw_caret = !draw_caret; - if (is_visible_in_tree() && has_focus() && window_has_focus) { + if (is_visible_in_tree() && ((has_focus() && window_has_focus) || caret_force_displayed)) { update(); } } @@ -1658,6 +1674,14 @@ bool LineEdit::is_shortcut_keys_enabled() const { return shortcut_keys_enabled; } +void LineEdit::set_virtual_keyboard_enabled(bool p_enable) { + virtual_keyboard_enabled = p_enable; +} + +bool LineEdit::is_virtual_keyboard_enabled() const { + return virtual_keyboard_enabled; +} + void LineEdit::set_selecting_enabled(bool p_enabled) { selecting_enabled = p_enabled; @@ -1796,6 +1820,8 @@ void LineEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("get_expand_to_text_length"), &LineEdit::get_expand_to_text_length); ClassDB::bind_method(D_METHOD("cursor_set_blink_enabled", "enabled"), &LineEdit::cursor_set_blink_enabled); ClassDB::bind_method(D_METHOD("cursor_get_blink_enabled"), &LineEdit::cursor_get_blink_enabled); + ClassDB::bind_method(D_METHOD("cursor_set_force_displayed", "enabled"), &LineEdit::cursor_set_force_displayed); + ClassDB::bind_method(D_METHOD("cursor_get_force_displayed"), &LineEdit::cursor_get_force_displayed); ClassDB::bind_method(D_METHOD("cursor_set_blink_speed", "blink_speed"), &LineEdit::cursor_set_blink_speed); ClassDB::bind_method(D_METHOD("cursor_get_blink_speed"), &LineEdit::cursor_get_blink_speed); ClassDB::bind_method(D_METHOD("set_max_length", "chars"), &LineEdit::set_max_length); @@ -1813,6 +1839,8 @@ void LineEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("get_menu"), &LineEdit::get_menu); ClassDB::bind_method(D_METHOD("set_context_menu_enabled", "enable"), &LineEdit::set_context_menu_enabled); ClassDB::bind_method(D_METHOD("is_context_menu_enabled"), &LineEdit::is_context_menu_enabled); + ClassDB::bind_method(D_METHOD("set_virtual_keyboard_enabled", "enable"), &LineEdit::set_virtual_keyboard_enabled); + ClassDB::bind_method(D_METHOD("is_virtual_keyboard_enabled"), &LineEdit::is_virtual_keyboard_enabled); ClassDB::bind_method(D_METHOD("set_clear_button_enabled", "enable"), &LineEdit::set_clear_button_enabled); ClassDB::bind_method(D_METHOD("is_clear_button_enabled"), &LineEdit::is_clear_button_enabled); ClassDB::bind_method(D_METHOD("set_shortcut_keys_enabled", "enable"), &LineEdit::set_shortcut_keys_enabled); @@ -1848,6 +1876,7 @@ void LineEdit::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::STRING, "secret_character"), "set_secret_character", "get_secret_character"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "expand_to_text_length"), "set_expand_to_text_length", "get_expand_to_text_length"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "context_menu_enabled"), "set_context_menu_enabled", "is_context_menu_enabled"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "virtual_keyboard_enabled"), "set_virtual_keyboard_enabled", "is_virtual_keyboard_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "clear_button_enabled"), "set_clear_button_enabled", "is_clear_button_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shortcut_keys_enabled"), "set_shortcut_keys_enabled", "is_shortcut_keys_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "selecting_enabled"), "set_selecting_enabled", "is_selecting_enabled"); @@ -1859,6 +1888,7 @@ void LineEdit::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret_blink"), "cursor_set_blink_enabled", "cursor_get_blink_enabled"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "caret_blink_speed", PROPERTY_HINT_RANGE, "0.1,10,0.01"), "cursor_set_blink_speed", "cursor_get_blink_speed"); ADD_PROPERTY(PropertyInfo(Variant::INT, "caret_position"), "set_cursor_position", "get_cursor_position"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret_force_displayed"), "cursor_set_force_displayed", "cursor_get_force_displayed"); } LineEdit::LineEdit() { @@ -1888,6 +1918,7 @@ LineEdit::LineEdit() { draw_caret = true; caret_blink_enabled = false; + caret_force_displayed = false; caret_blink_timer = memnew(Timer); add_child(caret_blink_timer); caret_blink_timer->set_wait_time(0.65); diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h index e6c964c906..d6cc1f1f11 100644 --- a/scene/gui/line_edit.h +++ b/scene/gui/line_edit.h @@ -90,6 +90,8 @@ private: bool shortcut_keys_enabled; + bool virtual_keyboard_enabled = true; + Ref<Texture2D> right_icon; struct Selection { @@ -134,6 +136,7 @@ private: void update_placeholder_width(); bool caret_blink_enabled; + bool caret_force_displayed; bool draw_caret; bool window_has_focus; @@ -201,6 +204,9 @@ public: float cursor_get_blink_speed() const; void cursor_set_blink_speed(const float p_speed); + bool cursor_get_force_displayed() const; + void cursor_set_force_displayed(const bool p_enabled); + void copy_text(); void cut_text(); void paste_text(); @@ -227,6 +233,9 @@ public: void set_shortcut_keys_enabled(bool p_enabled); bool is_shortcut_keys_enabled() const; + void set_virtual_keyboard_enabled(bool p_enable); + bool is_virtual_keyboard_enabled() const; + void set_selecting_enabled(bool p_enabled); bool is_selecting_enabled() const; diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 8d7bccf814..572be8d901 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -1020,7 +1020,8 @@ void RichTextLabel::_notification(int p_what) { visible_line_count = 0; while (y < size.height && from_line < main->lines.size()) { - visible_line_count += _process_line(main, text_rect.get_position(), y, text_rect.get_size().width - scroll_w, from_line, PROCESS_DRAW, base_font, base_color, font_color_shadow, use_outline, shadow_ofs, Point2i(), nullptr, nullptr, nullptr, total_chars); + visible_line_count++; + _process_line(main, text_rect.get_position(), y, text_rect.get_size().width - scroll_w, from_line, PROCESS_DRAW, base_font, base_color, font_color_shadow, use_outline, shadow_ofs, Point2i(), nullptr, nullptr, nullptr, total_chars); total_chars += main->lines[from_line].char_count; from_line++; diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 47761d724e..eeb7f9430d 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -3419,6 +3419,8 @@ void Tree::scroll_to_item(TreeItem *p_item) { TreeItem *Tree::_search_item_text(TreeItem *p_at, const String &p_find, int *r_col, bool p_selectable, bool p_backwards) { TreeItem *from = p_at; + TreeItem *loop = nullptr; // Safe-guard against infinite loop. + while (p_at) { for (int i = 0; i < columns.size(); i++) { if (p_at->get_text(i).findn(p_find) == 0 && (!p_selectable || p_at->is_selectable(i))) { @@ -3438,6 +3440,12 @@ TreeItem *Tree::_search_item_text(TreeItem *p_at, const String &p_find, int *r_c if ((p_at) == from) { break; } + + if (!loop) { + loop = p_at; + } else if (loop == p_at) { + break; + } } return nullptr; diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index 479d97aadc..b8edd70712 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -752,7 +752,9 @@ int Animation::_insert(float p_time, T &p_keys, const V &p_value) { while (true) { // Condition for replacement. if (idx > 0 && Math::is_equal_approx(p_keys[idx - 1].time, p_time)) { + float transition = p_keys[idx - 1].transition; p_keys.write[idx - 1] = p_value; + p_keys.write[idx - 1].transition = transition; return idx - 1; // Condition for insert. diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp index 3d99556a10..99f87dd6ed 100644 --- a/scene/resources/dynamic_font.cpp +++ b/scene/resources/dynamic_font.cpp @@ -290,6 +290,21 @@ Size2 DynamicFontAtSize::get_char_size(CharType p_char, CharType p_next, const V return ret; } +String DynamicFontAtSize::get_available_chars() const { + String chars; + + FT_UInt gindex; + FT_ULong charcode = FT_Get_First_Char(face, &gindex); + while (gindex != 0) { + if (charcode != 0) { + chars += CharType(charcode); + } + charcode = FT_Get_Next_Char(face, charcode, &gindex); + } + + return chars; +} + float DynamicFontAtSize::draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next, const Color &p_modulate, const Vector<Ref<DynamicFontAtSize>> &p_fallbacks, bool p_advance_only, bool p_outline) const { if (!valid) { return 0; @@ -849,6 +864,25 @@ Size2 DynamicFont::get_char_size(CharType p_char, CharType p_next) const { return ret; } +String DynamicFont::get_available_chars() const { + if (!data_at_size.is_valid()) { + return ""; + } + + String chars = data_at_size->get_available_chars(); + + for (int i = 0; i < fallback_data_at_size.size(); i++) { + String fallback_chars = fallback_data_at_size[i]->get_available_chars(); + for (int j = 0; j < fallback_chars.length(); j++) { + if (chars.find_char(fallback_chars[j]) == -1) { + chars += fallback_chars[j]; + } + } + } + + return chars; +} + bool DynamicFont::is_distance_field_hint() const { return false; } @@ -964,6 +998,8 @@ void DynamicFont::_bind_methods() { ClassDB::bind_method(D_METHOD("set_font_data", "data"), &DynamicFont::set_font_data); ClassDB::bind_method(D_METHOD("get_font_data"), &DynamicFont::get_font_data); + ClassDB::bind_method(D_METHOD("get_available_chars"), &DynamicFont::get_available_chars); + ClassDB::bind_method(D_METHOD("set_size", "data"), &DynamicFont::set_size); ClassDB::bind_method(D_METHOD("get_size"), &DynamicFont::get_size); diff --git a/scene/resources/dynamic_font.h b/scene/resources/dynamic_font.h index 0afad428b3..e8637e7e34 100644 --- a/scene/resources/dynamic_font.h +++ b/scene/resources/dynamic_font.h @@ -189,6 +189,7 @@ public: float get_underline_thickness() const; Size2 get_char_size(CharType p_char, CharType p_next, const Vector<Ref<DynamicFontAtSize>> &p_fallbacks) const; + String get_available_chars() const; float draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next, const Color &p_modulate, const Vector<Ref<DynamicFontAtSize>> &p_fallbacks, bool p_advance_only = false, bool p_outline = false) const; @@ -277,6 +278,7 @@ public: virtual float get_underline_thickness() const override; virtual Size2 get_char_size(CharType p_char, CharType p_next = 0) const override; + String get_available_chars() const; virtual bool is_distance_field_hint() const override; diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 331cffed5d..5681613c04 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -2079,7 +2079,7 @@ Error StreamTextureLayered::_load_data(const String &p_path, Vector<Ref<Image>> uint32_t df = f->get_32(); //data format mipmap_limit = int(f->get_32()); - //reserverd + //reserved f->get_32(); f->get_32(); f->get_32(); |