Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/DerivedMesh.cc
| Show First 20 Lines • Show All 1,904 Lines • ▼ Show 20 Lines | static void mesh_build_data(struct Depsgraph *depsgraph, | ||||
| BKE_object_free_derived_caches(ob); | BKE_object_free_derived_caches(ob); | ||||
| if (DEG_is_active(depsgraph)) { | if (DEG_is_active(depsgraph)) { | ||||
| BKE_sculpt_update_object_before_eval(ob); | BKE_sculpt_update_object_before_eval(ob); | ||||
| } | } | ||||
| #if 0 /* XXX This is already taken care of in mesh_calc_modifiers()... */ | #if 0 /* XXX This is already taken care of in mesh_calc_modifiers()... */ | ||||
| if (need_mapping) { | if (need_mapping) { | ||||
| /* Also add the flag so that it is recorded in lastDataMask. */ | /* Also add the flag so that it is recorded in `last_data_mask`. */ | ||||
| dataMask->vmask |= CD_MASK_ORIGINDEX; | dataMask->vmask |= CD_MASK_ORIGINDEX; | ||||
| dataMask->emask |= CD_MASK_ORIGINDEX; | dataMask->emask |= CD_MASK_ORIGINDEX; | ||||
| dataMask->pmask |= CD_MASK_ORIGINDEX; | dataMask->pmask |= CD_MASK_ORIGINDEX; | ||||
| } | } | ||||
| #endif | #endif | ||||
| Mesh *mesh_eval = nullptr, *mesh_deform_eval = nullptr; | Mesh *mesh_eval = nullptr, *mesh_deform_eval = nullptr; | ||||
| GeometrySet *geometry_set_eval = nullptr; | GeometrySet *geometry_set_eval = nullptr; | ||||
| ▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| BLI_assert(obedit->id.tag & LIB_TAG_COPIED_ON_WRITE); | BLI_assert(obedit->id.tag & LIB_TAG_COPIED_ON_WRITE); | ||||
| BKE_object_free_derived_caches(obedit); | BKE_object_free_derived_caches(obedit); | ||||
| if (DEG_is_active(depsgraph)) { | if (DEG_is_active(depsgraph)) { | ||||
| BKE_sculpt_update_object_before_eval(obedit); | BKE_sculpt_update_object_before_eval(obedit); | ||||
| } | } | ||||
| BKE_editmesh_free_derivedmesh(em); | BKE_mesh_runtime_clear_geometry_for_edit_mode((Mesh *)obedit->data); | ||||
| BKE_mesh_runtime_ensure_edit_data((Mesh *)obedit->data); | |||||
| EditMeshEval *em_eval = &((Mesh *)obedit->data)->runtime.edit_eval; | |||||
| Mesh *me_cage; | Mesh *me_cage; | ||||
| Mesh *me_final; | Mesh *me_final; | ||||
| GeometrySet *non_mesh_components; | GeometrySet *non_mesh_components; | ||||
| editbmesh_calc_modifiers( | editbmesh_calc_modifiers( | ||||
| depsgraph, scene, obedit, em, dataMask, &me_cage, &me_final, &non_mesh_components); | depsgraph, scene, obedit, em, dataMask, &me_cage, &me_final, &non_mesh_components); | ||||
| em->mesh_eval_final = me_final; | em_eval->mesh_final = me_final; | ||||
| em->mesh_eval_cage = me_cage; | em_eval->mesh_cage = me_cage; | ||||
| obedit->runtime.geometry_set_eval = non_mesh_components; | obedit->runtime.geometry_set_eval = non_mesh_components; | ||||
| BKE_object_boundbox_calc_from_mesh(obedit, em->mesh_eval_final); | BKE_object_boundbox_calc_from_mesh(obedit, em_eval->mesh_final); | ||||
| em->lastDataMask = *dataMask; | em_eval->last_data_mask = *dataMask; | ||||
| mesh_runtime_check_normals_valid(em->mesh_eval_final); | mesh_runtime_check_normals_valid(em_eval->mesh_final); | ||||
| } | } | ||||
| static void object_get_datamask(const Depsgraph *depsgraph, | static void object_get_datamask(const Depsgraph *depsgraph, | ||||
| Object *ob, | Object *ob, | ||||
| CustomData_MeshMasks *r_mask, | CustomData_MeshMasks *r_mask, | ||||
| bool *r_need_mapping) | bool *r_need_mapping) | ||||
| { | { | ||||
| ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph); | ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph); | ||||
| ▲ Show 20 Lines • Show All 191 Lines • ▼ Show 20 Lines | Mesh *editbmesh_get_eval_cage_and_final(Depsgraph *depsgraph, | ||||
| Mesh **r_final) | Mesh **r_final) | ||||
| { | { | ||||
| CustomData_MeshMasks cddata_masks = *dataMask; | CustomData_MeshMasks cddata_masks = *dataMask; | ||||
| /* if there's no derived mesh or the last data mask used doesn't include | /* if there's no derived mesh or the last data mask used doesn't include | ||||
| * the data we need, rebuild the derived mesh | * the data we need, rebuild the derived mesh | ||||
| */ | */ | ||||
| object_get_datamask(depsgraph, obedit, &cddata_masks, nullptr); | object_get_datamask(depsgraph, obedit, &cddata_masks, nullptr); | ||||
| EditMeshEval *em_eval = &((Mesh *)obedit->data)->runtime.edit_eval; | |||||
| if (!em->mesh_eval_cage || | if ((!(em_eval->mesh_cage)) || | ||||
| !CustomData_MeshMasks_are_matching(&(em->lastDataMask), &cddata_masks)) { | !CustomData_MeshMasks_are_matching(&em_eval->last_data_mask, &cddata_masks)) { | ||||
| editbmesh_build_data(depsgraph, scene, obedit, em, &cddata_masks); | editbmesh_build_data(depsgraph, scene, obedit, em, &cddata_masks); | ||||
| } | } | ||||
| *r_final = em->mesh_eval_final; | *r_final = em_eval->mesh_final; | ||||
| if (em->mesh_eval_final) { | if (em_eval->mesh_final) { | ||||
| BLI_assert(!(em->mesh_eval_final->runtime.cd_dirty_vert & DM_DIRTY_NORMALS)); | BLI_assert(!(em_eval->mesh_final->runtime.cd_dirty_vert & DM_DIRTY_NORMALS)); | ||||
| } | } | ||||
| return em->mesh_eval_cage; | return em_eval->mesh_cage; | ||||
| } | } | ||||
| Mesh *editbmesh_get_eval_cage(struct Depsgraph *depsgraph, | Mesh *editbmesh_get_eval_cage(struct Depsgraph *depsgraph, | ||||
| Scene *scene, | Scene *scene, | ||||
| Object *obedit, | Object *obedit, | ||||
| BMEditMesh *em, | BMEditMesh *em, | ||||
| const CustomData_MeshMasks *dataMask) | const CustomData_MeshMasks *dataMask) | ||||
| { | { | ||||
| CustomData_MeshMasks cddata_masks = *dataMask; | CustomData_MeshMasks cddata_masks = *dataMask; | ||||
| /* if there's no derived mesh or the last data mask used doesn't include | /* if there's no derived mesh or the last data mask used doesn't include | ||||
| * the data we need, rebuild the derived mesh | * the data we need, rebuild the derived mesh | ||||
| */ | */ | ||||
| object_get_datamask(depsgraph, obedit, &cddata_masks, nullptr); | object_get_datamask(depsgraph, obedit, &cddata_masks, nullptr); | ||||
| EditMeshEval *em_eval = &((Mesh *)obedit->data)->runtime.edit_eval; | |||||
| if (!em->mesh_eval_cage || | if ((!(em_eval->mesh_cage)) || | ||||
| !CustomData_MeshMasks_are_matching(&(em->lastDataMask), &cddata_masks)) { | !CustomData_MeshMasks_are_matching(&em_eval->last_data_mask, &cddata_masks)) { | ||||
| editbmesh_build_data(depsgraph, scene, obedit, em, &cddata_masks); | editbmesh_build_data(depsgraph, scene, obedit, em, &cddata_masks); | ||||
| } | } | ||||
| return em->mesh_eval_cage; | return em_eval->mesh_cage; | ||||
| } | } | ||||
| Mesh *editbmesh_get_eval_cage_from_orig(struct Depsgraph *depsgraph, | Mesh *editbmesh_get_eval_cage_from_orig(struct Depsgraph *depsgraph, | ||||
| Scene *scene, | Scene *scene, | ||||
| Object *obedit, | Object *obedit, | ||||
| const CustomData_MeshMasks *dataMask) | const CustomData_MeshMasks *dataMask) | ||||
| { | { | ||||
| BLI_assert((obedit->id.tag & LIB_TAG_COPIED_ON_WRITE) == 0); | BLI_assert((obedit->id.tag & LIB_TAG_COPIED_ON_WRITE) == 0); | ||||
| ▲ Show 20 Lines • Show All 289 Lines • Show Last 20 Lines | |||||