Fix broken edge rip
The recent element index work broke edge split entirely, because edge rip was trying to use BM_Get/SetIndex across calls to other BMesh operators (which is bad practice). I've converted it instead to use the indices in the BMO layer, which belongs ot the edge split operator and won't be overwritten by BMO operators called in the process of doing the edge split.
This commit is contained in:
@@ -493,6 +493,16 @@ BM_INLINE void *BMO_Get_MapPointer(BMesh *bm, BMOperator *op, const char *slotna
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BM_INLINE void BMO_SetIndex(BMesh *bm, BMHeader *element, int index)
|
||||
{
|
||||
element->flags[bm->stackdepth-1].index = index;
|
||||
}
|
||||
|
||||
BM_INLINE int BMO_GetIndex(BMesh *bm, BMHeader *element)
|
||||
{
|
||||
return element->flags[bm->stackdepth-1].index;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -102,8 +102,8 @@ static BMFace *remake_face(BMesh *bm, EdgeTag *etags, BMFace *f, BMVert **verts,
|
||||
if (l->e != l2->e) {
|
||||
/*set up data for figuring out the two sides of
|
||||
the splits*/
|
||||
BM_SetIndex(l2->e, BM_GetIndex(l->e)); /* set_dirty! */ /* BMESH_TODO, double check this is being set dirty - campbell */
|
||||
et = etags + BM_GetIndex(l->e);
|
||||
BMO_SetIndex(bm, l2->e, BMO_GetIndex(bm, l->e));
|
||||
et = etags + BMO_GetIndex(bm, l->e);
|
||||
|
||||
if (!et->newe1) {
|
||||
et->newe1 = l2->e;
|
||||
@@ -128,7 +128,6 @@ static BMFace *remake_face(BMesh *bm, EdgeTag *etags, BMFace *f, BMVert **verts,
|
||||
BMO_SetFlag(bm, l->e, EDGE_MARK);
|
||||
BMO_SetFlag(bm, l2->e, EDGE_MARK);
|
||||
}
|
||||
bm->elem_index_dirty |= BM_EDGE; /* double check this, see above */
|
||||
|
||||
return f2;
|
||||
}
|
||||
@@ -148,7 +147,7 @@ static void tag_out_edges(BMesh *bm, EdgeTag *etags, BMOperator *UNUSED(op))
|
||||
if (!BMO_TestFlag(bm, e, EDGE_SEAM))
|
||||
continue;
|
||||
|
||||
et = etags + BM_GetIndex(e);
|
||||
et = etags + BMO_GetIndex(bm, e);
|
||||
if (!et->tag && e->l) {
|
||||
break;
|
||||
}
|
||||
@@ -165,7 +164,7 @@ static void tag_out_edges(BMesh *bm, EdgeTag *etags, BMOperator *UNUSED(op))
|
||||
v = i ? l->next->v : l->v;
|
||||
|
||||
while (1) {
|
||||
et = etags + BM_GetIndex(l->e);
|
||||
et = etags + BMO_GetIndex(bm, l->e);
|
||||
if (et->newe1 == l->e) {
|
||||
if (et->newe1) {
|
||||
BMO_SetFlag(bm, et->newe1, EDGE_RET1);
|
||||
@@ -247,8 +246,10 @@ void bmesh_edgesplitop_exec(BMesh *bm, BMOperator *op)
|
||||
}
|
||||
|
||||
etags = MEM_callocN(sizeof(EdgeTag)*bm->totedge, "EdgeTag");
|
||||
|
||||
BM_ElemIndex_Ensure(bm, BM_EDGE);
|
||||
|
||||
BM_ITER_INDEX(e, &iter, bm, BM_EDGES_OF_MESH, NULL, i) {
|
||||
BMO_SetIndex(bm, e, i);
|
||||
}
|
||||
|
||||
#ifdef ETV
|
||||
# undef ETV
|
||||
@@ -280,7 +281,7 @@ void bmesh_edgesplitop_exec(BMesh *bm, BMOperator *op)
|
||||
if (!BMO_TestFlag(bm, l->e, EDGE_SEAM)) {
|
||||
if (!verts[i]) {
|
||||
|
||||
et = etags + BM_GetIndex(l->e);
|
||||
et = etags + BMO_GetIndex(bm, l->e);
|
||||
if (ETV(et, l->v, l)) {
|
||||
verts[i] = ETV(et, l->v, l);
|
||||
}
|
||||
@@ -335,7 +336,7 @@ void bmesh_edgesplitop_exec(BMesh *bm, BMOperator *op)
|
||||
} while (l3 != l2 && !BMO_TestFlag(bm, l3->e, EDGE_SEAM));
|
||||
|
||||
if (l3 == NULL || (BMO_TestFlag(bm, l3->e, EDGE_SEAM) && l3->e != l->e)) {
|
||||
et = etags + BM_GetIndex(l2->e);
|
||||
et = etags + BMO_GetIndex(bm, l2->e);
|
||||
if (ETV(et, v, l2) == NULL) {
|
||||
v2 = BM_Make_Vert(bm, v->co, v);
|
||||
|
||||
@@ -349,7 +350,7 @@ void bmesh_edgesplitop_exec(BMesh *bm, BMOperator *op)
|
||||
l3 = l3->radial_next;
|
||||
l3 = BM_OtherFaceLoop(l3->e, l3->f, v);
|
||||
|
||||
et = etags + BM_GetIndex(l3->e);
|
||||
et = etags + BMO_GetIndex(bm, l3->e);
|
||||
} while (l3 != l2 && !BMO_TestFlag(bm, l3->e, EDGE_SEAM));
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user