Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/mesh/editmesh_utils.c
| Show First 20 Lines • Show All 316 Lines • ▼ Show 20 Lines | #endif | ||||
| me->edit_mesh->selectmode = me->edit_mesh->bm->selectmode = select_mode; | me->edit_mesh->selectmode = me->edit_mesh->bm->selectmode = select_mode; | ||||
| me->edit_mesh->mat_nr = (ob->actcol > 0) ? ob->actcol - 1 : 0; | me->edit_mesh->mat_nr = (ob->actcol > 0) ? ob->actcol - 1 : 0; | ||||
| me->edit_mesh->ob = ob; | me->edit_mesh->ob = ob; | ||||
| /* we need to flush selection because the mode may have changed from when last in editmode */ | /* we need to flush selection because the mode may have changed from when last in editmode */ | ||||
| EDBM_selectmode_flush(me->edit_mesh); | EDBM_selectmode_flush(me->edit_mesh); | ||||
| } | } | ||||
| /** | |||||
| * \warning This can invalidate the #Mesh runtime cache of other objects (for linked duplicates). | |||||
| * Most callers should run #DEG_id_tag_update on \a ob->data, see: T46738, T46913 | |||||
| */ | |||||
| void EDBM_mesh_load_ex(Main *bmain, Object *ob, bool free_data) | void EDBM_mesh_load_ex(Main *bmain, Object *ob, bool free_data) | ||||
| { | { | ||||
| Mesh *me = ob->data; | Mesh *me = ob->data; | ||||
| BMesh *bm = me->edit_mesh->bm; | BKE_editmesh_load_ex(bmain, me->edit_mesh, free_data); | ||||
| /* Workaround for T42360, 'ob->shapenr' should be 1 in this case. | |||||
| * however this isn't synchronized between objects at the moment. */ | |||||
| if (UNLIKELY((ob->shapenr == 0) && (me->key && !BLI_listbase_is_empty(&me->key->block)))) { | |||||
| bm->shapenr = 1; | |||||
| } | |||||
| BM_mesh_bm_to_me(bmain, | |||||
| bm, | |||||
| me, | |||||
| (&(struct BMeshToMeshParams){ | |||||
| .calc_object_remap = true, | |||||
| .update_shapekey_indices = !free_data, | |||||
| })); | |||||
| /* Free derived mesh. usually this would happen through depsgraph but there | |||||
| * are exceptions like file save that will not cause this, and we want to | |||||
| * avoid ending up with an invalid derived mesh then. | |||||
| * | |||||
| * Do it for all objects which shares the same mesh datablock, since their | |||||
| * derived meshes might also be referencing data which was just freed, | |||||
| * | |||||
| * Annoying enough, but currently seems most efficient way to avoid access | |||||
| * of freed data on scene update, especially in cases when there are dependency | |||||
| * cycles. | |||||
| */ | |||||
| #if 0 | |||||
| for (Object *other_object = bmain->objects.first; other_object != NULL; | |||||
| other_object = other_object->id.next) { | |||||
| if (other_object->data == ob->data) { | |||||
| BKE_object_free_derived_caches(other_object); | |||||
| } | |||||
| } | |||||
| #endif | |||||
| } | } | ||||
| void EDBM_mesh_clear(BMEditMesh *em) | void EDBM_mesh_clear(BMEditMesh *em) | ||||
| { | { | ||||
| /* clear bmesh */ | /* clear bmesh */ | ||||
| BM_mesh_clear(em->bm); | BM_mesh_clear(em->bm); | ||||
| /* free derived meshes */ | /* free derived meshes */ | ||||
| ▲ Show 20 Lines • Show All 1,255 Lines • Show Last 20 Lines | |||||