[Bf-blender-cvs] [d7d6ad76d7a] sculpt-dev: sculpt-dev: Fix tip_roundness versioning bug
Joseph Eagar
noreply at git.blender.org
Thu Jun 2 04:34:58 CEST 2022
Commit: d7d6ad76d7ac901eaf3b5850ec32f110df677b03
Author: Joseph Eagar
Date: Wed Jun 1 19:34:22 2022 -0700
Branches: sculpt-dev
https://developer.blender.org/rBd7d6ad76d7ac901eaf3b5850ec32f110df677b03
sculpt-dev: Fix tip_roundness versioning bug
===================================================================
M source/blender/blenkernel/intern/brush_engine_presets.c
M source/blender/blenloader/intern/versioning_300.c
M source/blender/editors/sculpt_paint/sculpt.c
===================================================================
diff --git a/source/blender/blenkernel/intern/brush_engine_presets.c b/source/blender/blenkernel/intern/brush_engine_presets.c
index 4195c7726f8..7638baa8484 100644
--- a/source/blender/blenkernel/intern/brush_engine_presets.c
+++ b/source/blender/blenkernel/intern/brush_engine_presets.c
@@ -52,12 +52,6 @@
extern struct CurveMappingCache *brush_curve_cache;
-#if 1
-struct {
- char t1[32], t2[32], t3[32], t4[32];
-} test[1] = {{1, 1, 1, 1}};
-#endif
-
static bool check_builtin_init();
#if 1
@@ -439,13 +433,19 @@ static bool check_builtin_init()
/* TODO: Destroy these macros.*/
-#define ADDCH_EX(idname, category, visflag) \
- do { \
- BKE_brush_channelset_ensure_builtin(chset, BRUSH_BUILTIN_##idname); \
- BrushChannel *ch = BKE_brush_channelset_lookup(chset, BRUSH_BUILTIN_##idname); \
- SETCAT(idname, category); \
- ch->flag |= visflag; \
- } while (0);
+static void _ensure_channel(BrushChannelSet *chset,
+ const char *idname,
+ const char *category,
+ int visflag)
+{
+ BKE_brush_channelset_ensure_builtin(chset, idname);
+ BrushChannel *ch = BKE_brush_channelset_lookup(chset, idname);
+
+ BLI_strncpy(_get_def(idname)->category, category, sizeof(_get_def(idname)->category));
+ ch->flag |= visflag;
+}
+#define ensure_channel(chset, idname, category, visflag) \
+ _ensure_channel(chset, BRUSH_BUILTIN_##idname, category, visflag)
/* TODO: replace these two macros with equivalent BRUSHSET_XXX ones */
#define ADDCH(name) \
@@ -1104,7 +1104,7 @@ void reset_clay_mappings(BrushChannelSet *chset, bool strips)
}
// adds any missing channels to brushes
-void BKE_brush_builtin_patch(Brush *brush, int tool)
+ATTR_NO_OPT void BKE_brush_builtin_patch(Brush *brush, int tool)
{
check_builtin_init();
@@ -1280,16 +1280,23 @@ void BKE_brush_builtin_patch(Brush *brush, int tool)
/* Patch olds files. */
if (!BRUSHSET_LOOKUP(chset, tip_scale_x)) {
- ADDCH_EX(tip_scale_x,
- "Basic",
- BRUSH_CHANNEL_SHOW_IN_WORKSPACE | BRUSH_CHANNEL_SHOW_IN_CONTEXT_MENU);
- ADDCH_EX(tip_roundness,
- "Basic",
- BRUSH_CHANNEL_SHOW_IN_WORKSPACE | BRUSH_CHANNEL_SHOW_IN_CONTEXT_MENU);
+ ensure_channel(chset,
+ tip_scale_x,
+ "Basic",
+ BRUSH_CHANNEL_SHOW_IN_WORKSPACE | BRUSH_CHANNEL_SHOW_IN_CONTEXT_MENU);
+ ensure_channel(chset,
+ tip_roundness,
+ "Basic",
+ BRUSH_CHANNEL_SHOW_IN_WORKSPACE | BRUSH_CHANNEL_SHOW_IN_CONTEXT_MENU);
if (tool == SCULPT_TOOL_CLAY_STRIPS) {
BRUSHSET_SET_FLOAT(chset, tip_roundness, 0.18f);
}
+ else {
+ BRUSHSET_SET_FLOAT(chset, tip_roundness, 1.0f);
+ }
+
+ BRUSHSET_SET_FLOAT(chset, tip_scale_x, 1.0f);
}
/* stuff for deform_target cloth mode*/
ADDCH(cloth_use_collision);
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index 7ee6d158ece..ddc61a47367 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -2471,6 +2471,9 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
BKE_brush_builtin_create(brush, brush->sculpt_tool);
BKE_brush_channelset_compat_load(brush->channels, brush, true);
+
+ BRUSHSET_SET_FLOAT(brush->channels, tip_roundness, 1.0f);
+ BRUSHSET_SET_FLOAT(brush->channels, tip_scale_x, 1.0f);
}
}
@@ -2885,6 +2888,9 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
BKE_brush_builtin_patch(brush, brush->sculpt_tool);
BKE_brush_channelset_compat_load(brush->channels, brush, true);
+ BRUSHSET_SET_FLOAT(brush->channels, tip_roundness, 1.0f);
+ BRUSHSET_SET_FLOAT(brush->channels, tip_scale_x, 1.0f);
+
Brush temp = *brush;
temp.channels = NULL;
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index de9e0735986..69c9c440536 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -3058,6 +3058,10 @@ bool SCULPT_brush_test_cube_sq(SculptBrushTest *test, const float co[3])
if (SCULPT_brush_test_cube(test, co, test->cube_matrix, test->tip_roundness, true)) {
test->dist *= test->dist * test->radius_squared;
+ if (test->dist > test->radius_squared) {
+ return false;
+ }
+
return true;
}
@@ -3067,7 +3071,7 @@ bool SCULPT_brush_test_cube_sq(SculptBrushTest *test, const float co[3])
bool SCULPT_brush_test_thru_cube_sq(SculptBrushTest *test, const float co[3])
{
if (SCULPT_brush_test_cube(test, co, test->cube_matrix, test->tip_roundness, false)) {
- test->dist *= test->dist * test->radius_squared;
+ test->dist *= test->radius;
return true;
}
@@ -3237,7 +3241,12 @@ SculptBrushTestFn SCULPT_brush_test_init_ex(const SculptSession *ss,
mat[1][3] = 0;
copy_v3_v3(mat[2], ss->cache->cached_area_normal);
mat[2][3] = 0;
- copy_v3_v3(mat[3], ss->cache->location);
+
+ float loc[3];
+ copy_v3_v3(loc, ss->cache->location);
+ madd_v3_v3fl(loc, ss->cache->sculpt_normal_symm, -ss->cache->radius * 0.5f);
+
+ copy_v3_v3(mat[3], loc);
mat[3][3] = 1;
normalize_m4(mat);
More information about the Bf-blender-cvs
mailing list