1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-06 12:20:30 +00:00

Merge pull request #23407 from bojidar-bg/3281-ysort-recursive

Y-Sort children together in nested YSorts
This commit is contained in:
Rémi Verschelde
2018-11-12 20:42:55 +01:00
committed by GitHub
2 changed files with 62 additions and 12 deletions

View File

@@ -48,6 +48,9 @@ public:
bool use_parent_material;
int index;
bool children_order_dirty;
int ysort_children_count;
Transform2D ysort_xform;
Vector2 ysort_pos;
Vector<Item *> child_items;
@@ -61,6 +64,9 @@ public:
use_parent_material = false;
z_relative = true;
index = 0;
ysort_children_count = -1;
ysort_xform = Transform2D();
ysort_pos = Vector2();
}
};
@@ -76,10 +82,10 @@ public:
_FORCE_INLINE_ bool operator()(const Item *p_left, const Item *p_right) const {
if (Math::abs(p_left->xform.elements[2].y - p_right->xform.elements[2].y) < CMP_EPSILON)
return p_left->xform.elements[2].x < p_right->xform.elements[2].x;
if (Math::abs(p_left->ysort_pos.y - p_right->ysort_pos.y) < CMP_EPSILON)
return p_left->ysort_pos.x < p_right->ysort_pos.x;
else
return p_left->xform.elements[2].y < p_right->xform.elements[2].y;
return p_left->ysort_pos.y < p_right->ysort_pos.y;
}
};