Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-02-05 02:39:43 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-02-05 02:43:16 +0300
commit445433a6913fb95fe04bf69089710cab877a581b (patch)
tree5d62260902affe01b56928865972a99f7e2cb697 /source/blender/blenkernel/intern/object.c
parent2c84c23a074e315581f374c93039c2ebfa56a947 (diff)
Fix empty object front/back display in perspective views
Diffstat (limited to 'source/blender/blenkernel/intern/object.c')
-rw-r--r--source/blender/blenkernel/intern/object.c17
1 files changed, 14 insertions, 3 deletions
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;