diff options
Diffstat (limited to 'source/blender/bmesh/intern')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_construct.c | 8 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_core.c | 1 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_mesh_conv.c | 49 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_mesh_conv.h | 7 |
4 files changed, 36 insertions, 29 deletions
diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index a0eac488c77..fba71b20e7c 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -662,10 +662,10 @@ void BM_mesh_copy_init_customdata(BMesh *bm_dst, BMesh *bm_src, const BMAllocTem allocsize = &bm_mesh_allocsize_default; } - CustomData_copy(&bm_src->vdata, &bm_dst->vdata, CD_MASK_BMESH, CD_CALLOC, 0); - CustomData_copy(&bm_src->edata, &bm_dst->edata, CD_MASK_BMESH, CD_CALLOC, 0); - CustomData_copy(&bm_src->ldata, &bm_dst->ldata, CD_MASK_BMESH, CD_CALLOC, 0); - CustomData_copy(&bm_src->pdata, &bm_dst->pdata, CD_MASK_BMESH, CD_CALLOC, 0); + CustomData_copy(&bm_src->vdata, &bm_dst->vdata, CD_MASK_BMESH.vmask, CD_CALLOC, 0); + CustomData_copy(&bm_src->edata, &bm_dst->edata, CD_MASK_BMESH.emask, CD_CALLOC, 0); + CustomData_copy(&bm_src->ldata, &bm_dst->ldata, CD_MASK_BMESH.lmask, CD_CALLOC, 0); + CustomData_copy(&bm_src->pdata, &bm_dst->pdata, CD_MASK_BMESH.pmask, CD_CALLOC, 0); CustomData_bmesh_init_pool(&bm_dst->vdata, allocsize->totvert, BM_VERT); CustomData_bmesh_init_pool(&bm_dst->edata, allocsize->totedge, BM_EDGE); diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c index 95bfab46619..eead30bcd24 100644 --- a/source/blender/bmesh/intern/bmesh_core.c +++ b/source/blender/bmesh/intern/bmesh_core.c @@ -32,6 +32,7 @@ #include "DNA_meshdata_types.h" +#include "BKE_customdata.h" #include "BKE_mesh.h" #include "bmesh.h" diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.c b/source/blender/bmesh/intern/bmesh_mesh_conv.c index 46a0ed2bddd..c5557eb91c2 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_conv.c +++ b/source/blender/bmesh/intern/bmesh_mesh_conv.c @@ -195,15 +195,15 @@ void BM_mesh_bm_from_me( BMFace *f, **ftable = NULL; float (*keyco)[3] = NULL; int totloops, i; - const int64_t mask = CD_MASK_BMESH | params->cd_mask_extra; - const int64_t mask_loop_only = mask & ~CD_MASK_ORIGINDEX; + CustomData_MeshMasks mask = CD_MASK_BMESH; + CustomData_MeshMasks_update(&mask, ¶ms->cd_mask_extra); if (!me || !me->totvert) { if (me && is_new) { /*no verts? still copy customdata layout*/ - CustomData_copy(&me->vdata, &bm->vdata, mask, CD_ASSIGN, 0); - CustomData_copy(&me->edata, &bm->edata, mask, CD_ASSIGN, 0); - CustomData_copy(&me->ldata, &bm->ldata, mask_loop_only, CD_ASSIGN, 0); - CustomData_copy(&me->pdata, &bm->pdata, mask, CD_ASSIGN, 0); + CustomData_copy(&me->vdata, &bm->vdata, mask.vmask, CD_ASSIGN, 0); + CustomData_copy(&me->edata, &bm->edata, mask.emask, CD_ASSIGN, 0); + CustomData_copy(&me->ldata, &bm->ldata, mask.lmask, CD_ASSIGN, 0); + CustomData_copy(&me->pdata, &bm->pdata, mask.pmask, CD_ASSIGN, 0); CustomData_bmesh_init_pool(&bm->vdata, me->totvert, BM_VERT); CustomData_bmesh_init_pool(&bm->edata, me->totedge, BM_EDGE); @@ -214,10 +214,10 @@ void BM_mesh_bm_from_me( } if (is_new) { - CustomData_copy(&me->vdata, &bm->vdata, mask, CD_CALLOC, 0); - CustomData_copy(&me->edata, &bm->edata, mask, CD_CALLOC, 0); - CustomData_copy(&me->ldata, &bm->ldata, mask_loop_only, CD_CALLOC, 0); - CustomData_copy(&me->pdata, &bm->pdata, mask, CD_CALLOC, 0); + CustomData_copy(&me->vdata, &bm->vdata, mask.vmask, CD_CALLOC, 0); + CustomData_copy(&me->edata, &bm->edata, mask.emask, CD_CALLOC, 0); + CustomData_copy(&me->ldata, &bm->ldata, mask.lmask, CD_CALLOC, 0); + CustomData_copy(&me->pdata, &bm->pdata, mask.pmask, CD_CALLOC, 0); } /* -------------------------------------------------------------------- */ @@ -604,11 +604,12 @@ void BM_mesh_bm_to_me( me->act_face = -1; { - const CustomDataMask mask = CD_MASK_MESH | params->cd_mask_extra; - CustomData_copy(&bm->vdata, &me->vdata, mask, CD_CALLOC, me->totvert); - CustomData_copy(&bm->edata, &me->edata, mask, CD_CALLOC, me->totedge); - CustomData_copy(&bm->ldata, &me->ldata, mask, CD_CALLOC, me->totloop); - CustomData_copy(&bm->pdata, &me->pdata, mask, CD_CALLOC, me->totpoly); + CustomData_MeshMasks mask = CD_MASK_MESH; + CustomData_MeshMasks_update(&mask, ¶ms->cd_mask_extra); + CustomData_copy(&bm->vdata, &me->vdata, mask.vmask, CD_CALLOC, me->totvert); + CustomData_copy(&bm->edata, &me->edata, mask.emask, CD_CALLOC, me->totedge); + CustomData_copy(&bm->ldata, &me->ldata, mask.lmask, CD_CALLOC, me->totloop); + CustomData_copy(&bm->pdata, &me->pdata, mask.pmask, CD_CALLOC, me->totpoly); } CustomData_add_layer(&me->vdata, CD_MVERT, CD_ASSIGN, mvert, me->totvert); @@ -950,11 +951,11 @@ void BM_mesh_bm_to_me( * * \note Was `cddm_from_bmesh_ex` in 2.7x, removed `MFace` support. */ -void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const int64_t cd_mask_extra) +void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const CustomData_MeshMasks *cd_mask_extra) { /* must be an empty mesh. */ BLI_assert(me->totvert == 0); - BLI_assert((cd_mask_extra & CD_MASK_SHAPEKEY) == 0); + BLI_assert(cd_mask_extra == NULL || (cd_mask_extra->vmask & CD_MASK_SHAPEKEY) == 0); me->totvert = bm->totvert; me->totedge = bm->totedge; @@ -973,11 +974,15 @@ void BM_mesh_bm_to_me_for_eval(BMesh *bm, Mesh *me, const int64_t cd_mask_extra) /* don't process shapekeys, we only feed them through the modifier stack as needed, * e.g. for applying modifiers or the like*/ - const CustomDataMask mask = (CD_MASK_DERIVEDMESH | cd_mask_extra) & ~CD_MASK_SHAPEKEY; - CustomData_merge(&bm->vdata, &me->vdata, mask, CD_CALLOC, me->totvert); - CustomData_merge(&bm->edata, &me->edata, mask, CD_CALLOC, me->totedge); - CustomData_merge(&bm->ldata, &me->ldata, mask, CD_CALLOC, me->totloop); - CustomData_merge(&bm->pdata, &me->pdata, mask, CD_CALLOC, me->totpoly); + CustomData_MeshMasks mask = CD_MASK_DERIVEDMESH; + if (cd_mask_extra != NULL) { + CustomData_MeshMasks_update(&mask, cd_mask_extra); + } + mask.vmask &= ~CD_MASK_SHAPEKEY; + CustomData_merge(&bm->vdata, &me->vdata, mask.vmask, CD_CALLOC, me->totvert); + CustomData_merge(&bm->edata, &me->edata, mask.emask, CD_CALLOC, me->totedge); + CustomData_merge(&bm->ldata, &me->ldata, mask.lmask, CD_CALLOC, me->totloop); + CustomData_merge(&bm->pdata, &me->pdata, mask.pmask, CD_CALLOC, me->totpoly); BKE_mesh_update_customdata_pointers(me, false); diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.h b/source/blender/bmesh/intern/bmesh_mesh_conv.h index 52d3b0b8808..30a1e8bffd5 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_conv.h +++ b/source/blender/bmesh/intern/bmesh_mesh_conv.h @@ -24,6 +24,7 @@ * \ingroup bmesh */ +struct CustomData_MeshMasks; struct Main; struct Mesh; @@ -39,7 +40,7 @@ struct BMeshFromMeshParams { uint use_shapekey : 1; /* define the active shape key (index + 1) */ int active_shapekey; - int64_t cd_mask_extra; + struct CustomData_MeshMasks cd_mask_extra; }; void BM_mesh_bm_from_me( BMesh *bm, const struct Mesh *me, @@ -49,7 +50,7 @@ ATTR_NONNULL(1, 3); struct BMeshToMeshParams { /** Update object hook indices & vertex parents. */ uint calc_object_remap : 1; - int64_t cd_mask_extra; + struct CustomData_MeshMasks cd_mask_extra; }; void BM_mesh_bm_to_me( struct Main *bmain, BMesh *bm, struct Mesh *me, @@ -57,7 +58,7 @@ void BM_mesh_bm_to_me( ATTR_NONNULL(2, 3, 4); void BM_mesh_bm_to_me_for_eval( - BMesh *bm, struct Mesh *me, const int64_t cd_mask_extra) + BMesh *bm, struct Mesh *me, const struct CustomData_MeshMasks *cd_mask_extra) ATTR_NONNULL(1, 2); |