Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-10-12 10:39:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-10-12 10:39:24 +0300
commitfe1befcadfa44d012561e8dc697470b2a5cc5f36 (patch)
treed8f3fdf65d4fa24d2ca06475334ba39001b8c8a5 /source/blender/editors/object/object_modifier.c
parentb15123d27965f5ef753354b3eb5f6739802848b9 (diff)
Modifier: remove derived mesh call for bind
Diffstat (limited to 'source/blender/editors/object/object_modifier.c')
-rw-r--r--source/blender/editors/object/object_modifier.c50
1 files changed, 19 insertions, 31 deletions
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index cfd50b0dba6..2b5b5a078a6 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -98,6 +98,23 @@ static void modifier_skin_customdata_delete(struct Object *ob);
/******************************** API ****************************/
+static void object_force_modifier_update_for_bind(Depsgraph *depsgraph, Scene *scene, Object *ob)
+{
+ if (ob->type == OB_MESH) {
+ Mesh *me_eval = mesh_create_eval_final_view(depsgraph, scene, ob, 0);
+ BKE_id_free(NULL, me_eval);
+ }
+ 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);
+ }
+}
+
ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *scene, Object *ob, const char *name, int type)
{
ModifierData *md = NULL, *new_md = NULL;
@@ -2269,27 +2286,13 @@ static int laplaciandeform_bind_exec(bContext *C, wmOperator *op)
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);
- }
+ object_force_modifier_update_for_bind(depsgraph, scene, ob);
lmd->modifier.mode = mode;
}
@@ -2340,39 +2343,24 @@ static int surfacedeform_bind_exec(bContext *C, wmOperator *op)
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);
- }
+ object_force_modifier_update_for_bind(depsgraph, scene, ob);
smd->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;
}