Fix empty object front/back display in perspective views

This commit is contained in:
2019-02-05 10:39:43 +11:00
parent 2c84c23a07
commit 445433a691

View File

@@ -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;