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>2009-08-30 15:37:29 +0400
committerJoshua Leung <aligorith@gmail.com>2009-08-30 15:37:29 +0400
commitd4d520c9a2312e1b03872f92b1e9be1150d167d5 (patch)
tree56cf674b0c6f93c03d38b39cce5617657bd28903 /source/blender/editors/gpencil
parentb9b30e2032a7f5ebcf87a22ad4ab8d66194d6125 (diff)
Grease Pencil: Various Drawing Fixes
* Restored option to have strokes aligned to screen space. By default, this is not enabled (the setting for view-space is the default instead). * Fixed bugs related to drawing/erasing in screen space.
Diffstat (limited to 'source/blender/editors/gpencil')
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_buttons.c20
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c28
3 files changed, 27 insertions, 23 deletions
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index a89a038d760..d6678b50d7b 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -773,7 +773,7 @@ void draw_gpencil_oglrender (bContext *C)
/* pass 2: draw 2d-strokes ------------ > */
/* adjust view matrices */
- wmOrtho2(-0.375f, (float)(ar->winx)-0.375f, -0.375f, (float)(ar->winy)-0.375f);
+ wmOrtho2(-0.375f, (float)(ar->winx)-0.375f, -0.375f, (float)(ar->winy)-0.375f); // XXX may not be correct anymore
glLoadIdentity();
/* draw it! */
diff --git a/source/blender/editors/gpencil/gpencil_buttons.c b/source/blender/editors/gpencil/gpencil_buttons.c
index f29d37311fb..774f7b7162b 100644
--- a/source/blender/editors/gpencil/gpencil_buttons.c
+++ b/source/blender/editors/gpencil/gpencil_buttons.c
@@ -226,9 +226,13 @@ static void gp_drawui_layer (uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl)
/* Draw the contents for a grease-pencil panel*/
static void draw_gpencil_panel (bContext *C, uiLayout *layout, bGPdata *gpd, PointerRNA *ctx_ptr)
{
+ PointerRNA gpd_ptr;
bGPDlayer *gpl;
uiLayout *col;
+ /* make new PointerRNA for Grease Pencil block */
+ RNA_id_pointer_create((ID *)gpd, &gpd_ptr);
+
/* draw gpd settings first ------------------------------------- */
col= uiLayoutColumn(layout, 0);
/* current Grease Pencil block */
@@ -238,19 +242,19 @@ static void draw_gpencil_panel (bContext *C, uiLayout *layout, bGPdata *gpd, Poi
/* add new layer button */
uiItemO(col, NULL, 0, "GPENCIL_OT_layer_add");
- /* 'view align' button (naming depends on context) */
-#if 0 // XXX for now, this is enabled by default anyways
- 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
- 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");
-#endif
-
/* draw each layer --------------------------------------------- */
for (gpl= gpd->layers.first; gpl; gpl= gpl->next) {
col= uiLayoutColumn(layout, 1);
gp_drawui_layer(col, gpd, gpl);
}
+
+ /* draw gpd drawing settings first ------------------------------------- */
+ col= uiLayoutColumn(layout, 0);
+ /* label */
+ uiItemL(col, "Drawing Settings:", 0);
+
+ /* 'stick to view' option */
+ uiItemR(col, NULL, 0, &gpd_ptr, "view_space_draw", 0);
}
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index c18a807f9d4..b5d25ce651f 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -239,8 +239,8 @@ static void gp_stroke_convertcoords (tGPsdata *p, short mval[], float out[])
/* 2d - relative to screen (viewport area) */
else {
- out[0] = (float)(mval[0]) / (float)(p->sa->winx) * 100;
- out[1] = (float)(mval[1]) / (float)(p->sa->winy) * 100;
+ out[0] = (float)(mval[0]) / (float)(p->ar->winx) * 100;
+ out[1] = (float)(mval[1]) / (float)(p->ar->winy) * 100;
}
}
@@ -310,8 +310,8 @@ static short gp_stroke_addpoint (tGPsdata *p, int mval[2], float pressure)
return GP_STROKEADD_NORMAL;
}
- /* just say it's normal for now, since we don't have another state... */
- return GP_STROKEADD_NORMAL;
+ /* return invalid state for now... */
+ return GP_STROKEADD_INVALID;
}
/* smooth a stroke (in buffer) before storing it */
@@ -614,8 +614,8 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], sho
}
#endif
else {
- x0= (int)(gps->points->x / 100 * p->sa->winx);
- y0= (int)(gps->points->y / 100 * p->sa->winy);
+ x0= (int)(gps->points->x / 100 * p->ar->winx);
+ y0= (int)(gps->points->y / 100 * p->ar->winy);
}
/* do boundbox check first */
@@ -671,10 +671,10 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], sho
}
#endif
else {
- x0= (int)(pt1->x / 100 * p->sa->winx);
- y0= (int)(pt1->y / 100 * p->sa->winy);
- x1= (int)(pt2->x / 100 * p->sa->winx);
- y1= (int)(pt2->y / 100 * p->sa->winy);
+ x0= (int)(pt1->x / 100 * p->ar->winx);
+ y0= (int)(pt1->y / 100 * p->ar->winy);
+ x1= (int)(pt2->x / 100 * p->ar->winx);
+ y1= (int)(pt2->y / 100 * p->ar->winy);
}
/* check that point segment of the boundbox of the eraser stroke */
@@ -944,15 +944,15 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode)
p->gpd->sbuffer_sflag |= GP_STROKE_ERASER;
/* check if points will need to be made in view-aligned space */
- // XXX this should be the default? this is something that needs review
- /*if (p->gpd->flag & GP_DATA_VIEWALIGN)*/ {
+ if (p->gpd->flag & GP_DATA_VIEWALIGN) {
switch (p->sa->spacetype) {
case SPACE_VIEW3D:
{
View3D *v3d= (View3D *)p->sa->spacedata.first;
RegionView3D *rv3d= p->ar->regiondata;
- // TODO: this should only happen for scene... otherwise apply correction for object center!
+ // TODO 1: when using objects, make the data stick to the object centers?
+ // TODO 2: what happens when cursor is behind view-camera plane?
float *fp= give_cursor(p->scene, v3d);
initgrabz(rv3d, fp[0], fp[1], fp[2]);
@@ -1139,7 +1139,7 @@ static void gpencil_draw_apply (bContext *C, wmOperator *op, tGPsdata *p)
if (G.f & G_DEBUG)
printf("Error: Grease-Pencil Paint - Add Point Invalid \n");
- // XXX break!
+ return;
}
/* store used values */