Fix #34813: smooth brush used on a shape key messes up the topology - part2

This reverts rev55642 and fixes issue in a different way.

The thing here is: isolated vertices are for sure not in BVH
and updating keyblock could not only rely on idea that all
vertices are in BVH (no idea why it was noticed just now).

Solved in a way, that uses old keyblock coordinates as new
keyblock, and then refines it using coordinates from BVH.

Hopefully it'll cover all cases now :)
This commit is contained in:
Sergey Sharybin
2013-04-01 09:55:37 +00:00
parent 271a7a5554
commit e8d0e77856

View File

@@ -3220,24 +3220,23 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob)
PBVHNode **nodes;
float (*vertCos)[3] = NULL;
if (ss->kb)
if (ss->kb) {
vertCos = MEM_mallocN(sizeof(*vertCos) * me->totvert, "flushStrokeDeofrm keyVerts");
/* mesh could have isolated verts which wouldn't be in BVH,
* to deal with this we copy old coordinates over new ones
* and then update coordinates for all vertices from BVH
*/
memcpy(vertCos, ss->orig_cos, 3 * sizeof(float) * me->totvert);
}
BKE_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;
int mode = PBVH_ITER_UNIQUE;
/* when sculpting on a shape key, we need to gather all vertices, even
* hidden one, so key block update happens correct (otherwise we'll
* miss coordinates for hidden vertices)
*/
if (ss->kb)
mode = PBVH_ITER_ALL;
BKE_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, mode)
BKE_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE)
{
sculpt_flush_pbvhvert_deform(ob, &vd);