[Bf-blender-cvs] [21c1c3c59c2] blender2.8: 3D View: empty image option to show front/back

Campbell Barton noreply at git.blender.org
Mon Dec 17 04:51:27 CET 2018


Commit: 21c1c3c59c2309512293619cc58f9fe5a1edef2e
Author: Campbell Barton
Date:   Mon Dec 17 14:49:16 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB21c1c3c59c2309512293619cc58f9fe5a1edef2e

3D View: empty image option to show front/back

Only back was possible.

===================================================================

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

===================================================================

diff --git a/release/scripts/startup/bl_operators/object.py b/release/scripts/startup/bl_operators/object.py
index dfa6b1ac4ef..949e2baff03 100644
--- a/release/scripts/startup/bl_operators/object.py
+++ b/release/scripts/startup/bl_operators/object.py
@@ -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:
diff --git a/release/scripts/startup/bl_ui/properties_data_empty.py b/release/scripts/startup/bl_ui/properties_data_empty.py
index bcbb6a7dc01..70c1315927c 100644
--- a/release/scripts/startup/bl_ui/properties_data_empty.py
+++ b/release/scripts/startup/bl_ui/properties_data_empty.py
@@ -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 = (
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 56843899ff6..498658765b6 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -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;
+			}
 		}
 	}
 
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 16ca673c83b..606cbe66d0d 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -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
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 7fde114ca54..411c6af5a3f 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -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 */



More information about the Bf-blender-cvs mailing list