Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt_undo.c
| Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | typedef struct UndoSculpt { | ||||
| size_t undo_size; | size_t undo_size; | ||||
| } UndoSculpt; | } UndoSculpt; | ||||
| static UndoSculpt *sculpt_undo_get_nodes(void); | static UndoSculpt *sculpt_undo_get_nodes(void); | ||||
| static void update_cb(PBVHNode *node, void *rebuild) | static void update_cb(PBVHNode *node, void *rebuild) | ||||
| { | { | ||||
| BKE_pbvh_node_mark_update(node); | BKE_pbvh_node_mark_update(node); | ||||
| BKE_pbvh_node_mark_update_mask(node); | |||||
| if (*((bool *)rebuild)) { | if (*((bool *)rebuild)) { | ||||
| BKE_pbvh_node_mark_rebuild_draw(node); | BKE_pbvh_node_mark_rebuild_draw(node); | ||||
| } | } | ||||
| BKE_pbvh_node_fully_hidden_set(node, 0); | BKE_pbvh_node_fully_hidden_set(node, 0); | ||||
| } | } | ||||
| struct PartialUpdateData { | struct PartialUpdateData { | ||||
| PBVH *pbvh; | PBVH *pbvh; | ||||
| bool rebuild; | bool rebuild; | ||||
| char *modified_grids; | char *modified_grids; | ||||
jbakker: Is this line used at all? | |||||
| }; | }; | ||||
| /** | /** | ||||
| * A version of #update_cb that tests for 'ME_VERT_PBVH_UPDATE' | * A version of #update_cb that tests for 'ME_VERT_PBVH_UPDATE' | ||||
| */ | */ | ||||
| static void update_cb_partial(PBVHNode *node, void *userdata) | static void update_cb_partial(PBVHNode *node, void *userdata) | ||||
| { | { | ||||
| struct PartialUpdateData *data = userdata; | struct PartialUpdateData *data = userdata; | ||||
| ▲ Show 20 Lines • Show All 394 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| View3D *v3d = CTX_wm_view3d(C); | View3D *v3d = CTX_wm_view3d(C); | ||||
| Object *ob = OBACT(view_layer); | Object *ob = OBACT(view_layer); | ||||
| SculptSession *ss = ob->sculpt; | SculptSession *ss = ob->sculpt; | ||||
| SubdivCCG *subdiv_ccg = ss->subdiv_ccg; | SubdivCCG *subdiv_ccg = ss->subdiv_ccg; | ||||
| SculptUndoNode *unode; | SculptUndoNode *unode; | ||||
| bool update = false, rebuild = false; | bool update = false, rebuild = false, update_mask = false; | ||||
| bool need_mask = false; | bool need_mask = false; | ||||
| for (unode = lb->first; unode; unode = unode->next) { | for (unode = lb->first; unode; unode = unode->next) { | ||||
| /* restore pivot */ | /* restore pivot */ | ||||
| copy_v3_v3(ss->pivot_pos, unode->pivot_pos); | copy_v3_v3(ss->pivot_pos, unode->pivot_pos); | ||||
| copy_v3_v3(ss->pivot_rot, unode->pivot_rot); | copy_v3_v3(ss->pivot_rot, unode->pivot_rot); | ||||
| if (STREQ(unode->idname, ob->id.name)) { | if (STREQ(unode->idname, ob->id.name)) { | ||||
| if (unode->type == SCULPT_UNDO_MASK) { | if (unode->type == SCULPT_UNDO_MASK) { | ||||
| ▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | switch (unode->type) { | ||||
| case SCULPT_UNDO_HIDDEN: | case SCULPT_UNDO_HIDDEN: | ||||
| if (sculpt_undo_restore_hidden(C, unode)) { | if (sculpt_undo_restore_hidden(C, unode)) { | ||||
| rebuild = true; | rebuild = true; | ||||
| } | } | ||||
| break; | break; | ||||
| case SCULPT_UNDO_MASK: | case SCULPT_UNDO_MASK: | ||||
| if (sculpt_undo_restore_mask(C, unode)) { | if (sculpt_undo_restore_mask(C, unode)) { | ||||
| update = true; | update = true; | ||||
| update_mask = true; | |||||
| } | } | ||||
| break; | break; | ||||
| case SCULPT_UNDO_DYNTOPO_BEGIN: | case SCULPT_UNDO_DYNTOPO_BEGIN: | ||||
| case SCULPT_UNDO_DYNTOPO_END: | case SCULPT_UNDO_DYNTOPO_END: | ||||
| case SCULPT_UNDO_DYNTOPO_SYMMETRIZE: | case SCULPT_UNDO_DYNTOPO_SYMMETRIZE: | ||||
| BLI_assert(!"Dynamic topology should've already been handled"); | BLI_assert(!"Dynamic topology should've already been handled"); | ||||
| break; | break; | ||||
| Show All 21 Lines | if (update || rebuild) { | ||||
| * the nodes get recreated, though in that case it could do all */ | * the nodes get recreated, though in that case it could do all */ | ||||
| struct PartialUpdateData data = { | struct PartialUpdateData data = { | ||||
| .rebuild = rebuild, | .rebuild = rebuild, | ||||
| .pbvh = ss->pbvh, | .pbvh = ss->pbvh, | ||||
| .modified_grids = undo_modified_grids, | .modified_grids = undo_modified_grids, | ||||
| }; | }; | ||||
| BKE_pbvh_search_callback(ss->pbvh, NULL, NULL, update_cb_partial, &data); | BKE_pbvh_search_callback(ss->pbvh, NULL, NULL, update_cb_partial, &data); | ||||
| BKE_pbvh_update_bounds(ss->pbvh, PBVH_UpdateBB | PBVH_UpdateOriginalBB | PBVH_UpdateRedraw); | BKE_pbvh_update_bounds(ss->pbvh, PBVH_UpdateBB | PBVH_UpdateOriginalBB | PBVH_UpdateRedraw); | ||||
| if (update_mask) { | |||||
| BKE_pbvh_update_vertex_data(ss->pbvh, PBVH_UpdateMask); | |||||
| } | |||||
| if (BKE_sculpt_multires_active(scene, ob)) { | if (BKE_sculpt_multires_active(scene, ob)) { | ||||
| if (rebuild) { | if (rebuild) { | ||||
| multires_mark_as_modified(depsgraph, ob, MULTIRES_HIDDEN_MODIFIED); | multires_mark_as_modified(depsgraph, ob, MULTIRES_HIDDEN_MODIFIED); | ||||
| } | } | ||||
| else { | else { | ||||
| multires_mark_as_modified(depsgraph, ob, MULTIRES_COORDS_MODIFIED); | multires_mark_as_modified(depsgraph, ob, MULTIRES_COORDS_MODIFIED); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 697 Lines • Show Last 20 Lines | |||||
Is this line used at all?