[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40016] trunk/blender/source/blender/ editors/space_node/node_edit.c: Node comparison function for sort order did not take parent selection into account .
Lukas Toenne
lukas.toenne at googlemail.com
Wed Sep 7 17:11:36 CEST 2011
Revision: 40016
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40016
Author: lukastoenne
Date: 2011-09-07 15:11:36 +0000 (Wed, 07 Sep 2011)
Log Message:
-----------
Node comparison function for sort order did not take parent selection into account.
Modified Paths:
--------------
trunk/blender/source/blender/editors/space_node/node_edit.c
Modified: trunk/blender/source/blender/editors/space_node/node_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/node_edit.c 2011-09-07 15:09:03 UTC (rev 40015)
+++ trunk/blender/source/blender/editors/space_node/node_edit.c 2011-09-07 15:11:36 UTC (rev 40016)
@@ -607,28 +607,45 @@
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;
More information about the Bf-blender-cvs
mailing list