Fix #135931: Paint brush with gravity factor can crash Blender
This commit prevents the "Gravity" value from having an effect on brushes that are based on either the Paint or Smear brush in addition to the ones that are already filtered. Prior versions of blender don't crash, but still deformed the mesh, which is unexpected & undesired. Pull Request: https://projects.blender.org/blender/blender/pulls/135944
This commit is contained in:
@@ -3520,11 +3520,7 @@ static void do_brush_action(const Depsgraph &depsgraph,
|
||||
}
|
||||
|
||||
/* The cloth brush adds the gravity as a regular force and it is processed in the solver. */
|
||||
if (ss.cache->supports_gravity && !ELEM(brush.sculpt_brush_type,
|
||||
SCULPT_BRUSH_TYPE_CLOTH,
|
||||
SCULPT_BRUSH_TYPE_DRAW_FACE_SETS,
|
||||
SCULPT_BRUSH_TYPE_BOUNDARY))
|
||||
{
|
||||
if (ss.cache->supports_gravity && brush.sculpt_brush_type != SCULPT_BRUSH_TYPE_CLOTH) {
|
||||
do_gravity_brush(depsgraph, sd, ob, node_mask);
|
||||
}
|
||||
|
||||
@@ -4121,13 +4117,8 @@ static void sculpt_update_cache_invariants(
|
||||
mul_m3_v3(mat, viewDir);
|
||||
normalize_v3_v3(cache->view_normal, viewDir);
|
||||
|
||||
cache->supports_gravity = (!ELEM(brush->sculpt_brush_type,
|
||||
SCULPT_BRUSH_TYPE_MASK,
|
||||
SCULPT_BRUSH_TYPE_SMOOTH,
|
||||
SCULPT_BRUSH_TYPE_SIMPLIFY,
|
||||
SCULPT_BRUSH_TYPE_DISPLACEMENT_SMEAR,
|
||||
SCULPT_BRUSH_TYPE_DISPLACEMENT_ERASER) &&
|
||||
(sd.gravity_factor > 0.0f));
|
||||
cache->supports_gravity = brush_type_supports_gravity(brush->sculpt_brush_type) &&
|
||||
(sd.gravity_factor > 0.0f);
|
||||
/* Get gravity vector in world space. */
|
||||
if (cache->supports_gravity) {
|
||||
if (sd.gravity_object) {
|
||||
|
||||
@@ -988,6 +988,16 @@ inline bool brush_uses_vector_displacement(const Brush &brush)
|
||||
brush.mtex.brush_map_mode == MTEX_MAP_MODE_AREA;
|
||||
}
|
||||
|
||||
inline bool brush_type_supports_gravity(const int tool)
|
||||
{
|
||||
return !brush_type_is_attribute_only(tool) && !ELEM(tool,
|
||||
SCULPT_BRUSH_TYPE_BOUNDARY,
|
||||
SCULPT_BRUSH_TYPE_SMOOTH,
|
||||
SCULPT_BRUSH_TYPE_SIMPLIFY,
|
||||
SCULPT_BRUSH_TYPE_DISPLACEMENT_SMEAR,
|
||||
SCULPT_BRUSH_TYPE_DISPLACEMENT_ERASER);
|
||||
}
|
||||
|
||||
} // namespace blender::ed::sculpt_paint
|
||||
|
||||
namespace blender::ed::sculpt_paint {
|
||||
|
||||
Reference in New Issue
Block a user