[Bf-blender-cvs] [eae36be372a] master: Refactor: Unify vertex and sculpt colors into new color attribute system.

Joseph Eagar noreply at git.blender.org
Tue Apr 5 20:45:22 CEST 2022


Commit: eae36be372a6b16ee3e76eff0485a47da4f3c230
Author: Joseph Eagar
Date:   Tue Apr 5 11:42:55 2022 -0700
Branches: master
https://developer.blender.org/rBeae36be372a6b16ee3e76eff0485a47da4f3c230

Refactor: Unify vertex and sculpt colors into new
          color attribute system.

This commit removes sculpt colors from experimental
status and unifies it with vertex colors. It
introduces the concept of "color attributes", which
are any attributes that represents colors.  Color
attributes can be represented with byte or floating-point
numbers and can be stored in either vertices or
face corners.

Color attributes share a common namespace
(so you can no longer have a floating-point
sculpt color attribute and a byte vertex color
attribute with the same name).

Note: this commit does not include vertex paint mode,
      which is a separate patch, see:
      https://developer.blender.org/D14179

Differential Revision: https://developer.blender.org/D12587
Ref D12587

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

A	release/datafiles/icons/brush.sculpt.paint.dat
A	release/datafiles/icons/brush.sculpt.smear.dat
A	release/datafiles/icons/ops.sculpt.color_filter.dat
A	release/datafiles/icons/ops.sculpt.mask_by_color.dat
M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	release/scripts/startup/bl_ui/properties_data_mesh.py
M	release/scripts/startup/bl_ui/properties_material_gpencil.py
M	release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M	release/scripts/startup/bl_ui/space_userpref.py
M	release/scripts/startup/bl_ui/space_view3d.py
M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/blenkernel/BKE_attribute.h
M	source/blender/blenkernel/BKE_data_transfer.h
M	source/blender/blenkernel/BKE_paint.h
M	source/blender/blenkernel/BKE_pbvh.h
M	source/blender/blenkernel/CMakeLists.txt
M	source/blender/blenkernel/intern/attribute.c
M	source/blender/blenkernel/intern/brush.c
M	source/blender/blenkernel/intern/customdata.cc
M	source/blender/blenkernel/intern/data_transfer.c
M	source/blender/blenkernel/intern/mesh.cc
M	source/blender/blenkernel/intern/paint.c
M	source/blender/blenkernel/intern/pbvh.c
A	source/blender/blenkernel/intern/pbvh.cc
M	source/blender/blenkernel/intern/pbvh_intern.h
M	source/blender/blenloader/intern/versioning_300.c
M	source/blender/bmesh/intern/bmesh_opdefines.c
M	source/blender/bmesh/operators/bmo_utils.c
M	source/blender/draw/engines/workbench/workbench_engine.c
M	source/blender/draw/intern/draw_cache_extract.h
M	source/blender/draw/intern/draw_cache_impl_mesh.c
M	source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc
M	source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_vcol.cc
M	source/blender/editors/datafiles/CMakeLists.txt
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/include/UI_icons.h
M	source/blender/editors/io/io_alembic.c
M	source/blender/editors/io/io_usd.c
M	source/blender/editors/mesh/editmesh_tools.c
M	source/blender/editors/mesh/mesh_data.c
M	source/blender/editors/object/object_bake_api.c
M	source/blender/editors/object/object_data_transfer.c
M	source/blender/editors/sculpt_paint/paint_hide.c
M	source/blender/editors/sculpt_paint/paint_mask.c
M	source/blender/editors/sculpt_paint/paint_vertex.c
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_cloth.c
M	source/blender/editors/sculpt_paint/sculpt_detail.c
M	source/blender/editors/sculpt_paint/sculpt_dyntopo.c
M	source/blender/editors/sculpt_paint/sculpt_expand.c
M	source/blender/editors/sculpt_paint/sculpt_face_set.c
M	source/blender/editors/sculpt_paint/sculpt_filter_color.c
M	source/blender/editors/sculpt_paint/sculpt_filter_mask.c
M	source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
M	source/blender/editors/sculpt_paint/sculpt_intern.h
M	source/blender/editors/sculpt_paint/sculpt_mask_expand.c
M	source/blender/editors/sculpt_paint/sculpt_mask_init.c
M	source/blender/editors/sculpt_paint/sculpt_ops.c
M	source/blender/editors/sculpt_paint/sculpt_paint_color.c
M	source/blender/editors/sculpt_paint/sculpt_smooth.c
M	source/blender/editors/sculpt_paint/sculpt_transform.c
M	source/blender/editors/sculpt_paint/sculpt_undo.c
M	source/blender/gpu/GPU_buffers.h
M	source/blender/gpu/intern/gpu_buffers.c
M	source/blender/gpu/intern/gpu_codegen.c
M	source/blender/makesdna/DNA_customdata_types.h
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesdna/DNA_userdef_types.h
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_nodetree.c
M	source/blender/makesrna/intern/rna_scene.c
M	source/blender/makesrna/intern/rna_scene_api.c
M	source/blender/makesrna/intern/rna_sculpt_paint.c
M	source/blender/makesrna/intern/rna_space.c
M	source/blender/makesrna/intern/rna_userdef.c
M	source/blender/modifiers/intern/MOD_datatransfer.c
M	source/blender/nodes/NOD_static_types.h
M	source/blender/nodes/shader/nodes/node_shader_vertex_color.cc
M	source/blender/windowmanager/intern/wm_toolsystem.c

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

diff --git a/release/datafiles/icons/brush.sculpt.paint.dat b/release/datafiles/icons/brush.sculpt.paint.dat
new file mode 100644
index 00000000000..1cee34c0dee
Binary files /dev/null and b/release/datafiles/icons/brush.sculpt.paint.dat differ
diff --git a/release/datafiles/icons/brush.sculpt.smear.dat b/release/datafiles/icons/brush.sculpt.smear.dat
new file mode 100644
index 00000000000..3efba0b4cb1
Binary files /dev/null and b/release/datafiles/icons/brush.sculpt.smear.dat differ
diff --git a/release/datafiles/icons/ops.sculpt.color_filter.dat b/release/datafiles/icons/ops.sculpt.color_filter.dat
new file mode 100644
index 00000000000..d589b15a124
Binary files /dev/null and b/release/datafiles/icons/ops.sculpt.color_filter.dat differ
diff --git a/release/datafiles/icons/ops.sculpt.mask_by_color.dat b/release/datafiles/icons/ops.sculpt.mask_by_color.dat
new file mode 100644
index 00000000000..637c47d2d84
Binary files /dev/null and b/release/datafiles/icons/ops.sculpt.mask_by_color.dat differ
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 0422f1afc58..399c4519635 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -7372,8 +7372,7 @@ def km_3d_view_tool_sculpt_mask_by_color(params):
         "3D View Tool: Sculpt, Mask by Color",
         {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
         {"items": [
-            ("sculpt.mask_by_color", {"type": params.tool_mouse, "value": 'ANY'}, None),
-            ("sculpt.mask_by_color", params.tool_tweak_event, None),
+            ("sculpt.mask_by_color", {"type": params.tool_mouse, "value": 'CLICK'}, None)
         ]},
     )
 
diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py
index 8e5f6dba1ab..929953dd411 100644
--- a/release/scripts/startup/bl_ui/properties_data_mesh.py
+++ b/release/scripts/startup/bl_ui/properties_data_mesh.py
@@ -135,19 +135,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'
@@ -433,64 +420,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 DATA_PT_vertex_colors(MeshButtonsPanel, Panel):
-    bl_label = "Vertex Colors"
-    bl_options = {'DEFAULT_CLOSED'}
-    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
-
-    def draw(self, context):
-        layout = self.layout
-
-        me = context.mesh
-
-        row = layout.row()
-        col = row.column()
-
-        col.template_list("MESH_UL_vcols", "vcols", me, "vertex_colors", me.vertex_colors, "active_index", rows=2)
-
-        col = row.column(align=True)
-        col.operator("mesh.vertex_color_add", icon='ADD', text="")
-        col.operator("mesh.vertex_color_remove", icon='REMOVE', text="")
-
-
-class DATA_PT_sculpt_vertex_colors(MeshButtonsPanel, Panel):
-    bl_label = "Sculpt Vertex Colors"
-    bl_options = {'DEFAULT_CLOSED'}
-    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
-
-    @classmethod
-    def poll(cls, context):
-        return super().poll(context) and context.preferences.experimental.use_sculpt_vertex_colors
-
-    def draw(self, context):
-        layout = self.layout
-
-        me = context.mesh
-
-        row = layout.row()
-        col = row.column()
-
-        col.template_list(
-            "MESH_UL_vcols",
-            "svcols",
-            me,
-            "sculpt_vertex_colors",
-            me.sculpt_vertex_colors,
-            "active_index",
-            rows=2,
-        )
-
-        col = row.column(align=True)
-        col.operator("mesh.sculpt_vertex_color_add", icon='ADD', text="")
-        col.operator("mesh.sculpt_vertex_color_remove", icon='REMOVE', text="")
-
-        row = layout.row()
-        col = row.column()
-        col.operator("sculpt.vertex_to_loop_colors", text="Store Sculpt Vertex Color")
-        col.operator("sculpt.loop_to_vertex_colors", text="Load Sculpt Vertex Color")
-
-
 class DATA_PT_remesh(MeshButtonsPanel, Panel):
     bl_label = "Remesh"
     bl_options = {'DEFAULT_CLOSED'}
@@ -514,8 +443,7 @@ class DATA_PT_remesh(MeshButtonsPanel, Panel):
             col.prop(mesh, "use_remesh_preserve_volume", text="Volume")
             col.prop(mesh, "use_remesh_preserve_paint_mask", text="Paint Mask")
             col.prop(mesh, "use_remesh_preserve_sculpt_face_sets", text="Face Sets")
-            if context.preferences.experimental.use_sculpt_vertex_colors:
-                col.prop(mesh, "use_remesh_preserve_vertex_colors", text="Vertex Colors")
+            col.prop(mesh, "use_remesh_preserve_vertex_colors", text="Color Attributes")
 
             col.operator("object.voxel_remesh", text="Voxel Remesh")
         else:
@@ -645,6 +573,79 @@ 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 = []
+
+        for idx, item in enumerate(attrs):
+            skip = item.domain not in {"POINT", "CORNER"}
+            skip = skip or item.data_type not in {"FLOAT_COLOR", "BYTE_COLOR"}
+
+            ret.append(self.bitflag_filter_item if not skip else 0)
+            idxs.append(idx)
+
+        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="")
+        
+        self.draw_attribute_warnings(context, layout)
+
 classes = (
     MESH_MT_vertex_group_context_menu,
     MESH_MT_shape_key_context_menu,
@@ -653,14 +654,12 @@ classes = (
     MESH_UL_fmaps,
     MESH_UL_shape_keys,
     MESH_UL_uvmaps,
-    MESH_UL_vcols,
     MESH_UL_attributes,
     DATA_PT_context_mesh,
     DATA_PT_vertex_groups,
     DATA_PT_shape_keys,
     DATA_PT_uv_texture,
     DATA_PT_vertex_colors,
-    DATA_PT_sculpt_vertex_colors,
     DATA_PT_face_maps,
     DATA_PT_mesh_attributes,
     DATA_PT_normals,
@@ -668,6 +667,7 @@ classes = (
     DATA_PT_remesh,
     DATA_PT_customdata,
     DATA_PT_custom_props_mesh,
+    MESH_UL_color_attributes,
 )
 
 if __name__ == "__main__":  # only for live edit.
diff --git a/release/scripts/startup/bl_ui/properties_material_gpencil.py b/release/scripts/startup/bl_ui/properties_material_gpencil.py
index 35b061ecb21..47c61984cbe 100644
--- a/release/scripts/startup/bl_ui/properties_material_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_material_gpencil.py
@@ -30,8 +30,8 @@ class GPENCIL_MT_material_context_menu(Menu):
 
         layout.separator()
 
-        layout.operator("gpencil.material_to_vertex_color", text="Convert Materials to Vertex Color")
-        layout.operator("gpencil.extract_palette_vertex", text="Extract Palette from Vertex Color")
+        layout.operator("gpencil.material_to_vertex_color", text="Convert Materials to Color Attribute")
+        layout.operator("gpencil.extract_palette_vertex", text="Extract Palette from Color Attribute")
 
         layout.separator()
 
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index fc621c5b51e..b8d30f06193 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsy

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list