Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/mesh_convert.c
| Show First 20 Lines • Show All 975 Lines • ▼ Show 20 Lines | case OB_MESH: | ||||
| BKE_id_copy_ex(bmain, &mesh->id, (ID **)&tmpmesh, 0); | BKE_id_copy_ex(bmain, &mesh->id, (ID **)&tmpmesh, 0); | ||||
| /* XXX BKE_mesh_copy() already handles materials usercount. */ | /* XXX BKE_mesh_copy() already handles materials usercount. */ | ||||
| do_mat_id_data_us = false; | do_mat_id_data_us = false; | ||||
| } | } | ||||
| /* if not getting the original caged mesh, get final derived mesh */ | /* if not getting the original caged mesh, get final derived mesh */ | ||||
| else { | else { | ||||
| /* Make a dummy mesh, saves copying */ | /* Make a dummy mesh, saves copying */ | ||||
| Mesh *me_eval; | Mesh *me_eval; | ||||
| /* CustomDataMask mask = CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL; */ | CustomData_Masks mask = CD_MASK_MESH; /* this seems more suitable, exporter, | ||||
| CustomDataMask mask = CD_MASK_MESH; /* this seems more suitable, exporter, | |||||
| * for example, needs CD_MASK_MDEFORMVERT */ | * for example, needs CD_MASK_MDEFORMVERT */ | ||||
| if (calc_undeformed) | if (calc_undeformed) { | ||||
| mask |= CD_MASK_ORCO; | mask.vmask |= CD_MASK_ORCO; | ||||
| } | |||||
| if (render) { | if (render) { | ||||
| me_eval = mesh_create_eval_final_render(depsgraph, sce, ob, mask); | me_eval = mesh_create_eval_final_render(depsgraph, sce, ob, mask); | ||||
| } | } | ||||
| else { | else { | ||||
| me_eval = mesh_create_eval_final_view(depsgraph, sce, ob, mask); | me_eval = mesh_create_eval_final_view(depsgraph, sce, ob, mask); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 225 Lines • ▼ Show 20 Lines | if (kb->totelem != mesh_src->totvert) { | ||||
| kb->data = MEM_calloc_arrayN(kb->totelem, 3 * sizeof(float), __func__); | kb->data = MEM_calloc_arrayN(kb->totelem, 3 * sizeof(float), __func__); | ||||
| CLOG_ERROR(&LOG, "lost a shapekey layer: '%s'! (bmesh internal error)", kb->name); | CLOG_ERROR(&LOG, "lost a shapekey layer: '%s'! (bmesh internal error)", kb->name); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* This is a Mesh-based copy of DM_to_mesh() */ | /* This is a Mesh-based copy of DM_to_mesh() */ | ||||
| void BKE_mesh_nomain_to_mesh(Mesh *mesh_src, Mesh *mesh_dst, Object *ob, CustomDataMask mask, bool take_ownership) | void BKE_mesh_nomain_to_mesh(Mesh *mesh_src, Mesh *mesh_dst, Object *ob, CustomData_Masks mask, bool take_ownership) | ||||
| { | { | ||||
| /* mesh_src might depend on mesh_dst, so we need to do everything with a local copy */ | /* mesh_src might depend on mesh_dst, so we need to do everything with a local copy */ | ||||
| /* TODO(Sybren): the above claim came from DM_to_mesh(); check whether it is still true with Mesh */ | /* TODO(Sybren): the above claim came from DM_to_mesh(); check whether it is still true with Mesh */ | ||||
| Mesh tmp = *mesh_dst; | Mesh tmp = *mesh_dst; | ||||
| int totvert, totedge /*, totface */ /* UNUSED */, totloop, totpoly; | int totvert, totedge /*, totface */ /* UNUSED */, totloop, totpoly; | ||||
| int did_shapekeys = 0; | int did_shapekeys = 0; | ||||
| eCDAllocType alloctype = CD_DUPLICATE; | eCDAllocType alloctype = CD_DUPLICATE; | ||||
| Show All 17 Lines | void BKE_mesh_nomain_to_mesh(Mesh *mesh_src, Mesh *mesh_dst, Object *ob, CustomData_Masks mask, bool take_ownership) | ||||
| BKE_mesh_ensure_normals(mesh_src); | BKE_mesh_ensure_normals(mesh_src); | ||||
| totvert = tmp.totvert = mesh_src->totvert; | totvert = tmp.totvert = mesh_src->totvert; | ||||
| totedge = tmp.totedge = mesh_src->totedge; | totedge = tmp.totedge = mesh_src->totedge; | ||||
| totloop = tmp.totloop = mesh_src->totloop; | totloop = tmp.totloop = mesh_src->totloop; | ||||
| totpoly = tmp.totpoly = mesh_src->totpoly; | totpoly = tmp.totpoly = mesh_src->totpoly; | ||||
| tmp.totface = 0; | tmp.totface = 0; | ||||
| CustomData_copy(&mesh_src->vdata, &tmp.vdata, mask, alloctype, totvert); | CustomData_copy(&mesh_src->vdata, &tmp.vdata, mask.vmask, alloctype, totvert); | ||||
| CustomData_copy(&mesh_src->edata, &tmp.edata, mask, alloctype, totedge); | CustomData_copy(&mesh_src->edata, &tmp.edata, mask.emask, alloctype, totedge); | ||||
| CustomData_copy(&mesh_src->ldata, &tmp.ldata, mask, alloctype, totloop); | CustomData_copy(&mesh_src->ldata, &tmp.ldata, mask.lmask, alloctype, totloop); | ||||
| CustomData_copy(&mesh_src->pdata, &tmp.pdata, mask, alloctype, totpoly); | CustomData_copy(&mesh_src->pdata, &tmp.pdata, mask.pmask, alloctype, totpoly); | ||||
| tmp.cd_flag = mesh_src->cd_flag; | tmp.cd_flag = mesh_src->cd_flag; | ||||
| tmp.runtime.deformed_only = mesh_src->runtime.deformed_only; | tmp.runtime.deformed_only = mesh_src->runtime.deformed_only; | ||||
| if (CustomData_has_layer(&mesh_src->vdata, CD_SHAPEKEY)) { | if (CustomData_has_layer(&mesh_src->vdata, CD_SHAPEKEY)) { | ||||
| KeyBlock *kb; | KeyBlock *kb; | ||||
| int uid; | int uid; | ||||
| if (ob) { | if (ob) { | ||||
| ▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | if (mesh_dst->bb) { | ||||
| tmp.bb = NULL; | tmp.bb = NULL; | ||||
| } | } | ||||
| /* skip the listbase */ | /* skip the listbase */ | ||||
| MEMCPY_STRUCT_OFS(mesh_dst, &tmp, id.prev); | MEMCPY_STRUCT_OFS(mesh_dst, &tmp, id.prev); | ||||
| if (take_ownership) { | if (take_ownership) { | ||||
| if (alloctype == CD_ASSIGN) { | if (alloctype == CD_ASSIGN) { | ||||
| CustomData_free_typemask(&mesh_src->vdata, mesh_src->totvert, ~mask); | CustomData_free_typemask(&mesh_src->vdata, mesh_src->totvert, ~mask.vmask); | ||||
| CustomData_free_typemask(&mesh_src->edata, mesh_src->totedge, ~mask); | CustomData_free_typemask(&mesh_src->edata, mesh_src->totedge, ~mask.emask); | ||||
| CustomData_free_typemask(&mesh_src->ldata, mesh_src->totloop, ~mask); | CustomData_free_typemask(&mesh_src->ldata, mesh_src->totloop, ~mask.lmask); | ||||
| CustomData_free_typemask(&mesh_src->pdata, mesh_src->totpoly, ~mask); | CustomData_free_typemask(&mesh_src->pdata, mesh_src->totpoly, ~mask.pmask); | ||||
| } | } | ||||
| BKE_id_free(NULL, mesh_src); | BKE_id_free(NULL, mesh_src); | ||||
| } | } | ||||
| } | } | ||||
| /* This is a Mesh-based copy of DM_to_meshkey() */ | /* This is a Mesh-based copy of DM_to_meshkey() */ | ||||
| void BKE_mesh_nomain_to_meshkey(Mesh *mesh_src, Mesh *mesh_dst, KeyBlock *kb) | void BKE_mesh_nomain_to_meshkey(Mesh *mesh_src, Mesh *mesh_dst, KeyBlock *kb) | ||||
| { | { | ||||
| Show All 19 Lines | |||||