[Bf-blender-cvs] [668a819bec5] sculpt-dev: Sculpt: Added compile-type name checking for brush channels.
Joseph Eagar
noreply at git.blender.org
Wed Sep 22 11:48:12 CEST 2021
Commit: 668a819bec54f89ba7ef3fb26d7e1001c244e735
Author: Joseph Eagar
Date: Wed Sep 22 02:47:42 2021 -0700
Branches: sculpt-dev
https://developer.blender.org/rB668a819bec54f89ba7ef3fb26d7e1001c244e735
Sculpt: Added compile-type name checking for
brush channels.
===================================================================
M release/datafiles/locale
M release/scripts/addons
M source/blender/blenkernel/BKE_brush_engine.h
M source/blender/blenkernel/CMakeLists.txt
A source/blender/blenkernel/intern/brush_channel_define.h
M source/blender/blenkernel/intern/brush_engine.c
M source/blender/blenkernel/intern/brush_engine_presets.c
M source/blender/editors/sculpt_paint/sculpt.c
M source/blender/editors/sculpt_paint/sculpt_automasking.c
M source/blender/editors/sculpt_paint/sculpt_intern.h
M source/blender/makesrna/intern/rna_brush_engine.c
===================================================================
diff --git a/release/datafiles/locale b/release/datafiles/locale
index 94c39b5832b..8ce0741c51a 160000
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit 94c39b5832b9ef3b56ed94ce4011412e3d776eb2
+Subproject commit 8ce0741c51afec6a12b78c1ce21a7779e1f51c69
diff --git a/release/scripts/addons b/release/scripts/addons
index e7f22134350..eed6d6cc132 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit e7f22134350127ac18747c367bb0ad9a1ef2d8a3
+Subproject commit eed6d6cc132d194efe018996d43a36ebc8d91ad4
diff --git a/source/blender/blenkernel/BKE_brush_engine.h b/source/blender/blenkernel/BKE_brush_engine.h
index 993f83e9a9f..b41eaa8f237 100644
--- a/source/blender/blenkernel/BKE_brush_engine.h
+++ b/source/blender/blenkernel/BKE_brush_engine.h
@@ -53,6 +53,19 @@ struct BlendDataReader;
struct Brush;
struct Sculpt;
+#define MAKE_BUILTIN_CH_NAME(idname) BRUSH_BUILTIN_##idname
+
+/*these macros check channel names at compile time*/
+
+#define BRUSHSET_LOOKUP(chset, channel) \
+ BKE_brush_channelset_lookup(chset, MAKE_BUILTIN_CH_NAME(channel))
+#define BRUSHSET_HAS(chset, channel, mapdata) \
+ BKE_brush_channelset_lookup(chset, MAKE_BUILTIN_CH_NAME(channel))
+#define BRUSHSET_GET_FLOAT(chset, channel, mapdata) \
+ BKE_brush_channelset_get_float(chset, MAKE_BUILTIN_CH_NAME(channel), mapdata)
+#define BRUSHSET_GET_INT(chset, channel, mapdata) \
+ BKE_brush_channelset_get_int(chset, MAKE_BUILTIN_CH_NAME(channel), mapdata)
+
//#define DEBUG_CURVE_MAPPING_ALLOC
#ifdef DEBUG_CURVE_MAPPING_ALLOC
void namestack_push(const char *name);
@@ -133,13 +146,13 @@ void BKE_brush_channelset_free(BrushChannelSet *chset);
void BKE_brush_channelset_add(BrushChannelSet *chset, BrushChannel *ch);
-// makes a copy of ch
+/* makes a copy of ch and adds it to the channel set */
void BKE_brush_channelset_add_duplicate(BrushChannelSet *chset, BrushChannel *ch);
-// does not add to namemap ghash
+/* finds a unique name for ch, does not add it to chset->namemap */
void BKE_brush_channel_ensure_unque_name(BrushChannelSet *chset, BrushChannel *ch);
-// does not free ch or its data
+/* does not free ch or its data */
void BKE_brush_channelset_remove(BrushChannelSet *chset, BrushChannel *ch);
// does not free ch or its data
@@ -262,6 +275,13 @@ bool BKE_brush_mapping_ensure_write(BrushMapping *mp);
void BKE_brush_channelset_apply_mapping(BrushChannelSet *chset, BrushMappingData *mapdata);
void BKE_brush_check_toolsettings(struct Sculpt *sd);
+/*
+set up static type checker for BRUSHSET_XXX macros
+*/
+#define BRUSH_CHANNEL_DEFINE_EXTERNAL
+#include "intern/brush_channel_define.h"
+#undef BRUSH_CHANNEL_DEFINE_EXTERNAL
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index a2058b1017f..0dce06e5350 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -96,6 +96,9 @@ set(SRC
intern/boids.c
intern/bpath.c
intern/brush.c
+ intern/brush_channel_define.h
+ intern/brush_engine.c
+ intern/brush_engine_presets.c
intern/bvhutils.cc
intern/cachefile.c
intern/callbacks.c
@@ -116,6 +119,7 @@ set(SRC
intern/curve_decimate.c
intern/curve_deform.c
intern/curve_eval.cc
+ intern/curvemapping_cache.c
intern/curveprofile.c
intern/customdata.c
intern/customdata_file.c
@@ -289,9 +293,6 @@ set(SRC
intern/workspace.c
intern/world.c
intern/writeavi.c
- intern/brush_engine.c
- intern/brush_engine_presets.c
- intern/curvemapping_cache.c
BKE_DerivedMesh.h
BKE_action.h
diff --git a/source/blender/blenkernel/intern/brush_channel_define.h b/source/blender/blenkernel/intern/brush_channel_define.h
new file mode 100644
index 00000000000..2bb99c97daf
--- /dev/null
+++ b/source/blender/blenkernel/intern/brush_channel_define.h
@@ -0,0 +1,251 @@
+// static name checking stuff
+#if defined(BRUSH_CHANNEL_DEFINE_TYPES) || defined(BRUSH_CHANNEL_DEFINE_EXTERNAL)
+# ifdef MAKE_FLOAT
+# undef MAKE_FLOAT
+# endif
+# ifdef MAKE_FLOAT_EX
+# undef MAKE_FLOAT_EX
+# endif
+# ifdef MAKE_FLOAT_EX_EX
+# undef MAKE_FLOAT_EX_EX
+# endif
+# ifdef MAKE_FLOAT_EX_INV
+# undef MAKE_FLOAT_EX_INV
+# endif
+
+# ifdef MAKE_INT
+# undef MAKE_INT
+# endif
+# ifdef MAKE_INT_EX
+# undef MAKE_INT_EX
+# endif
+# ifdef MAKE_COLOR3
+# undef MAKE_COLOR3
+# endif
+# ifdef MAKE_COLOR4
+# undef MAKE_COLOR4
+# endif
+# ifdef MAKE_BOOL
+# undef MAKE_BOOL
+# endif
+# ifdef MAKE_BOOL_EX
+# undef MAKE_BOOL_EX
+# endif
+# ifdef MAKE_ENUM
+# undef MAKE_ENUM
+# endif
+# ifdef MAKE_FLAGS
+# undef MAKE_FLAGS
+# endif
+# ifdef MAKE_ENUM_EX
+# undef MAKE_ENUM_EX
+# endif
+# ifdef MAKE_FLAGS_EX
+# undef MAKE_FLAGS_EX
+# endif
+
+# ifdef MAKE_BUILTIN_CH_DEF
+# undef MAKE_BUILTIN_CH_DEF
+# endif
+
+# ifdef BRUSH_CHANNEL_DEFINE_TYPES
+# define MAKE_BUILTIN_CH_DEF(idname) const char *BRUSH_BUILTIN_##idname = # idname;
+# else
+# define MAKE_BUILTIN_CH_DEF(idname) extern const char *BRUSH_BUILTIN_##idname;
+# endif
+
+# define MAKE_FLOAT_EX(idname, name, tooltip, val, min, max, smin, smax, pressure_enabled) \
+ MAKE_BUILTIN_CH_DEF(idname)
+# define MAKE_FLOAT_EX_INV(idname, name, tooltip, val, min, max, smin, smax, pressure_enabled) \
+ MAKE_BUILTIN_CH_DEF(idname)
+# define MAKE_FLOAT_EX_EX( \
+ idname, name, tooltip, val, min, max, smin, smax, pressure_enabled, inv) \
+ MAKE_BUILTIN_CH_DEF(idname)
+# define MAKE_FLOAT(idname, name, tooltip, val, min, max) MAKE_BUILTIN_CH_DEF(idname);
+# define MAKE_INT_EX(idname, name, tooltip, val, min, max, smin, smax) \
+ MAKE_BUILTIN_CH_DEF(idname);
+# define MAKE_INT(idname, name, tooltip, val, min, max) MAKE_BUILTIN_CH_DEF(idname);
+# define MAKE_BOOL(idname, name, tooltip, val) MAKE_BUILTIN_CH_DEF(idname);
+# define MAKE_BOOL_EX(idname, name, tooltip, val, flag) MAKE_BUILTIN_CH_DEF(idname);
+# define MAKE_COLOR3(idname, name, tooltip, r, g, b) MAKE_BUILTIN_CH_DEF(idname);
+# define MAKE_COLOR4(idname, name, tooltip, r, g, b, a) MAKE_BUILTIN_CH_DEF(idname);
+# define MAKE_ENUM(idname1, name1, tooltip1, value1, enumdef1) MAKE_BUILTIN_CH_DEF(idname1);
+# define MAKE_ENUM_EX(idname1, name1, tooltip1, value1, enumdef1, flag) \
+ MAKE_BUILTIN_CH_DEF(idname1);
+# define MAKE_FLAGS(idname1, name1, tooltip1, value1, enumdef1) MAKE_BUILTIN_CH_DEF(idname1);
+# define MAKE_FLAGS_EX(idname1, name1, tooltip1, value1, enumdef1, flag1) \
+ MAKE_BUILTIN_CH_DEF(idname1);
+
+#else
+#endif
+
+// annoying trick to pass array initializers through macro arguments
+#define _(...) __VA_ARGS__
+
+/* clang-format off */
+ MAKE_FLOAT_EX(radius, "Radius", "Radius of the brush in pixels", 50.0f, 0.5f, MAX_BRUSH_PIXEL_RADIUS*10, 0.5, MAX_BRUSH_PIXEL_RADIUS, false)
+ MAKE_FLOAT_EX(strength, "Strength", "How powerful the effect of the brush is when applied", 0.5f, 0.0f, 10.0f, 0.0f, 1.0f, false)
+ MAKE_FLOAT_EX(spacing, "Spacing", "", 10.0f, 0.25f, 1000.0f, 1.0f, 500.0f, false)
+ MAKE_FLOAT_EX(topology_rake, "Topology Rake", "Automatically align edges to the brush direction to "
+ "generate cleaner topology and define sharp features. "
+ "Best used on low-poly meshes as it has a performance impact", 0.0f, 0.0f, 5.0f, 0.0f, 2.0f, false)
+ MAKE_FLOAT_EX_INV(autosmooth, "Auto-Smooth", "Amount of smoothing to automatically apply to each stroke", 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, false)
+ MAKE_FLOAT_EX(autosmooth_radius_scale, "Radius Scale", "Ratio between the brush radius and the radius that is going to be "
+ "used for smoothing", 1.0f, 0.001f, 5.0f, 0.01f, 2.0f, false)
+ MAKE_FLOAT_EX(topology_rake_radius_scale, "Radius Scale", "Ratio between the brush radius and the radius that is going to be "
+ "used for topology rake", 1.0f, 0.001f, 5.0f, 0.01f, 2.0f, false)
+ MAKE_FLOAT_EX(dyntopo_radius_scale, "Radius Scale", "Ratio between the brush radius and the radius that is going to be "
+ "used for DynTopo", 1.0f, 0.001f, 5.0f, 0.01f, 2.0f, false)
+ MAKE_FLOAT_EX(projection, "Projection", "Amount of volume preserving projection", 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, false)
+ MAKE_FLOAT_EX(autosmooth_projection, "Projection", "Amount of volume preserving projection", 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, false)
+ MAKE_FLOAT_EX(topology_rake_projection, "Projection", "Amount of volume preserving projection", 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, false)
+ MAKE_FLOAT(fset_slide, "Face Set Projection", "Stick face set boundaries to surface of mesh", 1.0f, 0.0f, 1.0f)
+ MAKE_FLOAT(boundary_smooth, "Boundary Smooth", "Smooth hard boundaries", 1.0f, 0.0f, 1.0f)
+ MAKE_BOOL(topology_rake_use_spacing, "Use Spacing", "Use custom spacing for topology rake", false)
+ MAKE_BOOL(autosmooth_use_spacing, "Use Spacing", "Use custom spacing for autosmooth", false)
+ MAKE_FLOAT_EX(topology_rake_spacing, "Spacing", "Topology rake stroke spacing", 13.0f, 0.05f, 1000.0f, 0.1f, 300.0f, false)
+ MAKE_FLOAT_EX(autosmooth_spacing, "Spacing", "Autosmooth stroke spacing", 13.0f, 0.05f, 1000.0f, 0.1f, 300.0f, false)
+ MAKE_ENUM(topology_rake_mode, "Topology Rake Mode", "", 1, _({
+ {0, "BRUSH_DIRECTION", ICON_NONE, "Stroke", "Stroke Direction"},
+ {1, "CURVATURE", ICON_NONE, "Curvature", "Follow mesh curvature"},
+ {-1},
+ }))
+
+ MAKE_FLAGS_EX(automasking, "Automasking", "", 0, _({
+ {BRUSH_AUTOMASKING_BOUNDARY_EDGES, "BOUNDARY_EDGE", ICON_NONE, "Boundary Edges", ""},
+ {BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS, "BOUNDARY_FACE_SETS", ICON_NONE, "Boundary Face Sets", ""},
+ {BRUSH_AUTOMASKING_CONCAVITY, "CONCAVITY", ICON_NONE, "Concave", ""},
+ {BRUSH_AUTOMASKING_INVERT_CONCAVITY, "INVERT_CONCAVITY", ICON_NONE, "Invert Concave", "Invert Concave Map"},
+ {BRUSH_AUTOMASKING_FACE_SETS, "FACE_SETS", ICON_NONE, "Face Sets", ""},
+ {BRUSH_AUTOMASKING_TOPOLOGY, "TOPOLOGY", ICON_NONE, "Topology", ""},
+ {-1},
+ }), BRUSH_CHANNEL_INHERIT_IF_UNSET)
+
+ MAKE_BOOL_EX(dyntopo_disabled, "Disable Dyntopo", "",
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list