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:
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_label = "Lighting"
bl_parent_id = 'VIEW3D_PT_shading' 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): def draw(self, context):
layout = self.layout layout = self.layout
shading = VIEW3D_PT_shading.get_shading(context) shading = VIEW3D_PT_shading.get_shading(context)
@@ -4028,7 +4033,7 @@ class VIEW3D_PT_shading_color(Panel):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
shading = VIEW3D_PT_shading.get_shading(context) shading = VIEW3D_PT_shading.get_shading(context)
return shading.type == 'SOLID' return shading.type in {'WIREFRAME', 'SOLID'}
def _draw_color_type(self, context): def _draw_color_type(self, context):
layout = self.layout layout = self.layout
@@ -4061,7 +4066,7 @@ class VIEW3D_PT_shading_options(Panel):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
shading = VIEW3D_PT_shading.get_shading(context) shading = VIEW3D_PT_shading.get_shading(context)
return shading.type == 'SOLID' return shading.type in {'WIREFRAME', 'SOLID'}
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
@@ -4079,6 +4084,7 @@ class VIEW3D_PT_shading_options(Panel):
sub.active = is_xray sub.active = is_xray
sub.prop(shading, "xray_alpha", text="X-Ray") sub.prop(shading, "xray_alpha", text="X-Ray")
if shading.type == 'SOLID':
row = col.row() row = col.row()
row.prop(shading, "show_shadows", text="") row.prop(shading, "show_shadows", text="")
row.active = not is_xray row.active = not is_xray
@@ -4114,7 +4120,7 @@ class VIEW3D_PT_shading_options(Panel):
sub.prop(shading, "object_outline_color", text="") sub.prop(shading, "object_outline_color", text="")
col = layout.column() col = layout.column()
if not shading.light == 'MATCAP': if shading.light not in {'WIREFRAME', 'MATCAP'}:
col.prop(shading, "show_specular_highlight") col.prop(shading, "show_specular_highlight")

View File

@@ -363,11 +363,21 @@ void workbench_forward_engine_init(WORKBENCH_Data *vedata)
/* Checker Depth */ /* 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; int state = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_ALWAYS;
psl->checker_depth_pass = DRW_pass_create("Checker Depth", state); psl->checker_depth_pass = DRW_pass_create("Checker Depth", state);
grp = DRW_shgroup_create(e_data.checker_depth_sh, psl->checker_depth_pass); 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_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) { switch (drawtype) {
case OB_WIRE: case OB_WIRE:
use_drw_engine(&draw_engine_workbench_transparent);
break; break;
case OB_SOLID: 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) || if ((stl->g_data->overlay.flag & V3D_OVERLAY_WIREFRAMES) ||
(v3d->shading.type == OB_WIRE) ||
(ob->dtx & OB_DRAWWIRE) || (ob->dtx & OB_DRAWWIRE) ||
(ob->dt == OB_WIRE)) (ob->dt == OB_WIRE))
{ {

View File

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