[Bf-blender-cvs] [f3d13be] master: Code Cleanup: correct fabsf/fabs/abs use

Campbell Barton noreply at git.blender.org
Tue Dec 3 23:26:54 CET 2013


Commit: f3d13bec6dbacbf2ddfba034776175cf78d628b0
Author: Campbell Barton
Date:   Wed Dec 4 09:23:29 2013 +1100
http://developer.blender.org/rBf3d13bec6dbacbf2ddfba034776175cf78d628b0

Code Cleanup: correct fabsf/fabs/abs use

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

M	source/blender/blenlib/BLI_math_vector.h
M	source/blender/blenlib/intern/math_matrix.c
M	source/blender/blenlib/intern/math_vector_inline.c
M	source/blender/editors/screen/area.c
M	source/blender/render/intern/source/shadeoutput.c

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

diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h
index 1444517..21bafef 100644
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@ -144,6 +144,7 @@ MINLINE void negate_v3_short(short r[3]);
 
 MINLINE float dot_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT;
 MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT;
+MINLINE float dot_v4v4(const float a[4], const float b[4]) ATTR_WARN_UNUSED_RESULT;
 
 MINLINE float cross_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT;
 MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3]);
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index 1f52caa..5b1f924 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -988,7 +988,7 @@ bool is_orthogonal_m4(float m[4][4])
 
 	for (i = 0; i < 4; i++) {
 		for (j = 0; j < i; j++) {
-			if (fabsf(dot_vn_vn(m[i], m[j], 4)) > 1.5f * FLT_EPSILON)
+			if (fabsf(dot_v4v4(m[i], m[j])) > 1.5f * FLT_EPSILON)
 				return 0;
 		}
 
@@ -1018,7 +1018,7 @@ bool is_orthonormal_m4(float m[4][4])
 		int i;
 
 		for (i = 0; i < 4; i++)
-			if (fabsf(dot_vn_vn(m[i], m[i], 4) - 1) > 1.5f * FLT_EPSILON)
+			if (fabsf(dot_v4v4(m[i], m[i]) - 1) > 1.5f * FLT_EPSILON)
 				return 0;
 
 		return 1;
diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c
index cdbbcc5..05be8bd 100644
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@ -595,6 +595,11 @@ MINLINE float dot_v3v3(const float a[3], const float b[3])
 	return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
 }
 
+MINLINE float dot_v4v4(const float a[4], const float b[4])
+{
+	return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
+}
+
 MINLINE float cross_v2v2(const float a[2], const float b[2])
 {
 	return a[0] * b[1] - a[1] * b[0];
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 8b89c2f..2caf318 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -160,8 +160,8 @@ static void area_draw_azone(short x1, short y1, short x2, short y2)
 	int dx = x2 - x1;
 	int dy = y2 - y1;
 
-	dx = copysign(ceilf(0.3f * fabsf(dx)), dx);
-	dy = copysign(ceilf(0.3f * fabsf(dy)), dy);
+	dx = copysign(ceilf(0.3f * abs(dx)), dx);
+	dy = copysign(ceilf(0.3f * abs(dy)), dy);
 
 	glEnable(GL_BLEND);
 	glEnable(GL_LINE_SMOOTH);
diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c
index 40a5a5d..6cb34a6 100644
--- a/source/blender/render/intern/source/shadeoutput.c
+++ b/source/blender/render/intern/source/shadeoutput.c
@@ -228,7 +228,7 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens)
 		maxz*= lar->sh_zfac;
 		maxy= lar->imat[0][1]*p1[0]+lar->imat[1][1]*p1[1]+lar->imat[2][1]*p1[2];
 
-		if (fabsf(nray[2]) < FLT_EPSILON) {
+		if (fabs(nray[2]) < FLT_EPSILON) {
 			use_yco = TRUE;
 		}
 	}




More information about the Bf-blender-cvs mailing list