Revision: 16405
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16405
Author:   aligorith
Date:     2008-09-07 13:36:52 +0200 (Sun, 07 Sep 2008)

Log Message:
-----------
Grease Pencil - Stick to View for Sequencer:

The 'Stick to View' feature now works in the sequencer (image previews)

Modified Paths:
--------------
    trunk/blender/source/blender/include/BIF_drawseq.h
    trunk/blender/source/blender/src/drawgpencil.c
    trunk/blender/source/blender/src/drawseq.c
    trunk/blender/source/blender/src/gpencil.c

Modified: trunk/blender/source/blender/include/BIF_drawseq.h
===================================================================
--- trunk/blender/source/blender/include/BIF_drawseq.h  2008-09-07 10:47:33 UTC 
(rev 16404)
+++ trunk/blender/source/blender/include/BIF_drawseq.h  2008-09-07 11:36:52 UTC 
(rev 16405)
@@ -33,6 +33,8 @@
 struct ScrArea;
 struct Sequence;
 
+#define SEQ_ZOOM_FAC(szoom) (szoom > 0)? (szoom) : (szoom == 0)? (1.0) : 
(-1.0/szoom)
+
 void drawprefetchseqspace(struct ScrArea *sa, void *spacedata);
 void drawseqspace(struct ScrArea *sa, void *spacedata);
 void set_special_seq_update(int val);

Modified: trunk/blender/source/blender/src/drawgpencil.c
===================================================================
--- trunk/blender/source/blender/src/drawgpencil.c      2008-09-07 10:47:33 UTC 
(rev 16404)
+++ trunk/blender/source/blender/src/drawgpencil.c      2008-09-07 11:36:52 UTC 
(rev 16405)
@@ -60,6 +60,7 @@
 #include "BIF_gl.h"
 #include "BIF_glutil.h"
 #include "BIF_butspace.h"
+#include "BIF_drawseq.h"
 #include "BIF_graphics.h"
 #include "BIF_interface.h"
 #include "BIF_mywindow.h"
@@ -310,7 +311,7 @@
                /* 'view align' button (naming depends on context) */
                if (sa->spacetype == SPACE_VIEW3D)
                        uiDefButBitI(block, TOG, GP_DATA_VIEWALIGN, B_REDR, 
"Sketch in 3D", 170, 205, 150, 20, &gpd->flag, 0, 0, 0, 0, "New strokes are 
added in 3D-space");
-               else if (sa->spacetype != SPACE_SEQ) /* not available for 
sequencer yet */
+               else
                        uiDefButBitI(block, TOG, GP_DATA_VIEWALIGN, B_REDR, 
"Stick to View", 170, 205, 150, 20, &gpd->flag, 0, 0, 0, 0, "New strokes are 
added on 2d-canvas");
        }
        
@@ -411,8 +412,8 @@
                        co[1]= points->y;
                }
                else if (sflag & GP_STROKE_2DIMAGE) {
-                       co[0]= points->x;
-                       co[1]= points->y;
+                       co[0]= (points->x * winx) + offsx;
+                       co[1]= (points->y * winy) + offsy;
                }
                else {
                        co[0]= (points->x / 1000 * winx);
@@ -480,8 +481,12 @@
 static void gp_draw_stroke (bGPDspoint *points, int totpoints, short 
thickness, short dflag, short sflag, 
                                                        short debug, int offsx, 
int offsy, int winx, int winy)
 {      
-       /* if thickness is less than GP_DRAWTHICKNESS_SPECIAL, 'smooth' opengl 
lines look better */
-       if ((thickness < GP_DRAWTHICKNESS_SPECIAL) || (dflag & 
GP_DRAWDATA_ONLYI2D)) {
+       /* if thickness is less than GP_DRAWTHICKNESS_SPECIAL, 'smooth' opengl 
lines look better
+        *      - but NOT if Image Editor 'image-based' stroke
+        */
+       if ( (thickness < GP_DRAWTHICKNESS_SPECIAL) || 
+                ((curarea->spacetype==SPACE_IMAGE) && (dflag & 
GP_DRAWDATA_ONLYV2D)) ) 
+       {
                bGPDspoint *pt;
                int i;
                
@@ -491,8 +496,8 @@
                                glVertex2f(pt->x, pt->y);
                        }
                        else if (sflag & GP_STROKE_2DIMAGE) {
-                               const float x= pt->x;
-                               const float y= pt->y;
+                               const float x= (pt->x * winx) + offsx;
+                               const float y= (pt->y * winy) + offsy;
                                
                                glVertex2f(x, y);
                        }
@@ -505,7 +510,10 @@
                }
                glEnd();
        }
-       else { /* tesselation code: currently only enabled with rt != 0 */
+       
+       /* tesselation code: currently only enabled with rt != 0 */
+       else 
+       { 
                bGPDspoint *pt1, *pt2;
                float pm[2];
                int i;
@@ -526,8 +534,10 @@
                                s1[0]= pt2->x;          s1[1]= pt2->y;
                        }
                        else if (sflag & GP_STROKE_2DIMAGE) {
-                               s0[0]= pt1->x;          s0[1]= pt1->y;
-                               s1[0]= pt2->x;          s1[1]= pt2->y;
+                               s0[0]= (pt1->x * winx) + offsx;                 
+                               s0[1]= (pt1->y * winy) + offsy;
+                               s1[0]= (pt2->x * winx) + offsx;         
+                               s1[1]= (pt2->y * winy) + offsy;
                        }
                        else {
                                s0[0]= (pt1->x / 1000 * winx);
@@ -672,9 +682,8 @@
                                glVertex2f(pt->x, pt->y);
                        }
                        else if (sflag & GP_STROKE_2DIMAGE) {
-                                       // fixme
-                               const float x= pt->x;
-                               const float y= pt->y;
+                               const float x= (pt->x * winx) + offsx;
+                               const float y= (pt->y * winy) + offsy;
                                
                                glVertex2f(x, y);
                        }
@@ -889,7 +898,7 @@
 {
        bGPdata *gpd;
        int offsx, offsy, sizex, sizey;
-       int dflag = 0;
+       int dflag = GP_DRAWDATA_NOSTATUS;
        
        /* check that we have grease-pencil stuff to draw */
        if (ELEM(NULL, sa, ibuf)) return;
@@ -902,27 +911,54 @@
                {
                        SpaceImage *sima= (SpaceImage *)sa->spacedata.first;
                        
-                       // fixme... are these settings still needed?
+                       /* just draw using standard scaling (settings here are 
currently ignored anyways) */
+                       // FIXME: the opengl poly-strokes don't draw at right 
thickness when done this way, so disabled
                        offsx= 0;
                        offsy= 0;
                        sizex= sa->winx;
                        sizey= sa->winy;
                        
                        myortho2(sima->v2d.cur.xmin, sima->v2d.cur.xmax, 
sima->v2d.cur.ymin, sima->v2d.cur.ymax);
+                       
+                       dflag |= GP_DRAWDATA_ONLYV2D;
                }
                        break;
                        
+               case SPACE_SEQ: /* sequence */
+               {
+                       SpaceSeq *sseq= (SpaceSeq *)sa->spacedata.first;
+                       float zoom, zoomx, zoomy;
+                       
+                       /* calculate accessory values */
+                       zoom= SEQ_ZOOM_FAC(sseq->zoom);
+                       if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
+                               zoomx = zoom * ((float)G.scene->r.xasp / 
(float)G.scene->r.yasp);
+                               zoomy = zoom;
+                       } 
+                       else
+                               zoomx = zoomy = zoom;
+                       
+                       sizex= zoomx * ibuf->x;
+                       sizey= zoomy * ibuf->y;
+                       offsx= (sa->winx-sizex)/2 + sseq->xof;
+                       offsy= (sa->winy-sizey)/2 + sseq->yof;
+                       
+                       dflag |= GP_DRAWDATA_ONLYI2D;
+               }
+                       break;
+                       
                default: /* for spacetype not yet handled */
                        offsx= 0;
                        offsy= 0;
                        sizex= sa->winx;
                        sizey= sa->winy;
+                       
+                       dflag |= GP_DRAWDATA_ONLYI2D;
                        break;
        }
        
        
        /* draw it! */
-       dflag = (GP_DRAWDATA_ONLYI2D|GP_DRAWDATA_NOSTATUS);
        gp_draw_data(gpd, offsx, offsy, sizex, sizey, dflag);
 }
 

Modified: trunk/blender/source/blender/src/drawseq.c
===================================================================
--- trunk/blender/source/blender/src/drawseq.c  2008-09-07 10:47:33 UTC (rev 
16404)
+++ trunk/blender/source/blender/src/drawseq.c  2008-09-07 11:36:52 UTC (rev 
16405)
@@ -922,17 +922,11 @@
 
        if(ibuf->rect_float && ibuf->rect==NULL)
                IMB_rect_from_float(ibuf);
-
-       if (sseq->zoom > 0) {
-               zoom = sseq->zoom;
-       } else if (sseq->zoom == 0) {
-               zoom = 1.0;
-       } else {
-               zoom = -1.0/sseq->zoom;
-       }
-
+       
        /* needed for gla draw */
        glaDefine2DArea(&curarea->winrct);
+       
+       zoom= SEQ_ZOOM_FAC(sseq->zoom);
        if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
                zoomx = zoom * ((float)G.scene->r.xasp / 
(float)G.scene->r.yasp);
                zoomy = zoom;
@@ -976,8 +970,11 @@
                setlinestyle(0);
                glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
        }
+       
+       /* draw grease-pencil (image aligned) */
+       if (sseq->flag & SEQ_DRAW_GPENCIL)
+               draw_gpencil_2dimage(sa, ibuf);
 
-
        if (free_ibuf) {
                IMB_freeImBuf(ibuf);
        } 

Modified: trunk/blender/source/blender/src/gpencil.c
===================================================================
--- trunk/blender/source/blender/src/gpencil.c  2008-09-07 10:47:33 UTC (rev 
16404)
+++ trunk/blender/source/blender/src/gpencil.c  2008-09-07 11:36:52 UTC (rev 
16405)
@@ -67,6 +67,7 @@
 #include "BIF_gl.h"
 #include "BIF_glutil.h"
 #include "BIF_butspace.h"
+#include "BIF_drawseq.h"
 #include "BIF_editarmature.h"
 #include "BIF_editview.h"
 #include "BIF_graphics.h"
@@ -694,7 +695,6 @@
 {
        if (gps->flag & GP_STROKE_3DSPACE) {
                /* directly use 3d-coordinates */
-               // FIXME: maybe we need to counterotate this for object 
rotation?
                VecCopyf(p3d, &pt->x);
        }
        else {
@@ -1246,17 +1246,45 @@
                out[1]= y;
        }
        
-       /* 2d - on image 'canvas' (asume that p->v2d is set) */
-       else if ( (gpd->sbuffer_sflag & GP_STROKE_2DIMAGE) && 
-                         (p->v2d) && (p->ibuf) ) 
+       /* 2d - on image 'canvas' (assume that p->v2d is set) */
+       else if ( (gpd->sbuffer_sflag & GP_STROKE_2DIMAGE) && (p->v2d) ) 
        {
-               float x, y;
-               
-               /* convert to 'canvas' coordinates (not need to adjust to 
canvas) */
-               areamouseco_to_ipoco(p->v2d, mval, &x, &y);
-               
-               out[0]= x;
-               out[1]= y;
+               /* for now - space specific */
+               switch (p->sa->spacetype) {
+                       case SPACE_SEQ: /* sequencer */
+                       {
+                               SpaceSeq *sseq= (SpaceSeq 
*)p->sa->spacedata.first;
+                               int sizex, sizey, offsx, offsy, rectx, recty;
+                               float zoom, zoomx, zoomy;
+                               
+                               /* calculate zoom factor */
+                               zoom= SEQ_ZOOM_FAC(sseq->zoom);
+                               if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
+                                       zoomx = zoom * ((float)G.scene->r.xasp 
/ (float)G.scene->r.yasp);
+                                       zoomy = zoom;
+                               } 
+                               else
+                                       zoomx = zoomy = zoom;
+                               
+                               /* calculate rect size */
+                               rectx= (G.scene->r.size*G.scene->r.xsch)/100;
+                               recty= (G.scene->r.size*G.scene->r.ysch)/100; 
+                               sizex= zoomx * rectx;
+                               sizey= zoomy * recty;
+                               offsx= (p->sa->winx-sizex)/2 + sseq->xof;
+                               offsy= (p->sa->winy-sizey)/2 + sseq->yof;
+                               
+                               /* calculate new points */
+                               out[0]= (float)(mval[0] - offsx) / (float)sizex;
+                               out[1]= (float)(mval[1] - offsy) / (float)sizey;
+                       }
+                               break;
+                               
+                       default: /* just use raw mouse coordinates - BAD! */
+                               out[0]= mval[0];
+                               out[1]= mval[1];
+                               break;
+               }               
        }
        
        /* 2d - relative to screen (viewport area) */
@@ -1487,6 +1515,11 @@
                        x0= xyval[0];
                        y0= xyval[1];
                }
+               else if (gps->flag & GP_STROKE_2DIMAGE) {                       
+                       ipoco_to_areaco_noclip(p->v2d, &gps->points->x, xyval);
+                       x0= xyval[0];
+                       y0= xyval[1];
+               }
                else {
                        x0= (gps->points->x / 1000 * p->sa->winx);
                        y0= (gps->points->y / 1000 * p->sa->winy);
@@ -1530,6 +1563,15 @@
                                x1= xyval[0];
                                y1= xyval[1];
                        }
+                       else if (gps->flag & GP_STROKE_2DIMAGE) {
+                               ipoco_to_areaco_noclip(p->v2d, &pt1->x, xyval);
+                               x0= xyval[0];
+                               y0= xyval[1];
+                               
+                               ipoco_to_areaco_noclip(p->v2d, &pt2->x, xyval);
+                               x1= xyval[0];
+                               y1= xyval[1];
+                       }
                        else {
                                x0= (pt1->x / 1000 * p->sa->winx);
                                y0= (pt1->y / 1000 * p->sa->winy);
@@ -1553,8 +1595,6 @@
        }
 }
 
-/* -------- */
-
 /* erase strokes which fall under the eraser strokes */
 static void gp_stroke_doeraser (tGPsdata *p)
 {
@@ -1626,14 +1666,14 @@
                        case SPACE_SEQ:
                        {
                                /* for now, this is not applicable here... */
-                               //p->gpd->sbuffer_sflag |= GP_STROKE_2DIMAGE;
+                               p->gpd->sbuffer_sflag |= GP_STROKE_2DIMAGE;
                        }
                                break;
                        case SPACE_IMAGE:
                        {
                                /* check if any ibuf available */
                                if (p->ibuf)
-                                       p->gpd->sbuffer_sflag |= 
GP_STROKE_2DIMAGE;
+                                       p->gpd->sbuffer_sflag |= 
GP_STROKE_2DSPACE;
                        }
                                break;
                }


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

Reply via email to