[Bf-blender-cvs] [a7242c3] master: Code cleanup: add _v2 suffix to resolve_tri/quad functions

Campbell Barton noreply at git.blender.org
Wed Mar 26 01:16:14 CET 2014


Commit: a7242c3162fd8ac28754b92c3bab8f003f912251
Author: Campbell Barton
Date:   Wed Mar 26 11:15:21 2014 +1100
https://developer.blender.org/rBa7242c3162fd8ac28754b92c3bab8f003f912251

Code cleanup: add _v2 suffix to resolve_tri/quad functions

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

M	source/blender/blenlib/BLI_math_geom.h
M	source/blender/blenlib/intern/math_geom.c
M	source/blender/render/intern/source/multires_bake.c

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

diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index 633887e..6889e4f 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -218,10 +218,10 @@ void barycentric_weights_v2_quad(const float v1[2], const float v2[2], const flo
 bool barycentric_coords_v2(const float v1[2], const float v2[2], const float v3[2], const float co[2], float w[3]);
 int barycentric_inside_triangle_v2(const float w[3]);
 
-void resolve_tri_uv(float r_uv[2], const float st[2], const float st0[2], const float st1[2], const float st2[2]);
-void resolve_quad_uv(float uv[2], const float st[2], const float st0[2], const float st1[2], const float st2[2], const float st3[2]);
-void resolve_quad_uv_deriv(float r_uv[2], float r_deriv[2][2],
-                           const float st[2], const float st0[2], const float st1[2], const float st2[2], const float st3[2]);
+void resolve_tri_uv_v2(float r_uv[2], const float st[2], const float st0[2], const float st1[2], const float st2[2]);
+void resolve_quad_uv_v2(float r_uv[2], const float st[2], const float st0[2], const float st1[2], const float st2[2], const float st3[2]);
+void resolve_quad_uv_v2_deriv(float r_uv[2], float r_deriv[2][2],
+                              const float st[2], const float st0[2], const float st1[2], const float st2[2], const float st3[2]);
 
 /* use to find the point of a UV on a face */
 void interp_bilinear_quad_v3(float data[4][3], float u, float v, float res[3]);
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index b1fd0fe..66fdaaf 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -2683,8 +2683,13 @@ void interp_cubic_v3(float x[3], float v[3], const float x1[3], const float v1[3
 
 #define IS_ZERO(x) ((x > (-DBL_EPSILON) && x < DBL_EPSILON) ? 1 : 0)
 
-/* Barycentric reverse  */
-void resolve_tri_uv(float r_uv[2], const float st[2], const float st0[2], const float st1[2], const float st2[2])
+/**
+ * Barycentric reverse
+ *
+ * Compute coordinates (u, v) for point \a st with respect to triangle (\a st0, \a st1, \a st2)"
+ */
+void resolve_tri_uv_v2(float r_uv[2], const float st[2],
+                       const float st0[2], const float st1[2], const float st2[2])
 {
 	/* find UV such that
 	 * t = u * t0 + v * t1 + (1 - u - v) * t2
@@ -2705,14 +2710,15 @@ void resolve_tri_uv(float r_uv[2], const float st[2], const float st0[2], const
 }
 
 /* bilinear reverse */
-void resolve_quad_uv(float r_uv[2], const float st[2], const float st0[2], const float st1[2], const float st2[2], const float st3[2])
+void resolve_quad_uv_v2(float r_uv[2], const float st[2],
+                        const float st0[2], const float st1[2], const float st2[2], const float st3[2])
 {
-	resolve_quad_uv_deriv(r_uv, NULL, st, st0, st1, st2, st3);
+	resolve_quad_uv_v2_deriv(r_uv, NULL, st, st0, st1, st2, st3);
 }
 
 /* bilinear reverse with derivatives */
-void resolve_quad_uv_deriv(float r_uv[2], float r_deriv[2][2],
-                           const float st[2], const float st0[2], const float st1[2], const float st2[2], const float st3[2])
+void resolve_quad_uv_v2_deriv(float r_uv[2], float r_deriv[2][2],
+                              const float st[2], const float st0[2], const float st1[2], const float st2[2], const float st3[2])
 {
 	const double signed_area = (st0[0] * st1[1] - st0[1] * st1[0]) + (st1[0] * st2[1] - st1[1] * st2[0]) +
 	                           (st2[0] * st3[1] - st2[1] * st3[0]) + (st3[0] * st0[1] - st3[1] * st0[0]);
diff --git a/source/blender/render/intern/source/multires_bake.c b/source/blender/render/intern/source/multires_bake.c
index be6d011..be11df4 100644
--- a/source/blender/render/intern/source/multires_bake.c
+++ b/source/blender/render/intern/source/multires_bake.c
@@ -200,7 +200,7 @@ static void flush_pixel(const MResolvePixelData *data, const int x, const int y)
 	multiresbake_get_normal(data, no1, data->face_index, i1);
 	multiresbake_get_normal(data, no2, data->face_index, i2);
 
-	resolve_tri_uv(fUV, st, st0, st1, st2);
+	resolve_tri_uv_v2(fUV, st, st0, st1, st2);
 
 	u = fUV[0];
 	v = fUV[1];
@@ -772,10 +772,10 @@ static void apply_heights_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm,
 
 	if (mface.v4) {
 		st3 = mtface[face_index].uv[3];
-		resolve_quad_uv(uv, st, st0, st1, st2, st3);
+		resolve_quad_uv_v2(uv, st, st0, st1, st2, st3);
 	}
 	else
-		resolve_tri_uv(uv, st, st0, st1, st2);
+		resolve_tri_uv_v2(uv, st, st0, st1, st2);
 
 	CLAMP(uv[0], 0.0f, 1.0f);
 	CLAMP(uv[1], 0.0f, 1.0f);
@@ -868,10 +868,10 @@ static void apply_tangmat_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm,
 
 	if (mface.v4) {
 		st3 = mtface[face_index].uv[3];
-		resolve_quad_uv(uv, st, st0, st1, st2, st3);
+		resolve_quad_uv_v2(uv, st, st0, st1, st2, st3);
 	}
 	else
-		resolve_tri_uv(uv, st, st0, st1, st2);
+		resolve_tri_uv_v2(uv, st, st0, st1, st2);
 
 	CLAMP(uv[0], 0.0f, 1.0f);
 	CLAMP(uv[1], 0.0f, 1.0f);
@@ -1112,10 +1112,10 @@ static void apply_ao_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, void
 
 	if (mface.v4) {
 		st3 = mtface[face_index].uv[3];
-		resolve_quad_uv(uv, st, st0, st1, st2, st3);
+		resolve_quad_uv_v2(uv, st, st0, st1, st2, st3);
 	}
 	else
-		resolve_tri_uv(uv, st, st0, st1, st2);
+		resolve_tri_uv_v2(uv, st, st0, st1, st2);
 
 	CLAMP(uv[0], 0.0f, 1.0f);
 	CLAMP(uv[1], 0.0f, 1.0f);




More information about the Bf-blender-cvs mailing list