Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt_undo.c
| Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | |||||
| #include "BKE_ccg.h" | #include "BKE_ccg.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_multires.h" | #include "BKE_multires.h" | ||||
| #include "BKE_paint.h" | #include "BKE_paint.h" | ||||
| #include "BKE_key.h" | #include "BKE_key.h" | ||||
| #include "BKE_mesh.h" | #include "BKE_mesh.h" | ||||
| #include "BKE_subsurf.h" | #include "BKE_subsurf.h" | ||||
| #include "DEG_depsgraph.h" | |||||
| #include "BKE_global.h" | |||||
| #include "BKE_main.h" | |||||
| #include "BKE_undo_system.h" | #include "BKE_undo_system.h" | ||||
| #include "DEG_depsgraph.h" | |||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "GPU_buffers.h" | #include "GPU_buffers.h" | ||||
| #include "ED_paint.h" | #include "ED_paint.h" | ||||
| #include "ED_object.h" | #include "ED_object.h" | ||||
| #include "ED_sculpt.h" | #include "ED_sculpt.h" | ||||
| #include "ED_undo.h" | |||||
| #include "bmesh.h" | #include "bmesh.h" | ||||
| #include "paint_intern.h" | #include "paint_intern.h" | ||||
| #include "sculpt_intern.h" | #include "sculpt_intern.h" | ||||
| typedef struct UndoSculpt { | typedef struct UndoSculpt { | ||||
| ListBase nodes; | ListBase nodes; | ||||
| ▲ Show 20 Lines • Show All 893 Lines • ▼ Show 20 Lines | SculptUndoNode *sculpt_undo_push_node( | ||||
| if (ss->kb) BLI_strncpy(unode->shapeName, ss->kb->name, sizeof(ss->kb->name)); | if (ss->kb) BLI_strncpy(unode->shapeName, ss->kb->name, sizeof(ss->kb->name)); | ||||
| else unode->shapeName[0] = '\0'; | else unode->shapeName[0] = '\0'; | ||||
| return unode; | return unode; | ||||
| } | } | ||||
| void sculpt_undo_push_begin(const char *name) | void sculpt_undo_push_begin(const char *name) | ||||
| { | { | ||||
| UndoStack *ustack = ED_undo_stack_get(); | |||||
| bContext *C = NULL; /* special case, we never read from this. */ | bContext *C = NULL; /* special case, we never read from this. */ | ||||
| wmWindowManager *wm = G.main->wm.first; | BKE_undosys_step_push_init_with_type(ustack, C, name, BKE_UNDOSYS_TYPE_SCULPT); | ||||
| BKE_undosys_step_push_init_with_type(wm->undo_stack, C, name, BKE_UNDOSYS_TYPE_SCULPT); | |||||
| } | } | ||||
| void sculpt_undo_push_end(void) | void sculpt_undo_push_end(void) | ||||
| { | { | ||||
| UndoSculpt *usculpt = sculpt_undo_get_nodes(); | UndoSculpt *usculpt = sculpt_undo_get_nodes(); | ||||
| SculptUndoNode *unode; | SculptUndoNode *unode; | ||||
| /* we don't need normals in the undo stack */ | /* we don't need normals in the undo stack */ | ||||
| for (unode = usculpt->nodes.first; unode; unode = unode->next) { | for (unode = usculpt->nodes.first; unode; unode = unode->next) { | ||||
| if (unode->no) { | if (unode->no) { | ||||
| MEM_freeN(unode->no); | MEM_freeN(unode->no); | ||||
| unode->no = NULL; | unode->no = NULL; | ||||
| } | } | ||||
| if (unode->node) | if (unode->node) | ||||
| BKE_pbvh_node_layer_disp_free(unode->node); | BKE_pbvh_node_layer_disp_free(unode->node); | ||||
| } | } | ||||
| wmWindowManager *wm = G.main->wm.first; /* XXX, avoids adding extra arg. */ | UndoStack *ustack = ED_undo_stack_get(); | ||||
| BKE_undosys_step_push(wm->undo_stack, NULL, NULL); | BKE_undosys_step_push(ustack, NULL, NULL); | ||||
| } | } | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Implements ED Undo System | /** \name Implements ED Undo System | ||||
| * \{ */ | * \{ */ | ||||
| typedef struct SculptUndoStep { | typedef struct SculptUndoStep { | ||||
| UndoStep step; | UndoStep step; | ||||
| ▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | |||||
| static UndoSculpt *sculpt_undosys_step_get_nodes(UndoStep *us_p) | static UndoSculpt *sculpt_undosys_step_get_nodes(UndoStep *us_p) | ||||
| { | { | ||||
| SculptUndoStep *us = (SculptUndoStep *)us_p; | SculptUndoStep *us = (SculptUndoStep *)us_p; | ||||
| return &us->data; | return &us->data; | ||||
| } | } | ||||
| static UndoSculpt *sculpt_undo_get_nodes(void) | static UndoSculpt *sculpt_undo_get_nodes(void) | ||||
| { | { | ||||
| wmWindowManager *wm = G.main->wm.first; /* XXX, avoids adding extra arg. */ | UndoStack *ustack = ED_undo_stack_get(); | ||||
| UndoStep *us = BKE_undosys_stack_init_or_active_with_type(wm->undo_stack, BKE_UNDOSYS_TYPE_SCULPT); | UndoStep *us = BKE_undosys_stack_init_or_active_with_type(ustack, BKE_UNDOSYS_TYPE_SCULPT); | ||||
| return sculpt_undosys_step_get_nodes(us); | return sculpt_undosys_step_get_nodes(us); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||