diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2010-09-26 22:29:54 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2010-09-26 22:29:54 +0400 |
commit | 57527cb0ac8b153a4aa89baf655c8d58c488d3a6 (patch) | |
tree | 5a66da50cddead9a445c217a7b998565d201001d | |
parent | cf6b2ca034d1a2d41ac04de1a1ababb1db39df3e (diff) |
- Save MDISPS layer when applying modifier.
All sculpting used to disappear before. Save MDISPS if new mesh has got the same faces amount.
NOTE: maybe some other layers should be saved?
- Apply multires modififier if MDISPS was auto-created.
Multires's applyModifier used to return unchanged DM when MDISPS was auto-created.
- Set multires totlvl from MDISPS layer when new multires was added to mesh with existing MDISPS layer.
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 9 | ||||
-rw-r--r-- | source/blender/editors/object/object_modifier.c | 8 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_multires.c | 1 |
3 files changed, 17 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index de7b962e38a..0b3bd106544 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -239,6 +239,15 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me) if(!CustomData_has_layer(&tmp.fdata, CD_MFACE)) CustomData_add_layer(&tmp.fdata, CD_MFACE, CD_ASSIGN, dm->dupFaceArray(dm), totface); + /* object had got displacement layer, should copy this layer to save sculpted data */ + /* NOTE: maybe some other layers should be copied? nazgul */ + if(CustomData_has_layer(&me->fdata, CD_MDISPS)) { + if (totface == me->totface) { + MDisps *mdisps = CustomData_get_layer(&me->fdata, CD_MDISPS); + CustomData_add_layer(&tmp.fdata, CD_MDISPS, CD_DUPLICATE, mdisps, totface); + } + } + mesh_update_customdata_pointers(&tmp); CustomData_free(&me->vdata, me->totvert); diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 7cf24d5d07d..ec44383f1dd 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -132,6 +132,9 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc } else if(type == eModifierType_Surface) DAG_scene_sort(bmain, scene); + else if(type == eModifierType_Multires) + /* set totlvl from existing MDISPS layer if object already had it */ + multiresModifier_set_levels_from_disps(new_md, ob); } DAG_id_flush_update(&ob->id, OB_RECALC_DATA); @@ -431,6 +434,11 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, DM_to_mesh(dm, me); dm->release(dm); + + if(md->type == eModifierType_Multires) { + CustomData_external_remove(&me->fdata, &me->id, CD_MDISPS, me->totface); + CustomData_free_layer_active(&me->fdata, CD_MDISPS, me->totface); + } } } else if (ELEM(ob->type, OB_CURVE, OB_SURF)) { diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c index dd99c88a684..988ce3921a7 100644 --- a/source/blender/modifiers/intern/MOD_multires.c +++ b/source/blender/modifiers/intern/MOD_multires.c @@ -74,7 +74,6 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm, if(!CustomData_get_layer(&me->fdata, CD_MDISPS)) { /* multires always needs a displacement layer */ CustomData_add_layer(&me->fdata, CD_MDISPS, CD_CALLOC, NULL, me->totface); - return dm; } } |