Workbench: drawtype object color from collection to v3d
Now every 3d view can have its own solid draw color setting
This commit is contained in:
parent
a8db1efbcf
commit
b0d5e74fcc
|
@ -87,7 +87,7 @@ class COLLECTION_PT_clay_settings(CollectionButtonsPanel, Panel):
|
|||
|
||||
|
||||
class COLLECTION_PT_workbench_settings(CollectionButtonsPanel, Panel):
|
||||
bl_label = "Workbench Settings"
|
||||
bl_label = "Collection Settings"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
@ -96,7 +96,6 @@ class COLLECTION_PT_workbench_settings(CollectionButtonsPanel, Panel):
|
|||
collection_props = collection.engine_overrides['BLENDER_WORKBENCH']
|
||||
|
||||
col = layout.column()
|
||||
col.template_override_property(collection_props, scene_props, "object_color_type")
|
||||
col.template_override_property(collection_props, scene_props, "object_color")
|
||||
|
||||
|
||||
|
|
|
@ -898,20 +898,6 @@ class RENDER_PT_eevee_film(RenderButtonsPanel, Panel):
|
|||
col.prop(rd, "alpha_mode", text="Alpha")
|
||||
|
||||
|
||||
class RENDER_PT_workbench_collection_settings(RenderButtonsPanel, Panel):
|
||||
bl_label = "Workbench Settings"
|
||||
COMPAT_ENGINES = {'BLENDER_WORKBENCH', 'BLENDER_EEVEE', 'CYCLES'}
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
props = context.scene.collection_properties['BLENDER_WORKBENCH']
|
||||
|
||||
col = layout.column()
|
||||
col.prop(props, "object_color_type")
|
||||
if props.object_color_type == 'COLLECTION':
|
||||
col.prop(props, "object_color")
|
||||
|
||||
|
||||
classes = (
|
||||
RENDER_MT_presets,
|
||||
RENDER_MT_ffmpeg_presets,
|
||||
|
@ -941,7 +927,6 @@ classes = (
|
|||
RENDER_PT_eevee_motion_blur,
|
||||
RENDER_PT_eevee_depth_of_field,
|
||||
RENDER_PT_eevee_bloom,
|
||||
RENDER_PT_workbench_collection_settings,
|
||||
)
|
||||
|
||||
if __name__ == "__main__": # only for live edit.
|
||||
|
|
|
@ -68,7 +68,7 @@ static void workbench_solid_flat_cache_init(void *vedata)
|
|||
static void workbench_solid_flat_cache_populate(void *vedata, Object *ob)
|
||||
{
|
||||
WORKBENCH_Data * data = (WORKBENCH_Data *)vedata;
|
||||
workbench_materials_solid_cache_populate(data, ob, V3D_LIGHTING_FLAT);
|
||||
workbench_materials_solid_cache_populate(data, ob);
|
||||
}
|
||||
|
||||
static void workbench_solid_flat_cache_finish(void *UNUSED(vedata))
|
||||
|
|
|
@ -68,7 +68,7 @@ static void workbench_solid_studio_cache_init(void *vedata)
|
|||
static void workbench_solid_studio_cache_populate(void *vedata, Object *ob)
|
||||
{
|
||||
WORKBENCH_Data * data = (WORKBENCH_Data *)vedata;
|
||||
workbench_materials_solid_cache_populate(data, ob, V3D_LIGHTING_STUDIO);
|
||||
workbench_materials_solid_cache_populate(data, ob);
|
||||
}
|
||||
|
||||
static void workbench_solid_studio_cache_finish(void *UNUSED(vedata))
|
||||
|
|
|
@ -49,7 +49,6 @@ static void workbench_layer_collection_settings_create(RenderEngine *UNUSED(engi
|
|||
props->type == IDP_GROUP &&
|
||||
props->subtype == IDP_GROUP_SUB_ENGINE_RENDER);
|
||||
float default_object_color[3] = {1.0, 1.0, 1.0};
|
||||
BKE_collection_engine_property_add_int(props, "object_color_type", V3D_OBJECT_COLOR_COLLECTION);
|
||||
BKE_collection_engine_property_add_float_array(props, "object_color", default_object_color, 3);
|
||||
}
|
||||
|
||||
|
|
|
@ -55,11 +55,10 @@ static uint get_material_hash(const float color[3])
|
|||
return r + g * 4096 + b * 4096 * 4096;
|
||||
}
|
||||
|
||||
static const float* get_material_solid_color(Object *ob)
|
||||
static const float* get_material_solid_color(WORKBENCH_PrivateData *wpd, Object *ob)
|
||||
{
|
||||
IDProperty *props = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_NONE, RE_engine_id_BLENDER_WORKBENCH);
|
||||
int object_color_option = BKE_collection_engine_property_value_get_int(props, "object_color_type");
|
||||
switch (object_color_option)
|
||||
switch (wpd->drawtype_object_color)
|
||||
{
|
||||
default:
|
||||
case V3D_OBJECT_COLOR_COLLECTION:
|
||||
|
@ -104,11 +103,33 @@ void workbench_materials_cache_init(WORKBENCH_Data *vedata)
|
|||
WORKBENCH_PassList *psl = vedata->psl;
|
||||
WORKBENCH_PrivateData *wpd = stl->g_data;
|
||||
|
||||
const DRWContextState *DCS = DRW_context_state_get();
|
||||
|
||||
wpd->depth_shgrp = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass);
|
||||
wpd->material_hash = BLI_ghash_ptr_new("Workbench material_hash");
|
||||
|
||||
View3D *v3d = DCS->v3d;
|
||||
if (v3d) {
|
||||
wpd->drawtype_object_color = v3d->drawtype_object_color;
|
||||
#if 0
|
||||
/* TODO: switch implementation when OB_TEXTURE is implemented */
|
||||
switch (v3d->drawtype) {
|
||||
default:
|
||||
case OB_SOLID:
|
||||
wpd->drawtype_lighting = v3d->drawtype_solid;
|
||||
break;
|
||||
}
|
||||
#else
|
||||
wpd->drawtype_lighting = v3d->drawtype_solid;
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
wpd->drawtype_object_color = V3D_OBJECT_COLOR_COLLECTION;
|
||||
wpd->drawtype_lighting = V3D_LIGHTING_STUDIO;
|
||||
}
|
||||
}
|
||||
|
||||
void workbench_materials_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob, int lighting_mode)
|
||||
void workbench_materials_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
|
||||
{
|
||||
WORKBENCH_StorageList *stl = vedata->stl;
|
||||
WORKBENCH_PassList *psl = vedata->psl;
|
||||
|
@ -124,9 +145,9 @@ void workbench_materials_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob
|
|||
DRW_shgroup_call_add(stl->g_data->depth_shgrp, geom, ob->obmat);
|
||||
|
||||
/* Solid */
|
||||
GPUShader *shader = lighting_mode == V3D_LIGHTING_FLAT?e_data.solid_flat_sh:e_data.solid_studio_sh;
|
||||
GPUShader *shader = wpd->drawtype_lighting == V3D_LIGHTING_FLAT?e_data.solid_flat_sh:e_data.solid_studio_sh;
|
||||
|
||||
const float *color = get_material_solid_color(ob);
|
||||
const float *color = get_material_solid_color(wpd, ob);
|
||||
uint hash = get_material_hash(color);
|
||||
|
||||
material = BLI_ghash_lookup(wpd->material_hash, SET_UINT_IN_POINTER(hash));
|
||||
|
|
|
@ -52,10 +52,12 @@ typedef struct WORKBENCH_Data {
|
|||
|
||||
typedef struct WORKBENCH_PrivateData {
|
||||
DRWShadingGroup *depth_shgrp;
|
||||
|
||||
|
||||
DRWShadingGroup *shadeless_shgrp;
|
||||
|
||||
|
||||
struct GHash *material_hash;
|
||||
short drawtype_object_color;
|
||||
short drawtype_lighting;
|
||||
} WORKBENCH_PrivateData; /* Transient data */
|
||||
|
||||
typedef struct WORKBENCH_MaterialData {
|
||||
|
@ -80,6 +82,6 @@ void workbench_materials_engine_init(void);
|
|||
void workbench_materials_engine_free(void);
|
||||
void workbench_materials_draw_scene_finish(WORKBENCH_Data *vedata);
|
||||
void workbench_materials_cache_init(WORKBENCH_Data *vedata);
|
||||
void workbench_materials_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob, int lighting_mode);
|
||||
void workbench_materials_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -307,6 +307,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
|
|||
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_object_color_type", 0, "", ICON_NONE);
|
||||
}
|
||||
|
||||
row = uiLayoutRow(layout, true);
|
||||
|
|
|
@ -252,6 +252,9 @@ typedef struct View3D {
|
|||
short drawtype_solid;
|
||||
/* drawtype subtype (lighting) used when drawtype == OB_TEXTURE */
|
||||
short drawtype_texture;
|
||||
/* how to draw objects when drawtype == OB_SOLID */
|
||||
short drawtype_object_color;
|
||||
char pad5[6];
|
||||
View3DDebug debug;
|
||||
} View3D;
|
||||
|
||||
|
|
|
@ -363,7 +363,6 @@ RNA_LAYER_ENGINE_CLAY_GET_SET_FLOAT(hair_brightness_randomness)
|
|||
/* workbench engine */
|
||||
/* LayerCollection settings. */
|
||||
RNA_LAYER_ENGINE_WORKBENCH_GET_SET_FLOAT_ARRAY(object_color, 3)
|
||||
RNA_LAYER_ENGINE_WORKBENCH_GET_SET_INT(object_color_type)
|
||||
|
||||
/* eevee engine */
|
||||
/* ViewLayer settings. */
|
||||
|
@ -1673,24 +1672,11 @@ static void rna_def_layer_collection_engine_settings_workbench(BlenderRNA *brna)
|
|||
StructRNA *srna;
|
||||
PropertyRNA *prop;
|
||||
|
||||
static const EnumPropertyItem object_color_type_items[] = {
|
||||
{V3D_OBJECT_COLOR_COLLECTION, "COLLECTION", 0, "Collection", ""},
|
||||
{V3D_OBJECT_COLOR_OBJECT, "OBJECT", 0, "Object", ""},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
srna = RNA_def_struct(brna, "LayerCollectionEngineSettingsWorkbench", "LayerCollectionSettings");
|
||||
RNA_def_struct_ui_text(srna, "Collections Workbench Engine Settings", "Workbench specific settings for this collection");
|
||||
|
||||
RNA_define_verify_sdna(0); /* not in sdna */
|
||||
|
||||
prop = RNA_def_property(srna, "object_color_type", PROP_ENUM, PROP_COLOR);
|
||||
RNA_def_property_enum_funcs(prop, "rna_LayerEngineSettings_Workbench_object_color_type_get", "rna_LayerEngineSettings_Workbench_object_color_type_set", NULL);
|
||||
RNA_def_property_enum_items(prop, object_color_type_items);
|
||||
RNA_def_property_ui_text(prop, "Object Color", "Way colors are given to the Object");
|
||||
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
|
||||
RNA_def_property_update(prop, 0, "rna_LayerCollectionEngineSettings_update");
|
||||
|
||||
prop = RNA_def_property(srna, "object_color", PROP_FLOAT, PROP_COLOR);
|
||||
RNA_def_property_array(prop, 3);
|
||||
RNA_def_property_float_funcs(prop, "rna_LayerEngineSettings_Workbench_object_color_get",
|
||||
|
|
|
@ -182,16 +182,16 @@ const EnumPropertyItem rna_enum_viewport_shade_items[] = {
|
|||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
const EnumPropertyItem rna_enum_viewport_shade_solid_items[] = {
|
||||
{V3D_LIGHTING_FLAT, "FLAT", ICON_SOLID, "Flat Lighting", "Display using flat lighting"},
|
||||
{V3D_LIGHTING_STUDIO, "STUDIO", ICON_SOLID, "Studio Lighting", "Display using studio lighting"},
|
||||
/* {V3D_LIGHTING_SCENE, "SCENE", ICON_SOLID, "Scene Lighting", "Display using scene lighting"}, */
|
||||
const EnumPropertyItem rna_enum_viewport_lighting_items[] = {
|
||||
{V3D_LIGHTING_FLAT, "FLAT", 0, "Flat Lighting", "Display using flat lighting"},
|
||||
{V3D_LIGHTING_STUDIO, "STUDIO", 0, "Studio Lighting", "Display using studio lighting"},
|
||||
/* {V3D_LIGHTING_SCENE, "SCENE", 0, "Scene Lighting", "Display using scene lighting"}, */
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
const EnumPropertyItem rna_enum_viewport_shade_texture_items[] = {
|
||||
{V3D_LIGHTING_FLAT, "FLAT", ICON_POTATO, "Flat Lighting", "Display using flat lighting"},
|
||||
{V3D_LIGHTING_STUDIO, "STUDIO", ICON_POTATO, "Studio Lighting", "Display using studio lighting"},
|
||||
/* {V3D_LIGHTING_SCENE, "SCENE", ICON_POTATO, "Scene Lighting", "Display using scene lighting"}, */
|
||||
|
||||
const EnumPropertyItem rna_enum_viewport_object_color_type_items[] = {
|
||||
{V3D_OBJECT_COLOR_COLLECTION, "COLLECTION", 0, "Collection", ""},
|
||||
{V3D_OBJECT_COLOR_OBJECT, "OBJECT", 0, "Object", ""},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
|
@ -2332,13 +2332,19 @@ static void rna_def_space_view3d(BlenderRNA *brna)
|
|||
|
||||
prop = RNA_def_property(srna, "viewport_shade_solid", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "drawtype_solid");
|
||||
RNA_def_property_enum_items(prop, rna_enum_viewport_shade_solid_items);
|
||||
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_object_color_type", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "drawtype_object_color");
|
||||
RNA_def_property_enum_items(prop, rna_enum_viewport_object_color_type_items);
|
||||
RNA_def_property_ui_text(prop, "Viewport Color", "Type of Color Distribution for Objects");
|
||||
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_shade_texture_items);
|
||||
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_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_SpaceView3D_viewport_shade_update");
|
||||
|
||||
|
|
Loading…
Reference in New Issue