Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/blenkernel/intern/mesh_validate.c25
-rw-r--r--source/blender/bmesh/operators/mesh_conv.c17
-rw-r--r--source/blender/editors/mesh/mesh_data.c17
3 files changed, 47 insertions, 12 deletions
diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c
index e7cec669081..76e74034ec7 100644
--- a/source/blender/blenkernel/intern/mesh_validate.c
+++ b/source/blender/blenkernel/intern/mesh_validate.c
@@ -326,6 +326,7 @@ void BKE_mesh_calc_edges(Mesh *mesh, int update)
MEdge *med, *med_orig;
EdgeHash *eh = BLI_edgehash_new();
int i, totedge, totface = mesh->totface;
+ int med_index;
if(mesh->totedge==0)
update= 0;
@@ -345,7 +346,9 @@ void BKE_mesh_calc_edges(Mesh *mesh, int update)
MLoop *l= &mesh->mloop[mp->loopstart];
int j, l_prev= (l + (mp->totloop-1))->v;
for (j=0; j < mp->totloop; j++, l++) {
- BLI_edgehash_insert(eh, l_prev, l->v, NULL);
+ if (!BLI_edgehash_haskey(eh, l_prev, l->v)) {
+ BLI_edgehash_insert(eh, l_prev, l->v, NULL);
+ }
l_prev= l->v;
}
}
@@ -387,9 +390,29 @@ void BKE_mesh_calc_edges(Mesh *mesh, int update)
BLI_edgehashIterator_getKey(ehi, (int*)&med->v1, (int*)&med->v2);
med->flag = ME_EDGEDRAW|ME_EDGERENDER|SELECT; /* select for newly created meshes which are selected [#25595] */
}
+
+ /* store the new edge index in the hash value */
+ BLI_edgehashIterator_setValue(ehi, SET_INT_IN_POINTER(i));
}
BLI_edgehashIterator_free(ehi);
+ if (mesh->totpoly) {
+ /* second pass, iterate through all loops again and assign
+ the newly created edges to them. */
+ MPoly *mp= mesh->mpoly;
+ for(i=0; i < mesh->totpoly; i++, mp++) {
+ MLoop *l= &mesh->mloop[mp->loopstart];
+ MLoop *l_prev= (l + (mp->totloop-1));
+ int j;
+ for (j=0; j < mp->totloop; j++, l++) {
+ /* lookup hashed edge index */
+ med_index = BLI_edgehash_lookup(eh, l_prev->v, l->v);
+ l_prev->e = med_index;
+ l_prev= l;
+ }
+ }
+ }
+
/* free old CustomData and assign new one */
CustomData_free(&mesh->edata, mesh->totedge);
mesh->edata = edata;
diff --git a/source/blender/bmesh/operators/mesh_conv.c b/source/blender/bmesh/operators/mesh_conv.c
index 901b9c99250..f6ef4729154 100644
--- a/source/blender/bmesh/operators/mesh_conv.c
+++ b/source/blender/bmesh/operators/mesh_conv.c
@@ -131,11 +131,12 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) {
vt[i] = v;
BM_SetIndex(v, i);
+ /*transfer flags*/
+ v->head.flag = MEFlags_To_BMFlags(mvert->flag, BM_VERT);
+
/*this is necassary for selection counts to work properly*/
if(v->head.flag & BM_SELECT) BM_Select_Vert(bm, v, 1);
- /*transfer flags*/
- v->head.flag = MEFlags_To_BMFlags(mvert->flag, BM_VERT);
BM_SetCDf(&bm->vdata, v, CD_BWEIGHT, (float)mvert->bweight / 255.0f);
/*Copy Custom Data*/
@@ -176,11 +177,11 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) {
BM_SetCDf(&bm->edata, e, CD_CREASE, (float)medge->crease / 255.0f);
BM_SetCDf(&bm->edata, e, CD_BWEIGHT, (float)medge->bweight / 255.0f);
- /*this is necassary for selection counts to work properly*/
- if (e->head.flag & BM_SELECT) BM_Select(bm, e, 1);
-
/*transfer flags*/
e->head.flag = MEFlags_To_BMFlags(medge->flag, BM_EDGE);
+
+ /*this is necassary for selection counts to work properly*/
+ if (e->head.flag & BM_SELECT) BM_Select(bm, e, 1);
}
if (!me->totpoly) {
@@ -227,12 +228,12 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) {
continue;
}
- /*this is necassary for selection counts to work properly*/
- if (f->head.flag & BM_SELECT) BM_Select(bm, f, 1);
-
/*transfer flags*/
f->head.flag = MEFlags_To_BMFlags(mpoly->flag, BM_FACE);
+ /*this is necassary for selection counts to work properly*/
+ if (f->head.flag & BM_SELECT) BM_Select(bm, f, 1);
+
f->mat_nr = mpoly->mat_nr;
if (i == me->act_face) bm->act_face = f;
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index 501d065e8d4..325a48c6422 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -629,14 +629,25 @@ void MESH_OT_sticky_remove(wmOperatorType *ot)
void ED_mesh_update(Mesh *mesh, bContext *C, int calc_edges)
{
- if(calc_edges || (mesh->totface && mesh->totedge == 0))
- BKE_mesh_calc_edges(mesh, calc_edges);
-
if(mesh->totface > 0 && mesh->totpoly == 0)
convert_mfaces_to_mpolys(mesh);
+ if(calc_edges || (mesh->totpoly && mesh->totedge == 0))
+ BKE_mesh_calc_edges(mesh, calc_edges);
+
mesh_calc_normals(mesh->mvert, mesh->totvert, mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, NULL, NULL, 0, NULL, NULL);
+ mesh->totface = mesh_recalcTesselation(
+ &mesh->fdata,
+ &mesh->ldata,
+ &mesh->pdata,
+ mesh->mvert,
+ mesh->totface,
+ mesh->totloop,
+ mesh->totpoly,
+ 0,
+ 0);
+
DAG_id_tag_update(&mesh->id, 0);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, mesh);
}