[Bf-blender-cvs] [abfb8b6963f] master: 3D View: option only to show axis aligned image empties
Campbell Barton
noreply at git.blender.org
Tue Sep 3 11:02:22 CEST 2019
Commit: abfb8b6963f4fcf02108e81f17b9de3fbef99dce
Author: Campbell Barton
Date: Tue Sep 3 18:55:26 2019 +1000
Branches: master
https://developer.blender.org/rBabfb8b6963f4fcf02108e81f17b9de3fbef99dce
3D View: option only to show axis aligned image empties
Useful for using reference images that only make sense to see
in aligned axis-views.
This restores functionality possible with 2.7x background images.
See: T52668.
===================================================================
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_ui/properties_data_empty.py b/release/scripts/startup/bl_ui/properties_data_empty.py
index 6650aef61aa..4ce87b85410 100644
--- a/release/scripts/startup/bl_ui/properties_data_empty.py
+++ b/release/scripts/startup/bl_ui/properties_data_empty.py
@@ -60,6 +60,7 @@ class DATA_PT_empty(DataButtonsPanel, Panel):
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_only_axis_aligned")
class DATA_PT_empty_image(DataButtonsPanel, Panel):
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 7ea395e9386..ed517bfc513 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -2985,6 +2985,15 @@ bool BKE_object_empty_image_data_is_visible_in_view3d(const Object *ob, const Re
}
}
+ if (visibility_flag & OB_EMPTY_IMAGE_HIDE_NON_AXIS_ALIGNED) {
+ float proj[3];
+ project_plane_v3_v3v3(proj, ob->obmat[2], rv3d->viewinv[2]);
+ const float proj_length_sq = len_squared_v3(proj);
+ if (proj_length_sq > 1e-5f) {
+ return false;
+ }
+ }
+
return true;
}
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 613871b1fee..ff1839f997c 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -686,6 +686,7 @@ enum {
OB_EMPTY_IMAGE_HIDE_ORTHOGRAPHIC = 1 << 1,
OB_EMPTY_IMAGE_HIDE_BACK = 1 << 2,
OB_EMPTY_IMAGE_HIDE_FRONT = 1 << 3,
+ OB_EMPTY_IMAGE_HIDE_NON_AXIS_ALIGNED = 1 << 4,
};
/** #Object.empty_image_flag */
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 3c0fd282b17..c8a0d543b70 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -2821,6 +2821,14 @@ static void rna_def_object(BlenderRNA *brna)
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_only_axis_aligned", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(
+ prop, NULL, "empty_image_visibility_flag", OB_EMPTY_IMAGE_HIDE_NON_AXIS_ALIGNED);
+ RNA_def_property_ui_text(prop,
+ "Display Only Axis Aligned",
+ "Only display the image when it is aligned with the view axis");
+ RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL);
+
prop = RNA_def_property(srna, "use_empty_image_alpha", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "empty_image_flag", OB_EMPTY_IMAGE_USE_ALPHA_BLEND);
RNA_def_property_ui_text(
More information about the Bf-blender-cvs
mailing list