Fix bad origindex layers for editmode modifiers

Reverts workaround from last commit.
This commit is contained in:
2018-10-23 13:50:43 +11:00
parent e3013fdc3b
commit dbdf653f8e
8 changed files with 28 additions and 22 deletions

View File

@@ -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);
}
/* -------------------------------------------------------------------- */

View File

@@ -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,

View File

@@ -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);

View File

@@ -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])

View File

@@ -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:

View File

@@ -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) {

View File

@@ -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);

View File

@@ -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(