diff options
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 10 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/cdderivedmesh.c | 11 |
2 files changed, 19 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 4ccec3893e8..ec8d37e1ae3 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1340,6 +1340,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0); int has_multires = mmd != NULL, multires_applied = 0; int sculpt_mode = ob->mode & OB_MODE_SCULPT && ob->sculpt; + int sculpt_dyntopo = (sculpt_mode && ob->sculpt->bm); const int draw_flag = ((scene->toolsettings->multipaint ? CALC_WP_MULTIPAINT : 0) | (scene->toolsettings->auto_normalize ? CALC_WP_AUTO_NORMALIZE : 0)); @@ -1407,7 +1408,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos if (!modifier_isEnabled(scene, md, required_mode)) continue; if (useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) continue; - if (mti->type == eModifierTypeType_OnlyDeform) { + if (mti->type == eModifierTypeType_OnlyDeform && !sculpt_dyntopo) { if (!deformedVerts) deformedVerts = mesh_getVertexCos(me, &numVerts); @@ -1465,9 +1466,14 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos modifier_setError(md, "Modifier requires original data, bad stack position"); continue; } - if (sculpt_mode && (!has_multires || multires_applied)) { + if (sculpt_mode && + (!has_multires || multires_applied || ob->sculpt->bm)) + { int unsupported = 0; + if (sculpt_dyntopo) + unsupported = TRUE; + if (scene->toolsettings->sculpt->flags & SCULPT_ONLY_DEFORM) unsupported |= mti->type != eModifierTypeType_OnlyDeform; diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 61d0936d41d..080e5fd857c 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -262,6 +262,17 @@ static PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) cddm->pbvh_draw = can_pbvh_draw(ob, dm); } + /* Sculpting on a BMesh (dynamic-topology) gets a special PBVH */ + if (!cddm->pbvh && ob->sculpt->bm) { + cddm->pbvh = BLI_pbvh_new(); + cddm->pbvh_draw = TRUE; + + BLI_pbvh_build_bmesh(cddm->pbvh, ob->sculpt->bm, + ob->sculpt->bm_smooth_shading, + ob->sculpt->bm_log); + } + + /* always build pbvh from original mesh, and only use it for drawing if * this derivedmesh is just original mesh. it's the multires subsurf dm * that this is actually for, to support a pbvh on a modified mesh */ |