Revision: 16298 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16298 Author: aligorith Date: 2008-08-29 12:47:53 +0200 (Fri, 29 Aug 2008)
Log Message: ----------- == Grease Pencil == Special request by Alxarch for Architecture: Hold Ctrl-Key when 'Draw Mode' is enabled to draw straight lines. Although when drawing the stroke, the stroke will still be freehand, the final result will be a line between the endpoints of that stroke. This is useful for annotations of sectioning lines + site maps, etc. Modified Paths: -------------- trunk/blender/source/blender/src/gpencil.c Modified: trunk/blender/source/blender/src/gpencil.c =================================================================== --- trunk/blender/source/blender/src/gpencil.c 2008-08-29 06:36:11 UTC (rev 16297) +++ trunk/blender/source/blender/src/gpencil.c 2008-08-29 10:47:53 UTC (rev 16298) @@ -1210,9 +1210,18 @@ bGPDspoint *pt; tGPspoint *ptc; int i, totelem; + + /* macro to test if only converting endpoints */ + #define GP_BUFFER2STROKE_ENDPOINTS ((gpd->flag & GP_DATA_EDITPAINT) && (G.qual & LR_CTRLKEY)) - /* get total number of points to allocate space for */ - totelem = gpd->sbuffer_size; + /* get total number of points to allocate space for: + * - in 'Draw Mode', holding the Ctrl-Modifier will only take endpoints + * - otherwise, do whole stroke + */ + if (GP_BUFFER2STROKE_ENDPOINTS) + totelem = (gpd->sbuffer_size >= 2) ? 2: gpd->sbuffer_size; + else + totelem = gpd->sbuffer_size; /* exit with error if no valid points from this stroke */ if (totelem == 0) { @@ -1233,18 +1242,50 @@ gps->flag= gpd->sbuffer_sflag; /* copy points from the buffer to the stroke */ - for (i=0, ptc=gpd->sbuffer; i < gpd->sbuffer_size && ptc; i++, ptc++) { - /* convert screen-coordinates to appropriate coordinates (and store them) */ - gp_stroke_convertcoords(p, &ptc->x, &pt->x); - - /* copy pressure */ - pt->pressure= ptc->pressure; - - pt++; + if (GP_BUFFER2STROKE_ENDPOINTS) { + /* 'Draw Mode' + Ctrl-Modifier - only endpoints */ + { + /* first point */ + ptc= gpd->sbuffer; + + /* convert screen-coordinates to appropriate coordinates (and store them) */ + gp_stroke_convertcoords(p, &ptc->x, &pt->x); + + /* copy pressure */ + pt->pressure= ptc->pressure; + + pt++; + } + + if (totelem == 2) { + /* last point if applicable */ + ptc= ((tGPspoint *)gpd->sbuffer) + (gpd->sbuffer_size - 1); + + /* convert screen-coordinates to appropriate coordinates (and store them) */ + gp_stroke_convertcoords(p, &ptc->x, &pt->x); + + /* copy pressure */ + pt->pressure= ptc->pressure; + } } + else { + /* convert all points (normal behaviour) */ + for (i=0, ptc=gpd->sbuffer; i < gpd->sbuffer_size && ptc; i++, ptc++) { + /* convert screen-coordinates to appropriate coordinates (and store them) */ + gp_stroke_convertcoords(p, &ptc->x, &pt->x); + + /* copy pressure */ + pt->pressure= ptc->pressure; + + pt++; + } + } /* add stroke to frame */ BLI_addtail(&p->gpf->strokes, gps); + + /* undefine macro to test if only converting endpoints */ + #undef GP_BUFFER2STROKE_ENDPOINTS } /* --- 'Eraser' for 'Paint' Tool ------ */ @@ -1677,7 +1718,8 @@ /* currently, we will only 'paint' if: * 1. draw-mode on gpd is set (for accessibility reasons) - * (single 'dots' are only available via this method) + * a) single dots are only available by this method if a single click is made + * b) a straight line is drawn if ctrl-modifier is held (check is done when stroke is converted!) * 2. if shift-modifier is held + lmb -> 'quick paint' * * OR _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs