Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Eagar <joeedh@gmail.com>2021-09-18 10:35:56 +0300
committerJoseph Eagar <joeedh@gmail.com>2021-09-18 10:35:56 +0300
commitfe4758431659ae7429c74334e4889b1f66261f99 (patch)
tree66f498f1d95fc18db61ecba77f410e097de390f2
parent2d3d6eb7b2a9be40aa5f383a1ff57ef37debc197 (diff)
Sculpt: Flesh out RNA wrapping of BrushChannels
m---------release/datafiles/locale0
m---------release/scripts/addons0
m---------release/scripts/addons_contrib0
-rw-r--r--release/scripts/startup/bl_ui/properties_paint_common.py4
-rw-r--r--source/blender/blenkernel/intern/brush_engine.c50
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.hh1
-rw-r--r--source/blender/makesrna/intern/rna_brush_engine.c70
m---------source/tools0
8 files changed, 119 insertions, 6 deletions
diff --git a/release/datafiles/locale b/release/datafiles/locale
-Subproject 326997b913d04bc5bc4656973d1e1a819f860dd
+Subproject 94c39b5832b9ef3b56ed94ce4011412e3d776eb
diff --git a/release/scripts/addons b/release/scripts/addons
-Subproject 59c8409947c4174983a36ec28dfeda2be9e254d
+Subproject e7f22134350127ac18747c367bb0ad9a1ef2d8a
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
-Subproject 98f6085e9d71ba35d41e5aafbcb7981bd7c4827
+Subproject 42da56aa73726710107031787af5eea18679798
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
-Subproject 548055f40213c775a6b77025525c91e8466e70d
+Subproject 723b24841df1ed8478949bca20c73878fab00dc