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:
authorPhilipp Oeser <info@graphics-engineer.com>2020-03-04 16:40:21 +0300
committerPhilipp Oeser <info@graphics-engineer.com>2020-03-10 15:47:33 +0300
commitca717f0489af6854f3f4bedb3c1e82ea0a8dff1c (patch)
tree9d25588ea433fd5242277a3a704283b0130d8799 /source/blender/editors/sculpt_paint/paint_image_proj.c
parent212660f467451b0092fcebcb44591c92c09acbc9 (diff)
Fix T74425: Cannot texture paint an images sequence anymore
Caused by the introduction of UDIM (rBc30d6571bb47). We need to make sure the tiles ImageUser is set up correctly [especially the framenr], otherwise BKE_image_acquire_ibuf() and friends will fail to find the correct ImBuf. Also instead of initializing a minimal BKE_imageuser_default, now use an appropriate ImageUser if avaliable and pass this around (instead of just the tile_number). 2D painting can reuse the Image Editor ImageUser, for 3D painting we still rely on a default ImageUser in most places, but at least set the framenr correctly]. This also fixes crashes when doing image operations such as inverting or resizing on images in a sequence in the Image Editor. This also fixes color sampling (S) from the 3DView going wrong for image sequences (would fallback to OpenGL sampling because an ImBuf could not be found). Maniphest Tasks: T74425 Differential Revision: https://developer.blender.org/D7022
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_image_proj.c')
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index cac377c7e33..b45e4f81027 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -744,9 +744,11 @@ static bool project_paint_PickColor(const ProjPaintState *ps,
ima = project_paint_face_paint_image(ps, tri_index);
/** we must have got the imbuf before getting here. */
int tile_number = project_paint_face_paint_tile(ima, lt_tri_uv[0]);
+ /* XXX get appropriate ImageUser instead */
ImageUser iuser;
BKE_imageuser_default(&iuser);
iuser.tile = tile_number;
+ iuser.framenr = ima->lastframe;
ibuf = BKE_image_acquire_ibuf(ima, &iuser, NULL);
if (ibuf == NULL) {
return false;
@@ -1839,7 +1841,7 @@ static int project_paint_undo_subtiles(const TileInfo *tinf, int tx, int ty)
pjIma->ima,
pjIma->ibuf,
tinf->tmpibuf,
- pjIma->iuser.tile,
+ &pjIma->iuser,
tx,
ty,
&pjIma->maskRect[tile_index],
@@ -1852,7 +1854,7 @@ static int project_paint_undo_subtiles(const TileInfo *tinf, int tx, int ty)
pjIma->ima,
pjIma->ibuf,
tinf->tmpibuf,
- pjIma->iuser.tile,
+ &pjIma->iuser,
tx,
ty,
NULL,
@@ -4265,7 +4267,7 @@ static bool project_paint_winclip(const ProjPaintState *ps, const ProjPaintFaceC
typedef struct PrepareImageEntry {
struct PrepareImageEntry *next, *prev;
Image *ima;
- int tile;
+ ImageUser iuser;
} PrepareImageEntry;
static void project_paint_build_proj_ima(ProjPaintState *ps,
@@ -4280,9 +4282,7 @@ static void project_paint_build_proj_ima(ProjPaintState *ps,
projIma = ps->projImages = BLI_memarena_alloc(arena, sizeof(ProjPaintImage) * ps->image_tot);
for (entry = used_images->first, i = 0; entry; entry = entry->next, i++, projIma++) {
- memset(&projIma->iuser, 0, sizeof(ImageUser));
- BKE_imageuser_default(&projIma->iuser);
- projIma->iuser.tile = entry->tile;
+ projIma->iuser = entry->iuser;
int size;
projIma->ima = entry->ima;
projIma->touch = 0;
@@ -4434,19 +4434,21 @@ static void project_paint_prepare_all_faces(ProjPaintState *ps,
if (tpage_last != tpage || tile_last != tile) {
image_index = 0;
for (PrepareImageEntry *e = used_images.first; e; e = e->next, image_index++) {
- if (e->ima == tpage && e->tile == tile) {
+ if (e->ima == tpage && e->iuser.tile == tile) {
break;
}
}
if (image_index == ps->image_tot) {
+ /* XXX get appropriate ImageUser instead */
ImageUser iuser;
BKE_imageuser_default(&iuser);
iuser.tile = tile;
+ iuser.framenr = tpage->lastframe;
if (BKE_image_has_ibuf(tpage, &iuser)) {
PrepareImageEntry *e = MEM_callocN(sizeof(PrepareImageEntry), "PrepareImageEntry");
e->ima = tpage;
- e->tile = tile;
+ e->iuser = iuser;
BLI_addtail(&used_images, e);
ps->image_tot++;
}