[Bf-blender-cvs] [318bc8ea428] sculpt-dev: Sculpt: fix symmetry bug and mesh filter smooth improvements
Joseph Eagar
noreply at git.blender.org
Mon Oct 11 13:28:16 CEST 2021
Commit: 318bc8ea42807b27906f59049ee7be2f3e9c5867
Author: Joseph Eagar
Date: Mon Oct 11 04:25:47 2021 -0700
Branches: sculpt-dev
https://developer.blender.org/rB318bc8ea42807b27906f59049ee7be2f3e9c5867
Sculpt: fix symmetry bug and mesh filter
smooth improvements
* Fixed symmetry bug
* Exposed a few hard edge options to the mesh filter tool
* Updated default brushes inside of startup.blend.
===================================================================
M release/datafiles/startup.blend
M release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M source/blender/blenkernel/BKE_brush.h
M source/blender/blenkernel/intern/brush_engine_presets.c
M source/blender/blenkernel/intern/customdata.c
M source/blender/blenkernel/intern/dyntopo.c
M source/blender/blenkernel/intern/pbvh_bmesh.c
M source/blender/editors/sculpt_paint/sculpt.c
M source/blender/editors/sculpt_paint/sculpt_cloth.c
M source/blender/editors/sculpt_paint/sculpt_filter_mesh.c
M source/blender/editors/sculpt_paint/sculpt_intern.h
M source/blender/editors/sculpt_paint/sculpt_smooth.c
M source/blender/makesdna/DNA_meshdata_types.h
===================================================================
diff --git a/release/datafiles/startup.blend b/release/datafiles/startup.blend
index 20ebf5d9986..e6000b345d2 100644
Binary files a/release/datafiles/startup.blend and b/release/datafiles/startup.blend differ
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index 58c66f5927e..b4992dc4478 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -1346,6 +1346,15 @@ class _defs_sculpt:
elif props.type == 'SPHERE':
layout.prop(props, "sphere_center", expand=False)
+ if props.type in ["SMOOTH", "SPHERE", "SURFACE_SMOOTH", "SHARPEN"]:
+ layout.prop(props, "weighted")
+
+ if props.type == "SMOOTH":
+ #layout.prop(props, "hard_edge_fac")
+ layout.prop(props, "hard_edge_mode")
+ layout.prop(props, "preserve_fset_boundaries")
+ layout.prop(props, "bound_smooth_radius")
+
return dict(idname="builtin.mesh_filter",
label="Mesh Filter",
icon="ops.sculpt.mesh_filter",
diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h
index c706739b3b4..cf38239d948 100644
--- a/source/blender/blenkernel/BKE_brush.h
+++ b/source/blender/blenkernel/BKE_brush.h
@@ -162,9 +162,13 @@ void BKE_brush_default_input_curves_set(struct Brush *brush);
#define BKE_brush_tool_set(brush, p, tool) \
{ \
CHECK_TYPE_ANY(brush, struct Brush *); \
+ char _old = *(char *)POINTER_OFFSET(brush, (p)->runtime.tool_offset); \
*(char *)POINTER_OFFSET(brush, (p)->runtime.tool_offset) = tool; \
if ((p)->runtime.ob_mode == OB_MODE_SCULPT) { \
BKE_brush_builtin_patch(brush, tool); \
+ if (_old != tool) { \
+ BKE_brush_sculpt_reset(brush, tool); \
+ } \
} \
} \
((void)0)
diff --git a/source/blender/blenkernel/intern/brush_engine_presets.c b/source/blender/blenkernel/intern/brush_engine_presets.c
index 4f27042a751..780cdc84489 100644
--- a/source/blender/blenkernel/intern/brush_engine_presets.c
+++ b/source/blender/blenkernel/intern/brush_engine_presets.c
@@ -537,7 +537,7 @@ BrushFlagMap brush_flags_map[] = {
DEF(flag, accumulate, BRUSH_ACCUMULATE)
DEF(flag2, use_weighted_smooth, BRUSH_SMOOTH_USE_AREA_WEIGHT)
DEF(flag2, preserve_faceset_boundary, BRUSH_SMOOTH_PRESERVE_FACE_SETS)
- DEF(flag2, hard_edge_mode, BRUSH_HARD_EDGE_MODE)
+ //DEF(flag2, hard_edge_mode, BRUSH_HARD_EDGE_MODE) don't convert, this only existed on temp_bmesh_multires
DEF(flag2, grab_silhouette, BRUSH_GRAB_SILHOUETTE)
DEF(flag, invert_to_scrape_fill, BRUSH_INVERT_TO_SCRAPE_FILL)
DEF(flag2, use_multiplane_scrape_dynamic, BRUSH_MULTIPLANE_SCRAPE_DYNAMIC)
@@ -1703,13 +1703,14 @@ void BKE_brush_builtin_create(Brush *brush, int tool)
break;
case SCULPT_TOOL_CREASE:
GETCH(direction)->ivalue = true;
- GETCH(strength)->fvalue = 0.25;
+ GETCH(strength)->fvalue = 0.25f;
+ GETCH(crease_pinch_factor)->fvalue = 0.5f;
break;
case SCULPT_TOOL_SCRAPE:
case SCULPT_TOOL_FILL:
GETCH(strength)->fvalue = 0.7f;
GETCH(area_radius_factor)->fvalue = 0.5f;
- GETCH(spacing)->fvalue = 7;
+ GETCH(spacing)->fvalue = 7.0f;
ADDCH(invert_to_scrape_fill);
GETCH(invert_to_scrape_fill)->ivalue = true;
GETCH(accumulate)->ivalue = true;
@@ -1805,6 +1806,11 @@ void BKE_brush_channelset_check_radius(BrushChannelSet *chset)
return;
}
+ if (ch1->fvalue == 0.0 || ch2->fvalue == 0.0) {
+ ch1->fvalue = 100.0f;
+ ch2->fvalue = 0.1f;
+ }
+
int mask = BRUSH_CHANNEL_INHERIT | BRUSH_CHANNEL_INHERIT_IF_UNSET |
/*BRUSH_CHANNEL_SHOW_IN_HEADER | BRUSH_CHANNEL_SHOW_IN_WORKSPACE |*/
BRUSH_CHANNEL_UI_EXPANDED;
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 636f60b22b5..a31e79a689b 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -1510,8 +1510,9 @@ static void layerDynTopoVert_copy(const void *source, void *dest, int count)
static void layerDynTopoVert_interp(
const void **sources, const float *weights, const float *sub_weights, int count, void *dest)
{
- float co[3], no[3], origmask, color[4];
+ float co[3], no[3], origmask, color[4], curv;
MSculptVert *mv = (MSculptVert *)dest;
+
// float totweight = 0.0f;
if (count == 0) {
@@ -1522,6 +1523,7 @@ static void layerDynTopoVert_interp(
zero_v3(co);
zero_v3(no);
origmask = 0.0f;
+ curv = 0.0f;
zero_v4(color);
for (int i = 0; i < count; i++) {
@@ -1538,7 +1540,8 @@ static void layerDynTopoVert_interp(
madd_v3_v3fl(co, mv2->origco, w);
madd_v3_v3fl(no, mv2->origno, w);
madd_v4_v4fl(color, mv2->origcolor, w);
- origmask += mv2->origmask * w;
+ origmask += (float)mv2->origmask * w;
+ curv += (float)mv2->curv * w;
// totweight += w;
}
@@ -1561,7 +1564,8 @@ static void layerDynTopoVert_interp(
copy_v3_v3(mv->origno, no);
copy_v4_v4(mv->origcolor, color);
- mv->origmask = origmask;
+ mv->curv = (short)curv;
+ mv->origmask = (short)origmask;
}
static void layerInterp_noop(const void **UNUSED(sources),
diff --git a/source/blender/blenkernel/intern/dyntopo.c b/source/blender/blenkernel/intern/dyntopo.c
index f8ca407cc76..e92f48e817b 100644
--- a/source/blender/blenkernel/intern/dyntopo.c
+++ b/source/blender/blenkernel/intern/dyntopo.c
@@ -35,6 +35,7 @@
#include <stdio.h>
//#define DYNTOPO_REPORT
+//#define WITH_ADAPTIVE_CURVATURE
#define SCULPTVERT_VALENCE_TEMP SCULPTVERT_SPLIT_TEMP
@@ -1422,8 +1423,10 @@ static void edge_queue_insert_val34_vert(EdgeQueueContext *eq_ctx, BMVert *v)
eq_ctx->val34_verts[eq_ctx->val34_verts_tot - 1] = v;
}
-BLI_INLINE float maskcb_get(EdgeQueueContext *eq_ctx, BMEdge *e)
+ATTR_NO_OPT static float maskcb_get(EdgeQueueContext *eq_ctx, BMEdge *e)
{
+ float ret = 0.0f;
+
if (eq_ctx->mask_cb) {
SculptVertRef sv1 = {(intptr_t)e->v1};
SculptVertRef sv2 = {(intptr_t)e->v2};
@@ -1431,13 +1434,16 @@ BLI_INLINE float maskcb_get(EdgeQueueContext *eq_ctx, BMEdge *e)
float w1 = eq_ctx->mask_cb(sv1, eq_ctx->mask_cb_data);
float w2 = eq_ctx->mask_cb(sv2, eq_ctx->mask_cb_data);
- return (w1 + w2) * 0.5f;
+ ret = (w1 + w2) * 0.5f;
+ }
+ else {
+ ret = 1.0f;
}
- return 1.0f;
+ return ret;
}
-BLI_INLINE float calc_weighted_edge_split(EdgeQueueContext *eq_ctx, BMVert *v1, BMVert *v2)
+ATTR_NO_OPT static float calc_weighted_edge_split(EdgeQueueContext *eq_ctx, BMVert *v1, BMVert *v2)
{
#ifdef FANCY_EDGE_WEIGHTS
float l = len_squared_v3v3(v1->co, v2->co);
@@ -1461,12 +1467,27 @@ BLI_INLINE float calc_weighted_edge_split(EdgeQueueContext *eq_ctx, BMVert *v1,
return l;
#else
+
+# ifdef WITH_ADAPTIVE_CURVATURE
+ MSculptVert *mv1 = BKE_PBVH_SCULPTVERT(eq_ctx->cd_sculpt_vert, v1);
+ MSculptVert *mv2 = BKE_PBVH_SCULPTVERT(eq_ctx->cd_sculpt_vert, v2);
+
+ float c1 = (float)mv1->curv / 65535.0f;
+ float c2 = (float)mv2->curv / 65535.0f;
+ float fac = 1.0f + powf((c1 + c2) * 100.0, 4.0f);
+ fac = min_ff(fac, 4.0f);
+
+ return fac * len_squared_v3v3(v1->co, v2->co);
+# else
return len_squared_v3v3(v1->co, v2->co);
+# endif
#endif
}
BLI_INLINE float calc_weighted_edge_collapse(EdgeQueueContext *eq_ctx, BMVert *v1, BMVert *v2)
{
+ return calc_weighted_edge_split(eq_ctx, v1, v2);
+
#ifdef FANCY_EDGE_WEIGHTS
float l = len_squared_v3v3(v1->co, v2->co);
// float val = (float)BM_vert_edge_count(v1) + (float)BM_vert_edge_count(v2);
@@ -1812,7 +1833,7 @@ static void long_edge_queue_edge_add(EdgeQueueContext *eq_ctx, BMEdge *e)
#endif
{
const float w = maskcb_get(eq_ctx, e);
- const float len_sq = BM_edge_calc_length_squared(e) * w * w;
+ const float len_sq = calc_weighted_edge_split(eq_ctx, e->v1, e->v2) * w * w;
if (len_sq > eq_ctx->q->limit_len_squared) {
edge_queue_insert(eq_ctx, e, -len_sq, eq_ctx->q->limit_len);
@@ -1855,7 +1876,8 @@ static void long_edge_queue_edge_add_recursive(EdgeQueueContext *eq_ctx,
do {
BMLoop *l_adjacent[2] = {l_iter->next, l_iter->prev};
for (int i = 0; i < (int)ARRAY_SIZE(l_adjacent); i++) {
- float len_sq_other = BM_edge_calc_length_squared(l_adjacent[i]->e);
+ float len_sq_other = calc_weighted_edge_split(
+ eq_ctx, l_adjacent[i]->e->v1, l_adjacent[i]->e->v2);
float w = maskcb_get(eq_ctx, l_adjacent[i]->e);
len_sq_other *= w * w;
@@ -1906,7 +1928,7 @@ static void long_edge_queue_face_add(EdgeQueueContext *eq_ctx, BMFace *f, bool i
BMLoop *l_iter = l_first;
do {
#ifdef USE_EDGEQUEUE_EVEN_SUBDIV
- float len_sq = BM_edge_calc_length_squared(l_iter->e);
+ float len_sq = calc_weighted_edge_split(eq_ctx, l_iter->e->v1, l_iter->e->v2);
float w = maskcb_get(eq_ctx, l_iter->e);
len_sq *= w * w;
@@ -2187,8 +2209,7 @@ static void long_edge_queue_task_cb(void *__restrict userdata,
#ifdef USE_EDGEQUEUE_EVEN_SUBDIV
float w = maskcb_get(eq_ctx, l_iter->e);
- float len_sq = BM_edge_calc_length_squared(l_iter->e);
-
+ float len_sq = calc_weighted_edge_split(eq_ctx, l_iter->e->v1, l_iter->e->v2);
len_sq *= w * w;
if (len_sq > eq_ctx->q->limit_len_squared) {
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index 3c7d89bb7bb..c34efdf08dc 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -817,6 +817,10 @@ void BKE_pbvh_bmesh_update_origvert(
BM_log_vert_before_modified(pbvh->bm_log, v, pbvh->cd_vert_mask_offset, r_color != NULL);
}
+ if (pbvh->cd_vert_mask_offset) {
+ mv->origmask = (short)(BM_ELEM_CD_GET_FLOAT(v, pbvh->cd_vert_mask_offset) * 65535.0f);
+ }
+
if (r_co || r_no) {
copy_v3_v3(mv->origco, v->co);
@@ -1489,16 +1493,20 @@ static int color_boundary_key(float col[4])
}
#endif
-void bke_pbvh_update_vert_boundary(int cd_sculpt_vert,
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list