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;
384
385
/* first check if we can execute */
385
386
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
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");
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");
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");
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");
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);
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);
405
if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
406
ID *obdata = ob->data;
415
if (ID_REAL_USERS(ob->data) > 1) {
416
BKE_report(reports, RPT_ERROR, "Cannot apply to a multi user curve, doing nothing");
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");
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);
428
BKE_report(reports, RPT_ERROR, "Cannot apply to a curve with vertex keys, doing nothing");
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);
563
555
BKE_tracking_reconstruction_scale(&clip->tracking, ob->size);
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.
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.
569
float max_scale = MAX3(ob->size[0], ob->size[1], ob->size[2]);
570
ob->empty_drawsize *= max_scale;