diff options
Diffstat (limited to 'source/blender/editors/object/object_modifier.c')
-rw-r--r-- | source/blender/editors/object/object_modifier.c | 223 |
1 files changed, 135 insertions, 88 deletions
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 81883725f64..9d1792e9f16 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -54,7 +54,6 @@ #include "BKE_animsys.h" #include "BKE_curve.h" #include "BKE_context.h" -#include "BKE_depsgraph.h" #include "BKE_displist.h" #include "BKE_DerivedMesh.h" #include "BKE_effect.h" @@ -75,6 +74,9 @@ #include "BKE_softbody.h" #include "BKE_editmesh.h" +#include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" + #include "RNA_access.h" #include "RNA_define.h" #include "RNA_enum_types.h" @@ -93,7 +95,10 @@ static void modifier_skin_customdata_delete(struct Object *ob); /******************************** API ****************************/ -ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *scene, Object *ob, const char *name, int type) +ModifierData *ED_object_modifier_add( + ReportList *reports, + Main *bmain, Scene *scene, + Object *ob, eObjectMode object_mode, const char *name, int type) { ModifierData *md = NULL, *new_md = NULL; const ModifierTypeInfo *mti = modifierType_getInfo(type); @@ -160,7 +165,7 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc /* set totlvl from existing MDISPS layer if object already had it */ multiresModifier_set_levels_from_disps((MultiresModifierData *)new_md, ob); - if (ob->mode & OB_MODE_SCULPT) { + if (object_mode & OB_MODE_SCULPT) { /* ensure that grid paint mask layer is created */ BKE_sculpt_mask_layers_ensure(ob, (MultiresModifierData *)new_md); } @@ -171,8 +176,8 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc } } - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - DAG_relations_tag_update(bmain); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_relations_tag_update(bmain); return new_md; } @@ -200,9 +205,11 @@ static bool object_has_modifier(const Object *ob, const ModifierData *exclude, * If the callback ever returns true, iteration will stop and the * function value will be true. Otherwise the function returns false. */ -bool ED_object_iter_other(Main *bmain, Object *orig_ob, const bool include_orig, - bool (*callback)(Object *ob, void *callback_data), - void *callback_data) +bool ED_object_iter_other( + const EvaluationContext *eval_ctx, + Main *bmain, Object *orig_ob, const bool include_orig, + bool (*callback)(const EvaluationContext *eval_ctx, Object *ob, void *callback_data), + void *callback_data) { ID *ob_data_id = orig_ob->data; int users = ob_data_id->us; @@ -221,7 +228,7 @@ bool ED_object_iter_other(Main *bmain, Object *orig_ob, const bool include_orig, if (((ob != orig_ob) || include_orig) && (ob->data == orig_ob->data)) { - if (callback(ob, callback_data)) + if (callback(eval_ctx, ob, callback_data)) return true; totfound++; @@ -229,13 +236,15 @@ bool ED_object_iter_other(Main *bmain, Object *orig_ob, const bool include_orig, } } else if (include_orig) { - return callback(orig_ob, callback_data); + return callback(eval_ctx, orig_ob, callback_data); } return false; } -static bool object_has_modifier_cb(Object *ob, void *data) +static bool object_has_modifier_cb( + const EvaluationContext *UNUSED(eval_ctx), + Object *ob, void *data) { ModifierType type = *((ModifierType *)data); @@ -245,15 +254,17 @@ static bool object_has_modifier_cb(Object *ob, void *data) /* Use with ED_object_iter_other(). Sets the total number of levels * for any multires modifiers on the object to the int pointed to by * callback_data. */ -bool ED_object_multires_update_totlevels_cb(Object *ob, void *totlevel_v) +bool ED_object_multires_update_totlevels_cb( + const struct EvaluationContext *eval_ctx, + Object *ob, void *totlevel_v) { ModifierData *md; int totlevel = *((char *)totlevel_v); for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Multires) { - multires_set_tot_level(ob, (MultiresModifierData *)md, totlevel); - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + multires_set_tot_level((MultiresModifierData *)md, totlevel, eval_ctx->object_mode); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); } } return false; @@ -265,7 +276,7 @@ static bool object_modifier_safe_to_delete(Main *bmain, Object *ob, ModifierType type) { return (!object_has_modifier(ob, exclude, type) && - !ED_object_iter_other(bmain, ob, false, + !ED_object_iter_other(NULL, bmain, ob, false, object_has_modifier_cb, &type)); } @@ -314,13 +325,15 @@ static bool object_modifier_remove(Main *bmain, Object *ob, ModifierData *md, modifier_skin_customdata_delete(ob); } +#if 0 /* not needed now modes are in workspace */ if (ELEM(md->type, eModifierType_Softbody, eModifierType_Cloth) && BLI_listbase_is_empty(&ob->particlesystem)) { ob->mode &= ~OB_MODE_PARTICLE_EDIT; } +#endif - DAG_relations_tag_update(bmain); + DEG_relations_tag_update(bmain); BLI_remlink(&ob->modifiers, md); modifier_free(md); @@ -341,8 +354,8 @@ bool ED_object_modifier_remove(ReportList *reports, Main *bmain, Object *ob, Mod return 0; } - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - DAG_relations_tag_update(bmain); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_relations_tag_update(bmain); return 1; } @@ -365,8 +378,8 @@ void ED_object_modifier_clear(Main *bmain, Object *ob) md = next_md; } - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - DAG_relations_tag_update(bmain); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_relations_tag_update(bmain); } int ED_object_modifier_move_up(ReportList *reports, Object *ob, ModifierData *md) @@ -411,7 +424,9 @@ int ED_object_modifier_move_down(ReportList *reports, Object *ob, ModifierData * return 1; } -int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene *scene, Object *ob, ModifierData *md) +int ED_object_modifier_convert( + ReportList *UNUSED(reports), Main *bmain, Scene *scene, + ViewLayer *view_layer, Object *UNUSED(ob), eObjectMode object_mode, ModifierData *md) { Object *obn; ParticleSystem *psys; @@ -425,7 +440,7 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene * int totpart = 0, totchild = 0; if (md->type != eModifierType_ParticleSystem) return 0; - if (ob && ob->mode & OB_MODE_PARTICLE_EDIT) return 0; + if (object_mode & OB_MODE_PARTICLE_EDIT) return 0; psys = ((ParticleSystemModifierData *)md)->psys; part = psys->part; @@ -463,7 +478,7 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene * if (totvert == 0) return 0; /* add new mesh */ - obn = BKE_object_add(bmain, scene, OB_MESH, NULL); + obn = BKE_object_add(bmain, scene, view_layer, OB_MESH, NULL); me = obn->data; me->totvert = totvert; @@ -515,14 +530,17 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene * } } - DAG_relations_tag_update(bmain); + DEG_relations_tag_update(bmain); return 1; } -static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, ModifierData *md) +static int modifier_apply_shape(ReportList *reports, const bContext *C, Scene *scene, Object *ob, ModifierData *md) { const ModifierTypeInfo *mti = modifierType_getInfo(md->type); + EvaluationContext eval_ctx; + + CTX_data_eval_ctx(C, &eval_ctx); md->scene = scene; @@ -553,7 +571,7 @@ static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, M return 0; } - dm = mesh_create_derived_for_modifier(scene, ob, md, 0); + dm = mesh_create_derived_for_modifier(&eval_ctx, scene, ob, md, 0); if (!dm) { BKE_report(reports, RPT_ERROR, "Modifier is disabled or returned error, skipping apply"); return 0; @@ -580,9 +598,12 @@ static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, M return 1; } -static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, ModifierData *md) +static int modifier_apply_obdata(ReportList *reports, const bContext *C, Scene *scene, Object *ob, ModifierData *md) { const ModifierTypeInfo *mti = modifierType_getInfo(md->type); + EvaluationContext eval_ctx; + + CTX_data_eval_ctx(C, &eval_ctx); md->scene = scene; @@ -606,13 +627,13 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, multires_force_update(ob); if (mmd && mmd->totlvl && mti->type == eModifierTypeType_OnlyDeform) { - if (!multiresModifier_reshapeFromDeformMod(scene, mmd, ob, md)) { + if (!multiresModifier_reshapeFromDeformMod(&eval_ctx, scene, mmd, ob, md)) { BKE_report(reports, RPT_ERROR, "Multires modifier returned error, skipping apply"); return 0; } } else { - dm = mesh_create_derived_for_modifier(scene, ob, md, 1); + dm = mesh_create_derived_for_modifier(&eval_ctx, scene, ob, md, 1); if (!dm) { BKE_report(reports, RPT_ERROR, "Modifier returned error, skipping apply"); return 0; @@ -638,12 +659,12 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, BKE_report(reports, RPT_INFO, "Applied modifier only changed CV points, not tessellated/bevel vertices"); vertexCos = BKE_curve_nurbs_vertexCos_get(&cu->nurb, &numVerts); - mti->deformVerts(md, ob, NULL, vertexCos, numVerts, 0); + mti->deformVerts(md, &eval_ctx, ob, NULL, vertexCos, numVerts, 0); BK_curve_nurbs_vertexCos_apply(&cu->nurb, vertexCos); MEM_freeN(vertexCos); - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); } else { BKE_report(reports, RPT_ERROR, "Cannot apply modifier for this object type"); @@ -660,18 +681,19 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, if (psys->part->type != PART_HAIR) continue; - psys_apply_hair_lattice(scene, ob, psys); + psys_apply_hair_lattice(&eval_ctx, scene, ob, psys); } } return 1; } -int ED_object_modifier_apply(ReportList *reports, Scene *scene, Object *ob, ModifierData *md, int mode) +int ED_object_modifier_apply(ReportList *reports, const bContext *C, Scene *scene, Object *ob, ModifierData *md, int mode) { + const WorkSpace *workspace = CTX_wm_workspace(C); int prev_mode; - if (scene->obedit) { + if (BKE_object_is_in_editmode(ob)) { BKE_report(reports, RPT_ERROR, "Modifiers cannot be applied in edit mode"); return 0; } @@ -679,7 +701,7 @@ int ED_object_modifier_apply(ReportList *reports, Scene *scene, Object *ob, Modi BKE_report(reports, RPT_ERROR, "Modifiers cannot be applied to multi-user data"); return 0; } - else if ((ob->mode & OB_MODE_SCULPT) && + else if ((workspace->object_mode & OB_MODE_SCULPT) && (find_multires_modifier_before(scene, md)) && (modifier_isSameTopology(md) == false)) { @@ -695,13 +717,13 @@ int ED_object_modifier_apply(ReportList *reports, Scene *scene, Object *ob, Modi md->mode |= eModifierMode_Realtime; if (mode == MODIFIER_APPLY_SHAPE) { - if (!modifier_apply_shape(reports, scene, ob, md)) { + if (!modifier_apply_shape(reports, C, scene, ob, md)) { md->mode = prev_mode; return 0; } } else { - if (!modifier_apply_obdata(reports, scene, ob, md)) { + if (!modifier_apply_obdata(reports, C, scene, ob, md)) { md->mode = prev_mode; return 0; } @@ -731,12 +753,13 @@ int ED_object_modifier_copy(ReportList *UNUSED(reports), Object *ob, ModifierDat static int modifier_add_exec(bContext *C, wmOperator *op) { + const WorkSpace *workspace = CTX_wm_workspace(C); Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); int type = RNA_enum_get(op->ptr, "type"); - if (!ED_object_modifier_add(op->reports, bmain, scene, ob, NULL, type)) + if (!ED_object_modifier_add(op->reports, bmain, scene, ob, workspace->object_mode, NULL, type)) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); @@ -873,11 +896,12 @@ ModifierData *edit_modifier_property_get(wmOperator *op, Object *ob, int type) static int modifier_remove_exec(bContext *C, wmOperator *op) { + const WorkSpace *workspace = CTX_wm_workspace(C); Main *bmain = CTX_data_main(C); - Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = ED_object_active_context(C); ModifierData *md = edit_modifier_property_get(op, ob, 0); - int mode_orig = ob->mode; + int mode_orig = workspace->object_mode; if (!md || !ED_object_modifier_remove(op->reports, bmain, ob, md)) return OPERATOR_CANCELLED; @@ -885,11 +909,13 @@ static int modifier_remove_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); /* if cloth/softbody was removed, particle mode could be cleared */ - if (mode_orig & OB_MODE_PARTICLE_EDIT) - if ((ob->mode & OB_MODE_PARTICLE_EDIT) == 0) - if (scene->basact && scene->basact->object == ob) + if (mode_orig & OB_MODE_PARTICLE_EDIT) { + if ((workspace->object_mode & OB_MODE_PARTICLE_EDIT) == 0) { + if (view_layer->basact && view_layer->basact->object == ob) { WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL); - + } + } + } return OPERATOR_FINISHED; } @@ -926,7 +952,7 @@ static int modifier_move_up_exec(bContext *C, wmOperator *op) if (!md || !ED_object_modifier_move_up(op->reports, ob, md)) return OPERATOR_CANCELLED; - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; @@ -965,7 +991,7 @@ static int modifier_move_down_exec(bContext *C, wmOperator *op) if (!md || !ED_object_modifier_move_down(op->reports, ob, md)) return OPERATOR_CANCELLED; - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; @@ -1003,11 +1029,11 @@ static int modifier_apply_exec(bContext *C, wmOperator *op) ModifierData *md = edit_modifier_property_get(op, ob, 0); int apply_as = RNA_enum_get(op->ptr, "apply_as"); - if (!md || !ED_object_modifier_apply(op->reports, scene, ob, md, apply_as)) { + if (!md || !ED_object_modifier_apply(op->reports, C, scene, ob, md, apply_as)) { return OPERATOR_CANCELLED; } - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; @@ -1048,15 +1074,18 @@ void OBJECT_OT_modifier_apply(wmOperatorType *ot) static int modifier_convert_exec(bContext *C, wmOperator *op) { + const WorkSpace *workspace = CTX_wm_workspace(C); Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = ED_object_active_context(C); ModifierData *md = edit_modifier_property_get(op, ob, 0); - - if (!md || !ED_object_modifier_convert(op->reports, bmain, scene, ob, md)) + + if (!md || !ED_object_modifier_convert(op->reports, bmain, scene, view_layer, ob, workspace->object_mode, md)) { return OPERATOR_CANCELLED; + } - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; @@ -1095,7 +1124,7 @@ static int modifier_copy_exec(bContext *C, wmOperator *op) if (!md || !ED_object_modifier_copy(op->reports, ob, md)) return OPERATOR_CANCELLED; - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; @@ -1138,10 +1167,13 @@ static int multires_higher_levels_delete_exec(bContext *C, wmOperator *op) if (!mmd) return OPERATOR_CANCELLED; - - multiresModifier_del_levels(mmd, ob, 1); - ED_object_iter_other(CTX_data_main(C), ob, true, + EvaluationContext eval_ctx; + CTX_data_eval_ctx(C, &eval_ctx); + + multiresModifier_del_levels(mmd, ob, 1, eval_ctx.object_mode); + + ED_object_iter_other(&eval_ctx, CTX_data_main(C), ob, true, ED_object_multires_update_totlevels_cb, &mmd->totlvl); @@ -1182,17 +1214,20 @@ static int multires_subdivide_exec(bContext *C, wmOperator *op) if (!mmd) return OPERATOR_CANCELLED; - - multiresModifier_subdivide(mmd, ob, 0, mmd->simple); - ED_object_iter_other(CTX_data_main(C), ob, true, - ED_object_multires_update_totlevels_cb, - &mmd->totlvl); + EvaluationContext eval_ctx; + CTX_data_eval_ctx(C, &eval_ctx); + multiresModifier_subdivide(mmd, ob, 0, mmd->simple, eval_ctx.object_mode); + + ED_object_iter_other( + &eval_ctx, CTX_data_main(C), ob, true, + ED_object_multires_update_totlevels_cb, + &mmd->totlvl); - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - if (ob->mode & OB_MODE_SCULPT) { + if (eval_ctx.mode & OB_MODE_SCULPT) { /* ensure that grid paint mask layer is created */ BKE_sculpt_mask_layers_ensure(ob, mmd); } @@ -1229,8 +1264,11 @@ static int multires_reshape_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C), *secondob = NULL; Scene *scene = CTX_data_scene(C); + EvaluationContext eval_ctx; MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires); + CTX_data_eval_ctx(C, &eval_ctx); + if (!mmd) return OPERATOR_CANCELLED; @@ -1253,12 +1291,12 @@ static int multires_reshape_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - if (!multiresModifier_reshape(scene, mmd, ob, secondob)) { + if (!multiresModifier_reshape(&eval_ctx, scene, mmd, ob, secondob)) { BKE_report(op->reports, RPT_ERROR, "Objects do not have the same number of vertices"); return OPERATOR_CANCELLED; } - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; @@ -1403,10 +1441,11 @@ static int multires_base_apply_exec(bContext *C, wmOperator *op) if (!mmd) return OPERATOR_CANCELLED; - - multiresModifier_base_apply(mmd, ob); - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + const WorkSpace *workspace = CTX_wm_workspace(C); + multiresModifier_base_apply(mmd, ob, workspace->object_mode); + + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; @@ -1512,7 +1551,7 @@ static int skin_root_mark_exec(bContext *C, wmOperator *UNUSED(op)) BLI_gset_free(visited, NULL); - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; @@ -1567,7 +1606,7 @@ static int skin_loose_mark_clear_exec(bContext *C, wmOperator *op) } } - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; @@ -1617,7 +1656,7 @@ static int skin_radii_equalize_exec(bContext *C, wmOperator *UNUSED(op)) } } - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; @@ -1686,8 +1725,10 @@ static void skin_armature_bone_create(Object *skin_ob, } } -static Object *modifier_skin_armature_create(Main *bmain, Scene *scene, Object *skin_ob) +static Object *modifier_skin_armature_create(const bContext *C, Scene *scene, ViewLayer *view_layer, Object *skin_ob) { + Main *bmain = CTX_data_main(C); + EvaluationContext eval_ctx; BLI_bitmap *edges_visited; DerivedMesh *deform_dm; MVert *mvert; @@ -1699,7 +1740,9 @@ static Object *modifier_skin_armature_create(Main *bmain, Scene *scene, Object * int *emap_mem; int v; - deform_dm = mesh_get_derived_deform(scene, skin_ob, CD_MASK_BAREMESH); + CTX_data_eval_ctx(C, &eval_ctx); + + deform_dm = mesh_get_derived_deform(&eval_ctx, scene, skin_ob, CD_MASK_BAREMESH); mvert = deform_dm->getVertArray(deform_dm); /* add vertex weights to original mesh */ @@ -1709,7 +1752,7 @@ static Object *modifier_skin_armature_create(Main *bmain, Scene *scene, Object * NULL, me->totvert); - arm_ob = BKE_object_add(bmain, scene, OB_ARMATURE, NULL); + arm_ob = BKE_object_add(bmain, scene, view_layer, OB_ARMATURE, NULL); BKE_object_transform_copy(arm_ob, skin_ob); arm = arm_ob->data; arm->layer = 1; @@ -1768,6 +1811,7 @@ static int skin_armature_create_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = CTX_data_active_object(C), *arm_ob; Mesh *me = ob->data; ModifierData *skin_md; @@ -1779,7 +1823,7 @@ static int skin_armature_create_exec(bContext *C, wmOperator *op) } /* create new armature */ - arm_ob = modifier_skin_armature_create(bmain, scene, ob); + arm_ob = modifier_skin_armature_create(C, scene, view_layer, ob); /* add a modifier to connect the new armature to the mesh */ arm_md = (ArmatureModifierData *)modifier_new(eModifierType_Armature); @@ -1789,8 +1833,8 @@ static int skin_armature_create_exec(bContext *C, wmOperator *op) arm_md->object = arm_ob; arm_md->deformflag = ARM_DEF_VGROUP | ARM_DEF_QUATERNION; - DAG_relations_tag_update(bmain); - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_relations_tag_update(bmain); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); } WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); @@ -1857,7 +1901,7 @@ static int correctivesmooth_bind_exec(bContext *C, wmOperator *op) csmd->bind_coords_num = (unsigned int)-1; } - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; @@ -1899,8 +1943,11 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); + EvaluationContext eval_ctx; MeshDeformModifierData *mmd = (MeshDeformModifierData *)edit_modifier_property_get(op, ob, eModifierType_MeshDeform); + CTX_data_eval_ctx(C, &eval_ctx); + if (!mmd) return OPERATOR_CANCELLED; @@ -1926,7 +1973,7 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op) mmd->totcagevert = 0; mmd->totinfluence = 0; - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); } else { @@ -1938,17 +1985,17 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op) mmd->modifier.mode |= eModifierMode_Realtime; if (ob->type == OB_MESH) { - dm = mesh_create_derived_view(scene, ob, 0); + dm = mesh_create_derived_view(&eval_ctx, scene, ob, 0); dm->release(dm); } else if (ob->type == OB_LATTICE) { - BKE_lattice_modifiers_calc(scene, ob); + BKE_lattice_modifiers_calc(&eval_ctx, scene, ob); } else if (ob->type == OB_MBALL) { - BKE_displist_make_mball(CTX_data_main(C)->eval_ctx, scene, ob); + BKE_displist_make_mball(&eval_ctx, scene, ob); } else if (ELEM(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { - BKE_displist_make_curveTypes(scene, ob, 0); + BKE_displist_make_curveTypes(&eval_ctx, scene, ob, 0); } mmd->bindfunc = NULL; @@ -2000,7 +2047,7 @@ static int explode_refresh_exec(bContext *C, wmOperator *op) emd->flag |= eExplodeFlag_CalcFaces; - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; @@ -2145,7 +2192,7 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) if (free) { omd->refresh |= MOD_OCEAN_REFRESH_CLEAR_CACHE; - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; } @@ -2173,7 +2220,7 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) * this part of the process before a threaded job is created */ //scene->r.cfra = f; - //ED_update_for_newframe(CTX_data_main(C), scene, 1); + //ED_update_for_newframe(CTX_data_main(C), scene); /* ok, this doesn't work with drivers, but is way faster. * let's use this for now and hope nobody wants to drive the time value... */ @@ -2195,7 +2242,7 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) scene->r.cfra = cfra; - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); #endif @@ -2268,7 +2315,7 @@ static int laplaciandeform_bind_exec(bContext *C, wmOperator *op) else { lmd->flag |= MOD_LAPLACIANDEFORM_BIND; } - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; } @@ -2320,7 +2367,7 @@ static int surfacedeform_bind_exec(bContext *C, wmOperator *op) smd->flags |= MOD_SDEF_BIND; } - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; |