diff options
Diffstat (limited to 'source/blender/editors/sculpt_paint/sculpt_undo.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_undo.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index d88d7a5ac49..4e62c66c425 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -30,6 +30,11 @@ * */ +/** \file blender/editors/sculpt_paint/sculpt_undo.c + * \ingroup edsculpt + */ + + #include "MEM_guardedalloc.h" #include "BLI_math.h" @@ -70,8 +75,10 @@ static void update_cb(PBVHNode *node, void *unused) static void sculpt_restore_deformed(SculptSession *ss, SculptUndoNode *unode, int uindex, int oindex, float coord[3]) { - swap_v3_v3(coord, unode->orig_co[uindex]); - copy_v3_v3(unode->co[uindex], ss->deform_cos[oindex]); + if(unode->orig_co) { + swap_v3_v3(coord, unode->orig_co[uindex]); + copy_v3_v3(unode->co[uindex], ss->deform_cos[oindex]); + } else swap_v3_v3(coord, unode->co[uindex]); } static void sculpt_undo_restore(bContext *C, ListBase *lb) @@ -93,17 +100,15 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) continue; if(unode->maxvert) { - char *shapeName= (char*)unode->shapeName; - /* regular mesh restore */ if(ss->totvert != unode->maxvert) continue; - if (ss->kb && strcmp(ss->kb->name, shapeName)) { + if (ss->kb && strcmp(ss->kb->name, unode->shapeName)) { /* shape key has been changed before calling undo operator */ Key *key= ob_get_key(ob); - KeyBlock *kb= key_get_named_keyblock(key, shapeName); + KeyBlock *kb= key_get_named_keyblock(key, unode->shapeName); if (kb) { ob->shapenr= BLI_findindex(&key->block, kb) + 1; @@ -126,7 +131,10 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) for(i=0; i<unode->totvert; i++) { if(ss->modifiers_active) sculpt_restore_deformed(ss, unode, i, index[i], vertCos[index[i]]); - else swap_v3_v3(vertCos[index[i]], unode->co[i]); + else { + if(unode->orig_co) swap_v3_v3(vertCos[index[i]], unode->orig_co[i]); + else swap_v3_v3(vertCos[index[i]], unode->co[i]); + } } /* propagate new coords to keyblock */ @@ -140,7 +148,10 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) } else { for(i=0; i<unode->totvert; i++) { if(ss->modifiers_active) sculpt_restore_deformed(ss, unode, i, index[i], mvert[index[i]].co); - else swap_v3_v3(mvert[index[i]].co, unode->co[i]); + else { + if(unode->orig_co) swap_v3_v3(mvert[index[i]].co, unode->orig_co[i]); + else swap_v3_v3(mvert[index[i]].co, unode->co[i]); + } mvert[index[i]].flag |= ME_VERT_PBVH_UPDATE; } } @@ -303,7 +314,7 @@ SculptUndoNode *sculpt_undo_push_node(SculptSession *ss, PBVHNode *node) memcpy(unode->grids, grids, sizeof(int)*totgrid); /* store active shape key */ - if(ss->kb) BLI_strncpy((char*)unode->shapeName, ss->kb->name, sizeof(ss->kb->name)); + if(ss->kb) BLI_strncpy(unode->shapeName, ss->kb->name, sizeof(ss->kb->name)); else unode->shapeName[0]= '\0'; return unode; |