[Bf-blender-cvs] [41050c0] soc-2016-pbvh-painting: more refactoring. Removed OpenMP flags since the multithreading support isn't really OpenMP.

Nathan Vollmer noreply at git.blender.org
Sun Aug 14 00:53:54 CEST 2016


Commit: 41050c0dbfdac575a3ee8ac5bd75f5cca5341b4c
Author: Nathan Vollmer
Date:   Sat Aug 13 15:20:37 2016 -0600
Branches: soc-2016-pbvh-painting
https://developer.blender.org/rB41050c0dbfdac575a3ee8ac5bd75f5cca5341b4c

more refactoring. Removed OpenMP flags since the multithreading support isn't really OpenMP.

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

M	source/blender/editors/sculpt_paint/paint_vertex.c
M	source/blender/editors/sculpt_paint/sculpt_intern.h
M	source/blender/makesrna/intern/rna_brush.c
M	source/blender/makesrna/intern/rna_sculpt_paint.c

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

diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 5ebe2b1..a1fe7b9 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -613,18 +613,18 @@ BLI_INLINE unsigned int mcol_blend(unsigned int col1, unsigned int col2, int fac
 	cp2 = (unsigned char *)&col2;
 	cp  = (unsigned char *)&col;
 
-  // Updated to use the rgb squared color model which blends more realistically. -N8V
-  int red1 = cp1[0] * cp1[0];
-  int green1 = cp1[1] * cp1[1];
-  int blue1 = cp1[2] * cp1[2];
-
-  int red2 = cp2[0] * cp2[0];
-  int green2 = cp2[1] * cp2[1];
-  int blue2 = cp2[2] * cp2[2];
-
-  cp[0] = (unsigned char)round(sqrt(divide_round_i((mfac * red1 + fac * red2), 255)));
-  cp[1] = (unsigned char)round(sqrt(divide_round_i((mfac * green1 + fac * green2), 255)));
-  cp[2] = (unsigned char)round(sqrt(divide_round_i((mfac * blue1 + fac * blue2), 255)));
+	// Updated to use the rgb squared color model which blends more realistically. -N8V
+	int red1 = cp1[0] * cp1[0];
+	int green1 = cp1[1] * cp1[1];
+	int blue1 = cp1[2] * cp1[2];
+
+	int red2 = cp2[0] * cp2[0];
+	int green2 = cp2[1] * cp2[1];
+	int blue2 = cp2[2] * cp2[2];
+
+	cp[0] = (unsigned char)round(sqrt(divide_round_i((mfac * red1 + fac * red2), 255)));
+	cp[1] = (unsigned char)round(sqrt(divide_round_i((mfac * green1 + fac * green2), 255)));
+	cp[2] = (unsigned char)round(sqrt(divide_round_i((mfac * blue1 + fac * blue2), 255)));
 	cp[3] = 255;
 
 	return col;
@@ -2330,8 +2330,7 @@ static void calc_area_normal(
 	BLI_mutex_init(&data.mutex);
 
 	BLI_task_parallel_range(
-			0, totnode, &data, calc_area_normal_and_center_task_cb,
-			((true & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT)); //Need to add OpenMP toggle in vpaint and wpaint
+			0, totnode, &data, calc_area_normal_and_center_task_cb, true);
 
 	BLI_mutex_end(&data.mutex);
 
@@ -2618,7 +2617,7 @@ static void calculate_average_weight(SculptThreadedTaskData *data, PBVHNode **no
 	UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
 	BLI_task_parallel_range_ex(
 			0, totnode, data, NULL, 0, do_wpaint_brush_calc_ave_weight_cb_ex,
-			((data->sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT), false);
+			true, false);
 
 	unsigned int totalHitLoops = 0;
 	double totalWeight = 0.0;
@@ -2651,28 +2650,19 @@ static void wpaint_paint_leaves(bContext *C, Object *ob, Sculpt *sd, VPaint *vp,
 	data.lcol = (unsigned int*)me->mloopcol;
 	data.me = me;
 	data.C = C;
-	sd->flags |= SCULPT_USE_OPENMP; // Need to add toggle for OpenMP
 	switch (brush->vertexpaint_tool) {
 		case PAINT_BLEND_AVERAGE:
 			calculate_average_weight(&data, nodes, totnode);
-			BLI_task_parallel_range_ex(
-					0, totnode, &data, NULL, 0, do_wpaint_brush_draw_task_cb_ex,
-					((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT), false);
+			BLI_task_parallel_range_ex( 0, totnode, &data, NULL, 0, do_wpaint_brush_draw_task_cb_ex, true, false);
 			break;
 		case PAINT_BLEND_SMUDGE:
-			BLI_task_parallel_range_ex(
-					0, totnode, &data, NULL, 0, do_wpaint_brush_smudge_task_cb_ex,
-					((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT), false);
+			BLI_task_parallel_range_ex( 0, totnode, &data, NULL, 0, do_wpaint_brush_smudge_task_cb_ex, true, false);
 			break;
 		case PAINT_BLEND_BLUR:
-			BLI_task_parallel_range_ex(
-					0, totnode, &data, NULL, 0, do_wpaint_brush_blur_task_cb_ex,
-					((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT), false);
+			BLI_task_parallel_range_ex( 0, totnode, &data, NULL, 0, do_wpaint_brush_blur_task_cb_ex, true, false);
 			break;
 		default:
-			BLI_task_parallel_range_ex(
-					0, totnode, &data, NULL, 0, do_wpaint_brush_draw_task_cb_ex,
-					((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT), false);
+			BLI_task_parallel_range_ex( 0, totnode, &data, NULL, 0, do_wpaint_brush_draw_task_cb_ex, true, false);
 			break;
 	}
 }
@@ -2886,10 +2876,6 @@ static void wpaint_stroke_done(const bContext *C, struct PaintStroke *stroke)
 		MEM_freeN(wpd);
 	}
 	
-
-	/* frees prev buffer */
-	//copy_wpaint_prev(ts->wpaint, NULL, 0);
-
 	/* and particles too */
 	if (ob->particlesystem.first) {
 		ParticleSystem *psys;
@@ -3544,7 +3530,7 @@ static void do_vpaint_brush_smudge_task_cb_ex(
 static void calculate_average_color(SculptThreadedTaskData *data, PBVHNode **nodes, int totnode) {
 	BLI_task_parallel_range_ex(
 			0, totnode, data, NULL, 0, do_vpaint_brush_calc_ave_color_cb_ex,
-			((data->sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT), false);
+			true, false);
 
 	unsigned int totalHitLoops = 0;
 	unsigned long totalColor[4] = { 0 };
@@ -3568,7 +3554,7 @@ static void calculate_average_color(SculptThreadedTaskData *data, PBVHNode **nod
 
 static void vpaint_paint_leaves(bContext *C, Sculpt *sd, VPaint *vp, VPaintData *vpd, Object *ob, Mesh *me, PBVHNode **nodes, int totnode)
 {
-	Brush *brush = ob->sculpt->cache->brush;//BKE_paint_brush(&sd->paint);
+	Brush *brush = ob->sculpt->cache->brush;
 
 	/* threaded loop over nodes */
 	SculptThreadedTaskData data = {
@@ -3580,28 +3566,19 @@ static void vpaint_paint_leaves(bContext *C, Sculpt *sd, VPaint *vp, VPaintData
 	data.lcol = (unsigned int*)me->mloopcol;
 	data.me = me;
 	data.C = C;
-	sd->flags |= SCULPT_USE_OPENMP; //Needs toggle...
 	switch (brush->vertexpaint_tool) {
 		case PAINT_BLEND_AVERAGE:
 			calculate_average_color(&data, nodes, totnode);
-			BLI_task_parallel_range_ex(
-					0, totnode, &data, NULL, 0, do_vpaint_brush_draw_task_cb_ex,
-					((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT), false);
+			BLI_task_parallel_range_ex( 0, totnode, &data, NULL, 0, do_vpaint_brush_draw_task_cb_ex, true, false);
 			break;
 		case PAINT_BLEND_BLUR:
-			BLI_task_parallel_range_ex(
-					0, totnode, &data, NULL, 0, do_vpaint_brush_blur_task_cb_ex,
-					((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT), false);
+			BLI_task_parallel_range_ex( 0, totnode, &data, NULL, 0, do_vpaint_brush_blur_task_cb_ex, true, false);
 			break;
 		case PAINT_BLEND_SMUDGE:
-			BLI_task_parallel_range_ex(
-					0, totnode, &data, NULL, 0, do_vpaint_brush_smudge_task_cb_ex,
-					((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT), false);
+			BLI_task_parallel_range_ex( 0, totnode, &data, NULL, 0, do_vpaint_brush_smudge_task_cb_ex, true, false);
 			break;
 		default:
-			BLI_task_parallel_range_ex(
-					0, totnode, &data, NULL, 0, do_vpaint_brush_draw_task_cb_ex,
-					((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT), false);
+			BLI_task_parallel_range_ex( 0, totnode, &data, NULL, 0, do_vpaint_brush_draw_task_cb_ex, true, false);
 			break;
 	}
 }
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 3dcffa2..6c308d0 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -153,7 +153,7 @@ typedef struct SculptProjectVector {
 
 /* Single struct used by all BLI_task threaded callbacks, let's avoid adding 10's of those... */
 typedef struct SculptThreadedTaskData {
-  bContext *C;
+	bContext *C;
 	Sculpt *sd;
 	Object *ob;
 	Brush *brush;
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 894c4b5..bd4e69e 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -94,8 +94,8 @@ EnumPropertyItem rna_enum_brush_vertex_tool_items[] = {
 	{PAINT_BLEND_BLUR, "BLUR", ICON_BRUSH_BLUR, "Blur", "Blur the color with surrounding values"},
 	{PAINT_BLEND_LIGHTEN, "LIGHTEN", ICON_BRUSH_LIGHTEN, "Lighten", "Use lighten blending mode while painting"},
 	{PAINT_BLEND_DARKEN, "DARKEN", ICON_BRUSH_DARKEN, "Darken", "Use darken blending mode while painting"},
-  {PAINT_BLEND_AVERAGE, "AVERAGE", ICON_BRUSH_BLUR, "Average", "Use average blending mode while painting" },
-  {PAINT_BLEND_SMUDGE, "SMUDGE", ICON_BRUSH_BLUR, "Smudge", "Use smudge blending mode while painting" },
+	{PAINT_BLEND_AVERAGE, "AVERAGE", ICON_BRUSH_BLUR, "Average", "Use average blending mode while painting" },
+	{PAINT_BLEND_SMUDGE, "SMUDGE", ICON_BRUSH_BLUR, "Smudge", "Use smudge blending mode while painting" },
 	{0, NULL, 0, NULL, NULL}
 };
 	
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index f007dce..688da80 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -675,13 +675,13 @@ static void rna_def_vertex_paint(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Restrict", "Restrict painting to vertices in the group");
 	RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
 
-  /* Mirroring */
-  prop = RNA_def_property(srna, "radial_symmetry", PROP_INT, PROP_XYZ);
-  RNA_def_property_int_sdna(prop, NULL, "radial_symm");
-  RNA_def_property_int_default(prop, 1);
-  RNA_def_property_range(prop, 1, 64);
-  RNA_def_property_ui_range(prop, 1, 32, 1, 1);
-  RNA_def_property_ui_text(prop, "Radial Symmetry Count X Axis",
+	/* Mirroring */
+	prop = RNA_def_property(srna, "radial_symmetry", PROP_INT, PROP_XYZ);
+	RNA_def_property_int_sdna(prop, NULL, "radial_symm");
+	RNA_def_property_int_default(prop, 1);
+	RNA_def_property_range(prop, 1, 64);
+	RNA_def_property_ui_range(prop, 1, 32, 1, 1);
+	RNA_def_property_ui_text(prop, "Radial Symmetry Count X Axis",
     "Number of times to copy strokes across the surface");
 }




More information about the Bf-blender-cvs mailing list