diff --git a/source/blender/include/BDR_sculptmode.h b/source/blender/include/BDR_sculptmode.h index cf58d711801..7272df21aa3 100644 --- a/source/blender/include/BDR_sculptmode.h +++ b/source/blender/include/BDR_sculptmode.h @@ -89,13 +89,13 @@ typedef struct SculptSession { vec3f pivot; } SculptSession; -SculptSession *sculpt_session(); -struct SculptData *sculpt_data(); +SculptSession *sculpt_session(void); +struct SculptData *sculpt_data(void); /* Memory */ void sculptmode_init(struct Scene *); void sculptmode_free_all(struct Scene *); -void sculptmode_correct_state(); +void sculptmode_correct_state(void); /* Undo */ typedef enum SculptUndoType { @@ -105,9 +105,10 @@ typedef enum SculptUndoType { SUNDO_MRES= 8 /* Mesh.mr changed */ } SculptUndoType; void sculptmode_undo_push(char *str, SculptUndoType type); -void sculptmode_undo(); -void sculptmode_redo(); -void sculptmode_undo_menu(); +void sculptmode_undo(void); +void sculptmode_redo(void); +void sculptmode_undo_menu(void); +void sculptmode_undo_free(struct Scene *sce); /* Interface */ void sculptmode_draw_interface_tools(struct uiBlock *block,unsigned short cx, unsigned short cy); @@ -115,17 +116,17 @@ void sculptmode_draw_interface_textures(struct uiBlock *block,unsigned short cx, void sculptmode_rem_tex(void*,void*); void sculptmode_propset_init(PropsetMode mode); void sculptmode_propset(const unsigned short event); -void sculptmode_selectbrush_menu(); +void sculptmode_selectbrush_menu(void); void sculptmode_draw_mesh(int); void sculpt_paint_brush(char clear); -struct BrushData *sculptmode_brush(); -float *get_tex_angle(); +struct BrushData *sculptmode_brush(void); +float *get_tex_angle(void); -void sculptmode_update_tex(); +void sculptmode_update_tex(void); char sculpt_modifiers_active(struct Object *ob); -void sculpt(); -void set_sculptmode(); +void sculpt(void); +void set_sculptmode(void); /* Partial Mesh Visibility */ struct PartialVisibility *sculptmode_copy_pmv(struct PartialVisibility *); diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index 836518964b8..0a74f65c619 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -1696,6 +1696,9 @@ void exit_editmode(int flag) /* freedata==0 at render, 1= freedata, 2= do undo b allqueue(REDRAWIMAGE, 0); if(G.f & G_WEIGHTPAINT) mesh_octree_table(G.obedit, NULL, 'e'); + /* to be sure, adding/removing data crashes undo for sculpt (ton) */ + if(G.f & G_SCULPTMODE) + sculptmode_undo_free(G.scene); } else if (G.obedit->type==OB_ARMATURE){ load_editArmature(); diff --git a/source/blender/src/sculptmode.c b/source/blender/src/sculptmode.c index ac03d36e1cb..2a00287426e 100644 --- a/source/blender/src/sculptmode.c +++ b/source/blender/src/sculptmode.c @@ -161,13 +161,14 @@ typedef struct ProjVert { static ProjVert *projverts= NULL; static Object *active_ob= NULL; -SculptData *sculpt_data() +SculptData *sculpt_data(void) { return &G.scene->sculptdata; } -void sculpt_init_session(); -SculptSession *sculpt_session() +void sculpt_init_session(void); + +SculptSession *sculpt_session(void) { if(!sculpt_data()->session) sculpt_init_session(); @@ -212,7 +213,7 @@ void sculptmode_init(Scene *sce) void sculptmode_undo_init(); void sculptmode_free_session(Scene *); -void sculpt_init_session() +void sculpt_init_session(void) { if(sculpt_data()->session) sculptmode_free_session(G.scene); @@ -336,6 +337,7 @@ void sculptmode_undo_pull_chopped(SculptUndoStep *sus) } } +/* also called now after leave mesh editmode. prevent crashing when data amount changes */ void sculptmode_undo_free(Scene *sce) { SculptSession *ss= sce->sculptdata.session; @@ -508,7 +510,7 @@ void sculptmode_undo_update(SculptUndoStep *newcur) allqueue(REDRAWBUTSEDIT, 0); } -void sculptmode_undo() +void sculptmode_undo(void) { SculptUndo *su= sculpt_session()->undo; @@ -516,7 +518,7 @@ void sculptmode_undo() sculptmode_undo_update(su->cur->prev); } -void sculptmode_redo() +void sculptmode_redo(void) { SculptUndo *su= sculpt_session()->undo; @@ -524,7 +526,7 @@ void sculptmode_redo() sculptmode_undo_update(su->cur->next); } -void sculptmode_undo_menu() +void sculptmode_undo_menu(void) { SculptUndo *su= sculpt_session()->undo; SculptUndoStep *sus; @@ -1004,7 +1006,7 @@ unsigned *get_ri_pixel(const RenderInfo *ri, int px, int py) } /* Use the warpfac field in MTex to store a rotation value for sculpt textures. */ -float *get_tex_angle() +float *get_tex_angle(void) { SculptData *sd= sculpt_data(); if(sd->texact!=-1 && sd->mtex[sd->texact]) @@ -1326,7 +1328,7 @@ void calc_damaged_verts(ListBase *damaged_verts, GrabData *grabdata) } } -BrushData *sculptmode_brush() +BrushData *sculptmode_brush(void) { SculptData *sd= &G.scene->sculptdata; return (sd->brush_type==DRAW_BRUSH ? &sd->drawbrush : @@ -1694,7 +1696,7 @@ void sculptmode_propset(unsigned short event) sculptmode_propset_header(); } -void sculptmode_selectbrush_menu() +void sculptmode_selectbrush_menu(void) { SculptData *sd= sculpt_data(); int val; @@ -1745,7 +1747,8 @@ void sculptmode_draw_wires(int only_damaged, Mesh *me) bglPolygonOffset(0.0); } -void sculptmode_draw_mesh(int only_damaged) { +void sculptmode_draw_mesh(int only_damaged) +{ Mesh *me= get_mesh(OBACT); int i, j, dt, drawCurrentMat = 1, matnr= -1; @@ -1799,7 +1802,7 @@ void sculptmode_draw_mesh(int only_damaged) { glDisable(GL_DEPTH_TEST); } -void sculptmode_correct_state() +void sculptmode_correct_state(void) { if(!sculpt_session()) sculpt_init_session(); @@ -1824,7 +1827,7 @@ char sculpt_modifiers_active(Object *ob) return 0; } -void sculpt() +void sculpt(void) { SculptData *sd= sculpt_data(); SculptSession *ss= sculpt_session(); @@ -2042,7 +2045,7 @@ void sculpt() allqueue(REDRAWVIEW3D, 0); } -void set_sculptmode() +void set_sculptmode(void) { if(G.f & G_SCULPTMODE) { Mesh *me= get_mesh(OBACT);