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. | |||||
| modifier_free(md); | modifier_free(md); | ||||
| BKE_object_free_derived_caches(ob); | BKE_object_free_derived_caches(ob); | ||||
| /* if grease pencil, need refresh cache */ | |||||
| if (ob->type == OB_GPENCIL) { | |||||
| BKE_gpencil_batch_cache_dirty(ob->gpd); | |||||
| } | |||||
| return 1; | return 1; | ||||
| } | } | ||||
| Context not available. | |||||
| DEG_id_tag_update(&ob->id, OB_RECALC_DATA); | DEG_id_tag_update(&ob->id, OB_RECALC_DATA); | ||||
| } | } | ||||
| else if (ELEM(ob->type, OB_GPENCIL)) { | |||||
| /* some modifier need to have bContext */ | |||||
| if (md->type == eModifierType_GpencilArray) { | |||||
| GpencilArrayModifierData *mmd = (GpencilArrayModifierData *)md; | |||||
| mmd->C = (void *) C; | |||||
| } | |||||
| if (md->type == eModifierType_GpencilLattice) { | |||||
| GpencilLatticeModifierData *mmd = (GpencilLatticeModifierData *)md; | |||||
| mmd->C = (void *)C; | |||||
| } | |||||
| mti->applyModifier(md, &eval_ctx, ob, NULL, 0); | |||||
| if (ob->gpd) { | |||||
| BKE_gpencil_batch_cache_dirty(ob->gpd); | |||||
| } | |||||
| return 1; | |||||
| } | |||||
| 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. | |||||
| 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->gpd)->us > 1) { | |||||
| BKE_report(reports, RPT_ERROR, "Modifiers cannot be applied to multi-user data"); | |||||
| return 0; | |||||
| } | |||||
| modifier_apply_obdata(reports, C, scene, ob, md); | |||||
| BLI_remlink(&ob->modifiers, md); | |||||
| modifier_free(md); | |||||
| BKE_object_free_derived_caches(ob); | |||||
| return 1; | |||||
| } | |||||
| 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. | |||||
| 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. | |||||
| if (sl->basact && sl->basact->object == ob) | if (sl->basact && sl->basact->object == ob) | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL); | WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL); | ||||
| /* if grease pencil, need refresh cache */ | |||||
| if (ob->type == OB_GPENCIL) { | |||||
| BKE_gpencil_batch_cache_dirty(ob->gpd); | |||||
| } | |||||
| 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); | ||||
| /* if grease pencil, need refresh cache */ | |||||
| if (ob->type == OB_GPENCIL) { | |||||
| BKE_gpencil_batch_cache_dirty(ob->gpd); | |||||
| } | |||||
| 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); | ||||
| /* if grease pencil, need refresh cache */ | |||||
| if (ob->type == OB_GPENCIL) { | |||||
| BKE_gpencil_batch_cache_dirty(ob->gpd); | |||||
| } | |||||
| 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); | ||||
| /* if grease pencil, need refresh cache */ | |||||
| if (ob->type == OB_GPENCIL) { | |||||
| BKE_gpencil_batch_cache_dirty(ob->gpd); | |||||
| } | |||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| Context not available. | |||||