BMEditMesh *BKE_editmesh_copy(BMEditMesh *em) { BMEditMesh *em_copy = MEM_callocN(sizeof(BMEditMesh), __func__); *em_copy = *em; em_copy->derivedCage = em_copy->derivedFinal = NULL; em_copy->derivedVertColor = NULL; em_copy->derivedVertColorLen = 0; em_copy->derivedFaceColor = NULL; em_copy->derivedFaceColorLen = 0; em_copy->bm = BM_mesh_copy(em->bm); /* The tessellation is NOT calculated on the copy here, * because currently all the callers of this function use * it to make a backup copy of the BMEditMesh to restore * it in the case of errors in an operation. For perf * reasons, in that case it makes more sense to do the * tessellation only when/if that copy ends up getting * used.*/ em_copy->looptris = NULL; em_copy->presel_verts = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "PSV"); em_copy->presel_edges = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "PSE"); em_copy->presel_faces = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "PSF"); em_copy->prop3d_faces = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "PPF"); em_copy->prop2d_faces = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "PPF"); return em_copy; }
void EDBM_redo_state_restore(BMBackup backup, BMEditMesh *em, int recalctess) { BMesh *tmpbm; if (!em || !backup.bmcopy) { return; } BM_mesh_data_free(em->bm); tmpbm = BM_mesh_copy(backup.bmcopy); *em->bm = *tmpbm; MEM_freeN(tmpbm); tmpbm = NULL; if (recalctess) { BKE_editmesh_tessface_calc(em); } }
BMBackup EDBM_redo_state_store(BMEditMesh *em) { BMBackup backup; backup.bmcopy = BM_mesh_copy(em->bm); return backup; }