/* 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;
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 *** */