diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_mesh_conv.c | 18 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_mesh_conv.h | 1 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_mesh.c | 10 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_bevel.c | 1 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_decimate.c | 9 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_edgesplit.c | 1 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_triangulate.c | 9 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_wireframe.c | 1 |
8 files changed, 28 insertions, 22 deletions
diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.c b/source/blender/bmesh/intern/bmesh_mesh_conv.c index 52d9d2cf445..0beeffceae5 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_conv.c +++ b/source/blender/bmesh/intern/bmesh_mesh_conv.c @@ -209,13 +209,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; if (!me || !me->totvert) { if (me && is_new) { /*no verts? still copy customdata layout*/ - CustomData_copy(&me->vdata, &bm->vdata, CD_MASK_BMESH, CD_ASSIGN, 0); - CustomData_copy(&me->edata, &bm->edata, CD_MASK_BMESH, CD_ASSIGN, 0); - CustomData_copy(&me->ldata, &bm->ldata, CD_MASK_BMESH, CD_ASSIGN, 0); - CustomData_copy(&me->pdata, &bm->pdata, CD_MASK_BMESH, CD_ASSIGN, 0); + 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_bmesh_init_pool(&bm->vdata, me->totvert, BM_VERT); CustomData_bmesh_init_pool(&bm->edata, me->totedge, BM_EDGE); @@ -226,10 +228,10 @@ void BM_mesh_bm_from_me( } if (is_new) { - CustomData_copy(&me->vdata, &bm->vdata, CD_MASK_BMESH, CD_CALLOC, 0); - CustomData_copy(&me->edata, &bm->edata, CD_MASK_BMESH, CD_CALLOC, 0); - CustomData_copy(&me->ldata, &bm->ldata, CD_MASK_BMESH, CD_CALLOC, 0); - CustomData_copy(&me->pdata, &bm->pdata, CD_MASK_BMESH, CD_CALLOC, 0); + 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); } /* -------------------------------------------------------------------- */ diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.h b/source/blender/bmesh/intern/bmesh_mesh_conv.h index a8bef1ee2a2..0560155faa0 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_conv.h +++ b/source/blender/bmesh/intern/bmesh_mesh_conv.h @@ -49,6 +49,7 @@ struct BMeshFromMeshParams { uint use_shapekey : 1; /* define the active shape key (index + 1) */ int active_shapekey; + int64_t cd_mask_extra; }; void BM_mesh_bm_from_me( BMesh *bm, struct Mesh *me, diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index 32c3acbec22..e27bc84c565 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -4427,10 +4427,7 @@ static GPUIndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material( BMFace **ftable = bm_mapped->ftable; for (uint i = 0; i < poly_len; i++) { const int p_orig = p_origindex_mapped[i]; - /* TODO(campbell): fix origindex layer. */ - if ((p_orig >= bm_mapped->totface) || - ((p_orig != ORIGINDEX_NONE) && !BM_elem_flag_test(ftable[p_orig], BM_ELEM_HIDDEN))) - { + if ((p_orig != ORIGINDEX_NONE) && !BM_elem_flag_test(ftable[p_orig], BM_ELEM_HIDDEN)) { const MPoly *mp = &rdata->mpoly[i]; ; const short ma_id = mp->mat_nr < mat_len ? mp->mat_nr : 0; mat_tri_len[ma_id] += (mp->totloop - 2); @@ -4476,10 +4473,7 @@ static GPUIndexBuf **mesh_batch_cache_get_triangles_in_order_split_by_material( for (uint i = 0; i < poly_len; i++) { const int p_orig = p_origindex_mapped[i]; const MPoly *mp = &rdata->mpoly[i]; ; - /* TODO(campbell): fix origindex layer. */ - if ((p_orig >= bm_mapped->totface) || - ((p_orig != ORIGINDEX_NONE) && !BM_elem_flag_test(ftable[p_orig], BM_ELEM_HIDDEN))) - { + if ((p_orig != ORIGINDEX_NONE) && !BM_elem_flag_test(ftable[p_orig], BM_ELEM_HIDDEN)) { const short ma_id = mp->mat_nr < mat_len ? mp->mat_nr : 0; for (int j = 2; j < mp->totloop; j++) { GPU_indexbuf_add_tri_verts(&elb[ma_id], nidx + 0, nidx + 1, nidx + 2); diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c index c071559bffe..8424df8a7bc 100644 --- a/source/blender/modifiers/intern/MOD_bevel.c +++ b/source/blender/modifiers/intern/MOD_bevel.c @@ -377,6 +377,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes .add_key_index = false, .use_shapekey = true, .active_shapekey = ctx->object->shapenr, + .cd_mask_extra = CD_MASK_ORIGINDEX, }); if ((bmd->lim_flags & MOD_BEVEL_VGROUP) && bmd->defgrp_name[0]) diff --git a/source/blender/modifiers/intern/MOD_decimate.c b/source/blender/modifiers/intern/MOD_decimate.c index 7af25a048f8..958b814c970 100644 --- a/source/blender/modifiers/intern/MOD_decimate.c +++ b/source/blender/modifiers/intern/MOD_decimate.c @@ -152,9 +152,12 @@ static Mesh *applyModifier( } bm = BKE_mesh_to_bmesh_ex( - mesh, - &((struct BMeshCreateParams){0}), - &((struct BMeshFromMeshParams){.calc_face_normal = calc_face_normal,})); + mesh, + &(struct BMeshCreateParams){0}, + &(struct BMeshFromMeshParams){ + .calc_face_normal = calc_face_normal, + .cd_mask_extra = CD_MASK_ORIGINDEX, + }); switch (dmd->mode) { case MOD_DECIM_MODE_COLLAPSE: diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c index 58cbbbc7b4d..3b7e1f84ef3 100644 --- a/source/blender/modifiers/intern/MOD_edgesplit.c +++ b/source/blender/modifiers/intern/MOD_edgesplit.c @@ -69,6 +69,7 @@ static Mesh *doEdgeSplit(Mesh *mesh, EdgeSplitModifierData *emd, const ModifierE .add_key_index = false, .use_shapekey = true, .active_shapekey = ctx->object->shapenr, + .cd_mask_extra = CD_MASK_ORIGINDEX, }); if (emd->flags & MOD_EDGESPLIT_FROMANGLE) { diff --git a/source/blender/modifiers/intern/MOD_triangulate.c b/source/blender/modifiers/intern/MOD_triangulate.c index 6c38d208c02..1247c59b3f9 100644 --- a/source/blender/modifiers/intern/MOD_triangulate.c +++ b/source/blender/modifiers/intern/MOD_triangulate.c @@ -47,9 +47,12 @@ static Mesh *triangulate_mesh(Mesh *mesh, const int quad_method, const int ngon_ MEdge *me; bm = BKE_mesh_to_bmesh_ex( - mesh, - &((struct BMeshCreateParams){0}), - &((struct BMeshFromMeshParams){.calc_face_normal = true,})); + mesh, + &((struct BMeshCreateParams){0}), + &((struct BMeshFromMeshParams){ + .calc_face_normal = true, + .cd_mask_extra = CD_MASK_ORIGINDEX, + })); BM_mesh_triangulate(bm, quad_method, ngon_method, false, NULL, NULL, NULL); diff --git a/source/blender/modifiers/intern/MOD_wireframe.c b/source/blender/modifiers/intern/MOD_wireframe.c index 15e26fb5c2e..05fc589a5ad 100644 --- a/source/blender/modifiers/intern/MOD_wireframe.c +++ b/source/blender/modifiers/intern/MOD_wireframe.c @@ -76,6 +76,7 @@ static Mesh *WireframeModifier_do(WireframeModifierData *wmd, Object *ob, Mesh * .add_key_index = false, .use_shapekey = true, .active_shapekey = ob->shapenr, + .cd_mask_extra = CD_MASK_ORIGINDEX, }); BM_mesh_wireframe( |