fix for transforming parented nodes, the node would check its parent was not transfor...
authorCampbell Barton <ideasman42@gmail.com>
Sun, 5 Aug 2012 21:06:56 +0000 (21:06 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 5 Aug 2012 21:06:56 +0000 (21:06 +0000)
fix for mingw broke from one of my own commits, changing header order fixes.

source/blender/editors/space_node/node_view.c
source/blender/editors/transform/transform_conversions.c

index 0c3a5372e6d51fa4f2eac33c0bc34b42330b5d08..248998a3a56b94dff3e50aafb65805b99b84cb1e 100644 (file)
 
 #include "UI_view2d.h"
 
+#include "MEM_guardedalloc.h"
+
 #include "IMB_imbuf.h"
 #include "IMB_imbuf_types.h"
 
-#include "MEM_guardedalloc.h"
-
 #include "node_intern.h"  /* own include */
 
 
index c8fab021651839f4bf9216616ccda93eb6c49990..5a8e83d3df05ea0334c3229fecbf56207f24b1be 100644 (file)
@@ -5534,25 +5534,20 @@ static void createTransObject(bContext *C, TransInfo *t)
 
 /* transcribe given node into TransData2D for Transforming */
 static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node)
-// static void NodeToTransData(bContext *C, TransInfo *t, TransData2D *td, bNode *node)
 {
        /* hold original location */
        float locxy[2];
        nodeToView(node, 0.0f, 0.0f, &locxy[0], &locxy[1]);
        copy_v2_v2(td2d->loc, locxy);
        td2d->loc[2] = 0.0f;
-       //td2d->loc2d = &node->locx; /* current location */
+       td2d->loc2d = td2d->loc; /* current location */
 
        td->flag = 0;
-       /* exclude nodes whose parent is also transformed */
-       if (node->parent && (node->parent->flag & NODE_TRANSFORM)) {
-               td->flag |= TD_SKIP;
-       }
 
        td->loc = td2d->loc;
        copy_v3_v3(td->iloc, td->loc);
        /* use node center instead of origin (top-left corner) */
-       td->center[0] = locxy[0] - 0.5f * (node->totr.xmax - node->totr.xmin);
+       td->center[0] = locxy[0] + 0.5f * (node->totr.xmax - node->totr.xmin);
        td->center[1] = locxy[1] - 0.5f * (node->totr.ymax - node->totr.ymin);  /* node height is used negative */
        td->center[2] = 0.0f;
 
@@ -5570,36 +5565,48 @@ static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node)
        td->extra = node;
 }
 
-static void createTransNodeData(bContext *C, TransInfo *t)
+static int is_node_parent_select(bNode *node)
+{
+       while ((node = node->parent)) {
+               if (node->flag & NODE_TRANSFORM) {
+                       return TRUE;
+               }
+       }
+       return FALSE;
+}
+
+static void createTransNodeData(bContext *UNUSED(C), TransInfo *t)
 {
        TransData *td;
        TransData2D *td2d;
        SpaceNode *snode = t->sa->spacedata.first;
        bNode *node;
 
+       t->total = 0;
+
        if (!snode->edittree) {
-               t->total = 0;
                return;
        }
 
        /* set transform flags on nodes */
        for (node = snode->edittree->nodes.first; node; node = node->next) {
-               if ((node->flag & NODE_SELECT) || (node->parent && (node->parent->flag & NODE_TRANSFORM)))
+               if (node->flag & NODE_SELECT && is_node_parent_select(node) == FALSE) {
                        node->flag |= NODE_TRANSFORM;
-               else
+                       t->total++;
+               }
+               else {
                        node->flag &= ~NODE_TRANSFORM;
+               }
        }
 
-       t->total = CTX_DATA_COUNT(C, selected_nodes);
-
        td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransNode TransData");
        td2d = t->data2d = MEM_callocN(t->total * sizeof(TransData2D), "TransNode TransData2D");
 
-       CTX_DATA_BEGIN(C, bNode *, selnode, selected_nodes)
-       {
-               NodeToTransData(td++, td2d++, selnode);
+       for (node = snode->edittree->nodes.first; node; node = node->next) {
+               if (node->flag & NODE_TRANSFORM) {
+                       NodeToTransData(td++, td2d++, node);
+               }
        }
-       CTX_DATA_END
 }
 
 /* *** CLIP EDITOR *** */