Fix #34779: Channels disappear from multilayer exr sequence
Issue was caused by delayed or missing image user frame number update, which lead to image loading failure in cases node is updating from image signal callback. Solved in a way that file from image datablock is used for sockets detection instead of loading image for current frame.
This commit is contained in:
parent
cb6f4160cc
commit
68d8c6ad3d
|
@ -232,6 +232,8 @@ void BKE_image_buf_fill_checker_color(unsigned char *rect, float *rect_float, in
|
|||
unsigned char *BKE_image_get_pixels_for_frame(struct Image *image, int frame);
|
||||
float *BKE_image_get_float_pixels_for_frame(struct Image *image, int frame);
|
||||
|
||||
/* Guess offset for the first frame in the sequence */
|
||||
int BKE_image_sequence_guess_offset(struct Image *image);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -3430,3 +3430,15 @@ float *BKE_image_get_float_pixels_for_frame(struct Image *image, int frame)
|
|||
|
||||
return pixels;
|
||||
}
|
||||
|
||||
int BKE_image_sequence_guess_offset(Image *image)
|
||||
{
|
||||
unsigned short numlen;
|
||||
char head[FILE_MAX], tail[FILE_MAX];
|
||||
char num[FILE_MAX] = {0};
|
||||
|
||||
BLI_stringdec(image->name, head, tail, &numlen);
|
||||
BLI_strncpy(num, image->name + strlen(head), numlen + 1);
|
||||
|
||||
return atoi(num);
|
||||
}
|
||||
|
|
|
@ -174,11 +174,24 @@ static void cmp_node_image_create_outputs(bNodeTree *ntree, bNode *node)
|
|||
{
|
||||
Image *ima= (Image *)node->id;
|
||||
if (ima) {
|
||||
ImageUser *iuser= node->storage;
|
||||
ImageUser *iuser = node->storage;
|
||||
ImageUser load_iuser = {0};
|
||||
ImBuf *ibuf;
|
||||
|
||||
int offset = BKE_image_sequence_guess_offset(ima);
|
||||
|
||||
/* It is possible that image user in this node is not
|
||||
* properly updated yet. In this case loading image will
|
||||
* fail and sockets detection will go wrong.
|
||||
*
|
||||
* So we manually construct image user to be sure first
|
||||
* image from sequence (that one which is set as fileanme
|
||||
* for image datablock) is used for sockets detection
|
||||
*/
|
||||
load_iuser.ok = 1;
|
||||
load_iuser.framenr = offset;
|
||||
|
||||
/* make sure ima->type is correct */
|
||||
ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);
|
||||
ibuf = BKE_image_acquire_ibuf(ima, &load_iuser, NULL);
|
||||
|
||||
if (ima->rr) {
|
||||
RenderLayer *rl= BLI_findlink(&ima->rr->layers, iuser->layer);
|
||||
|
|
Loading…
Reference in New Issue