forked from bartvdbraak/blender
3D View: add object color drawing option
Has some advantages over existing options. - Using material links color to rendering with no way to vary colors if objects share a material. - Random gives no control, objects may randomly have the same color, duplicating an object often changes it's color.
This commit is contained in:
parent
c8dfe763e5
commit
9dde3e42a7
@ -4378,7 +4378,7 @@ class VIEW3D_PT_shading(Panel):
|
||||
bl_space_type = 'VIEW_3D'
|
||||
bl_region_type = 'HEADER'
|
||||
bl_label = "Shading"
|
||||
bl_ui_units_x = 11
|
||||
bl_ui_units_x = 12
|
||||
|
||||
@classmethod
|
||||
def get_shading(cls, context):
|
||||
|
@ -832,7 +832,8 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
|
||||
DRW_shgroup_call_object_add(material->shgrp, geom_array[i], ob);
|
||||
}
|
||||
}
|
||||
else if (ELEM(wpd->shading.color_type, V3D_SHADING_SINGLE_COLOR, V3D_SHADING_RANDOM_COLOR)) {
|
||||
else if (ELEM(wpd->shading.color_type,
|
||||
V3D_SHADING_SINGLE_COLOR, V3D_SHADING_OBJECT_COLOR, V3D_SHADING_RANDOM_COLOR)) {
|
||||
/* Draw solid color */
|
||||
material = get_or_create_material_data(vedata, ob, NULL, NULL, wpd->shading.color_type);
|
||||
if (is_sculpt_mode) {
|
||||
|
@ -528,7 +528,9 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob)
|
||||
|
||||
/* Fallback from not drawn OB_TEXTURE mode or just OB_SOLID mode */
|
||||
if (!is_drawn) {
|
||||
if (ELEM(wpd->shading.color_type, V3D_SHADING_SINGLE_COLOR, V3D_SHADING_RANDOM_COLOR)) {
|
||||
if (ELEM(wpd->shading.color_type,
|
||||
V3D_SHADING_SINGLE_COLOR, V3D_SHADING_OBJECT_COLOR, V3D_SHADING_RANDOM_COLOR))
|
||||
{
|
||||
/* No material split needed */
|
||||
struct GPUBatch *geom = DRW_cache_object_surface_get(ob);
|
||||
if (geom) {
|
||||
|
@ -37,6 +37,10 @@ void workbench_material_update_data(WORKBENCH_PrivateData *wpd, Object *ob, Mate
|
||||
hsv_to_rgb_v(hsv, data->diffuse_color);
|
||||
copy_v3_v3(data->base_color, data->diffuse_color);
|
||||
}
|
||||
else if (color_type == V3D_SHADING_OBJECT_COLOR) {
|
||||
copy_v3_v3(data->diffuse_color, ob->col);
|
||||
copy_v3_v3(data->base_color, data->diffuse_color);
|
||||
}
|
||||
else {
|
||||
/* V3D_SHADING_MATERIAL_COLOR */
|
||||
if (mat) {
|
||||
|
@ -405,6 +405,7 @@ enum {
|
||||
V3D_SHADING_RANDOM_COLOR = 1,
|
||||
V3D_SHADING_SINGLE_COLOR = 2,
|
||||
V3D_SHADING_TEXTURE_COLOR = 3,
|
||||
V3D_SHADING_OBJECT_COLOR = 4,
|
||||
};
|
||||
|
||||
/* View3DShading->background_type */
|
||||
|
@ -284,6 +284,7 @@ static const EnumPropertyItem rna_enum_viewport_lighting_items[] = {
|
||||
static const EnumPropertyItem rna_enum_shading_color_type_items[] = {
|
||||
{V3D_SHADING_SINGLE_COLOR, "SINGLE", 0, "Single", "Show scene in a single color"},
|
||||
{V3D_SHADING_MATERIAL_COLOR, "MATERIAL", 0, "Material", "Show material color"},
|
||||
{V3D_SHADING_OBJECT_COLOR, "OBJECT", 0, "Object", "Show object color"},
|
||||
{V3D_SHADING_RANDOM_COLOR, "RANDOM", 0, "Random", "Show random object color"},
|
||||
{V3D_SHADING_TEXTURE_COLOR, "TEXTURE", 0, "Texture", "Show texture"},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
@ -819,6 +820,7 @@ static const EnumPropertyItem *rna_View3DShading_color_type_itemf(
|
||||
if (shading->type == OB_SOLID) {
|
||||
RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_color_type_items, V3D_SHADING_SINGLE_COLOR);
|
||||
RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_color_type_items, V3D_SHADING_MATERIAL_COLOR);
|
||||
RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_color_type_items, V3D_SHADING_OBJECT_COLOR);
|
||||
RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_color_type_items, V3D_SHADING_RANDOM_COLOR);
|
||||
if (shading->light != V3D_LIGHTING_MATCAP) {
|
||||
RNA_enum_items_add_value(&item, &totitem, rna_enum_shading_color_type_items, V3D_SHADING_TEXTURE_COLOR);
|
||||
|
Loading…
Reference in New Issue
Block a user