Fix T53943: Weight paint crash in new scene
This commit is contained in:
parent
b0af44fa4d
commit
d0f63d402d
Notes:
blender-bot
2023-02-14 07:36:17 +01:00
Referenced by issue #53943, Weight Paint Crash In New Scene
|
@ -253,6 +253,7 @@ void BKE_sculpt_update_mesh_elements(struct Scene *scene, struct Sculpt *sd, str
|
|||
struct MultiresModifierData *BKE_sculpt_multires_active(struct Scene *scene, struct Object *ob);
|
||||
int BKE_sculpt_mask_layers_ensure(struct Object *ob,
|
||||
struct MultiresModifierData *mmd);
|
||||
void BKE_sculpt_toolsettings_data_ensure(struct Scene *scene);
|
||||
|
||||
enum {
|
||||
SCULPT_MASK_LAYER_CALC_VERT = (1 << 0),
|
||||
|
|
|
@ -1057,3 +1057,39 @@ int BKE_sculpt_mask_layers_ensure(Object *ob, MultiresModifierData *mmd)
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void BKE_sculpt_toolsettings_data_ensure(struct Scene *scene)
|
||||
{
|
||||
Sculpt *sd = scene->toolsettings->sculpt;
|
||||
if (sd == NULL) {
|
||||
sd = scene->toolsettings->sculpt = MEM_callocN(sizeof(Sculpt), __func__);
|
||||
|
||||
/* Turn on X plane mirror symmetry by default */
|
||||
sd->paint.symmetry_flags |= PAINT_SYMM_X;
|
||||
sd->paint.flags |= PAINT_SHOW_BRUSH;
|
||||
|
||||
/* Make sure at least dyntopo subdivision is enabled */
|
||||
sd->flags |= SCULPT_DYNTOPO_SUBDIVIDE | SCULPT_DYNTOPO_COLLAPSE;
|
||||
}
|
||||
|
||||
if (!sd->detail_size) {
|
||||
sd->detail_size = 12;
|
||||
}
|
||||
if (!sd->detail_percent) {
|
||||
sd->detail_percent = 25;
|
||||
}
|
||||
if (sd->constant_detail == 0.0f) {
|
||||
sd->constant_detail = 3.0f;
|
||||
}
|
||||
|
||||
/* Set sane default tiling offsets */
|
||||
if (!sd->paint.tile_offset[0]) {
|
||||
sd->paint.tile_offset[0] = 1.0f;
|
||||
}
|
||||
if (!sd->paint.tile_offset[1]) {
|
||||
sd->paint.tile_offset[1] = 1.0f;
|
||||
}
|
||||
if (!sd->paint.tile_offset[2]) {
|
||||
sd->paint.tile_offset[2] = 1.0f;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue