diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_object.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 21 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_280.c | 3 | ||||
-rw-r--r-- | source/blender/draw/modes/object_mode.c | 13 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_gizmo_empty.c | 13 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_object_types.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_object.c | 5 |
7 files changed, 33 insertions, 26 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 diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 2cdc8d32cc3..3211033c327 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -2235,7 +2235,8 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) for (Object *ob = bmain->object.first; ob; ob = ob->id.next) { 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); } diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c index 7f364698d07..824068a9800 100644 --- a/source/blender/draw/modes/object_mode.c +++ b/source/blender/draw/modes/object_mode.c @@ -856,17 +856,6 @@ static void image_calc_aspect(Image *ima, ImageUser *iuser, float r_image_aspect } } -static bool is_image_empty_visible(Object *ob, RegionView3D *rv3d) -{ - int visibility_flag = ob->empty_image_visibility_flag; - if (rv3d->is_persp) { - return visibility_flag & OB_EMPTY_IMAGE_VISIBLE_PERSPECTIVE; - } - else { - return visibility_flag & OB_EMPTY_IMAGE_VISIBLE_ORTHOGRAPHIC; - } -} - /* per-image shading groups for image-type empty objects */ struct EmptyImageShadingGroupData { DRWShadingGroup *shgrp_image; @@ -879,7 +868,7 @@ static void DRW_shgroup_empty_image( { /* TODO: 'StereoViews', see draw_empty_image. */ - if (!is_image_empty_visible(ob, rv3d)) return; + if (!BKE_image_empty_visible_in_view3d(ob, rv3d)) return; if (sgl->image_plane_map == NULL) { sgl->image_plane_map = BLI_ghash_ptr_new(__func__); diff --git a/source/blender/editors/space_view3d/view3d_gizmo_empty.c b/source/blender/editors/space_view3d/view3d_gizmo_empty.c index c58b1a6d6cd..9ce0041c76c 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_empty.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_empty.c @@ -107,17 +107,6 @@ static void gizmo_empty_image_prop_matrix_set( ob->ima_ofs[1] = (matrix[3][1] - (0.5f * dims[1])) / dims[1]; } -static bool is_image_empty_visible(Object *ob, RegionView3D *rv3d) -{ - int visibility_flag = ob->empty_image_visibility_flag; - if (rv3d->is_persp) { - return visibility_flag & OB_EMPTY_IMAGE_VISIBLE_PERSPECTIVE; - } - else { - return visibility_flag & OB_EMPTY_IMAGE_VISIBLE_ORTHOGRAPHIC; - } -} - static bool WIDGETGROUP_empty_image_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt)) { View3D *v3d = CTX_wm_view3d(C); @@ -133,7 +122,7 @@ static bool WIDGETGROUP_empty_image_poll(const bContext *C, wmGizmoGroupType *UN if (ob && ob->type == OB_EMPTY) { if (ob->empty_drawtype == OB_EMPTY_IMAGE) { - return is_image_empty_visible(ob, rv3d); + return BKE_image_empty_visible_in_view3d(ob, rv3d); } } return false; diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index fca6a8767be..ffc798317ce 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -608,6 +608,7 @@ enum { enum { OB_EMPTY_IMAGE_VISIBLE_PERSPECTIVE = 1 << 0, OB_EMPTY_IMAGE_VISIBLE_ORTHOGRAPHIC = 1 << 1, + OB_EMPTY_IMAGE_VISIBLE_BACKSIDE = 1 << 2, }; #define MAX_DUPLI_RECUR 8 diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 9ac5d73ed93..57bf1341d9f 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -2510,6 +2510,11 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Display in Orthographic Mode", "Display image in orthographic mode"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); + prop = RNA_def_property(srna, "show_empty_image_backside", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "empty_image_visibility_flag", OB_EMPTY_IMAGE_VISIBLE_BACKSIDE); + RNA_def_property_ui_text(prop, "Display Back Side", "Display empty image even when viewed from the back"); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); + /* render */ prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "index"); |