patch [#36078] Fixes joining behavior for curves and armatures (when active object not selected).

This commit is contained in:
Campbell Barton
2013-07-10 09:55:10 +00:00
parent 6ebfdd8dc3
commit 3f9629a4c7
3 changed files with 38 additions and 5 deletions

View File

@@ -170,7 +170,7 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann
}
/* join armature exec is exported for use in object->join objects operator... */
int join_armature_exec(bContext *C, wmOperator *UNUSED(op))
int join_armature_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
@@ -180,6 +180,7 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op))
bPoseChannel *pchan, *pchann;
EditBone *curbone;
float mat[4][4], oimat[4][4];
bool ok = false;
/* Ensure we're not in editmode and that the active object is an armature*/
if (!ob || ob->type != OB_ARMATURE)
@@ -187,6 +188,21 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op))
if (!arm || arm->edbo)
return OPERATOR_CANCELLED;
CTX_DATA_BEGIN(C, Base *, base, selected_editable_bases)
{
if (base->object == ob) {
ok = true;
break;
}
}
CTX_DATA_END;
/* that way the active object is always selected */
if (ok == false) {
BKE_report(op->reports, RPT_WARNING, "Active object is not a selected armature");
return OPERATOR_CANCELLED;
}
/* Get editbones of active armature to add editbones to */
ED_armature_to_edit(ob);

View File

@@ -6100,7 +6100,7 @@ void CURVE_OT_shade_flat(wmOperatorType *ot)
/************** join operator, to be used externally? ****************/
/* TODO: shape keys - as with meshes */
int join_curve_exec(bContext *C, wmOperator *UNUSED(op))
int join_curve_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
@@ -6112,6 +6112,22 @@ int join_curve_exec(bContext *C, wmOperator *UNUSED(op))
ListBase tempbase;
float imat[4][4], cmat[4][4];
int a;
bool ok = false;
CTX_DATA_BEGIN(C, Base *, base, selected_editable_bases)
{
if (base->object == ob) {
ok = true;
break;
}
}
CTX_DATA_END;
/* that way the active object is always selected */
if (ok == false) {
BKE_report(op->reports, RPT_WARNING, "Active object is not a selected curve");
return OPERATOR_CANCELLED;
}
tempbase.first = tempbase.last = NULL;

View File

@@ -88,9 +88,10 @@ int join_mesh_exec(bContext *C, wmOperator *op)
Key *key, *nkey = NULL;
KeyBlock *kb, *okb, *kbn;
float imat[4][4], cmat[4][4], *fp1, *fp2;
int a, b, totcol, totmat = 0, totedge = 0, totvert = 0, ok = 0;
int a, b, totcol, totmat = 0, totedge = 0, totvert = 0;
int totloop = 0, totpoly = 0, vertofs, *matmap = NULL;
int i, j, index, haskey = 0, edgeofs, loopofs, polyofs;
bool ok = false;
bDeformGroup *dg, *odg;
MDeformVert *dvert;
CustomData vdata, edata, fdata, ldata, pdata;
@@ -119,7 +120,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
totmat += base->object->totcol;
if (base->object == ob)
ok = 1;
ok = true;
/* check for shapekeys */
if (me->key)
@@ -129,7 +130,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
/* that way the active object is always selected */
if (ok == 0) {
if (ok == false) {
BKE_report(op->reports, RPT_WARNING, "Active object is not a selected mesh");
return OPERATOR_CANCELLED;
}