[Bf-blender-cvs] [515e69999e6] master: Weight Paint: don't set weight w/ average brush

Campbell Barton noreply at git.blender.org
Tue Oct 3 09:55:27 CEST 2017


Commit: 515e69999e63aab7720e48b0c85233f61facce65
Author: Campbell Barton
Date:   Tue Oct 3 18:43:18 2017 +1100
Branches: master
https://developer.blender.org/rB515e69999e63aab7720e48b0c85233f61facce65

Weight Paint: don't set weight w/ average brush

Also use 'const' for brush.

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

M	source/blender/blenkernel/BKE_brush.h
M	source/blender/blenkernel/intern/brush.c
M	source/blender/editors/sculpt_paint/paint_intern.h
M	source/blender/editors/sculpt_paint/paint_utils.c
M	source/blender/editors/sculpt_paint/paint_vertex.c
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_intern.h
M	source/blender/render/extern/include/RE_render_ext.h
M	source/blender/render/intern/source/render_texture.c

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

diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h
index c1e107e101a..c6d4217780e 100644
--- a/source/blender/blenkernel/BKE_brush.h
+++ b/source/blender/blenkernel/BKE_brush.h
@@ -74,7 +74,7 @@ float BKE_brush_curve_strength(const struct Brush *br, float p, const float len)
 
 /* sampling */
 float BKE_brush_sample_tex_3D(
-        const struct Scene *scene, struct Brush *br, const float point[3],
+        const struct Scene *scene, const struct Brush *br, const float point[3],
         float rgba[4], const int thread, struct ImagePool *pool);
 float BKE_brush_sample_masktex(
         const struct Scene *scene, struct Brush *br, const float point[2],
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 0300dfe5891..4a54ab26373 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -521,13 +521,13 @@ int BKE_brush_clone_image_delete(Brush *brush)
  * region space mouse coordinates, or 3d world coordinates for 3D mapping.
  *
  * rgba outputs straight alpha. */
-float BKE_brush_sample_tex_3D(const Scene *scene, Brush *br,
+float BKE_brush_sample_tex_3D(const Scene *scene, const Brush *br,
                               const float point[3],
                               float rgba[4], const int thread,
                               struct ImagePool *pool)
 {
 	UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
-	MTex *mtex = &br->mtex;
+	const MTex *mtex = &br->mtex;
 	float intensity = 1.0;
 	bool hasrgb = false;
 
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index bd35218bb64..f6fcbfdfbee 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -242,8 +242,8 @@ void paint_calc_redraw_planes(float planes[4][4],
                               const struct rcti *screen_rect);
 
 float paint_calc_object_space_radius(struct ViewContext *vc, const float center[3], float pixel_radius);
-float paint_get_tex_pixel(struct MTex *mtex, float u, float v, struct ImagePool *pool, int thread);
-void paint_get_tex_pixel_col(struct MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool, int thread, bool convert, struct ColorSpace *colorspace);
+float paint_get_tex_pixel(const struct MTex *mtex, float u, float v, struct ImagePool *pool, int thread);
+void paint_get_tex_pixel_col(const struct MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool, int thread, bool convert, struct ColorSpace *colorspace);
 
 void paint_sample_color(struct bContext *C, struct ARegion *ar, int x, int y, bool texpaint_proj, bool palette);
 
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index 10628d8cccb..7668b8ebd99 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -171,7 +171,7 @@ float paint_calc_object_space_radius(ViewContext *vc, const float center[3],
 	return len_v3(delta) / scale;
 }
 
-float paint_get_tex_pixel(MTex *mtex, float u, float v, struct ImagePool *pool, int thread)
+float paint_get_tex_pixel(const MTex *mtex, float u, float v, struct ImagePool *pool, int thread)
 {
 	float intensity, rgba[4];
 	float co[3] = {u, v, 0.0f};
@@ -182,7 +182,7 @@ float paint_get_tex_pixel(MTex *mtex, float u, float v, struct ImagePool *pool,
 	return intensity;
 }
 
-void paint_get_tex_pixel_col(MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool, int thread, bool convert_to_linear, struct ColorSpace *colorspace)
+void paint_get_tex_pixel_col(const MTex *mtex, float u, float v, float rgba[4], struct ImagePool *pool, int thread, bool convert_to_linear, struct ColorSpace *colorspace)
 {
 	float co[3] = {u, v, 0.0f};
 	int hasrgb;
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 4dd218114f6..c61d250446c 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -262,12 +262,12 @@ uint vpaint_get_current_col(Scene *scene, VPaint *vp)
 
 /* wpaint has 'wpaint_blend' */
 static uint vpaint_blend(
-        VPaint *vp, uint color_curr, uint color_orig,
+        const VPaint *vp, uint color_curr, uint color_orig,
         uint color_paint, const int alpha_i,
         /* pre scaled from [0-1] --> [0-255] */
         const int brush_alpha_value_i)
 {
-	Brush *brush = BKE_paint_brush(&vp->paint);
+	const Brush *brush = vp->paint.brush;
 	const int tool = brush->vertexpaint_tool;
 
 	uint color_blend = ED_vpaint_blend_tool(tool, color_curr, color_paint, alpha_i);
@@ -383,12 +383,12 @@ static float calc_vp_alpha_col_dl(
 
 /* vpaint has 'vpaint_blend' */
 static float wpaint_blend(
-        VPaint *wp, float weight,
+        const VPaint *wp, float weight,
         const float alpha, float paintval,
         const float UNUSED(brush_alpha_value),
         const short do_flip)
 {
-	Brush *brush = BKE_paint_brush(&wp->paint);
+	const Brush *brush = wp->paint.brush;
 	int tool = brush->vertexpaint_tool;
 
 	if (do_flip) {
@@ -698,7 +698,7 @@ typedef struct WeightPaintInfo {
 
 static void do_weight_paint_vertex_single(
         /* vars which remain the same for every vert */
-        VPaint *wp, Object *ob, const WeightPaintInfo *wpi,
+        const VPaint *wp, Object *ob, const WeightPaintInfo *wpi,
         /* vars which change on each stroke */
         const uint index, float alpha, float paintweight)
 {
@@ -847,7 +847,7 @@ static void do_weight_paint_vertex_single(
 
 static void do_weight_paint_vertex_multi(
         /* vars which remain the same for every vert */
-        VPaint *wp, Object *ob, const WeightPaintInfo *wpi,
+        const VPaint *wp, Object *ob, const WeightPaintInfo *wpi,
         /* vars which change on each stroke */
         const uint index, float alpha, float paintweight)
 {
@@ -945,7 +945,7 @@ static void do_weight_paint_vertex_multi(
 
 static void do_weight_paint_vertex(
         /* vars which remain the same for every vert */
-        VPaint *wp, Object *ob, const WeightPaintInfo *wpi,
+        const VPaint *wp, Object *ob, const WeightPaintInfo *wpi,
         /* vars which change on each stroke */
         const uint index, float alpha, float paintweight)
 {
@@ -1199,12 +1199,12 @@ struct WPaintData {
 
 /* Initialize the stroke cache invariants from operator properties */
 static void vwpaint_update_cache_invariants(
-        bContext *C, VPaint *vp, SculptSession *ss, wmOperator *op, const float mouse[2])
+        bContext *C, const VPaint *vp, SculptSession *ss, wmOperator *op, const float mouse[2])
 {
 	StrokeCache *cache;
 	Scene *scene = CTX_data_scene(C);
 	UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings;
-	Brush *brush = BKE_paint_brush(&vp->paint);
+	const Brush *brush = vp->paint.brush;
 	ViewContext *vc = paint_stroke_view_context(op->customdata);
 	Object *ob = CTX_data_active_object(C);
 	float mat[3][3];
@@ -1667,7 +1667,7 @@ static void do_wpaint_brush_smear_task_cb_ex(
 						/* Apply weight to vertex */
 						if (do_color) {
 							const float brush_fade = BKE_brush_curve_strength(brush, 0.0f, cache->radius);
-							float final_alpha =
+							const float final_alpha =
 							        brush_fade * brush_strength *
 							        grid_alpha * brush_alpha_pressure;
 							do_weight_paint_vertex(
@@ -1692,7 +1692,9 @@ static void do_wpaint_brush_draw_task_cb_ex(
 
 	const Brush *brush = data->brush;
 	const StrokeCache *cache = ss->cache;
-	const float paintweight = BKE_brush_weight_get(scene, brush);
+	/* note: normally `BKE_brush_weight_get(scene, brush)` is used,
+	 * however in this case we calculate a new weight each time. */
+	const float paintweight = data->strength;
 	float brush_size_pressure, brush_alpha_value, brush_alpha_pressure;
 	get_brush_alpha_data(scene, ss, brush, &brush_size_pressure, &brush_alpha_value, &brush_alpha_pressure);
 	const bool use_normal = vwpaint_use_normal(data->vp);
@@ -1820,10 +1822,7 @@ static void calculate_average_weight(SculptThreadedTaskData *data, PBVHNode **UN
 	}
 	if (accum_len != 0) {
 		accum_weight /= accum_len;
-		if (ups->flag & UNIFIED_PAINT_WEIGHT)
-			ups->weight = (float)accum_weight;
-		else
-			data->brush->weight = (float)accum_weight;
+		data->strength = (float)accum_weight;
 	}
 
 	MEM_SAFE_FREE(data->custom_data);  /* 'accum' */
@@ -1834,7 +1833,7 @@ static void wpaint_paint_leaves(
         bContext *C, Object *ob, Sculpt *sd, VPaint *vp, struct WPaintData *wpd, WeightPaintInfo *wpi,
         Mesh *me, PBVHNode **nodes, int totnode)
 {
-	Brush *brush = ob->sculpt->cache->brush;
+	const Brush *brush = ob->sculpt->cache->brush;
 
 	/* threaded loop over nodes */
 	SculptThreadedTaskData data = {
@@ -2733,6 +2732,7 @@ static void do_vpaint_brush_smear_task_cb_ex(
 							const int p_index = gmap->vert_to_poly[v_index].indices[j];
 							const int l_index = gmap->vert_to_loop[v_index].indices[j];
 							BLI_assert(data->me->mloop[l_index].v == v_index);
+							UNUSED_VARS_NDEBUG(l_index);
 							const MPoly *mp = &data->me->mpoly[p_index];
 							if (!use_face_sel || mp->flag & ME_FACE_SEL) {
 								const MLoop *ml_other = &data->me->mloop[mp->loopstart];
@@ -2829,7 +2829,7 @@ static void vpaint_paint_leaves(
         bContext *C, Sculpt *sd, VPaint *vp, struct VPaintData *vpd,
         Object *ob, Mesh *me, PBVHNode **nodes, int totnode)
 {
-	Brush *brush = ob->sculpt->cache->brush;
+	const Brush *brush = ob->sculpt->cache->brush;
 
 	SculptThreadedTaskData data = {
 		.sd = sd, .ob = ob, .brush = brush, .nodes = nodes, .vp = vp, .vpd = vpd,
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 1698ab9e5c7..e8ea7f6709c 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -634,7 +634,7 @@ bool sculpt_brush_test_cube(SculptBrushTest *test, const float co[3], float loca
 	}
 }
 
-static float frontface(Brush *br, const float sculp

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list