diff options
author | Jesse Yurkovich <jesse.y@gmail.com> | 2021-08-17 07:19:39 +0300 |
---|---|---|
committer | Jesse Yurkovich <jesse.y@gmail.com> | 2021-08-17 07:19:39 +0300 |
commit | eaa152738523bdd2163330fda7ffb1ad62e559cd (patch) | |
tree | 4ffcca90d73d247838abebd1a0b1330b77fb670e /source | |
parent | 4dba2060118b43699a40ae04a66f75ba5f9c745e (diff) |
UDIM: Fix tile number calculation when adding a range of image tiles
When adding a range of tiles, the operator could incorrectly calculate
the end_tile. It would not account for the start_tile itself and the
IMA_UDIM_MAX value was 1 too small. This is most noticeable when
attempting to fill the entire supported range of tiles.
Differential Revision: https://developer.blender.org/D11857
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_image.h | 2 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_ops.c | 5 |
2 files changed, 4 insertions, 3 deletions
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index d298e5dcf6d..ac73bd2b595 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -45,7 +45,7 @@ struct StampData; struct anim; #define IMA_MAX_SPACE 64 -#define IMA_UDIM_MAX 1999 +#define IMA_UDIM_MAX 2000 void BKE_images_init(void); void BKE_images_exit(void); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 613042a2ab9..999d2956fef 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -3922,7 +3922,7 @@ static int tile_add_exec(bContext *C, wmOperator *op) Image *ima = CTX_data_edit_image(C); int start_tile = RNA_int_get(op->ptr, "number"); - int end_tile = start_tile + RNA_int_get(op->ptr, "count"); + int end_tile = start_tile + RNA_int_get(op->ptr, "count") - 1; if (start_tile < 1001 || end_tile > IMA_UDIM_MAX) { BKE_report(op->reports, RPT_ERROR, "Invalid UDIM index range was specified"); @@ -3933,7 +3933,7 @@ static int tile_add_exec(bContext *C, wmOperator *op) char *label = RNA_string_get_alloc(op->ptr, "label", NULL, 0); bool created_tile = false; - for (int tile_number = start_tile; tile_number < end_tile; tile_number++) { + for (int tile_number = start_tile; tile_number <= end_tile; tile_number++) { ImageTile *tile = BKE_image_add_tile(ima, tile_number, label); if (tile != NULL) { @@ -3949,6 +3949,7 @@ static int tile_add_exec(bContext *C, wmOperator *op) MEM_freeN(label); if (!created_tile) { + BKE_report(op->reports, RPT_WARNING, "No UDIM tiles were created"); return OPERATOR_CANCELLED; } |