set the index on newly added vert/edge/faces
added BM_ElemIndex_Ensure(...), not used yet.
This commit is contained in:
@@ -87,14 +87,14 @@ struct EditMesh;
|
||||
*
|
||||
*/
|
||||
|
||||
/*BMHeader->type*/
|
||||
/*BMHeader->htype (char) */
|
||||
#define BM_VERT 1
|
||||
#define BM_EDGE 2
|
||||
#define BM_LOOP 4
|
||||
#define BM_FACE 8
|
||||
#define BM_ALL (BM_VERT | BM_EDGE | BM_LOOP | BM_FACE)
|
||||
|
||||
/*BMHeader->flag*/
|
||||
/*BMHeader->hflag (char, all bits used!) */
|
||||
#define BM_SELECT (1<<0)
|
||||
|
||||
#define BM_SEAM (1<<1)
|
||||
@@ -305,6 +305,8 @@ void BM_Kill_Face_Verts(BMesh *bm, BMFace *f) ;
|
||||
/*clear all data in bm*/
|
||||
void BM_Clear_Mesh(BMesh *bm);
|
||||
|
||||
void BM_ElemIndex_Ensure(BMesh *bm, const char hflag);
|
||||
|
||||
/*start/stop edit*/
|
||||
void bmesh_begin_edit(struct BMesh *bm, int flag);
|
||||
void bmesh_end_edit(struct BMesh *bm, int flag);
|
||||
|
||||
@@ -481,3 +481,36 @@ void bmesh_end_edit(BMesh *bm, int flag)
|
||||
BM_Compute_Normals(bm);
|
||||
BM_SelectMode_Flush(bm);
|
||||
}
|
||||
|
||||
void BM_ElemIndex_Ensure(BMesh *bm, const char hflag)
|
||||
{
|
||||
BMIter iter;
|
||||
BMHeader *ele;
|
||||
int index;
|
||||
|
||||
/* TODO, mark arrays as dirty, only calculate if needed! */
|
||||
|
||||
if (hflag & BM_VERT) {
|
||||
index= 0;
|
||||
BM_ITER(ele, &iter, bm, BM_VERTS_OF_MESH, NULL) {
|
||||
BM_SetIndex(ele, index);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
if (hflag & BM_EDGE) {
|
||||
index= 0;
|
||||
BM_ITER(ele, &iter, bm, BM_EDGES_OF_MESH, NULL) {
|
||||
BM_SetIndex(ele, index);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
if (hflag & BM_FACE) {
|
||||
index= 0;
|
||||
BM_ITER(ele, &iter, bm, BM_FACES_OF_MESH, NULL) {
|
||||
BM_SetIndex(ele, index);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,9 @@
|
||||
BMVert *BM_Make_Vert(BMesh *bm, float co[3], const struct BMVert *example)
|
||||
{
|
||||
BMVert *v = BLI_mempool_calloc(bm->vpool);
|
||||
|
||||
|
||||
BM_SetIndex(v, bm->totvert);
|
||||
|
||||
bm->totvert += 1;
|
||||
|
||||
v->head.htype = BM_VERT;
|
||||
@@ -76,7 +78,11 @@ BMEdge *BM_Make_Edge(BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *example, i
|
||||
return (BMEdge*)e;
|
||||
|
||||
e = BLI_mempool_calloc(bm->epool);
|
||||
|
||||
BM_SetIndex(e, bm->totedge);
|
||||
|
||||
bm->totedge += 1;
|
||||
|
||||
e->head.htype = BM_EDGE;
|
||||
|
||||
/*allocate flags*/
|
||||
@@ -221,7 +227,11 @@ BMFace *BM_Make_Face(BMesh *bm, BMVert **verts, BMEdge **edges, int len, int nod
|
||||
}
|
||||
|
||||
f = BLI_mempool_calloc(bm->fpool);
|
||||
|
||||
BM_SetIndex(f, bm->totface);
|
||||
|
||||
bm->totface += 1;
|
||||
|
||||
f->head.htype = BM_FACE;
|
||||
|
||||
startl = lastl = BM_Add_FaceBoundary(bm, (BMFace*)f, verts[0], edges[0]);
|
||||
|
||||
@@ -1254,7 +1254,7 @@ int BMO_VInitOpf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist)
|
||||
state = 1;
|
||||
break;
|
||||
default:
|
||||
printf("unrecognized bmop format char: %c\n", *fmt);
|
||||
printf("%s: unrecognized bmop format char: %c\n", __func__, *fmt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1275,7 +1275,7 @@ int BMO_InitOpf(BMesh *bm, BMOperator *op, const char *fmt, ...)
|
||||
|
||||
va_start(list, fmt);
|
||||
if (!BMO_VInitOpf(bm, op, fmt, list)) {
|
||||
printf("BMO_InitOpf failed\n");
|
||||
printf("%s: failed\n", __func__);
|
||||
va_end(list);
|
||||
return 0;
|
||||
}
|
||||
@@ -1291,7 +1291,7 @@ int BMO_CallOpf(BMesh *bm, const char *fmt, ...)
|
||||
|
||||
va_start(list, fmt);
|
||||
if (!BMO_VInitOpf(bm, &op, fmt, list)) {
|
||||
printf("BMO_CallOpf failed, format is:\n \"%s\"\n", fmt);
|
||||
printf("%s: failed, format is:\n \"%s\"\n", __func__, fmt);
|
||||
va_end(list);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1147,8 +1147,8 @@ static KnifeEdge *knife_find_closest_edge(knifetool_opdata *kcd, float p[3], flo
|
||||
if (cure && p) {
|
||||
if (!kcd->ignore_edge_snapping || !(cure->e)) {
|
||||
if (kcd->snap_midpoints) {
|
||||
interp_v3_v3v3(p, cure->v1->co, cure->v2->co, 0.5f);
|
||||
interp_v3_v3v3(cagep, cure->v1->cageco, cure->v2->cageco, 0.5f);
|
||||
mid_v3_v3v3(p, cure->v1->co, cure->v2->co);
|
||||
mid_v3_v3v3(cagep, cure->v1->cageco, cure->v2->cageco);
|
||||
} else {
|
||||
float d;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user