forked from bartvdbraak/blender
xray option for grease pencil (on by default), sometimes its nicer not to have lines draw through the mesh.
This commit is contained in:
parent
3556da255a
commit
94ec34fb04
@ -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)*/
|
||||
|
@ -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
|
||||
|
@ -119,6 +119,8 @@ typedef struct bGPDlayer {
|
||||
#define GP_LAYER_SELECT (1<<5)
|
||||
/* current frame for layer can't be changed */
|
||||
#define GP_LAYER_FRAMELOCK (1<<6)
|
||||
/* don't render xray (which is default) */
|
||||
#define GP_LAYER_NO_XRAY (1<<7)
|
||||
|
||||
|
||||
/* Grease-Pencil Annotations - 'DataBlock' */
|
||||
|
@ -235,6 +235,12 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_DRAWDEBUG);
|
||||
RNA_def_property_ui_text(prop, "Show Points", "Draw the points which make up the strokes (for debugging purposes)");
|
||||
RNA_def_property_update(prop, NC_SCREEN|ND_GPENCIL, NULL);
|
||||
|
||||
/* X-Ray */
|
||||
prop= RNA_def_property(srna, "show_x_ray", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GP_LAYER_NO_XRAY);
|
||||
RNA_def_property_ui_text(prop, "X Ray", "");
|
||||
RNA_def_property_update(prop, NC_SCREEN|ND_GPENCIL, NULL);
|
||||
}
|
||||
|
||||
static void rna_def_gpencil_data(BlenderRNA *brna)
|
||||
|
Loading…
Reference in New Issue
Block a user