Sculpt-dev: fix crash

* Tool slots weren't initializes sculpt
  brushes properly.
This commit is contained in:
Joseph Eagar 2021-11-19 06:58:54 -08:00
parent 26a82fd5cc
commit bcf91617b3
3 changed files with 20 additions and 1 deletions

View File

@ -1105,6 +1105,14 @@ void brush_channel_apply_mapping_flags(BrushChannel *ch, BrushChannel *child, Br
BrushMapping *cmp = child ? child->mappings + i : NULL;
BrushMapping *pmp = parent ? parent->mappings + i : NULL;
if (!cmp) {
if (pmp) {
*mp = *pmp;
}
continue;
}
if (pmp && brush_mapping_inherits(child, cmp)) {
*mp = *pmp;
}

View File

@ -660,9 +660,17 @@ static int brush_tool(const Brush *brush, size_t tool_offset)
return *(((char *)brush) + tool_offset);
}
static void brush_tool_set(const Brush *brush, size_t tool_offset, int tool)
static void brush_tool_set(Brush *brush, size_t tool_offset, int tool)
{
*(((char *)brush) + tool_offset) = tool;
if (tool_offset == offsetof(Brush, sculpt_tool)) {
if (!brush->channels) {
brush->channels = BKE_brush_channelset_create(__func__);
}
BKE_brush_builtin_patch(brush, tool);
}
}
static Brush *brush_tool_cycle(Main *bmain, Paint *paint, Brush *brush_orig, const int tool)

View File

@ -8401,6 +8401,9 @@ static bool sculpt_stroke_test_start(bContext *C, struct wmOperator *op, const f
channels = sculpt_init_tool_override_channels(sd, ob->sculpt, tool);
}
//paranoia check to correct corrupted brushes
BKE_brush_builtin_patch(brush, brush->sculpt_tool);
BKE_brush_channelset_compat_load(sculpt_get_brush_channels(ob->sculpt, brush), brush, false);
if (tool) {