diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_multires.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/multires.c | 29 | ||||
-rw-r--r-- | source/blender/editors/object/object_modifier.c | 20 |
3 files changed, 30 insertions, 22 deletions
diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h index 6c8d20eed30..69482706da6 100644 --- a/source/blender/blenkernel/BKE_multires.h +++ b/source/blender/blenkernel/BKE_multires.h @@ -44,6 +44,9 @@ struct MultiresModifierData; struct Object; struct Scene; +/* Delete mesh mdisps */ +void multires_customdata_delete(struct Mesh *me); + void multires_mark_as_modified(struct Object *ob, enum MultiresModifiedFlags flags); void multires_force_update(struct Object *ob); diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 102f1cc335d..19f8cee989d 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -77,6 +77,27 @@ typedef enum { static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert); static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm2, DispOp op, DMGridData **oldGridData, int totlvl); +/** Customdata **/ + +void multires_customdata_delete(Mesh *me) +{ + if(me->edit_btmesh) { + BMEditMesh *em= me->edit_btmesh; + /* CustomData_external_remove is used here only to mark layer + * as non-external for further free-ing, so zero element count + * looks safer than em->totface */ + CustomData_external_remove(&em->bm->ldata, &me->id, + CD_MDISPS, 0); + BM_data_layer_free(em->bm, &em->bm->ldata, CD_MDISPS); + } + else { + CustomData_external_remove(&me->ldata, &me->id, + CD_MDISPS, me->totloop); + CustomData_free_layer_active(&me->ldata, CD_MDISPS, + me->totloop); + } +} + /** Grid hiding **/ static BLI_bitmap multires_mdisps_upsample_hidden(BLI_bitmap lo_hidden, int lo_level, @@ -619,8 +640,7 @@ static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl) } } else { - CustomData_external_remove(&me->ldata, &me->id, CD_MDISPS, me->totloop); - CustomData_free_layer_active(&me->ldata, CD_MDISPS, me->totloop); + multires_customdata_delete(me); } } @@ -2005,10 +2025,7 @@ static void multires_sync_levels(Scene *scene, Object *ob, Object *to_ob) * upsampled correct without modifier data. * just remove mdisps if no multires present (nazgul) */ - Mesh *me= (Mesh*)ob->data; - - CustomData_external_remove(&me->ldata, &me->id, CD_MDISPS, me->totloop); - CustomData_free_layer_active(&me->ldata, CD_MDISPS, me->totloop); + multires_customdata_delete(ob->data); } if (!mmd || !to_mmd) return; diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index dea9c1a3b6c..c420b214a7a 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -203,10 +203,9 @@ static int object_modifier_remove(Object *ob, ModifierData *md, int *sort_depsgr } else if(md->type == eModifierType_Multires) { int ok= 1; - Mesh *me= ob->data; ModifierData *tmpmd; - /* ensure MDISPS CustomData layer is't used by another multires modifiers */ + /* ensure MDISPS CustomData layer isn't used by another multires modifiers */ for(tmpmd= ob->modifiers.first; tmpmd; tmpmd= tmpmd->next) if(tmpmd!=md && tmpmd->type == eModifierType_Multires) { ok= 0; @@ -214,16 +213,7 @@ static int object_modifier_remove(Object *ob, ModifierData *md, int *sort_depsgr } if(ok) { - if(me->edit_btmesh) { - BMEditMesh *em= me->edit_btmesh; - /* CustomData_external_remove is used here only to mark layer as non-external - * for further free-ing, so zero element count looks safer than em->totface */ - CustomData_external_remove(&em->bm->ldata, &me->id, CD_MDISPS, 0); - BM_data_layer_free(em->bm, &em->bm->ldata, CD_MDISPS); - } else { - CustomData_external_remove(&me->ldata, &me->id, CD_MDISPS, me->totloop); - CustomData_free_layer_active(&me->ldata, CD_MDISPS, me->totloop); - } + multires_customdata_delete(ob->data); } } @@ -536,10 +526,8 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, dm->release(dm); - if(md->type == eModifierType_Multires) { - CustomData_external_remove(&me->ldata, &me->id, CD_MDISPS, me->totloop); - CustomData_free_layer_active(&me->ldata, CD_MDISPS, me->totloop); - } + if(md->type == eModifierType_Multires) + multires_customdata_delete(me); } } else if (ELEM(ob->type, OB_CURVE, OB_SURF)) { |