From 7ff1d5d9e4cf1f87a617f25ab748d90a7a34282b Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 27 Aug 2024 13:16:10 +0200 Subject: [PATCH] Fix #82514: Default Value for Viewport Display Color's Alpha Wrong. For now duplicate default diffuse color values into RNA code too. Sad work-around, but fixes the problem, until we get rid of hacks like 'interpret 4 consecutive floats in DNA as an array of 4 floats in RNA'. --- source/blender/makesdna/DNA_material_defaults.h | 1 + source/blender/makesrna/intern/rna_material.cc | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/source/blender/makesdna/DNA_material_defaults.h b/source/blender/makesdna/DNA_material_defaults.h index 5bc742f384e..944a7e9580e 100644 --- a/source/blender/makesdna/DNA_material_defaults.h +++ b/source/blender/makesdna/DNA_material_defaults.h @@ -14,6 +14,7 @@ /** \name Material Struct * \{ */ +/* Keep RGBA diffuse defaults in sync with #rna_def_material_display in rna_material.cc */ #define _DNA_DEFAULT_Material \ { \ .r = 0.8, \ diff --git a/source/blender/makesrna/intern/rna_material.cc b/source/blender/makesrna/intern/rna_material.cc index 5ffe7663689..f984644d7a5 100644 --- a/source/blender/makesrna/intern/rna_material.cc +++ b/source/blender/makesrna/intern/rna_material.cc @@ -453,6 +453,10 @@ static void rna_def_material_display(StructRNA *srna) RNA_def_property_array(prop, 4); RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); RNA_def_property_ui_text(prop, "Diffuse Color", "Diffuse color of the material"); + /* See #82514 for details, for now re-define defaults here. Keep in sync with + * #DNA_material_defaults.h */ + static float diffuse_color_default[4] = {0.8f, 0.8f, 0.8f, 1.0f}; + RNA_def_property_float_array_default(prop, diffuse_color_default); RNA_def_property_update(prop, 0, "rna_Material_draw_update"); prop = RNA_def_property(srna, "specular_color", PROP_FLOAT, PROP_COLOR);