diff options
Diffstat (limited to 'source/blender/editors/mesh/meshtools.c')
-rw-r--r-- | source/blender/editors/mesh/meshtools.c | 100 |
1 files changed, 50 insertions, 50 deletions
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 802922ab799..786b27ee816 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -286,7 +286,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_WARNING, "Cannot join while in edit mode"); return OPERATOR_CANCELLED; } - + /* ob is the object we are adding geometry to */ if (!ob || ob->type != OB_MESH) { BKE_report(op->reports, RPT_WARNING, "Active object is not a mesh"); @@ -306,23 +306,23 @@ int join_mesh_exec(bContext *C, wmOperator *op) totloop += me->totloop; totpoly += me->totpoly; totmat += base->object->totcol; - + if (base->object == ob) ok = true; - + /* check for shapekeys */ if (me->key) haskey++; } } CTX_DATA_END; - - /* that way the active object is always selected */ + + /* that way the active object is always selected */ if (ok == false) { BKE_report(op->reports, RPT_WARNING, "Active object is not a selected mesh"); return OPERATOR_CANCELLED; } - + /* only join meshes if there are verts to join, there aren't too many, and we only had one mesh selected */ me = (Mesh *)ob->data; key = me->key; @@ -331,7 +331,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_WARNING, "No mesh data to join"); return OPERATOR_CANCELLED; } - + if (totvert > MESH_MAX_VERTS) { BKE_reportf(op->reports, RPT_WARNING, "Joining results in %d vertices, limit is %ld", totvert, MESH_MAX_VERTS); return OPERATOR_CANCELLED; @@ -346,23 +346,23 @@ int join_mesh_exec(bContext *C, wmOperator *op) matmap = MEM_callocN(sizeof(*matmap) * totmat, "join_mesh matmap"); } totcol = ob->totcol; - + /* obact materials in new main array, is nicer start! */ for (a = 0; a < ob->totcol; a++) { matar[a] = give_current_material(ob, a + 1); id_us_plus((ID *)matar[a]); /* increase id->us : will be lowered later */ } - + /* - if destination mesh had shapekeys, move them somewhere safe, and set up placeholders * with arrays that are large enough to hold shapekey data for all meshes - * - if destination mesh didn't have shapekeys, but we encountered some in the meshes we're + * - if destination mesh didn't have shapekeys, but we encountered some in the meshes we're * joining, set up a new keyblock and assign to the mesh */ if (key) { /* make a duplicate copy that will only be used here... (must remember to free it!) */ nkey = BKE_key_copy(bmain, key); - + /* for all keys in old block, clear data-arrays */ for (kb = key->block.first; kb; kb = kb->next) { if (kb->data) MEM_freeN(kb->data); @@ -375,14 +375,14 @@ int join_mesh_exec(bContext *C, wmOperator *op) key = me->key = BKE_key_add((ID *)me); key->type = KEY_RELATIVE; } - + /* first pass over objects - copying materials and vertexgroups across */ CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { /* 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; - + /* Join this object's vertex groups to the base one's */ for (dg = base->object->defbase.first; dg; dg = dg->next) { /* See if this group exists in the object (if it doesn't, add it to the end) */ @@ -394,8 +394,8 @@ int join_mesh_exec(bContext *C, wmOperator *op) } if (ob->defbase.first && ob->actdef == 0) ob->actdef = 1; - - + + 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) { @@ -419,7 +419,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) } } } - + /* if this mesh has shapekeys, check if destination mesh already has matching entries too */ if (me->key && key) { /* for remapping KeyBlock.relative */ @@ -481,7 +481,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) edgeofs = 0; loopofs = 0; polyofs = 0; - + /* inverse transform for all selected meshes in this object */ invert_m4_m4(imat, ob->obmat); @@ -522,10 +522,10 @@ int join_mesh_exec(bContext *C, wmOperator *op) } } CTX_DATA_END; - + /* return to mesh we're merging to */ me = ob->data; - + CustomData_free(&me->vdata, me->totvert); CustomData_free(&me->edata, me->totedge); CustomData_free(&me->ldata, me->totloop); @@ -546,7 +546,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) /* update normals in case objects with non-uniform scale are joined */ BKE_mesh_calc_normals(me); - + /* old material array */ for (a = 1; a <= ob->totcol; a++) { ma = ob->mat[a - 1]; @@ -573,13 +573,13 @@ int join_mesh_exec(bContext *C, wmOperator *op) /* other mesh users */ test_all_objects_materials(bmain, (ID *)me); - + /* free temp copy of destination shapekeys (if applicable) */ if (nkey) { /* We can assume nobody is using that ID currently. */ BKE_libblock_free_ex(bmain, nkey, false, false); } - + /* ensure newly inserted keys are time sorted */ if (key && (key->type != KEY_RELATIVE)) { BKE_key_sort(key); @@ -599,7 +599,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) /*********************** JOIN AS SHAPES ***************************/ -/* Append selected meshes vertex locations as shapes of the active mesh, +/* Append selected meshes vertex locations as shapes of the active mesh, * return 0 if no join is made (error) and 1 of the join is done */ int join_mesh_shapes_exec(bContext *C, wmOperator *op) @@ -613,14 +613,14 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op) Key *key = me->key; KeyBlock *kb; bool ok = false, nonequal_verts = false; - + CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { if (base->object == ob) continue; - + if (base->object->type == OB_MESH) { selme = (Mesh *)base->object->data; - + if (selme->totvert == me->totvert) ok = true; else @@ -628,7 +628,7 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op) } } CTX_DATA_END; - + if (!ok) { if (nonequal_verts) BKE_report(op->reports, RPT_WARNING, "Selected meshes must have equal numbers of vertices"); @@ -636,7 +636,7 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_WARNING, "No additional selected meshes with equal vertex count to join"); return OPERATOR_CANCELLED; } - + if (key == NULL) { key = me->key = BKE_key_add((ID *)me); key->type = KEY_RELATIVE; @@ -645,32 +645,32 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op) kb = BKE_keyblock_add(key, NULL); BKE_keyblock_convert_from_mesh(me, kb); } - + /* now ready to add new keys from selected meshes */ CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { if (base->object == ob) continue; - + if (base->object->type == OB_MESH) { selme = (Mesh *)base->object->data; - + if (selme->totvert == me->totvert) { dm = mesh_get_derived_deform(depsgraph, scene, base->object, CD_MASK_BAREMESH); - + if (!dm) continue; - + kb = BKE_keyblock_add(key, base->object->id.name + 2); - + DM_to_meshkey(dm, me, kb); - + dm->release(dm); } } } CTX_DATA_END; - + WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); - + return OPERATOR_FINISHED; } @@ -739,12 +739,12 @@ static int mesh_get_x_mirror_vert_spatial(Object *ob, DerivedMesh *dm, int index Mesh *me = ob->data; MVert *mvert = dm ? dm->getVertArray(dm) : me->mvert; float vec[3]; - + mvert = &mvert[index]; vec[0] = -mvert->co[0]; vec[1] = mvert->co[1]; vec[2] = mvert->co[2]; - + return ED_mesh_mirror_spatial_table(ob, NULL, dm, vec, 'u'); } @@ -802,7 +802,7 @@ static BMVert *editbmesh_get_x_mirror_vert_spatial(Object *ob, BMEditMesh *em, c { float vec[3]; int i; - + /* ignore nan verts */ if ((isfinite(co[0]) == false) || (isfinite(co[1]) == false) || @@ -810,11 +810,11 @@ static BMVert *editbmesh_get_x_mirror_vert_spatial(Object *ob, BMEditMesh *em, c { return NULL; } - + vec[0] = -co[0]; vec[1] = co[1]; vec[2] = co[2]; - + i = ED_mesh_mirror_spatial_table(ob, em, NULL, vec, 'u'); if (i != -1) { return BM_vert_at_index(em->bm, i); @@ -831,14 +831,14 @@ static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob, struct BMEditMesh *e if (index == -1) { BMIter iter; BMVert *v; - + index = 0; BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) { if (v == eve) break; index++; } - + if (index == em->bm->totvert) { return NULL; } @@ -849,7 +849,7 @@ static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob, struct BMEditMesh *e if (poinval != -1) return (BMVert *)(poinval); return NULL; -} +} BMVert *editbmesh_get_x_mirror_vert(Object *ob, struct BMEditMesh *em, BMVert *eve, const float co[3], int index, const bool use_topology) { @@ -921,19 +921,19 @@ static float *editmesh_get_mirror_uv(BMEditMesh *em, int axis, float *uv, float { BMIter iter; BMFace *efa; - + BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { uv_poly_center(efa, cent, cd_loop_uv_offset); - + if ( (fabsf(cent[0] - cent_vec[0]) < 0.001f) && (fabsf(cent[1] - cent_vec[1]) < 0.001f) ) { BMIter liter; BMLoop *l; - + BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { MLoopUV *luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); if ( (fabsf(luv->uv[0] - vec[0]) < 0.001f) && (fabsf(luv->uv[1] - vec[1]) < 0.001f) ) { return luv->uv; - + } } } @@ -982,7 +982,7 @@ static int mirror_facerotation(MFace *a, MFace *b) else if (a->v2 == b->v1 && a->v3 == b->v2 && a->v1 == b->v3) return 2; } - + return -1; } |