fix own regression [#36443] Vertex to UV index doesn't match with 2.68a
add BM_face_create_verts wrapper for BM_face_create which creates its own edge array.
This commit is contained in:
parent
f6b13c83ab
commit
57f8a252d6
@ -369,6 +369,32 @@ BMFace *BM_face_create(BMesh *bm, BMVert **verts, BMEdge **edges, const int len,
|
||||
return f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper for #BM_face_create when you don't have an edge array
|
||||
*/
|
||||
BMFace *BM_face_create_verts(BMesh *bm, BMVert **vert_arr, const int len, const eBMCreateFlag create_flag,
|
||||
const bool create_edges)
|
||||
{
|
||||
BMEdge **edge_arr = BLI_array_alloca(edge_arr, len);
|
||||
int i, i_prev = len - 1;
|
||||
|
||||
if (create_edges) {
|
||||
for (i = 0; i < len; i++) {
|
||||
edge_arr[i_prev] = BM_edge_create(bm, vert_arr[i_prev], vert_arr[i], NULL, BM_CREATE_NO_DOUBLE);
|
||||
i_prev = i;
|
||||
}
|
||||
}
|
||||
else {
|
||||
edge_arr[i] = BM_edge_exists(vert_arr[i_prev], vert_arr[i]);
|
||||
if (edge_arr[i] == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
i_prev = i;
|
||||
}
|
||||
|
||||
return BM_face_create(bm, vert_arr, edge_arr, len, create_flag);
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
||||
/**
|
||||
|
@ -31,6 +31,7 @@ BMFace *BM_face_copy(BMesh *bm_dst, BMesh *bm_src, BMFace *f,
|
||||
const bool copy_verts, const bool copy_edges);
|
||||
|
||||
typedef enum eBMCreateFlag {
|
||||
BM_CREATE_NOP = 0,
|
||||
/* faces and edges only */
|
||||
BM_CREATE_NO_DOUBLE = (1 << 1),
|
||||
/* Skip CustomData - for all element types data,
|
||||
@ -42,6 +43,8 @@ typedef enum eBMCreateFlag {
|
||||
BMVert *BM_vert_create(BMesh *bm, const float co[3], const BMVert *example, const eBMCreateFlag create_flag);
|
||||
BMEdge *BM_edge_create(BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *example, const eBMCreateFlag create_flag);
|
||||
BMFace *BM_face_create(BMesh *bm, BMVert **verts, BMEdge **edges, const int len, const eBMCreateFlag create_flag);
|
||||
BMFace *BM_face_create_verts(BMesh *bm, BMVert **verts, const int len, const eBMCreateFlag create_flag,
|
||||
const bool create_edges);
|
||||
|
||||
void BM_face_edges_kill(BMesh *bm, BMFace *f);
|
||||
void BM_face_verts_kill(BMesh *bm, BMFace *f);
|
||||
|
@ -933,7 +933,6 @@ static void add_poly(SkinOutput *so,
|
||||
BMVert *v4)
|
||||
{
|
||||
BMVert *verts[4] = {v1, v2, v3, v4};
|
||||
BMEdge *edges[4];
|
||||
BMFace *f;
|
||||
|
||||
BLI_assert(v1 != v2 && v1 != v3 && v1 != v4);
|
||||
@ -941,18 +940,7 @@ static void add_poly(SkinOutput *so,
|
||||
BLI_assert(v3 != v4);
|
||||
BLI_assert(v1 && v2 && v3);
|
||||
|
||||
edges[0] = BM_edge_create(so->bm, v1, v2, NULL, BM_CREATE_NO_DOUBLE);
|
||||
edges[1] = BM_edge_create(so->bm, v2, v3, NULL, BM_CREATE_NO_DOUBLE);
|
||||
if (v4) {
|
||||
edges[2] = BM_edge_create(so->bm, v3, v4, NULL, BM_CREATE_NO_DOUBLE);
|
||||
edges[3] = BM_edge_create(so->bm, v4, v1, NULL, BM_CREATE_NO_DOUBLE);
|
||||
}
|
||||
else {
|
||||
edges[2] = BM_edge_create(so->bm, v3, v1, NULL, BM_CREATE_NO_DOUBLE);
|
||||
edges[3] = NULL;
|
||||
}
|
||||
|
||||
f = BM_face_create(so->bm, verts, edges, v4 ? 4 : 3, BM_CREATE_NO_DOUBLE);
|
||||
f = BM_face_create_verts(so->bm, verts, v4 ? 4 : 3, BM_CREATE_NO_DOUBLE, true);
|
||||
if (so->smd->flag & MOD_SKIN_SMOOTH_SHADING)
|
||||
BM_elem_flag_enable(f, BM_ELEM_SMOOTH);
|
||||
f->mat_nr = so->mat_nr;
|
||||
|
@ -2020,7 +2020,7 @@ static PyObject *bpy_bmfaceseq_new(BPy_BMElemSeq *self, PyObject *args)
|
||||
/* Go ahead and make the face!
|
||||
* --------------------------- */
|
||||
|
||||
f_new = BM_face_create_ngon_verts(bm, vert_array, vert_seq_len, 0, false, true);
|
||||
f_new = BM_face_create_verts(bm, vert_array, vert_seq_len, BM_CREATE_NOP, true);
|
||||
|
||||
if (UNLIKELY(f_new == NULL)) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
|
Loading…
Reference in New Issue
Block a user