~ubuntu-branches/ubuntu/trusty/blender/trusty-proposed

« back to all changes in this revision

Viewing changes to source/blender/editors/sculpt_paint/sculpt_undo.c

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2013-08-14 10:43:49 UTC
  • mfrom: (14.2.19 sid)
  • Revision ID: package-import@ubuntu.com-20130814104349-t1d5mtwkphp12dyj
Tags: 2.68a-3
* Upload to unstable
* debian/: python3.3 Depends simplified
  - debian/control: python3.3 Depends dropped
    for blender-data package
  - 0001-blender_thumbnailer.patch refreshed
* debian/control: libavcodec b-dep versioning dropped

Show diffs side-by-side

added added

removed removed

Lines of Context:
131
131
                        vertCos = BKE_key_convert_to_vertcos(ob, ss->kb);
132
132
 
133
133
                        for (i = 0; i < unode->totvert; i++) {
134
 
                                if (ss->modifiers_active) sculpt_undo_restore_deformed(ss, unode, i, index[i], vertCos[index[i]]);
 
134
                                if (ss->modifiers_active) {
 
135
                                        sculpt_undo_restore_deformed(ss, unode, i, index[i], vertCos[index[i]]);
 
136
                                }
135
137
                                else {
136
138
                                        if (unode->orig_co) swap_v3_v3(vertCos[index[i]], unode->orig_co[i]);
137
139
                                        else swap_v3_v3(vertCos[index[i]], unode->co[i]);
149
151
                }
150
152
                else {
151
153
                        for (i = 0; i < unode->totvert; i++) {
152
 
                                if (ss->modifiers_active) sculpt_undo_restore_deformed(ss, unode, i, index[i], mvert[index[i]].co);
 
154
                                if (ss->modifiers_active) {
 
155
                                        sculpt_undo_restore_deformed(ss, unode, i, index[i], mvert[index[i]].co);
 
156
                                }
153
157
                                else {
154
158
                                        if (unode->orig_co) swap_v3_v3(mvert[index[i]].co, unode->orig_co[i]);
155
159
                                        else swap_v3_v3(mvert[index[i]].co, unode->co[i]);
263
267
}
264
268
 
265
269
static void sculpt_undo_bmesh_restore_generic(SculptUndoNode *unode,
266
 
                                                                                          Object *ob,
267
 
                                                                                          SculptSession *ss)
 
270
                                              Object *ob,
 
271
                                              SculptSession *ss)
268
272
{
269
273
        if (unode->applied) {
270
274
                BM_log_undo(ss->bm, ss->bm_log);
282
286
 
283
287
/* Create empty sculpt BMesh and enable logging */
284
288
static void sculpt_undo_bmesh_enable(Object *ob,
285
 
                                                                         SculptUndoNode *unode)
 
289
                                     SculptUndoNode *unode)
286
290
{
287
291
        SculptSession *ss = ob->sculpt;
288
292
        Mesh *me = ob->data;
296
300
 
297
301
        /* Restore the BMLog using saved entries */
298
302
        ss->bm_log = BM_log_from_existing_entries_create(ss->bm,
299
 
                                                                                                         unode->bm_entry);
 
303
                                                         unode->bm_entry);
300
304
}
301
305
 
302
306
static void sculpt_undo_bmesh_restore_begin(bContext *C,
303
 
                                                                                        SculptUndoNode *unode,
304
 
                                                                                        Object *ob,
305
 
                                                                                        SculptSession *ss)
 
307
                                            SculptUndoNode *unode,
 
308
                                            Object *ob,
 
309
                                            SculptSession *ss)
306
310
{
307
311
        if (unode->applied) {
308
312
                sculpt_dynamic_topology_disable(C, unode);
319
323
}
320
324
 
321
325
static void sculpt_undo_bmesh_restore_end(bContext *C,
322
 
                                                                                  SculptUndoNode *unode,
323
 
                                                                                  Object *ob,
324
 
                                                                                  SculptSession *ss)
 
326
                                          SculptUndoNode *unode,
 
327
                                          Object *ob,
 
328
                                          SculptSession *ss)
325
329
{
326
330
        if (unode->applied) {
327
331
                sculpt_undo_bmesh_enable(ob, unode);
343
347
 * Returns TRUE if this was a dynamic-topology undo step, otherwise
344
348
 * returns FALSE to indicate the non-dyntopo code should run. */
345
349
static int sculpt_undo_bmesh_restore(bContext *C,
346
 
                                                                         SculptUndoNode *unode,
347
 
                                                                         Object *ob,
348
 
                                                                         SculptSession *ss)
 
350
                                     SculptUndoNode *unode,
 
351
                                     Object *ob,
 
352
                                     SculptSession *ss)
349
353
{
350
354
        switch (unode->type) {
351
355
                case SCULPT_UNDO_DYNTOPO_BEGIN:
375
379
        DerivedMesh *dm;
376
380
        SculptSession *ss = ob->sculpt;
377
381
        SculptUndoNode *unode;
378
 
        MultiresModifierData *mmd;
379
382
        int update = FALSE, rebuild = FALSE;
380
383
        int need_mask = FALSE;
381
384
 
446
449
                BKE_pbvh_search_callback(ss->pbvh, NULL, NULL, update_cb, &rebuild);
447
450
                BKE_pbvh_update(ss->pbvh, PBVH_UpdateBB | PBVH_UpdateOriginalBB | PBVH_UpdateRedraw, NULL);
448
451
 
449
 
                if ((mmd = sculpt_multires_active(scene, ob))) {
 
452
                if (sculpt_multires_active(scene, ob)) {
450
453
                        if (rebuild)
451
454
                                multires_mark_as_modified(ob, MULTIRES_HIDDEN_MODIFIED);
452
455
                        else
563
566
        if (node) {
564
567
                BKE_pbvh_node_num_verts(ss->pbvh, node, &totvert, &allvert);
565
568
                BKE_pbvh_node_get_grids(ss->pbvh, node, &grids, &totgrid,
566
 
                                                                &maxgrid, &gridsize, NULL, NULL);
 
569
                                        &maxgrid, &gridsize, NULL, NULL);
567
570
 
568
571
                unode->totvert = totvert;
569
572
        }
 
573
        else
 
574
                maxgrid = 0;
570
575
        
571
576
        /* we will use this while sculpting, is mapalloc slow to access then? */
572
577
 
671
676
}
672
677
 
673
678
static SculptUndoNode *sculpt_undo_bmesh_push(Object *ob,
674
 
                                                                                          PBVHNode *node,
675
 
                                                                                          SculptUndoType type)
 
679
                                              PBVHNode *node,
 
680
                                              SculptUndoType type)
676
681
{
677
682
        ListBase *lb = undo_paint_push_get_list(UNDO_PAINT_MESH);
678
683
        SculptUndoNode *unode = lb->first;
699
704
                         * (converting polys to triangles) that the BMLog can't
700
705
                         * fully restore from */
701
706
                        CustomData_copy(&me->vdata, &unode->bm_enter_vdata, CD_MASK_MESH,
702
 
                                                        CD_DUPLICATE, me->totvert);
 
707
                                        CD_DUPLICATE, me->totvert);
703
708
                        CustomData_copy(&me->edata, &unode->bm_enter_edata, CD_MASK_MESH,
704
 
                                                        CD_DUPLICATE, me->totedge);
 
709
                                        CD_DUPLICATE, me->totedge);
705
710
                        CustomData_copy(&me->ldata, &unode->bm_enter_ldata, CD_MASK_MESH,
706
 
                                                        CD_DUPLICATE, me->totloop);
 
711
                                        CD_DUPLICATE, me->totloop);
707
712
                        CustomData_copy(&me->pdata, &unode->bm_enter_pdata, CD_MASK_MESH,
708
 
                                                        CD_DUPLICATE, me->totpoly);
 
713
                                        CD_DUPLICATE, me->totpoly);
709
714
                        unode->bm_enter_totvert = me->totvert;
710
715
                        unode->bm_enter_totedge = me->totedge;
711
716
                        unode->bm_enter_totloop = me->totloop;
754
759
        BLI_lock_thread(LOCK_CUSTOM1);
755
760
 
756
761
        if (ss->bm ||
757
 
                ELEM(type,
758
 
                         SCULPT_UNDO_DYNTOPO_BEGIN,
759
 
                         SCULPT_UNDO_DYNTOPO_END))
 
762
            ELEM(type,
 
763
                 SCULPT_UNDO_DYNTOPO_BEGIN,
 
764
                 SCULPT_UNDO_DYNTOPO_END))
760
765
        {
761
766
                /* Dynamic topology stores only one undo node per stroke,
762
767
                 * regardless of the number of PBVH nodes modified */