Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
| Show First 20 Lines • Show All 8,158 Lines • ▼ Show 20 Lines | void ED_object_sculptmode_enter_ex(Main *bmain, | ||||
| ob->mode |= mode_flag; | ob->mode |= mode_flag; | ||||
| MultiresModifierData *mmd = BKE_sculpt_multires_active(scene, ob); | MultiresModifierData *mmd = BKE_sculpt_multires_active(scene, ob); | ||||
| const int flush_recalc = ed_object_sculptmode_flush_recalc_flag(scene, ob, mmd); | const int flush_recalc = ed_object_sculptmode_flush_recalc_flag(scene, ob, mmd); | ||||
| if (flush_recalc) { | if (flush_recalc) { | ||||
| DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); | DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); | ||||
| } | } | ||||
sergey: To follow old logic there needs to be evaluation here. Without such evaluation it seems that… | |||||
| /* Create sculpt mode session data. */ | /* Create sculpt mode session data. */ | ||||
| if (ob->sculpt) { | if (ob->sculpt) { | ||||
| BKE_sculptsession_free(ob); | BKE_sculptsession_free(ob); | ||||
| } | } | ||||
| /* Make sure derived final from original object does not reference possibly | /* Make sure derived final from original object does not reference possibly | ||||
| * freed memory. */ | * freed memory. */ | ||||
| BKE_object_free_derived_caches(ob); | BKE_object_free_derived_caches(ob); | ||||
| /* Copy the current mesh visibility to the Face Sets. */ | /* Copy the current mesh visibility to the Face Sets. */ | ||||
| BKE_sculpt_face_sets_ensure_from_base_mesh_visibility(me); | BKE_sculpt_face_sets_ensure_from_base_mesh_visibility(me); | ||||
| /* We need to flush changes to evaluated data in depsgraph (especially the freeing of | |||||
| * `ob->sculpt`), since `scult_init_session` call below will use those evaluated data and may | |||||
| * therefore access freed memory. */ | |||||
| DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); | |||||
| BKE_scene_graph_evaluated_ensure(depsgraph, bmain); | |||||
| sculpt_init_session(depsgraph, scene, ob); | sculpt_init_session(depsgraph, scene, ob); | ||||
| /* Mask layer is required. */ | /* Mask layer is required. */ | ||||
| if (mmd) { | if (mmd) { | ||||
| /* XXX, we could attempt to support adding mask data mid-sculpt mode (with multi-res) | /* XXX, we could attempt to support adding mask data mid-sculpt mode (with multi-res) | ||||
| * but this ends up being quite tricky (and slow). */ | * but this ends up being quite tricky (and slow). */ | ||||
| BKE_sculpt_mask_layers_ensure(ob, mmd); | BKE_sculpt_mask_layers_ensure(ob, mmd); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,053 Lines • Show Last 20 Lines | |||||
To follow old logic there needs to be evaluation here. Without such evaluation it seems that sculpt session will be wrongly initialized if, say, multires sculpt level is different from viewport level.