Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/object/object_modifier.c
| Show First 20 Lines • Show All 2,275 Lines • ▼ Show 20 Lines | |||||
| static int laplaciandeform_poll(bContext *C) | static int laplaciandeform_poll(bContext *C) | ||||
| { | { | ||||
| return edit_modifier_poll_generic(C, &RNA_LaplacianDeformModifier, 0); | return edit_modifier_poll_generic(C, &RNA_LaplacianDeformModifier, 0); | ||||
| } | } | ||||
| static int laplaciandeform_bind_exec(bContext *C, wmOperator *op) | static int laplaciandeform_bind_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | |||||
| Object *ob = ED_object_active_context(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); | LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)edit_modifier_property_get(op, ob, eModifierType_LaplacianDeform); | ||||
| if (!lmd) | if (!lmd) | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| if (lmd->flag & MOD_LAPLACIANDEFORM_BIND) { | if (lmd->flag & MOD_LAPLACIANDEFORM_BIND) { | ||||
| /* Un-binding happens inside the modifier when it's evaluated. */ | |||||
| lmd->flag &= ~MOD_LAPLACIANDEFORM_BIND; | lmd->flag &= ~MOD_LAPLACIANDEFORM_BIND; | ||||
| } | } | ||||
| else { | 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; | 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); | DEG_id_tag_update(&ob->id, OB_RECALC_DATA); | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); | WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static int laplaciandeform_bind_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | static int laplaciandeform_bind_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | ||||
| { | { | ||||
| if (edit_modifier_invoke_properties(C, op)) | if (edit_modifier_invoke_properties(C, op)) | ||||
| ▲ Show 20 Lines • Show All 98 Lines • Show Last 20 Lines | |||||