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:
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_image.c')
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c53
1 files changed, 38 insertions, 15 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 9dbede754f3..c0ced572515 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -358,9 +358,13 @@ typedef struct UndoImageTile {
struct UndoImageTile *next, *prev;
char idname[MAX_ID_NAME]; /* name instead of pointer*/
+ char ibufname[IB_FILENAME_SIZE];
void *rect;
int x, y;
+
+ short source;
+ char gen_type;
} UndoImageTile;
static ImagePaintPartialRedraw imapaintpartial = {0, 0, 0, 0, 0};
@@ -391,8 +395,9 @@ static void *image_undo_push_tile(Image *ima, ImBuf *ibuf, ImBuf **tmpibuf, int
int allocsize;
for(tile=lb->first; tile; tile=tile->next)
- if(tile->x == x_tile && tile->y == y_tile && strcmp(tile->idname, ima->id.name)==0)
- return tile->rect;
+ if(tile->x == x_tile && tile->y == y_tile && ima->gen_type == tile->gen_type && ima->source == tile->source)
+ if(strcmp(tile->idname, ima->id.name)==0 && strcmp(tile->ibufname, ibuf->name)==0)
+ return tile->rect;
if (*tmpibuf==NULL)
*tmpibuf = IMB_allocImBuf(IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, 32, IB_rectfloat|IB_rect);
@@ -406,6 +411,11 @@ static void *image_undo_push_tile(Image *ima, ImBuf *ibuf, ImBuf **tmpibuf, int
allocsize *= (ibuf->rect_float)? sizeof(float): sizeof(char);
tile->rect= MEM_mapallocN(allocsize, "UndeImageTile.rect");
+ strcpy(tile->ibufname, ibuf->name);
+
+ tile->gen_type= ima->gen_type;
+ tile->source= ima->source;
+
undo_copy_tile(tile, *tmpibuf, ibuf, 0);
undo_paint_push_count_alloc(UNDO_PAINT_IMAGE, allocsize);
@@ -426,18 +436,30 @@ static void image_undo_restore(bContext *C, ListBase *lb)
for(tile=lb->first; tile; tile=tile->next) {
/* find image based on name, pointer becomes invalid with global undo */
- if(ima && strcmp(tile->idname, ima->id.name)==0);
+ if(ima && strcmp(tile->idname, ima->id.name)==0) {
+ /* ima is valid */
+ }
else {
- for(ima=bmain->image.first; ima; ima=ima->id.next)
- if(strcmp(tile->idname, ima->id.name)==0)
- break;
+ ima= BLI_findstring(&bmain->image, tile->idname, offsetof(ID, name));
}
ibuf= BKE_image_get_ibuf(ima, NULL);
+ if(ima && ibuf && strcmp(tile->ibufname, ibuf->name)!=0) {
+ /* current ImBuf filename was changed, probably current frame
+ was changed when paiting on image sequence, rather than storing
+ full image user (which isn't so obvious, btw) try to find ImBuf with
+ matched file name in list of already loaded images */
+
+ ibuf= BLI_findstring(&ima->ibufs, tile->ibufname, offsetof(ImBuf, name));
+ }
+
if (!ima || !ibuf || !(ibuf->rect || ibuf->rect_float))
continue;
+ if (ima->gen_type != tile->gen_type || ima->source != tile->source)
+ continue;
+
undo_copy_tile(tile, tmpibuf, ibuf, 1);
GPU_free_image(ima); /* force OpenGL reload */
@@ -1900,11 +1922,13 @@ static int IsectPT2Df_limit(float pt[2], float v1[2], float v2[2], float v3[2],
/* Clip the face by a bucket and set the uv-space bucket_bounds_uv
* so we have the clipped UV's to do pixel intersection tests with
* */
-static int float_z_sort_flip(const void *p1, const void *p2) {
+static int float_z_sort_flip(const void *p1, const void *p2)
+{
return (((float *)p1)[2] < ((float *)p2)[2] ? 1:-1);
}
-static int float_z_sort(const void *p1, const void *p2) {
+static int float_z_sort(const void *p1, const void *p2)
+{
return (((float *)p1)[2] < ((float *)p2)[2] ?-1:1);
}
@@ -2706,9 +2730,7 @@ static void project_bucket_init(const ProjPaintState *ps, const int thread_index
tpage = project_paint_face_image(ps, face_index);
if (tpage_last != tpage) {
tpage_last = tpage;
-
- image_index = -1; /* sanity check */
-
+
for (image_index=0; image_index < ps->image_tot; image_index++) {
if (ps->projImages[image_index].ima == tpage_last) {
ibuf = ps->projImages[image_index].ibuf;
@@ -3728,7 +3750,8 @@ static void do_projectpaint_draw(ProjPaintState *ps, ProjPixel *projPixel, float
}
}
-static void do_projectpaint_draw_f(ProjPaintState *ps, ProjPixel *projPixel, float *rgba, float alpha, float mask, int use_color_correction) {
+static void do_projectpaint_draw_f(ProjPaintState *ps, ProjPixel *projPixel, float *rgba, float alpha, float mask, int use_color_correction)
+{
if (ps->is_texbrush) {
/* rgba already holds a texture result here from higher level function */
float rgba_br[3];
@@ -3744,7 +3767,7 @@ static void do_projectpaint_draw_f(ProjPaintState *ps, ProjPixel *projPixel, flo
if(use_color_correction){
srgb_to_linearrgb_v3_v3(rgba, ps->brush->rgb);
}
- else {
+ else {
VECCOPY(rgba, ps->brush->rgb);
}
rgba[3] = 1.0;
@@ -4917,7 +4940,6 @@ static void paint_apply_event(bContext *C, wmOperator *op, wmEvent *event)
time= PIL_check_seconds_timer();
tablet= 0;
- pressure= 0;
pop->s.blend= pop->s.brush->blend;
if(event->custom == EVT_DATA_TABLET) {
@@ -4928,8 +4950,9 @@ static void paint_apply_event(bContext *C, wmOperator *op, wmEvent *event)
if(wmtab->Active == EVT_TABLET_ERASER)
pop->s.blend= IMB_BLEND_ERASE_ALPHA;
}
- else /* otherwise airbrush becomes 1.0 pressure instantly */
+ else { /* otherwise airbrush becomes 1.0 pressure instantly */
pressure= pop->prev_pressure ? pop->prev_pressure : 1.0f;
+ }
if(pop->first) {
pop->prevmouse[0]= event->mval[0];