Revision: 16864
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16864
Author:   aligorith
Date:     2008-10-01 10:23:08 +0200 (Wed, 01 Oct 2008)

Log Message:
-----------
General tidying of Grease Pencil code...

Modified Paths:
--------------
    trunk/blender/source/blender/src/drawgpencil.c
    trunk/blender/source/blender/src/gpencil.c

Modified: trunk/blender/source/blender/src/drawgpencil.c
===================================================================
--- trunk/blender/source/blender/src/drawgpencil.c      2008-10-01 08:08:27 UTC 
(rev 16863)
+++ trunk/blender/source/blender/src/drawgpencil.c      2008-10-01 08:23:08 UTC 
(rev 16864)
@@ -80,7 +80,7 @@
 #include "blendef.h"
 #include "butspace.h"
 
-#include "PIL_time.h"                  /* sleep                                
*/
+#include "PIL_time.h"
 #include "mydevice.h"
 
 /* ************************************************** */
@@ -447,7 +447,7 @@
                        
                        /* need to translate drawing position, but must reset 
after too! */
                        glTranslatef(co[0],  co[1], 0.); 
-                       gluDisk( qobj, 0.0,  thickness, 32, 1); 
+                       gluDisk(qobj, 0.0,  thickness, 32, 1); 
                        glTranslatef(-co[0],  -co[1], 0.);
                        
                        gluDeleteQuadric(qobj);
@@ -524,7 +524,9 @@
                glEnd();
        }
        
-       /* tesselation code: currently only enabled with rt != 0 */
+       /* tesselation code - draw stroke as series of connected quads with 
connection
+        * edges rotated to minimise shrinking artifacts, and rounded endcaps
+        */
        else 
        { 
                bGPDspoint *pt1, *pt2;
@@ -723,7 +725,7 @@
        glColor4f(color[0], color[1], color[2], color[3]);
        
        for (gps= gpf->strokes.first; gps; gps= gps->next) {
-               /* check if stroke can be drawn */
+               /* check if stroke can be drawn - checks here generally fall 
into pairs */
                if ((dflag & GP_DRAWDATA_ONLY3D) && !(gps->flag & 
GP_STROKE_3DSPACE))
                        continue;
                if (!(dflag & GP_DRAWDATA_ONLY3D) && (gps->flag & 
GP_STROKE_3DSPACE))
@@ -876,13 +878,13 @@
                                BIF_ThemeColor(TH_TEXT_HI);
                        
                        if (actlay->actframe) {
-                               sprintf(printable, "GPencil: Layer ('%s'), 
Frame (%d) %s", 
+                               sprintf(printable, "GPencil: Layer ('%s'), 
Frame (%d)%s", 
                                        actlay->info, 
actlay->actframe->framenum,
-                                       ((gpd->flag & GP_DATA_EDITPAINT)?", 
Draw Mode On":"") );
+                                       ((gpd->flag & GP_DATA_EDITPAINT)?" , 
Draw Mode On":"") );
                        }
                        else {
-                               sprintf(printable, "GPencil: Layer ('%s'), 
Frame <None> %s", 
-                                       actlay->info, ((gpd->flag & 
GP_DATA_EDITPAINT)?", Draw Mode On":"") );
+                               sprintf(printable, "GPencil: Layer ('%s'), 
Frame <None>%s", 
+                                       actlay->info, ((gpd->flag & 
GP_DATA_EDITPAINT)?" , Draw Mode On":"") );
                        }
                }
                else {

Modified: trunk/blender/source/blender/src/gpencil.c
===================================================================
--- trunk/blender/source/blender/src/gpencil.c  2008-10-01 08:08:27 UTC (rev 
16863)
+++ trunk/blender/source/blender/src/gpencil.c  2008-10-01 08:23:08 UTC (rev 
16864)
@@ -614,7 +614,6 @@
        /* free layer */        
        free_gpencil_frames(gpl);
        BLI_freelinkN(&gpd->layers, gpl);
-
 }
 
 /* ************************************************** */
@@ -1058,145 +1057,6 @@
        gpd->sbuffer_sflag= 0;
 }
 
-/* init new painting session */
-static void gp_session_initpaint (tGPsdata *p)
-{
-       /* clear previous data (note: is on stack) */
-       memset(p, 0, sizeof(tGPsdata));
-       
-       /* make sure the active view (at the starting time) is a 3d-view */
-       if (curarea == NULL) {
-               p->status= GP_STATUS_ERROR;
-               if (G.f & G_DEBUG) 
-                       printf("Error: No active view for painting \n");
-               return;
-       }
-       switch (curarea->spacetype) {
-               /* supported views first */
-               case SPACE_VIEW3D:
-               {
-                       View3D *v3d= curarea->spacedata.first;
-                       
-                       /* set current area */
-                       p->sa= curarea;
-                       
-                       /* check that gpencil data is allowed to be drawn */
-                       if ((v3d->flag2 & V3D_DISPGP)==0) {
-                               p->status= GP_STATUS_ERROR;
-                               if (G.f & G_DEBUG) 
-                                       printf("Error: In active view, Grease 
Pencil not shown \n");
-                               return;
-                       }
-               }
-                       break;
-               case SPACE_NODE:
-               {
-                       SpaceNode *snode= curarea->spacedata.first;
-                       
-                       /* set current area */
-                       p->sa= curarea;
-                       p->v2d= &snode->v2d;
-                       
-                       /* check that gpencil data is allowed to be drawn */
-                       if ((snode->flag & SNODE_DISPGP)==0) {
-                               p->status= GP_STATUS_ERROR;
-                               if (G.f & G_DEBUG) 
-                                       printf("Error: In active view, Grease 
Pencil not shown \n");
-                               return;
-                       }
-               }
-                       break;
-               case SPACE_SEQ:
-               {
-                       SpaceSeq *sseq= curarea->spacedata.first;
-                       
-                       /* set current area */
-                       p->sa= curarea;
-                       p->v2d= &sseq->v2d;
-                       
-                       /* check that gpencil data is allowed to be drawn */
-                       if (sseq->mainb == 0) {
-                               p->status= GP_STATUS_ERROR;
-                               if (G.f & G_DEBUG) 
-                                       printf("Error: In active view 
(sequencer), active mode doesn't support Grease Pencil \n");
-                               return;
-                       }
-                       if ((sseq->flag & SEQ_DRAW_GPENCIL)==0) {
-                               p->status= GP_STATUS_ERROR;
-                               if (G.f & G_DEBUG) 
-                                       printf("Error: In active view, Grease 
Pencil not shown \n");
-                               return;
-                       }
-               }
-                       break;  
-               case SPACE_IMAGE:
-               {
-                       SpaceImage *sima= curarea->spacedata.first;
-                       
-                       /* set the current area */
-                       p->sa= curarea;
-                       p->v2d= &sima->v2d;
-                       p->ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser);
-               }
-                       break;
-               /* unsupported views */
-               default:
-               {
-                       p->status= GP_STATUS_ERROR;
-                       if (G.f & G_DEBUG) 
-                               printf("Error: Active view not appropriate for 
Grease Pencil drawing \n");
-                       return;
-               }
-                       break;
-       }
-       
-       /* get gp-data */
-       p->gpd= gpencil_data_getactive(p->sa);
-       if (p->gpd == NULL) {
-               short ok;
-               
-               p->gpd= gpencil_data_addnew();
-               ok= gpencil_data_setactive(p->sa, p->gpd);
-               
-               /* most of the time, the following check isn't needed */
-               if (ok == 0) {
-                       /* free gpencil data as it can't be used */
-                       free_gpencil_data(p->gpd);
-                       p->gpd= NULL;
-                       p->status= GP_STATUS_ERROR;
-                       if (G.f & G_DEBUG) 
-                               printf("Error: Could not assign newly created 
Grease Pencil data to active area \n");
-                       return;
-               }
-       }
-       
-       /* set edit flags */
-       G.f |= G_GREASEPENCIL;
-       
-       /* clear out buffer (stored in gp-data) in case something contaminated 
it */
-       gp_session_validatebuffer(p);
-}
-
-/* cleanup after a painting session */
-static void gp_session_cleanup (tGPsdata *p)
-{
-       bGPdata *gpd= p->gpd;
-       
-       /* error checking */
-       if (gpd == NULL)
-               return;
-       
-       /* free stroke buffer */
-       if (gpd->sbuffer) {
-               MEM_freeN(gpd->sbuffer);
-               gpd->sbuffer= NULL;
-       }
-       
-       /* clear flags */
-       gpd->sbuffer_size= 0;
-       gpd->sbuffer_sflag= 0;
-}
-
 /* check if the current mouse position is suitable for adding a new point */
 static short gp_stroke_filtermval (tGPsdata *p, short mval[2], short pmval[2])
 {
@@ -1615,6 +1475,145 @@
 
 /* ---------- 'Paint' Tool ------------ */
 
+/* init new painting session */
+static void gp_session_initpaint (tGPsdata *p)
+{
+       /* clear previous data (note: is on stack) */
+       memset(p, 0, sizeof(tGPsdata));
+       
+       /* make sure the active view (at the starting time) is a 3d-view */
+       if (curarea == NULL) {
+               p->status= GP_STATUS_ERROR;
+               if (G.f & G_DEBUG) 
+                       printf("Error: No active view for painting \n");
+               return;
+       }
+       switch (curarea->spacetype) {
+               /* supported views first */
+               case SPACE_VIEW3D:
+               {
+                       View3D *v3d= curarea->spacedata.first;
+                       
+                       /* set current area */
+                       p->sa= curarea;
+                       
+                       /* check that gpencil data is allowed to be drawn */
+                       if ((v3d->flag2 & V3D_DISPGP)==0) {
+                               p->status= GP_STATUS_ERROR;
+                               if (G.f & G_DEBUG) 
+                                       printf("Error: In active view, Grease 
Pencil not shown \n");
+                               return;
+                       }
+               }
+                       break;
+               case SPACE_NODE:
+               {
+                       SpaceNode *snode= curarea->spacedata.first;
+                       
+                       /* set current area */
+                       p->sa= curarea;
+                       p->v2d= &snode->v2d;
+                       
+                       /* check that gpencil data is allowed to be drawn */
+                       if ((snode->flag & SNODE_DISPGP)==0) {
+                               p->status= GP_STATUS_ERROR;
+                               if (G.f & G_DEBUG) 
+                                       printf("Error: In active view, Grease 
Pencil not shown \n");
+                               return;
+                       }
+               }
+                       break;
+               case SPACE_SEQ:
+               {
+                       SpaceSeq *sseq= curarea->spacedata.first;
+                       
+                       /* set current area */
+                       p->sa= curarea;
+                       p->v2d= &sseq->v2d;
+                       
+                       /* check that gpencil data is allowed to be drawn */
+                       if (sseq->mainb == 0) {
+                               p->status= GP_STATUS_ERROR;
+                               if (G.f & G_DEBUG) 
+                                       printf("Error: In active view 
(sequencer), active mode doesn't support Grease Pencil \n");
+                               return;
+                       }
+                       if ((sseq->flag & SEQ_DRAW_GPENCIL)==0) {
+                               p->status= GP_STATUS_ERROR;
+                               if (G.f & G_DEBUG) 
+                                       printf("Error: In active view, Grease 
Pencil not shown \n");
+                               return;
+                       }
+               }
+                       break;  
+               case SPACE_IMAGE:
+               {
+                       SpaceImage *sima= curarea->spacedata.first;
+                       
+                       /* set the current area */
+                       p->sa= curarea;
+                       p->v2d= &sima->v2d;
+                       p->ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser);
+               }
+                       break;
+               /* unsupported views */
+               default:
+               {
+                       p->status= GP_STATUS_ERROR;
+                       if (G.f & G_DEBUG) 
+                               printf("Error: Active view not appropriate for 
Grease Pencil drawing \n");
+                       return;
+               }
+                       break;
+       }
+       
+       /* get gp-data */
+       p->gpd= gpencil_data_getactive(p->sa);
+       if (p->gpd == NULL) {
+               short ok;
+               
+               p->gpd= gpencil_data_addnew();
+               ok= gpencil_data_setactive(p->sa, p->gpd);
+               
+               /* most of the time, the following check isn't needed */
+               if (ok == 0) {
+                       /* free gpencil data as it can't be used */
+                       free_gpencil_data(p->gpd);
+                       p->gpd= NULL;
+                       p->status= GP_STATUS_ERROR;
+                       if (G.f & G_DEBUG) 
+                               printf("Error: Could not assign newly created 
Grease Pencil data to active area \n");
+                       return;
+               }
+       }
+       
+       /* set edit flags */
+       G.f |= G_GREASEPENCIL;
+       
+       /* clear out buffer (stored in gp-data) in case something contaminated 
it */
+       gp_session_validatebuffer(p);
+}
+
+/* cleanup after a painting session */
+static void gp_session_cleanup (tGPsdata *p)
+{
+       bGPdata *gpd= p->gpd;
+       
+       /* error checking */
+       if (gpd == NULL)
+               return;
+       
+       /* free stroke buffer */
+       if (gpd->sbuffer) {
+               MEM_freeN(gpd->sbuffer);
+               gpd->sbuffer= NULL;
+       }
+       
+       /* clear flags */
+       gpd->sbuffer_size= 0;
+       gpd->sbuffer_sflag= 0;
+}
+
 /* init new stroke */
 static void gp_paint_initstroke (tGPsdata *p, short paintmode)
 {      


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

Reply via email to