3D View: empty image option to show front/back
authorCampbell Barton <ideasman42@gmail.com>
Mon, 17 Dec 2018 03:49:16 +0000 (14:49 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 17 Dec 2018 03:49:16 +0000 (14:49 +1100)
Only back was possible.

release/scripts/startup/bl_operators/object.py
release/scripts/startup/bl_ui/properties_data_empty.py
source/blender/blenkernel/intern/object.c
source/blender/makesdna/DNA_object_types.h
source/blender/makesrna/intern/rna_object.c

index dfa6b1ac4ef2df88e4f31576db2ccc9eac0ca2aa..949e2baff03193a4e3ec01f8b1c52a24440778a0 100644 (file)
@@ -927,7 +927,7 @@ class LoadBackgroundImage(LoadImageAsEmpty, Operator):
 
     def set_settings(self, context, obj):
         obj.empty_image_depth = 'BACK'
-        obj.show_empty_image_back = False
+        obj.empty_image_side = 'FRONT'
 
         if context.space_data.type == 'VIEW_3D':
             if not context.space_data.region_3d.is_perspective:
index bcbb6a7dc01aee08c05f4d3d73bb35eccc7484c9..70c1315927c76a4e5d459cc9ad184dbcdbe9a06f 100644 (file)
@@ -56,9 +56,9 @@ class DATA_PT_empty(DataButtonsPanel, Panel):
 
             col = layout.column()
             col.row().prop(ob, "empty_image_depth", text="Depth", expand=True)
+            col.row().prop(ob, "empty_image_side", text="Side", expand=True)
             col.prop(ob, "show_empty_image_orthographic", text="Display Orthographic")
             col.prop(ob, "show_empty_image_perspective", text="Display Perspective")
-            col.prop(ob, "show_empty_image_back", text="Display Back")
 
 
 classes = (
index 56843899ff669d5a08ea5927c0709b576a7ff70b..498658765b653a0e171c916e22e9405e664c87fc 100644 (file)
@@ -2672,9 +2672,18 @@ 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) != 0) {
-               if (dot_v3v3((float *)&ob->obmat[2], (float *)&rv3d->viewinv[2]) < 0.0f) {
-                       return false;
+       if ((visibility_flag & (OB_EMPTY_IMAGE_HIDE_BACK | OB_EMPTY_IMAGE_HIDE_FRONT)) != 0) {
+               /* TODO: this isn't correct with perspective projection. */
+               const float dot = dot_v3v3((float *)&ob->obmat[2], (float *)&rv3d->viewinv[2]);
+               if (visibility_flag & OB_EMPTY_IMAGE_HIDE_BACK) {
+                       if (dot < 0.0f) {
+                               return false;
+                       }
+               }
+               if (visibility_flag & OB_EMPTY_IMAGE_HIDE_FRONT) {
+                       if (dot > 0.0f) {
+                               return false;
+                       }
                }
        }
 
index 16ca673c83bd954cc5d475a46991d3b6a73750f1..606cbe66d0d20281c5cecafee8a8fbc88c872f3d 100644 (file)
@@ -614,6 +614,7 @@ enum {
        OB_EMPTY_IMAGE_HIDE_PERSPECTIVE  = 1 << 0,
        OB_EMPTY_IMAGE_HIDE_ORTHOGRAPHIC = 1 << 1,
        OB_EMPTY_IMAGE_HIDE_BACK         = 1 << 2,
+       OB_EMPTY_IMAGE_HIDE_FRONT        = 1 << 3,
 };
 
 #define MAX_DUPLI_RECUR 8
index 7fde114ca541e7482d70d52a48c71667063a0698..411c6af5a3fb41af7467ec5317d728d2c5924dab 100644 (file)
@@ -2511,9 +2511,16 @@ 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_back", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_negative_sdna(prop, NULL, "empty_image_visibility_flag", OB_EMPTY_IMAGE_HIDE_BACK);
-       RNA_def_property_ui_text(prop, "Display Back Side", "Display empty image even when viewed from the back");
+       static EnumPropertyItem prop_empty_image_side_items[] = {
+               {0, "DOUBLE_SIDED", 0, "Both", ""},
+               {OB_EMPTY_IMAGE_HIDE_BACK, "FRONT", 0, "Front", ""},
+               {OB_EMPTY_IMAGE_HIDE_FRONT, "BACK", 0, "Back", ""},
+               {0, NULL, 0, NULL, NULL}
+       };
+       prop = RNA_def_property(srna, "empty_image_side", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_bitflag_sdna(prop, NULL, "empty_image_visibility_flag");
+       RNA_def_property_enum_items(prop, prop_empty_image_side_items);
+       RNA_def_property_ui_text(prop, "Empty Image Side", "Show front/back side");
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
 
        /* render */