Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-09-26 21:31:14 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-09-26 21:31:20 +0300
commit5732d9e1dcc08d284d7f9f56be22ad901fd53f22 (patch)
treeb95990cabfe96e39b8a14883c6166e10bd9918fb
parentebd234eee5d7fdae6d7a5efa56171f6ab773a9e1 (diff)
Wireframe/Xray: Make Xray option local to wireframe mode
This commit make the Xray option for the wireframe different from the other shading mode. This makes it possible to rapidly switch between wireframe + Xray and Solid mode without Xray. Xray alpha is also decoupled. Both variables are duplicated and exposed separately through RNA.
-rw-r--r--release/scripts/startup/bl_ui/space_view3d.py27
-rw-r--r--source/blender/blenkernel/intern/screen.c3
-rw-r--r--source/blender/blenloader/intern/versioning_280.c24
-rw-r--r--source/blender/draw/engines/workbench/workbench_forward.c9
-rw-r--r--source/blender/draw/engines/workbench/workbench_render.c2
-rw-r--r--source/blender/draw/intern/DRW_render.h4
-rw-r--r--source/blender/draw/modes/edit_mesh_mode.c4
-rw-r--r--source/blender/draw/modes/object_mode.c2
-rw-r--r--source/blender/draw/modes/overlay_mode.c4
-rw-r--r--source/blender/editors/include/ED_view3d.h4
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c2
-rw-r--r--source/blender/editors/transform/transform_snap_object.c2
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h3
-rw-r--r--source/blender/makesrna/intern/rna_space.c19
14 files changed, 81 insertions, 28 deletions
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index aaaa85a5e09..8a3442f35e5 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -261,6 +261,14 @@ class VIEW3D_HT_header(Header):
sub.active = overlay.show_overlays
sub.popover(panel="VIEW3D_PT_overlay")
+ row = layout.row()
+ row.active = (shading.type in {'WIREFRAME', 'SOLID'}) or object_mode in {'EDIT'}
+
+ if shading.type == 'WIREFRAME':
+ row.prop(shading, "show_xray_wireframe", text="", icon='ORTHO')
+ else:
+ row.prop(shading, "show_xray", text="", icon='ORTHO')
+
row = layout.row(align=True)
row.prop(shading, "type", text="", expand=True)
sub = row.row(align=True)
@@ -3786,7 +3794,10 @@ class VIEW3D_MT_shading_pie(Menu):
sub = pie.row()
sub.active = False
- sub.prop(view.shading, "show_xray", text="Toggle X-Ray", icon='ORTHO')
+ if view.shading.type == 'WIREFRAME':
+ sub.prop(view.shading, "show_xray_wireframe", text="Toggle X-Ray", icon='ORTHO')
+ else:
+ sub.prop(view.shading, "show_xray", text="Toggle X-Ray", icon='ORTHO')
pie.prop(view.overlay, "show_overlays", text="Toggle Overlays", icon='OVERLAY')
pie.prop_enum(view.shading, "type", value='MATERIAL')
@@ -4126,10 +4137,11 @@ class VIEW3D_PT_shading_options(Panel):
is_shadows = shading.show_shadows
row = col.row()
- row.prop(shading, "show_xray", text="")
- sub = row.row()
- sub.active = is_xray
- sub.prop(shading, "xray_alpha", text="X-Ray")
+ row.active = is_xray
+ if shading.type == 'WIREFRAME':
+ row.prop(shading, "xray_alpha_wireframe", text="X-Ray")
+ else:
+ row.prop(shading, "xray_alpha", text="X-Ray")
if shading.type == 'SOLID':
row = col.row()
@@ -4426,7 +4438,10 @@ class VIEW3D_PT_overlay_edit_mesh(Panel):
sub = split.column()
sub.prop(overlay, "show_faces", text="Faces")
sub = split.column()
- sub.active = shading.show_xray
+ if shading.type == 'WIREFRAME':
+ sub.active = shading.show_xray_wireframe
+ else:
+ sub.active = shading.show_xray
sub.prop(overlay, "show_face_center", text="Center")
row = col.row(align=True)
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index 299c9290eae..84962e9b03f 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -787,10 +787,11 @@ void BKE_screen_view3d_shading_init(View3DShading *shading)
shading->type = OB_SOLID;
shading->prev_type = OB_SOLID;
- shading->flag = V3D_SHADING_SPECULAR_HIGHLIGHT;
+ shading->flag = V3D_SHADING_SPECULAR_HIGHLIGHT | V3D_SHADING_XRAY_WIREFRAME;
shading->light = V3D_LIGHTING_STUDIO;
shading->shadow_intensity = 0.5f;
shading->xray_alpha = 0.5f;
+ shading->xray_alpha_wire = 0.5f;
shading->cavity_valley_factor = 1.0f;
shading->cavity_ridge_factor = 1.0f;
copy_v3_fl(shading->single_color, 0.8f);
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 0c946581fcd..10fcbf6d557 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -2107,5 +2107,29 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
+
+ if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "xray_alpha_wire")) {
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->shading.xray_alpha_wire = 0.5f;
+ }
+ }
+ }
+ }
+
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
+ v3d->shading.flag |= V3D_SHADING_XRAY_WIREFRAME;
+ }
+ }
+ }
+ }
+ }
}
}
diff --git a/source/blender/draw/engines/workbench/workbench_forward.c b/source/blender/draw/engines/workbench/workbench_forward.c
index 938852c764e..ca8f06ce146 100644
--- a/source/blender/draw/engines/workbench/workbench_forward.c
+++ b/source/blender/draw/engines/workbench/workbench_forward.c
@@ -365,12 +365,13 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata)
{
float blend_threshold = 0.0f;
- if (draw_ctx->v3d->shading.flag & V3D_SHADING_XRAY) {
- blend_threshold = 0.75f - wpd->shading.xray_alpha * 0.5f;
+ if (draw_ctx->v3d->shading.flag & XRAY_FLAG(draw_ctx->v3d)) {
+ blend_threshold = 0.75f - XRAY_ALPHA(wpd) * 0.5f;
}
if (draw_ctx->v3d->shading.type == OB_WIRE) {
wpd->shading.xray_alpha = 0.0f;
+ wpd->shading.xray_alpha_wire = 0.0f;
}
int state = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_ALWAYS;
@@ -445,7 +446,7 @@ static void workbench_forward_cache_populate_particles(WORKBENCH_Data *vedata, O
DRW_shgroup_uniform_vec4(shgrp, "viewvecs[0]", (float *)wpd->viewvecs, 3);
/* Hairs have lots of layer and can rapidly become the most prominent surface.
* So lower their alpha artificially. */
- float hair_alpha = wpd->shading.xray_alpha * 0.33f;
+ float hair_alpha = XRAY_ALPHA(wpd) * 0.33f;
DRW_shgroup_uniform_float_copy(shgrp, "alpha", hair_alpha);
if (STUDIOLIGHT_ORIENTATION_VIEWNORMAL_ENABLED(wpd)) {
BKE_studiolight_ensure_flag(wpd->studio_light, STUDIOLIGHT_EQUIRECTANGULAR_RADIANCE_GPUTEXTURE);
@@ -611,7 +612,7 @@ void workbench_forward_draw_scene(WORKBENCH_Data *vedata)
GPU_framebuffer_clear_color(fbl->object_outline_fb, clear_outline);
DRW_draw_pass(psl->object_outline_pass);
- if (wpd->shading.xray_alpha > 0.0) {
+ if (XRAY_ALPHA(wpd) > 0.0) {
const float clear_color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
GPU_framebuffer_bind(fbl->transparent_accum_fb);
GPU_framebuffer_clear_color(fbl->transparent_accum_fb, clear_color);
diff --git a/source/blender/draw/engines/workbench/workbench_render.c b/source/blender/draw/engines/workbench/workbench_render.c
index bdbf473ec2d..67059dae861 100644
--- a/source/blender/draw/engines/workbench/workbench_render.c
+++ b/source/blender/draw/engines/workbench/workbench_render.c
@@ -137,7 +137,7 @@ void workbench_render(WORKBENCH_Data *data, RenderEngine *engine, RenderLayer *r
return;
}
- const bool deferred = (scene->display.shading.flag & V3D_SHADING_XRAY) == 0;
+ const bool deferred = (scene->display.shading.flag & XRAY_FLAG(draw_ctx->v3d)) == 0;
if (deferred) {
/* Init engine. */
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index aaad7a8c7a9..193c2416215 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -592,6 +592,8 @@ typedef struct DRWContextState {
const DRWContextState *DRW_context_state_get(void);
-#define XRAY_ENABLED(v3d) ((((v3d)->shading.flag & V3D_SHADING_XRAY) != 0) && ((v3d)->shading.xray_alpha < 1.0f))
+#define XRAY_ALPHA(v3d) (((v3d)->shading.type == OB_WIRE) ? (v3d)->shading.xray_alpha_wire : (v3d)->shading.xray_alpha)
+#define XRAY_FLAG(v3d) (((v3d)->shading.type == OB_WIRE) ? V3D_SHADING_XRAY_WIREFRAME : V3D_SHADING_XRAY)
+#define XRAY_ENABLED(v3d) ((((v3d)->shading.flag & XRAY_FLAG(v3d)) != 0) && (XRAY_ALPHA(v3d) < 1.0f))
#endif /* __DRW_RENDER_H__ */
diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c
index e4670ba7578..f4d6947e967 100644
--- a/source/blender/draw/modes/edit_mesh_mode.c
+++ b/source/blender/draw/modes/edit_mesh_mode.c
@@ -393,7 +393,7 @@ static void EDIT_MESH_cache_init(void *vedata)
stl->g_data->do_faces = true;
stl->g_data->do_edges = true;
- stl->g_data->do_zbufclip = ((v3d)->shading.flag & V3D_SHADING_XRAY) != 0;
+ stl->g_data->do_zbufclip = ((v3d)->shading.flag & XRAY_FLAG(v3d)) != 0;
/* Applies on top of the theme edge width, so edge-mode can have thick edges. */
stl->g_data->edge_width_scale = (tsettings->selectmode & (SCE_SELECT_EDGE)) ? 1.75f : 1.0f;
@@ -692,7 +692,7 @@ static void EDIT_MESH_draw_scene(void *vedata)
const DRWContextState *draw_ctx = DRW_context_state_get();
View3D *v3d = draw_ctx->v3d;
- if (v3d->shading.type == OB_SOLID && (v3d->shading.flag & V3D_SHADING_XRAY) == 0) {
+ if (v3d->shading.type == OB_SOLID && (v3d->shading.flag & XRAY_FLAG(v3d)) == 0) {
if (stl->g_data->ghost_ob == 1 && stl->g_data->edit_ob == 1) {
/* In the case of single ghost object edit (common case for retopology):
* we duplicate the depht+stencil buffer and clear all depth to 1.0f where
diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index 99d71939e2f..2c1dc47a48c 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -1680,7 +1680,7 @@ static void DRW_shgroup_camera(OBJECT_ShadingGroupList *sgl, Object *ob, ViewLay
const bool is_select = DRW_state_is_select();
const bool is_solid_bundle = (v3d->bundle_drawtype == OB_EMPTY_SPHERE) &&
((v3d->shading.type != OB_SOLID) ||
- ((v3d->shading.flag & V3D_SHADING_XRAY) == 0));
+ ((v3d->shading.flag & XRAY_FLAG(v3d)) == 0));
MovieTracking *tracking = &clip->tracking;
/* Index must start in 1, to mimic BKE_tracking_track_get_indexed. */
diff --git a/source/blender/draw/modes/overlay_mode.c b/source/blender/draw/modes/overlay_mode.c
index b28e400055e..3eef5a47288 100644
--- a/source/blender/draw/modes/overlay_mode.c
+++ b/source/blender/draw/modes/overlay_mode.c
@@ -290,7 +290,7 @@ static void overlay_cache_populate(void *vedata, Object *ob)
GPUShader *sh = (all_wires) ? e_data.face_wireframe_sh : e_data.face_wireframe_pretty_sh;
if ((DRW_state_is_select() || DRW_state_is_depth()) &&
- (v3d->shading.flag & V3D_SHADING_XRAY) != 0)
+ (v3d->shading.flag & XRAY_FLAG(v3d)) != 0)
{
static float params[2] = {1.2f, 1.0f}; /* Parameters for all wires */
@@ -332,7 +332,7 @@ static void overlay_cache_finish(void *vedata)
View3D *v3d = ctx->v3d;
/* only in solid mode */
- if (v3d->shading.type == OB_SOLID && (v3d->shading.flag & V3D_SHADING_XRAY) == 0) {
+ if (v3d->shading.type == OB_SOLID && (v3d->shading.flag & XRAY_FLAG(v3d)) == 0) {
if (stl->g_data->ghost_stencil_test) {
DRW_pass_state_add(psl->face_wireframe_pass, DRW_STATE_STENCIL_EQUAL);
DRW_pass_state_add(psl->face_wireframe_full_pass, DRW_STATE_STENCIL_EQUAL);
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index 605c9bc3d97..713cc21c8ec 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -535,8 +535,8 @@ void ED_view3d_operator_properties_viewmat_get(struct wmOperator *op, int *winx,
void ED_view3d_stop_render_preview(struct wmWindowManager *wm, struct ARegion *ar);
void ED_view3d_shade_update(struct Main *bmain, struct View3D *v3d, struct ScrArea *sa);
-#define V3D_IS_ZBUF(v3d) \
- (((v3d)->shading.flag & V3D_SHADING_XRAY) == 0)
+#define V3D_XRAY_FLAG(v3d) (((v3d)->shading.type == OB_WIRE) ? V3D_SHADING_XRAY_WIREFRAME : V3D_SHADING_XRAY)
+#define V3D_IS_ZBUF(v3d) (((v3d)->shading.flag & V3D_XRAY_FLAG(v3d)) == 0)
void ED_view3d_id_remap(struct View3D *v3d, const struct ID *old_id, struct ID *new_id);
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 68e9053101e..ca4fe0ad67b 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -1009,7 +1009,7 @@ int view3d_opengl_select(
}
/* If in xray mode, we select the wires in priority. */
- if (v3d->shading.flag & V3D_SHADING_XRAY) {
+ if (v3d->shading.flag & V3D_XRAY_FLAG(v3d)) {
/* We need to call "GPU_select_*" API's inside DRW_draw_select_loop
* because the OpenGL context created & destroyed inside this function. */
struct DrawSelectLoopUserData drw_select_loop_user_data = {
diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c
index 00d521fc81c..7b8f95dfeaa 100644
--- a/source/blender/editors/transform/transform_snap_object.c
+++ b/source/blender/editors/transform/transform_snap_object.c
@@ -2601,7 +2601,7 @@ static short transform_snap_context_project_view3d_mixed_impl(
bool use_occlusion_test =
params->use_occlusion_test &&
- !(sctx->v3d_data.v3d->shading.flag & V3D_SHADING_XRAY);
+ !(sctx->v3d_data.v3d->shading.flag & V3D_XRAY_FLAG(sctx->v3d_data.v3d));
if (snap_to_flag & SCE_SNAP_MODE_FACE || use_occlusion_test) {
float ray_start[3], ray_normal[3];
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 5c129b1aa3a..c73def54cc6 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -156,12 +156,12 @@ typedef struct View3DShading {
float object_outline_color[3];
float xray_alpha;
+ float xray_alpha_wire;
float cavity_valley_factor;
float cavity_ridge_factor;
float background_color[3];
- int pad;
} View3DShading;
@@ -388,6 +388,7 @@ enum {
V3D_SHADING_CAVITY = (1 << 5),
V3D_SHADING_MATCAP_FLIP_X = (1 << 6),
V3D_SHADING_SCENE_WORLD = (1 << 7),
+ V3D_SHADING_XRAY_WIREFRAME = (1 << 8),
};
/* View3DShading->color_type */
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 1afcafca26b..c4dded4955e 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -2551,6 +2551,12 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Show X-Ray", "Show whole scene transparent");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ prop = RNA_def_property(srna, "show_xray_wireframe", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_XRAY_WIREFRAME);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Show X-Ray", "Show whole scene transparent");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
prop = RNA_def_property(srna, "xray_alpha", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "xray_alpha");
RNA_def_property_float_default(prop, 0.5);
@@ -2559,6 +2565,14 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+ prop = RNA_def_property(srna, "xray_alpha_wireframe", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, NULL, "xray_alpha_wire");
+ RNA_def_property_float_default(prop, 0.5);
+ RNA_def_property_ui_text(prop, "X-Ray Alpha", "Amount of alpha to use");
+ RNA_def_property_range(prop, 0.0f, 1.0f);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
+
prop = RNA_def_property(srna, "use_scene_lights", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_SHADING_SCENE_LIGHTS);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
@@ -2772,11 +2786,6 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Show Wire", "Use wireframe display in painting modes");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
- prop = RNA_def_property(srna, "show_occlude_wire", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "overlay.edit_flag", V3D_OVERLAY_EDIT_OCCLUDE_WIRE);
- RNA_def_property_ui_text(prop, "Hidden Wire", "Use hidden wireframe display in edit mode");
- RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
-
prop = RNA_def_property(srna, "show_weight", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "overlay.edit_flag", V3D_OVERLAY_EDIT_WEIGHT);
RNA_def_property_ui_text(prop, "Show Weights", "Display weights in editmode");