From 1a61c209a0ff7c7b10a3b9bd00cb125fd5e21de6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 29 Jan 2019 20:33:51 +0100 Subject: Workbench: Make Material transparency part of the rgba color picker It is only used for solid mode for now but could be used by eevee in the future. --- source/blender/blenloader/intern/versioning_280.c | 6 ++++++ source/blender/draw/engines/workbench/workbench_deferred.c | 6 +++--- source/blender/makesdna/DNA_material_types.h | 3 +-- source/blender/makesrna/intern/rna_material.c | 8 +------- 4 files changed, 11 insertions(+), 12 deletions(-) (limited to 'source') diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index c5c234580e6..e1e821d6897 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -2790,5 +2790,11 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) { /* Versioning code until next subversion bump goes here. */ + + if (!DNA_struct_elem_find(fd->filesdna, "Material", "float", "a")) { + for (Material *mat = bmain->mat.first; mat; mat = mat->id.next) { + mat->a = 1.0f; + } + } } } diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c index 4e0ec0259c2..538dca3b87f 100644 --- a/source/blender/draw/engines/workbench/workbench_deferred.c +++ b/source/blender/draw/engines/workbench/workbench_deferred.c @@ -943,6 +943,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) if ((ob->col[3] < 1.0f) && (wpd->shading.color_type == V3D_SHADING_OBJECT_COLOR)) { + /* Hack */ wpd->shading.xray_alpha = ob->col[3]; material = workbench_forward_get_or_create_material_data(vedata, ob, NULL, NULL, wpd->shading.color_type, 0); has_transp_mat = true; @@ -978,10 +979,9 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) for (int i = 0; i < materials_len; ++i) { if (geoms != NULL && geoms[i] != NULL) { Material *mat = give_current_material(ob, i + 1); - if (mat != NULL && mat->transparency > 0.0) { + if (mat != NULL && mat->a < 1.0f) { /* Hack */ - wpd->shading.xray_alpha = 1.0f - mat->transparency; - CLAMP(wpd->shading.xray_alpha, 0.0, 1.0); + wpd->shading.xray_alpha = mat->a; material = workbench_forward_get_or_create_material_data(vedata, ob, mat, NULL, V3D_SHADING_MATERIAL_COLOR, 0); has_transp_mat = true; } diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h index 10c40cc28a6..769d4272d70 100644 --- a/source/blender/makesdna/DNA_material_types.h +++ b/source/blender/makesdna/DNA_material_types.h @@ -145,7 +145,7 @@ typedef struct Material { short flag, pad1[7]; /* Colors from Blender Internal that we are still using. */ - float r, g, b; + float r, g, b, a; float specr, specg, specb; float alpha DNA_DEPRECATED; float ray_mirror DNA_DEPRECATED; @@ -154,7 +154,6 @@ typedef struct Material { float gloss_mir DNA_DEPRECATED; float roughness; float metallic; - float transparency; float pad4; /* Ror buttons and render. */ diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index b32d3aa9d78..4a6ab3e8882 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -354,7 +354,7 @@ static void rna_def_material_display(StructRNA *srna) prop = RNA_def_property(srna, "diffuse_color", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "r"); - RNA_def_property_array(prop, 3); + RNA_def_property_array(prop, 4); RNA_def_property_ui_text(prop, "Diffuse Color", "Diffuse color of the material"); RNA_def_property_update(prop, 0, "rna_Material_draw_update"); @@ -384,12 +384,6 @@ static void rna_def_material_display(StructRNA *srna) RNA_def_property_ui_text(prop, "Metallic", "Amount of mirror reflection for raytrace"); RNA_def_property_update(prop, 0, "rna_Material_update"); - prop = RNA_def_property(srna, "transparency", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "transparency"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Transparency", "Amount of transparency in solid mode"); - RNA_def_property_update(prop, 0, "rna_Material_draw_update"); - /* Freestyle line color */ prop = RNA_def_property(srna, "line_color", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "line_col"); -- cgit v1.2.3