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
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')
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c4
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_2d.c15
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c18
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c2
4 files changed, 22 insertions, 17 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 8f4f304b3a1..dd064591018 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -120,7 +120,7 @@ void imapaint_region_tiles(
}
void ED_imapaint_dirty_region(
- Image *ima, ImBuf *ibuf, int tile_number, int x, int y, int w, int h, bool find_old)
+ Image *ima, ImBuf *ibuf, ImageUser *iuser, int x, int y, int w, int h, bool find_old)
{
ImBuf *tmpibuf = NULL;
int tilex, tiley, tilew, tileh, tx, ty;
@@ -153,7 +153,7 @@ void ED_imapaint_dirty_region(
for (ty = tiley; ty <= tileh; ty++) {
for (tx = tilex; tx <= tilew; tx++) {
ED_image_paint_tile_push(
- undo_tiles, ima, ibuf, &tmpibuf, tile_number, tx, ty, NULL, NULL, false, find_old);
+ undo_tiles, ima, ibuf, &tmpibuf, iuser, tx, ty, NULL, NULL, false, find_old);
}
}
diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c
index 1bd6a831be2..4a99e40a361 100644
--- a/source/blender/editors/sculpt_paint/paint_image_2d.c
+++ b/source/blender/editors/sculpt_paint/paint_image_2d.c
@@ -1335,11 +1335,11 @@ static void paint_2d_do_making_brush(ImagePaintState *s,
if (tile->canvas->rect_float) {
tmpbuf.rect_float = ED_image_paint_tile_find(
- undo_tiles, s->image, tile->canvas, tile->iuser.tile, tx, ty, &mask, false);
+ undo_tiles, s->image, tile->canvas, &tile->iuser, tx, ty, &mask, false);
}
else {
tmpbuf.rect = ED_image_paint_tile_find(
- undo_tiles, s->image, tile->canvas, tile->iuser.tile, tx, ty, &mask, false);
+ undo_tiles, s->image, tile->canvas, &tile->iuser, tx, ty, &mask, false);
}
IMB_rectblend(tile->canvas,
@@ -1448,7 +1448,7 @@ static int paint_2d_op(void *state,
for (a = 0; a < tot; a++) {
ED_imapaint_dirty_region(s->image,
canvas,
- tile->iuser.tile,
+ &tile->iuser,
region[a].destx,
region[a].desty,
region[a].width,
@@ -1667,6 +1667,7 @@ void paint_2d_stroke(void *ps,
void *paint_2d_new_stroke(bContext *C, wmOperator *op, int mode)
{
Scene *scene = CTX_data_scene(C);
+ SpaceImage *sima = CTX_wm_space_image(C);
ToolSettings *settings = scene->toolsettings;
Brush *brush = BKE_paint_brush(&settings->imapaint.paint);
@@ -1697,7 +1698,7 @@ void *paint_2d_new_stroke(bContext *C, wmOperator *op, int mode)
s->num_tiles = BLI_listbase_count(&s->image->tiles);
s->tiles = MEM_callocN(sizeof(ImagePaintTile) * s->num_tiles, "ImagePaintTile");
for (int i = 0; i < s->num_tiles; i++) {
- BKE_imageuser_default(&s->tiles[i].iuser);
+ s->tiles[i].iuser = sima->iuser;
}
s->tiles[0].iuser.ok = true;
@@ -1941,7 +1942,7 @@ void paint_2d_bucket_fill(const bContext *C,
if (!mouse_final || !br) {
/* first case, no image UV, fill the whole image */
- ED_imapaint_dirty_region(ima, ibuf, tile_number, 0, 0, ibuf->x, ibuf->y, false);
+ ED_imapaint_dirty_region(ima, ibuf, iuser, 0, 0, ibuf->x, ibuf->y, false);
if (do_float) {
for (x_px = 0; x_px < ibuf->x; x_px++) {
@@ -1984,7 +1985,7 @@ void paint_2d_bucket_fill(const bContext *C,
}
/* change image invalidation method later */
- ED_imapaint_dirty_region(ima, ibuf, tile_number, 0, 0, ibuf->x, ibuf->y, false);
+ ED_imapaint_dirty_region(ima, ibuf, iuser, 0, 0, ibuf->x, ibuf->y, false);
stack = BLI_stack_new(sizeof(size_t), __func__);
touched = BLI_BITMAP_NEW(((size_t)ibuf->x) * ibuf->y, "bucket_fill_bitmap");
@@ -2158,7 +2159,7 @@ void paint_2d_gradient_fill(
do_float = (ibuf->rect_float != NULL);
/* this will be substituted by something else when selection is available */
- ED_imapaint_dirty_region(ima, ibuf, tile_number, 0, 0, ibuf->x, ibuf->y, false);
+ ED_imapaint_dirty_region(ima, ibuf, iuser, 0, 0, ibuf->x, ibuf->y, false);
if (do_float) {
for (x_px = 0; x_px < ibuf->x; x_px++) {
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++;
}
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index bd43fddb652..77a3aa529e6 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -518,8 +518,10 @@ void paint_sample_color(
if (image) {
float uv[2];
float u, v;
+ /* XXX get appropriate ImageUser instead */
ImageUser iuser;
BKE_imageuser_default(&iuser);
+ iuser.framenr = image->lastframe;
imapaint_pick_uv(me_eval, scene, ob_eval, faceindex, mval, uv);