diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-11-24 13:43:16 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-11-27 14:11:56 +0300 |
commit | 37fc23dd9e7738de7187e889f058cda845544ffb (patch) | |
tree | b1423676fcc8f2cc07fdeb8125152e4d7d105b6a /source/blender/editors/space_view3d/view3d_draw.c | |
parent | ff9cf0664529db88bd2ea6e13dde6f002054c745 (diff) |
Refactor view3d offscreen drawing to avoid having multiple boolean arguments
This is fully unreadable to have lots of boolean arguments scattered across the
whole argument list. What does `false, true, true` mean in terms of behavior?
Replace those with bitfield which has advantage of having more human readable
meaning.
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_draw.c')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 56508ea989a..8fd38d6a8de 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -3286,14 +3286,16 @@ void ED_view3d_draw_setup_view( */ ImBuf *ED_view3d_draw_offscreen_imbuf( Scene *scene, View3D *v3d, ARegion *ar, int sizex, int sizey, - unsigned int flag, bool draw_background, - int alpha_mode, int samples, bool full_samples, const char *viewname, + unsigned int flag, unsigned int draw_flags, + int alpha_mode, int samples, const char *viewname, /* output vars */ GPUFX *fx, GPUOffScreen *ofs, char err_out[256]) { RegionView3D *rv3d = ar->regiondata; ImBuf *ibuf; const bool draw_sky = (alpha_mode == R_ADDSKY); + const bool draw_background = (draw_flags & V3D_OFSDRAW_USE_BACKGROUND); + const bool use_full_sample = (draw_flags & V3D_OFSDRAW_USE_FULL_SAMPLE); /* view state */ GPUFXSettings fx_settings = v3d->fx_settings; @@ -3309,7 +3311,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf( if (own_ofs) { /* bind */ - ofs = GPU_offscreen_create(sizex, sizey, full_samples ? 0 : samples, err_out); + ofs = GPU_offscreen_create(sizex, sizey, use_full_sample ? 0 : samples, err_out); if (ofs == NULL) { return NULL; } @@ -3354,7 +3356,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf( } } - if ((samples && full_samples) == 0) { + if ((samples && use_full_sample) == 0) { /* Single-pass render, common case */ ED_view3d_draw_offscreen( scene, v3d, ar, sizex, sizey, NULL, winmat, @@ -3454,8 +3456,8 @@ ImBuf *ED_view3d_draw_offscreen_imbuf( */ ImBuf *ED_view3d_draw_offscreen_imbuf_simple( Scene *scene, Object *camera, int width, int height, - unsigned int flag, int drawtype, bool use_solid_tex, bool use_gpencil, bool draw_background, - int alpha_mode, int samples, bool full_samples, const char *viewname, + unsigned int flag, unsigned int draw_flags, int drawtype, + int alpha_mode, int samples, const char *viewname, GPUFX *fx, GPUOffScreen *ofs, char err_out[256]) { View3D v3d = {NULL}; @@ -3472,13 +3474,13 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple( v3d.drawtype = drawtype; v3d.flag2 = V3D_RENDER_OVERRIDE; - if (use_gpencil) + if (draw_flags & V3D_OFSDRAW_USE_GPENCIL) v3d.flag2 |= V3D_SHOW_GPENCIL; - if (use_solid_tex) + if (draw_flags & V3D_OFSDRAW_USE_SOLID_TEX) v3d.flag2 |= V3D_SOLID_TEX; - if (draw_background) + if (draw_flags & V3D_OFSDRAW_USE_BACKGROUND) v3d.flag3 |= V3D_SHOW_WORLD; rv3d.persp = RV3D_CAMOB; @@ -3507,9 +3509,8 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple( invert_m4_m4(rv3d.persinv, rv3d.viewinv); return ED_view3d_draw_offscreen_imbuf( - scene, &v3d, &ar, width, height, flag, - draw_background, alpha_mode, samples, full_samples, viewname, - fx, ofs, err_out); + scene, &v3d, &ar, width, height, flag, draw_flags, + alpha_mode, samples, viewname, fx, ofs, err_out); } |