Fix #117235: Frame node sorting sometimes incorrect
Sometimes a frame node can't be behind another because of parenting. Comparing the two nodes with `compare_node_depth` would give that result too, but sometimes every combination of frame node isn't tested. In that case, the existing values of `ui_order` matter, and we should start the sort there. So first sort based on the existing order, then do a stable sort to fulfill the constrains coming from selection and parenting.
This commit is contained in:
@@ -289,6 +289,9 @@ static bool compare_node_depth(const bNode *a, const bNode *b)
|
||||
void tree_draw_order_update(bNodeTree &ntree)
|
||||
{
|
||||
Array<bNode *> sort_nodes = ntree.all_nodes();
|
||||
std::sort(sort_nodes.begin(), sort_nodes.end(), [](bNode *a, bNode *b) {
|
||||
return a->ui_order < b->ui_order;
|
||||
});
|
||||
std::stable_sort(sort_nodes.begin(), sort_nodes.end(), compare_node_depth);
|
||||
for (const int i : sort_nodes.index_range()) {
|
||||
sort_nodes[i]->ui_order = i;
|
||||
|
||||
Reference in New Issue
Block a user