summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/array.cpp3
-rw-r--r--editor/import/editor_scene_importer_gltf.cpp25
-rw-r--r--modules/gdscript/gdscript_parser.cpp3
-rw-r--r--scene/gui/line_edit.cpp37
4 files changed, 48 insertions, 20 deletions
diff --git a/core/array.cpp b/core/array.cpp
index ac30df08bc..fd507f46c3 100644
--- a/core/array.cpp
+++ b/core/array.cpp
@@ -240,6 +240,9 @@ int Array::_clamp_index(int p_index) const {
Array Array::slice(int p_begin, int p_end, int p_step, bool p_deep) const { // like python, but inclusive on upper bound
Array new_arr;
+ if (empty()) // Don't try to slice empty arrays.
+ return new_arr;
+
p_begin = Array::_fix_slice_index(p_begin, size(), -1); // can't start out of range
p_end = Array::_fix_slice_index(p_end, size(), 0);
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/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() {