Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/object.c
| Show First 20 Lines • Show All 355 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static void object_update_from_subsurf_ccg(Object *object) | static void object_update_from_subsurf_ccg(Object *object) | ||||
| { | { | ||||
| /* Currently CCG is only created for Mesh objects. */ | /* Currently CCG is only created for Mesh objects. */ | ||||
| if (object->type != OB_MESH) { | if (object->type != OB_MESH) { | ||||
| return; | return; | ||||
| } | } | ||||
| /* If object does not own evaluated mesh we can not access it since it might be freed already | |||||
| * (happens on dependency graph free where order of CoW-ed IDs free is undefined). | |||||
| * | |||||
| * Good news is: such mesh does not have modifiers applied, so no need to worry about CCG. */ | |||||
| if (!object->runtime.is_mesh_eval_owned) { | |||||
| return; | |||||
| } | |||||
| /* Object was never evaluated, so can not have CCG subdivision surface. */ | /* Object was never evaluated, so can not have CCG subdivision surface. */ | ||||
| Mesh *mesh_eval = object->runtime.mesh_eval; | Mesh *mesh_eval = object->runtime.mesh_eval; | ||||
| if (mesh_eval == NULL) { | if (mesh_eval == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| SubdivCCG *subdiv_ccg = mesh_eval->runtime.subdiv_ccg; | SubdivCCG *subdiv_ccg = mesh_eval->runtime.subdiv_ccg; | ||||
| if (subdiv_ccg == NULL) { | if (subdiv_ccg == NULL) { | ||||
| return; | return; | ||||
| ▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | else if (ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT)) { | ||||
| } | } | ||||
| } | } | ||||
| MEM_SAFE_FREE(ob->runtime.bb); | MEM_SAFE_FREE(ob->runtime.bb); | ||||
| object_update_from_subsurf_ccg(ob); | object_update_from_subsurf_ccg(ob); | ||||
| BKE_object_free_derived_mesh_caches(ob); | BKE_object_free_derived_mesh_caches(ob); | ||||
| if (ob->runtime.mesh_eval != NULL) { | |||||
| Mesh *mesh_eval = ob->runtime.mesh_eval; | |||||
| /* Restore initial pointer. */ | /* Restore initial pointer. */ | ||||
| if (ob->data == mesh_eval) { | if (ob->runtime.mesh_orig != NULL) { | ||||
| ob->data = ob->runtime.mesh_orig; | ob->data = ob->runtime.mesh_orig; | ||||
| } | } | ||||
| if ((ob->runtime.mesh_eval != NULL && ob->runtime.is_mesh_eval_owned)) { | |||||
| Mesh *mesh_eval = ob->runtime.mesh_eval; | |||||
| /* Evaluated mesh points to edit mesh, but does not own it. */ | /* Evaluated mesh points to edit mesh, but does not own it. */ | ||||
| mesh_eval->edit_mesh = NULL; | mesh_eval->edit_mesh = NULL; | ||||
| BKE_mesh_free(mesh_eval); | BKE_mesh_free(mesh_eval); | ||||
| BKE_libblock_free_data(&mesh_eval->id, false); | BKE_libblock_free_data(&mesh_eval->id, false); | ||||
| MEM_freeN(mesh_eval); | MEM_freeN(mesh_eval); | ||||
| ob->runtime.mesh_eval = NULL; | ob->runtime.mesh_eval = NULL; | ||||
| } | } | ||||
| if (ob->runtime.mesh_deform_eval != NULL) { | if (ob->runtime.mesh_deform_eval != NULL) { | ||||
| ▲ Show 20 Lines • Show All 4,054 Lines • Show Last 20 Lines | |||||