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:
Diffstat (limited to 'source/blender/editors/object/object_transform.c')
-rw-r--r--source/blender/editors/object/object_transform.c59
1 files changed, 40 insertions, 19 deletions
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index 900bf57b509..80d494a6a07 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -57,6 +57,7 @@
#include "BKE_tessmesh.h"
#include "BKE_multires.h"
#include "BKE_armature.h"
+#include "BKE_lattice.h"
#include "RNA_define.h"
#include "RNA_access.h"
@@ -66,6 +67,7 @@
#include "ED_armature.h"
#include "ED_keyframing.h"
+#include "ED_mball.h"
#include "ED_mesh.h"
#include "ED_screen.h"
#include "ED_view3d.h"
@@ -211,7 +213,6 @@ static void object_clear_scale(Object *ob)
static int object_clear_transform_generic_exec(bContext *C, wmOperator *op,
void (*clear_func)(Object *), const char default_ksName[])
{
- Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
KeyingSet *ks;
@@ -242,8 +243,6 @@ static int object_clear_transform_generic_exec(bContext *C, wmOperator *op,
CTX_DATA_END;
/* this is needed so children are also updated */
- DAG_ids_flush_update(bmain, 0);
-
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
return OPERATOR_FINISHED;
@@ -316,7 +315,6 @@ void OBJECT_OT_scale_clear(wmOperatorType *ot)
static int object_origin_clear_exec(bContext *C, wmOperator *UNUSED(op))
{
- Main *bmain = CTX_data_main(C);
float *v1, *v3;
float mat[3][3];
@@ -336,8 +334,6 @@ static int object_origin_clear_exec(bContext *C, wmOperator *UNUSED(op))
}
CTX_DATA_END;
- DAG_ids_flush_update(bmain, 0);
-
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
return OPERATOR_FINISHED;
@@ -406,6 +402,12 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo
change = 0;
}
}
+ 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;
+ }
+ }
else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
Curve *cu;
@@ -416,7 +418,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo
cu = ob->data;
- if (!(cu->flag & CU_3D) && (apply_rot || apply_loc)) {
+ 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;
@@ -447,7 +449,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo
float tmat[3][3], timat[3][3];
/* simple rotation matrix */
- BKE_object_rot_to_mat3(ob, rsmat);
+ BKE_object_rot_to_mat3(ob, rsmat, TRUE);
/* correct for scale, note mul_m3_m3m3 has swapped args! */
BKE_object_scale_to_mat3(ob, tmat);
@@ -515,6 +517,10 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo
bp++;
}
}
+ else if (ob->type == OB_MBALL) {
+ MetaBall *mb = ob->data;
+ ED_mball_transform(mb, (float *)mat);
+ }
else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
Curve *cu = ob->data;
@@ -699,9 +705,11 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
}
else {
if (around == V3D_CENTROID) {
- const float total_div = 1.0f / (float)em->bm->totvert;
- BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
- madd_v3_v3fl(cent, eve->co, total_div);
+ if (em->bm->totvert) {
+ const float total_div = 1.0f / (float)em->bm->totvert;
+ BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
+ madd_v3_v3fl(cent, eve->co, total_div);
+ }
}
}
else {
@@ -787,8 +795,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
if (centermode == ORIGIN_TO_CURSOR) { /* done */ }
else if (centermode == ORIGIN_TO_CENTER_OF_MASS) { BKE_mesh_center_centroid(me, cent); }
- else if (around == V3D_CENTROID) { BKE_mesh_center_median(me, cent); }
- else { BKE_mesh_center_bounds(me, cent); }
+ else if (around == V3D_CENTROID) { BKE_mesh_center_median(me, cent); }
+ else { BKE_mesh_center_bounds(me, cent); }
negate_v3_v3(cent_neg, cent);
BKE_mesh_translate(me, cent_neg, 1);
@@ -800,9 +808,9 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
Curve *cu = ob->data;
- if (centermode == ORIGIN_TO_CURSOR) { /* done */ }
+ if (centermode == ORIGIN_TO_CURSOR) { /* done */ }
else if (around == V3D_CENTROID) { BKE_curve_center_median(cu, cent); }
- else { BKE_curve_center_bounds(cu, cent); }
+ else { BKE_curve_center_bounds(cu, cent); }
/* don't allow Z change if curve is 2D */
if ((ob->type == OB_CURVE) && !(cu->flag & CU_3D))
@@ -863,7 +871,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
/* Function to recenter armatures in editarmature.c
* Bone + object locations are handled there.
*/
- docenter_armature(scene, ob, cursor, centermode, around);
+ ED_armature_origin_set(scene, ob, cursor, centermode, around);
tot_change++;
arm->id.flag |= LIB_DOIT;
@@ -881,9 +889,9 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
else if (ob->type == OB_MBALL) {
MetaBall *mb = ob->data;
- if (centermode == ORIGIN_TO_CURSOR) { /* done */ }
+ if (centermode == ORIGIN_TO_CURSOR) { /* done */ }
else if (around == V3D_CENTROID) { BKE_mball_center_median(mb, cent); }
- else { BKE_mball_center_bounds(mb, cent); }
+ else { BKE_mball_center_bounds(mb, cent); }
negate_v3_v3(cent_neg, cent);
BKE_mball_translate(mb, cent_neg);
@@ -899,6 +907,20 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
break;
}
}
+ else if (ob->type == OB_LATTICE) {
+ Lattice *lt = ob->data;
+
+ if (centermode == ORIGIN_TO_CURSOR) { /* done */ }
+ else if (around == V3D_CENTROID) { BKE_lattice_center_median(lt, cent); }
+ else { BKE_lattice_center_bounds(lt, cent); }
+
+ negate_v3_v3(cent_neg, cent);
+ BKE_lattice_translate(lt, cent_neg, 1);
+
+ tot_change++;
+ lt->id.flag |= LIB_DOIT;
+ do_inverse_offset = TRUE;
+ }
/* offset other selected objects */
if (do_inverse_offset && (centermode != GEOMETRY_TO_ORIGIN)) {
@@ -963,7 +985,6 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
DAG_id_tag_update(&tob->id, OB_RECALC_OB | OB_RECALC_DATA);
if (tot_change) {
- DAG_ids_flush_update(bmain, 0);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
}