diff options
author | Colin Basnett <cmbasnett@gmail.com> | 2022-09-17 03:50:37 +0300 |
---|---|---|
committer | Colin Basnett <cmbasnett@gmail.com> | 2022-09-17 03:50:37 +0300 |
commit | 564bda241a973396da51d7c3ccd9efd97d51728a (patch) | |
tree | 4d9aa4cccd82e2e606b47774afa5e1015bf14768 /source/blender/makesrna/intern/rna_attribute.c | |
parent | 0fff238150d076576053c25b646f653d6e3b0edb (diff) | |
parent | 48d7ff68f0df209c77bbb081ab46fbc109fd825a (diff) |
Merge branch 'master' into feature-imformatfeature-imformat
Diffstat (limited to 'source/blender/makesrna/intern/rna_attribute.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_attribute.c | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_attribute.c b/source/blender/makesrna/intern/rna_attribute.c index 5e17f22ecf5..03bb1a44526 100644 --- a/source/blender/makesrna/intern/rna_attribute.c +++ b/source/blender/makesrna/intern/rna_attribute.c @@ -21,6 +21,8 @@ #include "BKE_attribute.h" #include "BKE_customdata.h" +#include "BLT_translation.h" + #include "WM_types.h" const EnumPropertyItem rna_enum_attribute_type_items[] = { @@ -194,7 +196,7 @@ const EnumPropertyItem *rna_enum_attribute_domain_itemf(ID *id, int totitem = 0, a; static EnumPropertyItem mesh_vertex_domain_item = { - ATTR_DOMAIN_POINT, "POINT", 0, "Vertex", "Attribute per point/vertex"}; + ATTR_DOMAIN_POINT, "POINT", 0, N_("Vertex"), N_("Attribute per point/vertex")}; for (a = 0; rna_enum_attribute_domain_items[a].identifier; a++) { domain_item = &rna_enum_attribute_domain_items[a]; @@ -321,6 +323,36 @@ static void rna_ByteColorAttributeValue_color_set(PointerRNA *ptr, const float * linearrgb_to_srgb_uchar4(&mlcol->r, values); } +static void rna_ByteColorAttributeValue_color_srgb_get(PointerRNA *ptr, float *values) +{ + MLoopCol *col = (MLoopCol *)ptr->data; + values[0] = col->r / 255.0f; + values[1] = col->g / 255.0f; + values[2] = col->b / 255.0f; + values[3] = col->a / 255.0f; +} + +static void rna_ByteColorAttributeValue_color_srgb_set(PointerRNA *ptr, const float *values) +{ + MLoopCol *col = (MLoopCol *)ptr->data; + col->r = round_fl_to_uchar_clamp(values[0] * 255.0f); + col->g = round_fl_to_uchar_clamp(values[1] * 255.0f); + col->b = round_fl_to_uchar_clamp(values[2] * 255.0f); + col->a = round_fl_to_uchar_clamp(values[3] * 255.0f); +} + +static void rna_FloatColorAttributeValue_color_srgb_get(PointerRNA *ptr, float *values) +{ + MPropCol *col = (MPropCol *)ptr->data; + linearrgb_to_srgb_v4(values, col->color); +} + +static void rna_FloatColorAttributeValue_color_srgb_set(PointerRNA *ptr, const float *values) +{ + MPropCol *col = (MPropCol *)ptr->data; + srgb_to_linearrgb_v4(col->color, values); +} + /* Int8 Attribute. */ static int rna_ByteIntAttributeValue_get(PointerRNA *ptr) @@ -715,6 +747,16 @@ static void rna_def_attribute_float_color(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "color"); RNA_def_property_array(prop, 4); RNA_def_property_update(prop, 0, "rna_Attribute_update_data"); + + prop = RNA_def_property(srna, "color_srgb", PROP_FLOAT, PROP_COLOR); + RNA_def_property_ui_text(prop, "Color", "RGBA color in sRGB color space"); + RNA_def_property_float_sdna(prop, NULL, "color"); + RNA_def_property_array(prop, 4); + RNA_def_property_float_funcs(prop, + "rna_FloatColorAttributeValue_color_srgb_get", + "rna_FloatColorAttributeValue_color_srgb_set", + NULL); + RNA_def_property_update(prop, 0, "rna_Attribute_update_data"); } static void rna_def_attribute_byte_color(BlenderRNA *brna) @@ -756,6 +798,16 @@ static void rna_def_attribute_byte_color(BlenderRNA *brna) NULL); RNA_def_property_ui_text(prop, "Color", "RGBA color in scene linear color space"); RNA_def_property_update(prop, 0, "rna_Attribute_update_data"); + + prop = RNA_def_property(srna, "color_srgb", PROP_FLOAT, PROP_COLOR); + RNA_def_property_array(prop, 4); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_float_funcs(prop, + "rna_ByteColorAttributeValue_color_srgb_get", + "rna_ByteColorAttributeValue_color_srgb_set", + NULL); + RNA_def_property_ui_text(prop, "Color", "RGBA color in sRGB color space"); + RNA_def_property_update(prop, 0, "rna_Attribute_update_data"); } static void rna_def_attribute_int(BlenderRNA *brna) |