Image Empties: Option to not display the backside of image empties
Reviewers: brecht Differential Revision: https://developer.blender.org/D3964
This commit is contained in:
@@ -54,9 +54,11 @@ class DATA_PT_empty(DataButtonsPanel, Panel):
|
||||
col.prop(ob, "empty_image_offset", text="Offset X", index=0)
|
||||
col.prop(ob, "empty_image_offset", text="Y", index=1)
|
||||
|
||||
layout.prop(ob, "empty_image_depth", text="Depth", expand=True)
|
||||
layout.prop(ob, "show_empty_image_orthographic", text="Display Orthographic")
|
||||
layout.prop(ob, "show_empty_image_perspective", text="Display Perspective")
|
||||
col = layout.column()
|
||||
col.row().prop(ob, "empty_image_depth", text="Depth", 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_backside", text="Display Backside")
|
||||
|
||||
|
||||
classes = (
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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__);
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
|
@@ -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");
|
||||
|
Reference in New Issue
Block a user