From 6953c57d2c9317f46387b3a80c1b68108c2c0dfa Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 22 May 2018 16:22:24 +0200 Subject: Fix T55149: missing mesh custom data after modifier stack, after recent changes. --- source/blender/blenkernel/intern/mesh.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel/intern/mesh.c') diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index aea3e5f4281..f99818f39b9 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -534,15 +534,21 @@ Mesh *BKE_mesh_add(Main *bmain, const char *name) void BKE_mesh_copy_data(Main *bmain, Mesh *me_dst, const Mesh *me_src, const int flag) { const bool do_tessface = ((me_src->totface != 0) && (me_src->totpoly == 0)); /* only do tessface if we have no polys */ + CustomDataMask mask = CD_MASK_MESH; + + if (me_src->id.tag & LIB_TAG_NO_MAIN) { + /* For copies in depsgraph, keep data like origindex and orco. */ + mask |= CD_MASK_DERIVEDMESH; + } me_dst->mat = MEM_dupallocN(me_src->mat); - CustomData_copy(&me_src->vdata, &me_dst->vdata, CD_MASK_MESH, CD_DUPLICATE, me_dst->totvert); - CustomData_copy(&me_src->edata, &me_dst->edata, CD_MASK_MESH, CD_DUPLICATE, me_dst->totedge); - CustomData_copy(&me_src->ldata, &me_dst->ldata, CD_MASK_MESH, CD_DUPLICATE, me_dst->totloop); - CustomData_copy(&me_src->pdata, &me_dst->pdata, CD_MASK_MESH, CD_DUPLICATE, me_dst->totpoly); + CustomData_copy(&me_src->vdata, &me_dst->vdata, mask, CD_DUPLICATE, me_dst->totvert); + CustomData_copy(&me_src->edata, &me_dst->edata, mask, CD_DUPLICATE, me_dst->totedge); + CustomData_copy(&me_src->ldata, &me_dst->ldata, mask, CD_DUPLICATE, me_dst->totloop); + CustomData_copy(&me_src->pdata, &me_dst->pdata, mask, CD_DUPLICATE, me_dst->totpoly); if (do_tessface) { - CustomData_copy(&me_src->fdata, &me_dst->fdata, CD_MASK_MESH, CD_DUPLICATE, me_dst->totface); + CustomData_copy(&me_src->fdata, &me_dst->fdata, mask, CD_DUPLICATE, me_dst->totface); } else { mesh_tessface_clear_intern(me_dst, false); -- cgit v1.2.3