diff options
author | Sybren A. Stüvel <sybren@stuvel.eu> | 2018-05-09 12:33:32 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2018-05-09 13:17:24 +0300 |
commit | 632755a3b1988e7553b381c2d737cb956e26780b (patch) | |
tree | 7f290e47a189470810dbdeb77afd4bcfb12a956e /source/blender/editors/object/object_modifier.c | |
parent | 5e915baec4ad657ac9655a9921425bfaec98ea66 (diff) |
Modifiers: ported Surface Deform to Mesh
The modifier performed the 'bind' operation not in the bind operator,
but delayed in the mesh evaluation. This saved the result in a CoW copy
instead of in the actual modifier data. The binding operator now follows
the same approach as Mesh Deform: it forces the modifiers to run on the
real (non-CoW) data, making it possible for the modifier to store the
binding data.
This commit also ports the usage of DerivedMesh to Mesh.
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 dd04a730542..2e922e7f963 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -90,6 +90,8 @@ #include "WM_api.h" #include "WM_types.h" +#include "MOD_modifier_helpers.h" + #include "object_intern.h" static void modifier_skin_customdata_delete(struct Object *ob); @@ -2331,17 +2333,41 @@ static int surfacedeform_bind_poll(bContext *C) static int surfacedeform_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); SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)edit_modifier_property_get(op, ob, eModifierType_SurfaceDeform); if (!smd) return OPERATOR_CANCELLED; if (smd->flags & MOD_SDEF_BIND) { + /* Un-binding happens inside the modifier when it's evaluated. */ smd->flags &= ~MOD_SDEF_BIND; } else if (smd->target) { + DerivedMesh *dm; + int mode = smd->modifier.mode; + + /* Force modifier to run, it will call binding routine. */ + smd->modifier.mode |= eModifierMode_Realtime; smd->flags |= MOD_SDEF_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); + } + + smd->modifier.mode = mode; } DEG_id_tag_update(&ob->id, OB_RECALC_DATA); |