Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Toenne <lukas.toenne@googlemail.com>2011-09-07 19:11:36 +0400
committerLukas Toenne <lukas.toenne@googlemail.com>2011-09-07 19:11:36 +0400
commitc00eba13e0303efeb2c0e4846eec5376661c92be (patch)
tree75ddcf6d1b7fbb7433bab29b7d1437881a786608 /source/blender/editors
parent08a7a680ac855fcbec009a4c0c693917e6e74353 (diff)
Node comparison function for sort order did not take parent selection into account.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/space_node/node_edit.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index 43f8a071597..bb85a0dbe3a 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -607,28 +607,45 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node)
static int compare_nodes(bNode *a, bNode *b)
{
bNode *parent;
+ /* These tell if either the node or any of the parent nodes is selected.
+ * A selected parent means an unselected node is also in foreground!
+ */
+ int a_select=(a->flag & NODE_SELECT), b_select=(b->flag & NODE_SELECT);
+ int a_active=(a->flag & NODE_ACTIVE), b_active=(b->flag & NODE_ACTIVE);
/* if one is an ancestor of the other */
/* XXX there might be a better sorting algorithm for stable topological sort, this is O(n^2) worst case */
for (parent = a->parent; parent; parent=parent->parent) {
+ /* if b is an ancestor, it is always behind a */
if (parent==b)
return 1;
+ /* any selected ancestor moves the node forward */
+ if (parent->flag & NODE_ACTIVE)
+ a_active = 1;
+ if (parent->flag & NODE_SELECT)
+ a_select = 1;
}
for (parent = b->parent; parent; parent=parent->parent) {
+ /* if a is an ancestor, it is always behind b */
if (parent==a)
return 0;
+ /* any selected ancestor moves the node forward */
+ if (parent->flag & NODE_ACTIVE)
+ b_active = 1;
+ if (parent->flag & NODE_SELECT)
+ b_select = 1;
}
/* if one of the nodes is in the background and the other not */
- if ((a->flag & NODE_BACKGROUND) && !(b->typeinfo->flag & NODE_BACKGROUND))
+ if ((a->flag & NODE_BACKGROUND) && !(b->flag & NODE_BACKGROUND))
return 0;
- else if (!(a->flag & NODE_BACKGROUND) && (b->typeinfo->flag & NODE_BACKGROUND))
+ else if (!(a->flag & NODE_BACKGROUND) && (b->flag & NODE_BACKGROUND))
return 1;
/* if one has a higher selection state (active > selected > nothing) */
- if (!(b->flag & NODE_ACTIVE) && (a->flag & NODE_ACTIVE))
+ if (!b_active && a_active)
return 1;
- else if (!(b->flag & NODE_SELECT) && ((a->flag & NODE_ACTIVE) || (a->flag & NODE_SELECT)))
+ else if (!b_select && (a_active || a_select))
return 1;
return 0;