Changeset View
Changeset View
Standalone View
Standalone View
source/blender/bmesh/intern/bmesh_mesh_convert.c
| Show First 20 Lines • Show All 172 Lines • ▼ Show 20 Lines | char BM_mesh_cd_flag_from_bmesh(BMesh *bm) | ||||
| } | } | ||||
| return cd_flag; | return cd_flag; | ||||
| } | } | ||||
| /* Static function for alloc (duplicate in modifiers_bmesh.c) */ | /* Static function for alloc (duplicate in modifiers_bmesh.c) */ | ||||
| static BMFace *bm_face_create_from_mpoly( | static BMFace *bm_face_create_from_mpoly( | ||||
| MPoly *mp, MLoop *ml, BMesh *bm, BMVert **vtable, BMEdge **etable) | MPoly *mp, MLoop *ml, BMesh *bm, BMVert **vtable, BMEdge **etable) | ||||
| { | { | ||||
| BMVert **verts = BLI_array_alloca(verts, mp->totloop); | void *mem_stack[128]; | ||||
| BMEdge **edges = BLI_array_alloca(edges, mp->totloop); | const int totloop = mp->totloop; | ||||
| int j; | void **mem = (totloop <= 2 * ARRAY_SIZE(mem_stack)) ? | ||||
| mem_stack : | |||||
| for (j = 0; j < mp->totloop; j++, ml++) { | MEM_malloc_arrayN(2 * totloop, sizeof(*mem), __func__); | ||||
| BMVert **verts = mem; | |||||
| BMEdge **edges = mem + totloop; | |||||
| for (int j = 0; j < totloop; j++, ml++) { | |||||
| verts[j] = vtable[ml->v]; | verts[j] = vtable[ml->v]; | ||||
| edges[j] = etable[ml->e]; | edges[j] = etable[ml->e]; | ||||
| } | } | ||||
| return BM_face_create(bm, verts, edges, mp->totloop, NULL, BM_CREATE_SKIP_CD); | BMFace *f_new = BM_face_create(bm, verts, edges, mp->totloop, NULL, BM_CREATE_SKIP_CD); | ||||
| if (mem != mem_stack) { | |||||
| MEM_freeN(mem); | |||||
| } | |||||
| return f_new; | |||||
| } | } | ||||
| void BM_mesh_bm_from_me(BMesh *bm, const Mesh *me, const struct BMeshFromMeshParams *params) | void BM_mesh_bm_from_me(BMesh *bm, const Mesh *me, const struct BMeshFromMeshParams *params) | ||||
| { | { | ||||
| const bool is_new = !(bm->totvert || (bm->vdata.totlayer || bm->edata.totlayer || | const bool is_new = !(bm->totvert || (bm->vdata.totlayer || bm->edata.totlayer || | ||||
| bm->pdata.totlayer || bm->ldata.totlayer)); | bm->pdata.totlayer || bm->ldata.totlayer)); | ||||
| MVert *mvert; | MVert *mvert; | ||||
| MEdge *medge; | MEdge *medge; | ||||
| ▲ Show 20 Lines • Show All 978 Lines • Show Last 20 Lines | |||||