~ubuntu-branches/ubuntu/utopic/blender/utopic-proposed

« back to all changes in this revision

Viewing changes to source/blender/editors/object/object_transform.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2014-02-19 11:24:23 UTC
  • mfrom: (14.2.23 sid)
  • Revision ID: package-import@ubuntu.com-20140219112423-rkmaz2m7ha06d4tk
Tags: 2.69-3ubuntu1
* Merge with Debian; remaining changes:
  - Configure without OpenImageIO on armhf, as it is not available on
    Ubuntu.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
#include "BKE_curve.h"
51
51
#include "BKE_depsgraph.h"
52
52
#include "BKE_main.h"
 
53
#include "BKE_idcode.h"
53
54
#include "BKE_mball.h"
54
55
#include "BKE_mesh.h"
55
56
#include "BKE_object.h"
379
380
        Main *bmain = CTX_data_main(C);
380
381
        Scene *scene = CTX_data_scene(C);
381
382
        float rsmat[3][3], obmat[3][3], iobmat[3][3], mat[4][4], scale;
382
 
        int change = 1;
 
383
        bool change = true;
383
384
        
384
385
        /* first check if we can execute */
385
386
        CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
386
387
        {
387
 
 
388
 
                if (ob->type == OB_MESH) {
389
 
                        if (ID_REAL_USERS(ob->data) > 1) {
390
 
                                BKE_report(reports, RPT_ERROR, "Cannot apply to a multi user mesh, doing nothing");
391
 
                                change = 0;
392
 
                        }
393
 
                }
394
 
                else if (ob->type == OB_ARMATURE) {
395
 
                        if (ID_REAL_USERS(ob->data) > 1) {
396
 
                                BKE_report(reports, RPT_ERROR, "Cannot apply to a multi user armature, doing nothing");
397
 
                                change = 0;
398
 
                        }
399
 
                }
400
 
                else if (ob->type == OB_LATTICE) {
401
 
                        if (ID_REAL_USERS(ob->data) > 1) {
402
 
                                BKE_report(reports, RPT_ERROR, "Cannot apply to a multi user lattice, doing nothing");
403
 
                                change = 0;
404
 
                        }
405
 
                }
406
 
                else if (ob->type == OB_MBALL) {
407
 
                        if (ID_REAL_USERS(ob->data) > 1) {
408
 
                                BKE_report(reports, RPT_ERROR, "Cannot apply to a multi user metaball, doing nothing");
409
 
                                change = 0;
410
 
                        }
411
 
                }
412
 
                else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
 
388
                if (ELEM6(ob->type, OB_MESH, OB_ARMATURE, OB_LATTICE, OB_MBALL, OB_CURVE, OB_SURF)) {
 
389
                        ID *obdata = ob->data;
 
390
                        if (ID_REAL_USERS(obdata) > 1) {
 
391
                                BKE_reportf(reports, RPT_ERROR,
 
392
                                            "Cannot apply to a multi user: Object \"%s\", %s \"%s\", aborting",
 
393
                                            ob->id.name + 2, BKE_idcode_to_name(GS(obdata->name)), obdata->name + 2);
 
394
                                change = false;
 
395
                        }
 
396
 
 
397
                        if (obdata->lib) {
 
398
                                BKE_reportf(reports, RPT_ERROR,
 
399
                                            "Cannot apply to library data: Object \"%s\", %s \"%s\", aborting",
 
400
                                            ob->id.name + 2, BKE_idcode_to_name(GS(obdata->name)), obdata->name + 2);
 
401
                                change = false;
 
402
                        }
 
403
                }
 
404
 
 
405
                if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
 
406
                        ID *obdata = ob->data;
413
407
                        Curve *cu;
414
408
 
415
 
                        if (ID_REAL_USERS(ob->data) > 1) {
416
 
                                BKE_report(reports, RPT_ERROR, "Cannot apply to a multi user curve, doing nothing");
417
 
                                change = 0;
418
 
                        }
419
 
 
420
409
                        cu = ob->data;
421
410
 
422
411
                        if (((ob->type == OB_CURVE) && !(cu->flag & CU_3D)) && (apply_rot || apply_loc)) {
423
 
                                BKE_report(reports, RPT_ERROR,
424
 
                                           "Neither rotation nor location could be applied to a 2D curve, doing nothing");
425
 
                                change = 0;
 
412
                                BKE_reportf(reports, RPT_ERROR,
 
413
                                            "Rotation/Location can't apply to a 2D curve: Object \"%s\", %s \"%s\", aborting",
 
414
                                            ob->id.name + 2, BKE_idcode_to_name(GS(obdata->name)), obdata->name + 2);
 
415
                                change = false;
426
416
                        }
427
417
                        if (cu->key) {
428
 
                                BKE_report(reports, RPT_ERROR, "Cannot apply to a curve with vertex keys, doing nothing");
429
 
                                change = 0;
 
418
                                BKE_reportf(reports, RPT_ERROR,
 
419
                                            "Can't apply to a curve with shape-keys: Object \"%s\", %s \"%s\", aborting",
 
420
                                            ob->id.name + 2, BKE_idcode_to_name(GS(obdata->name)), obdata->name + 2);
 
421
                                change = false;
430
422
                        }
431
423
                }
432
424
        }
435
427
        if (!change)
436
428
                return OPERATOR_CANCELLED;
437
429
 
438
 
        change = 0;
 
430
        change = false;
439
431
 
440
432
        /* now execute */
441
433
        CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
551
543
                        }
552
544
                }
553
545
                else if (ob->type == OB_CAMERA) {
554
 
                        MovieClip *clip = BKE_object_movieclip_get(scene, ob, FALSE);
 
546
                        MovieClip *clip = BKE_object_movieclip_get(scene, ob, false);
555
547
 
556
548
                        /* applying scale on camera actually scales clip's reconstruction.
557
549
                         * of there's clip assigned to camera nothing to do actually.
562
554
                        if (apply_scale)
563
555
                                BKE_tracking_reconstruction_scale(&clip->tracking, ob->size);
564
556
                }
 
557
                else if (ob->type == OB_EMPTY) {
 
558
                        /* It's possible for empties too, even though they don't 
 
559
                         * really have obdata, since we can simply apply the maximum
 
560
                         * scaling to the empty's drawsize.
 
561
                         *
 
562
                         * Core Assumptions:
 
563
                         * 1) Most scaled empties have uniform scaling 
 
564
                         *    (i.e. for visibility reasons), AND/OR
 
565
                         * 2) Preserving non-uniform scaling is not that important,
 
566
                         *    and is something that many users would be willing to
 
567
                         *    sacrifice for having an easy way to do this.
 
568
                         */
 
569
                         float max_scale = MAX3(ob->size[0], ob->size[1], ob->size[2]);
 
570
                         ob->empty_drawsize *= max_scale;
 
571
                }
565
572
                else {
566
573
                        continue;
567
574
                }
585
592
 
586
593
                DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA);
587
594
 
588
 
                change = 1;
 
595
                change = true;
589
596
        }
590
597
        CTX_DATA_END;
591
598
 
592
 
        if (!change)
 
599
        if (!change) {
 
600
                BKE_report(reports, RPT_WARNING, "Objects have no data to transform");
593
601
                return OPERATOR_CANCELLED;
 
602
        }
594
603
 
595
604
        WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
596
605
        return OPERATOR_FINISHED;
768
777
        }
769
778
 
770
779
        if (ctx_ob_act) {
771
 
                BLI_rotatelist(&ctx_data_list, (LinkData *)ctx_ob_act);
 
780
                BLI_rotatelist_first(&ctx_data_list, (LinkData *)ctx_ob_act);
772
781
        }
773
782
 
774
783
        for (tob = bmain->object.first; tob; tob = tob->id.next) {