Fix #106043: Moving frame node jittering while cursor is still

The fix for #105363 (6d3ce8273a) made the transform system respect
(Frame) nodes `offsetx`/`offsety`.

Now Node Editors run the transform system even if the mouse is still (due to edge panning -- unnecessarily, see PR #106301 for fixing this). And due to the way `frame_node_prepare_for_draw` recalculates these offsets (based on
on updated positions and `node.runtime->totr` [which in turn gets rounded in `node_update_basis` -- so subpixel precision is lost there, see [1]]), this can lead to slight imprecisions/noise/jitter during transform (if we use float offsets, see the PR for more info).

So to counter this, use rounded offsets now [which will keep the whole circle stable].

NOTE: PR #106301 would fix this already for having the cursor still, but this patch still improves slight jitter when moving, so will commit separately.

[1] comment from `node_update_basis`
> /* Round the node origin because text contents are always pixel-aligned. */

Pull Request: https://projects.blender.org/blender/blender/pulls/106096
This commit is contained in:
Philipp Oeser
2023-03-30 14:02:45 +02:00
committed by Philipp Oeser
parent d90795bc3c
commit 2a6f177e8e

View File

@@ -48,11 +48,15 @@ static void create_transform_data_for_node(TransData &td,
/* account for parents (nested nodes) */
if (node.parent) {
nodeToView(node.parent, node.locx + node.offsetx, node.locy + node.offsety, &locx, &locy);
nodeToView(node.parent,
node.locx + roundf(node.offsetx),
node.locy + roundf(node.offsety),
&locx,
&locy);
}
else {
locx = node.locx + node.offsetx;
locy = node.locy + node.offsety;
locx = node.locx + roundf(node.offsetx);
locy = node.locy + roundf(node.offsety);
}
/* use top-left corner as the transform origin for nodes */
@@ -245,14 +249,14 @@ static void flushTransNodes(TransInfo *t)
/* account for parents (nested nodes) */
if (node->parent) {
nodeFromView(node->parent,
loc[0] - node->offsetx,
loc[1] - node->offsety,
loc[0] - roundf(node->offsetx),
loc[1] - roundf(node->offsety),
&node->locx,
&node->locy);
}
else {
node->locx = loc[0] - node->offsetx;
node->locy = loc[1] - node->offsety;
node->locx = loc[0] - roundf(node->offsetx);
node->locy = loc[1] - roundf(node->offsety);
}
}