Maniphest T94784

Crop node gizmo doesn't work
Closed, Resolved

Assigned To
Sebastian Parborg (zeddb)
Authored By
Campbell Barton (campbellbarton)
Jan 10 2022, 11:37 AM
Tags
  • Compositing
  • VFX & Video
Subscribers
Campbell Barton (campbellbarton)
Hans Goudey (HooglyBoogly)
Philipp Oeser (lichtwerk)

Description

The crop nodes gizmo displays as expected in 3.0 but can't be interacted with.

This is a regression in rB482806c81678e351ff171c68a757386a5b2d4676 (should have been picked up in patch review).

With the attached file

  • Toggle the backdrop off/on so it refreshes (seems like a bug that this is needed at all...).
  • Select a corner of the crop node and drag it.
  • Notice all values are set to zero.

2.93 and prior to rB482806c81678e351ff171c68a757386a5b2d4676 work as expected.

Revisions and Commits

rB Blender

Related Objects

Mentioned In
rBc69a581c0b95: Cleanup: avoid positional struct initialization
T93479: 3.0 Potential candidates for corrective releases
Mentioned Here
rB5703efab886d: Fix T94784: Crop node gizmo doesn't work
rBcbca71a7cff3: Cleanup: Move remaning node editor files to C++
rB482806c81678: VSE: Implement the bounding box (xform) tool in the seq preview window

Event Timeline

Campbell Barton (campbellbarton) created this task.Jan 10 2022, 11:37 AM
Philipp Oeser (lichtwerk) changed the task status from Needs Triage to Confirmed.Jan 10 2022, 11:55 AM
Philipp Oeser (lichtwerk) triaged this task as High priority.
Philipp Oeser (lichtwerk) added a project: VFX & Video.
Philipp Oeser (lichtwerk) added a subscriber: Philipp Oeser (lichtwerk).

CC @Sebastian Parborg (zeddb)

Campbell Barton (campbellbarton) updated the task description.Jan 10 2022, 12:48 PM
Sebastian Parborg (zeddb) added a comment.EditedJan 12 2022, 3:56 PM

The bisection didn't catch the correct commit actually.
My commit broke it, yes. but we reverted part of it later so that the code started working again.

The commit that breaks this is actually rBcbca71a7cff3
There is a mistake where the rctf that is passed to BLI_rctf_isect had its max and min values swapped.

The older code explicitly stated which variables it would set, however the raw order is not the same.
So the clean up changes set the xmin AND xmax to zero instead of xmin and ymin.

I think this is the correct fix:

diff --git a/source/blender/editors/space_node/node_gizmo.cc b/source/blender/editors/space_node/node_gizmo.cc
index 41d13976209..9aa4f299774 100644
--- a/source/blender/editors/space_node/node_gizmo.cc
+++ b/source/blender/editors/space_node/node_gizmo.cc
@@ -292,7 +292,7 @@ static void gizmo_node_crop_prop_matrix_set(const wmGizmo *gz,
   const bool ny = rct.ymin > rct.ymax;
   BLI_rctf_resize(&rct, fabsf(matrix[0][0]), fabsf(matrix[1][1]));
   BLI_rctf_recenter(&rct, (matrix[3][0] / dims[0]) + 0.5f, (matrix[3][1] / dims[1]) + 0.5f);
-  const rctf rct_isect{0, 0, 1, 1};
+  const rctf rct_isect{0, 1, 0, 1};
   BLI_rctf_isect(&rct_isect, &rct, &rct);
   if (nx) {
     SWAP(float, rct.xmin, rct.xmax);

Can you guys confirm?

Hans Goudey (HooglyBoogly) added a subscriber: Hans Goudey (HooglyBoogly).Jan 12 2022, 4:18 PM

That seems to work for me, sorry for the typo.

Campbell Barton (campbellbarton) added a comment.EditedJan 13 2022, 7:48 AM

This works, although I'm increasingly of the opinion that we should avoid positional arguments when initializing struct members especially when moving C code to C++, it's bitten us a few times, is less readable - and can potentially backfire if struct members are ever recorded.

Sebastian Parborg (zeddb) added a comment.Jan 13 2022, 4:52 PM

@Campbell Barton (campbellbarton) how would you like it to be initialized?

Campbell Barton (campbellbarton) added a comment.EditedJan 14 2022, 12:24 AM

Until MSVC supports C99's struct initialization - this is the closest match AFAICS.

rctf rct_isect{};
rct_isect.xmin = 0;
rct_isect.xmax = 1;
rct_isect.ymin = 0;
rct_isect.ymax = 1;
  • The {} are important, to zero members not assigned later (in the case of rctf it's not so important but as a convention I think we should stick to this as it's caused multiple bugs when moving from C to C++ (Unless leaving other members uninitialized is intended, in that case it can be left out).
  • It's unfortinate the struct cant remain const but I don't think there are better alternatives.
Sebastian Parborg (zeddb) closed this task as Resolved by committing rB5703efab886d: Fix T94784: Crop node gizmo doesn't work.Jan 14 2022, 5:44 PM
Sebastian Parborg (zeddb) added a commit: rB5703efab886d: Fix T94784: Crop node gizmo doesn't work.
Philipp Oeser (lichtwerk) added a comment.Jan 17 2022, 12:36 PM

@Sebastian Parborg (zeddb): for 3.0.1 corrective release, rB5703efab886d: Fix T94784: Crop node gizmo doesn't work doesnt apply (rBcbca71a7cff3: Cleanup: Move remaning node editor files to C++ is not in 3.0)

In T94784#1287023, @Sebastian Parborg (zeddb) wrote:

My commit broke it, yes. but we reverted part of it later so that the code started working again.

What was reverted partially? What should go into 3.0.1? Are we sure this is actually broken in blender-v3.0-release? (I cannot reproduce there... neither in 3.0 release for some reason, pretty sure I could repro initially though)

Sebastian Parborg (zeddb) added a comment.Jan 17 2022, 3:32 PM

@Philipp Oeser (lichtwerk) my bad, the clean up commit from Hans is indeed not in the 3.0 branch.
So disregard this fix.

Campbell Barton (campbellbarton) mentioned this in rBc69a581c0b95: Cleanup: avoid positional struct initialization.Jan 24 2022, 4:28 AM