diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-11-28 09:00:27 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-11-28 09:02:03 +0300 |
commit | ca05985ca72ecb33f81d25976ee56903dab892dc (patch) | |
tree | 3953770f7a550321a46dd205b9cbbfdf7739209f /source/blender/editors/space_node | |
parent | 62edc31d3433a9fded71e92d4168bcbf61c5b4bd (diff) |
Gizmo: fix compositor node crop w/ negative rectangles
min/max could be negative, causing the gizmo to fail.
Diffstat (limited to 'source/blender/editors/space_node')
-rw-r--r-- | source/blender/editors/space_node/node_gizmo.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/source/blender/editors/space_node/node_gizmo.c b/source/blender/editors/space_node/node_gizmo.c index 6778ba8fb04..303962138a8 100644 --- a/source/blender/editors/space_node/node_gizmo.c +++ b/source/blender/editors/space_node/node_gizmo.c @@ -270,8 +270,8 @@ static void gizmo_node_crop_prop_matrix_get( bool is_relative = (bool)node->custom2; rctf rct; two_xy_to_rect(nxy, &rct, dims, is_relative); - matrix[0][0] = BLI_rctf_size_x(&rct); - matrix[1][1] = BLI_rctf_size_y(&rct); + matrix[0][0] = fabsf(BLI_rctf_size_x(&rct)); + matrix[1][1] = fabsf(BLI_rctf_size_y(&rct)); matrix[3][0] = (BLI_rctf_cent_x(&rct) - 0.5f) * dims[0]; matrix[3][1] = (BLI_rctf_cent_y(&rct) - 0.5f) * dims[1]; } @@ -289,9 +289,17 @@ static void gizmo_node_crop_prop_matrix_set( bool is_relative = (bool)node->custom2; rctf rct; two_xy_to_rect(nxy, &rct, dims, is_relative); - BLI_rctf_resize(&rct, matrix[0][0], matrix[1][1]); + const bool nx = rct.xmin > rct.xmax; + 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); BLI_rctf_isect(&(rctf){.xmin = 0, .ymin = 0, .xmax = 1, .ymax = 1}, &rct, &rct); + if (nx) { + SWAP(float, rct.xmin, rct.xmax); + } + if (ny) { + SWAP(float, rct.ymin, rct.ymax); + } two_xy_from_rect(nxy, &rct, dims, is_relative); gizmo_node_crop_update(crop_group); } @@ -309,7 +317,7 @@ static bool WIDGETGROUP_node_crop_poll(const bContext *C, wmGizmoGroupType *UNUS if (node && ELEM(node->type, CMP_NODE_CROP)) { /* ignore 'use_crop_size', we can't usefully edit the crop in this case. */ - if ((node->custom1 & (0 << 1)) == 0) { + if ((node->custom1 & (1 << 0)) == 0) { return true; } } |