diff options
-rw-r--r-- | release/scripts/startup/bl_ui/space_view3d.py | 8 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 45 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_view3d_types.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 5 |
4 files changed, 45 insertions, 14 deletions
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 8240841d5ed..5d3003ed373 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -2478,10 +2478,12 @@ class VIEW3D_PT_background_image(Panel): column.prop(bg.clip_user, "use_render_undistorted") if has_bg: - box.prop(bg, "opacity", slider=True) + col = box.column() + col.prop(bg, "show_on_foreground") + col.prop(bg, "opacity", slider=True) if bg.view_axis != 'CAMERA': - box.prop(bg, "size") - row = box.row(align=True) + col.prop(bg, "size") + row = col.row(align=True) row.prop(bg, "offset_x", text="X") row.prop(bg, "offset_y", text="Y") diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 59a19782f1d..9e5bd1c860c 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1515,7 +1515,7 @@ exit: /* ************************************************************* */ -static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d) +static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, int foreground) { RegionView3D *rv3d = ar->regiondata; BGpic *bgpic; @@ -1524,10 +1524,13 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d) ImBuf *ibuf = NULL, *freeibuf; float vec[4], fac, asp, zoomx, zoomy; float x1, y1, x2, y2, cx, cy; - + int fg_flag = foreground ? V3D_BGPIC_FOREGROUND : 0; for (bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) { + if ((bgpic->flag & V3D_BGPIC_FOREGROUND) != fg_flag) + continue; + if ((bgpic->view == 0) || /* zero for any */ (bgpic->view & (1 << rv3d->view)) || /* check agaist flags */ (rv3d->persp == RV3D_CAMOB && bgpic->view == (1 << RV3D_VIEW_CAMERA))) @@ -1680,6 +1683,26 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d) } } +static void draw_bgpics(Scene *scene, ARegion *ar, View3D *v3d, int foreground) +{ + RegionView3D *rv3d = ar->regiondata; + + if ((v3d->flag & V3D_DISPBGPICS) == 0) + return; + + if (v3d->flag2 & V3D_RENDER_OVERRIDE) + return; + + if ((rv3d->view == RV3D_VIEW_USER) || (rv3d->persp != RV3D_ORTHO)) { + if (rv3d->persp == RV3D_CAMOB) { + draw_bgpic(scene, ar, v3d, foreground); + } + } + else { + draw_bgpic(scene, ar, v3d, foreground); + } +} + /* ****************** View3d afterdraw *************** */ typedef struct View3DAfter { @@ -2750,13 +2773,16 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar) /* render result draw */ if (v3d->flag & V3D_DISPBGPICS) - draw_bgpic(scene, ar, v3d); + draw_bgpic(scene, ar, v3d, FALSE); else fdrawcheckerboard(0, 0, ar->winx, ar->winy); type = rv3d->render_engine->type; type->view_draw(rv3d->render_engine, C); + if (v3d->flag & V3D_DISPBGPICS) + draw_bgpic(scene, ar, v3d, TRUE); + return 1; } @@ -2837,9 +2863,6 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const star_stuff_term_func); } } - if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { - if (v3d->flag & V3D_DISPBGPICS) draw_bgpic(scene, ar, v3d); - } } } else { @@ -2851,13 +2874,11 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const glLoadMatrixf(rv3d->winmat); glMatrixMode(GL_MODELVIEW); glLoadMatrixf(rv3d->viewmat); - - if (v3d->flag & V3D_DISPBGPICS) { - draw_bgpic(scene, ar, v3d); - } } } - + + draw_bgpics(scene, ar, v3d, FALSE); + if (rv3d->rflag & RV3D_CLIPPING) ED_view3d_clipping_set(rv3d); @@ -2915,6 +2936,8 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const } } + draw_bgpics(scene, ar, v3d, TRUE); + // REEB_draw(); if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index 610513ca860..fb4d4202b31 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -314,6 +314,7 @@ typedef struct View3D { #define V3D_BGPIC_EXPANDED 2 #define V3D_BGPIC_CAMERACLIP 4 #define V3D_BGPIC_DISABLED 8 +#define V3D_BGPIC_FOREGROUND 16 /* BGPic->source */ /* may want to use 1 for select ?*/ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 1a6c2aa17c3..0143473f7db 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1350,6 +1350,11 @@ static void rna_def_background_image(BlenderRNA *brna) RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", V3D_BGPIC_DISABLED); RNA_def_property_ui_text(prop, "Show Background Image", "Show this image as background"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); + + prop = RNA_def_property(srna, "show_on_foreground", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_BGPIC_FOREGROUND); + RNA_def_property_ui_text(prop, "Show On Foreground", "Show this image in fround of objects in viewport"); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); } static void rna_def_backgroundImages(BlenderRNA *brna, PropertyRNA *cprop) |