Fix T70790: Crash in sculpt mode switching from two meshes after reload saved file

This fixes the crash, but it does not fix the core issue. The PBVH should
always be available when an object is in sculpt mode and tools should
not need to check for that.

Reviewed By: jbakker

Maniphest Tasks: T70790

Differential Revision: https://developer.blender.org/D6063
This commit is contained in:
Pablo Dobarro 2019-10-18 16:33:14 +02:00
parent 082fb6603d
commit 970d7ed860
Notes: blender-bot 2023-04-04 07:45:26 +02:00
Referenced by issue #70962, Render image / render animation crash with OptiX enabled (works with CUDA)
Referenced by issue #70790, crash in sculpt mode switching from two meshes after reload saved file
Referenced by issue #67718, Point density texture crashes
Referenced by issue #65511, Opening Blender's File Chooser from a Dialog Causes Blender to Crash
1 changed files with 4 additions and 4 deletions

View File

@ -6369,9 +6369,9 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, Po
/* Returns true if any of the smoothing modes are active (currently
* one of smooth brush, autosmooth, mask smooth, or shift-key
* smooth) */
static bool sculpt_needs_conectivity_info(const Brush *brush, SculptSession *ss, int stroke_mode)
static bool sculpt_needs_connectivity_info(const Brush *brush, SculptSession *ss, int stroke_mode)
{
if (ss && sculpt_automasking_enabled(ss, brush)) {
if (ss && ss->pbvh && sculpt_automasking_enabled(ss, brush)) {
return true;
}
return ((stroke_mode == BRUSH_STROKE_SMOOTH) || (ss && ss->cache && ss->cache->alt_smooth) ||
@ -6385,7 +6385,7 @@ static void sculpt_stroke_modifiers_check(const bContext *C, Object *ob, const B
SculptSession *ss = ob->sculpt;
View3D *v3d = CTX_wm_view3d(C);
bool need_pmap = sculpt_needs_conectivity_info(brush, ss, 0);
bool need_pmap = sculpt_needs_connectivity_info(brush, ss, 0);
if (ss->shapekey_active || ss->deform_modifiers_active ||
(!BKE_sculptsession_use_pbvh_draw(ob, v3d) && need_pmap)) {
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
@ -6738,7 +6738,7 @@ static void sculpt_brush_stroke_init(bContext *C, wmOperator *op)
view3d_operator_needs_opengl(C);
sculpt_brush_init_tex(scene, sd, ss);
is_smooth = sculpt_needs_conectivity_info(brush, ss, mode);
is_smooth = sculpt_needs_connectivity_info(brush, ss, mode);
BKE_sculpt_update_object_for_edit(depsgraph, ob, is_smooth, need_mask);
}