forked from bartvdbraak/blender
Update DerivedMesh for dynamic-topology sculpt mode
* Build bmesh PBVH in CDDM when dyntopo is enabled * Disable all modifiers when dyntopo is enabled
This commit is contained in:
parent
ae9d6e0813
commit
bbaeac3bf8
@ -1340,6 +1340,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos
|
|||||||
MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0);
|
MultiresModifierData *mmd = get_multires_modifier(scene, ob, 0);
|
||||||
int has_multires = mmd != NULL, multires_applied = 0;
|
int has_multires = mmd != NULL, multires_applied = 0;
|
||||||
int sculpt_mode = ob->mode & OB_MODE_SCULPT && ob->sculpt;
|
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) |
|
const int draw_flag = ((scene->toolsettings->multipaint ? CALC_WP_MULTIPAINT : 0) |
|
||||||
(scene->toolsettings->auto_normalize ? CALC_WP_AUTO_NORMALIZE : 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 (!modifier_isEnabled(scene, md, required_mode)) continue;
|
||||||
if (useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) continue;
|
if (useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) continue;
|
||||||
|
|
||||||
if (mti->type == eModifierTypeType_OnlyDeform) {
|
if (mti->type == eModifierTypeType_OnlyDeform && !sculpt_dyntopo) {
|
||||||
if (!deformedVerts)
|
if (!deformedVerts)
|
||||||
deformedVerts = mesh_getVertexCos(me, &numVerts);
|
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");
|
modifier_setError(md, "Modifier requires original data, bad stack position");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (sculpt_mode && (!has_multires || multires_applied)) {
|
if (sculpt_mode &&
|
||||||
|
(!has_multires || multires_applied || ob->sculpt->bm))
|
||||||
|
{
|
||||||
int unsupported = 0;
|
int unsupported = 0;
|
||||||
|
|
||||||
|
if (sculpt_dyntopo)
|
||||||
|
unsupported = TRUE;
|
||||||
|
|
||||||
if (scene->toolsettings->sculpt->flags & SCULPT_ONLY_DEFORM)
|
if (scene->toolsettings->sculpt->flags & SCULPT_ONLY_DEFORM)
|
||||||
unsupported |= mti->type != eModifierTypeType_OnlyDeform;
|
unsupported |= mti->type != eModifierTypeType_OnlyDeform;
|
||||||
|
|
||||||
|
@ -262,6 +262,17 @@ static PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm)
|
|||||||
cddm->pbvh_draw = can_pbvh_draw(ob, 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
|
/* 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
|
* 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 */
|
* that this is actually for, to support a pbvh on a modified mesh */
|
||||||
|
Loading…
Reference in New Issue
Block a user