fix [#33501] Grease pencil in OpenGL render

With the view3d 'Render Only' option, grease pencil wouldn't draw, but for OpenGL render it did.

Since grease pencil can be very useful in opengl renders, enable grease pencil drawing with 'Render Only' option in the viewport,
and add a checkbox in the grease pencil header not to draw (unchecking each layer is annoying and applies to all spaces).
This commit is contained in:
Campbell Barton 2012-12-17 02:34:53 +00:00
parent bc0e1211de
commit f9ec10688a
20 changed files with 155 additions and 45 deletions

View File

@ -42,7 +42,7 @@ extern "C" {
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 265
#define BLENDER_SUBVERSION 2
#define BLENDER_SUBVERSION 3
/* 262 was the last editmesh release but it has compatibility code for bmesh data */
#define BLENDER_MINVERSION 262

View File

@ -8365,6 +8365,50 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
}
if (main->versionfile < 265 || (main->versionfile == 265 && main->subversionfile < 3)) {
bScreen *sc;
for (sc = main->screen.first; sc; sc = sc->id.next) {
ScrArea *sa;
for (sa = sc->areabase.first; sa; sa = sa->next) {
SpaceLink *sl;
for (sl = sa->spacedata.first; sl; sl = sl->next) {
switch (sl->spacetype) {
case SPACE_VIEW3D:
{
View3D *v3d = (View3D *)sl;
v3d->flag2 |= V3D_SHOW_GPENCIL;
break;
}
case SPACE_SEQ:
{
SpaceSeq *sseq = (SpaceSeq *)sl;
sseq->flag |= SEQ_SHOW_GPENCIL;
break;
}
case SPACE_IMAGE:
{
SpaceImage *sima = (SpaceImage *)sl;
sima->flag |= SI_SHOW_GPENCIL;
break;
}
case SPACE_NODE:
{
SpaceNode *snode = (SpaceNode *)sl;
snode->flag |= SNODE_SHOW_GPENCIL;
break;
}
case SPACE_CLIP:
{
SpaceClip *sclip = (SpaceClip *)sl;
sclip->flag |= SC_SHOW_GPENCIL;
break;
}
}
}
}
}
}
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
/* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */

View File

@ -312,6 +312,13 @@ static void draw_gpencil_panel(bContext *C, uiLayout *layout, bGPdata *gpd, Poin
}
}
void gpencil_panel_standard_header(const bContext *C, Panel *pa)
{
PointerRNA ptr;
RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_Space, CTX_wm_space_data(C), &ptr);
uiItemR(pa->layout, &ptr, "show_grease_pencil", 0, "", ICON_NONE);
}
/* Standard panel to be included wherever Grease Pencil is used... */
void gpencil_panel_standard(const bContext *C, Panel *pa)

View File

@ -81,6 +81,7 @@ void draw_gpencil_2dimage(const struct bContext *C);
void draw_gpencil_view2d(const struct bContext *C, short onlyv2d);
void draw_gpencil_view3d(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, short only3d);
void gpencil_panel_standard_header(const struct bContext *C, struct Panel *pa);
void gpencil_panel_standard(const struct bContext *C, struct Panel *pa);
/* ----------- Grease-Pencil AnimEdit API ------------------ */

View File

@ -78,6 +78,7 @@ void ED_clip_buttons_register(ARegionType *art)
pt = MEM_callocN(sizeof(PanelType), "spacetype clip panel gpencil");
strcpy(pt->idname, "CLIP_PT_gpencil");
strcpy(pt->label, "Grease Pencil");
pt->draw_header = gpencil_panel_standard_header;
pt->draw = gpencil_panel_standard;
pt->flag |= PNL_DEFAULT_CLOSED;
pt->poll = clip_grease_pencil_panel_poll;

View File

@ -246,7 +246,7 @@ static SpaceLink *clip_new(const bContext *C)
sc = MEM_callocN(sizeof(SpaceClip), "initclip");
sc->spacetype = SPACE_CLIP;
sc->flag = SC_SHOW_MARKER_PATTERN | SC_SHOW_TRACK_PATH | SC_MANUAL_CALIBRATION |
SC_SHOW_GRAPH_TRACKS | SC_SHOW_GRAPH_FRAMES;
SC_SHOW_GRAPH_TRACKS | SC_SHOW_GRAPH_FRAMES | SC_SHOW_GPENCIL;
sc->zoom = 1.0f;
sc->path_length = 20;
sc->scopes.track_preview_height = 120;
@ -1151,14 +1151,18 @@ static void clip_main_area_draw(const bContext *C, ARegion *ar)
}
/* Grease Pencil */
clip_draw_grease_pencil((bContext *)C, 1);
if (sc->flag & SC_SHOW_GPENCIL) {
/* Grease Pencil */
clip_draw_grease_pencil((bContext *)C, TRUE);
}
/* reset view matrix */
UI_view2d_view_restore(C);
/* draw Grease Pencil - screen space only */
clip_draw_grease_pencil((bContext *)C, 0);
if (sc->flag & SC_SHOW_GPENCIL) {
/* draw Grease Pencil - screen space only */
clip_draw_grease_pencil((bContext *)C, FALSE);
}
}
static void clip_main_area_listener(ARegion *ar, wmNotifier *wmn)

View File

@ -858,6 +858,7 @@ void image_buttons_register(ARegionType *art)
pt = MEM_callocN(sizeof(PanelType), "spacetype image panel gpencil");
strcpy(pt->idname, "IMAGE_PT_gpencil");
strcpy(pt->label, "Grease Pencil");
pt->draw_header = gpencil_panel_standard_header;
pt->draw = gpencil_panel_standard;
BLI_addtail(&art->paneltypes, pt);
}

View File

@ -151,6 +151,7 @@ static SpaceLink *image_new(const bContext *UNUSED(C))
simage->spacetype = SPACE_IMAGE;
simage->zoom = 1.0f;
simage->lock = TRUE;
simage->flag = SI_SHOW_GPENCIL;
simage->iuser.ok = TRUE;
simage->iuser.fie_ima = 2;
@ -674,16 +675,20 @@ static void image_main_area_draw(const bContext *C, ARegion *ar)
ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
/* Grease Pencil too (in addition to UV's) */
draw_image_grease_pencil((bContext *)C, 1);
if (sima->flag & SI_SHOW_GPENCIL) {
/* Grease Pencil too (in addition to UV's) */
draw_image_grease_pencil((bContext *)C, TRUE);
}
/* sample line */
draw_image_sample_line(sima);
UI_view2d_view_restore(C);
/* draw Grease Pencil - screen space only */
draw_image_grease_pencil((bContext *)C, 0);
if (sima->flag & SI_SHOW_GPENCIL) {
/* draw Grease Pencil - screen space only */
draw_image_grease_pencil((bContext *)C, FALSE);
}
if (mask) {
int width, height;

View File

@ -184,6 +184,7 @@ void node_buttons_register(ARegionType *art)
pt = MEM_callocN(sizeof(PanelType), "spacetype node panel gpencil");
strcpy(pt->idname, "NODE_PT_gpencil");
strcpy(pt->label, "Grease Pencil");
pt->draw_header = gpencil_panel_standard_header;
pt->draw = gpencil_panel_standard;
pt->poll = active_nodetree_poll;
BLI_addtail(&art->paneltypes, pt);

View File

@ -1172,16 +1172,22 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d)
ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
/* draw grease-pencil ('canvas' strokes) */
if (snode->nodetree)
draw_gpencil_view2d(C, 1);
if (snode->flag & SNODE_SHOW_GPENCIL) {
/* draw grease-pencil ('canvas' strokes) */
if (snode->nodetree) {
draw_gpencil_view2d(C, TRUE);
}
}
/* reset view matrix */
UI_view2d_view_restore(C);
/* draw grease-pencil (screen strokes, and also paintbuffer) */
if (snode->nodetree)
draw_gpencil_view2d(C, 0);
if (snode->flag & SNODE_SHOW_GPENCIL) {
/* draw grease-pencil (screen strokes, and also paintbuffer) */
if (snode->nodetree) {
draw_gpencil_view2d(C, FALSE);
}
}
/* scrollers */
scrollers = UI_view2d_scrollers_calc(C, v2d, 10, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);

View File

@ -119,6 +119,8 @@ static SpaceLink *node_new(const bContext *UNUSED(C))
snode = MEM_callocN(sizeof(SpaceNode), "initnode");
snode->spacetype = SPACE_NODE;
snode->flag = SNODE_SHOW_GPENCIL;
/* backdrop */
snode->zoom = 1.0f;

View File

@ -58,6 +58,7 @@ void sequencer_buttons_register(ARegionType *art)
pt = MEM_callocN(sizeof(PanelType), "spacetype sequencer panel gpencil");
strcpy(pt->idname, "SEQUENCER_PT_gpencil");
strcpy(pt->label, N_("Grease Pencil"));
pt->draw_header = gpencil_panel_standard_header;
pt->draw = gpencil_panel_standard;
BLI_addtail(&art->paneltypes, pt);
}

View File

@ -1125,8 +1125,10 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
setlinestyle(0);
}
/* draw grease-pencil (image aligned) */
draw_gpencil_2dimage(C);
if (sseq->flag & SEQ_SHOW_GPENCIL) {
/* draw grease-pencil (image aligned) */
draw_gpencil_2dimage(C);
}
if (!scope)
IMB_freeImBuf(ibuf);
@ -1134,9 +1136,10 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
/* ortho at pixel level */
UI_view2d_view_restore(C);
/* draw grease-pencil (screen aligned) */
draw_gpencil_view2d(C, 0);
if (sseq->flag & SEQ_SHOW_GPENCIL) {
/* draw grease-pencil (screen aligned) */
draw_gpencil_view2d(C, 0);
}
/* NOTE: sequencer mask editing isnt finished, the draw code is working but editing not,

View File

@ -120,6 +120,8 @@ static SpaceLink *sequencer_new(const bContext *C)
sseq->chanshown = 0;
sseq->view = SEQ_VIEW_SEQUENCE;
sseq->mainb = SEQ_DRAW_IMG_IMBUF;
sseq->flag = SEQ_SHOW_GPENCIL;
/* header */
ar = MEM_callocN(sizeof(ARegion), "header for sequencer");
@ -306,8 +308,7 @@ static void sequencer_refresh(const bContext *C, ScrArea *sa)
}
}
static SpaceLink *sequencer_duplicate(SpaceLink *sl)
{
static SpaceLink *sequencer_duplicate(SpaceLink *sl){
SpaceSeq *sseqn = MEM_dupallocN(sl);
/* clear or remove stuff from old */

View File

@ -261,14 +261,11 @@ static SpaceLink *view3d_new(const bContext *C)
v3d->gridlines = 16;
v3d->gridsubdiv = 10;
v3d->drawtype = OB_SOLID;
v3d->gridflag = V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_FLOOR;
v3d->gridflag |= V3D_SHOW_X;
v3d->gridflag |= V3D_SHOW_Y;
v3d->gridflag |= V3D_SHOW_FLOOR;
v3d->gridflag &= ~V3D_SHOW_Z;
v3d->flag |= V3D_SELECT_OUTLINE;
v3d->flag2 |= V3D_SHOW_RECONSTRUCTION;
v3d->flag = V3D_SELECT_OUTLINE;
v3d->flag2 = V3D_SHOW_RECONSTRUCTION | V3D_SHOW_GPENCIL;
v3d->lens = 35.0f;
v3d->near = 0.01f;

View File

@ -1260,6 +1260,7 @@ void view3d_buttons_register(ARegionType *art)
pt = MEM_callocN(sizeof(PanelType), "spacetype view3d panel gpencil");
strcpy(pt->idname, "VIEW3D_PT_gpencil");
strcpy(pt->label, "Grease Pencil");
pt->draw_header = gpencil_panel_standard_header;
pt->draw = gpencil_panel_standard;
BLI_addtail(&art->paneltypes, pt);

View File

@ -2169,7 +2169,9 @@ void draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d)
v3d->zbuf = TRUE;
glEnable(GL_DEPTH_TEST);
draw_gpencil_view3d(scene, v3d, ar, 1);
if (v3d->flag2 & V3D_SHOW_GPENCIL) {
draw_gpencil_view3d(scene, v3d, ar, TRUE);
}
v3d->zbuf = zbuf;
@ -2649,9 +2651,11 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar,
}
/* must be before xray draw which clears the depth buffer */
if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
draw_gpencil_view3d(scene, v3d, ar, 1);
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
if (v3d->flag2 & V3D_SHOW_GPENCIL) {
if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
draw_gpencil_view3d(scene, v3d, ar, TRUE);
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
}
/* transp and X-ray afterdraw stuff */
if (v3d->afterdraw_transp.first) view3d_draw_transp(scene, ar, v3d);
@ -2675,8 +2679,11 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar,
/* draw grease-pencil stuff */
ED_region_pixelspace(ar);
/* draw grease-pencil stuff - needed to get paint-buffer shown too (since it's 2D) */
draw_gpencil_view3d(scene, v3d, ar, 0);
if (v3d->flag2 & V3D_SHOW_GPENCIL) {
/* draw grease-pencil stuff - needed to get paint-buffer shown too (since it's 2D) */
draw_gpencil_view3d(scene, v3d, ar, FALSE);
}
/* freeing the images again here could be done after the operator runs, leaving for now */
GPU_free_images_anim();
@ -3109,10 +3116,10 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const
// REEB_draw();
if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
if (v3d->flag2 & V3D_SHOW_GPENCIL) {
/* must be before xray draw which clears the depth buffer */
if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
draw_gpencil_view3d(scene, v3d, ar, 1);
draw_gpencil_view3d(scene, v3d, ar, TRUE);
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
}
@ -3178,9 +3185,10 @@ static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const cha
if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {
Object *ob;
/* draw grease-pencil stuff - needed to get paint-buffer shown too (since it's 2D) */
// if (v3d->flag2 & V3D_DISPGP)
draw_gpencil_view3d(scene, v3d, ar, 0);
if (v3d->flag2 & V3D_SHOW_GPENCIL) {
/* draw grease-pencil stuff - needed to get paint-buffer shown too (since it's 2D) */
draw_gpencil_view3d(scene, v3d, ar, FALSE);
}
drawcursor(scene, ar, v3d);

View File

@ -496,6 +496,7 @@ typedef enum eSpaceSeq_Flag {
SEQ_DRAW_SAFE_MARGINS = (1 << 3),
/* SEQ_DRAW_GPENCIL = (1 << 4), */ /* DEPRECATED */
SEQ_NO_DRAW_CFRANUM = (1 << 5),
SEQ_SHOW_GPENCIL = (1 << 6),
} eSpaceSeq_Flag;
/* sseq->view */
@ -776,7 +777,7 @@ typedef enum eSpaceImage_Flag {
SI_DRAW_TILE = (1 << 19),
SI_SMOOTH_UV = (1 << 20),
SI_DRAW_STRETCH = (1 << 21),
/* SI_DISPGP = (1 << 22), */ /* deprecated */
SI_SHOW_GPENCIL = (1 << 22),
SI_DRAW_OTHER = (1 << 23),
SI_COLOR_CORRECTION = (1 << 24),
@ -907,7 +908,7 @@ typedef struct SpaceNode {
/* snode->flag */
typedef enum eSpaceNode_Flag {
SNODE_BACKDRAW = (1 << 1),
/* SNODE_DISPGP = (1 << 2), */ /* XXX: Grease Pencil - deprecated? */
SNODE_SHOW_GPENCIL = (1 << 2),
SNODE_USE_ALPHA = (1 << 3),
SNODE_SHOW_ALPHA = (1 << 4),
SNODE_SHOW_R = (1 << 7),
@ -1061,7 +1062,7 @@ typedef enum eSpaceClip_Flag {
SC_SHOW_GRID = (1 << 9),
SC_SHOW_STABLE = (1 << 10),
SC_MANUAL_CALIBRATION = (1 << 11),
/* SC_SHOW_GPENCIL = (1 << 12),*/ /* UNUSED */
SC_SHOW_GPENCIL = (1 << 12),
SC_SHOW_FILTERS = (1 << 13),
SC_SHOW_GRAPH_FRAMES = (1 << 14),
SC_SHOW_GRAPH_TRACKS = (1 << 15),

View File

@ -225,6 +225,7 @@ typedef struct View3D {
#define V3D_DISPBGPICS 2
#define V3D_HIDE_HELPLINES 4
#define V3D_INVALID_BACKBUF 8
#define V3D_INVALID_BACKBUF 8
#define V3D_ALIGN 1024
#define V3D_SELECT_OUTLINE 2048
@ -261,7 +262,7 @@ typedef struct View3D {
/* View3d->flag2 (short) */
#define V3D_RENDER_OVERRIDE 4
#define V3D_SOLID_TEX 8
#define V3D_DISPGP 16
#define V3D_SHOW_GPENCIL 16
#define V3D_LOCK_CAMERA 32
#define V3D_RENDER_SHADOW 64 /* This is a runtime only flag that's used to tell draw_mesh_object() that we're doing a shadow pass instead of a regular draw */
#define V3D_SHOW_RECONSTRUCTION 128

View File

@ -1659,6 +1659,12 @@ static void rna_def_space_view3d(BlenderRNA *brna)
"Show dashed lines indicating parent or constraint relationships");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "show_grease_pencil", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_SHOW_GPENCIL);
RNA_def_property_ui_text(prop, "Show Grease Pencil",
"Show grease pencil for this view");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "show_textured_solid", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_SOLID_TEX);
RNA_def_property_ui_text(prop, "Textured Solid", "Display face-assigned textures in solid view");
@ -2044,6 +2050,12 @@ static void rna_def_space_image(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Draw Repeated", "Draw the image repeated outside of the main view");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL);
prop = RNA_def_property(srna, "show_grease_pencil", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_SHOW_GPENCIL);
RNA_def_property_ui_text(prop, "Show Grease Pencil",
"Show grease pencil for this view");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL);
prop = RNA_def_property(srna, "draw_channels", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
RNA_def_property_enum_items(prop, draw_channels_items);
@ -2209,6 +2221,12 @@ static void rna_def_space_sequencer(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Show Seconds", "Show timing in seconds not frames");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL);
prop = RNA_def_property(srna, "show_grease_pencil", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_SHOW_GPENCIL);
RNA_def_property_ui_text(prop, "Show Grease Pencil",
"Show grease pencil for this view");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL);
prop = RNA_def_property(srna, "display_channel", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "chanshown");
RNA_def_property_ui_text(prop, "Display Channel",
@ -3302,6 +3320,13 @@ static void rna_def_space_clip(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Manual Calibration", "Use manual calibration helpers");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
/* show grease pencil */
prop = RNA_def_property(srna, "show_grease_pencil", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_SHOW_GPENCIL);
RNA_def_property_ui_text(prop, "Show Grease Pencil",
"Show grease pencil for this view");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
/* show filters */
prop = RNA_def_property(srna, "show_filters", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_SHOW_FILTERS);