[Bf-blender-cvs] [673e1fbac5c] sculpt-dev: Sculpt: smothing ops now slide UVs
Joseph Eagar
noreply at git.blender.org
Fri Oct 15 22:43:01 CEST 2021
Commit: 673e1fbac5cb7136a516f1124725fc52b4658f1c
Author: Joseph Eagar
Date: Fri Oct 15 13:40:02 2021 -0700
Branches: sculpt-dev
https://developer.blender.org/rB673e1fbac5cb7136a516f1124725fc52b4658f1c
Sculpt: smothing ops now slide UVs
* Wrote a new function, SCULPT_reproject_cdata,
to reproject loop customdata after smoothing.
* SCULPT_reproject_cdata is only called if UV
layers exist.
* All of the smoothing tools (hopefully all)
use it.
* This change is necassary to properly support vector
displacement maps in the future; otherwise DynTopo
will introduce lots of noise into the uv tangent
space.
===================================================================
M release/scripts/startup/bl_ui/space_view3d_toolbar.py
M source/blender/blenkernel/BKE_brush_engine.h
M source/blender/blenkernel/BKE_paint.h
M source/blender/blenkernel/intern/brush.c
M 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/blenkernel/intern/dyntopo.c
M source/blender/blenkernel/intern/paint.c
M source/blender/blenkernel/intern/scene.c
M source/blender/editors/sculpt_paint/sculpt.c
M source/blender/editors/sculpt_paint/sculpt_dyntopo.c
M source/blender/editors/sculpt_paint/sculpt_face_set.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
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 86fbbda83db..579ba19f9df 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -1285,6 +1285,12 @@ class VIEW3D_PT_sculpt_options(Panel, View3DPaintPanel):
"show_origco",
toolsettings_only=True, ui_editing=False)
+ UnifiedPaintPanel.channel_unified(layout.column(),
+ context,
+ brush,
+ "save_temp_layers",
+ toolsettings_only=True, ui_editing=False)
+
col.separator()
col.operator("sculpt.set_limit_surface")
diff --git a/source/blender/blenkernel/BKE_brush_engine.h b/source/blender/blenkernel/BKE_brush_engine.h
index 3eeac12863d..9c63450e960 100644
--- a/source/blender/blenkernel/BKE_brush_engine.h
+++ b/source/blender/blenkernel/BKE_brush_engine.h
@@ -191,7 +191,7 @@ void BKE_brush_channel_free(BrushChannel *ch);
void BKE_brush_channel_copy_data(BrushChannel *dst, BrushChannel *src, bool keep_mappings);
void BKE_brush_channel_init(BrushChannel *ch, BrushChannelType *def);
-BrushChannelSet *BKE_brush_channelset_create();
+BrushChannelSet *BKE_brush_channelset_create(const char *info);
#ifdef DEBUG_CURVE_MAPPING_ALLOC
BrushChannelSet *_BKE_brush_channelset_copy(BrushChannelSet *src);
# define BKE_brush_channelset_copy(src) \
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 97f52d70779..c09ce15f6ab 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -818,6 +818,8 @@ typedef struct SculptSession {
*/
struct SculptCustomLayer **layers_to_free;
int tot_layers_to_free;
+
+ bool save_temp_layers;
} SculptSession;
void BKE_sculptsession_free(struct Object *ob);
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index ee1b3c24620..579b101cfe0 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -64,7 +64,7 @@ static void brush_init_data(ID *id)
MEMCPY_STRUCT_AFTER(brush, DNA_struct_default_get(Brush), id);
- brush->channels = BKE_brush_channelset_create();
+ brush->channels = BKE_brush_channelset_create(NULL);
/* enable fake user by default */
id_fake_user_set(&brush->id);
diff --git a/source/blender/blenkernel/intern/brush_channel_define.h b/source/blender/blenkernel/intern/brush_channel_define.h
index 992fcd5f93d..d66a6f403b3 100644
--- a/source/blender/blenkernel/intern/brush_channel_define.h
+++ b/source/blender/blenkernel/intern/brush_channel_define.h
@@ -278,6 +278,7 @@ places in rna_engine_codebase are relevent:
MAKE_FLOAT(tip_roundness, "Tip Roundness", "", 1.0f, 0.0f, 1.0f)
MAKE_BOOL(accumulate, "Accumulate", "", false)
MAKE_BOOL_EX(show_origco, "Show OrigCo", "", false, BRUSH_CHANNEL_INHERIT)
+ MAKE_BOOL_EX(save_temp_layers, "Save Temp Layers", "Developer option; save temporary vertex attributes", false, BRUSH_CHANNEL_INHERIT)
MAKE_ENUM(direction, "Direction", "", 0, {\
{0, "ADD", "ADD", "Add", "Add effect of brush"},
{1, "SUBTRACT", "REMOVE", "Subtract", "Subtract effect of brush"},
diff --git a/source/blender/blenkernel/intern/brush_engine.c b/source/blender/blenkernel/intern/brush_engine.c
index 5c47e21f0ce..fec5b0b33f0 100644
--- a/source/blender/blenkernel/intern/brush_engine.c
+++ b/source/blender/blenkernel/intern/brush_engine.c
@@ -478,12 +478,30 @@ float BKE_brush_channel_curve_evaluate(BrushChannel *ch, float val, const float
return BKE_brush_curve_strength_ex(ch->curve.preset, ch->curve.curve, val, maxval);
}
-BrushChannelSet *BKE_brush_channelset_create()
+BrushChannelSet *BKE_brush_channelset_create(const char *info)
{
+ static char *tags[512] = {0};
+
+ char buf[512] = "BrushChannelSet", *tag;
+
+ if (info) {
+ strcat(buf, " ");
+ strcat(buf, info);
+
+ for (int i = 0; i < ARRAY_SIZE(tags); i++) {
+ if (tags[i] && STREQ(tags[i], buf)) {
+ tag = tags[i];
+ }
+ else if (!tags[i]) {
+ tags[i] = tag = strdup(buf);
+ }
+ }
+ }
+
BrushChannelSet *chset = (BrushChannelSet *)MEM_callocN(sizeof(BrushChannelSet),
- "BrushChannelSet");
+ info ? tag : "BrushChannelSet");
- chset->namemap = BLI_ghash_str_new("BrushChannelSet");
+ chset->namemap = BLI_ghash_str_new("BrushChannelSet ghash");
return chset;
}
@@ -807,7 +825,7 @@ BrushChannelSet *_BKE_brush_channelset_copy(BrushChannelSet *src)
BrushChannelSet *BKE_brush_channelset_copy(BrushChannelSet *src)
#endif
{
- BrushChannelSet *chset = BKE_brush_channelset_create();
+ BrushChannelSet *chset = BKE_brush_channelset_create(NULL);
if (!src->totchannel) {
return chset;
@@ -871,7 +889,7 @@ void BKE_brush_commandlist_start(BrushCommandList *list,
if (cmd->params_final) {
BKE_brush_channelset_free(cmd->params_final);
}
- cmd->params_final = BKE_brush_channelset_create();
+ cmd->params_final = BKE_brush_channelset_create("params_final");
BKE_brush_channelset_merge(cmd->params_final, cmd->params, chset_final);
@@ -889,7 +907,7 @@ void BKE_brush_resolve_channels(Brush *brush, Sculpt *sd)
BKE_brush_channelset_free(brush->channels_final);
}
- brush->channels_final = BKE_brush_channelset_create();
+ brush->channels_final = BKE_brush_channelset_create("channels_final");
BKE_brush_channelset_merge(brush->channels_final, brush->channels, sd->channels);
}
@@ -1346,7 +1364,7 @@ BrushCommand *BKE_brush_commandlist_add(BrushCommandList *cl,
}
}
else {
- cmd->params = BKE_brush_channelset_create();
+ cmd->params = BKE_brush_channelset_create("params");
}
cmd->params_final = NULL;
@@ -1886,7 +1904,7 @@ BrushTex *BKE_brush_tex_create()
{
BrushTex *bt = MEM_callocN(sizeof(BrushTex), "BrushTex");
- bt->channels = BKE_brush_channelset_create();
+ bt->channels = BKE_brush_channelset_create("brush tex");
return bt;
}
diff --git a/source/blender/blenkernel/intern/brush_engine_presets.c b/source/blender/blenkernel/intern/brush_engine_presets.c
index d5d356c29d4..ee54f93956e 100644
--- a/source/blender/blenkernel/intern/brush_engine_presets.c
+++ b/source/blender/blenkernel/intern/brush_engine_presets.c
@@ -993,7 +993,7 @@ void BKE_brush_builtin_patch(Brush *brush, int tool)
bool setup_ui = !brush->channels || !brush->channels->totchannel;
if (!brush->channels) {
- brush->channels = BKE_brush_channelset_create();
+ brush->channels = BKE_brush_channelset_create("brush");
}
BrushChannelSet *chset = brush->channels;
@@ -1009,6 +1009,7 @@ void BKE_brush_builtin_patch(Brush *brush, int tool)
ADDCH(sharp_mode);
ADDCH(show_origco);
+ ADDCH(save_temp_layers);
ADDCH(use_surface_falloff);
@@ -1522,13 +1523,13 @@ void BKE_brush_builtin_create(Brush *brush, int tool)
namestack_push(__func__);
if (!brush->channels) {
- brush->channels = BKE_brush_channelset_create();
+ brush->channels = BKE_brush_channelset_create("brush 2");
}
if (brush->channels) {
// forcibly reset all non-user-defined channels for this brush
- BrushChannelSet *chset = BKE_brush_channelset_create();
+ BrushChannelSet *chset = BKE_brush_channelset_create("brush 3");
Brush tmp = *brush;
tmp.channels = chset;
@@ -1542,6 +1543,8 @@ void BKE_brush_builtin_create(Brush *brush, int tool)
BKE_brush_channel_copy_data(ch, ch2, false);
}
}
+
+ BKE_brush_channelset_free(chset);
}
BrushChannelSet *chset = brush->channels;
@@ -1851,6 +1854,7 @@ void BKE_brush_check_toolsettings(Sculpt *sd)
ADDCH(unprojected_radius);
ADDCH(show_origco);
+ ADDCH(save_temp_layers);
ADDCH(smooth_strength_factor);
ADDCH(smooth_strength_projection);
diff --git a/source/blender/blenkernel/intern/dyntopo.c b/source/blender/blenkernel/intern/dyntopo.c
index 28ce2010127..1cf930cca37 100644
--- a/source/blender/blenkernel/intern/dyntopo.c
+++ b/source/blender/blenkernel/intern/dyntopo.c
@@ -4678,10 +4678,15 @@ bool BKE_pbvh_bmesh_update_topology(PBVH *pbvh,
int custom_max_steps,
bool disable_surface_relax)
{
+ /* disable surface smooth if uv layers are present, to avoid expensive reprojection operation */
+ if (CustomData_has_layer(&pbvh->bm->ldata, CD_MLOOPUV)) {
+ disable_surface_relax = true;
+ }
/* 2 is enough for edge faces - manifold edge */
BLI_buffer_declare_static(BMLoop *, edge_loops, BLI_BUFFER_NOP, 2);
BLI_buffer_declare_static(BMFace *, deleted_faces, BLI_BUFFER_NOP, 32);
+
const int cd_vert_mask_offset = CustomData_get_offset(&pbvh->bm->vdata, CD_PAINT_MASK);
const int cd_vert_node_offset = pbvh->cd_vert_node_offset;
const int cd_face_node_offset = pbvh->cd_face_node_offset;
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 615176b39f1..f987c70c989 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -1700,6 +1700,9 @@ static void sculpt_update_object(Depsgraph *depsgraph,
ss->building_vp_handle = false;
ss->scene = scene;
+ if (sd->channels) {
+ ss->save_temp_layers = BRUSHSET_GET_INT(sd->channels, save_temp_layers, NULL);
+ }
if (need_mask) {
if (mmd == NULL) {
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index fa7913904e1..8557abfd682 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -1073,7 +1073,7 @@ static void scene_blend_read_data(BlendDataReader *reader, ID *id)
BKE_brush_channelset_read(reader, sce->toolsettings->sculpt->channels);
}
else if (sce->toolsettings->sculpt) {
- sce->toolsettings->sculpt->channels = BKE_brush_channelset_create();
+ sce->toolsettings->sculpt->channels = BKE_brush_channelset_create("sculpt toolsettings");
}
if (sce->toolset
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list