Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2008-08-29 14:47:53 +0400
committerJoshua Leung <aligorith@gmail.com>2008-08-29 14:47:53 +0400
commitbcff5afeb23882ee9f519f7c4d1716c70b67ca33 (patch)
treebe0c329637eefb84d11f7411c1f99c96376c95da
parente21b3d81c54b81723cf6438669b94e89449d3a66 (diff)
== 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.
-rw-r--r--source/blender/src/gpencil.c64
1 files changed, 53 insertions, 11 deletions
diff --git a/source/blender/src/gpencil.c b/source/blender/src/gpencil.c
index 0148ace20d4..ed046929d2e 100644
--- a/source/blender/src/gpencil.c
+++ b/source/blender/src/gpencil.c
@@ -1210,9 +1210,18 @@ static void gp_stroke_newfrombuffer (tGPsdata *p)
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 @@ static void gp_stroke_newfrombuffer (tGPsdata *p)
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 @@ short gpencil_do_paint (ScrArea *sa, short mbut)
/* 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