Gizmo: fix compositor node crop w/ negative rectangles
min/max could be negative, causing the gizmo to fail.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user