Sculpt-dev: fix elastic deform brush

* Volume preservation had wrong bounds in
  elastic deform brush leading to wrong
  behavior.
* Fixed unprojected_radius channel not
  being shown in header when scene radius
  unit is on.
* Draw face sets now only fully rebuild draw buffers
  in indexed draw modes that require it.
This commit is contained in:
Joseph Eagar 2021-12-02 16:37:31 -08:00
parent 61e2d15bfe
commit e4b6180c4e
6 changed files with 33 additions and 11 deletions

View File

@ -261,19 +261,26 @@ class _draw_tool_settings_context_mode:
"accumulate" : ["Accu..", 2.5] #needs an icon
}
scene_radius = UnifiedPaintPanel.get_channel_value(context, brush, "radius_unit") == "SCENE"
for ch in brush.channels:
show_in_header = ch.show_in_header
if ch.idname == "radius" and scene_radius:
ch = brush.channels["unprojected_radius"]
final_ch = ch
if ch.inherit:
sculpt.channels.ensure(ch)
final_ch = sculpt.channels[ch.idname]
row = row1.row(align=False).row(align=True)
row.use_property_split = False
row.use_property_decorate = False
layoutuse_property_split = False
if show_in_header:
row = row1.row(align=False).row(align=True)
row.use_property_split = False
row.use_property_decorate = False
layoutuse_property_split = False
if ch.show_in_header:
text = ch.name if ch.type in ["BOOL", "FLOAT", "INT"] else ""
if final_ch.type in ["VEC3", "VEC4"]:

View File

@ -528,6 +528,10 @@ void BKE_pbvh_bmesh_update_all_valence(PBVH *pbvh);
void BKE_pbvh_bmesh_flag_all_disk_sort(PBVH *pbvh);
bool BKE_pbvh_bmesh_mark_update_valence(PBVH *pbvh, SculptVertRef vertex);
/* if pbvh uses a split index buffer, will call BKE_pbvh_node_mark_update_triangulation;
otherwise does nothing. returns true if BKE_pbvh_node_mark_update_triangulation was
called.*/
bool BKE_pbvh_node_mark_update_index_buffer(PBVH *pbvh, PBVHNode *node);
void BKE_pbvh_node_mark_update_triangulation(PBVHNode *node);
void BKE_pbvh_node_mark_original_update(PBVHNode *node);
void BKE_pbvh_node_mark_update_tri_area(PBVHNode *node);

View File

@ -508,7 +508,7 @@ MAKE_ENUM(blend,"Blending Mode","Brush blending mode",IMB_BLEND_MIX,{\
"Smooth iterations applied after calculating the pose factor of each vertex",4,0.0f,100.0f)
MAKE_INT(pose_ik_segments,"Pose IK Segments",
"Number of segments of the inverse kinematics chain that will deform the mesh",1,1,20)
MAKE_FLOAT(surface_smooth_shape_preservation,"Shape Preservation","How much of the original shape is preserved when smoothing",0.5f,0.0f,1.0f)
MAKE_FLOAT(surface_smooth_shape_preservation,"Shape Preservation","How much of the original shape is preserved when smoothing", 0.5f,0.0f,1.0f)
MAKE_FLOAT(surface_smooth_current_vertex,"Per Vertex Displacement",
"How much the position of each individual vertex influences the final result",0.5f,0.0f,1.0f)
MAKE_INT(surface_smooth_iterations,"Iterations","Number of smoothing iterations per brush step",4,1,10)
@ -591,7 +591,7 @@ MAKE_ENUM(blend,"Blending Mode","Brush blending mode",IMB_BLEND_MIX,{\
})
MAKE_FLOAT(elastic_deform_volume_preservation,"Volume Preservation",
"Poisson ratio for elastic deformation. Higher values preserve volume "
"more, but also lead to more bulging",0.0f,0.9f,false)
"more, but also lead to more bulging", 0.0f, 0.0f, 0.9f)
MAKE_BOOL(use_ctrl_invert,"Use Ctrl Invert","Take brush addition or subtraction mode into account",true)

View File

@ -2010,7 +2010,7 @@ void BKE_sculpt_update_object_before_eval(Object *ob)
/* In vertex/weight paint, force maps to be rebuilt. */
BKE_sculptsession_free_vwpaint_data(ob->sculpt);
}
else {
else if (ss->pbvh) {
PBVHNode **nodes;
int n, totnode;
@ -2020,7 +2020,7 @@ void BKE_sculpt_update_object_before_eval(Object *ob)
BKE_pbvh_node_mark_update(nodes[n]);
}
MEM_freeN(nodes);
MEM_SAFE_FREE(nodes);
}
}
}

View File

@ -4238,6 +4238,17 @@ PBVHNode *BKE_pbvh_get_node(PBVH *pbvh, int node)
return pbvh->nodes + node;
}
bool BKE_pbvh_node_mark_update_index_buffer(PBVH *pbvh, PBVHNode *node)
{
bool split_indexed = pbvh->bm && (pbvh->flags & (PBVH_DYNTOPO_SMOOTH_SHADING | PBVH_FAST_DRAW));
if (split_indexed) {
BKE_pbvh_node_mark_update_triangulation(node);
}
return split_indexed;
}
void BKE_pbvh_node_mark_update_triangulation(PBVHNode *node)
{
node->flag |= PBVH_UpdateTris;

View File

@ -633,7 +633,7 @@ void do_draw_face_sets_brush_task_cb_ex(void *__restrict userdata,
BKE_pbvh_vertex_iter_end;
if (modified) {
BKE_pbvh_node_mark_update_triangulation(data->nodes[n]);
BKE_pbvh_node_mark_update_index_buffer(ss->pbvh, data->nodes[n]);
}
// restore automasking flag