[Bf-blender-cvs] [c06333d77bf] blender2.8: Object Join: use 'selected_editable_objects'

Campbell Barton noreply at git.blender.org
Mon Oct 1 08:47:35 CEST 2018


Commit: c06333d77bf085c177ed78282e6b9f010295aef6
Author: Campbell Barton
Date:   Mon Oct 1 16:43:49 2018 +1000
Branches: blender2.8
https://developer.blender.org/rBc06333d77bf085c177ed78282e6b9f010295aef6

Object Join: use 'selected_editable_objects'

Was using 'selected_editable_bases', which used to save a lookup.
This is no longer the case and complicates access from Python
which cant yet easily access Bases.

===================================================================

M	source/blender/editors/armature/armature_relations.c
M	source/blender/editors/curve/editcurve.c
M	source/blender/editors/gpencil/gpencil_data.c
M	source/blender/editors/mesh/meshtools.c

===================================================================

diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c
index 1ab5d3dda1f..57b5f27cc91 100644
--- a/source/blender/editors/armature/armature_relations.c
+++ b/source/blender/editors/armature/armature_relations.c
@@ -247,8 +247,8 @@ int join_armature_exec(bContext *C, wmOperator *op)
 {
 	Main *bmain = CTX_data_main(C);
 	Scene *scene = CTX_data_scene(C);
-	Object  *ob = CTX_data_active_object(C);
-	bArmature *arm = (ob) ? ob->data : NULL;
+	Object  *ob_active = CTX_data_active_object(C);
+	bArmature *arm = (ob_active) ? ob_active->data : NULL;
 	bPose *pose, *opose;
 	bPoseChannel *pchan, *pchann;
 	EditBone *curbone;
@@ -256,14 +256,14 @@ int join_armature_exec(bContext *C, wmOperator *op)
 	bool ok = false;
 
 	/*	Ensure we're not in editmode and that the active object is an armature*/
-	if (!ob || ob->type != OB_ARMATURE)
+	if (!ob_active || ob_active->type != OB_ARMATURE)
 		return OPERATOR_CANCELLED;
 	if (!arm || arm->edbo)
 		return OPERATOR_CANCELLED;
 
-	CTX_DATA_BEGIN(C, Base *, base, selected_editable_bases)
+	CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects)
 	{
-		if (base->object == ob) {
+		if (ob_iter == ob_active) {
 			ok = true;
 			break;
 		}
@@ -280,34 +280,34 @@ int join_armature_exec(bContext *C, wmOperator *op)
 	ED_armature_to_edit(arm);
 
 	/* get pose of active object and move it out of posemode */
-	pose = ob->pose;
-	ob->mode &= ~OB_MODE_POSE;
+	pose = ob_active->pose;
+	ob_active->mode &= ~OB_MODE_POSE;
 
-	CTX_DATA_BEGIN(C, Base *, base, selected_editable_bases)
+	CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects)
 	{
-		if ((base->object->type == OB_ARMATURE) && (base->object != ob)) {
+		if ((ob_iter->type == OB_ARMATURE) && (ob_iter != ob_active)) {
 			tJoinArmature_AdtFixData afd = {NULL};
-			bArmature *curarm = base->object->data;
+			bArmature *curarm = ob_iter->data;
 
 			/* we assume that each armature datablock is only used in a single place */
-			BLI_assert(ob->data != base->object->data);
+			BLI_assert(ob_active->data != ob_iter->data);
 
 			/* init callback data for fixing up AnimData links later */
-			afd.srcArm = base->object;
-			afd.tarArm = ob;
+			afd.srcArm = ob_iter;
+			afd.tarArm = ob_active;
 			afd.names_map = BLI_ghash_str_new("join_armature_adt_fix");
 
 			/* Make a list of editbones in current armature */
-			ED_armature_to_edit(base->object->data);
+			ED_armature_to_edit(ob_iter->data);
 
 			/* Get Pose of current armature */
-			opose = base->object->pose;
-			base->object->mode &= ~OB_MODE_POSE;
+			opose = ob_iter->pose;
+			ob_iter->mode &= ~OB_MODE_POSE;
 			//BASACT->flag &= ~OB_MODE_POSE;
 
 			/* Find the difference matrix */
-			invert_m4_m4(oimat, ob->obmat);
-			mul_m4_m4m4(mat, oimat, base->object->obmat);
+			invert_m4_m4(oimat, ob_active->obmat);
+			mul_m4_m4m4(mat, oimat, ob_iter->obmat);
 
 			/* Copy bones and posechannels from the object to the edit armature */
 			for (pchan = opose->chanbase.first; pchan; pchan = pchann) {
@@ -347,7 +347,7 @@ int join_armature_exec(bContext *C, wmOperator *op)
 				}
 
 				/* Fix Constraints and Other Links to this Bone and Armature */
-				joined_armature_fix_links(bmain, ob, base->object, pchan, curbone);
+				joined_armature_fix_links(bmain, ob_active, ob_iter, pchan, curbone);
 
 				/* Rename pchan */
 				BLI_strncpy(pchan->name, curbone->name, sizeof(pchan->name));
@@ -370,14 +370,14 @@ int join_armature_exec(bContext *C, wmOperator *op)
 			 * so that we don't have to worry about ambiguities re which armature
 			 * a bone came from!
 			 */
-			if (base->object->adt) {
-				if (ob->adt == NULL) {
+			if (ob_iter->adt) {
+				if (ob_active->adt == NULL) {
 					/* no animdata, so just use a copy of the whole thing */
-					ob->adt = BKE_animdata_copy(bmain, base->object->adt, false, true);
+					ob_active->adt = BKE_animdata_copy(bmain, ob_iter->adt, false, true);
 				}
 				else {
 					/* merge in data - we'll fix the drivers manually */
-					BKE_animdata_merge_copy(bmain, &ob->id, &base->object->id, ADT_MERGECOPY_KEEP_DST, false);
+					BKE_animdata_merge_copy(bmain, &ob_active->id, &ob_iter->id, ADT_MERGECOPY_KEEP_DST, false);
 				}
 			}
 
@@ -393,7 +393,7 @@ int join_armature_exec(bContext *C, wmOperator *op)
 			}
 
 			/* Free the old object data */
-			ED_object_base_free_and_unlink(bmain, scene, base->object);
+			ED_object_base_free_and_unlink(bmain, scene, ob_iter);
 		}
 	}
 	CTX_DATA_END;
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 9154d72f493..cdd59203cd6 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -6084,7 +6084,7 @@ int join_curve_exec(bContext *C, wmOperator *op)
 {
 	Main *bmain = CTX_data_main(C);
 	Scene *scene = CTX_data_scene(C);
-	Object *ob = CTX_data_active_object(C);
+	Object *ob_active = CTX_data_active_object(C);
 	Curve *cu;
 	Nurb *nu, *newnu;
 	BezTriple *bezt;
@@ -6094,9 +6094,9 @@ int join_curve_exec(bContext *C, wmOperator *op)
 	int a;
 	bool ok = false;
 
-	CTX_DATA_BEGIN(C, Base *, base, selected_editable_bases)
+	CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects)
 	{
-		if (base->object == ob) {
+		if (ob_iter == ob_active) {
 			ok = true;
 			break;
 		}
@@ -6112,24 +6112,24 @@ int join_curve_exec(bContext *C, wmOperator *op)
 	BLI_listbase_clear(&tempbase);
 
 	/* trasnform all selected curves inverse in obact */
-	invert_m4_m4(imat, ob->obmat);
+	invert_m4_m4(imat, ob_active->obmat);
 
-	CTX_DATA_BEGIN(C, Base *, base, selected_editable_bases)
+	CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects)
 	{
-		if (base->object->type == ob->type) {
-			if (base->object != ob) {
+		if (ob_iter->type == ob_active->type) {
+			if (ob_iter != ob_active) {
 
-				cu = base->object->data;
+				cu = ob_iter->data;
 
 				if (cu->nurb.first) {
 					/* watch it: switch order here really goes wrong */
-					mul_m4_m4m4(cmat, imat, base->object->obmat);
+					mul_m4_m4m4(cmat, imat, ob_iter->obmat);
 
 					nu = cu->nurb.first;
 					while (nu) {
 						newnu = BKE_nurb_duplicate(nu);
-						if (ob->totcol) { /* TODO, merge material lists */
-							CLAMP(newnu->mat_nr, 0, ob->totcol - 1);
+						if (ob_active->totcol) { /* TODO, merge material lists */
+							CLAMP(newnu->mat_nr, 0, ob_active->totcol - 1);
 						}
 						else {
 							newnu->mat_nr = 0;
@@ -6157,23 +6157,23 @@ int join_curve_exec(bContext *C, wmOperator *op)
 					}
 				}
 
-				ED_object_base_free_and_unlink(bmain, scene, base->object);
+				ED_object_base_free_and_unlink(bmain, scene, ob_iter);
 			}
 		}
 	}
 	CTX_DATA_END;
 
-	cu = ob->data;
+	cu = ob_active->data;
 	BLI_movelisttolist(&cu->nurb, &tempbase);
 
-	if (ob->type == OB_CURVE) {
+	if (ob_active->type == OB_CURVE) {
 		/* Account for mixed 2D/3D curves when joining */
 		BKE_curve_curve_dimension_update(cu);
 	}
 
 	DEG_relations_tag_update(bmain);   // because we removed object(s), call before editmode!
 
-	DEG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA);
+	DEG_id_tag_update(&ob_active->id, OB_RECALC_OB | OB_RECALC_DATA);
 	DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE);
 
 	WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index d2ad38fed3a..068478af325 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -2038,27 +2038,27 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op)
 	Main *bmain = CTX_data_main(C);
 	Scene *scene = CTX_data_scene(C);
 	Depsgraph *depsgraph = CTX_data_depsgraph(C);
-	Object  *obact = CTX_data_active_object(C);
+	Object  *ob_active = CTX_data_active_object(C);
 	bGPdata *gpd_dst = NULL;
 	bool ok = false;
 
 	/* Ensure we're in right mode and that the active object is correct */
-	if (!obact || obact->type != OB_GPENCIL)
+	if (!ob_active || ob_active->type != OB_GPENCIL)
 		return OPERATOR_CANCELLED;
 
-	bGPdata *gpd = (bGPdata *)obact->data;
+	bGPdata *gpd = (bGPdata *)ob_active->data;
 	if ((!gpd) || GPENCIL_ANY_MODE(gpd)) {
 		return OPERATOR_CANCELLED;
 	}
 
 	/* Ensure all rotations are applied before */
 	// XXX: Why don't we apply them here instead of warning?
-	CTX_DATA_BEGIN(C, Base *, base, selected_editable_bases)
+	CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects)
 	{
-		if (base->object->type == OB_GPENCIL) {
-			if ((base->object->rot[0] != 0) ||
-			    (base->object->rot[1] != 0) ||
-			    (base->object->rot[2] != 0))
+		if (ob_iter->type == OB_GPENCIL) {
+			if ((ob_iter->rot[0] != 0) ||
+			    (ob_iter->rot[1] != 0) ||
+			    (ob_iter->rot[2] != 0))
 			{
 				BKE_report(op->reports, RPT_ERROR, "Apply all rotations before join objects");
 				return OPERATOR_CANCELLED;
@@ -2067,9 +2067,9 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op)
 	}
 	CTX_DATA_END;
 
-	CTX_DATA_BEGIN(C, Base *, base, selected_editable_bases)
+	CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects)
 	{
-		if (base->object == obact) {
+		if (ob_iter == ob_active) {
 			ok = true;
 			break;
 		}
@@ -2082,33 +2082,33 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op)
 		return OPERATOR_CANCELLED;
 	}
 
-	gpd_dst = obact->data;
-	Object *ob_dst = obact;
+	gpd_dst = ob_active->data;
+	Object *ob_dst = ob_active;
 
 	/* loop and join all data */
-	CTX_DATA_BEGIN(C, Base *, base, selected_editable_bases)
+	CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects)
 	{
-		if ((base->object->type == OB_GPENCIL) && (base->object != obact)) {
+		if ((ob_iter->type == OB_GPENCIL) && (ob_iter != ob_active)) {
 			/* we assume that each datablock is not already used in active object */
-			if (obact->data != base->object->data) {
-				Object *ob_src = base->object;
-				bGPdata *gpd_src = base->object->data;
+			if (ob_active->data != ob_iter->data) {
+				Object *ob_src = ob_iter;
+				bGPdata *gpd_src = ob_iter->data;
 
 				/* Apply all GP modifiers before */
-				for (GpencilModifierData *md = base->object->greasepencil_modifiers.first; md; md = md->ne

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list