diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-10-01 09:43:49 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-10-01 09:45:57 +0300 |
commit | c06333d77bf085c177ed78282e6b9f010295aef6 (patch) | |
tree | 198310c223455bd103f8888bcbd92a8f50914eae /source/blender/editors/mesh | |
parent | 5fca5c8065fc611961d6507bc468494ba358a224 (diff) |
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.
Diffstat (limited to 'source/blender/editors/mesh')
-rw-r--r-- | source/blender/editors/mesh/meshtools.c | 62 |
1 files changed, 33 insertions, 29 deletions
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index b4033af1523..84f209b5889 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -298,18 +298,18 @@ int join_mesh_exec(bContext *C, wmOperator *op) Depsgraph *depsgraph = CTX_data_depsgraph(C); /* count & check */ - CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) + CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) { - if (base->object->type == OB_MESH) { - me = base->object->data; + if (ob_iter->type == OB_MESH) { + me = ob_iter->data; totvert += me->totvert; totedge += me->totedge; totloop += me->totloop; totpoly += me->totpoly; - totmat += base->object->totcol; + totmat += ob_iter->totcol; - if (base->object == ob) + if (ob_iter == ob) ok = true; /* check for shapekeys */ @@ -379,14 +379,14 @@ int join_mesh_exec(bContext *C, wmOperator *op) } /* first pass over objects - copying materials and vertexgroups across */ - CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) + CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) { /* only act if a mesh, and not the one we're joining to */ - if ((ob != base->object) && (base->object->type == OB_MESH)) { - me = base->object->data; + if ((ob != ob_iter) && (ob_iter->type == OB_MESH)) { + me = ob_iter->data; /* Join this object's vertex groups to the base one's */ - for (dg = base->object->defbase.first; dg; dg = dg->next) { + for (dg = ob_iter->defbase.first; dg; dg = dg->next) { /* See if this group exists in the object (if it doesn't, add it to the end) */ if (!defgroup_find_name(ob, dg->name)) { odg = MEM_callocN(sizeof(bDeformGroup), "join deformGroup"); @@ -401,8 +401,8 @@ int join_mesh_exec(bContext *C, wmOperator *op) if (me->totvert) { /* Add this object's materials to the base one's if they don't exist already (but only if limits not exceeded yet) */ if (totcol < MAXMAT) { - for (a = 1; a <= base->object->totcol; a++) { - ma = give_current_material(base->object, a); + for (a = 1; a <= ob_iter->totcol; a++) { + ma = give_current_material(ob_iter, a); for (b = 0; b < totcol; b++) { if (ma == matar[b]) { @@ -500,16 +500,16 @@ int join_mesh_exec(bContext *C, wmOperator *op) matar, matmap, totcol, &vertofs, &edgeofs, &loopofs, &polyofs); - 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) { continue; } /* only join if this is a mesh */ - if (base->object->type == OB_MESH) { + if (ob_iter->type == OB_MESH) { join_mesh_single( depsgraph, bmain, scene, - ob, base->object, imat, + ob, ob_iter, imat, &mvert, &medge, &mloop, &mpoly, &vdata, &edata, &ldata, &pdata, totvert, totedge, totloop, totpoly, @@ -518,8 +518,8 @@ int join_mesh_exec(bContext *C, wmOperator *op) &vertofs, &edgeofs, &loopofs, &polyofs); /* free base, now that data is merged */ - if (base->object != ob) { - ED_object_base_free_and_unlink(bmain, scene, base->object); + if (ob_iter != ob) { + ED_object_base_free_and_unlink(bmain, scene, ob_iter); } } } @@ -609,21 +609,23 @@ int join_mesh_shapes_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); Depsgraph *depsgraph = CTX_data_depsgraph(C); - Mesh *me = (Mesh *)ob->data; + Mesh *me = (Mesh *)ob_active->data; Mesh *selme = NULL; Mesh *me_deformed = NULL; Key *key = me->key; KeyBlock *kb; bool ok = false, nonequal_verts = false; - CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) + CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) { - if (base->object == ob) continue; + if (ob_iter == ob_active) { + continue; + } - if (base->object->type == OB_MESH) { - selme = (Mesh *)base->object->data; + if (ob_iter->type == OB_MESH) { + selme = (Mesh *)ob_iter->data; if (selme->totvert == me->totvert) ok = true; @@ -651,21 +653,23 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op) } /* now ready to add new keys from selected meshes */ - CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) + CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) { - if (base->object == ob) continue; + if (ob_iter == ob_active) { + continue; + } - if (base->object->type == OB_MESH) { - selme = (Mesh *)base->object->data; + if (ob_iter->type == OB_MESH) { + selme = (Mesh *)ob_iter->data; if (selme->totvert == me->totvert) { - me_deformed = mesh_get_eval_deform(depsgraph, scene, base->object, CD_MASK_BAREMESH); + me_deformed = mesh_get_eval_deform(depsgraph, scene, ob_iter, CD_MASK_BAREMESH); if (!me_deformed) { continue; } - kb = BKE_keyblock_add(key, base->object->id.name + 2); + kb = BKE_keyblock_add(key, ob_iter->id.name + 2); BKE_mesh_runtime_eval_to_meshkey(me_deformed, me, kb); } |