From a3802f66e22e57115f48545a39bf41959eb16fad Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 31 Oct 2018 13:35:53 +0100 Subject: Image Empties: More visibility settings Support for showing images in background/foreground and only in perspective/orthographic view. Internally the depth of the image is modified in the fragment shader by setting `gl_FragDepth` explicitly. The UI still needs some work to improve usability, see D3863 for details. Currently there is one duplicated function, not sure how to best deduplicate it yet. (`is_image_empty_visible`) Reviewer: fclem, brecht, campbellbarton Differential Revision: https://developer.blender.org/D3863 --- source/blender/editors/space_view3d/view3d_gizmo_empty.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'source/blender/editors/space_view3d/view3d_gizmo_empty.c') diff --git a/source/blender/editors/space_view3d/view3d_gizmo_empty.c b/source/blender/editors/space_view3d/view3d_gizmo_empty.c index fe1129f8028..bc190355ea6 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_empty.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_empty.c @@ -107,9 +107,21 @@ static void gizmo_empty_image_prop_matrix_set( ob->ima_ofs[1] = (matrix[3][1] - (0.5f * dims[1])) / dims[1]; } +static bool is_image_empty_visible(Object *ob, RegionView3D *rv3d) +{ + int visibility_flag = ob->empty_image_visibility_flag; + if (rv3d->is_persp) { + return visibility_flag & OB_EMPTY_IMAGE_VISIBLE_PERSPECTIVE; + } + else { + return visibility_flag & OB_EMPTY_IMAGE_VISIBLE_ORTHOGRAPHIC; + } +} + static bool WIDGETGROUP_empty_image_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt)) { View3D *v3d = CTX_wm_view3d(C); + RegionView3D *rv3d = CTX_wm_region_view3d(C); if ((v3d->flag2 & V3D_RENDER_OVERRIDE) || (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_CONTEXT))) @@ -120,7 +132,9 @@ static bool WIDGETGROUP_empty_image_poll(const bContext *C, wmGizmoGroupType *UN Object *ob = CTX_data_active_object(C); if (ob && ob->type == OB_EMPTY) { - return (ob->empty_drawtype == OB_EMPTY_IMAGE); + if (ob->empty_drawtype == OB_EMPTY_IMAGE){ + return is_image_empty_visible(ob, rv3d); + } } return false; } -- cgit v1.2.3