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.
This commit is contained in:
Lukas Tönne 2014-03-28 10:05:16 +01:00
parent f0106d2985
commit 29888dcea0
Notes: blender-bot 2023-02-14 10:53:21 +01:00
Referenced by issue #39455, node editor: nodes scaled wrong when some in a frame, some not
1 changed files with 29 additions and 8 deletions

View File

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