[Bf-blender-cvs] [7a463bc17a2] temp-sculpt-colors: temp-sculpt-colors: patch updates

Joseph Eagar noreply at git.blender.org
Wed Mar 30 22:03:30 CEST 2022


Commit: 7a463bc17a231d7d7a95d0596d1452fb03820c23
Author: Joseph Eagar
Date:   Wed Mar 30 13:00:42 2022 -0700
Branches: temp-sculpt-colors
https://developer.blender.org/rB7a463bc17a231d7d7a95d0596d1452fb03820c23

temp-sculpt-colors: patch updates

* Got rid of active_render and temporary attribute
  RNA properties
* Active render color attribute is now set via
  an internal operator, GEOMETRY_OT_color_attribute_render_set.
  There is also a new property in AttributeGroup,
  render_color_index that is the index of the active
  render color attribute inside the color attribute list.
* Temporary properties are now filtered internally in
  RNA.

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

M	release/scripts/startup/bl_ui/properties_data_mesh.py
M	source/blender/blenkernel/BKE_attribute.h
M	source/blender/blenkernel/intern/paint.c
M	source/blender/blenkernel/intern/pbvh.c
M	source/blender/blenkernel/intern/pbvh.cc
M	source/blender/blenloader/intern/versioning_300.c
M	source/blender/draw/intern/draw_cache_impl_mesh.c
M	source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc
M	source/blender/editors/geometry/geometry_attributes.cc
M	source/blender/editors/geometry/geometry_intern.hh
M	source/blender/editors/geometry/geometry_ops.cc
M	source/blender/editors/sculpt_paint/sculpt_undo.c
M	source/blender/editors/space_spreadsheet/CMakeLists.txt
M	source/blender/gpu/opengl/gl_vertex_buffer.cc
M	source/blender/makesrna/intern/rna_attribute.c
M	source/blender/makesrna/intern/rna_internal.h
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/makesrna/intern/rna_scene.c
M	source/blender/makesrna/intern/rna_scene_api.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py
index e1bb3fca170..f2c390b538b 100644
--- a/release/scripts/startup/bl_ui/properties_data_mesh.py
+++ b/release/scripts/startup/bl_ui/properties_data_mesh.py
@@ -13,12 +13,16 @@ class MESH_MT_vertex_group_context_menu(Menu):
     def draw(self, _context):
         layout = self.layout
 
-        layout.operator("object.vertex_group_sort",
+        layout.operator(
+            "object.vertex_group_sort",
             icon='SORTALPHA',
-            text="Sort by Name",).sort_type = 'NAME'
-        layout.operator("object.vertex_group_sort",
+            text="Sort by Name",
+        ).sort_type = 'NAME'
+        layout.operator(
+            "object.vertex_group_sort",
             icon='BONE_DATA',
-            text="Sort by Bone Hierarchy",).sort_type = 'BONE_HIERARCHY'
+            text="Sort by Bone Hierarchy",
+        ).sort_type = 'BONE_HIERARCHY'
         layout.separator()
         layout.operator("object.vertex_group_copy", icon='DUPLICATE')
         layout.operator("object.vertex_group_copy_to_selected")
@@ -26,9 +30,11 @@ class MESH_MT_vertex_group_context_menu(Menu):
         layout.operator("object.vertex_group_mirror", icon='ARROW_LEFTRIGHT').use_topology = False
         layout.operator("object.vertex_group_mirror", text="Mirror Vertex Group (Topology)").use_topology = True
         layout.separator()
-        layout.operator("object.vertex_group_remove_from",
+        layout.operator(
+            "object.vertex_group_remove_from",
             icon='X',
-            text="Remove from All Groups",).use_all_groups = True
+            text="Remove from All Groups",
+        ).use_all_groups = True
         layout.operator("object.vertex_group_remove_from", text="Clear Active Group").use_all_verts = True
         layout.operator("object.vertex_group_remove", text="Delete All Unlocked Groups").all_unlocked = True
         layout.operator("object.vertex_group_remove", text="Delete All Groups").all = True
@@ -130,20 +136,6 @@ class MESH_UL_uvmaps(UIList):
             layout.alignment = 'CENTER'
             layout.label(text="", icon_value=icon)
 
-
-class MESH_UL_vcols(UIList):
-    def draw_item(self, _context, layout, _data, item, icon, _active_data, _active_propname, _index):
-        # assert(isinstance(item, (bpy.types.MeshTexturePolyLayer,
-        # bpy.types.MeshLoopColorLayer)))
-        if self.layout_type in {'DEFAULT', 'COMPACT'}:
-            layout.prop(item, "name", text="", emboss=False, icon='GROUP_VCOL')
-            icon = 'RESTRICT_RENDER_OFF' if item.active_render else 'RESTRICT_RENDER_ON'
-            layout.prop(item, "active_render", text="", icon=icon, emboss=False)
-        elif self.layout_type == 'GRID':
-            layout.alignment = 'CENTER'
-            layout.label(text="", icon_value=icon)
-
-
 class MeshButtonsPanel:
     bl_space_type = 'PROPERTIES'
     bl_region_type = 'WINDOW'
@@ -425,106 +417,6 @@ class DATA_PT_uv_texture(MeshButtonsPanel, Panel):
         col.operator("mesh.uv_texture_add", icon='ADD', text="")
         col.operator("mesh.uv_texture_remove", icon='REMOVE', text="")
 
-class MESH_UL_color_attributes(UIList):
-    display_domain_names = {
-        'POINT': "Vertex",
-        'EDGE': "Edge",
-        'FACE': "Face",
-        'CORNER': "Face Corner",
-    }
-
-    def filter_items(self, context, data, property):
-        attrs = getattr(data, property)
-        ret = []
-        idxs = []
-        idx = 0
-
-        for item in attrs:
-            bad = item.domain not in ["POINT", "CORNER"]
-            bad = bad or item.data_type not in ["FLOAT_COLOR", "BYTE_COLOR"]
-            bad = bad or item.temporary
-
-            ret.append(self.bitflag_filter_item if not bad else 0)
-            idxs.append(idx)
-
-            # note this is index in full attribute list, not color list
-            idx += 1
-
-        return ret, idxs
-
-    def draw_item(self, _context, layout, _data, attribute, _icon, _active_data, _active_propname, _index):
-        data_type = attribute.bl_rna.properties['data_type'].enum_items[attribute.data_type]
-
-        domain_name = self.display_domain_names.get(attribute.domain, "")
-
-        split = layout.split(factor=0.50)
-        split.emboss = 'NONE'
-        split.prop(attribute, "name", text="")
-
-        split.prop(attribute, "active_render", text="", icon = 'RESTRICT_RENDER_OFF' if attribute.active_render else 'RESTRICT_RENDER_ON')
-
-        sub = split.row()
-        sub.alignment = 'RIGHT'
-        sub.active = False
-        sub.label(text="%s ▶ %s" % (domain_name, data_type.name))
-
-class DATA_PT_vertex_colors(MeshButtonsPanel, Panel):
-    bl_label = "Color Attributes"
-    bl_options = {'DEFAULT_CLOSED'}
-    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
-
-    def draw(self, context):
-        mesh = context.mesh
-
-        layout = self.layout
-        row = layout.row()
-
-        col = row.column()
-        col.template_list("MESH_UL_color_attributes",
-            "attributes",
-            mesh,
-            "attributes",
-            mesh.attributes,
-            "active_color_index",
-            rows=3,)
-
-        col = row.column(align=True)
-        col.operator("geometry.color_attribute_add", icon='ADD', text="")
-        col.operator("geometry.color_attribute_remove", icon='REMOVE', text="")
-
-        active = mesh.attributes.active
-        
-        self.draw_attribute_warnings(context, layout)
-
-    def draw_attribute_warnings(self, context, layout):
-        attributes_by_name = defaultdict(list)
-
-        ob = context.object
-        mesh = ob.data
-
-        builtin_attribute = object()
-
-        def add_builtin(name):
-            attributes_by_name[name].append(builtin_attribute)
-
-        def add_attributes(layers):
-            for layer in layers:
-                attributes_by_name[layer.name].append(layer)
-
-        add_builtin("position")
-        add_builtin("material_index")
-        add_builtin("shade_smooth")
-        add_builtin("normal")
-        add_builtin("crease")
-
-        add_attributes(mesh.attributes)
-
-        colliding_names = [name for name, layers in attributes_by_name.items() if len(layers) >= 2]
-        if len(colliding_names) == 0:
-            return
-
-        layout.label(text="Name collisions: {}".format(", ".join(colliding_names)), icon='ERROR')
-
 class DATA_PT_remesh(MeshButtonsPanel, Panel):
     bl_label = "Remesh"
     bl_options = {'DEFAULT_CLOSED'}
@@ -690,6 +582,80 @@ class DATA_PT_mesh_attributes(MeshButtonsPanel, Panel):
         layout.label(text="Name collisions: {}".format(", ".join(colliding_names)), icon='ERROR')
 
 
+class MESH_UL_color_attributes(UIList):
+    display_domain_names = {
+        'POINT': "Vertex",
+        'EDGE': "Edge",
+        'FACE': "Face",
+        'CORNER': "Face Corner",
+    }
+
+    def filter_items(self, context, data, property):
+        attrs = getattr(data, property)
+        ret = []
+        idxs = []
+        idx = 0
+
+        for item in attrs:
+            bad = item.domain not in ["POINT", "CORNER"]
+            bad = bad or item.data_type not in ["FLOAT_COLOR", "BYTE_COLOR"]
+
+            ret.append(self.bitflag_filter_item if not bad else 0)
+            idxs.append(idx)
+
+            idx += 1
+
+        return ret, idxs
+
+    def draw_item(self, _context, layout, _data, attribute, _icon, _active_data, _active_propname, _index):
+        data_type = attribute.bl_rna.properties['data_type'].enum_items[attribute.data_type]
+
+        domain_name = self.display_domain_names.get(attribute.domain, "")
+
+        split = layout.split(factor=0.50)
+        split.emboss = 'NONE'
+        split.prop(attribute, "name", text="")
+
+        active_render = _index == _data.color_attributes.render_color_index
+
+        props = split.operator("geometry.color_attribute_render_set", text="", icon = 'RESTRICT_RENDER_OFF' if active_render else 'RESTRICT_RENDER_ON')
+        props.name = attribute.name
+
+        sub = split.row()
+        sub.alignment = 'RIGHT'
+        sub.active = False
+        sub.label(text="%s ▶ %s" % (domain_name, data_type.name))
+
+class DATA_PT_vertex_colors(DATA_PT_mesh_attributes, Panel):
+    bl_label = "Color Attributes"
+    bl_options = {'DEFAULT_CLOSED'}
+    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
+
+    def draw(self, context):
+        mesh = context.mesh
+
+        layout = self.layout
+        row = layout.row()
+
+        col = row.column()
+        col.template_list(
+            "MESH_UL_color_attributes",
+            "color_attributes",
+            mesh,
+            "color_attributes",
+            mesh.color_attributes,
+            "active_color_index",
+            rows=3,
+        )
+
+        col = row.column(align=True)
+        col.operator("geometry.color_attribute_add", icon='ADD', text="")
+        col.operator("geometry.color_attribute_remove", icon='REMOVE', text="")
+
+        active = mesh.attributes.active
+        
+        self.draw_attribute_warnings(context, layout)
+
 classes = (MESH_MT_vertex_group_context_menu,
     MESH_MT_shape_key_context_menu,
     MESH_MT_attribute_context_menu,
@@ -697,7 +663,6 @@ classes = (MESH_MT_vertex_group_context_menu,
     MESH_UL_fmaps,
     MESH_UL_shape_keys,
     MESH_UL_uvmaps,
-    MESH_UL_vcols,
     MESH_UL_attributes,
     DATA_PT_context_mesh,
     DATA_PT_vertex_groups,
@@ -711,7 +676,8 @@ classes = (MESH_MT_vertex_group_context_menu,
     DATA_PT_remesh,
     DATA_PT_customdata,
     DATA_PT_custom_props_mesh,
-    MESH_UL_color_attributes,)
+    MESH_UL_color_attributes,
+)
 
 if __name__ == "__main__":  # only for live edit.
     from bpy.utils import register_class
diff --git a/source/blender/blenkernel/BKE_attribute.h b/source/blender/blenkernel/BKE_attribute.h
index 52bbb07f0ff..1bf2d7ca18e 100644
--- a/source/blender/blenkernel/BKE_attribute.h
+++ b/source/blender/blenkernel/BKE_attribute.h
@@ -103,9 +103,9 @@ void BKE_id_attribute_subset_active_set(struct ID *id,
                                         CustomDataMask mask);
 
 /** C

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list