[Bf-blender-cvs] [29888dc] master: Fix T39455: Nodes scaled wrong when some in a frame, some not.

Lukas Tönne noreply at git.blender.org
Fri Mar 28 10:12:46 CET 2014


Commit: 29888dcea0519ebe5873db7de5a6667414153ee9
Author: Lukas Tönne
Date:   Fri Mar 28 10:05:16 2014 +0100
https://developer.blender.org/rB29888dcea0519ebe5873db7de5a6667414153ee9

Fix T39455: Nodes scaled wrong when some in a frame, some not.

Transform operators for nodes were not taking parent nodes (frames) into
account. Now use the nodeToView/nodeFromView functions to apply
transforms in local node space.

===================================================================

M	source/blender/editors/transform/transform_conversions.c

===================================================================

diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 10575eb..886dea2 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -2384,15 +2384,25 @@ void flushTransNodes(TransInfo *t)
 	/* flush to 2d vector from internally used 3d vector */
 	for (a = 0, td = t->data, td2d = t->data2d; a < t->total; a++, td++, td2d++) {
 		bNode *node = td->extra;
+		float locx, locy;
 
 		/* weirdo - but the node system is a mix of free 2d elements and dpi sensitive UI */
 #ifdef USE_NODE_CENTER
-		node->locx = (td2d->loc[0] - (BLI_rctf_size_x(&node->totr)) * +0.5f) / dpi_fac;
-		node->locy = (td2d->loc[1] - (BLI_rctf_size_y(&node->totr)) * -0.5f) / dpi_fac;
+		locx = (td2d->loc[0] - (BLI_rctf_size_x(&node->totr)) * +0.5f) / dpi_fac;
+		locy = (td2d->loc[1] - (BLI_rctf_size_y(&node->totr)) * -0.5f) / dpi_fac;
 #else
-		node->locx = td2d->loc[0] / dpi_fac;
-		node->locy = td2d->loc[1] / dpi_fac;
+		locx = td2d->loc[0] / dpi_fac;
+		locy = td2d->loc[1] / dpi_fac;
 #endif
+		
+		/* account for parents (nested nodes) */
+		if (node->parent) {
+			nodeFromView(node->parent, locx, locy, &node->locx, &node->locy);
+		}
+		else {
+			node->locx = locx;
+			node->locy = locy;
+		}
 	}
 	
 	/* handle intersection with noodles */
@@ -5907,14 +5917,25 @@ static void createTransObject(bContext *C, TransInfo *t)
 /* transcribe given node into TransData2D for Transforming */
 static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node, const float dpi_fac)
 {
+	float locx, locy;
+	
+	/* account for parents (nested nodes) */
+	if (node->parent) {
+		nodeToView(node->parent, node->locx, node->locy, &locx, &locy);
+	}
+	else {
+		locx = node->locx;
+		locy = node->locy;
+	}
+	
 	/* use top-left corner as the transform origin for nodes */
 	/* weirdo - but the node system is a mix of free 2d elements and dpi sensitive UI */
 #ifdef USE_NODE_CENTER
-	td2d->loc[0] = (node->locx * dpi_fac) + (BLI_rctf_size_x(&node->totr) * +0.5f);
-	td2d->loc[1] = (node->locy * dpi_fac) + (BLI_rctf_size_y(&node->totr) * -0.5f);
+	td2d->loc[0] = (locx * dpi_fac) + (BLI_rctf_size_x(&node->totr) * +0.5f);
+	td2d->loc[1] = (locy * dpi_fac) + (BLI_rctf_size_y(&node->totr) * -0.5f);
 #else
-	td2d->loc[0] = node->locx * dpi_fac;
-	td2d->loc[1] = node->locy * dpi_fac;
+	td2d->loc[0] = locx * dpi_fac;
+	td2d->loc[1] = locy * dpi_fac;
 #endif
 	td2d->loc[2] = 0.0f;
 	td2d->loc2d = td2d->loc; /* current location */




More information about the Bf-blender-cvs mailing list