[Bf-blender-cvs] [0fc46d05e5e] temp-T96709-painting-target: Only show images when texture painting feature is enabled.
Jeroen Bakker
noreply at git.blender.org
Mon Mar 28 11:46:53 CEST 2022
Commit: 0fc46d05e5e9f0e88abd4eaaeb8819ab1c2db6a7
Author: Jeroen Bakker
Date: Mon Mar 28 09:45:42 2022 +0200
Branches: temp-T96709-painting-target
https://developer.blender.org/rB0fc46d05e5e9f0e88abd4eaaeb8819ab1c2db6a7
Only show images when texture painting feature is enabled.
===================================================================
M release/scripts/startup/bl_ui/space_view3d_toolbar.py
M source/blender/editors/sculpt_paint/paint_canvas_material.cc
M source/blender/makesrna/intern/rna_sculpt_paint.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index e051650e117..ced9ac579c6 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -2225,20 +2225,21 @@ class VIEW3D_PT_tools_paint_canvas(View3DPanel, Panel):
@classmethod
def poll(cls, context):
- if not context.preferences.experimental.use_sculpt_texture_paint:
+ if not context.preferences.experimental.use_sculpt_vertex_colors:
return False
if context.active_object is None:
return False
- brush = context.tool_settings.sculpt.brush
- if brush:
- return brush.sculpt_tool in [
- 'PAINT',
- ]
+ from bl_ui.space_toolsystem_common import ToolSelectPanelHelper
+ tool_context = ToolSelectPanelHelper.tool_active_from_context(context)
+ if not tool_context:
+ return False
- # TODO: check active tool... but when migrating to paint mode this might not be needed.
- return True
+ return tool_context.idname in [
+ "builtin_brush.Paint",
+ "builtin.color_filter",
+ ]
def draw(self, context):
layout = self.layout
@@ -2252,6 +2253,7 @@ class VIEW3D_PT_tools_paint_canvas(View3DPanel, Panel):
match settings.canvas_source:
case 'COLOR_ATTRIBUTE':
me = ob.data
+ # TODO(jbakker): When vertex colors are committed change to color attributes
layout.template_list("MESH_UL_vcols", "vcols", me, "vertex_colors", me.vertex_colors, "active_index", rows=2)
case 'MATERIAL':
diff --git a/source/blender/editors/sculpt_paint/paint_canvas_material.cc b/source/blender/editors/sculpt_paint/paint_canvas_material.cc
index 0ed6841ab6b..63befbbb112 100644
--- a/source/blender/editors/sculpt_paint/paint_canvas_material.cc
+++ b/source/blender/editors/sculpt_paint/paint_canvas_material.cc
@@ -130,6 +130,9 @@ struct MaterialCanvas {
{
switch (node->type) {
case SH_NODE_TEX_IMAGE:
+ if (!U.experimental.use_sculpt_texture_paint) {
+ return false;
+ }
return node->id != nullptr;
case SH_NODE_ATTRIBUTE: {
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index 2d291163fc0..341c5aef06d 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -82,14 +82,14 @@ static const EnumPropertyItem rna_enum_gpencil_paint_mode[] = {
"Paint the material with custom vertex color"},
{0, NULL, 0, NULL, NULL},
};
+#endif
-static const EnumPropertyItem rna_enum_canvas_type_items[] = {
+static const EnumPropertyItem rna_enum_canvas_source_items[] = {
{PAINT_CANVAS_COLOR_ATTRIBUTE, "COLOR_ATTRIBUTE", 0, "Color Attribute", ""},
{PAINT_CANVAS_MATERIAL, "MATERIAL", 0, "Material", ""},
{PAINT_CANVAS_IMAGE, "IMAGE", 0, "Image", ""},
{0, NULL, 0, NULL, NULL},
};
-#endif
const EnumPropertyItem rna_enum_symmetrize_direction_items[] = {
{BMO_SYMMETRIZE_NEGATIVE_X, "NEGATIVE_X", 0, "-X to +X", ""},
@@ -558,6 +558,37 @@ static bool rna_PaintModeSettings_image_poll(PointerRNA *UNUSED(ptr), PointerRNA
return !ELEM(image->type, IMA_TYPE_COMPOSITE, IMA_TYPE_R_RESULT);
}
+static int rna_PaintModeSettings_canvas_source_get(PointerRNA *ptr)
+{
+ PaintModeSettings *settings = ptr->data;
+ if (!U.experimental.use_sculpt_texture_paint && settings->canvas_source == PAINT_CANVAS_IMAGE) {
+ return PAINT_CANVAS_COLOR_ATTRIBUTE;
+ }
+
+ return settings->canvas_source;
+}
+
+static const EnumPropertyItem *rna_PaintModeSettings_canvas_source_itemf(bContext *UNUSED(C),
+ PointerRNA *UNUSED(ptr),
+ PropertyRNA *UNUSED(prop),
+ bool *r_free)
+{
+ EnumPropertyItem *items = NULL;
+ int totitem = 0;
+
+ for (int index = 0; rna_enum_canvas_source_items[index].identifier != NULL; index++) {
+ if (!U.experimental.use_sculpt_texture_paint &&
+ rna_enum_canvas_source_items[index].value == PAINT_CANVAS_IMAGE) {
+ continue;
+ }
+ RNA_enum_item_add(&items, &totitem, &rna_enum_canvas_source_items[index]);
+ }
+
+ RNA_enum_item_end(&items, &totitem);
+ *r_free = false;
+ return items;
+}
+
/* \} */
static bool rna_ImaPaint_detect_data(ImagePaintSettings *imapaint)
@@ -999,7 +1030,11 @@ static void rna_def_paint_mode(BlenderRNA *brna)
prop = RNA_def_property(srna, "canvas_source", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "canvas_source");
- RNA_def_property_enum_items(prop, rna_enum_canvas_type_items);
+ RNA_def_property_enum_items(prop, rna_enum_canvas_source_items);
+ RNA_def_property_enum_funcs(prop,
+ "rna_PaintModeSettings_canvas_source_get",
+ NULL,
+ "rna_PaintModeSettings_canvas_source_itemf");
RNA_def_property_ui_text(prop, "Source", "Source to select canvas from");
prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE);
More information about the Bf-blender-cvs
mailing list