[Bf-blender-cvs] [09eb086779b] temp-sculpt-colors: temp-sculpt-colors:
Joseph Eagar
noreply at git.blender.org
Wed Mar 23 17:20:49 CET 2022
Commit: 09eb086779b4349a4245fdcb74493204db856286
Author: Joseph Eagar
Date: Wed Mar 23 09:19:00 2022 -0700
Branches: temp-sculpt-colors
https://developer.blender.org/rB09eb086779b4349a4245fdcb74493204db856286
temp-sculpt-colors:
* Updated reverse face colors to use color attribute api.
* Updated rotate face colors to use color attribute api.
* Fixed mask by color not redrawing.
* Fixed duplicate mask by color keymap entry.
* Change bunches of UI strings from "vertex color" to "color attribute."
- But not in git submodules.
===================================================================
M release/scripts/presets/keyconfig/keymap_data/blender_default.py
M release/scripts/startup/bl_ui/properties_material_gpencil.py
M release/scripts/startup/bl_ui/space_view3d.py
M release/scripts/startup/bl_ui/space_view3d_toolbar.py
M source/blender/blenkernel/intern/mesh.cc
M source/blender/bmesh/intern/bmesh_opdefines.c
M source/blender/bmesh/operators/bmo_utils.c
M source/blender/editors/geometry/geometry_attributes.cc
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/sculpt_paint/sculpt_ops.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/nodes/NOD_static_types.h
M source/blender/nodes/shader/nodes/node_shader_vertex_color.cc
===================================================================
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index ac9258d53ca..62aa65ce863 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -7230,8 +7230,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_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_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index cae4e69da00..65723e7197a 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -1864,7 +1864,7 @@ class VIEW3D_MT_paint_gpencil(Menu):
def draw(self, _context):
layout = self.layout
- layout.operator("gpencil.vertex_color_set", text="Set Vertex Colors")
+ layout.operator("gpencil.vertex_color_set", text="Set Color Attribute")
layout.operator("gpencil.stroke_reset_vertex_color")
layout.separator()
layout.operator("gpencil.vertex_color_invert", text="Invert")
@@ -1897,7 +1897,7 @@ class VIEW3D_MT_select_gpencil(Menu):
layout.operator_menu_enum("gpencil.select_grouped", "type", text="Grouped")
if context.mode == 'VERTEX_GPENCIL':
- layout.operator("gpencil.select_vertex_color", text="Vertex Color")
+ layout.operator("gpencil.select_vertex_color", text="Color Attribute")
layout.separator()
@@ -7571,7 +7571,7 @@ class TOPBAR_PT_gpencil_materials(GreasePencilMaterialsPanel, Panel):
class TOPBAR_PT_gpencil_vertexcolor(GreasePencilVertexcolorPanel, Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
- bl_label = "Vertex Color"
+ bl_label = "Color Attribute"
bl_ui_units_x = 10
@classmethod
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 216ca9068da..c4fb0736dd0 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -867,7 +867,7 @@ class VIEW3D_PT_sculpt_voxel_remesh(Panel, View3DPaintPanel):
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")
- col.prop(mesh, "use_remesh_preserve_vertex_colors", text="Vertex Colors")
+ col.prop(mesh, "use_remesh_preserve_vertex_colors", text="Color Attributes")
layout.operator("object.voxel_remesh", text="Remesh")
diff --git a/source/blender/blenkernel/intern/mesh.cc b/source/blender/blenkernel/intern/mesh.cc
index 824c1ab1b90..e6838264be8 100644
--- a/source/blender/blenkernel/intern/mesh.cc
+++ b/source/blender/blenkernel/intern/mesh.cc
@@ -433,7 +433,7 @@ static const char *cmpcode_to_str(int code)
case MESHCMP_DVERT_TOTGROUPMISMATCH:
return "Vertex Doesn't Belong To Same Number Of Groups";
case MESHCMP_LOOPCOLMISMATCH:
- return "Vertex Color Mismatch";
+ return "Color Attribute Mismatch";
case MESHCMP_LOOPUVMISMATCH:
return "UV Mismatch";
case MESHCMP_LOOPMISMATCH:
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c
index 276a8abb731..928b7538f73 100644
--- a/source/blender/bmesh/intern/bmesh_opdefines.c
+++ b/source/blender/bmesh/intern/bmesh_opdefines.c
@@ -1493,6 +1493,7 @@ static BMOpDefine bmo_rotate_colors_def = {
/* slots_in */
{{"faces", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}}, /* input faces */
{"use_ccw", BMO_OP_SLOT_BOOL}, /* rotate counter-clockwise if true, otherwise clockwise */
+ {"object", BMO_OP_SLOT_PTR, {(int)BMO_OP_SLOT_SUBTYPE_PTR_MESH}},
{{'\0'}},
},
{{{'\0'}}}, /* no output */
@@ -1509,6 +1510,7 @@ static BMOpDefine bmo_reverse_colors_def = {
"reverse_colors",
/* slots_in */
{{"faces", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}}, /* input faces */
+ {"object", BMO_OP_SLOT_PTR, {(int)BMO_OP_SLOT_SUBTYPE_PTR_MESH}},
{{'\0'}},
},
{{{'\0'}}}, /* no output */
diff --git a/source/blender/bmesh/operators/bmo_utils.c b/source/blender/bmesh/operators/bmo_utils.c
index c79eecaf1a0..1002e970763 100644
--- a/source/blender/bmesh/operators/bmo_utils.c
+++ b/source/blender/bmesh/operators/bmo_utils.c
@@ -10,11 +10,14 @@
#include "MEM_guardedalloc.h"
#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
#include "BLI_alloca.h"
#include "BLI_math.h"
+#include "BKE_attribute.h"
#include "BKE_customdata.h"
+#include "BKE_object.h"
#include "bmesh.h"
@@ -553,6 +556,29 @@ void bmo_reverse_uvs_exec(BMesh *bm, BMOperator *op)
/**************************************************************************** *
* Cycle colors for a face
**************************************************************************** */
+static void bmo_get_loop_color_ref(BMesh *bm,
+ Object *ob,
+ int *r_cd_color_offset,
+ int *r_cd_color_type)
+{
+ *r_cd_color_offset = -1;
+
+ if (!ob || ob->type != OB_MESH) {
+ fprintf(stderr, "Must pass in a valid mesh object to reverse_colors\n");
+ return;
+ }
+
+ CustomDataLayer *layer = BKE_id_attributes_active_color_get((ID *)ob->data);
+
+ if (!layer || BKE_id_attribute_domain((ID *)ob->data, layer) != ATTR_DOMAIN_CORNER) {
+ return;
+ }
+
+ int layer_i = CustomData_get_layer_index(&bm->ldata, layer->type);
+
+ *r_cd_color_offset = bm->ldata.layers[layer_i].offset;
+ *r_cd_color_type = layer->type;
+}
void bmo_rotate_colors_exec(BMesh *bm, BMOperator *op)
{
@@ -561,39 +587,46 @@ void bmo_rotate_colors_exec(BMesh *bm, BMOperator *op)
BMIter l_iter; /* iteration loop */
const bool use_ccw = BMO_slot_bool_get(op->slots_in, "use_ccw");
- const int cd_loop_color_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPCOL);
+
+ Object *ob = (Object *)BMO_slot_ptr_get(op->slots_in, "object");
+
+ int cd_loop_color_offset;
+ int cd_loop_color_type;
+
+ bmo_get_loop_color_ref(bm, ob, &cd_loop_color_offset, &cd_loop_color_type);
if (cd_loop_color_offset != -1) {
+ const size_t size = cd_loop_color_type == CD_PROP_COLOR ? sizeof(MPropCol) : sizeof(MLoopCol);
+ void *p_col; /* previous color */
+ void *t_col = alloca(size); /* tmp color */
+
BMO_ITER (fs, &fs_iter, op->slots_in, "faces", BM_FACE) {
if (use_ccw == false) { /* same loops direction */
BMLoop *lf; /* current face loops */
- MLoopCol *f_lcol; /* first face loop color */
- MLoopCol p_col; /* previous color */
- MLoopCol t_col; /* tmp color */
+ void *f_lcol; /* first face loop color */
int n = 0;
BM_ITER_ELEM (lf, &l_iter, fs, BM_LOOPS_OF_FACE) {
/* current loop color is the previous loop color */
- MLoopCol *lcol = BM_ELEM_CD_GET_VOID_P(lf, cd_loop_color_offset);
+ void *lcol = BM_ELEM_CD_GET_VOID_P(lf, cd_loop_color_offset);
+
if (n == 0) {
f_lcol = lcol;
- p_col = *lcol;
+ p_col = lcol;
}
else {
- t_col = *lcol;
- *lcol = p_col;
- p_col = t_col;
+ memcpy(t_col, lcol, size);
+ memcpy(lcol, p_col, size);
+ memcpy(p_col, t_col, size);
}
n++;
}
- *f_lcol = p_col;
+ memcpy(f_lcol, p_col, size);
}
- else { /* counter loop direction */
- BMLoop *lf; /* current face loops */
- MLoopCol *p_lcol; /* previous loop color */
- MLoopCol *lcol;
- MLoopCol t_col; /* current color */
+ else { /* counter loop direction */
+ BMLoop *lf; /* current face loops */
+ void *lcol, *p_lcol;
int n = 0;
BM_ITER_ELEM (lf, &l_iter, fs, BM_LOOPS_OF_FACE) {
@@ -601,16 +634,16 @@ void bmo_rotate_colors_exec(BMesh *bm, BMOperator *op)
lcol = BM_ELEM_CD_GET_VOID_P(lf, cd_loop_color_offset);
if (n == 0) {
p_lcol = lcol;
- t_col = *lcol;
+ memcpy(t_col, lcol, size);
}
else {
- *p_lcol = *lcol;
+ memcpy(p_lcol, lcol, size);
p_lcol = lcol;
}
n++;
}
- *lcol = t_col;
+ memcpy(lcol, t_col, size);
}
}
}
@@ -619,35 +652,50 @@ void bmo_rotate_colors_exec(BMesh *bm, BMOperator *op)
/*************************************************************************** *
* Reverse colors for a face
*************************************************************************** */
-static void bm_face_reverse_colors(BMFace *f, const int cd_loop_color_offset)
+static void bm_face_reverse_colors(BMFace *f
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list