DRW: show image empty frame when the 'side' is hidden
authorCampbell Barton <ideasman42@gmail.com>
Thu, 7 Mar 2019 00:26:28 +0000 (11:26 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 7 Mar 2019 00:41:33 +0000 (11:41 +1100)
This behavior matches back-face culled mesh objects,
where the wire outline doesn't depend on the viewing angle.

Applying this before empty visibility check for view framing,
since it's strange if viewing all gives different results
depending on back-face culling.

source/blender/blenkernel/BKE_object.h
source/blender/blenkernel/intern/object.c
source/blender/draw/modes/object_mode.c
source/blender/editors/space_view3d/view3d_gizmo_empty.c

index 32bc2f03b9e61a1c1510d0c4b89f266aee8da5d5..9cd982323758b35c8b1fcbf1ce6dbff56e254991 100644 (file)
@@ -349,7 +349,8 @@ bool BKE_object_modifier_update_subframe(
 
 void BKE_object_type_set_empty_for_versioning(struct Object *ob);
 
 
 void BKE_object_type_set_empty_for_versioning(struct Object *ob);
 
-bool BKE_object_empty_image_is_visible_in_view3d(const struct Object *ob, const struct RegionView3D *rv3d);
+bool BKE_object_empty_image_frame_is_visible_in_view3d(const struct Object *ob, const struct RegionView3D *rv3d);
+bool BKE_object_empty_image_data_is_visible_in_view3d(const struct Object *ob, const struct RegionView3D *rv3d);
 
 #ifdef __cplusplus
 }
 
 #ifdef __cplusplus
 }
index ca82353a16a9d505019ea44c361b72eac451c12a..1743060aa97f823a52786afef965466458ea0094 100644 (file)
@@ -2849,9 +2849,23 @@ void BKE_object_empty_draw_type_set(Object *ob, const int value)
        }
 }
 
        }
 }
 
-bool BKE_object_empty_image_is_visible_in_view3d(const Object *ob, const RegionView3D *rv3d)
+bool BKE_object_empty_image_frame_is_visible_in_view3d(const Object *ob, const RegionView3D *rv3d)
 {
 {
-       char visibility_flag = ob->empty_image_visibility_flag;
+       const char visibility_flag = ob->empty_image_visibility_flag;
+       if (rv3d->is_persp) {
+               return (visibility_flag & OB_EMPTY_IMAGE_HIDE_PERSPECTIVE) == 0;
+       }
+       else {
+               return (visibility_flag & OB_EMPTY_IMAGE_HIDE_ORTHOGRAPHIC) == 0;
+       }
+}
+
+bool BKE_object_empty_image_data_is_visible_in_view3d(const Object *ob, const RegionView3D *rv3d)
+{
+       /* Caller is expected to check this. */
+       BLI_assert(BKE_object_empty_image_frame_is_visible_in_view3d(ob, rv3d));
+
+       const char visibility_flag = ob->empty_image_visibility_flag;
 
        if ((visibility_flag & (OB_EMPTY_IMAGE_HIDE_BACK | OB_EMPTY_IMAGE_HIDE_FRONT)) != 0) {
                float eps, dot;
 
        if ((visibility_flag & (OB_EMPTY_IMAGE_HIDE_BACK | OB_EMPTY_IMAGE_HIDE_FRONT)) != 0) {
                float eps, dot;
@@ -2880,12 +2894,7 @@ bool BKE_object_empty_image_is_visible_in_view3d(const Object *ob, const RegionV
                }
        }
 
                }
        }
 
-       if (rv3d->is_persp) {
-               return (visibility_flag & OB_EMPTY_IMAGE_HIDE_PERSPECTIVE) == 0;
-       }
-       else {
-               return (visibility_flag & OB_EMPTY_IMAGE_HIDE_ORTHOGRAPHIC) == 0;
-       }
+       return true;
 }
 
 bool BKE_object_minmax_dupli(Depsgraph *depsgraph, Scene *scene, Object *ob, float r_min[3], float r_max[3], const bool use_hidden)
 }
 
 bool BKE_object_minmax_dupli(Depsgraph *depsgraph, Scene *scene, Object *ob, float r_min[3], float r_max[3], const bool use_hidden)
index 126e5da4b83602bf0a539fafd540af7c89fd58cc..f68be196f0e89c1c631d2328d4a1f3e929a0cd0e 100644 (file)
@@ -919,7 +919,7 @@ static void DRW_shgroup_empty_image(
 {
        /* TODO: 'StereoViews', see draw_empty_image. */
 
 {
        /* TODO: 'StereoViews', see draw_empty_image. */
 
-       if (!BKE_object_empty_image_is_visible_in_view3d(ob, rv3d)) {
+       if (!BKE_object_empty_image_frame_is_visible_in_view3d(ob, rv3d)) {
                return;
        }
 
                return;
        }
 
@@ -945,7 +945,7 @@ static void DRW_shgroup_empty_image(
        /* OPTI(fclem) We need sorting only for transparent images. If an image as no alpha channel and
         * ob->col[3] == 1.0f,  we could remove it from the sorting pass. */
 
        /* OPTI(fclem) We need sorting only for transparent images. If an image as no alpha channel and
         * ob->col[3] == 1.0f,  we could remove it from the sorting pass. */
 
-       if (tex && (ob->color[3] > 0.0f)) {
+       if (tex && (ob->color[3] > 0.0f) && BKE_object_empty_image_data_is_visible_in_view3d(ob, rv3d)) {
                DRWShadingGroup *grp = DRW_shgroup_create(sh_data->object_empty_image, sgl->image_empties);
                DRW_shgroup_uniform_texture(grp, "image", tex);
                /* TODO(fclem) implement DRW_shgroup_uniform_vec2_copy */
                DRWShadingGroup *grp = DRW_shgroup_create(sh_data->object_empty_image, sgl->image_empties);
                DRW_shgroup_uniform_texture(grp, "image", tex);
                /* TODO(fclem) implement DRW_shgroup_uniform_vec2_copy */
index ee6dd2b82672a314a5af827ba07ed6b91c56fce9..7d6ec3b782f08a6af370c3539dcb7a539e3ddf5a 100644 (file)
@@ -118,7 +118,7 @@ static bool WIDGETGROUP_empty_image_poll(const bContext *C, wmGizmoGroupType *UN
                Object *ob = base->object;
                if (ob->type == OB_EMPTY) {
                        if (ob->empty_drawtype == OB_EMPTY_IMAGE) {
                Object *ob = base->object;
                if (ob->type == OB_EMPTY) {
                        if (ob->empty_drawtype == OB_EMPTY_IMAGE) {
-                               return BKE_object_empty_image_is_visible_in_view3d(ob, rv3d);
+                               return BKE_object_empty_image_frame_is_visible_in_view3d(ob, rv3d);
                        }
                }
        }
                        }
                }
        }