[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49583] trunk/blender/source/blender/ editors/transform/transform_conversions.c: fix for transforming parented nodes (parent relative offset wasn' t taken into account)

Campbell Barton ideasman42 at gmail.com
Sun Aug 5 22:16:15 CEST 2012


Revision: 49583
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49583
Author:   campbellbarton
Date:     2012-08-05 20:16:14 +0000 (Sun, 05 Aug 2012)
Log Message:
-----------
fix for transforming parented nodes (parent relative offset wasn't taken into account)

Modified Paths:
--------------
    trunk/blender/source/blender/editors/transform/transform_conversions.c

Modified: trunk/blender/source/blender/editors/transform/transform_conversions.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_conversions.c	2012-08-05 18:12:34 UTC (rev 49582)
+++ trunk/blender/source/blender/editors/transform/transform_conversions.c	2012-08-05 20:16:14 UTC (rev 49583)
@@ -2189,12 +2189,21 @@
 void flushTransNodes(TransInfo *t)
 {
 	int a;
-	TransData2D *td;
+	TransData *td;
+	TransData2D *td2d;
 
 	/* flush to 2d vector from internally used 3d vector */
-	for (a = 0, td = t->data2d; a < t->total; a++, td++) {
-		td->loc2d[0] = td->loc[0];
-		td->loc2d[1] = td->loc[1];
+	for (a = 0, td = t->data, td2d = t->data2d; a < t->total; a++, td++, td2d++) {
+		bNode *node = td->extra;
+		float locxy[2];
+		if (node->parent) {
+			nodeFromView(node->parent, td2d->loc[0], td2d->loc[1], &locxy[0], &locxy[1]);
+		}
+		else {
+			copy_v2_v2(locxy, td2d->loc);
+		}
+		node->locx = locxy[0];
+		node->locy = locxy[1];
 	}
 	
 	/* handle intersection with noodles */
@@ -5527,10 +5536,12 @@
 static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node)
 // static void NodeToTransData(bContext *C, TransInfo *t, TransData2D *td, bNode *node)
 {
-	td2d->loc[0] = node->locx; /* hold original location */
-	td2d->loc[1] = node->locy;
+	/* 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 = &node->locx; /* current location */
 
 	td->flag = 0;
 	/* exclude nodes whose parent is also transformed */
@@ -5541,8 +5552,8 @@
 	td->loc = td2d->loc;
 	copy_v3_v3(td->iloc, td->loc);
 	/* use node center instead of origin (top-left corner) */
-	td->center[0] = node->locx + 0.5f * (node->totr.xmax - node->totr.xmin);
-	td->center[1] = node->locy - 0.5f * (node->totr.ymax - node->totr.ymin);	/* node height is used negative */
+	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;
 
 	memset(td->axismtx, 0, sizeof(td->axismtx));
@@ -5585,7 +5596,9 @@
 	td2d = t->data2d = MEM_callocN(t->total * sizeof(TransData2D), "TransNode TransData2D");
 
 	CTX_DATA_BEGIN(C, bNode *, selnode, selected_nodes)
-	NodeToTransData(td++, td2d++, selnode);
+	{
+		NodeToTransData(td++, td2d++, selnode);
+	}
 	CTX_DATA_END
 }
 




More information about the Bf-blender-cvs mailing list