[Bf-blender-cvs] [101d04f41ff] master: Fix T103564: creating a color attribute doesn't make it active
Philipp Oeser
noreply at git.blender.org
Tue Jan 3 11:42:27 CET 2023
Commit: 101d04f41ffbb72bf20e7c2b15f1bb868328cd03
Author: Philipp Oeser
Date: Mon Jan 2 15:27:00 2023 +0100
Branches: master
https://developer.blender.org/rB101d04f41ffbb72bf20e7c2b15f1bb868328cd03
Fix T103564: creating a color attribute doesn't make it active
This was the case when done via the py-API.
Now also set active_color_attribute / default_color_attribute on newly
created attributes (in case none exist yet).
Maniphest Tasks: T103564
Differential Revision: https://developer.blender.org/D16898
===================================================================
M source/blender/makesrna/intern/rna_attribute.c
===================================================================
diff --git a/source/blender/makesrna/intern/rna_attribute.c b/source/blender/makesrna/intern/rna_attribute.c
index f2afbdcce2b..67d0e8adef5 100644
--- a/source/blender/makesrna/intern/rna_attribute.c
+++ b/source/blender/makesrna/intern/rna_attribute.c
@@ -389,6 +389,17 @@ static PointerRNA rna_AttributeGroup_new(
ID *id, ReportList *reports, const char *name, const int type, const int domain)
{
CustomDataLayer *layer = BKE_id_attribute_new(id, name, type, domain, reports);
+
+ if ((GS(id->name) == ID_ME) && ELEM(layer->type, CD_PROP_COLOR, CD_PROP_BYTE_COLOR)) {
+ Mesh *mesh = (Mesh *)id;
+ if (!mesh->active_color_attribute) {
+ mesh->active_color_attribute = BLI_strdup(layer->name);
+ }
+ if (!mesh->default_color_attribute) {
+ mesh->default_color_attribute = BLI_strdup(layer->name);
+ }
+ }
+
DEG_id_tag_update(id, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_GEOM | ND_DATA, id);
More information about the Bf-blender-cvs
mailing list