Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/object/object_modifier.c
| Show First 20 Lines • Show All 313 Lines • ▼ Show 20 Lines | else if (md->type == eModifierType_Skin) { | ||||
| /* Delete MVertSkin layer if not used by another skin modifier */ | /* Delete MVertSkin layer if not used by another skin modifier */ | ||||
| if (object_modifier_safe_to_delete(bmain, ob, md, eModifierType_Skin)) | if (object_modifier_safe_to_delete(bmain, ob, md, eModifierType_Skin)) | ||||
| modifier_skin_customdata_delete(ob); | modifier_skin_customdata_delete(ob); | ||||
| } | } | ||||
| if (ELEM(md->type, eModifierType_Softbody, eModifierType_Cloth) && | if (ELEM(md->type, eModifierType_Softbody, eModifierType_Cloth) && | ||||
| BLI_listbase_is_empty(&ob->particlesystem)) | BLI_listbase_is_empty(&ob->particlesystem)) | ||||
| { | { | ||||
| ob->mode &= ~OB_MODE_PARTICLE_EDIT; | ob->mode = OB_MODE_OBJECT; // XXX | ||||
| } | } | ||||
| DEG_relations_tag_update(bmain); | DEG_relations_tag_update(bmain); | ||||
| BLI_remlink(&ob->modifiers, md); | BLI_remlink(&ob->modifiers, md); | ||||
| modifier_free(md); | modifier_free(md); | ||||
| BKE_object_free_derived_caches(ob); | BKE_object_free_derived_caches(ob); | ||||
| ▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | if (md->next) { | ||||
| BLI_remlink(&ob->modifiers, md); | BLI_remlink(&ob->modifiers, md); | ||||
| BLI_insertlinkafter(&ob->modifiers, md->next, md); | BLI_insertlinkafter(&ob->modifiers, md->next, md); | ||||
| } | } | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene *scene, ViewLayer *view_layer, Object *ob, ModifierData *md) | int ED_object_modifier_convert( | ||||
| ReportList *UNUSED(reports), WorkSpace *workspace, | |||||
| Main *bmain, Scene *scene, ViewLayer *view_layer, Object *ob, | |||||
| ModifierData *md) | |||||
| { | { | ||||
| Object *obn; | Object *obn; | ||||
| ParticleSystem *psys; | ParticleSystem *psys; | ||||
| ParticleCacheKey *key, **cache; | ParticleCacheKey *key, **cache; | ||||
| ParticleSettings *part; | ParticleSettings *part; | ||||
| Mesh *me; | Mesh *me; | ||||
| MVert *mvert; | MVert *mvert; | ||||
| MEdge *medge; | MEdge *medge; | ||||
| Show All 35 Lines | if (key->segments > 0) { | ||||
| totvert += key->segments + 1; | totvert += key->segments + 1; | ||||
| totedge += key->segments; | totedge += key->segments; | ||||
| } | } | ||||
| } | } | ||||
| if (totvert == 0) return 0; | if (totvert == 0) return 0; | ||||
| /* add new mesh */ | /* add new mesh */ | ||||
| obn = BKE_object_add(bmain, scene, view_layer, OB_MESH, NULL); | obn = BKE_object_add(bmain, scene, view_layer, workspace, OB_MESH, NULL); | ||||
| me = obn->data; | me = obn->data; | ||||
| me->totvert = totvert; | me->totvert = totvert; | ||||
| me->totedge = totedge; | me->totedge = totedge; | ||||
| me->mvert = CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, totvert); | me->mvert = CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, totvert); | ||||
| me->medge = CustomData_add_layer(&me->edata, CD_MEDGE, CD_CALLOC, NULL, totedge); | me->medge = CustomData_add_layer(&me->edata, CD_MEDGE, CD_CALLOC, NULL, totedge); | ||||
| me->mface = CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, NULL, 0); | me->mface = CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, NULL, 0); | ||||
| ▲ Show 20 Lines • Show All 578 Lines • ▼ Show 20 Lines | |||||
| /************************ convert modifier operator *********************/ | /************************ convert modifier operator *********************/ | ||||
| static int modifier_convert_exec(bContext *C, wmOperator *op) | static int modifier_convert_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| Object *ob = ED_object_active_context(C); | Object *ob = ED_object_active_context(C); | ||||
| WorkSpace *workspace = CTX_wm_workspace(C); | |||||
| ModifierData *md = edit_modifier_property_get(op, ob, 0); | ModifierData *md = edit_modifier_property_get(op, ob, 0); | ||||
| if (!md || !ED_object_modifier_convert(op->reports, bmain, scene, view_layer, ob, md)) | if (!md || !ED_object_modifier_convert(op->reports, workspace, bmain, scene, view_layer, ob, md)) | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| 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; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 646 Lines • ▼ Show 20 Lines | static Object *modifier_skin_armature_create(const bContext *C, Scene *scene, ViewLayer *view_layer, Object *skin_ob) | ||||
| /* add vertex weights to original mesh */ | /* add vertex weights to original mesh */ | ||||
| CustomData_add_layer(&me->vdata, | CustomData_add_layer(&me->vdata, | ||||
| CD_MDEFORMVERT, | CD_MDEFORMVERT, | ||||
| CD_CALLOC, | CD_CALLOC, | ||||
| NULL, | NULL, | ||||
| me->totvert); | me->totvert); | ||||
| arm_ob = BKE_object_add(bmain, scene, view_layer, OB_ARMATURE, NULL); | arm_ob = BKE_object_add(bmain, scene, view_layer, CTX_wm_workspace(C), OB_ARMATURE, NULL); | ||||
| BKE_object_transform_copy(arm_ob, skin_ob); | BKE_object_transform_copy(arm_ob, skin_ob); | ||||
| arm = arm_ob->data; | arm = arm_ob->data; | ||||
| arm->layer = 1; | arm->layer = 1; | ||||
| arm_ob->dtx |= OB_DRAWXRAY; | arm_ob->dtx |= OB_DRAWXRAY; | ||||
| arm->drawtype = ARM_LINE; | arm->drawtype = ARM_LINE; | ||||
| arm->edbo = MEM_callocN(sizeof(ListBase), "edbo armature"); | arm->edbo = MEM_callocN(sizeof(ListBase), "edbo armature"); | ||||
| mvert_skin = CustomData_get_layer(&me->vdata, CD_MVERT_SKIN); | mvert_skin = CustomData_get_layer(&me->vdata, CD_MVERT_SKIN); | ||||
| ▲ Show 20 Lines • Show All 636 Lines • Show Last 20 Lines | |||||