[Bf-blender-cvs] [b649fc13ed4] master: Cleanup: Avoid using invalid attribute domain

Hans Goudey noreply at git.blender.org
Tue Aug 23 16:44:32 CEST 2022


Commit: b649fc13ed47a80e9b06b83cd76c6f9ab73154bc
Author: Hans Goudey
Date:   Tue Aug 23 10:44:02 2022 -0400
Branches: master
https://developer.blender.org/rBb649fc13ed47a80e9b06b83cd76c6f9ab73154bc

Cleanup: Avoid using invalid attribute domain

The number of attribute domains isn't an attribute domain, so storing
ATTR_DOMAIN_NUM in a variable with an eAttrDomain type isn't correct.
In the cases it was used, the value wouldn't be accessed anyway.

===================================================================

M	source/blender/blenkernel/intern/paint.c
M	source/blender/blenkernel/intern/pbvh.c
M	source/blender/editors/sculpt_paint/sculpt_undo.c
M	source/blender/gpu/intern/gpu_buffers.c

===================================================================

diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 922ea45703d..25a8ffcaf7e 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -1698,7 +1698,7 @@ static void sculpt_update_object(Depsgraph *depsgraph,
       ss->mcol = NULL;
 
       ss->vcol_type = -1;
-      ss->vcol_domain = ATTR_DOMAIN_NUM;
+      ss->vcol_domain = ATTR_DOMAIN_POINT;
     }
   }
 
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 9db6689167d..726c022ba2c 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -1275,7 +1275,7 @@ bool BKE_pbvh_get_color_layer(const Mesh *me, CustomDataLayer **r_layer, eAttrDo
 
   if (!layer || !ELEM(layer->type, CD_PROP_COLOR, CD_PROP_BYTE_COLOR)) {
     *r_layer = NULL;
-    *r_attr = ATTR_DOMAIN_NUM;
+    *r_attr = ATTR_DOMAIN_POINT;
     return false;
   }
 
@@ -1283,7 +1283,7 @@ bool BKE_pbvh_get_color_layer(const Mesh *me, CustomDataLayer **r_layer, eAttrDo
 
   if (!ELEM(domain, ATTR_DOMAIN_POINT, ATTR_DOMAIN_CORNER)) {
     *r_layer = NULL;
-    *r_attr = ATTR_DOMAIN_NUM;
+    *r_attr = ATTR_DOMAIN_POINT;
     return false;
   }
 
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index 283e9a1c6fa..9a445359c4e 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -1669,11 +1669,12 @@ static void sculpt_undo_set_active_layer(struct bContext *C, SculptAttrRef *attr
    */
   if (!layer) {
     layer = BKE_id_attribute_search(&me->id, attr->name, CD_MASK_PROP_ALL, ATTR_DOMAIN_MASK_ALL);
-    eAttrDomain domain = layer ? BKE_id_attribute_domain(&me->id, layer) : ATTR_DOMAIN_NUM;
-
-    if (layer && ED_geometry_attribute_convert(
-                     me, attr->name, layer->type, domain, attr->type, attr->domain)) {
-      layer = BKE_id_attribute_find(&me->id, attr->name, attr->type, attr->domain);
+    if (layer) {
+      const eAttrDomain domain = BKE_id_attribute_domain(&me->id, layer);
+      if (ED_geometry_attribute_convert(
+              me, attr->name, layer->type, domain, attr->type, attr->domain)) {
+        layer = BKE_id_attribute_find(&me->id, attr->name, attr->type, attr->domain);
+      }
     }
   }
 
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index d64b8b4118a..8d9ae8e5257 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -1324,7 +1324,7 @@ bool GPU_pbvh_attribute_names_update(PBVHType pbvh_type,
       eAttrDomain active_color_domain = active_color_layer ?
                                             BKE_id_attribute_domain(&me_query.id,
                                                                     active_color_layer) :
-                                            ATTR_DOMAIN_NUM;
+                                            ATTR_DOMAIN_POINT;
 
       GPUAttrRef vcol_layers[MAX_GPU_ATTR];
       int totlayer = gpu_pbvh_make_attr_offs(ATTR_DOMAIN_MASK_COLOR,



More information about the Bf-blender-cvs mailing list