diff options
Diffstat (limited to 'source/blender/blenkernel/intern/data_transfer.c')
-rw-r--r-- | source/blender/blenkernel/intern/data_transfer.c | 282 |
1 files changed, 140 insertions, 142 deletions
diff --git a/source/blender/blenkernel/intern/data_transfer.c b/source/blender/blenkernel/intern/data_transfer.c index 3639649eab5..208adf53bef 100644 --- a/source/blender/blenkernel/intern/data_transfer.c +++ b/source/blender/blenkernel/intern/data_transfer.c @@ -42,12 +42,10 @@ #include "BLI_blenlib.h" #include "BLI_utildefines.h" -#include "BKE_cdderivedmesh.h" #include "BKE_context.h" #include "BKE_customdata.h" #include "BKE_data_transfer.h" #include "BKE_deform.h" -#include "BKE_DerivedMesh.h" #include "BKE_mesh.h" #include "BKE_mesh_mapping.h" #include "BKE_mesh_runtime.h" @@ -257,77 +255,76 @@ int BKE_object_data_transfer_dttype_to_srcdst_index(const int dtdata_type) /* Generic pre/post processing, only used by custom loop normals currently. */ static void data_transfer_dtdata_type_preprocess( - Object *UNUSED(ob_src), Object *UNUSED(ob_dst), DerivedMesh *dm_src, DerivedMesh *dm_dst, Mesh *me_dst, - const int dtdata_type, const bool dirty_nors_dst, const bool use_split_nors_src, const float split_angle_src) + Mesh *dm_src, Mesh *dm_dst, + const int dtdata_type, const bool dirty_nors_dst) { if (dtdata_type == DT_TYPE_LNOR) { /* Compute custom normals into regular loop normals, which will be used for the transfer. */ - MVert *verts_dst = dm_dst ? dm_dst->getVertArray(dm_dst) : me_dst->mvert; - const int num_verts_dst = dm_dst ? dm_dst->getNumVerts(dm_dst) : me_dst->totvert; - MEdge *edges_dst = dm_dst ? dm_dst->getEdgeArray(dm_dst) : me_dst->medge; - const int num_edges_dst = dm_dst ? dm_dst->getNumEdges(dm_dst) : me_dst->totedge; - MPoly *polys_dst = dm_dst ? dm_dst->getPolyArray(dm_dst) : me_dst->mpoly; - const int num_polys_dst = dm_dst ? dm_dst->getNumPolys(dm_dst) : me_dst->totpoly; - MLoop *loops_dst = dm_dst ? dm_dst->getLoopArray(dm_dst) : me_dst->mloop; - const int num_loops_dst = dm_dst ? dm_dst->getNumLoops(dm_dst) : me_dst->totloop; - CustomData *pdata_dst = dm_dst ? dm_dst->getPolyDataLayout(dm_dst) : &me_dst->pdata; - CustomData *ldata_dst = dm_dst ? dm_dst->getLoopDataLayout(dm_dst) : &me_dst->ldata; - - const bool use_split_nors_dst = (me_dst->flag & ME_AUTOSMOOTH) != 0; - const float split_angle_dst = me_dst->smoothresh; - - dm_src->calcLoopNormals(dm_src, use_split_nors_src, split_angle_src); + MVert *verts_dst = dm_dst->mvert; + const int num_verts_dst = dm_dst->totvert; + MEdge *edges_dst = dm_dst->medge; + const int num_edges_dst = dm_dst->totedge; + MPoly *polys_dst = dm_dst->mpoly; + const int num_polys_dst = dm_dst->totpoly; + MLoop *loops_dst = dm_dst->mloop; + const int num_loops_dst = dm_dst->totloop; + CustomData *pdata_dst = &dm_dst->pdata; + CustomData *ldata_dst = &dm_dst->ldata; + + const bool use_split_nors_dst = (dm_dst->flag & ME_AUTOSMOOTH) != 0; + const float split_angle_dst = dm_dst->smoothresh; + + BKE_mesh_calc_normals_split(dm_src); + + float (*poly_nors_dst)[3]; + float (*loop_nors_dst)[3]; + short (*custom_nors_dst)[2] = CustomData_get_layer(ldata_dst, CD_CUSTOMLOOPNORMAL); - if (dm_dst) { - dm_dst->calcLoopNormals(dm_dst, use_split_nors_dst, split_angle_dst); - } - else { - float (*poly_nors_dst)[3]; - float (*loop_nors_dst)[3]; - short (*custom_nors_dst)[2] = CustomData_get_layer(ldata_dst, CD_CUSTOMLOOPNORMAL); - - /* Cache poly nors into a temp CDLayer. */ - poly_nors_dst = CustomData_get_layer(pdata_dst, CD_NORMAL); - if (dirty_nors_dst || !poly_nors_dst) { - if (!poly_nors_dst) { - poly_nors_dst = CustomData_add_layer(pdata_dst, CD_NORMAL, CD_CALLOC, NULL, num_polys_dst); - CustomData_set_layer_flag(pdata_dst, CD_NORMAL, CD_FLAG_TEMPORARY); - } - BKE_mesh_calc_normals_poly(verts_dst, NULL, num_verts_dst, loops_dst, polys_dst, - num_loops_dst, num_polys_dst, poly_nors_dst, true); - } - /* Cache loop nors into a temp CDLayer. */ - loop_nors_dst = CustomData_get_layer(ldata_dst, CD_NORMAL); - if (dirty_nors_dst || loop_nors_dst) { - if (!loop_nors_dst) { - loop_nors_dst = CustomData_add_layer(ldata_dst, CD_NORMAL, CD_CALLOC, NULL, num_loops_dst); - CustomData_set_layer_flag(ldata_dst, CD_NORMAL, CD_FLAG_TEMPORARY); - } - BKE_mesh_normals_loop_split(verts_dst, num_verts_dst, edges_dst, num_edges_dst, - loops_dst, loop_nors_dst, num_loops_dst, - polys_dst, (const float (*)[3])poly_nors_dst, num_polys_dst, - use_split_nors_dst, split_angle_dst, NULL, custom_nors_dst, NULL); - } + /* Cache poly nors into a temp CDLayer. */ + poly_nors_dst = CustomData_get_layer(pdata_dst, CD_NORMAL); + const bool do_poly_nors_dst = (poly_nors_dst == NULL); + if (do_poly_nors_dst) { + poly_nors_dst = CustomData_add_layer(pdata_dst, CD_NORMAL, CD_CALLOC, NULL, num_polys_dst); + CustomData_set_layer_flag(pdata_dst, CD_NORMAL, CD_FLAG_TEMPORARY); + } + if (dirty_nors_dst || do_poly_nors_dst) { + BKE_mesh_calc_normals_poly( + verts_dst, NULL, num_verts_dst, loops_dst, polys_dst, + num_loops_dst, num_polys_dst, poly_nors_dst, true); + } + /* Cache loop nors into a temp CDLayer. */ + loop_nors_dst = CustomData_get_layer(ldata_dst, CD_NORMAL); + const bool do_loop_nors_dst = (loop_nors_dst == NULL); + if (do_loop_nors_dst) { + loop_nors_dst = CustomData_add_layer(ldata_dst, CD_NORMAL, CD_CALLOC, NULL, num_loops_dst); + CustomData_set_layer_flag(ldata_dst, CD_NORMAL, CD_FLAG_TEMPORARY); + } + if (dirty_nors_dst || do_loop_nors_dst) { + BKE_mesh_normals_loop_split( + verts_dst, num_verts_dst, edges_dst, num_edges_dst, + loops_dst, loop_nors_dst, num_loops_dst, + polys_dst, (const float (*)[3])poly_nors_dst, num_polys_dst, + use_split_nors_dst, split_angle_dst, NULL, custom_nors_dst, NULL); } } } static void data_transfer_dtdata_type_postprocess( - Object *UNUSED(ob_src), Object *UNUSED(ob_dst), DerivedMesh *UNUSED(dm_src), DerivedMesh *dm_dst, Mesh *me_dst, + Object *UNUSED(ob_src), Object *UNUSED(ob_dst), Mesh *UNUSED(dm_src), Mesh *dm_dst, Mesh *me_dst, const int dtdata_type, const bool changed) { if (dtdata_type == DT_TYPE_LNOR) { /* Bake edited destination loop normals into custom normals again. */ - MVert *verts_dst = dm_dst ? dm_dst->getVertArray(dm_dst) : me_dst->mvert; - const int num_verts_dst = dm_dst ? dm_dst->getNumVerts(dm_dst) : me_dst->totvert; - MEdge *edges_dst = dm_dst ? dm_dst->getEdgeArray(dm_dst) : me_dst->medge; - const int num_edges_dst = dm_dst ? dm_dst->getNumEdges(dm_dst) : me_dst->totedge; - MPoly *polys_dst = dm_dst ? dm_dst->getPolyArray(dm_dst) : me_dst->mpoly; - const int num_polys_dst = dm_dst ? dm_dst->getNumPolys(dm_dst) : me_dst->totpoly; - MLoop *loops_dst = dm_dst ? dm_dst->getLoopArray(dm_dst) : me_dst->mloop; - const int num_loops_dst = dm_dst ? dm_dst->getNumLoops(dm_dst) : me_dst->totloop; - CustomData *pdata_dst = dm_dst ? dm_dst->getPolyDataLayout(dm_dst) : &me_dst->pdata; - CustomData *ldata_dst = dm_dst ? dm_dst->getLoopDataLayout(dm_dst) : &me_dst->ldata; + MVert *verts_dst = dm_dst ? dm_dst->mvert : me_dst->mvert; + const int num_verts_dst = dm_dst ? dm_dst->totvert : me_dst->totvert; + MEdge *edges_dst = dm_dst ? dm_dst->medge : me_dst->medge; + const int num_edges_dst = dm_dst ? dm_dst->totedge : me_dst->totedge; + MPoly *polys_dst = dm_dst ? dm_dst->mpoly : me_dst->mpoly; + const int num_polys_dst = dm_dst ? dm_dst->totpoly : me_dst->totpoly; + MLoop *loops_dst = dm_dst ? dm_dst->mloop : me_dst->mloop; + const int num_loops_dst = dm_dst ? dm_dst->totloop : me_dst->totloop; + CustomData *pdata_dst = dm_dst ? &dm_dst->pdata : &me_dst->pdata; + CustomData *ldata_dst = dm_dst ? &dm_dst->ldata : &me_dst->ldata; const float (*poly_nors_dst)[3] = CustomData_get_layer(pdata_dst, CD_NORMAL); float (*loop_nors_dst)[3] = CustomData_get_layer(ldata_dst, CD_NORMAL); @@ -763,7 +760,7 @@ static bool data_transfer_layersmapping_cdlayers( } static bool data_transfer_layersmapping_generate( - ListBase *r_map, Object *ob_src, Object *ob_dst, DerivedMesh *dm_src, DerivedMesh *dm_dst, Mesh *me_dst, + ListBase *r_map, Object *ob_src, Object *ob_dst, Mesh *dm_src, Mesh *dm_dst, Mesh *me_dst, const int elem_type, int cddata_type, int mix_mode, float mix_factor, const float *mix_weights, const int num_elem_dst, const bool use_create, const bool use_delete, const int fromlayers, const int tolayers, SpaceTransform *space_transform) @@ -775,8 +772,8 @@ static bool data_transfer_layersmapping_generate( if (elem_type == ME_VERT) { if (!(cddata_type & CD_FAKE)) { - cd_src = dm_src->getVertDataLayout(dm_src); - cd_dst = dm_dst ? dm_dst->getVertDataLayout(dm_dst) : &me_dst->vdata; + cd_src = &dm_src->vdata; + cd_dst = dm_dst ? &dm_dst->vdata : &me_dst->vdata; if (!data_transfer_layersmapping_cdlayers(r_map, cddata_type, mix_mode, mix_factor, mix_weights, num_elem_dst, use_create, use_delete, @@ -809,10 +806,10 @@ static bool data_transfer_layersmapping_generate( } if (r_map) { data_transfer_layersmapping_add_item(r_map, cddata_type, mix_mode, mix_factor, mix_weights, - dm_src->getVertArray(dm_src), - dm_dst ? dm_dst->getVertArray(dm_dst) : me_dst->mvert, - dm_src->getNumVerts(dm_src), - dm_dst ? dm_dst->getNumVerts(dm_dst) : me_dst->totvert, + dm_src->mvert, + dm_dst ? dm_dst->mvert : me_dst->mvert, + dm_src->totvert, + dm_dst ? dm_dst->totvert : me_dst->totvert, elem_size, data_size, data_offset, data_flag, data_transfer_interp_char, interp_data); } @@ -821,8 +818,8 @@ static bool data_transfer_layersmapping_generate( else if (cddata_type == CD_FAKE_MDEFORMVERT) { bool ret; - cd_src = dm_src->getVertDataLayout(dm_src); - cd_dst = dm_dst ? dm_dst->getVertDataLayout(dm_dst) : &me_dst->vdata; + cd_src = &dm_src->vdata; + cd_dst = dm_dst ? &dm_dst->vdata : &me_dst->vdata; ret = data_transfer_layersmapping_vgroups(r_map, mix_mode, mix_factor, mix_weights, num_elem_dst, use_create, use_delete, @@ -840,8 +837,8 @@ static bool data_transfer_layersmapping_generate( } else if (elem_type == ME_EDGE) { if (!(cddata_type & CD_FAKE)) { /* Unused for edges, currently... */ - cd_src = dm_src->getEdgeDataLayout(dm_src); - cd_dst = dm_dst ? dm_dst->getEdgeDataLayout(dm_dst) : &me_dst->edata; + cd_src = &dm_src->edata; + cd_dst = dm_dst ? &dm_dst->edata : &me_dst->edata; if (!data_transfer_layersmapping_cdlayers(r_map, cddata_type, mix_mode, mix_factor, mix_weights, num_elem_dst, use_create, use_delete, @@ -874,10 +871,10 @@ static bool data_transfer_layersmapping_generate( } if (r_map) { data_transfer_layersmapping_add_item(r_map, cddata_type, mix_mode, mix_factor, mix_weights, - dm_src->getEdgeArray(dm_src), - dm_dst ? dm_dst->getEdgeArray(dm_dst) : me_dst->medge, - dm_src->getNumEdges(dm_src), - dm_dst ? dm_dst->getNumEdges(dm_dst) : me_dst->totedge, + dm_src->medge, + dm_dst ? dm_dst->medge : me_dst->medge, + dm_src->totedge, + dm_dst ? dm_dst->totedge : me_dst->totedge, elem_size, data_size, data_offset, data_flag, data_transfer_interp_char, interp_data); } @@ -903,10 +900,10 @@ static bool data_transfer_layersmapping_generate( } if (r_map) { data_transfer_layersmapping_add_item(r_map, cddata_type, mix_mode, mix_factor, mix_weights, - dm_src->getEdgeArray(dm_src), - dm_dst ? dm_dst->getEdgeArray(dm_dst) : me_dst->medge, - dm_src->getNumEdges(dm_src), - dm_dst ? dm_dst->getNumEdges(dm_dst) : me_dst->totedge, + dm_src->medge, + dm_dst ? dm_dst->medge : me_dst->medge, + dm_src->totedge, + dm_dst ? dm_dst->totedge : me_dst->totedge, elem_size, data_size, data_offset, data_flag, data_transfer_interp_char, interp_data); } @@ -920,10 +917,10 @@ static bool data_transfer_layersmapping_generate( data_transfer_layersmapping_add_item( r_map, cddata_type, mix_mode, mix_factor, mix_weights, - dm_src->getEdgeArray(dm_src), - dm_dst ? dm_dst->getEdgeArray(dm_dst) : me_dst->medge, - dm_src->getNumEdges(dm_src), - dm_dst ? dm_dst->getNumEdges(dm_dst) : me_dst->totedge, + dm_src->medge, + dm_dst ? dm_dst->medge : me_dst->medge, + dm_src->totedge, + dm_dst ? dm_dst->totedge : me_dst->totedge, elem_size, data_size, data_offset, data_flag, NULL, interp_data); return true; } @@ -943,8 +940,8 @@ static bool data_transfer_layersmapping_generate( } if (!(cddata_type & CD_FAKE)) { - cd_src = dm_src->getLoopDataLayout(dm_src); - cd_dst = dm_dst ? dm_dst->getLoopDataLayout(dm_dst) : &me_dst->ldata; + cd_src = &dm_src->ldata; + cd_dst = dm_dst ? &dm_dst->ldata : &me_dst->ldata; if (!data_transfer_layersmapping_cdlayers( r_map, cddata_type, mix_mode, mix_factor, mix_weights, @@ -967,8 +964,8 @@ static bool data_transfer_layersmapping_generate( } if (!(cddata_type & CD_FAKE)) { - cd_src = dm_src->getPolyDataLayout(dm_src); - cd_dst = dm_dst ? dm_dst->getPolyDataLayout(dm_dst) : &me_dst->pdata; + cd_src = &dm_src->pdata; + cd_dst = dm_dst ? &dm_dst->pdata : &me_dst->pdata; if (!data_transfer_layersmapping_cdlayers( r_map, cddata_type, mix_mode, mix_factor, mix_weights, @@ -989,10 +986,10 @@ static bool data_transfer_layersmapping_generate( data_transfer_layersmapping_add_item( r_map, cddata_type, mix_mode, mix_factor, mix_weights, - dm_src->getPolyArray(dm_src), - dm_dst ? dm_dst->getPolyArray(dm_dst) : me_dst->mpoly, - dm_src->getNumPolys(dm_src), - dm_dst ? dm_dst->getNumPolys(dm_dst) : me_dst->totpoly, + dm_src->mpoly, + dm_dst ? dm_dst->mpoly : me_dst->mpoly, + dm_src->totpoly, + dm_dst ? dm_dst->totpoly : me_dst->totpoly, elem_size, data_size, data_offset, data_flag, NULL, interp_data); return true; } @@ -1015,7 +1012,7 @@ void BKE_object_data_transfer_layout( Object *ob_src, Object *ob_dst, const int data_types, const bool use_delete, const int fromlayers_select[DT_MULTILAYER_INDEX_MAX], const int tolayers_select[DT_MULTILAYER_INDEX_MAX]) { - DerivedMesh *dm_src; + Mesh *dm_src; Mesh *me_dst; int i; @@ -1029,7 +1026,7 @@ void BKE_object_data_transfer_layout( /* Get source DM.*/ dm_src_mask |= BKE_object_data_transfer_dttypes_to_cdmask(data_types); - dm_src = mesh_get_derived_final(depsgraph, scene, ob_src, dm_src_mask); + dm_src = mesh_get_eval_final(depsgraph, scene, ob_src, dm_src_mask); if (!dm_src) { return; } @@ -1087,7 +1084,7 @@ void BKE_object_data_transfer_layout( } bool BKE_object_data_transfer_dm( - struct Depsgraph *depsgraph, Scene *scene, Object *ob_src, Object *ob_dst, DerivedMesh *dm_dst, + struct Depsgraph *depsgraph, Scene *scene, Object *ob_src, Object *ob_dst, Mesh *dm_dst, const int data_types, bool use_create, const int map_vert_mode, const int map_edge_mode, const int map_loop_mode, const int map_poly_mode, SpaceTransform *space_transform, const bool auto_transform, const float max_distance, const float ray_radius, const float islands_handling_precision, @@ -1103,8 +1100,8 @@ bool BKE_object_data_transfer_dm( SpaceTransform auto_space_transform; - DerivedMesh *dm_src; - Mesh *me_dst, *me_src; + Mesh *dm_src; + Mesh *me_dst; bool dirty_nors_dst = true; /* Assumed always true if not using a dm as destination. */ int i; @@ -1124,15 +1121,16 @@ bool BKE_object_data_transfer_dm( BLI_assert((ob_src != ob_dst) && (ob_src->type == OB_MESH) && (ob_dst->type == OB_MESH)); me_dst = ob_dst->data; - me_src = ob_src->data; if (dm_dst) { - dirty_nors_dst = (dm_dst->dirty & DM_DIRTY_NORMALS) != 0; - use_create = false; /* Never create needed custom layers on DM (modifier case). */ + dirty_nors_dst = (dm_dst->runtime.cd_dirty_vert & CD_NORMAL) != 0; + /* Never create needed custom layers on passed destination mesh + * (assumed to *not* be ob_dst->data, aka modifier case). */ + use_create = false; } if (vgroup_name) { if (dm_dst) { - mdef = dm_dst->getVertDataArray(dm_dst, CD_MDEFORMVERT); + mdef = CustomData_get_layer(&dm_dst->vdata, CD_MDEFORMVERT); } else { mdef = CustomData_get_layer(&me_dst->vdata, CD_MDEFORMVERT); @@ -1151,15 +1149,16 @@ bool BKE_object_data_transfer_dm( * Also, we need to make a local copy of dm_src, otherwise we may end with concurrent creation * of data in it (multi-threaded evaluation of the modifier stack, see T46672). */ - dm_src = dm_dst ? ob_src->derivedFinal : mesh_get_derived_final(depsgraph, scene, ob_src, dm_src_mask); + /* XXX TODO new depsgraph shall always ensure we have that src evaluated mesh built before this point, now, I think? */ + dm_src = dm_dst ? ob_src->runtime.mesh_eval : mesh_get_eval_final(depsgraph, scene, ob_src, dm_src_mask); if (!dm_src) { return changed; } - dm_src = CDDM_copy(dm_src); +// dm_src = CDDM_copy(dm_src); if (auto_transform) { - MVert *verts_dst = dm_dst ? dm_dst->getVertArray(dm_dst) : me_dst->mvert; - const int num_verts_dst = dm_dst ? dm_dst->getNumVerts(dm_dst) : me_dst->totvert; + MVert *verts_dst = dm_dst ? dm_dst->mvert : me_dst->mvert; + const int num_verts_dst = dm_dst ? dm_dst->totvert : me_dst->totvert; if (space_transform == NULL) { space_transform = &auto_space_transform; @@ -1179,9 +1178,8 @@ bool BKE_object_data_transfer_dm( continue; } - data_transfer_dtdata_type_preprocess(ob_src, ob_dst, dm_src, dm_dst, me_dst, - dtdata_type, dirty_nors_dst, - (me_src->flag & ME_AUTOSMOOTH) != 0, me_src->smoothresh); + data_transfer_dtdata_type_preprocess( + dm_src, dm_dst ? dm_dst : me_dst, dtdata_type, dirty_nors_dst); cddata_type = BKE_object_data_transfer_dttype_to_cdtype(dtdata_type); @@ -1195,11 +1193,11 @@ bool BKE_object_data_transfer_dm( } if (DT_DATATYPE_IS_VERT(dtdata_type)) { - MVert *verts_dst = dm_dst ? dm_dst->getVertArray(dm_dst) : me_dst->mvert; - const int num_verts_dst = dm_dst ? dm_dst->getNumVerts(dm_dst) : me_dst->totvert; + MVert *verts_dst = dm_dst ? dm_dst->mvert : me_dst->mvert; + const int num_verts_dst = dm_dst ? dm_dst->totvert : me_dst->totvert; if (!geom_map_init[VDATA]) { - const int num_verts_src = dm_src->getNumVerts(dm_src); + const int num_verts_src = dm_src->totvert; if ((map_vert_mode == MREMAP_MODE_TOPOLOGY) && (num_verts_dst != num_verts_src)) { BKE_report(reports, RPT_ERROR, @@ -1207,13 +1205,13 @@ bool BKE_object_data_transfer_dm( "'Topology' mapping cannot be used in this case"); continue; } - if ((map_vert_mode & MREMAP_USE_EDGE) && (dm_src->getNumEdges(dm_src) == 0)) { + if ((map_vert_mode & MREMAP_USE_EDGE) && (dm_src->totedge == 0)) { BKE_report(reports, RPT_ERROR, "Source mesh doesn't have any edges, " "None of the 'Edge' mappings can be used in this case"); continue; } - if ((map_vert_mode & MREMAP_USE_POLY) && (dm_src->getNumPolys(dm_src) == 0)) { + if ((map_vert_mode & MREMAP_USE_POLY) && (dm_src->totpoly == 0)) { BKE_report(reports, RPT_ERROR, "Source mesh doesn't have any faces, " "None of the 'Face' mappings can be used in this case"); @@ -1253,13 +1251,13 @@ bool BKE_object_data_transfer_dm( } } if (DT_DATATYPE_IS_EDGE(dtdata_type)) { - MVert *verts_dst = dm_dst ? dm_dst->getVertArray(dm_dst) : me_dst->mvert; - const int num_verts_dst = dm_dst ? dm_dst->getNumVerts(dm_dst) : me_dst->totvert; - MEdge *edges_dst = dm_dst ? dm_dst->getEdgeArray(dm_dst) : me_dst->medge; - const int num_edges_dst = dm_dst ? dm_dst->getNumEdges(dm_dst) : me_dst->totedge; + MVert *verts_dst = dm_dst ? dm_dst->mvert : me_dst->mvert; + const int num_verts_dst = dm_dst ? dm_dst->totvert : me_dst->totvert; + MEdge *edges_dst = dm_dst ? dm_dst->medge : me_dst->medge; + const int num_edges_dst = dm_dst ? dm_dst->totedge : me_dst->totedge; if (!geom_map_init[EDATA]) { - const int num_edges_src = dm_src->getNumEdges(dm_src); + const int num_edges_src = dm_src->totedge; if ((map_edge_mode == MREMAP_MODE_TOPOLOGY) && (num_edges_dst != num_edges_src)) { BKE_report(reports, RPT_ERROR, @@ -1267,7 +1265,7 @@ bool BKE_object_data_transfer_dm( "'Topology' mapping cannot be used in this case"); continue; } - if ((map_edge_mode & MREMAP_USE_POLY) && (dm_src->getNumPolys(dm_src) == 0)) { + if ((map_edge_mode & MREMAP_USE_POLY) && (dm_src->totpoly == 0)) { BKE_report(reports, RPT_ERROR, "Source mesh doesn't have any faces, " "None of the 'Face' mappings can be used in this case"); @@ -1310,21 +1308,21 @@ bool BKE_object_data_transfer_dm( } } if (DT_DATATYPE_IS_LOOP(dtdata_type)) { - MVert *verts_dst = dm_dst ? dm_dst->getVertArray(dm_dst) : me_dst->mvert; - const int num_verts_dst = dm_dst ? dm_dst->getNumVerts(dm_dst) : me_dst->totvert; - MEdge *edges_dst = dm_dst ? dm_dst->getEdgeArray(dm_dst) : me_dst->medge; - const int num_edges_dst = dm_dst ? dm_dst->getNumEdges(dm_dst) : me_dst->totedge; - MPoly *polys_dst = dm_dst ? dm_dst->getPolyArray(dm_dst) : me_dst->mpoly; - const int num_polys_dst = dm_dst ? dm_dst->getNumPolys(dm_dst) : me_dst->totpoly; - MLoop *loops_dst = dm_dst ? dm_dst->getLoopArray(dm_dst) : me_dst->mloop; - const int num_loops_dst = dm_dst ? dm_dst->getNumLoops(dm_dst) : me_dst->totloop; - CustomData *pdata_dst = dm_dst ? dm_dst->getPolyDataLayout(dm_dst) : &me_dst->pdata; - CustomData *ldata_dst = dm_dst ? dm_dst->getLoopDataLayout(dm_dst) : &me_dst->ldata; + MVert *verts_dst = dm_dst ? dm_dst->mvert : me_dst->mvert; + const int num_verts_dst = dm_dst ? dm_dst->totvert : me_dst->totvert; + MEdge *edges_dst = dm_dst ? dm_dst->medge : me_dst->medge; + const int num_edges_dst = dm_dst ? dm_dst->totedge : me_dst->totedge; + MPoly *polys_dst = dm_dst ? dm_dst->mpoly : me_dst->mpoly; + const int num_polys_dst = dm_dst ? dm_dst->totpoly : me_dst->totpoly; + MLoop *loops_dst = dm_dst ? dm_dst->mloop : me_dst->mloop; + const int num_loops_dst = dm_dst ? dm_dst->totloop : me_dst->totloop; + CustomData *pdata_dst = dm_dst ? &dm_dst->pdata : &me_dst->pdata; + CustomData *ldata_dst = dm_dst ? &dm_dst->ldata : &me_dst->ldata; MeshRemapIslandsCalc island_callback = data_transfer_get_loop_islands_generator(cddata_type); if (!geom_map_init[LDATA]) { - const int num_loops_src = dm_src->getNumLoops(dm_src); + const int num_loops_src = dm_src->totloop; if ((map_loop_mode == MREMAP_MODE_TOPOLOGY) && (num_loops_dst != num_loops_src)) { BKE_report(reports, RPT_ERROR, @@ -1332,7 +1330,7 @@ bool BKE_object_data_transfer_dm( "'Topology' mapping cannot be used in this case"); continue; } - if ((map_loop_mode & MREMAP_USE_EDGE) && (dm_src->getNumEdges(dm_src) == 0)) { + if ((map_loop_mode & MREMAP_USE_EDGE) && (dm_src->totedge == 0)) { BKE_report(reports, RPT_ERROR, "Source mesh doesn't have any edges, " "None of the 'Edge' mappings can be used in this case"); @@ -1349,8 +1347,8 @@ bool BKE_object_data_transfer_dm( verts_dst, num_verts_dst, edges_dst, num_edges_dst, loops_dst, num_loops_dst, polys_dst, num_polys_dst, ldata_dst, pdata_dst, - (me_dst->flag & ME_AUTOSMOOTH) != 0, me_dst->smoothresh, dirty_nors_dst, - dm_src, (me_src->flag & ME_AUTOSMOOTH) != 0, me_src->smoothresh, + ((dm_dst ? dm_dst : me_dst)->flag & ME_AUTOSMOOTH) != 0, (dm_dst ? dm_dst : me_dst)->smoothresh, dirty_nors_dst, + dm_src, island_callback, islands_handling_precision, &geom_map[LDATA]); geom_map_init[LDATA] = true; } @@ -1379,16 +1377,16 @@ bool BKE_object_data_transfer_dm( } } if (DT_DATATYPE_IS_POLY(dtdata_type)) { - MVert *verts_dst = dm_dst ? dm_dst->getVertArray(dm_dst) : me_dst->mvert; - const int num_verts_dst = dm_dst ? dm_dst->getNumVerts(dm_dst) : me_dst->totvert; - MPoly *polys_dst = dm_dst ? dm_dst->getPolyArray(dm_dst) : me_dst->mpoly; - const int num_polys_dst = dm_dst ? dm_dst->getNumPolys(dm_dst) : me_dst->totpoly; - MLoop *loops_dst = dm_dst ? dm_dst->getLoopArray(dm_dst) : me_dst->mloop; - const int num_loops_dst = dm_dst ? dm_dst->getNumLoops(dm_dst) : me_dst->totloop; - CustomData *pdata_dst = dm_dst ? dm_dst->getPolyDataLayout(dm_dst) : &me_dst->pdata; + MVert *verts_dst = dm_dst ? dm_dst->mvert : me_dst->mvert; + const int num_verts_dst = dm_dst ? dm_dst->totvert : me_dst->totvert; + MPoly *polys_dst = dm_dst ? dm_dst->mpoly : me_dst->mpoly; + const int num_polys_dst = dm_dst ? dm_dst->totpoly : me_dst->totpoly; + MLoop *loops_dst = dm_dst ? dm_dst->mloop : me_dst->mloop; + const int num_loops_dst = dm_dst ? dm_dst->totloop : me_dst->totloop; + CustomData *pdata_dst = dm_dst ? &dm_dst->pdata : &me_dst->pdata; if (!geom_map_init[PDATA]) { - const int num_polys_src = dm_src->getNumPolys(dm_src); + const int num_polys_src = dm_src->totpoly; if ((map_poly_mode == MREMAP_MODE_TOPOLOGY) && (num_polys_dst != num_polys_src)) { BKE_report(reports, RPT_ERROR, @@ -1396,7 +1394,7 @@ bool BKE_object_data_transfer_dm( "'Topology' mapping cannot be used in this case"); continue; } - if ((map_poly_mode & MREMAP_USE_EDGE) && (dm_src->getNumEdges(dm_src) == 0)) { + if ((map_poly_mode & MREMAP_USE_EDGE) && (dm_src->totedge == 0)) { BKE_report(reports, RPT_ERROR, "Source mesh doesn't have any edges, " "None of the 'Edge' mappings can be used in this case"); @@ -1447,7 +1445,7 @@ bool BKE_object_data_transfer_dm( BKE_mesh_remap_free(&geom_map[i]); MEM_SAFE_FREE(weights[i]); } - dm_src->release(dm_src); +// dm_src->release(dm_src); return changed; |