Revision: 61186
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=61186
Author:   lukastoenne
Date:     2013-11-07 09:15:29 +0000 (Thu, 07 Nov 2013)
Log Message:
-----------
Fix for node transform offsets when adding new nodes: The transform operator 
was using the node->totr rect for defining the initial location of the node - 
but this is only defined after the node has been
drawn at least once, so nodes would jump to (0,0) after adding ... Use the 
locx/locy instead (including DPI factor), which is more reliable.

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

Modified: trunk/blender/source/blender/editors/space_node/node_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/node_draw.c 2013-11-07 
09:02:30 UTC (rev 61185)
+++ trunk/blender/source/blender/editors/space_node/node_draw.c 2013-11-07 
09:15:29 UTC (rev 61186)
@@ -330,6 +330,7 @@
        
        /* get "global" coords */
        node_to_view(node, 0.0f, 0.0f, &locx, &locy);
+       printf("DRAW: %s at (%f, %f)\n", node->name, locx, locy);
        dy = locy;
        
        /* header */

Modified: trunk/blender/source/blender/editors/transform/transform_conversions.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_conversions.c      
2013-11-07 09:02:30 UTC (rev 61185)
+++ trunk/blender/source/blender/editors/transform/transform_conversions.c      
2013-11-07 09:15:29 UTC (rev 61186)
@@ -5963,8 +5963,9 @@
 static void NodeToTransData(TransData *td, TransData2D *td2d, bNode *node)
 {
        /* use top-left corner as the transform origin for nodes */
-       td2d->loc[0] = node->totr.xmin;
-       td2d->loc[1] = node->totr.ymax;
+       /* weirdo - but the node system is a mix of free 2d elements and dpi 
sensitive UI */
+       td2d->loc[0] = UI_DPI_FAC * node->locx;
+       td2d->loc[1] = UI_DPI_FAC * node->locy;
        td2d->loc[2] = 0.0f;
        td2d->loc2d = td2d->loc; /* current location */
 
@@ -5973,8 +5974,8 @@
        td->loc = td2d->loc;
        copy_v3_v3(td->iloc, td->loc);
        /* use node center instead of origin (top-left corner) */
-       td->center[0] = BLI_rctf_cent_x(&node->totr);
-       td->center[1] = BLI_rctf_cent_y(&node->totr);
+       td->center[0] = td2d->loc[0] + BLI_rctf_size_x(&node->totr);
+       td->center[1] = td2d->loc[1] + BLI_rctf_size_y(&node->totr);
        td->center[2] = 0.0f;
 
        memset(td->axismtx, 0, sizeof(td->axismtx));

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to