[Bf-blender-cvs] [fe475843165] sculpt-dev: Sculpt: Flesh out RNA wrapping of BrushChannels
Joseph Eagar
noreply at git.blender.org
Sat Sep 18 10:26:23 CEST 2021
Commit: fe4758431659ae7429c74334e4889b1f66261f99
Author: Joseph Eagar
Date: Sat Sep 18 00:35:56 2021 -0700
Branches: sculpt-dev
https://developer.blender.org/rBfe4758431659ae7429c74334e4889b1f66261f99
Sculpt: Flesh out RNA wrapping of BrushChannels
===================================================================
M release/datafiles/locale
M release/scripts/addons
M release/scripts/addons_contrib
M release/scripts/startup/bl_ui/properties_paint_common.py
M source/blender/blenkernel/intern/brush_engine.c
M source/blender/editors/sculpt_paint/sculpt.hh
M source/blender/makesrna/intern/rna_brush_engine.c
M source/tools
===================================================================
diff --git a/release/datafiles/locale b/release/datafiles/locale
index 326997b913d..94c39b5832b 160000
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit 326997b913d04bc5bc4656973d1e1a819f860dd2
+Subproject commit 94c39b5832b9ef3b56ed94ce4011412e3d776eb2
diff --git a/release/scripts/addons b/release/scripts/addons
index 59c8409947c..e7f22134350 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit 59c8409947c4174983a36ec28dfeda2be9e254d2
+Subproject commit e7f22134350127ac18747c367bb0ad9a1ef2d8a3
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
index 98f6085e9d7..42da56aa737 160000
--- a/release/scripts/addons_contrib
+++ b/release/scripts/addons_contrib
@@ -1 +1 @@
-Subproject commit 98f6085e9d71ba35d41e5aafbcb7981bd7c48275
+Subproject commit 42da56aa73726710107031787af5eea186797984
diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index bf29c3f8159..8ae7bec51e9 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -972,6 +972,10 @@ def brush_shared_settings(layout, context, brush, popover=False):
layout.row().prop(size_owner, "use_locked_size", expand=True)
layout.separator()
+ #if strength and mode == "SCULPT":
+ # layout.prop(brush.channels.channels["STRENGTH"], "value", text="Strength")
+ # pass
+ #elif strength:
if strength:
pressure_name = "use_pressure_strength" if strength_pressure else None
UnifiedPaintPanel.prop_unified(
diff --git a/source/blender/blenkernel/intern/brush_engine.c b/source/blender/blenkernel/intern/brush_engine.c
index d247a69e4b5..6c4e879be3f 100644
--- a/source/blender/blenkernel/intern/brush_engine.c
+++ b/source/blender/blenkernel/intern/brush_engine.c
@@ -13,6 +13,7 @@
#include "DNA_brush_types.h"
#include "DNA_color_types.h"
#include "DNA_curveprofile_types.h"
+#include "DNA_material_types.h"
#include "DNA_node_types.h"
#include "DNA_sculpt_brush_types.h"
@@ -326,19 +327,49 @@ bool BKE_brush_channelset_has(BrushChannelSet *chset, const char *idname)
return BKE_brush_channelset_lookup(chset, idname) != NULL;
}
-ATTR_NO_OPT void BKE_brush_channelset_add_builtin(BrushChannelSet *chset, const char *idname)
+BrushChannelType brush_default_channel_type = {
+ .name = "Channel",
+ .idname = "CHANNEL",
+ .min = 0.0f,
+ .max = 1.0f,
+ .soft_min = 0.0f,
+ .soft_max = 1.0f,
+ .type = BRUSH_CHANNEL_FLOAT,
+ .flag = 0,
+ .ivalue = 0,
+ .fvalue = 0.0f,
+ .mappings = {.pressure = {.curve = CURVE_PRESET_LINE,
+ .enabled = false,
+ .inv = false,
+ .blendmode = MA_RAMP_BLEND}}};
+
+BrushChannelType *BKE_brush_default_channel_def()
{
- BrushChannelType *def = NULL;
+ return &brush_default_channel_type;
+}
+void BKE_brush_channel_def_copy(BrushChannelType *dst, BrushChannelType *src)
+{
+ *dst = *src;
+}
+
+ATTR_NO_OPT BrushChannelType *BKE_brush_builtin_channel_def_find(const char *name)
+{
for (int i = 0; i < builtin_channel_len; i++) {
- BrushChannelType *def2 = brush_builtin_channels + i;
+ BrushChannelType *def = brush_builtin_channels + i;
- if (STREQ(def2->idname, idname)) {
- def = def2;
- break;
+ if (STREQ(def->idname, name)) {
+ return def;
}
}
+ return NULL;
+}
+
+ATTR_NO_OPT void BKE_brush_channelset_add_builtin(BrushChannelSet *chset, const char *idname)
+{
+ BrushChannelType *def = BKE_brush_builtin_channel_def_find(idname);
+
if (!def) {
printf("%s: Could not find brush %s\n", __func__, idname);
return;
@@ -625,6 +656,13 @@ void BKE_brush_channelset_read(BlendDataReader *reader, BrushChannelSet *cset)
for (int j = 0; j < BRUSH_MAPPING_MAX; j++) {
BKE_curvemapping_blend_read(reader, &ch->mappings[j].curve);
}
+
+ ch->def = BKE_brush_builtin_channel_def_find(ch->idname);
+
+ if (!ch->def) {
+ printf("failed to find brush definition");
+ ch->def = BKE_brush_default_channel_def();
+ }
}
}
diff --git a/source/blender/editors/sculpt_paint/sculpt.hh b/source/blender/editors/sculpt_paint/sculpt.hh
index ca144ea6391..7640ab70736 100644
--- a/source/blender/editors/sculpt_paint/sculpt.hh
+++ b/source/blender/editors/sculpt_paint/sculpt.hh
@@ -4,6 +4,7 @@
/*
This is a proof of concept of how a C++ sculpt system could work.
+It's a design study, not even a proposal.
We can't really use virtual-based polymorphism for performance reasons,
so the idea is to use templates and C++20's concepts instead.
diff --git a/source/blender/makesrna/intern/rna_brush_engine.c b/source/blender/makesrna/intern/rna_brush_engine.c
index a16aec474d5..e05c0bd4690 100644
--- a/source/blender/makesrna/intern/rna_brush_engine.c
+++ b/source/blender/makesrna/intern/rna_brush_engine.c
@@ -66,8 +66,48 @@ int rna_BrushChannelSet_channels_assignint(struct PointerRNA *ptr,
return 1;
}
+float rna_BrushChannel_get_value(PointerRNA *rna)
+{
+ BrushChannel *ch = rna->data;
+
+ return ch->fvalue;
+}
+void rna_BrushChannel_set_value(PointerRNA *rna, float value)
+{
+ BrushChannel *ch = rna->data;
+
+ ch->fvalue = value;
+}
+
+void rna_BrushChannel_value_range(
+ PointerRNA *rna, float *min, float *max, float *soft_min, float *soft_max)
+{
+ BrushChannel *ch = rna->data;
+
+ if (ch->def) {
+ *min = ch->def->min;
+ *max = ch->def->max;
+ *soft_min = ch->def->soft_min;
+ *soft_max = ch->def->soft_max;
+ }
+ else {
+ *min = 0.0f;
+ *max = 1.0f;
+ *soft_min = 0.0f;
+ *soft_max = 1.0f;
+ }
+}
#endif
+extern BrushChannelType *brush_builtin_channels;
+extern const int builtin_channel_len;
+
+EnumPropertyItem channel_types[] = {{BRUSH_CHANNEL_FLOAT, "FLOAT", ICON_NONE, "Float"},
+ {BRUSH_CHANNEL_INT, "INT", ICON_NONE, "Int"},
+ {BRUSH_CHANNEL_ENUM, "ENUM", ICON_NONE, "Enum"},
+ {BRUSH_CHANNEL_BITMASK, "BITMASK", ICON_NONE, "Bitmask"},
+ {-1, NULL, -1, NULL}};
+
void RNA_def_brush_channel(BlenderRNA *brna)
{
StructRNA *srna;
@@ -82,6 +122,36 @@ void RNA_def_brush_channel(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_EDITABLE | PROP_ANIMATABLE);
RNA_def_struct_name_property(srna, prop);
+
+ prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, "BrushChannel", "name");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE | PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Name", "Channel name");
+
+ prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, "BrushChannel", "type");
+ RNA_def_property_enum_items(prop, channel_types);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE | PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Type", "Value Type");
+
+ prop = RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, "BrushChannel", "fvalue");
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
+ RNA_def_property_ui_text(prop, "Value", "Current value");
+ RNA_def_property_float_funcs(prop,
+ "rna_BrushChannel_get_value",
+ "rna_BrushChannel_set_value",
+ "rna_BrushChannel_value_range");
+
+ prop = RNA_def_property(srna, "inherit", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, "BrushChannel", "flag", BRUSH_CHANNEL_INHERIT);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
+ RNA_def_property_ui_text(prop, "Inherit", "Inherit from scene defaults");
+
+ prop = RNA_def_property(srna, "inherit_if_unset", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, "BrushChannel", "flag", BRUSH_CHANNEL_INHERIT_IF_UNSET);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
+ RNA_def_property_ui_text(prop, "Inherit If Unset", "Combine with default settings");
}
void RNA_def_brush_channelset(BlenderRNA *brna)
diff --git a/source/tools b/source/tools
index 548055f4021..723b24841df 160000
--- a/source/tools
+++ b/source/tools
@@ -1 +1 @@
-Subproject commit 548055f40213c775a6b77025525c91e8466e70d6
+Subproject commit 723b24841df1ed8478949bca20c73878fab00dca
More information about the Bf-blender-cvs
mailing list