Revision: 60950
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60950
Author:   psy-fi
Date:     2013-10-26 19:35:30 +0000 (Sat, 26 Oct 2013)
Log Message:
-----------
Fix anchored and drag dot strokes not being undoable after last commit
to undo tiles. Not really nice but it works for now.

Modified Paths:
--------------
    branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c
    
branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_proj.c
    branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_intern.h

Modified: 
branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c   
2013-10-26 17:45:39 UTC (rev 60949)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c   
2013-10-26 19:35:30 UTC (rev 60950)
@@ -218,7 +218,7 @@
        return NULL;
 }
 
-void *image_undo_push_tile(Image *ima, ImBuf *ibuf, ImBuf **tmpibuf, int 
x_tile, int y_tile, unsigned short **mask)
+void *image_undo_push_tile(Image *ima, ImBuf *ibuf, ImBuf **tmpibuf, int 
x_tile, int y_tile, unsigned short **mask, bool **valid)
 {
        ListBase *lb = undo_paint_push_get_list(UNDO_PAINT_IMAGE);
        UndoImageTile *tile;
@@ -256,6 +256,9 @@
        tile->valid = true;
        tile->ima = ima;
 
+       if (valid)
+               *valid = &tile->valid;
+
        undo_copy_tile(tile, *tmpibuf, ibuf, COPY);
        undo_paint_push_count_alloc(UNDO_PAINT_IMAGE, allocsize);
 
@@ -461,7 +464,7 @@
 
        for (ty = tiley; ty <= tileh; ty++)
                for (tx = tilex; tx <= tilew; tx++)
-                       image_undo_push_tile(ima, ibuf, &tmpibuf, tx, ty, NULL);
+                       image_undo_push_tile(ima, ibuf, &tmpibuf, tx, ty, NULL, 
NULL);
 
        ibuf->userflags |= IB_BITMAPDIRTY;
        

Modified: 
branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_proj.c
===================================================================
--- 
branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_proj.c  
    2013-10-26 17:45:39 UTC (rev 60949)
+++ 
branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_proj.c  
    2013-10-26 19:35:30 UTC (rev 60950)
@@ -185,6 +185,7 @@
        void **undoRect; /* only used to build undo tiles after painting */
        void **maskRect; /* the mask accumulation must happen on canvas, not on 
space screen bucket.
                          * Here we store the mask rectangle */
+       bool **valid; /* store flag to enforce validation of undo rectangle */
        int touch;
 } ProjPaintImage;
 
@@ -316,6 +317,8 @@
        unsigned short mask;
 
        short x_px, y_px;
+       /* horrible hack, store tile valid flag pointer here to re-validate 
tiles used for anchored and drag-dot strokes */
+       bool *valid;
 
        PixelPointer origColor;
        PixelStore newColor;
@@ -1390,7 +1393,7 @@
        }
 }
 
-static int project_paint_undo_subtiles(const TileInfo *tinf, int tx, int ty)
+static int project_paint_undo_subtiles(const TileInfo *tinf, int tx, int ty, 
bool **valid)
 {
        unsigned short *maskrect;
        ProjPaintImage *pjIma = tinf->pjima;
@@ -1402,14 +1405,18 @@
 
        if (UNLIKELY(!pjIma->undoRect[tileindex])) {
                if (tinf->masked) {
-                       pjIma->undoRect[tileindex] = 
image_undo_push_tile(pjIma->ima, pjIma->ibuf, tinf->tmpibuf, tx, ty, &maskrect);
+                       pjIma->undoRect[tileindex] = 
image_undo_push_tile(pjIma->ima, pjIma->ibuf, tinf->tmpibuf, tx, ty, &maskrect, 
&pjIma->valid[tileindex]);
                        pjIma->maskRect[tileindex] = maskrect;
                }
                else
-                       pjIma->undoRect[tileindex] = 
image_undo_push_tile(pjIma->ima, pjIma->ibuf, tinf->tmpibuf, tx, ty, NULL);
+                       pjIma->undoRect[tileindex] = 
image_undo_push_tile(pjIma->ima, pjIma->ibuf, tinf->tmpibuf, tx, ty, NULL, 
&pjIma->valid[tileindex]);
 
+               *valid = pjIma->valid[tileindex];
                pjIma->ibuf->userflags |= IB_BITMAPDIRTY;
        }
+       else {
+               *valid = pjIma->valid[tileindex];
+       }
 
        if (tinf->threaded)
                BLI_unlock_thread(LOCK_CUSTOM1);
@@ -1443,6 +1450,9 @@
        x_px = mod_i(x_px, ibuf->x);
        y_px = mod_i(y_px, ibuf->y);
 
+       BLI_assert(ps->pixel_sizeof == project_paint_pixel_sizeof(ps->tool));
+       projPixel = (ProjPixel *)BLI_memarena_alloc(arena, ps->pixel_sizeof);
+
        /* calculate the undo tile offset of the pixel, used to store the 
original
         * pixel colour and acculmuated mask if any */
        x_tile =  x_px >> IMAPAINT_TILE_BITS;
@@ -1450,17 +1460,14 @@
 
        x_round = x_tile * IMAPAINT_TILE_SIZE;
        y_round = y_tile * IMAPAINT_TILE_SIZE;
+       //memset(projPixel, 0, size);
 
        tile_offset = (x_px - x_round) + (y_px - y_round) * IMAPAINT_TILE_SIZE;
-       tile_index = project_paint_undo_subtiles(tinf, x_tile, y_tile);
+       tile_index = project_paint_undo_subtiles(tinf, x_tile, y_tile, 
&projPixel->valid);
 
        BLI_assert(tile_index < (IMAPAINT_TILE_NUMBER(ibuf->x) * 
IMAPAINT_TILE_NUMBER(ibuf->y)));
        BLI_assert(tile_offset < (IMAPAINT_TILE_SIZE * IMAPAINT_TILE_SIZE));
 
-       BLI_assert(ps->pixel_sizeof == project_paint_pixel_sizeof(ps->tool));
-       projPixel = (ProjPixel *)BLI_memarena_alloc(arena, ps->pixel_sizeof);
-       //memset(projPixel, 0, size);
-
        if (ibuf->rect_float) {
                projPixel->pixel.f_pt = ibuf->rect_float + ((x_px + y_px * 
ibuf->x) * 4);
                projPixel->origColor.f_pt = (float 
*)projima->undoRect[tile_index] + 4 * tile_offset;
@@ -3417,6 +3424,8 @@
                memset(projIma->undoRect, 0, size);
                projIma->maskRect = (void **) BLI_memarena_alloc(arena, size);
                memset(projIma->maskRect, 0, size);
+               projIma->valid = (bool **) BLI_memarena_alloc(arena, size);
+               memset(projIma->valid, 0, size);
        }
 
        /* we have built the array, discard the linked list */
@@ -4154,6 +4163,9 @@
                                                        }
                                                        /* end copy */
 
+                                                       /* validate undo tile, 
since we will modify t*/
+                                                       *projPixel->valid = 
true;
+
                                                        
last_partial_redraw_cell = last_projIma->partRedrawRect + 
projPixel->bb_cell_index;
                                                        
last_partial_redraw_cell->x1 = min_ii(last_partial_redraw_cell->x1, 
(int)projPixel->x_px);
                                                        
last_partial_redraw_cell->y1 = min_ii(last_partial_redraw_cell->y1, 
(int)projPixel->y_px);

Modified: 
branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_intern.h  
2013-10-26 17:45:39 UTC (rev 60949)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_intern.h  
2013-10-26 19:35:30 UTC (rev 60950)
@@ -145,7 +145,7 @@
 
 int image_texture_paint_poll(struct bContext *C);
 void *image_undo_find_tile(struct Image *ima, struct ImBuf *ibuf, int x_tile, 
int y_tile, unsigned short **mask, bool validate);
-void *image_undo_push_tile(struct Image *ima, struct ImBuf *ibuf, struct ImBuf 
**tmpibuf, int x_tile, int y_tile,  unsigned short **);
+void *image_undo_push_tile(struct Image *ima, struct ImBuf *ibuf, struct ImBuf 
**tmpibuf, int x_tile, int y_tile,  unsigned short **, bool **valid);
 void image_undo_remove_masks(void);
 void image_undo_restore(struct bContext *C, struct ListBase *lb);
 void image_undo_free(struct ListBase *lb);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to