diff options
Diffstat (limited to 'source/blender/editors/object/object_modifier.c')
-rw-r--r-- | source/blender/editors/object/object_modifier.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 917210390b1..43cd65c55cd 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -2281,17 +2281,43 @@ static int laplaciandeform_poll(bContext *C) static int laplaciandeform_bind_exec(bContext *C, wmOperator *op) { + Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); + Depsgraph *depsgraph = CTX_data_depsgraph(C); LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)edit_modifier_property_get(op, ob, eModifierType_LaplacianDeform); if (!lmd) return OPERATOR_CANCELLED; if (lmd->flag & MOD_LAPLACIANDEFORM_BIND) { + /* Un-binding happens inside the modifier when it's evaluated. */ lmd->flag &= ~MOD_LAPLACIANDEFORM_BIND; } else { + DerivedMesh *dm; + int mode = lmd->modifier.mode; + + /* Force modifier to run, it will call binding routine. */ + /* TODO(Sybren): deduplicate the code below, it's used multiple times here. */ + lmd->modifier.mode |= eModifierMode_Realtime; lmd->flag |= MOD_LAPLACIANDEFORM_BIND; + + if (ob->type == OB_MESH) { + dm = mesh_create_derived_view(depsgraph, scene, ob, 0); + dm->release(dm); + } + else if (ob->type == OB_LATTICE) { + BKE_lattice_modifiers_calc(depsgraph, scene, ob); + } + else if (ob->type == OB_MBALL) { + BKE_displist_make_mball(depsgraph, scene, ob); + } + else if (ELEM(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { + BKE_displist_make_curveTypes(depsgraph, scene, ob, 0); + } + + lmd->modifier.mode = mode; } + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; |