Revision: 17470
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17470
Author:   campbellbarton
Date:     2008-11-15 17:20:37 +0100 (Sat, 15 Nov 2008)

Log Message:
-----------
* clone tool didnt work when the object was not at the center point.
* added clone button to the paint editbuttons (was only in the image window 
before)
* ctrl+clicking to set the 3d cursor also sets its depth to the face its over 
(much more useful when cloning and rotating the view)
* support for painting and cloning for tiled textures (for UV's outside 0-1)
* more consistant veriable names, merged image arrays into a ProjectPaintImage 
type to be less confusing.

Modified Paths:
--------------
    branches/projection-paint/source/blender/src/buttons_editing.c
    branches/projection-paint/source/blender/src/imagepaint.c

Modified: branches/projection-paint/source/blender/src/buttons_editing.c
===================================================================
--- branches/projection-paint/source/blender/src/buttons_editing.c      
2008-11-15 12:10:16 UTC (rev 17469)
+++ branches/projection-paint/source/blender/src/buttons_editing.c      
2008-11-15 16:20:37 UTC (rev 17470)
@@ -6337,9 +6337,15 @@
                yco= 160;
 
                uiBlockBeginAlign(block);
-               uiDefButS(block, ROW, B_BRUSHCHANGE, "Draw",            0  
,yco,108,19, &settings->imapaint.tool, 7.0, PAINT_TOOL_DRAW, 0, 0, "Draw 
brush");
-               uiDefButS(block, ROW, B_BRUSHCHANGE, "Soften",          108 
,yco,106,19, &settings->imapaint.tool, 7.0, PAINT_TOOL_SOFTEN, 0, 0, "Soften 
brush");
-               uiDefButS(block, ROW, B_BRUSHCHANGE, "Smear",           
214,yco,106,19, &settings->imapaint.tool, 7.0, PAINT_TOOL_SMEAR, 0, 0, "Smear 
brush");  
+               //uiDefButS(block, ROW, B_BRUSHCHANGE, "Draw",          0  
,yco,108,19, &settings->imapaint.tool, 7.0, PAINT_TOOL_DRAW, 0, 0, "Draw 
brush");
+               //uiDefButS(block, ROW, B_BRUSHCHANGE, "Soften",                
108 ,yco,106,19, &settings->imapaint.tool, 7.0, PAINT_TOOL_SOFTEN, 0, 0, 
"Soften brush");
+               //uiDefButS(block, ROW, B_BRUSHCHANGE, "Smear",         
214,yco,106,19, &settings->imapaint.tool, 7.0, PAINT_TOOL_SMEAR, 0, 0, "Smear 
brush");  
+               
+               uiDefButS(block, ROW, B_SIMABRUSHCHANGE, "Draw",                
0  ,yco,80,19, &settings->imapaint.tool, 7.0, PAINT_TOOL_DRAW, 0, 0, "Draw 
brush");
+               uiDefButS(block, ROW, B_SIMABRUSHCHANGE, "Soften",              
80 ,yco,80,19, &settings->imapaint.tool, 7.0, PAINT_TOOL_SOFTEN, 0, 0, "Soften 
brush");
+               uiDefButS(block, ROW, B_SIMABRUSHCHANGE, "Smear",               
160,yco,80,19, &settings->imapaint.tool, 7.0, PAINT_TOOL_SMEAR, 0, 0, "Smear 
brush");   
+               uiDefButS(block, ROW, B_SIMABRUSHCHANGE, "Clone",               
240,yco,80,19, &settings->imapaint.tool, 7.0, PAINT_TOOL_CLONE, 0, 0, "Clone 
brush, use RMB to drag source image");     
+               
                uiBlockEndAlign(block);
                yco -= 30;
 

Modified: branches/projection-paint/source/blender/src/imagepaint.c
===================================================================
--- branches/projection-paint/source/blender/src/imagepaint.c   2008-11-15 
12:10:16 UTC (rev 17469)
+++ branches/projection-paint/source/blender/src/imagepaint.c   2008-11-15 
16:20:37 UTC (rev 17470)
@@ -167,11 +167,19 @@
 // #define PROJ_BUCKET_CLONE_INIT      1<<1
 
 /* only for readability */
-#define PROJ_BUCKET_LEFT               0
+#define PROJ_BUCKET_LEFT       0
 #define PROJ_BUCKET_RIGHT      1
 #define PROJ_BUCKET_BOTTOM     2
 #define PROJ_BUCKET_TOP                3
 
+typedef struct ProjectPaintImage {
+       Image *ima;
+       ImBuf *ibuf;
+       ImagePaintPartialRedraw *partRedrawRect;
+       struct UndoTile **undoRect; /* only used to build undo tiles after 
painting */
+       int touch;
+} ProjectPaintImage;
+
 typedef struct ProjectPaintState {
        Brush *brush;
        short tool, blend;
@@ -187,51 +195,49 @@
        MTFace             *dm_mtface;
        
        /* projection painting only */
-       MemArena *projectArena;                 /* use for alocating many pixel 
structs and link-lists */
-       MemArena *projectArena_mt[BLENDER_MAX_THREADS];         /* Same as 
above but use for multithreading */
-       LinkNode **projectBuckets;              /* screen sized 2D array, each 
pixel has a linked list of ProjectPixel's */
-       LinkNode **projectFaces;                /* projectBuckets alligned 
array linkList of faces overlapping each bucket */
-       char *projectBucketFlags;               /* store if the bucks have been 
initialized  */
+       MemArena *arena;                        /* use for alocating many pixel 
structs and link-lists */
+       MemArena *arena_mt[BLENDER_MAX_THREADS];                /* Same as 
above but use for multithreading */
+       LinkNode **bucketRect;                          /* screen sized 2D 
array, each pixel has a linked list of ProjectPixel's */
+       LinkNode **bucketFaces;                         /* bucketRect alligned 
array linkList of faces overlapping each bucket */
+       char *bucketFlags;                                      /* store if the 
bucks have been initialized  */
 #ifndef PROJ_DEBUG_NOSEAMBLEED
-       char *projectFaceSeamFlags;             /* store info about faces, if 
they are initialized etc*/
-       float (*projectFaceSeamUVs)[4][2];      /* expanded UVs for faces to 
use as seams */
-       LinkNode **projectVertFaces;    /* Only needed for when 
projectSeamBleed is enabled, use to find UV seams */
+       char *faceSeamFlags;                            /* store info about 
faces, if they are initialized etc*/
+       float (*faceSeamUVs)[4][2];                     /* expanded UVs for 
faces to use as seams */
+       LinkNode **vertFaces;                           /* Only needed for when 
seam_bleed_px is enabled, use to find UV seams */
 #endif
-       int bucketsX;                                   /* The size of the 
bucket grid, the grid span's viewMin2D/viewMax2D so you can paint outsize the 
screen or with 2 brushes at once */
-       int bucketsY;
+       int buckets_x;                                          /* The size of 
the bucket grid, the grid span's screen_min/screen_max so you can paint outsize 
the screen or with 2 brushes at once */
+       int buckets_y;
        
-       Image **projectImages;                  /* array of images we are 
painting onto while, use so we can tag for updates */
-       ImBuf **projectImBufs;                  /* array of imbufs we are 
painting onto while, use so we can get the rect and rect_float quickly */
-       ImagePaintPartialRedraw *projectPartialRedraws[PROJ_BOUNDBOX_SQUARED];  
/* array of partial redraws */
+       ProjectPaintImage *projImages;
        
-       int projectImageTotal;                  /* size of projectImages array 
*/
+       int image_tot;                          /* size of projectImages array 
*/
        
-       float (*projectVertScreenCos)[4];       /* verts projected into 
floating point screen space */
+       float (*screenCoords)[4];       /* verts projected into floating point 
screen space */
        
        /* options for projection painting */
-       short projectIsOcclude;                 /* Use raytraced occlusion? - 
ortherwise will paint right through to the back*/
-       short projectIsBackfaceCull;    /* ignore faces with normals pointing 
away, skips a lot of raycasts if your normals are correctly flipped */
-       short projectIsOrtho;
+       short do_occlude;                       /* Use raytraced occlusion? - 
ortherwise will paint right through to the back*/
+       short do_backfacecull;  /* ignore faces with normals pointing away, 
skips a lot of raycasts if your normals are correctly flipped */
+       short is_ortho;
 #ifndef PROJ_DEBUG_NOSEAMBLEED
-       float projectSeamBleed;
+       float seam_bleed_px;
 #endif
        /* clone vars */
-       float cloneOfs[2];
+       float clone_offset[2];
        
        
        float projectMat[4][4];         /* Projection matrix, use for getting 
screen coords */
        float viewMat[4][4];
-       float viewDir[3];                       /* View vector, use for 
projectIsBackfaceCull and for ray casting with an ortho viewport  */
+       float viewDir[3];                       /* View vector, use for 
do_backfacecull and for ray casting with an ortho viewport  */
        
-       float viewMin2D[2];                     /* 2D bounds for mesh verts on 
the screen's plane (screenspace) */
-       float viewMax2D[2]; 
-       float viewWidth;                        /* Calculated from viewMin2D & 
viewMax2D */
-       float viewHeight;
+       float screen_min[2];                    /* 2D bounds for mesh verts on 
the screen's plane (screenspace) */
+       float screen_max[2]; 
+       float screen_width;                     /* Calculated from screen_min & 
screen_max */
+       float screen_height;
        
        /* threads */
        int thread_tot;
-       int min_bucket[2];
-       int max_bucket[2];
+       int bucket_min[2];
+       int bucket_max[2];
        int context_bucket_x, context_bucket_y; /* must lock threads while 
accessing these */
 } ProjectPaintState;
 
@@ -294,8 +300,11 @@
        IMB_rectcpy(tmpibuf, ibuf, 0, 0, tile->x*IMAPAINT_TILE_SIZE,
                tile->y*IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, 
IMAPAINT_TILE_SIZE);
 
-       if(ibuf->rect_float) SWAP(void*, tmpibuf->rect_float, tile->rect)
-       else SWAP(void*, tmpibuf->rect, tile->rect)
+       if(ibuf->rect_float) {
+               SWAP(void*, tmpibuf->rect_float, tile->rect);
+       } else {
+               SWAP(void*, tmpibuf->rect, tile->rect);
+       }
        
        if(restore)
                IMB_rectcpy(ibuf, tmpibuf, tile->x*IMAPAINT_TILE_SIZE,
@@ -443,24 +452,24 @@
 static int project_paint_BucketOffset(ProjectPaintState *ps, float projCo2D[2])
 {
        /* If we were not dealing with screenspace 2D coords we could simple 
do...
-        * ps->projectBuckets[x + (y*ps->bucketsY)] */
+        * ps->bucketRect[x + (y*ps->buckets_y)] */
        
        /* please explain?
-        * projCo2D[0] - ps->viewMin2D[0]       : zero origin
-        * ... / ps->viewWidth                          : range from 0.0 to 1.0
-        * ... * ps->bucketsX           : use as a bucket index
+        * projCo2D[0] - ps->screen_min[0]      : zero origin
+        * ... / ps->screen_width                               : range from 
0.0 to 1.0
+        * ... * ps->buckets_x          : use as a bucket index
         *
         * Second multiplication does similar but for vertical offset
         */
-       return  (       (int)(( (projCo2D[0] - ps->viewMin2D[0]) / 
ps->viewWidth)  * ps->bucketsX)) + 
-               (       (       (int)(( (projCo2D[1] - ps->viewMin2D[1])  / 
ps->viewHeight) * ps->bucketsY)) * ps->bucketsX );
+       return  (       (int)(( (projCo2D[0] - ps->screen_min[0]) / 
ps->screen_width)  * ps->buckets_x)) + 
+               (       (       (int)(( (projCo2D[1] - ps->screen_min[1])  / 
ps->screen_height) * ps->buckets_y)) * ps->buckets_x );
 }
 
 static int project_paint_BucketOffsetSafe(ProjectPaintState *ps, float 
projCo2D[2])
 {
        int bucket_index = project_paint_BucketOffset(ps, projCo2D);
        
-       if (bucket_index < 0 || bucket_index >= ps->bucketsX*ps->bucketsY) {    
+       if (bucket_index < 0 || bucket_index >= ps->buckets_x*ps->buckets_y) {  
                return -1;
        } else {
                return bucket_index;
@@ -479,7 +488,6 @@
                w[1]/=wtot;
                w[2]/=wtot;
        } else {
-               printf("WATCH oUT ZAREA FACE\n");
                w[0] = w[1] = w[2] = 1.0/3.0; /* dummy values for zero area 
face */
        }
 }
@@ -548,7 +556,7 @@
 
 /* return the topmost face  in screen coords index or -1
  * bucket_index can be -1 if we dont know it to begin with */
-static int screenco_pickface(ProjectPaintState *ps, float pt[2], float w[3], 
int *side) {
+static int project_paint_PickFace(ProjectPaintState *ps, float pt[2], float 
w[3], int *side) {
        LinkNode *node;
        float w_tmp[3];
        float *v1, *v2, *v3, *v4;
@@ -563,7 +571,7 @@
        if (bucket_index==-1)
                return -1;
        
-       node = ps->projectFaces[bucket_index];
+       node = ps->bucketFaces[bucket_index];
        
        /* we could return 0 for 1 face buckets, as long as this function 
assumes
         * that the point its testing is only every originated from an existing 
face */
@@ -572,9 +580,9 @@
                face_index = (int)node->link;
                mf = ps->dm_mface + face_index;
                
-               v1 = ps->projectVertScreenCos[mf->v1];
-               v2 = ps->projectVertScreenCos[mf->v2];
-               v3 = ps->projectVertScreenCos[mf->v3];
+               v1 = ps->screenCoords[mf->v1];
+               v2 = ps->screenCoords[mf->v2];
+               v3 = ps->screenCoords[mf->v3];
                
                if ( IsectPT2Df(pt, v1, v2, v3) ) {
                        z_depth = tri_depth_2d(v1,v2,v3,pt,w_tmp);
@@ -585,7 +593,7 @@
                                VECCOPY(w, w_tmp);
                        }
                } else if (mf->v4) {
-                       v4 = ps->projectVertScreenCos[mf->v4];
+                       v4 = ps->screenCoords[mf->v4];
                        
                        if ( IsectPT2Df(pt, v1, v3, v4) ) {

@@ Diff output truncated at 10240 characters. @@

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

Reply via email to