Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/object/object_modifier.c
| Context not available. | |||||
| #include "BKE_particle.h" | #include "BKE_particle.h" | ||||
| #include "BKE_softbody.h" | #include "BKE_softbody.h" | ||||
| #include "BKE_editmesh.h" | #include "BKE_editmesh.h" | ||||
| #include "BKE_gpencil.h" | |||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "DEG_depsgraph_build.h" | #include "DEG_depsgraph_build.h" | ||||
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| if (ob->type == OB_GPENCIL) { | |||||
| /* FIXME: Shouldn't the depsgraph tagging handle this? */ | |||||
| BKE_gpencil_batch_cache_dirty(ob->data); | |||||
| } | |||||
| DEG_id_tag_update(&ob->id, OB_RECALC_DATA); | DEG_id_tag_update(&ob->id, OB_RECALC_DATA); | ||||
| DEG_relations_tag_update(bmain); | DEG_relations_tag_update(bmain); | ||||
| Context not available. | |||||
| return 1; | return 1; | ||||
| } | } | ||||
| static int modifier_apply_obdata(ReportList *reports, Depsgraph *depsgraph, Scene *scene, Object *ob, ModifierData *md) | static int modifier_apply_obdata(ReportList *reports, bContext *C, Depsgraph *depsgraph, Scene *scene, Object *ob, ModifierData *md) | ||||
| { | { | ||||
| const ModifierTypeInfo *mti = modifierType_getInfo(md->type); | const ModifierTypeInfo *mti = modifierType_getInfo(md->type); | ||||
| Context not available. | |||||
| DEG_id_tag_update(&ob->id, OB_RECALC_DATA); | DEG_id_tag_update(&ob->id, OB_RECALC_DATA); | ||||
| } | } | ||||
| else if (ob->type == OB_GPENCIL) { | |||||
| if (ELEM(NULL, ob, ob->data)) { | |||||
| return 0; | |||||
| } | |||||
| else if (mti->bakeModifierGP == NULL) { | |||||
| BKE_report(reports, RPT_ERROR, "Not implemented"); | |||||
| return 0; | |||||
| } | |||||
| mti->bakeModifierGP(C, depsgraph, md, ob); | |||||
| DEG_id_tag_update(&ob->id, OB_RECALC_DATA); | |||||
| } | |||||
| else { | else { | ||||
| BKE_report(reports, RPT_ERROR, "Cannot apply modifier for this object type"); | BKE_report(reports, RPT_ERROR, "Cannot apply modifier for this object type"); | ||||
| return 0; | return 0; | ||||
| Context not available. | |||||
| } | } | ||||
| int ED_object_modifier_apply( | int ED_object_modifier_apply( | ||||
| ReportList *reports, Depsgraph *depsgraph, | ReportList *reports, bContext *C, Depsgraph *depsgraph, | ||||
| Scene *scene, Object *ob, ModifierData *md, int mode) | Scene *scene, Object *ob, ModifierData *md, int mode) | ||||
| { | { | ||||
| int prev_mode; | int prev_mode; | ||||
| Context not available. | |||||
| BKE_report(reports, RPT_ERROR, "Modifiers cannot be applied in edit mode"); | BKE_report(reports, RPT_ERROR, "Modifiers cannot be applied in edit mode"); | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| else if (ob->type == OB_GPENCIL) { | |||||
| if (ob->mode != OB_MODE_OBJECT) { | |||||
| BKE_report(reports, RPT_ERROR, "Modifiers cannot be applied in paint, sculpt or edit mode"); | |||||
| return 0; | |||||
| } | |||||
| if (((ID *)ob->data)->us > 1) { | |||||
| BKE_report(reports, RPT_ERROR, "Modifiers cannot be applied to multi-user data"); | |||||
| return 0; | |||||
| } | |||||
| } | |||||
| else if (((ID *) ob->data)->us > 1) { | else if (((ID *) ob->data)->us > 1) { | ||||
| BKE_report(reports, RPT_ERROR, "Modifiers cannot be applied to multi-user data"); | BKE_report(reports, RPT_ERROR, "Modifiers cannot be applied to multi-user data"); | ||||
| return 0; | return 0; | ||||
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| if (!modifier_apply_obdata(reports, depsgraph, scene, ob, md)) { | if (!modifier_apply_obdata(reports, C, depsgraph, scene, ob, md)) { | ||||
| md->mode = prev_mode; | md->mode = prev_mode; | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| Context not available. | |||||
| for (a = 0; rna_enum_object_modifier_type_items[a].identifier; a++) { | for (a = 0; rna_enum_object_modifier_type_items[a].identifier; a++) { | ||||
| md_item = &rna_enum_object_modifier_type_items[a]; | md_item = &rna_enum_object_modifier_type_items[a]; | ||||
| if (md_item->identifier[0]) { | if (md_item->identifier[0]) { | ||||
| mti = modifierType_getInfo(md_item->value); | mti = modifierType_getInfo(md_item->value); | ||||
| Context not available. | |||||
| 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; | ||||
| } | } | ||||
| Context not available. | |||||
| 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; | ||||
| } | } | ||||
| Context not available. | |||||
| ModifierData *md = edit_modifier_property_get(op, ob, 0); | ModifierData *md = edit_modifier_property_get(op, ob, 0); | ||||
| int apply_as = RNA_enum_get(op->ptr, "apply_as"); | int apply_as = RNA_enum_get(op->ptr, "apply_as"); | ||||
| if (!md || !ED_object_modifier_apply(op->reports, depsgraph, scene, ob, md, apply_as)) { | if (!md || !ED_object_modifier_apply(op->reports, C, depsgraph, scene, ob, md, apply_as)) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| Context not available. | |||||
| 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; | ||||
| } | } | ||||
| Context not available. | |||||