[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30995] trunk/blender/source/blender: set origin was setting surfaces as 2D curves, added dupli-group support using the dupli's offset value.

Campbell Barton ideasman42 at gmail.com
Tue Aug 3 02:56:43 CEST 2010


Revision: 30995
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30995
Author:   campbellbarton
Date:     2010-08-03 02:56:43 +0200 (Tue, 03 Aug 2010)

Log Message:
-----------
set origin was setting surfaces as 2D curves, added dupli-group support using the dupli's offset value.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_curve.h
    trunk/blender/source/blender/blenkernel/BKE_mesh.h
    trunk/blender/source/blender/blenkernel/intern/curve.c
    trunk/blender/source/blender/blenkernel/intern/mesh.c
    trunk/blender/source/blender/editors/object/object_transform.c

Modified: trunk/blender/source/blender/blenkernel/BKE_curve.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_curve.h	2010-08-02 22:53:40 UTC (rev 30994)
+++ trunk/blender/source/blender/blenkernel/BKE_curve.h	2010-08-03 00:56:43 UTC (rev 30995)
@@ -107,7 +107,7 @@
 
 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);

Modified: trunk/blender/source/blender/blenkernel/BKE_mesh.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_mesh.h	2010-08-02 22:53:40 UTC (rev 30994)
+++ trunk/blender/source/blender/blenkernel/BKE_mesh.h	2010-08-03 00:56:43 UTC (rev 30995)
@@ -142,7 +142,7 @@
 
 /* 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);

Modified: trunk/blender/source/blender/blenkernel/intern/curve.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/curve.c	2010-08-02 22:53:40 UTC (rev 30994)
+++ trunk/blender/source/blender/blenkernel/intern/curve.c	2010-08-03 00:56:43 UTC (rev 30995)
@@ -3105,13 +3105,11 @@
 
 
 /* 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_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;
 	}

Modified: trunk/blender/source/blender/blenkernel/intern/mesh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/mesh.c	2010-08-02 22:53:40 UTC (rev 30994)
+++ trunk/blender/source/blender/blenkernel/intern/mesh.c	2010-08-03 00:56:43 UTC (rev 30995)
@@ -330,7 +330,8 @@
 	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 @@
 }
 
 /* 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_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;
 	}

Modified: trunk/blender/source/blender/editors/object/object_transform.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_transform.c	2010-08-02 22:53:40 UTC (rev 30994)
+++ trunk/blender/source/blender/editors/object/object_transform.c	2010-08-03 00:56:43 UTC (rev 30995)
@@ -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 @@
 	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 @@
 			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 @@
 
 				tot_change++;
 				cu->id.flag |= LIB_DOIT;
+				do_inverse_offset= TRUE;
 
 				if(obedit) {
 					if (centermode == GEOMETRY_TO_ORIGIN) {
@@ -849,9 +868,7 @@
 				}
 				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 @@
 
 					tot_change++;
 					cu->id.flag |= LIB_DOIT;
+					do_inverse_offset= TRUE;
 				}
 			}
 			else if(ob->type==OB_ARMATURE) {
@@ -883,6 +901,7 @@
 
 					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 @@
 			}
 
 			/* 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);
+				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);
+				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;
 
-					/* 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);
 
-							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_other);
+						ignore_parent_tx(bmain, scene, ob_other);
 					}
-					CTX_DATA_END;
 				}
+				CTX_DATA_END;
 			}
 		}
 	}





More information about the Bf-blender-cvs mailing list