DRW: Add back wireframe mode

This is using the existing engine (workbench forward) with 0.0 xray_alpha
and forcing wireframes on all objects.

There is no workflow/shortcut changes in this commit.
This commit is contained in:
Clément Foucault 2018-09-21 14:10:06 +02:00
parent 6934b246d1
commit 3523958de9
5 changed files with 50 additions and 30 deletions

View File

@ -3963,6 +3963,11 @@ class VIEW3D_PT_shading_lighting(Panel):
bl_label = "Lighting"
bl_parent_id = 'VIEW3D_PT_shading'
@classmethod
def poll(cls, context):
shading = VIEW3D_PT_shading.get_shading(context)
return shading.type in {'SOLID', 'MATERIAL'}
def draw(self, context):
layout = self.layout
shading = VIEW3D_PT_shading.get_shading(context)
@ -4028,7 +4033,7 @@ class VIEW3D_PT_shading_color(Panel):
@classmethod
def poll(cls, context):
shading = VIEW3D_PT_shading.get_shading(context)
return shading.type == 'SOLID'
return shading.type in {'WIREFRAME', 'SOLID'}
def _draw_color_type(self, context):
layout = self.layout
@ -4061,7 +4066,7 @@ class VIEW3D_PT_shading_options(Panel):
@classmethod
def poll(cls, context):
shading = VIEW3D_PT_shading.get_shading(context)
return shading.type == 'SOLID'
return shading.type in {'WIREFRAME', 'SOLID'}
def draw(self, context):
layout = self.layout
@ -4079,34 +4084,35 @@ class VIEW3D_PT_shading_options(Panel):
sub.active = is_xray
sub.prop(shading, "xray_alpha", text="X-Ray")
row = col.row()
row.prop(shading, "show_shadows", text="")
row.active = not is_xray
sub = row.row(align=True)
sub.active = is_shadows
sub.prop(shading, "shadow_intensity", text="Shadow")
sub.popover(
panel="VIEW3D_PT_shading_options_shadow",
icon='SCRIPTWIN',
text=""
)
col = layout.column()
row = col.row()
row.active = not is_xray
row.prop(shading, "show_cavity")
if shading.show_cavity:
sub = col.row(align=True)
sub.active = not shading.show_xray and shading.show_cavity
sub.prop(shading, "cavity_ridge_factor")
sub.prop(shading, "cavity_valley_factor")
if shading.type == 'SOLID':
row = col.row()
row.prop(shading, "show_shadows", text="")
row.active = not is_xray
sub = row.row(align=True)
sub.active = is_shadows
sub.prop(shading, "shadow_intensity", text="Shadow")
sub.popover(
panel="VIEW3D_PT_shading_options_ssao",
panel="VIEW3D_PT_shading_options_shadow",
icon='SCRIPTWIN',
text=""
)
col = layout.column()
row = col.row()
row.active = not is_xray
row.prop(shading, "show_cavity")
if shading.show_cavity:
sub = col.row(align=True)
sub.active = not shading.show_xray and shading.show_cavity
sub.prop(shading, "cavity_ridge_factor")
sub.prop(shading, "cavity_valley_factor")
sub.popover(
panel="VIEW3D_PT_shading_options_ssao",
icon='SCRIPTWIN',
text=""
)
row = layout.split()
row.prop(shading, "show_object_outline")
sub = row.row()
@ -4114,7 +4120,7 @@ class VIEW3D_PT_shading_options(Panel):
sub.prop(shading, "object_outline_color", text="")
col = layout.column()
if not shading.light == 'MATCAP':
if shading.light not in {'WIREFRAME', 'MATCAP'}:
col.prop(shading, "show_specular_highlight")

View File

@ -363,11 +363,21 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata)
/* Checker Depth */
{
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.type == OB_WIRE) {
wpd->shading.xray_alpha = 0.0f;
}
int state = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_ALWAYS;
psl->checker_depth_pass = DRW_pass_create("Checker Depth", state);
grp = DRW_shgroup_create(e_data.checker_depth_sh, psl->checker_depth_pass);
DRW_shgroup_call_add(grp, DRW_cache_fullscreen_quad_get(), NULL);
DRW_shgroup_uniform_float_copy(grp, "threshold", 0.75f - wpd->shading.xray_alpha * 0.5f);
DRW_shgroup_uniform_float_copy(grp, "threshold", blend_threshold);
}
}

View File

@ -1164,6 +1164,7 @@ static void drw_engines_enable_from_engine(RenderEngineType *engine_type, int dr
{
switch (drawtype) {
case OB_WIRE:
use_drw_engine(&draw_engine_workbench_transparent);
break;
case OB_SOLID:

View File

@ -236,6 +236,7 @@ static void overlay_cache_populate(void *vedata, Object *ob)
}
if ((stl->g_data->overlay.flag & V3D_OVERLAY_WIREFRAMES) ||
(v3d->shading.type == OB_WIRE) ||
(ob->dtx & OB_DRAWWIRE) ||
(ob->dt == OB_WIRE))
{

View File

@ -238,9 +238,10 @@ static const EnumPropertyItem autosnap_items[] = {
#endif
const EnumPropertyItem rna_enum_shading_type_items[] = {
{OB_SOLID, "SOLID", ICON_SOLID, "Solid", "Display in solid mode"},
{OB_MATERIAL, "MATERIAL", ICON_MATERIAL_DATA, "LookDev", "Display in LookDev mode"},
{OB_RENDER, "RENDERED", ICON_SMOOTH, "Rendered", "Display render preview"},
{OB_WIRE, "WIREFRAME", ICON_WIRE, "Wireframe", "Display the object as wire edges"},
{OB_SOLID, "SOLID", ICON_SOLID, "Solid", "Display in solid mode"},
{OB_MATERIAL, "MATERIAL", ICON_MATERIAL_DATA, "LookDev", "Display in LookDev mode"},
{OB_RENDER, "RENDERED", ICON_SMOOTH, "Rendered", "Display render preview"},
{0, NULL, 0, NULL, NULL}
};
@ -769,6 +770,7 @@ static const EnumPropertyItem *rna_3DViewShading_type_itemf(
EnumPropertyItem *item = NULL;
int totitem = 0;
RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_WIRE);
RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_type_items, OB_SOLID);
if (BKE_scene_uses_blender_eevee(scene)) {