[Bf-blender-cvs] [5e65791516b] master: Fix T53347: Vertex paint crash

Campbell Barton noreply at git.blender.org
Fri Feb 9 02:11:25 CET 2018


Commit: 5e65791516b6e7c3ad22c7a46070c3fe34999f29
Author: Campbell Barton
Date:   Fri Feb 9 11:58:19 2018 +1100
Branches: master
https://developer.blender.org/rB5e65791516b6e7c3ad22c7a46070c3fe34999f29

Fix T53347: Vertex paint crash

Vertex paint was still using sculpt mode brush (which can be NULL).

===================================================================

M	source/blender/editors/sculpt_paint/sculpt.c

===================================================================

diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 696267a0e8e..d631a23bee0 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -4591,16 +4591,15 @@ static bool sculpt_any_smooth_mode(const Brush *brush,
 	         (brush->mask_tool == BRUSH_MASK_SMOOTH)));
 }
 
-static void sculpt_stroke_modifiers_check(const bContext *C, Object *ob)
+static void sculpt_stroke_modifiers_check(const bContext *C, Object *ob, const Brush *brush)
 {
 	SculptSession *ss = ob->sculpt;
 
 	if (ss->kb || ss->modifiers_active) {
-		Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
-		Brush *brush = BKE_paint_brush(&sd->paint);
-
-		BKE_sculpt_update_mesh_elements(CTX_data_scene(C), sd, ob,
-		                            sculpt_any_smooth_mode(brush, ss->cache, 0), false);
+		Scene *scene = CTX_data_scene(C);
+		Sculpt *sd = scene->toolsettings->sculpt;
+		bool need_pmap = sculpt_any_smooth_mode(brush, ss->cache, 0);
+		BKE_sculpt_update_mesh_elements(scene, sd, ob, need_pmap, false);
 	}
 }
 
@@ -4729,7 +4728,9 @@ bool sculpt_stroke_get_location(bContext *C, float out[3], const float mouse[2])
 	cache = ss->cache;
 	original = (cache) ? cache->original : 0;
 
-	sculpt_stroke_modifiers_check(C, ob);
+	const Brush *brush = BKE_paint_brush(BKE_paint_get_active_from_context(C));
+
+	sculpt_stroke_modifiers_check(C, ob, brush);
 
 	depth = sculpt_raycast_init(&vc, mouse, ray_start, ray_end, ray_normal, original);
 
@@ -4755,7 +4756,6 @@ bool sculpt_stroke_get_location(bContext *C, float out[3], const float mouse[2])
 	}
 
 	if (hit == false) {
-		const Brush *brush = BKE_paint_brush(BKE_paint_get_active_from_context(C));
 		if (ELEM(brush->falloff_shape, PAINT_FALLOFF_SHAPE_TUBE)) {
 			SculptFindNearestToRayData srd = {
 				.original = original,
@@ -4940,7 +4940,7 @@ static void sculpt_stroke_update_step(bContext *C, struct PaintStroke *UNUSED(st
 	SculptSession *ss = ob->sculpt;
 	const Brush *brush = BKE_paint_brush(&sd->paint);
 	
-	sculpt_stroke_modifiers_check(C, ob);
+	sculpt_stroke_modifiers_check(C, ob, brush);
 	sculpt_update_cache_variants(C, sd, ob, itemptr);
 	sculpt_restore_mesh(sd, ob);
 
@@ -5015,7 +5015,7 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str
 		BLI_assert(brush == ss->cache->brush);  /* const, so we shouldn't change. */
 		ups->draw_inverted = false;
 
-		sculpt_stroke_modifiers_check(C, ob);
+		sculpt_stroke_modifiers_check(C, ob, brush);
 
 		/* Alt-Smooth */
 		if (ss->cache->alt_smooth) {
@@ -5832,7 +5832,9 @@ static void sample_detail(bContext *C, int ss_co[2])
 	sd = CTX_data_tool_settings(C)->sculpt;
 	ob = vc.obact;
 
-	sculpt_stroke_modifiers_check(C, ob);
+	Brush *brush = BKE_paint_brush(&sd->paint);
+
+	sculpt_stroke_modifiers_check(C, ob, brush);
 
 	depth = sculpt_raycast_init(&vc, mouse, ray_start, ray_end, ray_normal, false);



More information about the Bf-blender-cvs mailing list