From d0f63d402db5260d57dc60cf52aa029d7f11f161 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 30 Jan 2018 20:33:20 +1100 Subject: Fix T53943: Weight paint crash in new scene --- source/blender/editors/sculpt_paint/paint_vertex.c | 3 +++ source/blender/editors/sculpt_paint/sculpt.c | 29 +++------------------- 2 files changed, 6 insertions(+), 26 deletions(-) (limited to 'source/blender/editors/sculpt_paint') diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index a5405338ada..490343ab1f2 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -939,6 +939,9 @@ static void do_weight_paint_vertex( /* Toggle operator for turning vertex paint mode on or off (copied from sculpt.c) */ static void vertex_paint_init_session(Scene *scene, Object *ob) { + /* Create persistent sculpt mode data */ + BKE_sculpt_toolsettings_data_ensure(scene); + if (ob->sculpt == NULL) { ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session"); BKE_sculpt_update_mesh_elements(scene, scene->toolsettings->sculpt, ob, 0, false); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 37af1732045..2468f273a04 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -5585,8 +5585,10 @@ static void SCULPT_OT_symmetrize(wmOperatorType *ot) static void sculpt_init_session(Scene *scene, Object *ob) { - ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session"); + /* Create persistent sculpt mode data */ + BKE_sculpt_toolsettings_data_ensure(scene); + ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session"); BKE_sculpt_update_mesh_elements(scene, scene->toolsettings->sculpt, ob, 0, false); } @@ -5650,31 +5652,6 @@ static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op) if (flush_recalc) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - /* Create persistent sculpt mode data */ - if (!ts->sculpt) { - ts->sculpt = MEM_callocN(sizeof(Sculpt), "sculpt mode data"); - - /* Turn on X plane mirror symmetry by default */ - ts->sculpt->paint.symmetry_flags |= PAINT_SYMM_X; - ts->sculpt->paint.flags |= PAINT_SHOW_BRUSH; - - /* Make sure at least dyntopo subdivision is enabled */ - ts->sculpt->flags |= SCULPT_DYNTOPO_SUBDIVIDE | SCULPT_DYNTOPO_COLLAPSE; - } - - if (!ts->sculpt->detail_size) - ts->sculpt->detail_size = 12; - if (!ts->sculpt->detail_percent) - ts->sculpt->detail_percent = 25; - if (ts->sculpt->constant_detail == 0.0f) - ts->sculpt->constant_detail = 3.0f; - - /* Set sane default tiling offsets */ - if (!ts->sculpt->paint.tile_offset[0]) ts->sculpt->paint.tile_offset[0] = 1.0f; - if (!ts->sculpt->paint.tile_offset[1]) ts->sculpt->paint.tile_offset[1] = 1.0f; - if (!ts->sculpt->paint.tile_offset[2]) ts->sculpt->paint.tile_offset[2] = 1.0f; - - /* Create sculpt mode session data */ if (ob->sculpt) BKE_sculptsession_free(ob); -- cgit v1.2.3