[Bf-blender-cvs] [3b1dad3eb67] soc-2016-pbvh-painting: Use BLI_math rounding function, replace sqrtl w/ sqrtf

Campbell Barton noreply at git.blender.org
Wed Sep 27 02:51:10 CEST 2017


Commit: 3b1dad3eb67de9175ffa35609e17da76010ec266
Author: Campbell Barton
Date:   Wed Sep 27 11:01:22 2017 +1000
Branches: soc-2016-pbvh-painting
https://developer.blender.org/rB3b1dad3eb67de9175ffa35609e17da76010ec266

Use BLI_math rounding function, replace sqrtl w/ sqrtf

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

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

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

diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index c934fc77274..54669e575d3 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -588,9 +588,9 @@ BLI_INLINE unsigned int mcol_blend(unsigned int col1, unsigned int col2, int fac
 	int g2 = cp2[1] * cp2[1];
 	int b2 = cp2[2] * cp2[2];
 
-	cp[0] = (unsigned char)round(sqrt(divide_round_i((mfac * r1 + fac * r2), 255)));
-	cp[1] = (unsigned char)round(sqrt(divide_round_i((mfac * g1 + fac * g2), 255)));
-	cp[2] = (unsigned char)round(sqrt(divide_round_i((mfac * b1 + fac * b2), 255)));
+	cp[0] = iroundf(sqrtf(divide_round_i((mfac * r1 + fac * r2), 255)));
+	cp[1] = iroundf(sqrtf(divide_round_i((mfac * g1 + fac * g2), 255)));
+	cp[2] = iroundf(sqrtf(divide_round_i((mfac * b1 + fac * b2), 255)));
 	cp[3] = 255;
 
 	return col;
@@ -3440,10 +3440,10 @@ static void do_vpaint_brush_blur_task_cb_ex(
 					if (total_hit_loops != 0) {
 						/* Use rgb^2 color averaging. */
 						char *col = (char *)(&color_final);
-						col[0] = (unsigned char)round(sqrtl(divide_round_i(blend[0], total_hit_loops)));
-						col[1] = (unsigned char)round(sqrtl(divide_round_i(blend[1], total_hit_loops)));
-						col[2] = (unsigned char)round(sqrtl(divide_round_i(blend[2], total_hit_loops)));
-						col[3] = (unsigned char)round(sqrtl(divide_round_i(blend[3], total_hit_loops)));
+						col[0] = iroundf(sqrtf(divide_round_i(blend[0], total_hit_loops)));
+						col[1] = iroundf(sqrtf(divide_round_i(blend[1], total_hit_loops)));
+						col[2] = iroundf(sqrtf(divide_round_i(blend[2], total_hit_loops)));
+						col[3] = iroundf(sqrtf(divide_round_i(blend[3], total_hit_loops)));
 
 						/* For each poly owning this vert, paint each loop belonging to this vert. */
 						for (int j = 0; j < ss->modes.vwpaint.vert_to_poly[v_index].count; j++) {
@@ -3600,9 +3600,9 @@ static void calculate_average_color(SculptThreadedTaskData *data, PBVHNode **UNU
 		total_color[2] += data->ob->sculpt->modes.vwpaint.total_color[i][2];
 	}
 	if (total_hit_loops != 0) {
-		blend[0] = (unsigned char)round(sqrtl(divide_round_i(total_color[0], total_hit_loops)));
-		blend[1] = (unsigned char)round(sqrtl(divide_round_i(total_color[1], total_hit_loops)));
-		blend[2] = (unsigned char)round(sqrtl(divide_round_i(total_color[2], total_hit_loops)));
+		blend[0] = iroundf(sqrtf(divide_round_i(total_color[0], total_hit_loops)));
+		blend[1] = iroundf(sqrtf(divide_round_i(total_color[1], total_hit_loops)));
+		blend[2] = iroundf(sqrtf(divide_round_i(total_color[2], total_hit_loops)));
 		blend[3] = 255;
 		data->vpd->paintcol = *((unsigned int *)blend);
 	}



More information about the Bf-blender-cvs mailing list