forked from bartvdbraak/blender
Fix #26879: Some sculpt brushes does not work when sculpting corrective shapekeys
It was simply missed crazyspace correction for shape keys when mesh is deformed by modifiers and current tool is smooth/layer (they need special approach due to they don't use proxies)
This commit is contained in:
parent
618690b05e
commit
b7269aa36e
@ -2492,38 +2492,50 @@ static void sculpt_update_keyblock(Object *ob)
|
||||
static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
Brush *brush= paint_brush(&sd->paint);
|
||||
|
||||
if(!ss->kb) {
|
||||
if(ELEM(brush->sculpt_tool, SCULPT_TOOL_SMOOTH, SCULPT_TOOL_LAYER)) {
|
||||
/* this brushes aren't using proxies, so sculpt_combine_proxies() wouldn't
|
||||
propagate needed deformation to original base */
|
||||
|
||||
int n, totnode;
|
||||
Mesh *me= (Mesh*)ob->data;
|
||||
Brush *brush= paint_brush(&sd->paint);
|
||||
PBVHNode** nodes;
|
||||
float (*vertCos)[3]= NULL;
|
||||
|
||||
if(ELEM(brush->sculpt_tool, SCULPT_TOOL_SMOOTH, SCULPT_TOOL_LAYER)) {
|
||||
/* this brushes aren't using proxies, so sculpt_combine_proxies() wouldn't
|
||||
propagate needed deformation to original base */
|
||||
if(ss->kb)
|
||||
vertCos= MEM_callocN(sizeof(*vertCos)*me->totvert, "flushStrokeDeofrm keyVerts");
|
||||
|
||||
int n, totnode;
|
||||
PBVHNode** nodes;
|
||||
BLI_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode);
|
||||
|
||||
BLI_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode);
|
||||
#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
|
||||
for (n= 0; n < totnode; n++) {
|
||||
PBVHVertexIter vd;
|
||||
|
||||
#pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
|
||||
for (n= 0; n < totnode; n++) {
|
||||
PBVHVertexIter vd;
|
||||
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
|
||||
sculpt_flush_pbvhvert_deform(ob, &vd);
|
||||
|
||||
BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
|
||||
sculpt_flush_pbvhvert_deform(ob, &vd);
|
||||
if(vertCos) {
|
||||
int index= vd.vert_indices[vd.i];
|
||||
copy_v3_v3(vertCos[index], ss->orig_cos[index]);
|
||||
}
|
||||
BLI_pbvh_vertex_iter_end;
|
||||
}
|
||||
|
||||
MEM_freeN(nodes);
|
||||
BLI_pbvh_vertex_iter_end;
|
||||
}
|
||||
|
||||
if(vertCos) {
|
||||
sculpt_vertcos_to_key(ob, ss->kb, vertCos);
|
||||
MEM_freeN(vertCos);
|
||||
}
|
||||
|
||||
MEM_freeN(nodes);
|
||||
|
||||
/* Modifiers could depend on mesh normals, so we should update them/
|
||||
Note, then if sculpting happens on locked key, normals should be re-calculated
|
||||
after applying coords from keyblock on base mesh */
|
||||
mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL);
|
||||
} else sculpt_update_keyblock(ob);
|
||||
} else if (ss->kb)
|
||||
sculpt_update_keyblock(ob);
|
||||
}
|
||||
|
||||
//static int max_overlap_count(Sculpt *sd)
|
||||
|
Loading…
Reference in New Issue
Block a user