Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt_undo.c
| Show First 20 Lines • Show All 1,484 Lines • ▼ Show 20 Lines | static void sculpt_undosys_step_decode_redo_impl(struct bContext *C, | ||||
| Depsgraph *depsgraph, | Depsgraph *depsgraph, | ||||
| SculptUndoStep *us) | SculptUndoStep *us) | ||||
| { | { | ||||
| BLI_assert(us->step.is_applied == false); | BLI_assert(us->step.is_applied == false); | ||||
| sculpt_undo_restore_list(C, depsgraph, &us->data.nodes); | sculpt_undo_restore_list(C, depsgraph, &us->data.nodes); | ||||
| us->step.is_applied = true; | us->step.is_applied = true; | ||||
| } | } | ||||
| static void sculpt_undosys_step_decode_undo(struct bContext *C, | |||||
| Depsgraph *depsgraph, | |||||
| SculptUndoStep *us) | |||||
| { | |||||
| SculptUndoStep *us_iter = us; | |||||
| while (us_iter->step.next && (us_iter->step.next->type == us_iter->step.type)) { | |||||
| if (us_iter->step.next->is_applied == false) { | |||||
| break; | |||||
| } | |||||
| us_iter = (SculptUndoStep *)us_iter->step.next; | |||||
| } | |||||
| while (us_iter != us) { | |||||
| sculpt_undosys_step_decode_undo_impl(C, depsgraph, us_iter); | |||||
| us_iter = (SculptUndoStep *)us_iter->step.prev; | |||||
| } | |||||
| } | |||||
| static void sculpt_undosys_step_decode_redo(struct bContext *C, | |||||
| Depsgraph *depsgraph, | |||||
| SculptUndoStep *us) | |||||
| { | |||||
| SculptUndoStep *us_iter = us; | |||||
| while (us_iter->step.prev && (us_iter->step.prev->type == us_iter->step.type)) { | |||||
| if (us_iter->step.prev->is_applied == true) { | |||||
| break; | |||||
| } | |||||
| us_iter = (SculptUndoStep *)us_iter->step.prev; | |||||
| } | |||||
| while (us_iter && (us_iter->step.is_applied == false)) { | |||||
| sculpt_undosys_step_decode_redo_impl(C, depsgraph, us_iter); | |||||
| if (us_iter == us) { | |||||
| break; | |||||
| } | |||||
| us_iter = (SculptUndoStep *)us_iter->step.next; | |||||
| } | |||||
| } | |||||
| static void sculpt_undosys_step_decode(struct bContext *C, | static void sculpt_undosys_step_decode(struct bContext *C, | ||||
| struct Main *bmain, | struct Main *bmain, | ||||
| UndoStep *us_p, | UndoStep *us_p, | ||||
| const eUndoStepDir dir, | const eUndoStepDir dir, | ||||
| bool UNUSED(is_final)) | bool UNUSED(is_final)) | ||||
| { | { | ||||
| BLI_assert(dir != STEP_INVALID); | BLI_assert(dir != STEP_INVALID); | ||||
| Show All 31 Lines | /* Ensure sculpt mode. */ | ||||
| else { | else { | ||||
| BLI_assert(0); | BLI_assert(0); | ||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||
| SculptUndoStep *us = (SculptUndoStep *)us_p; | SculptUndoStep *us = (SculptUndoStep *)us_p; | ||||
| if (dir == STEP_UNDO) { | if (dir == STEP_UNDO) { | ||||
| sculpt_undosys_step_decode_undo(C, depsgraph, us); | sculpt_undosys_step_decode_undo_impl(C, depsgraph, us); | ||||
| } | } | ||||
| else if (dir == STEP_REDO) { | else if (dir == STEP_REDO) { | ||||
| sculpt_undosys_step_decode_redo(C, depsgraph, us); | sculpt_undosys_step_decode_redo_impl(C, depsgraph, us); | ||||
| } | } | ||||
| } | } | ||||
| static void sculpt_undosys_step_free(UndoStep *us_p) | static void sculpt_undosys_step_free(UndoStep *us_p) | ||||
| { | { | ||||
| SculptUndoStep *us = (SculptUndoStep *)us_p; | SculptUndoStep *us = (SculptUndoStep *)us_p; | ||||
| sculpt_undo_free_list(&us->data.nodes); | sculpt_undo_free_list(&us->data.nodes); | ||||
| } | } | ||||
| Show All 15 Lines | |||||
| { | { | ||||
| ut->name = "Sculpt"; | ut->name = "Sculpt"; | ||||
| ut->poll = NULL; /* No poll from context for now. */ | ut->poll = NULL; /* No poll from context for now. */ | ||||
| ut->step_encode_init = sculpt_undosys_step_encode_init; | ut->step_encode_init = sculpt_undosys_step_encode_init; | ||||
| ut->step_encode = sculpt_undosys_step_encode; | ut->step_encode = sculpt_undosys_step_encode; | ||||
| ut->step_decode = sculpt_undosys_step_decode; | ut->step_decode = sculpt_undosys_step_decode; | ||||
| ut->step_free = sculpt_undosys_step_free; | ut->step_free = sculpt_undosys_step_free; | ||||
| ut->flags = 0; | ut->flags = UNDOTYPE_DIFFERENTIAL; | ||||
| ut->step_size = sizeof(SculptUndoStep); | ut->step_size = sizeof(SculptUndoStep); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Utilities | /** \name Utilities | ||||
| ▲ Show 20 Lines • Show All 109 Lines • Show Last 20 Lines | |||||