From 445433a6913fb95fe04bf69089710cab877a581b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 5 Feb 2019 10:39:43 +1100 Subject: Fix empty object front/back display in perspective views --- source/blender/blenkernel/intern/object.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index d8bc27fa596..5cb68a7e5bb 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2608,9 +2608,20 @@ bool BKE_object_empty_image_is_visible_in_view3d(const Object *ob, const RegionV char visibility_flag = ob->empty_image_visibility_flag; if ((visibility_flag & (OB_EMPTY_IMAGE_HIDE_BACK | OB_EMPTY_IMAGE_HIDE_FRONT)) != 0) { - const float eps = 1e-5f; - /* TODO: this isn't correct with perspective projection. */ - const float dot = dot_v3v3((float *)&ob->obmat[2], (float *)&rv3d->viewinv[2]); + float eps, dot; + if (rv3d->is_persp) { + /* Note, we could normalize the 'view_dir' then use 'eps' + * however the issue with empty objects being visible when viewed from the side + * is only noticeable in orthographic views. */ + float view_dir[3]; + sub_v3_v3v3(view_dir, rv3d->viewinv[3], ob->obmat[3]); + dot = dot_v3v3(ob->obmat[2], view_dir); + eps = 0.0f; + } + else { + dot = dot_v3v3(ob->obmat[2], rv3d->viewinv[2]); + eps = 1e-5f; + } if (visibility_flag & OB_EMPTY_IMAGE_HIDE_BACK) { if (dot < eps) { return false; -- cgit v1.2.3