Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/mesh/meshtools.c
| Show First 20 Lines • Show All 308 Lines • ▼ Show 20 Lines | int join_mesh_exec(bContext *C, wmOperator *op) | ||||
| MPoly *mpoly = NULL; | MPoly *mpoly = NULL; | ||||
| MLoop *mloop = NULL; | MLoop *mloop = NULL; | ||||
| Key *key, *nkey = NULL; | Key *key, *nkey = NULL; | ||||
| KeyBlock *kb, *kbn; | KeyBlock *kb, *kbn; | ||||
| float imat[4][4]; | float imat[4][4]; | ||||
| int a, b, totcol, totmat = 0, totedge = 0, totvert = 0; | int a, b, totcol, totmat = 0, totedge = 0, totvert = 0; | ||||
| int totloop = 0, totpoly = 0, vertofs, *matmap = NULL; | int totloop = 0, totpoly = 0, vertofs, *matmap = NULL; | ||||
| int i, haskey = 0, edgeofs, loopofs, polyofs; | int i, haskey = 0, edgeofs, loopofs, polyofs; | ||||
| bool ok = false; | bool ok = false, join_parent = false; | ||||
| bDeformGroup *dg, *odg; | bDeformGroup *dg, *odg; | ||||
| CustomData vdata, edata, fdata, ldata, pdata; | CustomData vdata, edata, fdata, ldata, pdata; | ||||
| if (ob->mode & OB_MODE_EDIT) { | if (ob->mode & OB_MODE_EDIT) { | ||||
| BKE_report(op->reports, RPT_WARNING, "Cannot join while in edit mode"); | BKE_report(op->reports, RPT_WARNING, "Cannot join while in edit mode"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| Show All 15 Lines | if (ob_iter->type == OB_MESH) { | ||||
| totloop += me->totloop; | totloop += me->totloop; | ||||
| totpoly += me->totpoly; | totpoly += me->totpoly; | ||||
| totmat += ob_iter->totcol; | totmat += ob_iter->totcol; | ||||
| if (ob_iter == ob) { | if (ob_iter == ob) { | ||||
| ok = true; | ok = true; | ||||
| } | } | ||||
| if ((ob->parent != NULL) && (ob_iter == ob->parent)) { | |||||
| join_parent = true; | |||||
| } | |||||
| /* check for shapekeys */ | /* check for shapekeys */ | ||||
| if (me->key) { | if (me->key) { | ||||
| haskey++; | haskey++; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| CTX_DATA_END; | CTX_DATA_END; | ||||
| /* Apply parent transform if the active object's parent was joined to it. | |||||
| * Note: This doesn't apply recursive parenting. */ | |||||
| if (join_parent) { | |||||
| ob->parent = NULL; | |||||
| BKE_object_apply_mat4_ex(ob, ob->obmat, ob->parent, ob->parentinv, false); | |||||
| } | |||||
| /* that way the active object is always selected */ | /* that way the active object is always selected */ | ||||
| if (ok == false) { | if (ok == false) { | ||||
| BKE_report(op->reports, RPT_WARNING, "Active object is not a selected mesh"); | BKE_report(op->reports, RPT_WARNING, "Active object is not a selected mesh"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| /* Only join meshes if there are verts to join, | /* Only join meshes if there are verts to join, | ||||
| * there aren't too many, and we only had one mesh selected. */ | * there aren't too many, and we only had one mesh selected. */ | ||||
| ▲ Show 20 Lines • Show All 1,154 Lines • Show Last 20 Lines | |||||