diff options
-rw-r--r-- | editor/import/editor_scene_importer_gltf.cpp | 25 | ||||
-rw-r--r-- | editor/spatial_editor_gizmos.cpp | 52 | ||||
-rw-r--r-- | modules/gdscript/gdscript_parser.cpp | 3 | ||||
-rw-r--r-- | scene/gui/line_edit.cpp | 37 |
4 files changed, 73 insertions, 44 deletions
diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index 79658c5a4c..cb21dda5ce 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -1656,6 +1656,14 @@ Error EditorSceneImporterGLTF::_expand_skin(GLTFState &state, GLTFSkin &skin) { } Error EditorSceneImporterGLTF::_verify_skin(GLTFState &state, GLTFSkin &skin) { + + // This may seem duplicated from expand_skins, but this is really a sanity check! (so it kinda is) + // In case additional interpolating logic is added to the skins, this will help ensure that you + // do not cause it to self implode into a fiery blaze + + // We are going to re-calculate the root nodes and compare them to the ones saved in the skin, + // then ensure the multiple trees (if they exist) are on the same sublevel + // Grab all nodes that lay in between skin joints/nodes DisjointSet<GLTFNodeIndex> disjoint_set; @@ -1673,15 +1681,28 @@ Error EditorSceneImporterGLTF::_verify_skin(GLTFState &state, GLTFSkin &skin) { } } + Vector<GLTFNodeIndex> out_owners; + disjoint_set.get_representatives(out_owners); + Vector<GLTFNodeIndex> out_roots; - disjoint_set.get_representatives(out_roots); + + for (int i = 0; i < out_owners.size(); ++i) { + Vector<GLTFNodeIndex> set; + disjoint_set.get_members(set, out_owners[i]); + + const GLTFNodeIndex root = _find_highest_node(state, set); + ERR_FAIL_COND_V(root < 0, FAILED); + out_roots.push_back(root); + } + out_roots.sort(); ERR_FAIL_COND_V(out_roots.size() == 0, FAILED); + // Make sure the roots are the exact same (they better be) ERR_FAIL_COND_V(out_roots.size() != skin.roots.size(), FAILED); for (int i = 0; i < out_roots.size(); ++i) { - ERR_FAIL_COND_V(out_roots.size() != skin.roots.size(), FAILED); + ERR_FAIL_COND_V(out_roots[i] != skin.roots[i], FAILED); } // Single rooted skin? Perfectly ok! diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index b9f26d666d..529e884fc9 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -1074,7 +1074,8 @@ AudioStreamPlayer3DSpatialGizmoPlugin::AudioStreamPlayer3DSpatialGizmoPlugin() { Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/stream_player_3d", Color(0.4, 0.8, 1)); create_icon_material("stream_player_3d_icon", SpatialEditor::get_singleton()->get_icon("GizmoSpatialSamplePlayer", "EditorIcons")); - create_material("stream_player_3d_material", gizmo_color); + create_material("stream_player_3d_material_primary", gizmo_color); + create_material("stream_player_3d_material_secondary", gizmo_color * Color(1, 1, 1, 0.35)); create_handle_material("handles"); } @@ -1160,50 +1161,53 @@ void AudioStreamPlayer3DSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_ void AudioStreamPlayer3DSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { - AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node()); + const AudioStreamPlayer3D *player = Object::cast_to<AudioStreamPlayer3D>(p_gizmo->get_spatial_node()); p_gizmo->clear(); - Ref<Material> icon = get_material("stream_player_3d_icon", p_gizmo); + const Ref<Material> icon = get_material("stream_player_3d_icon", p_gizmo); if (player->is_emission_angle_enabled()) { - Ref<Material> material = get_material("stream_player_3d_material", p_gizmo); - - float pc = player->get_emission_angle(); - - Vector<Vector3> points; - points.resize(208); + const float pc = player->get_emission_angle(); + const float ofs = -Math::cos(Math::deg2rad(pc)); + const float radius = Math::sin(Math::deg2rad(pc)); - float ofs = -Math::cos(Math::deg2rad(pc)); - float radius = Math::sin(Math::deg2rad(pc)); + Vector<Vector3> points_primary; + points_primary.resize(200); for (int i = 0; i < 100; i++) { - float a = i * 2.0 * Math_PI / 100.0; - float an = (i + 1) * 2.0 * Math_PI / 100.0; + const float a = i * 2.0 * Math_PI / 100.0; + const float an = (i + 1) * 2.0 * Math_PI / 100.0; - Vector3 from(Math::sin(a) * radius, Math::cos(a) * radius, ofs); - Vector3 to(Math::sin(an) * radius, Math::cos(an) * radius, ofs); + const Vector3 from(Math::sin(a) * radius, Math::cos(a) * radius, ofs); + const Vector3 to(Math::sin(an) * radius, Math::cos(an) * radius, ofs); - points.write[i * 2 + 0] = from; - points.write[i * 2 + 1] = to; + points_primary.write[i * 2 + 0] = from; + points_primary.write[i * 2 + 1] = to; } - for (int i = 0; i < 4; i++) { + const Ref<Material> material_primary = get_material("stream_player_3d_material_primary", p_gizmo); + p_gizmo->add_lines(points_primary, material_primary); + + Vector<Vector3> points_secondary; + points_secondary.resize(16); - float a = i * 2.0 * Math_PI / 4.0; + for (int i = 0; i < 8; i++) { - Vector3 from(Math::sin(a) * radius, Math::cos(a) * radius, ofs); + const float a = i * 2.0 * Math_PI / 8.0; + const Vector3 from(Math::sin(a) * radius, Math::cos(a) * radius, ofs); - points.write[200 + i * 2 + 0] = from; - points.write[200 + i * 2 + 1] = Vector3(); + points_secondary.write[i * 2 + 0] = from; + points_secondary.write[i * 2 + 1] = Vector3(); } - p_gizmo->add_lines(points, material); + const Ref<Material> material_secondary = get_material("stream_player_3d_material_secondary", p_gizmo); + p_gizmo->add_lines(points_secondary, material_secondary); Vector<Vector3> handles; - float ha = Math::deg2rad(player->get_emission_angle()); + const float ha = Math::deg2rad(player->get_emission_angle()); handles.push_back(Vector3(Math::sin(ha), 0, -Math::cos(ha))); p_gizmo->add_handles(handles, get_material("handles")); } diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 967b0c83ae..21434cd150 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -6700,7 +6700,8 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) { } } - p_node->set_datatype(_resolve_type(node_type, p_node->line)); + node_type = _resolve_type(node_type, p_node->line); + p_node->set_datatype(node_type); return node_type; } diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index bac14707fc..ab6f80bfa9 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -757,20 +757,17 @@ void LineEdit::_notification(int p_what) { } } - float icon_width = MIN(r_icon->get_width(), r_icon->get_width() * (height - (style->get_margin(MARGIN_TOP) + style->get_margin(MARGIN_BOTTOM))) / r_icon->get_height()); - float icon_height = MIN(r_icon->get_height(), height - (style->get_margin(MARGIN_TOP) + style->get_margin(MARGIN_BOTTOM))); - Rect2 icon_region = Rect2(Point2(width - icon_width - style->get_margin(MARGIN_RIGHT), height / 2 - icon_height / 2), Size2(icon_width, icon_height)); - draw_texture_rect_region(r_icon, icon_region, Rect2(Point2(), r_icon->get_size()), color_icon); + r_icon->draw(ci, Point2(width - r_icon->get_width() - style->get_margin(MARGIN_RIGHT), height / 2 - r_icon->get_height() / 2), color_icon); if (align == ALIGN_CENTER) { if (window_pos == 0) { - x_ofs = MAX(style->get_margin(MARGIN_LEFT), int(size.width - cached_text_width - icon_width - style->get_margin(MARGIN_RIGHT) * 2) / 2); + x_ofs = MAX(style->get_margin(MARGIN_LEFT), int(size.width - cached_text_width - r_icon->get_width() - style->get_margin(MARGIN_RIGHT) * 2) / 2); } } else { - x_ofs = MAX(style->get_margin(MARGIN_LEFT), x_ofs - icon_width - style->get_margin(MARGIN_RIGHT)); + x_ofs = MAX(style->get_margin(MARGIN_LEFT), x_ofs - r_icon->get_width() - style->get_margin(MARGIN_RIGHT)); } - ofs_max -= icon_width; + ofs_max -= r_icon->get_width(); } int caret_height = font->get_height() > y_area ? y_area : font->get_height(); @@ -1279,10 +1276,7 @@ void LineEdit::set_cursor_position(int p_pos) { bool display_clear_icon = !text.empty() && is_editable() && clear_button_enabled; if (right_icon.is_valid() || display_clear_icon) { Ref<Texture> r_icon = display_clear_icon ? Control::get_icon("clear") : right_icon; - - float icon_width = MIN(r_icon->get_width(), r_icon->get_width() * (get_size().height - (style->get_margin(MARGIN_TOP) + style->get_margin(MARGIN_BOTTOM))) / r_icon->get_height()); - - window_width -= icon_width; + window_width -= r_icon->get_width(); } if (window_width < 0) @@ -1361,21 +1355,30 @@ Size2 LineEdit::get_minimum_size() const { Ref<StyleBox> style = get_stylebox("normal"); Ref<Font> font = get_font("font"); - Size2 min = style->get_minimum_size(); - min.height += font->get_height(); + Size2 min_size; // Minimum size of text. int space_size = font->get_char_size(' ').x; - int mstext = get_constant("minimum_spaces") * space_size; + min_size.width = get_constant("minimum_spaces") * space_size; if (expand_to_text_length) { // Add a space because some fonts are too exact, and because cursor needs a bit more when at the end. - mstext = MAX(mstext, font->get_string_size(text).x + space_size); + min_size.width = MAX(min_size.width, font->get_string_size(text).x + space_size); } - min.width += mstext; + min_size.height = font->get_height(); + + // Take icons into account. + if (!text.empty() && is_editable() && clear_button_enabled) { + min_size.width = MAX(min_size.width, Control::get_icon("clear")->get_width()); + min_size.height = MAX(min_size.height, Control::get_icon("clear")->get_height()); + } + if (right_icon.is_valid()) { + min_size.width = MAX(min_size.width, right_icon->get_width()); + min_size.height = MAX(min_size.height, right_icon->get_height()); + } - return min; + return style->get_minimum_size() + min_size; } void LineEdit::deselect() { |