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:
authorCampbell Barton <ideasman42@gmail.com>2011-04-01 15:55:21 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-04-01 15:55:21 +0400
commit94ec34fb044a4f66da3cda7af9e98930e9cfc999 (patch)
tree4d56babd80c7e64258a26bce1346484830a78c38 /source/blender/editors/gpencil
parent3556da255a53de6dc1ab4bf3859b5780390063a2 (diff)
xray option for grease pencil (on by default), sometimes its nicer not to have lines draw through the mesh.
Diffstat (limited to 'source/blender/editors/gpencil')
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c36
-rw-r--r--source/blender/editors/gpencil/gpencil_buttons.c11
2 files changed, 42 insertions, 5 deletions
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index a0a815befba..7abdb1f8f07 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -81,6 +81,7 @@ enum {
GP_DRAWDATA_ONLYV2D = (1<<2), /* only draw 'canvas' strokes */
GP_DRAWDATA_ONLYI2D = (1<<3), /* only draw 'image' strokes */
GP_DRAWDATA_IEDITHACK = (1<<4), /* special hack for drawing strokes in Image Editor (weird coordinates) */
+ GP_DRAWDATA_NO_XRAY = (1<<5), /* dont draw xray in 3D view (which is default) */
};
/* thickness above which we should use special drawing */
@@ -506,8 +507,35 @@ static void gp_draw_strokes (bGPDframe *gpf, int offsx, int offsy, int winx, int
/* check which stroke-drawer to use */
if (gps->totpoints == 1)
gp_draw_stroke_point(gps->points, lthick, gps->flag, offsx, offsy, winx, winy);
- else if (dflag & GP_DRAWDATA_ONLY3D)
+ else if (dflag & GP_DRAWDATA_ONLY3D) {
+ const int no_xray= (dflag & GP_DRAWDATA_NO_XRAY);
+ int mask_orig;
+ if(no_xray) {
+ glGetIntegerv(GL_DEPTH_WRITEMASK, &mask_orig);
+ glDepthMask(0);
+ glEnable(GL_DEPTH_TEST);
+
+ /* first arg is normally rv3d->dist, but this isnt available here and seems to work quite well without */
+ bglPolygonOffset(1.0f, 1.0f);
+ /*
+ glEnable(GL_POLYGON_OFFSET_LINE);
+ glPolygonOffset(-1.0f, -1.0f);
+ */
+ }
+
gp_draw_stroke_3d(gps->points, gps->totpoints, lthick, debug);
+
+ if(no_xray) {
+ glDepthMask(mask_orig);
+ glDisable(GL_DEPTH_TEST);
+
+ bglPolygonOffset(0.0, 0.0);
+ /*
+ glDisable(GL_POLYGON_OFFSET_LINE);
+ glPolygonOffset(0, 0);
+ */
+ }
+ }
else if (gps->totpoints > 1)
gp_draw_stroke(gps->points, gps->totpoints, lthick, dflag, gps->flag, debug, offsx, offsy, winx, winy);
}
@@ -556,7 +584,11 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy
QUATCOPY(tcolor, gpl->color); // additional copy of color (for ghosting)
glColor4f(color[0], color[1], color[2], color[3]);
glPointSize((float)(gpl->thickness + 2));
-
+
+ /* apply xray layer setting */
+ if(gpl->flag & GP_LAYER_NO_XRAY) dflag |= GP_DRAWDATA_NO_XRAY;
+ else dflag &= ~GP_DRAWDATA_NO_XRAY;
+
/* draw 'onionskins' (frame left + right) */
if (gpl->flag & GP_LAYER_ONIONSKIN) {
/* drawing method - only immediately surrounding (gstep = 0), or within a frame range on either side (gstep > 0)*/
diff --git a/source/blender/editors/gpencil/gpencil_buttons.c b/source/blender/editors/gpencil/gpencil_buttons.c
index 47a9c007951..8df89a29f28 100644
--- a/source/blender/editors/gpencil/gpencil_buttons.c
+++ b/source/blender/editors/gpencil/gpencil_buttons.c
@@ -91,7 +91,7 @@ static void gp_ui_dellayer_cb (bContext *C, void *gpd, void *gpl)
/* ------- Drawing Code ------- */
/* draw the controls for a given layer */
-static void gp_drawui_layer (uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl)
+static void gp_drawui_layer (uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, const short is_v3d)
{
uiLayout *box=NULL, *split=NULL;
uiLayout *col=NULL, *subcol=NULL;
@@ -214,6 +214,10 @@ static void gp_drawui_layer (uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl)
subcol= uiLayoutColumn(col, 1);
uiItemR(subcol, &ptr, "use_onion_skinning", 0, "Onion Skinning", ICON_NONE);
uiItemR(subcol, &ptr, "ghost_range_max", 0, "Frames", ICON_NONE); // XXX shorter name here? i.e. GStep
+
+ if(is_v3d) {
+ uiItemR(subcol, &ptr, "show_x_ray", 0, "X-Ray", ICON_NONE);
+ }
}
}
@@ -232,6 +236,7 @@ static void draw_gpencil_panel (bContext *C, uiLayout *layout, bGPdata *gpd, Poi
bGPDlayer *gpl;
uiLayout *col, *row;
short v3d_stroke_opts = STROKE_OPTS_NORMAL;
+ const short is_v3d= CTX_wm_view3d(C) != NULL;
/* make new PointerRNA for Grease Pencil block */
RNA_id_pointer_create((ID *)gpd, &gpd_ptr);
@@ -255,7 +260,7 @@ static void draw_gpencil_panel (bContext *C, uiLayout *layout, bGPdata *gpd, Poi
/* draw each layer --------------------------------------------- */
for (gpl= gpd->layers.first; gpl; gpl= gpl->next) {
col= uiLayoutColumn(layout, 1);
- gp_drawui_layer(col, gpd, gpl);
+ gp_drawui_layer(col, gpd, gpl, is_v3d);
}
/* draw gpd drawing settings first ------------------------------------- */
@@ -264,7 +269,7 @@ static void draw_gpencil_panel (bContext *C, uiLayout *layout, bGPdata *gpd, Poi
uiItemL(col, "Drawing Settings:", ICON_NONE);
/* check whether advanced 3D-View drawing space options can be used */
- if (CTX_wm_view3d(C)) {
+ if (is_v3d) {
if (gpd->flag & (GP_DATA_DEPTH_STROKE|GP_DATA_DEPTH_VIEW))
v3d_stroke_opts = STROKE_OPTS_V3D_ON;
else