Sculpt-dev: Dyntopo Tweaks

* Increased substep count.
* Snake hook now runs dyntopo twice by
  inserting it into its commandlist twice,
  instead of running over the same nodes and
  re-executing it.
This commit is contained in:
Joseph Eagar 2022-03-12 12:21:17 -08:00
parent 54a3c7525b
commit 8b719fee19
4 changed files with 42 additions and 49 deletions

View File

@ -1196,8 +1196,8 @@ void BKE_brush_channel_apply_mapping_flags(BrushChannel *dst,
{
for (int i = 0; i < BRUSH_MAPPING_MAX; i++) {
BrushMapping *mp = dst->mappings + i;
BrushMapping *cmp = child ? child->mappings + i : NULL;
BrushMapping *pmp = parent ? parent->mappings + i : NULL;
const BrushMapping *cmp = child ? child->mappings + i : NULL;
const BrushMapping *pmp = parent ? parent->mappings + i : NULL;
if (!cmp) {
if (pmp) {
@ -1290,9 +1290,9 @@ void BKE_brush_channelset_set_final_int(BrushChannelSet *child,
}
float old_BKE_brush_channelset_get_final_float(BrushChannelSet *child,
BrushChannelSet *parent,
const char *idname,
BrushMappingData *mapdata)
BrushChannelSet *parent,
const char *idname,
BrushMappingData *mapdata)
{
BrushChannel *parentch, *childch;
BrushChannel *ch = brush_channel_final(child, parent, idname, &childch, &parentch);
@ -1389,10 +1389,10 @@ int BKE_brush_channel_get_vector(BrushChannel *ch, float out[4], BrushMappingDat
}
int old_BKE_brush_channelset_get_final_vector(BrushChannelSet *child,
BrushChannelSet *parent,
const char *idname,
float r_vec[4],
BrushMappingData *mapdata)
BrushChannelSet *parent,
const char *idname,
float r_vec[4],
BrushMappingData *mapdata)
{
BrushChannel *parentch, *childch;
BrushChannel *ch = brush_channel_final(child, parent, idname, &childch, &parentch);
@ -1851,8 +1851,15 @@ void BKE_builtin_commandlist_create(Brush *brush,
float radius = BKE_brush_channelset_get_float(chset, "radius", NULL);
/* build dyntopo command */
commandlist_add_dyntopo(chset, cl, brush, tool, hard_edge_mode, radius);
/* Build dyntopo command. */
if (tool == SCULPT_TOOL_SNAKE_HOOK) {
/* Add twice for snake hook. */
commandlist_add_dyntopo(chset, cl, brush, tool, hard_edge_mode, radius*1.25);
commandlist_add_dyntopo(chset, cl, brush, tool, hard_edge_mode, radius * 1.25);
}
else {
commandlist_add_dyntopo(chset, cl, brush, tool, hard_edge_mode, radius);
}
/* build main brush command */
cmd = BKE_brush_commandlist_add(cl, chset, true);

View File

@ -4517,14 +4517,14 @@ ATTR_NO_OPT bool BKE_pbvh_bmesh_update_topology(PBVH *pbvh,
int steps[2] = {0, 0};
if ((mode & PBVH_Subdivide) && (mode & PBVH_Collapse)) {
steps[0] = 1024;
steps[1] = 128;
steps[0] = 4096;
steps[1] = 1024;
}
else if (mode & PBVH_Subdivide) {
steps[0] = 2048;
steps[0] = 4096;
}
else if (mode & PBVH_Collapse) {
steps[0] = 2048;
steps[0] = 4096;
}
int edges_size = steps[0];
@ -4608,7 +4608,7 @@ ATTR_NO_OPT bool BKE_pbvh_bmesh_update_topology(PBVH *pbvh,
} while ((l = l->radial_next) != e->l);
}
//edges[etot++] = e;
// edges[etot++] = e;
break;
}
case PBVH_Collapse: {

View File

@ -2572,11 +2572,6 @@ ATTR_NO_OPT bool BKE_pbvh_bmesh_update_topology_nodes(PBVH *pbvh,
bool modified = false;
PBVHNode **nodes = NULL;
BLI_array_declare(nodes);
int steps = is_snake_hook ? 1 : 1;
if (is_snake_hook) {
//radius *= 1.25;
}
for (int i = 0; i < pbvh->totnode; i++) {
PBVHNode *node = pbvh->nodes + i;
@ -2592,34 +2587,26 @@ ATTR_NO_OPT bool BKE_pbvh_bmesh_update_topology_nodes(PBVH *pbvh,
}
}
for (int i = 0; i < steps; i++) {
for (int j = 0; j < BLI_array_len(nodes); j++) {
nodes[j]->flag |= PBVH_UpdateCurvatureDir;
BKE_pbvh_node_mark_topology_update(nodes[j]);
}
bool modified2 = BKE_pbvh_bmesh_update_topology(pbvh,
mode,
center,
view_normal,
radius,
use_frontface,
use_projected,
sym_axis,
updatePBVH && i == steps - 1,
mask_cb,
mask_cb_data,
is_snake_hook ? 40960 : 0,
disable_surface_relax,
is_snake_hook);
if (!modified2) {
break;
}
modified = true;
for (int j = 0; j < BLI_array_len(nodes); j++) {
nodes[j]->flag |= PBVH_UpdateCurvatureDir;
BKE_pbvh_node_mark_topology_update(nodes[j]);
}
modified = BKE_pbvh_bmesh_update_topology(pbvh,
mode,
center,
view_normal,
radius,
use_frontface,
use_projected,
sym_axis,
updatePBVH,
mask_cb,
mask_cb_data,
0, //is_snake_hook ? 40960 : 0,
disable_surface_relax,
is_snake_hook);
BLI_array_free(nodes);
return modified;

View File

@ -96,7 +96,7 @@ static void workbench_cache_sculpt_populate(WORKBENCH_PrivateData *wpd,
color_type, V3D_SHADING_MATERIAL_COLOR, V3D_SHADING_TEXTURE_COLOR);
if (use_single_drawcall) {
DRWShadingGroup *grp = workbench_material_setup(wpd, ob, 0, color_type, NULL);
DRWShadingGroup *grp = workbench_material_setup(wpd, ob, ob->actcol, color_type, NULL);
DRW_shgroup_call_sculpt(grp, ob, false, false);
}
else {
@ -254,7 +254,6 @@ static eV3DShadingColorType workbench_color_type_get(WORKBENCH_PrivateData *wpd,
eV3DShadingColorType color_type = wpd->shading.color_type;
const Mesh *me = (ob->type == OB_MESH) ? ob->data : NULL;
const CustomData *ldata = (me == NULL) ? NULL : workbench_mesh_get_loop_custom_data(me);
const CustomData *vdata = (me == NULL) ? NULL : workbench_mesh_get_vert_custom_data(me);
const DRWContextState *draw_ctx = DRW_context_state_get();
const bool is_active = (ob == draw_ctx->obact);