From 425da6206f75b9218cf4123ac1b9cdeaf7f86bb1 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 21 Jun 2010 20:10:59 +0000 Subject: [#22262] Sculpting shape keys using the Smooth brush switches the shape to the Basis PBVH used the same verts array as mesh data and shape key/reference key coords were applying on the mesh data, so on some refreshing undeformed mesh was displayed. Added utility functions to get vert coords from key block, apply new vert coords on keyblock and function to apply coords on bpvh, so now pbvh uses it's ovn vertex array and no changes are making to the mesh data. Additional change: Store key block name in SculptUndoNode, so now shape wouldn't be copied to wrong keyblock on undo --- source/blender/blenkernel/intern/cdderivedmesh.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern/cdderivedmesh.c') diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 80f39531b34..9612dac2ac4 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -186,6 +186,16 @@ static ListBase *cdDM_getFaceMap(Object *ob, DerivedMesh *dm) return cddm->fmap; } +static int can_pbvh_draw(Object *ob, DerivedMesh *dm) +{ + CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + Mesh *me= (ob)? ob->data: NULL; + + if(ob->sculpt->modifiers_active) return 0; + + return (cddm->mvert == me->mvert) || ob->sculpt->kb; +} + static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) { CDDerivedMesh *cddm = (CDDerivedMesh*) dm; @@ -200,7 +210,7 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) return NULL; if(ob->sculpt->pbvh) { cddm->pbvh= ob->sculpt->pbvh; - cddm->pbvh_draw = (cddm->mvert == me->mvert) || ob->sculpt->kb; + cddm->pbvh_draw = can_pbvh_draw(ob, dm); } /* always build pbvh from original mesh, and only use it for drawing if @@ -208,7 +218,7 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) that this is actually for, to support a pbvh on a modified mesh */ if(!cddm->pbvh && ob->type == OB_MESH) { cddm->pbvh = BLI_pbvh_new(); - cddm->pbvh_draw = (cddm->mvert == me->mvert) || ob->sculpt->kb; + cddm->pbvh_draw = can_pbvh_draw(ob, dm); BLI_pbvh_build_mesh(cddm->pbvh, me->mface, me->mvert, me->totface, me->totvert); } -- cgit v1.2.3