From b7269aa36e1e86dfa5142770e5f12c89f3898501 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 12 Apr 2011 10:16:00 +0000 Subject: 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) --- source/blender/editors/sculpt_paint/sculpt.c | 46 ++++++++++++++++++---------- 1 file changed, 29 insertions(+), 17 deletions(-) (limited to 'source') diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 9d9deeda604..1543cbedae9 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -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; - - if(!ss->kb) { + Brush *brush= paint_brush(&sd->paint); + + 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; } + BLI_pbvh_vertex_iter_end; + } - MEM_freeN(nodes); + 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) -- cgit v1.2.3