[Bf-blender-cvs] [a7c7ae5] master: Cleanup: math lib naming

Campbell Barton noreply at git.blender.org
Tue Dec 15 08:25:56 CET 2015


Commit: a7c7ae5bf76f9b9036289fa38c2c2ad11f5e2986
Author: Campbell Barton
Date:   Tue Dec 15 18:06:24 2015 +1100
Branches: master
https://developer.blender.org/rBa7c7ae5bf76f9b9036289fa38c2c2ad11f5e2986

Cleanup: math lib naming

Rename not-very-descriptive (p1, d) -> (ray_origin, ray_direction)

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

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

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

diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index 256d2a5..9f8f010 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -181,7 +181,7 @@ bool isect_line_line_strict_v3(
         float vi[3], float *r_lambda);
 
 bool isect_ray_plane_v3(
-        const float p1[3], const float d[3],
+        const float ray_origin[3], const float ray_direction[3],
         const float plane[4],
         float *r_lambda, const bool clip);
 
@@ -206,15 +206,15 @@ bool isect_line_tri_epsilon_v3(
         const float v0[3], const float v1[3], const float v2[3],
         float *r_lambda, float r_uv[2], const float epsilon);
 bool isect_ray_tri_v3(
-        const float p1[3], const float d[3],
+        const float ray_origin[3], const float ray_direction[3],
         const float v0[3], const float v1[3], const float v2[3],
         float *r_lambda, float r_uv[2]);
 bool isect_ray_tri_threshold_v3(
-        const float p1[3], const float d[3],
+        const float ray_origin[3], const float ray_direction[3],
         const float v0[3], const float v1[3], const float v2[3],
         float *r_lambda, float r_uv[2], const float threshold);
 bool isect_ray_tri_epsilon_v3(
-        const float p1[3], const float d[3],
+        const float ray_origin[3], const float ray_direction[3],
         const float v0[3], const float v1[3], const float v2[3],
         float *r_lambda, float r_uv[2], const float epsilon);
 bool isect_tri_tri_epsilon_v3(
@@ -233,20 +233,20 @@ struct IsectRayPrecalc {
 };
 
 void isect_ray_tri_watertight_v3_precalc(
-        struct IsectRayPrecalc *isect_precalc, const float dir[3]);
+        struct IsectRayPrecalc *isect_precalc, const float ray_direction[3]);
 bool isect_ray_tri_watertight_v3(
-        const float P[3], const struct IsectRayPrecalc *isect_precalc,
+        const float ray_origin[3], const struct IsectRayPrecalc *isect_precalc,
         const float v0[3], const float v1[3], const float v2[3],
         float *r_dist, float r_uv[2]);
 /* slower version which calculates IsectRayPrecalc each time */
 bool isect_ray_tri_watertight_v3_simple(
-        const float P[3], const float dir[3],
+        const float ray_origin[3], const float ray_direction[3],
         const float v0[3], const float v1[3], const float v2[3],
         float *r_lambda, float r_uv[2]);
 
 bool isect_ray_seg_v2(
-        const float p1[3], const float d[3],
-        const float v0[3], const float v1[3],
+        const float ray_origin[2], const float ray_direction[2],
+        const float v0[2], const float v1[2],
         float *r_lambda, float *r_u);
 
 /* point in polygon */
@@ -259,19 +259,20 @@ int  isect_point_tri_v2(const float pt[2], const float v1[2], const float v2[2],
 bool isect_point_tri_v2_cw(const float pt[2], const float v1[2], const float v2[2], const float v3[2]);
 int  isect_point_tri_v2_int(const int x1, const int y1, const int x2, const int y2, const int a, const int b);
 bool isect_point_tri_prism_v3(const float p[3], const float v1[3], const float v2[3], const float v3[3]);
-bool isect_point_tri_v3(const float p[3], const float v1[3], const float v2[3], const float v3[3],
-                        float r_vi[3]);
+bool isect_point_tri_v3(
+        const float p[3], const float v1[3], const float v2[3], const float v3[3],
+        float r_isect_co[3]);
 
 /* axis-aligned bounding box */
 bool isect_aabb_aabb_v3(const float min1[3], const float max1[3], const float min2[3], const float max2[3]);
 
 typedef struct {
-	float ray_start[3];
+	float ray_origin[3];
 	float ray_inv_dir[3];
 	int sign[3];
 } IsectRayAABBData;
 
-void isect_ray_aabb_initialize(IsectRayAABBData *data, const float ray_start[3], const float ray_direction[3]);
+void isect_ray_aabb_initialize(IsectRayAABBData *data, const float ray_origin[3], const float ray_direction[3]);
 bool isect_ray_aabb(const IsectRayAABBData *data, const float bb_min[3], const float bb_max[3], float *tmin);
 
 /* other */
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 4b74ca7..e635d3c 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -1215,7 +1215,7 @@ bool isect_line_tri_epsilon_v3(
  * return non zero if it does
  */
 bool isect_ray_tri_v3(
-        const float p1[3], const float d[3],
+        const float ray_origin[3], const float ray_direction[3],
         const float v0[3], const float v1[3], const float v2[3],
         float *r_lambda, float r_uv[2])
 {
@@ -1228,19 +1228,19 @@ bool isect_ray_tri_v3(
 	sub_v3_v3v3(e1, v1, v0);
 	sub_v3_v3v3(e2, v2, v0);
 
-	cross_v3_v3v3(p, d, e2);
+	cross_v3_v3v3(p, ray_direction, e2);
 	a = dot_v3v3(e1, p);
 	if ((a > -epsilon) && (a < epsilon)) return false;
 	f = 1.0f / a;
 
-	sub_v3_v3v3(s, p1, v0);
+	sub_v3_v3v3(s, ray_origin, v0);
 
 	u = f * dot_v3v3(s, p);
 	if ((u < 0.0f) || (u > 1.0f)) return false;
 
 	cross_v3_v3v3(q, s, e1);
 
-	v = f * dot_v3v3(d, q);
+	v = f * dot_v3v3(ray_direction, q);
 	if ((v < 0.0f) || ((u + v) > 1.0f)) return false;
 
 	*r_lambda = f * dot_v3v3(e2, q);
@@ -1256,24 +1256,24 @@ bool isect_ray_tri_v3(
 
 /**
  * if clip is nonzero, will only return true if lambda is >= 0.0
- * (i.e. intersection point is along positive d)
+ * (i.e. intersection point is along positive \a ray_direction)
  *
  * \note #line_plane_factor_v3() shares logic.
  */
 bool isect_ray_plane_v3(
-        const float p1[3], const float d[3],
+        const float ray_origin[3], const float ray_direction[3],
         const float plane[4],
         float *r_lambda, const bool clip)
 {
 	float h[3], plane_co[3];
 	float dot;
 
-	dot = dot_v3v3(plane, d);
+	dot = dot_v3v3(plane, ray_direction);
 	if (dot == 0.0f) {
 		return false;
 	}
 	mul_v3_v3fl(plane_co, plane, (-plane[3] / len_squared_v3(plane)));
-	sub_v3_v3v3(h, p1, plane_co);
+	sub_v3_v3v3(h, ray_origin, plane_co);
 	*r_lambda = -dot_v3v3(plane, h) / dot;
 	if (clip && (*r_lambda < 0.0f)) {
 		return false;
@@ -1282,9 +1282,9 @@ bool isect_ray_plane_v3(
 }
 
 bool isect_ray_tri_epsilon_v3(
-        const float p1[3], const float d[3],
+        const float ray_origin[3], const float ray_direction[3],
         const float v0[3], const float v1[3], const float v2[3],
-        float *r_lambda, float uv[2], const float epsilon)
+        float *r_lambda, float r_uv[2], const float epsilon)
 {
 	float p[3], s[3], e1[3], e2[3], q[3];
 	float a, f, u, v;
@@ -1292,50 +1292,50 @@ bool isect_ray_tri_epsilon_v3(
 	sub_v3_v3v3(e1, v1, v0);
 	sub_v3_v3v3(e2, v2, v0);
 
-	cross_v3_v3v3(p, d, e2);
+	cross_v3_v3v3(p, ray_direction, e2);
 	a = dot_v3v3(e1, p);
 	if (a == 0.0f) return false;
 	f = 1.0f / a;
 
-	sub_v3_v3v3(s, p1, v0);
+	sub_v3_v3v3(s, ray_origin, v0);
 
 	u = f * dot_v3v3(s, p);
 	if ((u < -epsilon) || (u > 1.0f + epsilon)) return false;
 
 	cross_v3_v3v3(q, s, e1);
 
-	v = f * dot_v3v3(d, q);
+	v = f * dot_v3v3(ray_direction, q);
 	if ((v < -epsilon) || ((u + v) > 1.0f + epsilon)) return false;
 
 	*r_lambda = f * dot_v3v3(e2, q);
 	if ((*r_lambda < 0.0f)) return false;
 
-	if (uv) {
-		uv[0] = u;
-		uv[1] = v;
+	if (r_uv) {
+		r_uv[0] = u;
+		r_uv[1] = v;
 	}
 
 	return true;
 }
 
-void isect_ray_tri_watertight_v3_precalc(struct IsectRayPrecalc *isect_precalc, const float dir[3])
+void isect_ray_tri_watertight_v3_precalc(struct IsectRayPrecalc *isect_precalc, const float ray_direction[3])
 {
 	float inv_dir_z;
 
 	/* Calculate dimension where the ray direction is maximal. */
-	int kz = axis_dominant_v3_single(dir);
+	int kz = axis_dominant_v3_single(ray_direction);
 	int kx = (kz != 2) ? (kz + 1) : 0;
 	int ky = (kx != 2) ? (kx + 1) : 0;
 
 	/* Swap kx and ky dimensions to preserve winding direction of triangles. */
-	if (dir[kz] < 0.0f) {
+	if (ray_direction[kz] < 0.0f) {
 		SWAP(int, kx, ky);
 	}
 
 	/* Calculate the shear constants. */
-	inv_dir_z = 1.0f / dir[kz];
-	isect_precalc->sx = dir[kx] * inv_dir_z;
-	isect_precalc->sy = dir[ky] * inv_dir_z;
+	inv_dir_z = 1.0f / ray_direction[kz];
+	isect_precalc->sx = ray_direction[kx] * inv_dir_z;
+	isect_precalc->sy = ray_direction[ky] * inv_dir_z;
 	isect_precalc->sz = inv_dir_z;
 
 	/* Store the dimensions. */
@@ -1345,7 +1345,7 @@ void isect_ray_tri_watertight_v3_precalc(struct IsectRayPrecalc *isect_precalc,
 }
 
 bool isect_ray_tri_watertight_v3(
-        const float p[3], const struct IsectRayPrecalc *isect_precalc,
+        const float ray_origin[3], const struct IsectRayPrecalc *isect_precalc,
         const float v0[3], const float v1[3], const float v2[3],
         float *r_lambda, float r_uv[2])
 {
@@ -1357,9 +1357,9 @@ bool isect_ray_tri_watertight_v3(
 	const float sz = isect_precalc->sz;
 
 	/* Calculate vertices relative to ray origin. */
-	const float a[3] = {v0[0] - p[0], v0[1] - p[1], v0[2] - p[2]};
-	const float b[3] = {v1[0] - p[0], v1[1] - p[1], v1[2] - p[2]};
-	const float c[3] = {v2[0] - p[0], v2[1] - p[1], v2[2] - p[2]};
+	const float a[3] = {v0[0] - ray_origin[0], v0[1] - ray_origin[1], v0[2] - ray_origin[2]};
+	const float b[3] = {v1[0] - ray_origin[0], v1[1] - ray_origin[1], v1[2] - ray_origin[2]};
+	const float c[3] = {v2[0] - ray_origin[0], v2[1] - ray_origin[1], v2[2] - ray_origin[2]};
 
 	const float a_kx = a[kx], a_ky = a[ky], a_kz = a[kz];
 	const float b_kx = b[kx], b_ky = b[ky], b_kz = b[kz];
@@ -1423,13 +1423,13 @@ bool isect_ray_tri_watertight_v3(
 }
 
 bool isect_ray_tri_watertight_v3_simple(
-        const float P[3], const float dir[3],
+        const float ray_origin[3], const float ray_direction[3],
         const float v0[3], const float v1[3], const float v2[3],
         float *r_lambda, float r_uv[2])
 {
 	struct IsectRayPrecalc isect_precalc;
-	isect_ray_tri_watertight_v3_precalc(&isect_precalc, dir);
-	return isect_ray_tri_watertight_v3(P, &isect_precalc, v0, v1, v2, r_lambda, r_uv);
+	isect_ray_tri_watertight_v3_precalc(&isect_precalc, ray_direction);
+	return isect_ray_tri_watertight_v3(ray_origin, &isect_precalc, v0, v1, v2, r_lambda, r_uv);
 }
 
 #if 0  /* UNUSED */
@@ -1438,7 +1438,7 @@ bool isect_ray_tri_watertight_v3_simple(
  * so rays slightly outside the triangle to be considered as intersecting.
  *

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list