diff options
author | Jacques Lucke <mail@jlucke.com> | 2018-11-19 21:33:09 +0300 |
---|---|---|
committer | Jacques Lucke <mail@jlucke.com> | 2018-11-19 21:33:09 +0300 |
commit | 5f21030a81fa306f807be5bee8bb1df8dd93a98e (patch) | |
tree | dbe0e0f3be413f60d26a04e2a76dcc1e79b266e7 /source/blender/blenkernel | |
parent | 99d9d3dbcee8035d7b69adc5b9a13c79b2aedbe5 (diff) |
Image Empties: Option to not display the backside of image empties
Reviewers: brecht
Differential Revision: https://developer.blender.org/D3964
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_object.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 21 |
2 files changed, 23 insertions, 1 deletions
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 6d950ec01f6..2527b0f5092 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -53,6 +53,7 @@ struct RigidBodyWorld; struct HookModifierData; struct ModifierData; struct HookGpencilModifierData; +struct RegionView3D; #include "DNA_object_enums.h" @@ -342,6 +343,8 @@ bool BKE_object_modifier_update_subframe( struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, bool update_mesh, int parent_recursion, float frame, int type); +bool BKE_image_empty_visible_in_view3d(const struct Object *ob, const struct RegionView3D *rv3d); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index d36a5838630..6590768917a 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -835,7 +835,8 @@ void BKE_object_init(Object *ob) ob->empty_image_depth = OB_EMPTY_IMAGE_DEPTH_DEFAULT; ob->empty_image_visibility_flag = ( OB_EMPTY_IMAGE_VISIBLE_PERSPECTIVE | - OB_EMPTY_IMAGE_VISIBLE_ORTHOGRAPHIC); + OB_EMPTY_IMAGE_VISIBLE_ORTHOGRAPHIC | + OB_EMPTY_IMAGE_VISIBLE_BACKSIDE); if (ob->type == OB_EMPTY) { copy_v2_fl(ob->ima_ofs, -0.5f); } @@ -4079,3 +4080,21 @@ bool BKE_object_modifier_update_subframe( return false; } + +bool BKE_image_empty_visible_in_view3d(const Object *ob, const RegionView3D *rv3d) +{ + int visibility_flag = ob->empty_image_visibility_flag; + + if ((visibility_flag & OB_EMPTY_IMAGE_VISIBLE_BACKSIDE) == 0) { + if (dot_v3v3((float *)&ob->obmat[2], (float *)&rv3d->viewinv[2]) < 0.0f) { + return false; + } + } + + if (rv3d->is_persp) { + return visibility_flag & OB_EMPTY_IMAGE_VISIBLE_PERSPECTIVE; + } + else { + return visibility_flag & OB_EMPTY_IMAGE_VISIBLE_ORTHOGRAPHIC; + } +}
\ No newline at end of file |