diff options
author | julianeisel <julian_eisel@web.de> | 2014-12-21 17:46:47 +0300 |
---|---|---|
committer | julianeisel <julian_eisel@web.de> | 2014-12-21 17:48:30 +0300 |
commit | 59a0c11ecc5bf3da563d6b012093027877e31e01 (patch) | |
tree | 3749ce93f75a9483b45bbba15bf614d411035dd5 | |
parent | 1fe7b84c733407b6fd0b855c1c91ad939c2ad342 (diff) |
GPencil: Correction to rB071ec918f4cd
* correct API convention: in rB071ec918f4cd gp_draw_data drew mulitple data blocks, I added gp_draw_data_all which now calles gp_draw_data multiple times (if needed). This follows our normal convention, e.g. see UI_panel_category_draw_all
* Draw scene data first, users may expect it like this
Points raised by @aligorith, thanks for this!
-rw-r--r-- | source/blender/editors/gpencil/drawgpencil.c | 55 |
1 files changed, 32 insertions, 23 deletions
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index ac0ad20b17b..4af41a56e8f 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -1043,8 +1043,7 @@ static void gp_draw_data_layers(bGPdata *gpd, int offsx, int offsy, int winx, in } /* draw grease-pencil datablock */ -static void gp_draw_data(Scene *scene, bGPdata *gpd, int offsx, int offsy, int winx, int winy, - int cfra, int dflag, const char spacetype) +static void gp_draw_data(bGPdata *gpd, int offsx, int offsy, int winx, int winy, int cfra, int dflag) { /* reset line drawing style (in case previous user didn't reset) */ setlinestyle(0); @@ -1061,34 +1060,44 @@ static void gp_draw_data(Scene *scene, bGPdata *gpd, int offsx, int offsy, int w /* draw! */ gp_draw_data_layers(gpd, offsx, offsy, winx, winy, cfra, dflag); - /* if stroke's source is an object (3d view) or a track (movieclip), - * we also want to draw the strokes coming from the scene/clip */ - if (scene) { - bGPdata *gpd_source = NULL; + /* turn off alpha blending, then smooth lines */ + glDisable(GL_BLEND); // alpha blending + glDisable(GL_LINE_SMOOTH); // smooth lines + glDisable(GL_POLYGON_SMOOTH); // smooth poly lines + + /* restore initial gl conditions */ + glLineWidth(1.0); + glPointSize(1.0); + glColor4f(0, 0, 0, 1); +} + +/* if we have strokes for scenes (3d view)/clips (movie clip editor) + * and objects/tracks, multiple data blocks have to be drawn */ +static void gp_draw_data_all(Scene *scene, bGPdata *gpd, int offsx, int offsy, int winx, int winy, + int cfra, int dflag, const char spacetype) +{ + bGPdata *gpd_source = NULL; + + if (scene) { if (spacetype == SPACE_VIEW3D) { gpd_source = (scene->gpd ? scene->gpd : NULL); } else if (spacetype == SPACE_CLIP && scene->clip) { - /* currently drawing only gpencil data from either clip or track not both - XXX fix logic behind */ + /* currently drawing only gpencil data from either clip or track, but not both - XXX fix logic behind */ gpd_source = (scene->clip->gpd ? scene->clip->gpd : NULL); } - /* if gpd_source == gpd, we've already drawn it above and nothing needs to be done here */ - if (gpd_source && gpd_source != gpd) { - gp_draw_data_layers(gpd_source, offsx, offsy, winx, winy, cfra, dflag); + if (gpd_source) { + gp_draw_data(gpd_source, offsx, offsy, winx, winy, cfra, dflag); } } - /* turn off alpha blending, then smooth lines */ - glDisable(GL_BLEND); // alpha blending - glDisable(GL_LINE_SMOOTH); // smooth lines - glDisable(GL_POLYGON_SMOOTH); // smooth poly lines - - /* restore initial gl conditions */ - glLineWidth(1.0); - glPointSize(1.0); - glColor4f(0, 0, 0, 1); + /* scene/clip data has already been drawn, only object/track data is drawn here + * if gpd_source == gpd, we don't have any object/track data and we can skip */ + if (gpd_source == NULL || (gpd_source && gpd_source != gpd)) { + gp_draw_data(gpd, offsx, offsy, winx, winy, cfra, dflag); + } } /* ----- Grease Pencil Sketches Drawing API ------ */ @@ -1156,7 +1165,7 @@ void ED_gpencil_draw_2dimage(const bContext *C) /* draw it! */ - gp_draw_data(scene, gpd, offsx, offsy, sizex, sizey, CFRA, dflag, sa->spacetype); + gp_draw_data_all(scene, gpd, offsx, offsy, sizex, sizey, CFRA, dflag, sa->spacetype); } /* draw grease-pencil sketches to specified 2d-view assuming that matrices are already set correctly @@ -1182,7 +1191,7 @@ void ED_gpencil_draw_view2d(const bContext *C, bool onlyv2d) /* draw it! */ if (onlyv2d) dflag |= (GP_DRAWDATA_ONLYV2D | GP_DRAWDATA_NOSTATUS); - gp_draw_data(scene, gpd, 0, 0, ar->winx, ar->winy, CFRA, dflag, sa->spacetype); + gp_draw_data_all(scene, gpd, 0, 0, ar->winx, ar->winy, CFRA, dflag, sa->spacetype); } /* draw grease-pencil sketches to specified 3d-view assuming that matrices are already set correctly @@ -1220,14 +1229,14 @@ void ED_gpencil_draw_view3d(Scene *scene, View3D *v3d, ARegion *ar, bool only3d) /* draw it! */ if (only3d) dflag |= (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_NOSTATUS); - gp_draw_data(scene, gpd, offsx, offsy, winx, winy, CFRA, dflag, v3d->spacetype); + gp_draw_data_all(scene, gpd, offsx, offsy, winx, winy, CFRA, dflag, v3d->spacetype); } void ED_gpencil_draw_ex(Scene *scene, bGPdata *gpd, int winx, int winy, const int cfra, const char spacetype) { int dflag = GP_DRAWDATA_NOSTATUS | GP_DRAWDATA_ONLYV2D; - gp_draw_data(scene, gpd, 0, 0, winx, winy, cfra, dflag, spacetype); + gp_draw_data_all(scene, gpd, 0, 0, winx, winy, cfra, dflag, spacetype); } /* ************************************************** */ |