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>2010-08-03 04:56:43 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-08-03 04:56:43 +0400
commit66f32bd7f9191702d561ff6995363d9a98084772 (patch)
tree961017902b0bc4bf869a87425ca5a9952df6494d /source/blender
parent15e475339670c4166c495fd9b1a559fac0915995 (diff)
set origin was setting surfaces as 2D curves, added dupli-group support using the dupli's offset value.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_curve.h2
-rw-r--r--source/blender/blenkernel/BKE_mesh.h2
-rw-r--r--source/blender/blenkernel/intern/curve.c8
-rw-r--r--source/blender/blenkernel/intern/mesh.c10
-rw-r--r--source/blender/editors/object/object_transform.c116
5 files changed, 78 insertions, 60 deletions
diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h
index bcc92b477a7..b9f0e6d0551 100644
--- a/source/blender/blenkernel/BKE_curve.h
+++ b/source/blender/blenkernel/BKE_curve.h
@@ -107,7 +107,7 @@ int clamp_nurb_order_v( struct Nurb *nu);
ListBase *BKE_curve_nurbs(struct Curve *cu);
-int curve_bounds(struct Curve *cu, float min[3], float max[3]);
+int minmax_curve(struct Curve *cu, float min[3], float max[3]);
int curve_center_median(struct Curve *cu, float cent[3]);
int curve_center_bounds(struct Curve *cu, float cent[3]);
void curve_translate(struct Curve *cu, float offset[3], int do_keys);
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index 8c5979222f0..e80c266ff70 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -142,7 +142,7 @@ int mesh_layers_menu(struct CustomData *data, int type);
/* vertex level transformations & checks (no derived mesh) */
-int mesh_bounds(struct Mesh *me, float min[3], float max[3]);
+int minmax_mesh(struct Mesh *me, float min[3], float max[3]);
int mesh_center_median(struct Mesh *me, float cent[3]);
int mesh_center_bounds(struct Mesh *me, float cent[3]);
void mesh_translate(struct Mesh *me, float offset[3], int do_keys);
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 1a30e85c5c4..3d7eb1624f3 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -3105,13 +3105,11 @@ ListBase *BKE_curve_nurbs(Curve *cu)
/* basic vertex data functions */
-int curve_bounds(Curve *cu, float min[3], float max[3])
+int minmax_curve(Curve *cu, float min[3], float max[3])
{
ListBase *nurb_lb= BKE_curve_nurbs(cu);
Nurb *nu;
- INIT_MINMAX(min, max);
-
for(nu= nurb_lb->first; nu; nu= nu->next)
minmaxNurb(nu, min, max);
@@ -3157,8 +3155,8 @@ int curve_center_median(Curve *cu, float cent[3])
int curve_center_bounds(Curve *cu, float cent[3])
{
float min[3], max[3];
-
- if(curve_bounds(cu, min, max)) {
+ INIT_MINMAX(min, max);
+ if(minmax_curve(cu, min, max)) {
mid_v3_v3v3(cent, min, max);
return 1;
}
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index ab7b0694836..7129ecb1d55 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -330,7 +330,8 @@ void boundbox_mesh(Mesh *me, float *loc, float *size)
if (!loc) loc= mloc;
if (!size) size= msize;
- if(!mesh_bounds(me, min, max)) {
+ INIT_MINMAX(min, max);
+ if(!minmax_mesh(me, min, max)) {
min[0] = min[1] = min[2] = -1.0f;
max[0] = max[1] = max[2] = 1.0f;
}
@@ -1484,11 +1485,10 @@ void mesh_pmv_off(Object *ob, Mesh *me)
}
/* basic vertex data functions */
-int mesh_bounds(Mesh *me, float min[3], float max[3])
+int minmax_mesh(Mesh *me, float min[3], float max[3])
{
int i= me->totvert;
MVert *mvert;
- INIT_MINMAX(min, max);
for(mvert= me->mvert; i--; mvert++) {
DO_MINMAX(mvert->co, min, max);
}
@@ -1512,8 +1512,8 @@ int mesh_center_median(Mesh *me, float cent[3])
int mesh_center_bounds(Mesh *me, float cent[3])
{
float min[3], max[3];
-
- if(mesh_bounds(me, min, max)) {
+ INIT_MINMAX(min, max);
+ if(minmax_mesh(me, min, max)) {
mid_v3_v3v3(cent, min, max);
return 1;
}
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index d7961a8cd2b..ba9a03194ac 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -34,6 +34,7 @@
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
+#include "DNA_group_types.h"
#include "BLI_math.h"
#include "BLI_editVert.h"
@@ -774,14 +775,45 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
for (tob= bmain->object.first; tob; tob= tob->id.next) {
if(tob->data)
((ID *)tob->data)->flag &= ~LIB_DOIT;
+ if(tob->dup_group)
+ ((ID *)tob->dup_group)->flag &= ~LIB_DOIT;
}
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
if((ob->flag & OB_DONE)==0) {
+ int do_inverse_offset = FALSE;
ob->flag |= OB_DONE;
+ if(centermode == ORIGIN_TO_CURSOR) {
+ copy_v3_v3(cent, cursor);
+ invert_m4_m4(ob->imat, ob->obmat);
+ mul_m4_v3(ob->imat, cent);
+ }
+
if(ob->data == NULL) {
- /* pass */
+ /* special support for dupligroups */
+ if((ob->transflag & OB_DUPLIGROUP) && ob->dup_group && (ob->dup_group->id.flag & LIB_DOIT)==0) {
+ if(ob->dup_group->id.lib) {
+ tot_lib_error++;
+ }
+ else {
+ if(centermode == ORIGIN_TO_CURSOR) { /* done */ }
+ else {
+ /* only bounds support */
+ INIT_MINMAX(min, max);
+ minmax_object_duplis(scene, ob, min, max);
+ mid_v3_v3v3(cent, min, max);
+ invert_m4_m4(ob->imat, ob->obmat);
+ mul_m4_v3(ob->imat, cent);
+ }
+
+ add_v3_v3(ob->dup_group->dupli_ofs, cent);
+
+ tot_change++;
+ ob->dup_group->id.flag |= LIB_DOIT;
+ do_inverse_offset= TRUE;
+ }
+ }
}
else if (((ID *)ob->data)->lib) {
tot_lib_error++;
@@ -790,40 +822,26 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
if(obedit==NULL && ob->type==OB_MESH) {
Mesh *me= ob->data;
- if(centermode == ORIGIN_TO_CURSOR) {
- copy_v3_v3(cent, cursor);
- invert_m4_m4(ob->imat, ob->obmat);
- mul_m4_v3(ob->imat, cent);
- } else {
- if(around==V3D_CENTROID)
- mesh_center_median(me, cent);
- else
- mesh_center_bounds(me, cent);
- }
+ if(centermode == ORIGIN_TO_CURSOR) { /* done */ }
+ else if(around==V3D_CENTROID) { mesh_center_median(me, cent); }
+ else { mesh_center_bounds(me, cent); }
negate_v3_v3(cent_neg, cent);
mesh_translate(me, cent_neg, 1);
tot_change++;
me->id.flag |= LIB_DOIT;
+ do_inverse_offset= TRUE;
}
else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
Curve *cu= ob->data;
- if(centermode == ORIGIN_TO_CURSOR) {
- copy_v3_v3(cent, cursor);
- invert_m4_m4(ob->imat, ob->obmat);
- mul_m4_v3(ob->imat, cent);
- }
- else {
- if(around==V3D_CENTROID)
- curve_center_median(cu, cent);
- else
- curve_center_bounds(cu, cent);
- }
+ if(centermode == ORIGIN_TO_CURSOR) { /* done */ }
+ else if(around==V3D_CENTROID) { curve_center_median(cu, cent); }
+ else { curve_center_bounds(cu, cent); }
/* don't allow Z change if curve is 2D */
- if( !( cu->flag & CU_3D ) )
+ if((ob->type == OB_CURVE) && !(cu->flag & CU_3D))
cent[2] = 0.0;
negate_v3_v3(cent_neg, cent);
@@ -831,6 +849,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
tot_change++;
cu->id.flag |= LIB_DOIT;
+ do_inverse_offset= TRUE;
if(obedit) {
if (centermode == GEOMETRY_TO_ORIGIN) {
@@ -849,9 +868,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
}
else {
if(centermode == ORIGIN_TO_CURSOR) {
- copy_v3_v3(cent, cursor);
- invert_m4_m4(ob->imat, ob->obmat);
- mul_m4_v3(ob->imat, cent);
+ /* done */
}
else {
cent[0]= 0.5f * ( cu->bb->vec[4][0] + cu->bb->vec[0][0]);
@@ -865,6 +882,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
tot_change++;
cu->id.flag |= LIB_DOIT;
+ do_inverse_offset= TRUE;
}
}
else if(ob->type==OB_ARMATURE) {
@@ -883,6 +901,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
tot_change++;
arm->id.flag |= LIB_DOIT;
+ /* do_inverse_offset= TRUE; */ /* docenter_armature() handles this */
where_is_object(scene, ob);
ignore_parent_tx(bmain, scene, ob);
@@ -893,33 +912,34 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
}
/* offset other selected objects */
- if(centermode != GEOMETRY_TO_ORIGIN) {
+ if(do_inverse_offset && (centermode != GEOMETRY_TO_ORIGIN)) {
/* was the object data modified
* note: the functions above must set 'cent' */
- if(ob->data && (((ID *)ob->data)->flag && LIB_DOIT) && ob->type != OB_ARMATURE) {
- copy_v3_v3(centn, cent);
- mul_mat3_m4_v3(ob->obmat, centn); /* ommit translation part */
- add_v3_v3(ob->loc, centn);
-
- where_is_object(scene, ob);
- ignore_parent_tx(bmain, scene, ob);
+ copy_v3_v3(centn, cent);
+ mul_mat3_m4_v3(ob->obmat, centn); /* ommit translation part */
+ add_v3_v3(ob->loc, centn);
- /* other users? */
- CTX_DATA_BEGIN(C, Object*, ob_other, selected_editable_objects) {
- if((ob_other->flag & OB_DONE)==0 && (ob_other->data == ob->data)) {
- ob_other->flag |= OB_DONE;
- ob_other->recalc= OB_RECALC_OB|OB_RECALC_DATA;
-
- copy_v3_v3(centn, cent);
- mul_mat3_m4_v3(ob_other->obmat, centn); /* ommit translation part */
- add_v3_v3(ob_other->loc, centn);
-
- where_is_object(scene, ob_other);
- ignore_parent_tx(bmain, scene, ob_other);
- }
+ where_is_object(scene, ob);
+ ignore_parent_tx(bmain, scene, ob);
+
+ /* other users? */
+ CTX_DATA_BEGIN(C, Object*, ob_other, selected_editable_objects) {
+ if( (ob_other->flag & OB_DONE)==0 &&
+ ( (ob->data && (ob->data == ob_other->data)) ||
+ (ob->dup_group==ob_other->dup_group && (ob->transflag|ob_other->transflag) & OB_DUPLIGROUP) )
+ ) {
+ ob_other->flag |= OB_DONE;
+ ob_other->recalc= OB_RECALC_OB|OB_RECALC_DATA;
+
+ copy_v3_v3(centn, cent);
+ mul_mat3_m4_v3(ob_other->obmat, centn); /* ommit translation part */
+ add_v3_v3(ob_other->loc, centn);
+
+ where_is_object(scene, ob_other);
+ ignore_parent_tx(bmain, scene, ob_other);
}
- CTX_DATA_END;
}
+ CTX_DATA_END;
}
}
}