Workbench: drawtype_* => drawtype_options, drawtype_lighting

In the new design the lighting is shared across the drawtypes.
the drawtype_options will be used for viewport draw engine settings
This commit is contained in:
2018-04-20 13:40:18 +02:00
parent b4aff90fd0
commit f18213ae3a
7 changed files with 18 additions and 31 deletions

View File

@@ -903,8 +903,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->drawtype_solid = V3D_LIGHTING_STUDIO;
v3d->drawtype_wireframe = V3D_LIGHTING_STUDIO;
v3d->drawtype_lighting = V3D_LIGHTING_STUDIO;
/* Assume (demo) files written with 2.8 want to show
* Eevee renders in the viewport. */

View File

@@ -106,11 +106,11 @@ void workbench_materials_cache_init(WORKBENCH_Data *vedata)
switch (v3d->drawtype) {
default:
case OB_SOLID:
wpd->drawtype_lighting = v3d->drawtype_solid;
wpd->drawtype_lighting = v3d->drawtype_lighting;
break;
}
#else
wpd->drawtype_lighting = v3d->drawtype_solid;
wpd->drawtype_lighting = v3d->drawtype_lighting;
#endif
}
else {

View File

@@ -895,19 +895,18 @@ static void drw_engines_enable_external(void)
/* TODO revisit this when proper layering is implemented */
/* Gather all draw engines needed and store them in DST.enabled_engines
* That also define the rendering order of engines */
static void drw_engines_enable_from_engine(RenderEngineType *engine_type, int drawtype,
int UNUSED(drawtype_wireframe), int drawtype_solid, int UNUSED(drawtype_texture))
static void drw_engines_enable_from_engine(RenderEngineType *engine_type, int drawtype, int drawtype_lighting)
{
switch (drawtype) {
case OB_WIRE:
break;
case OB_SOLID:
if (drawtype_solid == V3D_LIGHTING_FLAT) {
if (drawtype_lighting == V3D_LIGHTING_FLAT) {
use_drw_engine(&draw_engine_workbench_solid_flat);
}
else if (drawtype_solid == V3D_LIGHTING_STUDIO) {
else if (drawtype_lighting == V3D_LIGHTING_STUDIO) {
use_drw_engine(&draw_engine_workbench_solid_studio);
}
@@ -1004,11 +1003,9 @@ static void drw_engines_enable(ViewLayer *view_layer, RenderEngineType *engine_t
const int mode = CTX_data_mode_enum_ex(DST.draw_ctx.object_edit, obact, DST.draw_ctx.object_mode);
View3D * v3d = DST.draw_ctx.v3d;
const int drawtype = v3d->drawtype;
const int drawtype_wireframe = v3d->drawtype_wireframe;
const int drawtype_solid = v3d->drawtype_solid;
const int drawtype_texture = v3d->drawtype_texture;
const int drawtype_lighting = v3d->drawtype_lighting;
drw_engines_enable_from_engine(engine_type, drawtype, drawtype_wireframe, drawtype_solid, drawtype_texture);
drw_engines_enable_from_engine(engine_type, drawtype, drawtype_lighting);
if (DRW_state_draw_support()) {
drw_engines_enable_from_overlays(v3d->overlays);

View File

@@ -331,8 +331,7 @@ static SpaceLink *view3d_new(const bContext *C)
v3d->gridlines = 16;
v3d->gridsubdiv = 10;
v3d->drawtype = OB_SOLID;
v3d->drawtype_solid = V3D_LIGHTING_STUDIO;
v3d->drawtype_texture = V3D_LIGHTING_STUDIO;
v3d->drawtype_lighting = V3D_LIGHTING_STUDIO;
v3d->gridflag = V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_FLOOR;

View File

@@ -306,7 +306,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
/* Draw type */
uiItemR(layout, &v3dptr, "viewport_shade", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
if (v3d->drawtype == OB_SOLID) {
uiItemR(layout, &v3dptr, "viewport_shade_solid", 0, "", ICON_NONE);
uiItemR(layout, &v3dptr, "viewport_lighting", 0, "", ICON_NONE);
}
row = uiLayoutRow(layout, true);

View File

@@ -245,15 +245,13 @@ typedef struct View3D {
* Runtime-only, set in the rendered viewport toggle operator.
*/
short prev_drawtype;
/* drawtype subtype (visibility) used when drawtype == OB_WIRE */
short drawtype_wireframe;
/* drawtype subtype (lighting) used when drawtype == OB_SOLID */
short drawtype_solid;
/* drawtype subtype (lighting) used when drawtype == OB_TEXTURE */
short drawtype_texture;
/* drawtype options (lighting, random) used for drawtype == OB_SOLID */
short drawtype_lighting;
short drawtype_options;
short pad5;
int overlays;
int pad5;
int pad6;
View3DDebug debug;
} View3D;

View File

@@ -2269,16 +2269,10 @@ static void rna_def_space_view3d(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Viewport Shading", "Method to display/shade objects in the 3D View");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_SpaceView3D_viewport_shade_update");
prop = RNA_def_property(srna, "viewport_shade_solid", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "drawtype_solid");
prop = RNA_def_property(srna, "viewport_lighting", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "drawtype_lighting");
RNA_def_property_enum_items(prop, rna_enum_viewport_lighting_items);
RNA_def_property_ui_text(prop, "Viewport Lighting (Solid)", "Lighting Method for Solid Viewport Shading");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_SpaceView3D_viewport_shade_update");
prop = RNA_def_property(srna, "viewport_shade_texture", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "drawtype_texture");
RNA_def_property_enum_items(prop, rna_enum_viewport_lighting_items);
RNA_def_property_ui_text(prop, "Viewport Lighting (Texture)", "Lighting Method for Texture Viewport Shading");
RNA_def_property_ui_text(prop, "Viewport Lighting", "Lighting Method for Solid/Texture Viewport Shading");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_SpaceView3D_viewport_shade_update");
prop = RNA_def_property(srna, "show_face_orientation_overlay", PROP_BOOLEAN, PROP_NONE);