Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-09-19 02:45:14 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-09-19 02:45:14 +0400
commit206359db25ad4728bb01ee3108d8736f41ed3b9a (patch)
treec523d95e6a132eb3b6cef5b2ac52c4e914bebe4c /source/blender/editors/object/object_transform.c
parentc471d41d42145f480c354b2701c1ba83e531fc07 (diff)
fix [#36771] Prevent 'Apply Transform' for Objects with a linked mesh
Diffstat (limited to 'source/blender/editors/object/object_transform.c')
-rw-r--r--source/blender/editors/object/object_transform.c64
1 files changed, 28 insertions, 36 deletions
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index c4878ef79d9..4d7abbe7c39 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -50,6 +50,7 @@
#include "BKE_curve.h"
#include "BKE_depsgraph.h"
#include "BKE_main.h"
+#include "BKE_idcode.h"
#include "BKE_mball.h"
#include "BKE_mesh.h"
#include "BKE_object.h"
@@ -379,54 +380,45 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
float rsmat[3][3], obmat[3][3], iobmat[3][3], mat[4][4], scale;
- int change = 1;
+ bool change = true;
/* first check if we can execute */
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
{
-
- if (ob->type == OB_MESH) {
- if (ID_REAL_USERS(ob->data) > 1) {
- BKE_report(reports, RPT_ERROR, "Cannot apply to a multi user mesh, doing nothing");
- change = 0;
- }
- }
- else if (ob->type == OB_ARMATURE) {
- if (ID_REAL_USERS(ob->data) > 1) {
- BKE_report(reports, RPT_ERROR, "Cannot apply to a multi user armature, doing nothing");
- change = 0;
- }
- }
- else if (ob->type == OB_LATTICE) {
- if (ID_REAL_USERS(ob->data) > 1) {
- BKE_report(reports, RPT_ERROR, "Cannot apply to a multi user lattice, doing nothing");
- change = 0;
+ if (ELEM6(ob->type, OB_MESH, OB_ARMATURE, OB_LATTICE, OB_MBALL, OB_CURVE, OB_SURF)) {
+ ID *obdata = ob->data;
+ if (ID_REAL_USERS(obdata) > 1) {
+ BKE_reportf(reports, RPT_ERROR,
+ "Cannot apply to a multi user: Object \"%s\", %s \"%s\", aborting",
+ ob->id.name + 2, BKE_idcode_to_name(GS(obdata->name)), obdata->name + 2);
+ change = false;
}
- }
- else if (ob->type == OB_MBALL) {
- if (ID_REAL_USERS(ob->data) > 1) {
- BKE_report(reports, RPT_ERROR, "Cannot apply to a multi user metaball, doing nothing");
- change = 0;
+
+ if (obdata->lib) {
+ BKE_reportf(reports, RPT_ERROR,
+ "Cannot apply to library data: Object \"%s\", %s \"%s\", aborting",
+ ob->id.name + 2, BKE_idcode_to_name(GS(obdata->name)), obdata->name + 2);
+ change = false;
}
}
- else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
- Curve *cu;
- if (ID_REAL_USERS(ob->data) > 1) {
- BKE_report(reports, RPT_ERROR, "Cannot apply to a multi user curve, doing nothing");
- change = 0;
- }
+ if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
+ ID *obdata = ob->data;
+ Curve *cu;
cu = ob->data;
if (((ob->type == OB_CURVE) && !(cu->flag & CU_3D)) && (apply_rot || apply_loc)) {
- BKE_report(reports, RPT_ERROR,
- "Neither rotation nor location could be applied to a 2D curve, doing nothing");
- change = 0;
+ BKE_reportf(reports, RPT_ERROR,
+ "Rotation/Location can't apply to a 2D curve: Object \"%s\", %s \"%s\", aborting",
+ ob->id.name + 2, BKE_idcode_to_name(GS(obdata->name)), obdata->name + 2);
+ change = false;
}
if (cu->key) {
- BKE_report(reports, RPT_ERROR, "Cannot apply to a curve with vertex keys, doing nothing");
- change = 0;
+ BKE_reportf(reports, RPT_ERROR,
+ "Can't apply to a curve with shape-keys: Object \"%s\", %s \"%s\", aborting",
+ ob->id.name + 2, BKE_idcode_to_name(GS(obdata->name)), obdata->name + 2);
+ change = false;
}
}
}
@@ -435,7 +427,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo
if (!change)
return OPERATOR_CANCELLED;
- change = 0;
+ change = false;
/* now execute */
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
@@ -600,7 +592,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo
DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA);
- change = 1;
+ change = true;
}
CTX_DATA_END;