Changeset View
Changeset View
Standalone View
Standalone View
source/blender/bmesh/intern/bmesh_mesh_convert.cc
| Show First 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | |||||
| #include "DNA_mesh_types.h" | #include "DNA_mesh_types.h" | ||||
| #include "DNA_meshdata_types.h" | #include "DNA_meshdata_types.h" | ||||
| #include "DNA_modifier_types.h" | #include "DNA_modifier_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "BLI_alloca.h" | #include "BLI_alloca.h" | ||||
| #include "BLI_array.hh" | |||||
| #include "BLI_listbase.h" | #include "BLI_listbase.h" | ||||
| #include "BLI_math_vector.h" | #include "BLI_math_vector.h" | ||||
| #include "BKE_customdata.h" | #include "BKE_customdata.h" | ||||
| #include "BKE_mesh.h" | #include "BKE_mesh.h" | ||||
| #include "BKE_mesh_runtime.h" | #include "BKE_mesh_runtime.h" | ||||
| #include "BKE_multires.h" | #include "BKE_multires.h" | ||||
| #include "BKE_key.h" | #include "BKE_key.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "DEG_depsgraph_query.h" | #include "DEG_depsgraph_query.h" | ||||
| #include "bmesh.h" | #include "bmesh.h" | ||||
| #include "intern/bmesh_private.h" /* For element checking. */ | #include "intern/bmesh_private.h" /* For element checking. */ | ||||
| using blender::Array; | |||||
| void BM_mesh_cd_flag_ensure(BMesh *bm, Mesh *mesh, const char cd_flag) | void BM_mesh_cd_flag_ensure(BMesh *bm, Mesh *mesh, const char cd_flag) | ||||
| { | { | ||||
| const char cd_flag_all = BM_mesh_cd_flag_from_bmesh(bm) | cd_flag; | const char cd_flag_all = BM_mesh_cd_flag_from_bmesh(bm) | cd_flag; | ||||
| BM_mesh_cd_flag_apply(bm, cd_flag_all); | BM_mesh_cd_flag_apply(bm, cd_flag_all); | ||||
| if (mesh) { | if (mesh) { | ||||
| mesh->cd_flag = cd_flag_all; | mesh->cd_flag = cd_flag_all; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 67 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 = (BMVert **)BLI_array_alloca(verts, mp->totloop); | Array<BMVert *, 64> verts(mp->totloop); | ||||
| BMEdge **edges = (BMEdge **)BLI_array_alloca(edges, mp->totloop); | Array<BMEdge *, 64> edges(mp->totloop); | ||||
campbellbarton: Use `BM_DEFAULT_NGON_STACK_SIZE`, otherwise this seems fine. | |||||
| int j; | int j; | ||||
| for (j = 0; j < mp->totloop; j++, ml++) { | for (j = 0; j < mp->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, nullptr, BM_CREATE_SKIP_CD); | return BM_face_create(bm, verts.data(), edges.data(), mp->totloop, nullptr, BM_CREATE_SKIP_CD); | ||||
| } | } | ||||
| 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 984 Lines • Show Last 20 Lines | |||||
Use BM_DEFAULT_NGON_STACK_SIZE, otherwise this seems fine.