Fix (unreported) missing feature in ccgdm pbvh generator.
authorBastien Montagne <montagne29@wanadoo.fr>
Wed, 24 Jan 2018 10:17:53 +0000 (11:17 +0100)
committerBastien Montagne <montagne29@wanadoo.fr>
Wed, 24 Jan 2018 10:22:35 +0000 (11:22 +0100)
Compared to usual cddm one, ccgdm one was not applying the
ob->derivedDeform deformation to the pbvh generated from the
original mesh geometry, when possible.

source/blender/blenkernel/intern/subsurf_ccg.c

index 624a8975f5ea87c873c5d57609e08caa5d25fa26..84b97f2812a0e14a711bdf53277d18936081c380 100644 (file)
@@ -4561,6 +4561,18 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm)
                ob->sculpt->pbvh = ccgdm->pbvh = BKE_pbvh_new();
                BKE_pbvh_build_mesh(ccgdm->pbvh, me->mpoly, me->mloop, me->mvert, me->totvert, &me->vdata,
                                    looptri, looptris_num);
+
+               if (ob->sculpt->modifiers_active && ob->derivedDeform != NULL) {
+                       DerivedMesh *deformdm = ob->derivedDeform;
+                       float (*vertCos)[3];
+                       int totvert;
+
+                       totvert = deformdm->getNumVerts(deformdm);
+                       vertCos = MEM_malloc_arrayN(totvert, sizeof(float[3]), "ccgDM_getPBVH vertCos");
+                       deformdm->getVertCos(deformdm, vertCos);
+                       BKE_pbvh_apply_vertCos(ccgdm->pbvh, vertCos);
+                       MEM_freeN(vertCos);
+               }
        }
 
        if (ccgdm->pbvh != NULL) {