Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2021-08-25 01:40:18 +0300
committerHans Goudey <h.goudey@me.com>2021-08-25 01:40:18 +0300
commit137a5e162c2435662dbb299ff49771e7d2e7598f (patch)
treea40ebf526c1a320c7a9fa0c8456dfe2ffd4db6a6 /source/blender/editors/space_image/image_ops.c
parentaad18a005026cfaa19c45f2477318c6e06303eae (diff)
parent5ef3afd87c54b47614254d95c9b2e9a17c60f76e (diff)
Merge branch 'master' into refactor-idprop-ui-data
Diffstat (limited to 'source/blender/editors/space_image/image_ops.c')
-rw-r--r--source/blender/editors/space_image/image_ops.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 613042a2ab9..4f8feda3911 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -1289,8 +1289,10 @@ static Image *image_open_single(Main *bmain,
}
if ((range->length > 1) && (ima->source == IMA_SRC_FILE)) {
- if (range->udim_tiles.first && range->offset == 1001) {
+ if (range->udim_tiles.first) {
ima->source = IMA_SRC_TILED;
+ ImageTile *first_tile = ima->tiles.first;
+ first_tile->tile_number = range->offset;
LISTBASE_FOREACH (LinkData *, node, &range->udim_tiles) {
BKE_image_add_tile(ima, POINTER_AS_INT(node->data), NULL);
}
@@ -1806,10 +1808,13 @@ static int image_save_options_init(Main *bmain,
}
/* append UDIM numbering if not present */
- if (ima->source == IMA_SRC_TILED &&
- (BLI_path_sequence_decode(ima->filepath, NULL, NULL, NULL) != 1001)) {
+ if (ima->source == IMA_SRC_TILED) {
+ char udim[6];
+ ImageTile *tile = ima->tiles.first;
+ BLI_snprintf(udim, sizeof(udim), ".%d", tile->tile_number);
+
int len = strlen(opts->filepath);
- STR_CONCAT(opts->filepath, len, ".1001");
+ STR_CONCAT(opts->filepath, len, udim);
}
}
@@ -3868,9 +3873,9 @@ static void tile_fill_init(PointerRNA *ptr, Image *ima, ImageTile *tile)
/* Acquire ibuf to get the default values.
* If the specified tile has no ibuf, try acquiring the main tile instead
- * (unless the specified tile already was the main tile). */
+ * (unless the specified tile already was the first tile). */
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
- if (ibuf == NULL && (tile != NULL) && (tile->tile_number != 1001)) {
+ if (ibuf == NULL && (tile != NULL) && (tile != ima->tiles.first)) {
ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
}
@@ -3922,7 +3927,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");
@@ -3930,28 +3935,32 @@ static int tile_add_exec(bContext *C, wmOperator *op)
}
bool fill_tile = RNA_boolean_get(op->ptr, "fill");
- char *label = RNA_string_get_alloc(op->ptr, "label", NULL, 0);
+ char *label = RNA_string_get_alloc(op->ptr, "label", NULL, 0, NULL);
+
+ /* BKE_image_add_tile assumes a pre-sorted list of tiles. */
+ BKE_image_sort_tiles(ima);
- bool created_tile = false;
- for (int tile_number = start_tile; tile_number < end_tile; tile_number++) {
+ ImageTile *last_tile_created = NULL;
+ 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) {
- ima->active_tile_index = BLI_findindex(&ima->tiles, tile);
-
if (fill_tile) {
do_fill_tile(op->ptr, ima, tile);
}
- created_tile = true;
+ last_tile_created = tile;
}
}
MEM_freeN(label);
- if (!created_tile) {
+ if (!last_tile_created) {
+ BKE_report(op->reports, RPT_WARNING, "No UDIM tiles were created");
return OPERATOR_CANCELLED;
}
+ ima->active_tile_index = BLI_findindex(&ima->tiles, last_tile_created);
+
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL);
return OPERATOR_FINISHED;
}
@@ -4040,7 +4049,7 @@ static bool tile_remove_poll(bContext *C)
{
Image *ima = CTX_data_edit_image(C);
- return (ima != NULL && ima->source == IMA_SRC_TILED && ima->active_tile_index != 0);
+ return (ima != NULL && ima->source == IMA_SRC_TILED && !BLI_listbase_is_single(&ima->tiles));
}
static int tile_remove_exec(bContext *C, wmOperator *UNUSED(op))